|
From: <yaw...@us...> - 2006-03-08 23:17:39
|
Revision: 9 Author: yawnster Date: 2006-03-08 15:17:31 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=9&view=rev Log Message: ----------- Woops, forgot to delete the old files. Removed Paths: ------------- poc/src/OpenDocument.php5 poc/src/OpenDocumentAbstract.php5 poc/src/OpenDocumentContent.php5 poc/src/OpenDocumentContentBody.php5 poc/src/OpenDocumentContentBodyText.php5 poc/src/OpenDocumentFactory.php5 poc/src/OpenDocumentFactoryTest.php5 poc/src/OpenDocumentManifest.php5 poc/src/OpenDocumentManifestTest.php5 poc/src/OpenDocumentMeta.php5 poc/src/OpenDocumentMetaTest.php5 poc/src/OpenDocumentObjectAbstract.php5 poc/src/OpenDocumentPackage.php5 poc/src/OpenDocumentSingle.php5 poc/src/OpenDocumentStyle.php5 poc/src/TestOutput.php5 poc/src/ZipFile.php3 Deleted: poc/src/OpenDocument.php5 =================================================================== --- poc/src/OpenDocument.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocument.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,34 +0,0 @@ -<?php -/** - * OpenDocument interface - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ -interface OpenDocument { - /** - * get the whole OpenDocument as string. - */ - public function get(); - - public function getMeta(); - - public function getContent(); - - public function getStyle(); - - /** - * get mimetype of the document - * - * @return string Mimetype of the document - */ - public function getMimeType(); - - // public function getSetting(); -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentAbstract.php5 =================================================================== --- poc/src/OpenDocumentAbstract.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentAbstract.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,78 +0,0 @@ -<?php -/** - * OpenDocumentAbstract Class - * (C) by Norman Markgraf in 2006 - * - * OpenDocumentAbstract is the basic class for all OpenDocument classes - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ -require_once( "Log.php" ); - -class OpenDocumentAbstract { - /** - * - */ - const Revision = "ALPHA"; - const Release = "0.4.1"; - const Copyright = "(C) in 2006 by Norman Markgraf published under GPL 2.0"; - const PackageName = "OpenDocumentPHP"; - - protected $logger; - - protected $mimetype; - - /** - * This is the storage for all OpenDocument objects - */ - protected $DocumentObjects; - - public function __construct( $mimetype = 0 ) { - $this->logger = &Log::factory( "null", "", "OpenDocument" ); - //$this->logger = &Log::factory( "file", "d:/PHP/OpenDocumentPHP.log", "OpenDocument" ); - $this->logger->debug( "Constructing OpenDocumentAbstract." ); - - $this->DocumentObjects = array(); - - if (!empty($mimetype)) { - $this->mimetype = $mimetype; - } - } - - /** - * - */ - public function __destruct() { - $this->logger->debug( "OpenDocumentAbstract destructed." ); - $this->logger->close(); - } - - final public function getRevision() { - return self::Revision; - } - - final public function getRelease() { - return self::Release.".".self::Revision; - } - - final public function getPackageInformation() { - return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; - } - - final public function attachObserverToLogger( $observer ) { - $this->logger->attach( $observer ); - } - - final public function getMimeType() { - return $this->mimetype; - } - - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentContent.php5 =================================================================== --- poc/src/OpenDocumentContent.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentContent.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,131 +0,0 @@ -<?php -/** - * OpenDocumentContent Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -require_once "OpenDocumentObjectAbstract.php5"; -require_once "OpenDocumentContentBody.php5"; - -class OpenDocumentContent extends OpenDocumentObjectAbstract { - - private $root; - private $meta; - private $FontFaceDecl; - private $body; - private $text; - - /**I - * - */ - public function __construct( $dom=0 ) { - parent::__construct(); - $this->logger->debug( "Constructing OpenDocumentContent." ); - if (empty($dom)) { - // this is part of a package document - $this->dom = new DOMDocument( "1.0", "utf-8" ); - $this->dom->formatOutput = true; - - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-content" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); - - $this->content = $this->dom; - } else { - // this is part of a single document - $this->dom = $dom; - $this->content = $this->dom; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:content" ); - } - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); - $this->body = new OpenDocumentContentBody( $this->dom ); -/* - $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); - $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); -*/ - - } - - /** - * - */ - public function __destruct() { - unset( $this->dom ); - unset( $this->root ); - unset( $this->meta ); - unset( $this->FontFaceDecl ); - } - - public function addNoScript() { - $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:script" ) ); - } - - public function addFontFace( $name, $fontFamily ) { - $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); - $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); - $font->setAttributeNS( self::NS_SVG, "svg:font-family", $fontFamily ); - $this->FontFaceDecl->appendChild( $font ); - unset( $font ); - } - - public function addAutomaticStyles() { - - } - - public function addNoAutomaticStyles() { - $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:automatics-sytles" ) ); - } - - -/* - <text:sequence-decls> - <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> - <text:sequence-decl text:display-outline-level="0" text:name="Table"/> - <text:sequence-decl text:display-outline-level="0" text:name="Text"/> - <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> - </text:sequence-decls> - -*/ - - public function getBody() { - return $this->body; - } - - - /** - * - */ - public function commit() { - $this->root->appendChild( $this->FontFaceDecl ); - // $this->body->appendChild( $this->text ); - $this->root->appendChild( $this->body->get() ); - $this->content->appendChild( $this->root ); - $this->dom->normalize(); - $this->isCommited = true; - } - - /** - * @return - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - return $this->dom; - } - - /** - * - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentContentBody.php5 =================================================================== --- poc/src/OpenDocumentContentBody.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentContentBody.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,79 +0,0 @@ -<?php -/** - * OpenDocumentContentBody Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision: 2 $ - * @package OpenDocument.Content.Body - * @since POC 0.5 - * - * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ - */ -require_once "OpenDocumentObjectAbstract.php5"; -require_once "OpenDocumentContentBodyText.php5"; -require_once "OpenDocumentContentBodyTable.php5"; - -class OpenDocumentContentBody extends OpenDocumentObjectAbstract { - - private $DomFragment; - private $body; - - private $Fragments; - - public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing OpenDocumentContentBody." ); - - $this->dom = $dom; - $this->BodyFragment = $this->dom->createDocumentFragment(); - $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); - $this->Fragments = array(); - } - - public function commit() { - $this->logger->debug( "OpenDocumentContentBody->commit()" ); - foreach( $this->Fragments as $namespace => $class ) { - $tmp = $class->get(); - if (!empty( $tmp )) { - $this->BodyFragment->appendChild( $class->get() ); - } - } - if (!empty( $this->BodyFragment )) { - $this->body->appendChild( $this->BodyFragment ); - } - $this->isCommited = true; - } - - private function getByNamespace( $NS, $class ) { - $this->logger->debug( "OpenDocumentContentBody->getByNamespace(\"".$NS."\", \"".$class."\")" ); - if (!array_key_exists( $NS, $this->Fragments ) ) { - $this->Fragments[ $NS ] = new $class( $this->dom ); - } - return $this->Fragments[ $NS ]; - } - - public function getText() { - $this->logger->debug( "OpenDocumentContentBody->getText()" ); - return $this->getByNamespace( self::NS_TEXT, "OpenDocumentContentBodyText" ); - } - - public function getTable() { - $this->logger->debug( "OpenDocumentContentBody->getTable()" ); - return $this->getByNamespace( self::NS_TABLE, "OpenDocumentContentBodyTable" ); - } - - /** - * @return DOMDocumentFragment body fragment - */ - final public function get() { - $this->logger->debug( "OpenDocumentContentBody->get()" ); - if (!$this->isCommited) { - $this->commit(); - } - return $this->body; - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentContentBodyText.php5 =================================================================== --- poc/src/OpenDocumentContentBodyText.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentContentBodyText.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,78 +0,0 @@ -<?php -/** - * OpenDocumentContentBodyText Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision: 2 $ - * @package OpenDocument.Content.Body.Text - * @since POC 0.5 - * - * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ - */ - -class OpenDocumentContentBodyText extends OpenDocumentObjectAbstract { - - public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); - - $this->dom = $dom; - $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); - } - - public function commit() { - $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); - $this->isCommited = true; - } - - public function getTextParagraph( $styleName, $parText=0 ) { - $this->logger->debug( "OpenDocumentContentBodyText->getTextParagraph(\"".$styleName."\",\"".$parText."\")" ); - if (empty($parText)) { - $par = $this->dom->createElementNS( self::NS_TEXT, "text:p" ); - } else { - $par = $this->dom->createElementNS( self::NS_TEXT, "text:p", $parText ); - } - $par->setAttributeNS( self::NS_STYLE, "style:name", $styleName ); - return $par; - } - - public function addToText( $Node ) { - $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); - $this->text->appendChild( $Node ); - } - - public function getTextHeading( $styleName, $headText=0 ) { - $this->logger->debug( "OpenDocumentContentBodyText->getTextHeading()" ); - if (empty($headText)) { - $head = $this->dom->createElementNS( self::NS_TEXT, "text:h" ); - } else { - $head = $this->dom->createElementNS( self::NS_TEXT, "text:h", $headText ); - } - $head->setAttributeNS( self::NS_STYLE, "style:name", $styleName ); - return $head; - } - - public function addNoForms() { - $this->logger->debug( "OpenDocumentContentBodyText->addNoForms()" ); - $forms = $this->dom->createElementNS( self::NS_OFFICE, "office:forms" ); - - $forms->setAttributeNS( self::NS_FORM, "form:automatic-focus", "false" ); - $forms->setAttributeNS( self::NS_FORM, "form:apply-design-mode", "false" ); - - $this->text->appendChild( $forms ); - unset( $forms ); - } - - /** - * @return DOMDocumentFragment body fragment - */ - final public function get() { - $this->logger->debug( "OpenDocumentContentBodyText->get()" ); - if (!$this->isCommited) { - $this->commit(); - } - return $this->text; - } -} -?> \ No newline at end of file Deleted: poc/src/OpenDocumentFactory.php5 =================================================================== --- poc/src/OpenDocumentFactory.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentFactory.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,34 +0,0 @@ -<?php -/** - * OpenDocumentFactoy Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -require_once( "OpenDocumentPackage.php5" ); -require_once( "OpenDocumentSingle.php5" ); - -class OpenDocumentFactory { - -/** - * Creates a OpenDocument. - * - * @return OpenDocument - */ - static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType="application/vnd.oasis.opendocument.text" ) { - if ( $singleDocument ) { - return new OpenDocumentSingle( $mimeType ); - return 0; - } else { - return new OpenDocumentPackage( $documentName, $documentPath, $mimeType ); - } - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentFactoryTest.php5 =================================================================== --- poc/src/OpenDocumentFactoryTest.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentFactoryTest.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,78 +0,0 @@ -<?php -/** - * OpenDocumentFactoyTest Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision: 4 $ - * @package OpenDocumentTest - * - * $Id: OpenDocumentFactory.php5 4 2006-03-06 15:15:30Z nmarkgraf $ - */ -require_once "PHPUnit2/Framework/TestCase.php"; -require_once( "OpenDocumentFactory.php5" ); -require_once( "OpenDocumentSingle.php5" ); -require_once( "OpenDocumentPackage.php5" ); - -class OpenDocumentFactoryTest extends PHPUnit2_Framework_TestCase { - - function testFactoryForSingleDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); - $this->assertNotNull( $OD ); - - $this->assertType( "OpenDocumentSingle", $OD ); - - unset( $OD ); - } - - function testFactoryForMimetypeInSingleDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); - - $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly." ); - - $ODA = OpenDocumentFactory::createOpenDocument( "test.odf", "", true, "TestMimeType" ); - $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly." ); - - unset( $OD ); - unset( $ODA ); - } - - function testFactoryForPackageDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", false ); - $this->assertNotNull( $OD ); - - $this->assertType( "OpenDocumentPackage", $OD ); - - unset( $OD ); - } - - function testFactoryForMimetypeInPackageDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", false ); - - $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly." ); - - $ODA = OpenDocumentFactory::createOpenDocument( "test.odf", "", false, "TestMimeType" ); - $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly." ); - - unset( $OD ); - unset( $ODA ); - } - - -/** - * Creates a OpenDocument. - * - * @return OpenDocument - static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType="application/vnd.oasis.opendocument.text" ) { - if ( $singleDocument ) { - return new OpenDocumentSingle( $mimeType ); - return 0; - } else { - return new OpenDocumentPackage( $documentName, $documentPath, $mimeType ); - } - } - */ - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentManifest.php5 =================================================================== --- poc/src/OpenDocumentManifest.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentManifest.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,127 +0,0 @@ -<?php -/** - * OpenDocumentManifest.php - * - * Release information: - * 0.1 - 0.3 : 17/21-Feb-2006 (nm) Initial programmings - * 0.4 : 22-Feb-2006 (nm) Declared <c>getManifest<c> as deprecated. - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -require_once( "OpenDocumentObjectAbstract.php5" ); - -class OpenDocumentManifest extends OpenDocumentObjectAbstract { - const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; - const odmSYSTEM = "Manifest.dtd"; - const odmROOT = "manifest:manifest"; - - private $root; - - /** - * - */ - public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { - parent::__construct( $mimetype ); - $this->createManifestDOM(); - } - - /** - * - */ - public function __destruct() { - unset( $dom ); - unset( $root ); - unset( $mimetype ); - } - - /** - * - * @access private - */ - final private function createManifestDOM() { - $impl = new DOMImplementation; - - $dtd = $impl->createDocumentType( self::odmROOT, self::odmPUBLIC, self::odmSYSTEM ); - - $this->dom = $impl->createDocument( "", "", $dtd ); - $this->dom->encoding = "UTF-8"; - $this->dom->formatOutput = true; - - $this->root = $this->dom->createElementNS( self::NS_MANIFEST, self::odmROOT ); - - $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:media-type", $this->mimetype ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", "/" ); - - $this->root->appendChild( $node ); - - unset( $impl ); - unset( $dtd ); - unset( $node ); - } - - /** - * - */ - final public function addEntryToManifest( $fullpath, $mimetype, $size=-1, $encrypt=0 ) { - $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:mediatype", $mimetype ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", $filename ); - if ( $size >= 0 ) { - $node->setAttributeNS( self::NS_MANIFEST, "manifest:size", $size ); - } - if (!empty($encrypt)) { - $node->appendChild( $encrypt ); - } - $this->root->appendChild( $node ); - unset( $node ); - } - - /** - * - */ - final public function createEncryptionData( ) { - return $this->dom->createElmentNS( self::NS_MANIFEST, "manifest:encryption-data" ); - } - - /** - * Returns the whole OpenDocument Manifest as DOM. - * - * @access public - * - * @return DOM manifest as DOM. - */ - final public function get() { - $this->dom->appendChild( $this->root ); - $this->dom->normalize(); - return $this->dom; - } - - /** - * Same as <c>get<c>! - * - * @deprecated - */ - final public function getManifest() { - return $this->get(); - } - - /** - * Save the whole OpenDocument Manifest in a file - * - * @access public - * - * @param string name of file - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentManifestTest.php5 =================================================================== --- poc/src/OpenDocumentManifestTest.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentManifestTest.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,33 +0,0 @@ -<?php - - require_once "PHPUnit2/Framework/TestCase.php"; - require_once "OpenDocumentManifest.php5"; - -/** - * Test Class for OpenDocumentManifest - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocumentUnitTest - * - * $Id$ - */ - - class OpenDocumentManifestTest extends PHPUnit2_Framework_TestCase { - - function testConstrution() { - - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - - $ODMMT = new OpenDocumentManifest( "alternateMimeType" ); - - $this->assertNotNull( $ODMMT, "Error constructing OpenDocumentManifest with a given mimetype." ); - - } - - } - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentMeta.php5 =================================================================== --- poc/src/OpenDocumentMeta.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentMeta.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,222 +0,0 @@ -<?php -/** - * OpenDocumentMeta Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -require_once "OpenDocumentObjectAbstract.php5"; - -class OpenDocumentMeta extends OpenDocumentObjectAbstract { - - private $root; - private $meta; - - /** - * - */ - public function __construct( $dom=0 ) { - parent::__construct(); - - $this->logger->debug( "Constructing OpenDocumentMeta." ); - - if (empty($dom)) { - // this is part of a package document - $this->dom = new DOMDocument( "1.0", "utf-8" ); - $this->dom->formatOutput = true; - - $node = $this->dom->createElementNS( self::NS_OFFICE, "office:document-meta" ); - $node->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); - - $this->dom->appendChild( $node ); - $this->meta = $node; - unset( $node ); - } else { - // this is part of a single document - $this->dom = $dom; - $this->meta = $this->dom; - } - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); - } - - /** - * - */ - public function __destruct() { - unset( $dom ); - unset( $root ); - unset( $meta ); - - $this->logger->debug( "OpenDocumentMeta destructed." ); - - parent::__destruct(); - } - - public function load( $filename ) { - $tmpDom = new DOMDocument(); - - if($tmpDom->load( $filename ) === false) { - trigger_error( 'Could not parse XML contents in OpenDocument file' ); - $this->logger->crit( "Could not parse XML contents in OpenDocument file" ); - return false; - } - - $OFFICE_PREFIX = $tmpDom->getElementsByTagNameNS( self::NS_OFFICE, "*").item( 0 )->prefix; - - // Figgure out if file is part of a package or a single document; - $isSingleDoc = (count($tmpDom->getElementsByTagNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta" ))==0); - if ($isSingleDoc) { - $this->dom = $tmpDoc; - $this->meta = $tmpDoc; - } else { - $this->dom = $tmpDoc; - $this->meta = $tmtDoc->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":document-meta").item( 0 ); - } - - $this->root = $this->dom->getElementsByTageNameNS( self::NS_OFFICE, $OFFICE_PREFIX.":meta").item( 0 ); - - return true; - } - - /** - * - */ - public function addDublinCore( $dc, $value) { - $this->logger->debug( "OpenDocumentMeta->addDublinCore: ". $value ."." ); - $node = $this->dom->createElementNS( self::NS_DC, "dc:".$dc, $value ); - $this->root->appendChild( $node ); - unset( $node ); - } - - /** - * - */ - public function getDublicCore( $dc ) { - $retValue = ""; - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_DC, $dc ); - if ($nodelist->length == 1) { - $retValue = $nodelist->item( 0 )->nodeValue; - } - unset( $nodelist ); - $this->logger->debug( "OpenDocumentMeta->getDublinCore: ". $retValue ."." ); - return $retValue; - } - - /** - * - */ - public function addGenerator( $generator ) { - $lgenerator = ""; - - if (empty($generator)) { - $lgenerator = "OpenDocmentPHP/".$this->getRelease(); - } else { - $lgenerator = $generator; - } - - $this->logger->debug( "OpenDocumentMeta->addGenerator: ". $lgenerator ."." ); - - $node = $this->dom->createElementNS( self::NS_META, "meta:generator", $lgenerator ); - - $this->root->appendChild( $node ); - - unset( $lgenerator ); - } - - /** - * - */ - public function getGenerator() { - $retValue = ""; - - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "generator" ); - - if ($nodelist->length == 1) { - $retValue = $nodelist->item( 0 )->nodeValue; - } - unset( $nodelist ); - $this->logger->debug( "OpenDocumentMeta->getGenerator: ". $retValue ."." ); - return $retValue; - } - - /** - * - */ - public function addInitialCreator( $initialCreator ) { - $this->logger->debug( "OpenDocumentMeta->addInitialCreator: ". $initialCreator ."." ); - $node = $this->dom->createElementNS( self::NS_META, "meta:initial-creator", $initialCreator ); - $this->root->appendChild( $node ); - } - - /** - * - */ - public function getInitialCreator() { - $retValue = ""; - $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "initial-creator" ); - if ($nodelist->length == 1) { - $retValue = $nodelist->item( 0 )->nodeValue; - } -// unset( $nodelist ); - $this->logger->debug( "OpenDocumentMeta->getInitialCreator: ". $retValue ."." ); - return $retValue; - } - - /** - * - */ - public function addUserDefinedMetadata( $name, $type, $value ) { - $node = $this->dom->createElementNS( self::NS_META, "meta:user-defined" ); - $node->setAttributeNS( self::NS_META, "meta:name", $name ); - if ( !empty( $type ) ) { - $node->setAttributeNS( self::NS_META, "meta:type", $type ); - } - if ( !empty( $value ) ) { - $node->setAttributeNS( self::NS_META, "meta:value", $value ); - } - $this->root->appendChild( $node ); - unset( $node ); - } - - /** - * - */ - public function commit() { - $this->meta->appendChild( $this->root ); - $this->dom->normalize(); - $this->isCommited = true; - $this->logger->debug( "OpenDocumentMeta->commit()." ); - } - - /** - * @depricated - */ - final public function getMeta() { - return $this->get(); - } - - /** - * @return - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - $this->logger->debug( "OpenDocumentMeta->get()." ); - return $this->dom; - } - - /** - * - */ - final public function save( $filename ) { - $this->logger->debug( "OpenDocumentMeta->save(". $filename .")." ); - $this->get()->save( $filename ); - } - -} \ No newline at end of file Deleted: poc/src/OpenDocumentMetaTest.php5 =================================================================== --- poc/src/OpenDocumentMetaTest.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentMetaTest.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,131 +0,0 @@ -<?php - - require_once "PHPUnit2/Framework/TestCase.php"; - require_once "OpenDocumentMeta.php5"; - -/** - * Test class for OpenDocumentMeta - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocumentUnitTest - * - * $Id$ - */ - - class OpenDocumentMetaTest extends PHPUnit2_Framework_TestCase - { - /** - * namespace OpenDocument office - */ - const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; - /** - * namespace Dublin Core - */ - const NS_DC = "http://purl.org/dc/elements/1.1"; - - public function testConstructWithoutDom(){ - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $resultDom = $ODM->get(); - $this->assertNotNull($resultDom, "No result." ); - //$this->assertType(new DOMC$resultDom, new DOMDocument(), "Result is not for type DOMDocument!" ); - - $xpath = new DOMXPath( $resultDom ); - $xpath->registerNamespace( "office", self::NS_OFFICE ); - - // test for right root tag - $query = "/office:document-meta"; - $entries = $xpath->query( $query ); - $this->assertEquals( 1, $entries->length, "Wrong root tag." ); - - // test for right version - $query = '/office:document-meta[@office:version="1.0"]'; - $entries = $xpath->query( $query ); - $this->assertEquals( 1, $entries->length, "Wrong document version." ); - - // test for right body tag - $query = "/office:document-meta/office:meta"; - $entries = $xpath->query( $query ); - $this->assertEquals( 1, $entries->length, "Wrong meta tag" ); - - unset( $ODM ); - unset( $resultDom ); - unset( $query ); - unset( $entries ); - } - - public function testConstructWithDom(){ - $testDom = new DOMDocument(); - - $ODM = new OpenDocumentMeta( $testDom ); - $this->assertNotNull( $ODM ); - - $resultDom = $ODM->get(); - $this->assertNotNull($resultDom, "No result." ); - //$this->assertType($resultDom, new DOMDocument(), "Result is not for type DOMDocument!" ); - - $xpath = new DOMXPath( $resultDom ); - $xpath->registerNamespace( "office", self::NS_OFFICE ); - - - // test for right root tag - $query = "/office:meta"; - $entries = $xpath->query( $query ); - $this->assertEquals( 1, $entries->length, "Wrong meta tag" ); - - unset( $ODM ); - unset( $resultDom ); - unset( $query ); - unset( $entries ); - } - - public function testAddGetDublinCore() { - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getDublicCore( "xxx" ), "Returned Dublin Core should be empty, was not." ); - - $ODM->addDublinCore( "peek", "poke"); - $ODM->commit(); - - $this->assertEquals( "poke", $ODM->getDublicCore( "peek"), "Dublin Core entry was not correctly returned." ); - unset( $ODM ); - } - - public function testAddGetGenerator() { - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getGenerator(), "Generator should be empty, was not." ); - - $ODM->addGenerator( "TEST" ); - $ODM->commit(); - - $this->assertEquals( "TEST", $ODM->getGenerator(), "Generator was not correctly returned. (".$ODM->getGenerator().")" ); - - unset( $ODM ); - } - - public function testAddGetInitialCreator() { - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getInitialCreator(), "InitialCreator should be empty, was not." ); - - $ODM->addInitialCreator( "InitCreator" ); - $ODM->commit(); - - $this->assertEquals( "InitCreator", $ODM->getInitialCreator(), "InitialCreator was not correctly returned." ); - - unset( $ODM ); - } - - - } \ No newline at end of file Deleted: poc/src/OpenDocumentObjectAbstract.php5 =================================================================== --- poc/src/OpenDocumentObjectAbstract.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentObjectAbstract.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,117 +0,0 @@ -<?php -/** - * OpenDocumentObjectAbstract Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -require_once ( "OpenDocumentAbstract.php5" ); - -class OpenDocumentObjectAbstract extends OpenDocumentAbstract { - - /** - * namespace Dublin Core - */ - const NS_DC = "http://purl.org/dc/elements/1.1"; - - /** - * namespace OpenDocument meta - */ - const NS_META = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; - - /** - * namespace OpenDocument office - */ - const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; - - /** - * namespace OpenDocument manifest - */ - const NS_MANIFEST = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"; - - /** - * namespace OpenDocument style - */ - const NS_STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; - - /** - * namespace OpenDocument svg - */ - const NS_SVG = "urn:oasis:names:tc:openedocument:xmlsns:svg-compartible:1.0"; - - /** - * namespace OpenDocument fo (formation objects) - */ - const NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compartible:1.0"; - - /** - * namespace OpenDocument text - */ - const NS_TEXT = "urn:oasis:names:tc:opendocument:xmlns:text:1.0"; - - /** - * namespace OpenDocument draw - */ - const NS_DRAW = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; - - /** - * namespace OpenDocument table - */ - const NS_TABLE = "urn:oasis:names:tc:opendocument:xmlns:table:1.0"; - - /** - * namespace OpenDocument number - */ - const NS_NUMBER = "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; - - /** - * namespace OpenDocument chart - */ - const NS_CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; - - /** - * namespace OpenDocument form - */ - const NS_FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; - - - protected $dom; - - protected $isCommited; - - /** - * - */ - public function __construct( $mimetype = 0 ) { - parent::__construct( $mimetype ); - $this->logger->debug( "Constructing OpenDocumentObjectAbstract." ); - $this->isCommited = false; - } - - /** - * - */ - public function __destruct() { - $this->logger->debug( "OpenDocumentObjectAbstract destructed." ); - parent::__destruct(); - } - - public function get() { - return $this->dom; - } - - /** - * - */ - public function save( $filename ) { - $tmp =& $this->dom; - - $tmp->save( $filename ); - } -} -?> \ No newline at end of file Deleted: poc/src/OpenDocumentPackage.php5 =================================================================== --- poc/src/OpenDocumentPackage.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentPackage.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,242 +0,0 @@ -<?php -/** - * OpenDocumentPackage Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ -require_once( "OpenDocumentAbstract.php5" ); -require_once( "OpenDocumentObjectAbstract.php5" ); -require_once( "OpenDocumentManifest.php5" ); -require_once( "OpenDocumentMeta.php5" ); -require_once( "OpenDocumentContent.php5" ); -require_once( "OpenDocumentStyle.php5" ); -require_once( "OpenDocument.php5" ); -require_once( "ZipFile.php3" ); -require_once( "Log.php" ); - -class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { - private $manifest; - private $packagename; - private $packagetmp; - private $zip; - private $isCommited; - // - public $tmp = "c:/TEMP/"; - public $path = ""; - - /** - * - */ - public function __construct( $documentName=0, $documentPath=0, $mimetype="application/vnd.oasis.opendocument.text" ) { - parent::__construct( $mimetype ); - - $this->logger->debug( "Constructing OpenDocumentPackage." ); - - $this->isCommited = false; - - $this->logger->debug( "Generating ZipFile object." ); - $this->zip = new ZipFile; - $this->logger->debug( "Generating OpenDocumentManifest with mimetype \"".$this->getMimeType()."\"." ); - $this->manifest = new OpenDocumentManifest( $this->getMimeType() ); - - if ( !empty( $documentName ) ) { - $this->setPackageName( $documentName ); - if ( !empty( $documentPath ) ) { - $this->path = $documentPath; - } - } - } - - /** - * - */ - public function __destruct() { - $this->logger->debug( "Destructing OpenDocumentPackage." ); - $this->removeTmpPackage(); - - unset( $this->manifest ); - unset( $this->packagename ); - unset( $this->packagetmp ); - unset( $this->tmp ); - unset( $this->path ); - - $this->logger->debug( "OpenDocumentPackage destructed." ); - - parent::__destruct(); - } - - /** - * - */ - public function createPackage() { - //$this->compartibility->makeDir( $this->packagetmp ); - } - - /** - * - */ - private function writeDOMToPackage( $fullpath, $dom ) { - //$dom->save( str_replace( "\\", "/", $this->packagetmp . $fullpath) ); - $tmp = str_replace( "\\", "/", $fullpath ); - - $this->logger->debug( "Write DOM to package, use fullpath \"" . $tmp . "\"." ); - $this->zip->addFile( $dom->saveXML(), $tmp ); - - unset( $tmp ); - } - - /** - * - */ - public function writeZIPFile( $data, $alt=0 ) { - if (empty($alt)) { - $tmp = $this->path . $this->packagename; - } else { - $tmp = $alt; - } - clearstatcache(); - - $this->logger->debug( "OpenDocumentPackage->writeZIPFile: Write zip file to \"". $tmp ."\"" ); - - if ( file_exists( $tmp ) ) { - $this->logger->warning( "OpenDocumentPackage->writeZIPFile: Found old file \"". $tmp ."\", so I remove it first!" ); - unlink( $tmp ); - } - $handle = fopen( $tmp, "wb" ); - fputs( $handle, $data ); - fclose( $handle ); - unset( $tmp ); - } - - /** - * - */ - private function removeTmpPackage() { - // $this->compartibility->removeDir( $this->packagetmp ); - } - - /** - * - */ - private function makeSubDir( $path ) { - //$this->compartibility->makeDir( $this->packagetmp . $this->compartibility->sep . $path ); - } - - /** - * - */ - public function setPackageName( $filename ) { - global $logger; - $this->logger->debug( "OpenDocumentPackage->setPackageName(" . $filename . ")." ); - $this->packagename = $filename; - //$this->packagetmp = $this->tmp . $filename . ".tmp" . $this->compartibility->sep; - $this->packagetmp = $this->tmp . $filename . ".tmp/"; - $this->logger->debug( "OpenDocumentPackage->set packagetmp to \"" . $this->packagetmp . "\" ..." ); - } - - /** - * - */ - public function getPackageName() { - return $this->packagename; - } - - /** - * - */ - public function addManifest( $manifest ) { - $this->logger->debug( "OpenDocumentPackage->addManifest(...)." ); - $this->manifest = $manifest; - } - - - /** - * - */ - public function addImage( $fullpath, $origimage, $mimetype ) { - $this->copyFileToPackage( $origimage, $fullpath ); - $this->makeSubDir( "Pictures" ); - $this->manifest->addEntryToManifest( $fullpath, $mimetype ); - } - - /** - * - */ - public function addXMLDocument( $fullpath, $dom, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentPackage->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); - - $this->manifest->addEntryToManifest( $fullpath, $mimetype ); - $this->writeDOMToPackage( $fullpath, $dom ); - } - - private function commit() { - $this->logger->debug( "OpenDocumentPackage->commit()." ); - foreach($this->DocumentObjects as $key => $docObj) { - $this->logger->debug( "OpenDocumentPackage->commit: found \"" . $key . "\" in DocumentObjects array." ); - switch ($key) { - case "meta" : - $this->addXMLDocument( "meta.xml", $docObj->get() ); - break; - case "style" : - $this->addXMLDocument( "style.xml", $docObj->get() ); - break; - case "content" : - $this->addXMLDocument( "content.xml", $docObj->get() ); - break; -/* - case "settings" : - $this->addXMLDocument( "settings.xml", $dom ); - break; -*/ - } - } - - $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->manifest->getManifest() ); - $this->logger->debug( "OpenDocumentPackage->commit: Write mimetype \"". $this->getMimeType()."\" to file \"mimetype\"..." ); - $this->zip->addFile( $this->getMimeType(), "mimetype" ); - $this->logger->debug( "OpenDocumentPackage->commit: Commited package named \"" . $this->packagename . "\"..." ); - - $this->isCommited = true; - } - - public function get() { - if (!($this->isCommited)) { - $this->commit(); - } - $this->logger->debug( "OpenDocumentPackage->get()" ); - return $this->zip->file(); - } - - public function save( $altFilename=0 ) { - $this->writeZIPFile( $this->get() ); - } - - public function getMeta() { - if (!array_key_exists ( "meta", $this->DocumentObjects) ) { - $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta(); - } - return $this->DocumentObjects[ "meta" ]; - } - - public function getContent() { - if (!array_key_exists ( "content", $this->DocumentObjects) ) { - $this->DocumentObjects[ "content" ] = new OpenDocumentContent(); - } - return $this->DocumentObjects[ "content" ]; - } - - public function getStyle() { - if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = new OpenDocumentStyle(); - } - return $this->DocumentObjects[ "style" ]; - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentSingle.php5 =================================================================== --- poc/src/OpenDocumentSingle.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentSingle.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,108 +0,0 @@ -<?php -/** - * OpenDocumentSingle Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision: 3 $ - * @package OpenDocument - * - * $Id: OpenDocumentPackage.php5 3 2006-03-04 20:33:26Z nmarkgraf $ - */ -require_once( "OpenDocumentAbstract.php5" ); -require_once( "OpenDocumentObjectAbstract.php5" ); -require_once( "OpenDocumentManifest.php5" ); -require_once( "OpenDocumentMeta.php5" ); -require_once( "OpenDocumentContent.php5" ); -require_once( "OpenDocumentStyle.php5" ); -require_once( "OpenDocument.php5" ); -require_once( "ZipFile.php3" ); -require_once( "Log.php" ); - -class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { - private $isCommited; - private $dom; - - /** - * - */ - public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { - parent::__construct( $mimetype ); - - $this->logger->debug( "Constructing OpenDocumentSingle." ); - - $this->isCommited = false; - - $this->dom = new DOMDocument( "1.0", "utf-8" ); - } - - /** - * - */ - public function __destruct() { - $this->logger->debug( "OpenDocumentSingle destructed." ); - - parent::__destruct(); - } - - /** - * - */ - public function addImage( $fullpath, $origimage, $mimetype ) { - $this->copyFileToPackage( $origimage, $fullpath ); - $this->makeSubDir( "Pictures" ); - $this->manifest->addEntryToManifest( $fullpath, $mimetype ); - } - - /** - * - */ - public function addXMLDocument( $fullpath, $domFrag, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); - $this->dom->appendChild( $domFrag ); - } - - private function commit() { - $this->logger->debug( "OpenDocumentSingle->commit()" ); - foreach( $this->DocumentObjects as $key => $class) { - $class->commit(); - } - $this->isCommited = true; - } - - public function get() { - if (!($this->isCommited)) { - $this->commit(); - } - $this->logger->debug( "OpenDocumentSingle->get()" ); - return $this->dom->saveXML(); - } - - public function save( $altFilename=0 ) { - $this->writeZIPFile( $this->get() ); - } - - public function getMeta() { - if (!array_key_exists ( "meta", $this->DocumentObjects) ) { - $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta( $this->dom ); - } - return $this->DocumentObjects[ "meta" ]; - } - - public function getContent() { - if (!array_key_exists ( "content", $this->DocumentObjects) ) { - $this->DocumentObjects[ "content" ] = new OpenDocumentContent( $this->dom ); - } - return $this->DocumentObjects[ "content" ]; - } - - public function getStyle() { - if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = new OpenDocumentStyle( $this->dom ); - } - return $this->DocumentObjects[ "style" ]; - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentStyle.php5 =================================================================== --- poc/src/OpenDocumentStyle.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/OpenDocumentStyle.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,164 +0,0 @@ -<?php -/** - * OpenDocumentStyle Class - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * $Id$ - */ - -class OpenDocumentStyle extends OpenDocumentObjectAbstract { - - private $root; - private $style; - private $FontFaceDecl; - private $Styles; - private $DefaultStyles; - /** - * - */ - public function __construct( $dom=0 ) { - parent::__construct(); - - if (empty($dom)) { - // this is part of a package document - $this->dom = new DOMDocument( "1.0", "utf-8" ); - $this->dom->formatOutput = true; - - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document-styles" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); - - $this->style = $this->dom; - } else { - // this is part of a single document - $this->dom = $dom; - $this->style = $this->dom; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); - } - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); - $this->Styles = array(); - $this->DefaultStyles = array(); - } - - /** - * - */ - public function __destruct() { - unset( $this->dom ); - unset( $this->root ); - unset( $this->style ); - } - - public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { - $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); - $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); - $font->setAttributeNS( self::NS_SVG, "svg:font-family", $fontFamily ); - if (!empty($genericFamily)) { - $font->setAttributeNS( self::NS_STYLE, "style:font-family-genric", $genericFamily ); - } - if (!empty($fontPitch)) { - $font->setAttributeNS( self::NS_STYLE, "style:font-pitch", $fontPitch ); - } - if (!empty($fontCharset)) { - $font->setAttributeNS( self::NS_STYLE, "style:font-charset", $fontCharset ); - } - $this->FontFaceDecl->appendChild( $font ); - unset( $font ); - } - - public function getDom() { - return $this->dom; - } - - /** - * - * common family names: graphic, paragraph, table, table-row - */ - public function getDefaultStyle( $family=0 ) { - if (!empty($gamily) && array_key_exists($family, $this->DefaultStyles) ) { - return $this->DefaultStyles[$name]; - } else { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:default-style" ); - if (!empty($family)) { - $node->setAttributeNS( self::NS_STYLE, "style:family", $family ); - } - return $node; - } - } - /** - * - * common family names: graphic, paragraph, table, table-row - */ - public function addDefaultStyle( $DefaultStyle, $family=0 ) { - if (empty($family)) { - $this->DefaultStyles[] = $DefaultStyle; - } else { - $this->DefaultStyles[$name] = $DefaultStyle; - } - } - - public function getStyle( $name ) { - if (array_key_exists($name, $this->Styles) ) { - return $this->Styles[$name]; - } else { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:style" ); - $node->setAttributeNS( self::NS_STYLE, "style:name", $name ); - return $node; - } - } - - public function addStyle( $Style, $name=0 ) { - if (empty($name)) { - $this->Styles[] = $Style; - } else { - $this->Styles[$name] = $Style; - } - } - - - /** - * - */ - public function commit() { - $this->root->appendChild( $this->FontFaceDecl ); - $styleStyle = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); - - // Add all DefaultStyles - foreach( $this->DefaultStyles as $aDefaultStyle) { - $styleStyle->appendChild( $aDefaultStyle ); - } - - // Add all Styles - foreach( $this->Styles as $aStyle) { - $styleStyle->appendChild( $aStyle ); - } - $this->root->appendChild( $styleStyle ); - - $this->style->appendChild( $this->root ); - $this->dom->normalize(); - $this->isCommited = true; - } - - /** - * @return - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - return $this->dom; - } - - /** - * - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } - -} - -?> \ No newline at end of file Deleted: poc/src/TestOutput.php5 =================================================================== --- poc/src/TestOutput.php5 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/TestOutput.php5 2006-03-08 23:17:31 UTC (rev 9) @@ -1,170 +0,0 @@ -<?php -/** - * SampleClass produces a little OpenDocument and send it to the client - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument.Samples - * - * $Id$ - */ - -require_once( "OpenDocumentFactory.php5" ); -require_once( "Log/observer.php" ); - -class SampleClass { - - private $logger; - - function __construct() { - /* ***TO DO *** This raises a warning ... - // $conf = array( "mode" => 0600 ); - $this->logger = &Log_observer::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); - $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); - */ - - /* - Console output: - $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); - - File output: - $this->logger = &Log_observer::factory( "file", "OpenDocument.log", "OpenDocument" ); - */ - } - - function makeMeta( $meta ) { - $meta->addDublinCore( "title", "This is a test!" ); - $meta->addDublinCore( "creator", "Norman Markgraf" ); - $meta->addDublinCore( "language", "en-EN" ); - $meta->addGenerator( "" ); - $meta->addInitialCreator( "Norman Markgraf" ); - } - - function makeContent( $content ) { - $content->addNoScript(); - - $content->addFontFace( "Test", "Tahoma" ); - - $content->addNoAutomaticStyles(); - - $text = $content->getBody()->getText(); - - $text->addNoForms(); - - $text->addToText( $text->getTextHeading( "Heading", "The first step" ) ); - $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); - } - - function makeStyle( $style ) { - $NS_STYLE = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; - $NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compartible:1.0"; - - $style->addFontFace( "Test", "Tahoma" ); - - // Set default style - $defStyle = $style->getDefaultStyle( "paragraph" ); - - $defProp = $style->getDom()->createElementNS( $NS_STYLE, "style:paragraph-properties" ); - $defProp->setAttributeNS( $NS_FO, "fo:hypenation-ladder-count", "no-limit" ); - $defProp->setAttributeNS( $NS_STYLE, "style:text-autospace", "ideograph-alpha" ); - $defProp->setAttributeNS( $NS_STYLE, "style:punctuation-wrap", "hanging" ); - $defProp->setAttributeNS( $NS_STYLE, "style:line-break", "strict" ); - $defProp->setAttributeNS( $NS_STYLE, "style:tab-stop-distance", "1.251cm" ); - $defProp->setAttributeNS( $NS_STYLE, "style:writeing-mode", "page" ); - $defStyle->appendChild( $defProp ); - - $defProp = $style->getDom()->createElementNS( $NS_STYLE, "style:text-properties" ); - $defProp->setAttributeNS( $NS_FO, "fo:font-size", "12pt" ); - $defProp->setAttributeNS( $NS_FO, "fo:language", "de" ); - $defProp->setAttributeNS( $NS_FO, "fo:country", "DE" ); - $defProp->setAttributeNS( $NS_FO, "fo:hyphenate", "false" ); - $defProp->setAttributeNS( $NS_FO, "fo:hypenation-remain-char-count", "2" ); - $defProp->setAttributeNS( $NS_FO, "fo:hypenation-push-char-count", "2" ); - $defProp->setAttributeNS( $NS_STYLE, "style:use-window-font-color", "true" ); - $defProp->setAttributeNS( $NS_STYLE, "style:font-name", "Times New Roman" ); - $defProp->setAttributeNS( $NS_STYLE, "style:font-name-asian", "Arial Unicode MS" ); - $defProp->setAttributeNS( $NS_STYLE, "style:font-size-asian", "12pt" ); - $defProp->setAttributeNS( $NS_STYLE, "style:language-asian", "none" ); - $defProp->setAttributeNS( $NS_STYLE, "style:country-asian", "none" ); - $defProp->setAttributeNS( $NS_STYLE, "style:font-name-complex", "Tahoma" ); - $defProp->setAttributeNS( $NS_STYLE, "style:font-site-complex", "12pt" ); - $defProp->setAttributeNS( $NS_STYLE, "style:language-complex", "none" ); - $defProp->setAttributeNS( $NS_STYLE, "style:country-complex", "none" ); - $defStyle->appendChild( $defProp ); - - $style->addDefaultStyle( $defStyle ); - - //Set a style - $aStyle = $style->getStyle( "Paragraph" ); - $aStyle->setAttributeNS ( $NS_STYLE, "style:family", "paragraph" ); - $aStyle->setAttributeNS ( $NS_STYLE, "style:class", "text" ); - - $style->addStyle( $aStyle, "Paragraph" ); - - //Set a style - $aStyle = $style->getStyle( "Heading" ); - $aStyle->setAttributeNS ( $NS_STYLE, "style:family", "paragraph" ); - $aStyle->setAttributeNS ( $NS_STYLE, "style:class", "text" ); - - $aStyleProp = $style->getDom()->createElementNS( $NS_STYLE, "style:paragraph-properties" ); - $aStyleProp->setAttributeNS ( $NS_FO, "fo:margin-top", "0.423cm" ); - $aStyleProp->setAttributeNS ( $NS_FO, "fo:margin-bottom", "0.212cm" ); - $aStyleProp->setAttributeNS ( $NS_FO, "fo:keep-with-next", "always" ); - $aStyle->appendChild( $aStyleProp ); - - $aStyleProp = $style->getDom()->createElementNS( $NS_STYLE, "style:text-properties" ); - $aStyleProp->setAttributeNS ( $NS_FO, "fo:font-size", "20pt" ); - $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name", "Arial" ); - $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name-asian", "MS Mincho" ); - $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-size-asian", "20pt" ); - $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-name-complex", "Tahoma1" ); - $aStyleProp->setAttributeNS ( $NS_STYLE, "style:font-size-complex", "20pt" ); - $aStyle->appendChild( $aStyleProp ); - - $style->addStyle( $aStyle, "Paragraph" ); - } - - function run() { - if (!function_exists('gzencode')) { - $out = "<p>You have to enable zlib at compile time of your PHP! "; - $out .= "use <emph>--with-zlib=[DIR]</emph> at the <emph>configure</emph> "; - $out .= "procedure</p>"; - echo $out; - return; - } - - $DocumentName = "test.odt"; -/* - header( "Content-type: application/odt" ); - header( "Content-Disposition: attachment; filename=".$DocumentName ); - */ - - // Get a OpenDocument object from the factory: - - $SingleDocument = true; - - $TestDoc = OpenDocumentFactory::createOpenDocument( - $DocumentName, - "D:/PHP/OpenDocument/", - $SingleDocument - ); - - /* - $TestDoc->attachObserverToLogger( $this->logger ); - */ - - $this->makeMeta( $TestDoc->getMeta() ); - $this->makeStyle( $TestDoc->getStyle() ); - $this->makeContent( $TestDoc->getContent() ); - - echo $TestDoc->get(); - - //$TestDoc->save(); - } -} - - $TestOutput = new SampleClass(); - $TestOutput->run(); - -?> Deleted: poc/src/ZipFile.php3 =================================================================== --- poc/src/ZipFile.php3 2006-03-08 23:15:08 UTC (rev 8) +++ poc/src/ZipFile.php3 2006-03-08 23:17:31 UTC (rev 9) @@ -1,184 +0,0 @@ -<?php -/** - * Zip file creation class. - * Makes zip files. - * - * Based on : - * - * http://www.zend.com/codex.php?id=535&single=1 - * By Eric Mueller <er...@th...> - * - * http://www.zend.com/codex.php?id=470&single=1 - * by Denis125 <web...@at...> - * - * a patch from Peter Listiak <ml...@us...> for last modified - * date and time of the compressed file - * - * Official ZIP file format: http://www.pkware.com/appnote.txt - * - * @access public - */ -class ZipFile -{ - /** - * Array to store compressed data - * - * @var array $datasec - */ - var $datasec = array(); - - /** - * Central directory - * - * @var array $ctrl_dir - */ - var $ctrl_dir = array(); - - /** - * End of central directory record - * - * @var string $eof_ctrl_dir - */ - var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; - - /** - * Last offset position - * - * @var integer $old_offset - */ - var $old_offset = 0; - - - /** - * Converts an Unix timestamp to a four byte DOS date and time format (date - * in high two bytes, time in low two bytes allowing magnitude comparison). - * - * @param integer the current Unix timestamp - * - * @return integer the current date in a four byte DOS format - * - * @access private - */ - function unix2DosTime($unixtime = 0) { - $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); - - if ($timearray['year'] < 1980) { - $timearray['year'] = 1980; - $timearray['mon'] = 1; - $timearray['mday'] = 1; - $timearray['hours'] = 0; - $timearray['minutes'] = 0; - $timearray['seconds'] = 0; - } // end if - - return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | - ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); - } // end of the 'unix2DosTime()' method - - - /** - * Adds "file" to archive - * - * @param string file contents - * @param string name of the file in the archive (may contains the path) - * @param integer the current timestamp - * - * @access public - */ - function addFile($data, $name, $time = 0) - { - $name = str_replace('\\', '/', $name); - - $dtime = dechex($this->unix2DosTime($time)); - $hexdtime = '\x' . $dtime[6] . $dtime[7] - . '\x' . $dtime[4] . $dtime[5] - . '\x' . $dtime[2] . $dtime[3] - . '\x' . $dtime[0] . $dtime[1]; - eval('$hexdtime = "' . $hexdtime . '";'); - - $fr = "\x50\x4b\x03\x04"; - $fr .= "\x14\x00"; // ver needed to extract - $fr .= "\x00\x... [truncated message content] |