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] |
From: <nma...@us...> - 2006-03-09 08:45:09
|
Revision: 10 Author: nmarkgraf Date: 2006-03-09 00:44:32 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=10&view=rev Log Message: ----------- - Minor bugfix. Log/null.php should be found by __autoload now. - Added Alex to the author list and enable svn:keywords on his commits. Modified Paths: -------------- poc/src/OpenDocument.php poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentContent.php poc/src/OpenDocumentContentBody.php poc/src/OpenDocumentContentBodyText.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentStyle.php poc/src/TestOutput.php Property Changed: ---------------- poc/src/OpenDocument.php poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentContent.php poc/src/OpenDocumentContentBody.php poc/src/OpenDocumentContentBodyText.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentStyle.php poc/src/TestOutput.php poc/src/ZipFile.php Modified: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocument.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 5 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocument.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + * $Id$ */ interface OpenDocument { /** Property changes on: poc/src/OpenDocument.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentAbstract.php 2006-03-09 08:44:32 UTC (rev 10) @@ -7,10 +7,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 6 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + * $Id$ */ class OpenDocumentAbstract { Property changes on: poc/src/OpenDocumentAbstract.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentContent.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 6 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentContent.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + * $Id$ */ class OpenDocumentContent extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentContent.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentContentBody.php =================================================================== --- poc/src/OpenDocumentContentBody.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentContentBody.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,11 +4,11 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 2 $ + * @version $Revision$ * @package OpenDocument.Content.Body * @since POC 0.5 * - * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + * $Id$ */ class OpenDocumentContentBody extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentContentBody.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentContentBodyText.php =================================================================== --- poc/src/OpenDocumentContentBodyText.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentContentBodyText.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,11 +4,11 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 2 $ + * @version $Revision$ * @package OpenDocument.Content.Body.Text * @since POC 0.5 * - * $Id: OpenDocumentContent.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + * $Id$ */ class OpenDocumentContentBodyText extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentContentBodyText.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentFactory.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,17 +4,17 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 7 $ + * @author Alex Latchford <yan...@us...> + * @version $Revision$ * @package OpenDocument + * @since 0.4.0 * - * $Id: OpenDocumentFactory.php5 7 2006-03-08 10:31:35Z nmarkgraf $ + * $Id$ */ function __autoload($class_name) { - if($class_name != 'Log_null') - { - require_once("$class_name.php"); - } + // Classes in subdirectories have '_' instead of '/' or '\\' in their names. + require_once( strtr ( $class_name, "_", "/" ) . ".php" ); /* } class OpenDocumentFactory { Property changes on: poc/src/OpenDocumentFactory.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 4 $ + * @version $Revision$ * @package OpenDocumentTest * - * $Id: OpenDocumentFactory.php5 4 2006-03-06 15:15:30Z nmarkgraf $ + * $Id$ */ require_once "PHPUnit2/Framework/TestCase.php"; require_once( "OpenDocumentFactory.php" ); Property changes on: poc/src/OpenDocumentFactoryTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentManifest.php 2006-03-09 08:44:32 UTC (rev 10) @@ -8,10 +8,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 5 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentManifest.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + * $Id$ */ class OpenDocumentManifest extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentManifest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentManifestTest.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 3 $ + * @version $Revision$ * @package OpenDocumentUnitTest * - * $Id: OpenDocumentManifestTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + * $Id$ */ require_once "PHPUnit2/Framework/TestCase.php"; require_once "OpenDocumentManifest.php"; Property changes on: poc/src/OpenDocumentManifestTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentMeta.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 3 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentMeta.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + * $Id$ */ class OpenDocumentMeta extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentMeta.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentMetaTest.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 3 $ + * @version $Revision$ * @package OpenDocumentUnitTest * - * $Id: OpenDocumentMetaTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + * $Id$ */ require_once "PHPUnit2/Framework/TestCase.php"; require_once "OpenDocumentMeta.php"; Property changes on: poc/src/OpenDocumentMetaTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 6 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentObjectAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + * $Id$ */ class OpenDocumentObjectAbstract extends OpenDocumentAbstract { Property changes on: poc/src/OpenDocumentObjectAbstract.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentPackage.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 5 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentPackage.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + * $Id$ */ class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { Property changes on: poc/src/OpenDocumentPackage.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentSingle.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 3 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentPackage.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + * $Id$ */ class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { Property changes on: poc/src/OpenDocumentSingle.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/OpenDocumentStyle.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,10 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 2 $ + * @version $Revision$ * @package OpenDocument * - * $Id: OpenDocumentStyle.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + * $Id$ */ class OpenDocumentStyle extends OpenDocumentObjectAbstract { Property changes on: poc/src/OpenDocumentStyle.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/TestOutput.php =================================================================== --- poc/src/TestOutput.php 2006-03-08 23:17:31 UTC (rev 9) +++ poc/src/TestOutput.php 2006-03-09 08:44:32 UTC (rev 10) @@ -4,10 +4,12 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @version $Revision: 6 $ - * @package OpenDocument.Samples + * @author Alex Latchford <yan...@us...> + * @version $Revision$ + * @package OpenDocument_Samples + * @since 0.4.0 * - * $Id: TestOutput.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + * $Id$ */ require_once( "OpenDocumentFactory.php" ); Property changes on: poc/src/TestOutput.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Property changes on: poc/src/ZipFile.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yaw...@us...> - 2006-03-09 19:29:19
|
Revision: 11 Author: yawnster Date: 2006-03-09 11:29:11 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=11&view=rev Log Message: ----------- - Small bug fixes within TestOutput.php. Fixed warning within __construct(). - Defined OpenDocumentFactory as the top-level class. @ Norman: its yawnster, not yanister :P Modified Paths: -------------- poc/src/OpenDocumentFactory.php poc/src/TestOutput.php Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-09 08:44:32 UTC (rev 10) +++ poc/src/OpenDocumentFactory.php 2006-03-09 19:29:11 UTC (rev 11) @@ -4,7 +4,7 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yan...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @since 0.4.0 @@ -14,10 +14,10 @@ function __autoload($class_name) { // Classes in subdirectories have '_' instead of '/' or '\\' in their names. - require_once( strtr ( $class_name, "_", "/" ) . ".php" ); /* + require_once( strtr ( $class_name, "_", "/" ) . ".php" ); } -class OpenDocumentFactory { +final class OpenDocumentFactory { /** * Creates a OpenDocument. Modified: poc/src/TestOutput.php =================================================================== --- poc/src/TestOutput.php 2006-03-09 08:44:32 UTC (rev 10) +++ poc/src/TestOutput.php 2006-03-09 19:29:11 UTC (rev 11) @@ -4,7 +4,7 @@ * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yan...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument_Samples * @since 0.4.0 @@ -20,19 +20,11 @@ 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" ); - */ + $conf = array( "mode" => 0600 ); + // File Output: + $this->logger = &Log::factory( "file", "OpenDocument.log", "OpenDocument", $conf ); + // Console Output: + $this->logger = &Log::factory( "console", "", "OpenDocument" ); } function makeMeta( $meta ) { @@ -176,8 +168,6 @@ $TestOutput->run($SingleDocument); } - - ?> <html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-10 10:46:17
|
Revision: 12 Author: nmarkgraf Date: 2006-03-10 02:45:55 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=12&view=rev Log Message: ----------- Some minor bug fixes: - Added new directory to src /samples with two new php files TestInput.php and TestOutput.php. - Removed old TestOutput.php - Added a new method to OpenDocumentMeta.php (addCreationDate). - Removed a typo in OpenDocumentFactory.php - Fixed a typo in OpenDocumentObjectAbstract.php (NS_DC must have a "/" at the end!) Modified Paths: -------------- poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentPackage.php Added Paths: ----------- poc/src/samples/ poc/src/samples/TestInput.php poc/src/samples/TestOutput.php Removed Paths: ------------- poc/src/TestOutput.php Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentAbstract.php 2006-03-10 10:45:55 UTC (rev 12) @@ -18,7 +18,7 @@ * */ const Revision = "ALPHA"; - const Release = "0.4.1"; + const Release = "0.4.2"; const Copyright = "(C) in 2006 by Norman Markgraf published under GPL 2.0"; const PackageName = "OpenDocumentPHP"; Modified: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentManifest.php 2006-03-10 10:45:55 UTC (rev 12) @@ -102,15 +102,6 @@ } /** - * Same as <c>get<c>! - * - * @deprecated - */ - final public function getManifest() { - return $this->get(); - } - - /** * Save the whole OpenDocument Manifest in a file * * @access public Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentManifestTest.php 2006-03-10 10:45:55 UTC (rev 12) @@ -14,7 +14,7 @@ class OpenDocumentManifestTest extends PHPUnit2_Framework_TestCase { - function testConstrution() { + function testConstruction() { $ODM = new OpenDocumentManifest(); @@ -26,6 +26,18 @@ } + function testEmptyManifest() { + $ODM = new OpenDocumentManifest(); + + $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + + $this->assertNotNull( $ODM->get(), "Returned value of OpenDocumentManifest->get() is NULL." ); + + $EmptyManifest = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE manifest:manifest PUBLIC \"-//OpenOffice.org//DTD Manifest 1.0//EN\" \"Manifest.dtd\">\n<manifest:manifest xmlns:manifest=\"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0\">\n <manifest:file-entry manifest:media-type=\"application/vnd.oasis.opendocument.text\" manifest:full-path=\"/\"/>\n</manifest:manifest>"; + + $this->assertEquals( $ODM->get()->saveXML(), $EmptyManifest, "Returned value of OpenDocuemtnManifest->get() is not a empty Manifest file." ); + } + } ?> \ No newline at end of file Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentMeta.php 2006-03-10 10:45:55 UTC (rev 12) @@ -16,7 +16,8 @@ private $meta; /** - * + * + * @since 0.4.0 */ public function __construct( $dom=0 ) { parent::__construct(); @@ -54,7 +55,10 @@ parent::__destruct(); } - + + /** + * @since 0.4.0 + */ public function load( $filename ) { $tmpDom = new DOMDocument(); @@ -92,7 +96,7 @@ } /** - * + * @since 0.4.0 */ public function getDublicCore( $dc ) { $retValue = ""; @@ -106,6 +110,27 @@ } /** + * @param $date Timestamp or 0 = now. + * @since 0.4.2 + */ + public function addCreationDate( $date=0 ) { + if (empty($time)) { + // 2006-02-14T16:36:10 + $creation_time = date( "Y-m-d\TH:i:s" ); + } else { + $creation_time = date( "Y-m-d\TH:i:s", $date ) + } + $this->logger->debug( "OpenDocumentMeta->addCreationTime: ". $creation_time ."." ); + + $node = $this->dom->createElementNS( self::NS_META, "meta:creation-date", $creation_time ); + + $this->root->appendChild( $node ); + + unset( $creation_time ); + + } + + /** * */ public function addGenerator( $generator ) { @@ -128,6 +153,7 @@ /** * + * @since 0.4.0 */ public function getGenerator() { $retValue = ""; @@ -167,6 +193,7 @@ /** * + * @since 0.4.0 */ public function addUserDefinedMetadata( $name, $type, $value ) { $node = $this->dom->createElementNS( self::NS_META, "meta:user-defined" ); @@ -183,6 +210,7 @@ /** * + * @since 0.4.0 */ public function commit() { $this->meta->appendChild( $this->root ); @@ -193,12 +221,14 @@ /** * @depricated + * @since 0.4.0 */ final public function getMeta() { return $this->get(); } /** + * @since 0.4.0 * @return */ final public function get() { @@ -210,6 +240,7 @@ } /** + * @since 0.4.0 * */ final public function save( $filename ) { Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-10 10:45:55 UTC (rev 12) @@ -15,7 +15,7 @@ /** * namespace Dublin Core */ - const NS_DC = "http://purl.org/dc/elements/1.1"; + const NS_DC = "http://purl.org/dc/elements/1.1/"; /** * namespace OpenDocument meta Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/OpenDocumentPackage.php 2006-03-10 10:45:55 UTC (rev 12) @@ -187,7 +187,7 @@ } } - $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->manifest->getManifest() ); + $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->manifest->get() ); $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 . "\"..." ); Deleted: poc/src/TestOutput.php =================================================================== --- poc/src/TestOutput.php 2006-03-09 19:29:11 UTC (rev 11) +++ poc/src/TestOutput.php 2006-03-10 10:45:55 UTC (rev 12) @@ -1,187 +0,0 @@ -<?php -/** - * SampleClass produces a little OpenDocument and send it to the client - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument_Samples - * @since 0.4.0 - * - * $Id$ - */ - -require_once( "OpenDocumentFactory.php" ); -require_once( "Log/observer.php" ); - -class TestOutput { - - private $logger; - - function __construct() { - $conf = array( "mode" => 0600 ); - // File Output: - $this->logger = &Log::factory( "file", "OpenDocument.log", "OpenDocument", $conf ); - // Console Output: - $this->logger = &Log::factory( "console", "", "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($SingleDocument) { - 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: - - if(isset($SingleDocument)) - { - $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(); - } - - - } -} - -if(isset($_POST['SingleDocument'])) -{ - $SingleDocument = $_POST['SingleDocument']; - $TestOutput = new TestOutput(); - $TestOutput->run($SingleDocument); -} - -?> - -<html> -<head> -<title>TestOutput File!</title> -</head> -<body> -<form method="POST" action=""> - <fieldset> - <legend>Document Type:</legend> - Single <input type="radio" name="SingleDocument" value="TRUE" checked="checked" /> - Package <input type="radio" name="SingleDocument" value="FALSE" /><br /> - <input type="submit" value="Submit!" /> - </fieldset> -</form> -</body> -</html> Added: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php (rev 0) +++ poc/src/samples/TestInput.php 2006-03-10 10:45:55 UTC (rev 12) @@ -0,0 +1,46 @@ +<?php +/** + * SampleClass produces a little OpenDocument and send it to the client + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yan...@us...> + * @version $Revision$ + * @package OpenDocument/Samples + * @since 0.4.2 + * + * $Id$ + */ + ?> +<html> + <head> + <title>TestOutput File!</title> + </head> + <body> + <form method="POST" action="TestOutput.php"> + <fieldset> + <legend>Generate a sample OpenDocument:</legend> + <fieldset> + <legend>Document Type:</legend> + <label for="single">Single </label><input id="single" type="radio" name="SingleDocument" value="true" checked="checked" /> + <label for="package">Package </label><input id="package" type="radio" name="SingleDocument" value="false" /><br /> + </fieldset> + <fieldset> + <legend>Metadata:</legend> + <table> + <tr> + <td><label for="author">Author: </label></td> + <td><input id="author" type="text" name="Creator" size="40" maxsize="50" value="Norman Markgraf" /></td> + </tr> + <tr> + <td><label for="title">Title: </label></td> + <td><input id="title" type="text" name="Title" size="80" maxsize="180" value="This is a sample OpenDocument file." /></td> + </tr> + </table> + </fieldset> + <legend>Try it:</legend> + <input type="submit" value="Submit!" /> + </fieldset> + </form> + </body> +</html> \ No newline at end of file Property changes on: poc/src/samples/TestInput.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php (rev 0) +++ poc/src/samples/TestOutput.php 2006-03-10 10:45:55 UTC (rev 12) @@ -0,0 +1,193 @@ +<?php +/** + * SampleClass produces a little OpenDocument and send it to the client + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yan...@us...> + * @version $Revision$ + * @package OpenDocument/Samples + * @since 0.4.2 + * + * $Id$ + */ + +ini_set( "include_path", ini_get( "include_path" ). ";..\\" ); + +require_once( "OpenDocumentFactory.php" ); +require_once( "Log/observer.php" ); + +class TestOutput { + + const DocumentName = "test.odt"; + + const PathToDocument = "D:/PHP/OpenDocument/"; + + 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, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { + $meta->addDublinCore( "title", $title ); + $meta->addDublinCore( "creator", $creator ); + $meta->addDublinCore( "language", "en-EN" ); + $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); + $meta->addGenerator( "" ); + $meta->addInitialCreator( $creator ); + $meta->addCreationDate(); + } + + 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($post) { + 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; + } + + $SingleDocument = ($post["SingleDocument"] == "true"); + $creator = $post["Creator"]; + $title = $post["Title"]; + + + + header( "Content-type: application/odt" ); + header( "Content-Disposition: attachment; filename=".self::DocumentName ); + header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 + header( "Cache-Control: post-check=0, pre-check=0", false ); + header( "Pragma: no-cache" ); + + // Get a OpenDocument object from the factory: + + if(isset($SingleDocument)) + { + $TestDoc = OpenDocumentFactory::createOpenDocument( + self::DocumentName, + self::PathToDocument, + $SingleDocument + ); + + /* + $TestDoc->attachObserverToLogger( $this->logger ); + */ + + $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); + $this->makeStyle( $TestDoc->getStyle() ); + $this->makeContent( $TestDoc->getContent() ); + + echo $TestDoc->get(); + + //$TestDoc->save(); + } + + + } +} + +if(isset($_POST['SingleDocument'])) +{ + $TestOutput = new TestOutput(); + $TestOutput->run($_POST); +} + +// Do TestInput again ... +?> Property changes on: poc/src/samples/TestOutput.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-10 15:09:04
|
Revision: 14 Author: nmarkgraf Date: 2006-03-10 07:08:52 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=14&view=rev Log Message: ----------- Added some PHPDocumentor comments, some minor bug fixes and some minor changes. Modified Paths: -------------- poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentObjectAbstract.php Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-10 10:48:24 UTC (rev 13) +++ poc/src/OpenDocumentAbstract.php 2006-03-10 15:08:52 UTC (rev 14) @@ -5,7 +5,8 @@ * * OpenDocumentAbstract is the basic class for all OpenDocument classes * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument @@ -21,6 +22,7 @@ const Release = "0.4.2"; const Copyright = "(C) in 2006 by Norman Markgraf published under GPL 2.0"; const PackageName = "OpenDocumentPHP"; + const defaultMimeType = "application/vnd.oasis.opendocument.text"; protected $logger; Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-10 10:48:24 UTC (rev 13) +++ poc/src/OpenDocumentFactory.php 2006-03-10 15:08:52 UTC (rev 14) @@ -2,7 +2,8 @@ /** * OpenDocumentFactoy Class * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et. al. * @author Norman Markgraf <nma...@us...> * @author Alex Latchford <yaw...@us...> * @version $Revision$ @@ -12,6 +13,12 @@ * $Id$ */ +/** + * + * @author Alex Latchford <yaw...@us...> + * + * @since 0.4.1 + */ function __autoload($class_name) { // There is no "void" class, so we must ignore it if ($class_name != "void" ) { @@ -20,14 +27,44 @@ } } +/** + * The main factory class of OpenDocumentPHP + * + * This is the main factory class for OpenDocumentPHP. You can use like this: + * <code> + * <?php + * $SingleDoc = OpenDocumentFactory::createOpenDocument( + * "test.odc", "", true, "application/vnd.oasis.opendocument.calc" + * ); + * $PackageDoc = OpenDocumentFactory::createOpenDocument( + * "test.odt", "", false + * ); + * ?> + * </code> + * + * @acess public + * @final + * + * @since 0.4.0 + */ final class OpenDocumentFactory { - + const defaultMimeType = "application/vnd.oasis.opendocument.text"; /** * Creates a OpenDocument. + * + * @param string $documentName + * @param string $documentPath + * @param bool $singleDocument + * @param string $mimeType + * + * @return OpenDocument + * + * @access public + * @static + * * @since 0.4.0 - * @return OpenDocument */ - static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType="application/vnd.oasis.opendocument.text" ) { + static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType=self::defaultMimeType ) { if ( $singleDocument ) { return new OpenDocumentSingle( $mimeType ); } else { Modified: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-10 10:48:24 UTC (rev 13) +++ poc/src/OpenDocumentManifest.php 2006-03-10 15:08:52 UTC (rev 14) @@ -2,15 +2,14 @@ /** * 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 + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * + * @since 0.3.0 + * * $Id$ */ @@ -18,19 +17,26 @@ const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; const odmSYSTEM = "Manifest.dtd"; const odmROOT = "manifest:manifest"; + const defaultMimeType = "application/vnd.oasis.opendocument.text"; private $root; /** * + * @access public + * + * @since 0.4.0 */ - public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { + public function __construct( $mimetype = self::defaultMimeType ) { parent::__construct( $mimetype ); $this->createManifestDOM(); } /** * + * @access public + * + * @since 0.4.0 */ public function __destruct() { unset( $dom ); @@ -41,6 +47,9 @@ /** * * @access private + * @final + * + * @since 0.4.0 */ final private function createManifestDOM() { $impl = new DOMImplementation; @@ -66,6 +75,10 @@ /** * + * @access public + * @final + * + * @since 0.4.0 */ final public function addEntryToManifest( $fullpath, $mimetype, $size=-1, $encrypt=0 ) { $node = $this->dom->createElementNS( self::NS_MANIFEST, "manifest:file-entry" ); @@ -83,6 +96,10 @@ /** * + * @access public + * @final + * + * @since 0.4.0 */ final public function createEncryptionData( ) { return $this->dom->createElmentNS( self::NS_MANIFEST, "manifest:encryption-data" ); @@ -91,9 +108,12 @@ /** * Returns the whole OpenDocument Manifest as DOM. * + * @return DOMDocument manifest as DOM. + * * @access public + * @final * - * @return DOM manifest as DOM. + * @since 0.4.0 */ final public function get() { $this->dom->appendChild( $this->root ); @@ -104,9 +124,12 @@ /** * Save the whole OpenDocument Manifest in a file * + * @param string name of file + * * @access public + * @final * - * @param string name of file + * @since 0.4.0 */ final public function save( $filename ) { $this->get()->save( $filename ); Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-10 10:48:24 UTC (rev 13) +++ poc/src/OpenDocumentMeta.php 2006-03-10 15:08:52 UTC (rev 14) @@ -2,11 +2,14 @@ /** * OpenDocumentMeta Class * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * + * @since 0.3.0 + * * $Id$ */ @@ -17,7 +20,9 @@ /** * - * @since 0.4.0 + * @access public + * + * @since 0.3.0 */ public function __construct( $dom=0 ) { parent::__construct(); @@ -45,6 +50,9 @@ /** * + * @access public + * + * @since 0.3.0 */ public function __destruct() { unset( $dom ); @@ -57,6 +65,9 @@ } /** + * + * @access public + * * @since 0.4.0 */ public function load( $filename ) { @@ -87,6 +98,9 @@ /** * + * @access public + * + * @since 0.3.2 */ public function addDublinCore( $dc, $value) { $this->logger->debug( "OpenDocumentMeta->addDublinCore: ". $value ."." ); @@ -96,6 +110,9 @@ } /** + * + * @access public + * * @since 0.4.0 */ public function getDublicCore( $dc ) { @@ -110,7 +127,20 @@ } /** + * Add the "Creation Date" of the current OpenDocument to the Meta file. + * + * You can give a timestamp made by <c>mktime()</c> or nothing as parameter. + * If no parameter is given, the current time and date will be used. + * <code> + * // This will set the current date and time: + * Document->getMeta()->addCreationDate() + * // This will set the creation date to (April, 4th 1968 - 10:11:12) + * Document->getMeta()->addCreationDate( mktime( 10, 11, 12, 4, 3, 1968 ) ); + * </code> * @param $date Timestamp or 0 = now. + * + * @access public + * * @since 0.4.2 */ public function addCreationDate( $date=0 ) { @@ -118,7 +148,7 @@ // 2006-02-14T16:36:10 $creation_time = date( "Y-m-d\TH:i:s" ); } else { - $creation_time = date( "Y-m-d\TH:i:s", $date ) + $creation_time = date( "Y-m-d\TH:i:s", $date ); } $this->logger->debug( "OpenDocumentMeta->addCreationTime: ". $creation_time ."." ); @@ -132,6 +162,9 @@ /** * + * @access public + * + * @since 0.4.0 */ public function addGenerator( $generator ) { $lgenerator = ""; @@ -153,6 +186,8 @@ /** * + * @access public + * * @since 0.4.0 */ public function getGenerator() { @@ -170,6 +205,9 @@ /** * + * @access public + * + * @since 0.4.0 */ public function addInitialCreator( $initialCreator ) { $this->logger->debug( "OpenDocumentMeta->addInitialCreator: ". $initialCreator ."." ); @@ -179,6 +217,9 @@ /** * + * @access public + * + * @since 0.4.0 */ public function getInitialCreator() { $retValue = ""; @@ -193,6 +234,8 @@ /** * + * @access public + * * @since 0.4.0 */ public function addUserDefinedMetadata( $name, $type, $value ) { @@ -209,7 +252,11 @@ } /** + * Commits all changes to Meta and normalize them. After a commit call, you couldn't add + * new things to Meta. * + * @access public + * * @since 0.4.0 */ public function commit() { @@ -220,16 +267,17 @@ } /** - * @depricated - * @since 0.4.0 - */ - final public function getMeta() { - return $this->get(); - } - - /** + * Get Meta as DOMDocument. + * + * If this object is not commited, this method will first call <c>commit()</c> and return the + * Meta as DOMDocument after that. + * + * @return DOMDocument Meta as DOMDocument. + * + * @access public + * @final + * * @since 0.4.0 - * @return */ final public function get() { if (!$this->isCommited) { @@ -240,12 +288,15 @@ } /** + * + * @access public + * @final + * * @since 0.4.0 - * */ final public function save( $filename ) { $this->logger->debug( "OpenDocumentMeta->save(". $filename .")." ); $this->get()->save( $filename ); } - -} \ No newline at end of file +} +?> \ No newline at end of file Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-10 10:48:24 UTC (rev 13) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-10 15:08:52 UTC (rev 14) @@ -2,11 +2,14 @@ /** * OpenDocumentObjectAbstract Class * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * + * @since 0.4.0 + * * $Id$ */ @@ -76,14 +79,16 @@ * namespace OpenDocument form */ const NS_FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; - - + protected $dom; protected $isCommited; /** * + * @access public + * + * @since 0.4.0 */ public function __construct( $mimetype = 0 ) { parent::__construct( $mimetype ); @@ -93,18 +98,30 @@ /** * + * @access public + * + * @since 0.4.0 */ public function __destruct() { $this->logger->debug( "OpenDocumentObjectAbstract destructed." ); parent::__destruct(); } - + /** + * + * @return DOMDocument + * @access public + * + * @since 0.4.0 + */ public function get() { return $this->dom; } /** * + * @access public + * + * @since 0.4.0 */ public function save( $filename ) { $tmp =& $this->dom; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yaw...@us...> - 2006-03-11 18:21:05
|
Revision: 16 Author: yawnster Date: 2006-03-11 10:20:53 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=16&view=rev Log Message: ----------- - Revised TestOutput to include in main package, please see inbox for more details. - Added in Content Translation support, now adding in new editors is as simple as writing new Regular Expressions. TODO: Actually write some regular expressions that do the job, nothing is broken as such but it needs more work. Modified Paths: -------------- poc/src/samples/TestInput.php Added Paths: ----------- poc/src/OpenDocumentOutput.php poc/src/samples/TestTranslate.php Removed Paths: ------------- poc/src/samples/TestOutput.php Added: poc/src/OpenDocumentOutput.php =================================================================== --- poc/src/OpenDocumentOutput.php (rev 0) +++ poc/src/OpenDocumentOutput.php 2006-03-11 18:20:53 UTC (rev 16) @@ -0,0 +1,195 @@ +<?php +/** + * SampleClass produces a little OpenDocument and send it to the client + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yaw...@us...> + * @version $Revision$ + * @package OpenDocument + * @since 0.4.2 + * + * $Id$ + */ + +ini_set( "include_path", ini_get( "include_path" ). ";..\\" ); + +require_once( "OpenDocumentFactory.php" ); +require_once( "Log/observer.php" ); +require_once( "input/TestTranslate.php" ); + +class OpenDocumentOutput { + + const DocumentName = "test.odt"; + + const PathToDocument = "D:/PHP/OpenDocument/"; + + private $logger; + private $content_matches = array(); + + function __construct() { + $conf = array( "mode" => 0600 ); + $this->logger = &Log::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); + $this->logger = &Log::factory( "console", "", "OpenDocument" ); + + $this->testtranslate = new TestTranslate; + } + + function makeMeta( $meta, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { + $meta->addDublinCore( "title", $title ); + $meta->addDublinCore( "creator", $creator ); + $meta->addDublinCore( "language", "en-EN" ); + $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); + $meta->addGenerator( "" ); + $meta->addInitialCreator( $creator ); + $meta->addCreationDate(); + } + + function makeContent( $content, $document_content ) { + $content->addNoScript(); + + $content->addFontFace( "Test", "Tahoma" ); + + $content->addNoAutomaticStyles(); + + $text = $content->getBody()->getText(); + + $text->addNoForms(); + + $content_matches['paragraphs'] = $this->testtranslate->getParagraphs($document_content); + $content_matches['headings'] = $this->testtranslate->getHeadings($document_content); + //print_r($content_matches['headings']); + + foreach($content_matches['paragraphs'] as $paragraph) { + $text->addToText( $text->getTextParagraph( "Paragraph", $paragraph ) ); + } + + foreach($content_matches['headings'] as $heading) { + $text->addToText( $text->getTextHeading( "Heading", $heading ) ); + } + } + + 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($post) { + 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; + } + + $SingleDocument = ($post["SingleDocument"] == "true"); + $creator = $post["Creator"]; + $title = $post["Title"]; + $document_content = $post["Content"]; + + header( "Content-type: application/odt" ); + header( "Content-Disposition: attachment; filename=".self::DocumentName ); + header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 + header( "Cache-Control: post-check=0, pre-check=0", false ); + header( "Pragma: no-cache" ); + + // Get a OpenDocument object from the factory: + + if(isset($SingleDocument)) + { + $TestDoc = OpenDocumentFactory::createOpenDocument( + self::DocumentName, + self::PathToDocument, + $SingleDocument + ); + + /* + $TestDoc->attachObserverToLogger( $this->logger ); + */ + + $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); + $this->makeStyle( $TestDoc->getStyle() ); + $this->makeContent( $TestDoc->getContent(), $document_content ); + + echo $TestDoc->get(); + + //$TestDoc->save(); + } + + + } +} + +if(isset($_POST['SingleDocument'])) +{ + $TestOutput = new OpenDocumentOutput(); + $TestOutput->run($_POST); +} + +// Do TestInput again ... +?> Property changes on: poc/src/OpenDocumentOutput.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-11 00:11:52 UTC (rev 15) +++ poc/src/samples/TestInput.php 2006-03-11 18:20:53 UTC (rev 16) @@ -6,7 +6,7 @@ * @author Norman Markgraf <nma...@us...> * @author Alex Latchford <yaw...@us...> * @version $Revision$ - * @package OpenDocument/Samples + * @package OpenDocument/input * @since 0.4.2 * * $Id$ @@ -17,7 +17,7 @@ <title>TestOutput File!</title> </head> <body> - <form method="POST" action="TestOutput.php"> + <form method="POST" action="./../OpenDocumentOutput.php"> <fieldset> <legend>Generate a sample OpenDocument:</legend> <fieldset> @@ -40,6 +40,7 @@ </fieldset> <fieldset> <legend>Document Content:</legend> + <p>Please input your content with HTML formatting.</p> <textarea rows="10" cols="50" id="content" name="Content"></textarea> </fieldset> <legend>Try it:</legend> Deleted: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-11 00:11:52 UTC (rev 15) +++ poc/src/samples/TestOutput.php 2006-03-11 18:20:53 UTC (rev 16) @@ -1,183 +0,0 @@ -<?php -/** - * SampleClass produces a little OpenDocument and send it to the client - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument/Samples - * @since 0.4.2 - * - * $Id$ - */ - -ini_set( "include_path", ini_get( "include_path" ). ";..\\" ); - -require_once( "OpenDocumentFactory.php" ); -require_once( "Log/observer.php" ); - -class TestOutput { - - const DocumentName = "test.odt"; - - const PathToDocument = "D:/PHP/OpenDocument/"; - - private $logger; - - function __construct() { - $conf = array( "mode" => 0600 ); - $this->logger = &Log::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); - $this->logger = &Log::factory( "console", "", "OpenDocument" ); - } - - function makeMeta( $meta, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { - $meta->addDublinCore( "title", $title ); - $meta->addDublinCore( "creator", $creator ); - $meta->addDublinCore( "language", "en-EN" ); - $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); - $meta->addGenerator( "" ); - $meta->addInitialCreator( $creator ); - $meta->addCreationDate(); - } - - 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($post) { - 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; - } - - $SingleDocument = ($post["SingleDocument"] == "true"); - $creator = $post["Creator"]; - $title = $post["Title"]; - - - - header( "Content-type: application/odt" ); - header( "Content-Disposition: attachment; filename=".self::DocumentName ); - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 - header( "Cache-Control: post-check=0, pre-check=0", false ); - header( "Pragma: no-cache" ); - - // Get a OpenDocument object from the factory: - - if(isset($SingleDocument)) - { - $TestDoc = OpenDocumentFactory::createOpenDocument( - self::DocumentName, - self::PathToDocument, - $SingleDocument - ); - - /* - $TestDoc->attachObserverToLogger( $this->logger ); - */ - - $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); - $this->makeStyle( $TestDoc->getStyle() ); - $this->makeContent( $TestDoc->getContent() ); - - echo $TestDoc->get(); - - //$TestDoc->save(); - } - - - } -} - -if(isset($_POST['SingleDocument'])) -{ - $TestOutput = new TestOutput(); - $TestOutput->run($_POST); -} - -// Do TestInput again ... -?> Added: poc/src/samples/TestTranslate.php =================================================================== --- poc/src/samples/TestTranslate.php (rev 0) +++ poc/src/samples/TestTranslate.php 2006-03-11 18:20:53 UTC (rev 16) @@ -0,0 +1,46 @@ +<?php +/** + * TestTranslate class that will translate a given formatting style to ODF formatting. + * + * @copyright GNU General Public License + * @author Alex Latchford <yaw...@us...> + * @version $Revision$ + * @package OpenDocument/input + * @since 0.4.2 + * + * $Id$ + */ + +require_once( "Log/observer.php" ); + +class TestTranslate { + + private $expression; + private $logger; + private $matches = array(); + + public function __construct() { + $this->logger = &Log::factory( "null", "", "OpenDocument" ); + $this->logger->debug( "Constructing TestTranslate." ); + } + + public function __destruct() { + $this->logger->debug( "Destructing TestTranslate." ); + } + + public function getParagraphs($document_content) { + + $matches = preg_split( "/\n/", $document_content, 0, PREG_SPLIT_NO_EMPTY); + + return $matches; + } + + public function getHeadings($document_content) { + + $matches = preg_split( "/(<h[1-6])+\w.+(<\/h[1-6]>)+/", $document_content, 0, PREG_SPLIT_NO_EMPTY); + + return $matches; + } + +} + ?> \ No newline at end of file Property changes on: poc/src/samples/TestTranslate.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-13 07:43:15
|
Revision: 18 Author: nmarkgraf Date: 2006-03-12 23:42:56 -0800 (Sun, 12 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=18&view=rev Log Message: ----------- This is the first part of some new test methods. Now it tests if the produced manifest.xml is valid against the Relax NG schema. TODO: Make such Relax NG based tests for all the produced *.xml (like content.xml, styles.xml, ...,and for a whole single document). Modified Paths: -------------- poc/src/OpenDocumentManifestTest.php Added Paths: ----------- poc/etc/test/ poc/etc/test/OpenDocument-manifest-schema-v1.0-os.rng poc/etc/test/OpenDocument-schema-v1.0-os.rng Added: poc/etc/test/OpenDocument-manifest-schema-v1.0-os.rng =================================================================== --- poc/etc/test/OpenDocument-manifest-schema-v1.0-os.rng (rev 0) +++ poc/etc/test/OpenDocument-manifest-schema-v1.0-os.rng 2006-03-13 07:42:56 UTC (rev 18) @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + OASIS OpenDocument v1.0 + OASIS standard, 1 May 2005 + Relax-NG Manifest Schema + + $Id$ + + © 2002-2005 OASIS Open + © 1999-2005 Sun Microsystems, Inc. +--> + +<grammar + xmlns="http://relaxng.org/ns/structure/1.0" + + datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" + + xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"> +<define name="manifest"> + <element name="manifest:manifest"> + <oneOrMore> + <ref name="file-entry"/> + </oneOrMore> + </element> +</define> + +<start> + <choice> + <ref name="manifest"/> + </choice> +</start> +<define name="file-entry"> + <element name="manifest:file-entry"> + <ref name="file-entry-attlist"/> + <optional> + <ref name="encryption-data"/> + </optional> + </element> +</define> +<define name="file-entry-attlist" combine="interleave"> + <attribute name="manifest:full-path"> + <data type="string"/> + </attribute> +</define> +<define name="file-entry-attlist" combine="interleave"> + <optional> + <attribute name="manifest:size"> + <data type="nonNegativeInteger"/> + </attribute> + </optional> +</define> +<define name="file-entry-attlist" combine="interleave"> + <attribute name="manifest:media-type"> + <data type="string"/> + </attribute> +</define> +<define name="encryption-data"> + <element name="manifest:encryption-data"> + <ref name="encryption-data-attlist"/> + <ref name="algorithm"/> + <ref name="key-derivation"/> + </element> +</define> +<define name="encryption-data-attlist" combine="interleave"> + <attribute name="manifest:checksum-type"> + <data type="string"/> + </attribute> +</define> +<define name="encryption-data-attlist" combine="interleave"> + <attribute name="manifest:checksum"> + <data type="base64Binary"/> + </attribute> +</define> +<define name="algorithm"> + <element name="manifest:algorithm"> + <ref name="algorithm-attlist"/> + <empty/> + </element> +</define> +<define name="algorithm-attlist" combine="interleave"> + <attribute name="manifest:algorithm-name"> + <data type="string"/> + </attribute> +</define> +<define name="algorithm-attlist" combine="interleave"> + <attribute name="manifest:initialisation-vector"> + <data type="base64Binary"/> + </attribute> +</define> +<define name="key-derivation"> + <element name="manifest:key-derivation"> + <ref name="key-derivation-attlist"/> + <empty/> + </element> +</define> +<define name="key-derivation-attlist" combine="interleave"> + <attribute name="manifest:key-derivation-name"> + <data type="string"/> + </attribute> +</define> +<define name="key-derivation-attlist" combine="interleave"> + <attribute name="manifest:salt"> + <data type="base64Binary"/> + </attribute> +</define> +<define name="key-derivation-attlist" combine="interleave"> + <attribute name="manifest:iteration-count"> + <data type="nonNegativeInteger"/> + </attribute> +</define> +</grammar> Added: poc/etc/test/OpenDocument-schema-v1.0-os.rng =================================================================== --- poc/etc/test/OpenDocument-schema-v1.0-os.rng (rev 0) +++ poc/etc/test/OpenDocument-schema-v1.0-os.rng 2006-03-13 07:42:56 UTC (rev 18) @@ -0,0 +1,17593 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + OASIS OpenDocument v1.0 + OASIS Standard, 1 May 2005 + Relax-NG Schema + + $Id$ + + © 2002-2005 OASIS Open + © 1999-2005 Sun Microsystems, Inc. +--> +<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"> +<define name="office-process-content"> + <optional> + <attribute name="office:process-content" a:defaultValue="true"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<start> + <choice> + <ref name="office-document"/> + <ref name="office-document-content"/> + <ref name="office-document-styles"/> + <ref name="office-document-meta"/> + <ref name="office-document-settings"/> + </choice> +</start> +<define name="office-document"> + <element name="office:document"> + <ref name="office-document-attrs"/> + <ref name="office-document-common-attrs"/> + <ref name="office-meta"/> + <ref name="office-settings"/> + <ref name="office-scripts"/> + <ref name="office-font-face-decls"/> + <ref name="office-styles"/> + <ref name="office-automatic-styles"/> + <ref name="office-master-styles"/> + <ref name="office-body"/> + </element> +</define> +<define name="office-document-content"> + <element name="office:document-content"> + <ref name="office-document-common-attrs"/> + <ref name="office-scripts"/> + <ref name="office-font-face-decls"/> + <ref name="office-automatic-styles"/> + <ref name="office-body"/> + </element> +</define> +<define name="office-document-styles"> + <element name="office:document-styles"> + <ref name="office-document-common-attrs"/> + <ref name="office-font-face-decls"/> + <ref name="office-styles"/> + <ref name="office-automatic-styles"/> + <ref name="office-master-styles"/> + </element> +</define> +<define name="office-document-meta"> + <element name="office:document-meta"> + <ref name="office-document-common-attrs"/> + <ref name="office-meta"/> + </element> +</define> +<define name="office-document-settings"> + <element name="office:document-settings"> + <ref name="office-document-common-attrs"/> + <ref name="office-settings"/> + </element> +</define> +<define name="office-document-common-attrs" combine="interleave"> + <optional> + <attribute name="office:version"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="office-document-attrs" combine="interleave"> + <attribute name="office:mimetype"> + <ref name="string"/> + </attribute> +</define> +<define name="office-meta"> + <optional> + <element name="office:meta"> + <ref name="office-meta-content"/> + </element> + </optional> +</define> + +<define name="office-meta-content"> + <ref name="anyElements"/> +</define> + +<define name="office-meta-content-strict"> + <zeroOrMore> + <ref name="office-meta-data"/> + </zeroOrMore> +</define> +<define name="office-body"> + <element name="office:body"> + <ref name="office-body-content"/> + </element> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:text"> + <ref name="office-text-attlist"/> + <ref name="office-text-content-prelude"/> + <zeroOrMore> + <ref name="office-text-content-main"/> + </zeroOrMore> + <ref name="office-text-content-epilogue"/> + </element> +</define> +<define name="office-text-content-prelude"> + <ref name="office-forms"/> + <ref name="text-tracked-changes"/> + <ref name="text-decls"/> + <ref name="table-decls"/> +</define> +<define name="office-text-content-main"> + <choice> + <zeroOrMore> + <ref name="text-content"/> + </zeroOrMore> + <group> + <ref name="text-page-sequence"/> + <zeroOrMore> + <choice> + <ref name="draw-a"/> + <ref name="shape"/> + </choice> + </zeroOrMore> + </group> + </choice> +</define> + +<define name="text-content"> + <choice> + <ref name="text-h"/> + <ref name="text-p"/> + <ref name="text-list"/> + <ref name="text-numbered-paragraph"/> + <ref name="table-table"/> + <ref name="draw-a"/> + <ref name="text-section"/> + <ref name="text-table-of-content"/> + <ref name="text-illustration-index"/> + <ref name="text-table-index"/> + <ref name="text-object-index"/> + <ref name="text-user-index"/> + <ref name="text-alphabetical-index"/> + <ref name="text-bibliography"/> + <ref name="shape"/> + <ref name="change-marks"/> + </choice> +</define> +<define name="office-text-content-epilogue"> + <ref name="table-functions"/> +</define> +<define name="office-text-attlist" combine="interleave"> + <optional> + <attribute name="text:global" a:defaultValue="false"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:drawing"> + <ref name="office-drawing-attlist"/> + <ref name="office-drawing-content-prelude"/> + <ref name="office-drawing-content-main"/> + <ref name="office-drawing-content-epilogue"/> + </element> +</define> + +<define name="office-drawing-attlist"> + <empty/> +</define> +<define name="office-drawing-content-prelude"> + <ref name="text-decls"/> + <ref name="table-decls"/> +</define> +<define name="office-drawing-content-main"> + <zeroOrMore> + <ref name="draw-page"/> + </zeroOrMore> +</define> +<define name="office-drawing-content-epilogue"> + <ref name="table-functions"/> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:presentation"> + <ref name="office-presentation-attlist"/> + <ref name="office-presentation-content-prelude"/> + <ref name="office-presentation-content-main"/> + <ref name="office-presentation-content-epilogue"/> + </element> +</define> + +<define name="office-presentation-attlist"> + <empty/> +</define> +<define name="office-presentation-content-prelude"> + <ref name="text-decls"/> + <ref name="table-decls"/> + <ref name="presentation-decls"/> +</define> +<define name="office-presentation-content-main"> + <zeroOrMore> + <ref name="draw-page"/> + </zeroOrMore> +</define> +<define name="office-presentation-content-epilogue"> + <ref name="presentation-settings"/> + <ref name="table-functions"/> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:spreadsheet"> + <ref name="office-spreadsheet-attlist"/> + <ref name="office-spreadsheet-content-prelude"/> + <ref name="office-spreadsheet-content-main"/> + <ref name="office-spreadsheet-content-epilogue"/> + </element> +</define> +<define name="office-spreadsheet-content-prelude"> + <optional> + <ref name="table-tracked-changes"/> + </optional> + <ref name="text-decls"/> + <ref name="table-decls"/> +</define> + +<define name="table-decls"> + <optional> + <ref name="table-calculation-settings"/> + </optional> + <optional> + <ref name="table-content-validations"/> + </optional> + <optional> + <ref name="table-label-ranges"/> + </optional> +</define> +<define name="office-spreadsheet-content-main"> + <zeroOrMore> + <ref name="table-table"/> + </zeroOrMore> +</define> +<define name="office-spreadsheet-content-epilogue"> + <ref name="table-functions"/> +</define> + +<define name="table-functions"> + <optional> + <ref name="table-named-expressions"/> + </optional> + <optional> + <ref name="table-database-ranges"/> + </optional> + <optional> + <ref name="table-data-pilot-tables"/> + </optional> + <optional> + <ref name="table-consolidation"/> + </optional> + <optional> + <ref name="table-dde-links"/> + </optional> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:chart"> + <ref name="office-chart-attlist"/> + <ref name="office-chart-content-prelude"/> + <ref name="office-chart-content-main"/> + <ref name="office-chart-content-epilogue"/> + </element> +</define> + +<define name="office-chart-attlist"> + <empty/> +</define> +<define name="office-chart-content-prelude"> + <ref name="text-decls"/> + <ref name="table-decls"/> +</define> +<define name="office-chart-content-main"> + <ref name="chart-chart"/> +</define> +<define name="office-chart-content-epilogue"> + <ref name="table-functions"/> +</define> +<define name="office-body-content" combine="choice"> + <element name="office:image"> + <ref name="office-image-attlist"/> + <ref name="office-image-content-prelude"/> + <ref name="office-image-content-main"/> + <ref name="office-image-content-epilogue"/> + </element> +</define> + +<define name="office-image-attlist"> + <empty/> +</define> +<define name="office-image-content-prelude"> + <empty/> +</define> +<define name="office-image-content-main"> + <ref name="draw-frame"/> +</define> +<define name="office-image-content-epilogue"> + <empty/> +</define> +<define name="office-settings"> + <optional> + <element name="office:settings"> + <oneOrMore> + <ref name="config-config-item-set"/> + </oneOrMore> + </element> + </optional> +</define> +<define name="config-config-item-set"> + <element name="config:config-item-set"> + <ref name="config-config-item-set-attlist"/> + <ref name="config-items"/> + </element> +</define> + +<define name="config-items"> + <oneOrMore> + <choice> + <ref name="config-config-item"/> + <ref name="config-config-item-set"/> + <ref name="config-config-item-map-named"/> + <ref name="config-config-item-map-indexed"/> + </choice> + </oneOrMore> +</define> +<define name="config-config-item-set-attlist" combine="interleave"> + <attribute name="config:name"> + <ref name="string"/> + </attribute> +</define> +<define name="config-config-item"> + <element name="config:config-item"> + <ref name="config-config-item-attlist"/> + <text/> + </element> +</define> +<define name="config-config-item-attlist" combine="interleave"> + <attribute name="config:name"> + <ref name="string"/> + </attribute> +</define> +<define name="config-config-item-attlist" combine="interleave"> + <attribute name="config:type"> + <choice> + <value>boolean</value> + <value>short</value> + <value>int</value> + <value>long</value> + <value>double</value> + <value>string</value> + <value>datetime</value> + <value>base64Binary</value> + </choice> + </attribute> +</define> +<define name="config-config-item-map-indexed"> + <element name="config:config-item-map-indexed"> + <ref name="config-config-item-map-indexed-attlist"/> + <oneOrMore> + <ref name="config-config-item-map-entry"/> + </oneOrMore> + </element> +</define> +<define name="config-config-item-map-indexed-attlist" combine="interleave"> + <attribute name="config:name"> + <ref name="string"/> + </attribute> +</define> +<define name="config-config-item-map-entry"> + <element name="config:config-item-map-entry"> + <ref name="config-config-item-map-entry-attlist"/> + <ref name="config-items"/> + </element> +</define> +<define name="config-config-item-map-entry-attlist" combine="interleave"> + <optional> + <attribute name="config:name"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="config-config-item-map-named"> + <element name="config:config-item-map-named"> + <ref name="config-config-item-map-named-attlist"/> + <oneOrMore> + <ref name="config-config-item-map-entry"/> + </oneOrMore> + </element> +</define> +<define name="config-config-item-map-named-attlist" combine="interleave"> + <attribute name="config:name"> + <ref name="string"/> + </attribute> +</define> +<define name="office-scripts"> + <optional> + <element name="office:scripts"> + <zeroOrMore> + <ref name="office-script"/> + </zeroOrMore> + <optional> + <ref name="office-event-listeners"/> + </optional> + </element> + </optional> +</define> +<define name="office-script"> + <element name="office:script"> + <ref name="office-script-attlist"/> + <mixed> + <ref name="anyElements"/> + </mixed> + </element> +</define> +<define name="office-script-attlist"> + <attribute name="script:language"> + <ref name="string"/> + </attribute> +</define> +<define name="office-font-face-decls"> + <optional> + <element name="office:font-face-decls"> + <zeroOrMore> + <ref name="style-font-face"/> + </zeroOrMore> + </element> + </optional> +</define> +<define name="office-styles"> + <optional> + <element name="office:styles"> + <interleave> + <ref name="styles"/> + <zeroOrMore> + <ref name="style-default-style"/> + </zeroOrMore> + <optional> + <ref name="text-outline-style"/> + </optional> + <zeroOrMore> + <ref name="text-notes-configuration"/> + </zeroOrMore> + <optional> + <ref name="text-bibliography-configuration"/> + </optional> + <optional> + <ref name="text-linenumbering-configuration"/> + </optional> + <zeroOrMore> + <ref name="draw-gradient"/> + </zeroOrMore> + <zeroOrMore> + <ref name="svg-linearGradient"/> + </zeroOrMore> + <zeroOrMore> + <ref name="svg-radialGradient"/> + </zeroOrMore> + <zeroOrMore> + <ref name="draw-hatch"/> + </zeroOrMore> + <zeroOrMore> + <ref name="draw-fill-image"/> + </zeroOrMore> + <zeroOrMore> + <ref name="draw-marker"/> + </zeroOrMore> + <zeroOrMore> + <ref name="draw-stroke-dash"/> + </zeroOrMore> + <zeroOrMore> + <ref name="draw-opacity"/> + </zeroOrMore> + <zeroOrMore> + <ref name="style-presentation-page-layout"/> + </zeroOrMore> + </interleave> + </element> + </optional> +</define> +<define name="office-automatic-styles"> + <optional> + <element name="office:automatic-styles"> + <interleave> + <ref name="styles"/> + <zeroOrMore> + <ref name="style-page-layout"/> + </zeroOrMore> + </interleave> + </element> + </optional> +</define> +<define name="office-master-styles"> + <optional> + <element name="office:master-styles"> + <interleave> + <zeroOrMore> + <ref name="style-master-page"/> + </zeroOrMore> + <optional> + <ref name="style-handout-master"/> + </optional> + <optional> + <ref name="draw-layer-set"/> + </optional> + </interleave> + </element> + </optional> +</define> + +<define name="styles"> + <interleave> + <zeroOrMore> + <ref name="style-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="text-list-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-number-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-currency-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-percentage-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-date-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-time-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-boolean-style"/> + </zeroOrMore> + <zeroOrMore> + <ref name="number-text-style"/> + </zeroOrMore> + </interleave> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:generator"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="dc:title"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="dc:description"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="dc:subject"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:keyword"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:initial-creator"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <ref name="dc-creator"/> +</define> +<define name="dc-creator"> + <element name="dc:creator"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:printed-by"> + <ref name="string"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:creation-date"> + <ref name="dateTime"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <ref name="dc-date"/> +</define> +<define name="dc-date"> + <element name="dc:date"> + <ref name="dateTime"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:print-date"> + <ref name="dateTime"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:template"> + <attribute name="xlink:href"> + <ref name="anyURI"/> + </attribute> + <optional> + <attribute name="xlink:type" a:defaultValue="simple"> + <value>simple</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:actuate" a:defaultValue="onRequest"> + <value>onRequest</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:title"> + <ref name="string"/> + </attribute> + </optional> + <optional> + <attribute name="meta:date"> + <ref name="dateTime"/> + </attribute> + </optional> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:auto-reload"> + <optional> + <attribute name="xlink:type" a:defaultValue="simple"> + <value>simple</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:show" a:defaultValue="replace"> + <value>replace</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:actuate" a:defaultValue="onLoad"> + <value>onLoad</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:href"> + <ref name="anyURI"/> + </attribute> + </optional> + <optional> + <attribute name="meta:delay"> + <ref name="duration"/> + </attribute> + </optional> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:hyperlink-behaviour"> + <optional> + <attribute name="office:target-frame-name"> + <ref name="targetFrameName"/> + </attribute> + </optional> + <optional> + <attribute name="xlink:show"> + <choice> + <value>new</value> + <value>replace</value> + </choice> + </attribute> + </optional> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="dc:language"> + <ref name="language"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:editing-cycles"> + <ref name="nonNegativeInteger"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:editing-duration"> + <ref name="duration"/> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:document-statistic"> + <optional> + <attribute name="meta:page-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:table-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:draw-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:image-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:ole-object-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:paragraph-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:word-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:character-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="frame-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="sentence-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="syllable-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="non-whitespace-character-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:row-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:cell-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + <optional> + <attribute name="meta:object-count"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + </element> +</define> +<define name="office-meta-data" combine="choice"> + <element name="meta:user-defined"> + <attribute name="meta:name"> + <ref name="string"/> + </attribute> + <choice> + <group> + <attribute name="meta:value-type"> + <value>float</value> + </attribute> + <ref name="double"/> + </group> + <group> + <attribute name="meta:value-type"> + <value>date</value> + </attribute> + <ref name="dateOrDateTime"/> + </group> + <group> + <attribute name="meta:value-type"> + <value>time</value> + </attribute> + <ref name="duration"/> + </group> + <group> + <attribute name="meta:value-type"> + <value>boolean</value> + </attribute> + <ref name="boolean"/> + </group> + <group> + <attribute name="meta:value-type"> + <value>string</value> + </attribute> + <ref name="string"/> + </group> + <text/> + </choice> + </element> +</define> +<define name="text-h"> + <element name="text:h"> + <ref name="heading-attrs"/> + <ref name="paragraph-attrs"/> + <optional> + <ref name="text-number"/> + </optional> + <zeroOrMore> + <ref name="paragraph-content"/> + </zeroOrMore> + </element> +</define> +<define name="heading-attrs" combine="interleave"> + <attribute name="text:outline-level"> + <ref name="positiveInteger"/> + </attribute> +</define> +<define name="heading-attrs" combine="interleave"> + <optional> + <attribute name="text:restart-numbering" a:defaultValue="false"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="heading-attrs" combine="interleave"> + <optional> + <attribute name="text:start-value"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> +</define> +<define name="heading-attrs" combine="interleave"> + <optional> + <attribute name="text:is-list-header" a:defaultValue="false"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="text-number"> + <element name="text:number"> + <ref name="string"/> + </element> +</define> +<define name="text-p"> + <element name="text:p"> + <ref name="paragraph-attrs"/> + <zeroOrMore> + <ref name="paragraph-content"/> + </zeroOrMore> + </element> +</define> +<define name="paragraph-attrs"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> + <optional> + <attribute name="text:class-names"> + <ref name="styleNameRefs"/> + </attribute> + </optional> + <optional> + <attribute name="text:cond-style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> +</define> +<define name="paragraph-attrs" combine="interleave"> + <optional> + <ref name="text-id"/> + </optional> +</define> +<define name="text-page-sequence"> + <element name="text:page-sequence"> + <oneOrMore> + <ref name="text-page"/> + </oneOrMore> + </element> +</define> +<define name="text-page"> + <element name="text:page"> + <ref name="text-page-attlist"/> + <empty/> + </element> +</define> +<define name="text-page-attlist"> + <attribute name="text:master-page-name"> + <ref name="styleNameRef"/> + </attribute> +</define> +<define name="text-list"> + <element name="text:list"> + <ref name="text-list-attr"/> + <optional> + <ref name="text-list-header"/> + </optional> + <zeroOrMore> + <ref name="text-list-item"/> + </zeroOrMore> + </element> +</define> +<define name="text-list-attr" combine="interleave"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> +</define> +<define name="text-list-attr" combine="interleave"> + <optional> + <attribute name="text:continue-numbering"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="text-list-item"> + <element name="text:list-item"> + <ref name="text-list-item-attr"/> + <ref name="text-list-item-content"/> + </element> +</define> +<define name="text-list-item-content"> + <optional> + <ref name="text-number"/> + </optional> + <zeroOrMore> + <choice> + <ref name="text-p"/> + <ref name="text-h"/> + <ref name="text-list"/> + </choice> + </zeroOrMore> +</define> +<define name="text-list-item-attr" combine="interleave"> + <optional> + <attribute name="text:start-value"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> +</define> +<define name="text-list-header"> + <element name="text:list-header"> + <ref name="text-list-item-content"/> + </element> +</define> +<define name="text-numbered-paragraph"> + <element name="text:numbered-paragraph"> + <ref name="text-numbered-paragraph-attr"/> + <optional> + <ref name="text-number"/> + </optional> + <choice> + <ref name="text-p"/> + <ref name="text-h"/> + </choice> + </element> +</define> +<define name="text-numbered-paragraph-attr" combine="interleave"> + <optional> + <attribute name="text:level" a:defaultValue="1"> + <ref name="positiveInteger"/> + </attribute> + </optional> +</define> +<define name="text-numbered-paragraph-attr" combine="interleave"> + <ref name="text-list-attr"/> +</define> +<define name="text-numbered-paragraph-attr" combine="interleave"> + <ref name="text-list-item-attr"/> +</define> +<define name="text-section"> + <element name="text:section"> + <ref name="text-section-attr"/> + <choice> + <ref name="text-section-source"/> + <ref name="text-section-source-dde"/> + <empty/> + </choice> + <zeroOrMore> + <ref name="text-content"/> + </zeroOrMore> + </element> +</define> +<define name="text-section-attr" combine="interleave"> + <ref name="sectionAttr"/> +</define> +<define name="sectionAttr" combine="interleave"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> +</define> +<define name="sectionAttr" combine="interleave"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> +</define> +<define name="sectionAttr" combine="interleave"> + <optional> + <attribute name="text:protected"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="sectionAttr" combine="interleave"> + <optional> + <attribute name="text:protection-key"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="text-section-attr" combine="interleave"> + <choice> + <attribute name="text:display"> + <choice> + <value>true</value> + <value>none</value> + </choice> + </attribute> + <group> + <attribute name="text:display"> + <value>condition</value> + </attribute> + <attribute name="text:condition"> + <ref name="string"/> + </attribute> + </group> + <empty/> + </choice> +</define> +<define name="text-section-source"> + <element name="text:section-source"> + <ref name="text-section-source-attr"/> + </element> +</define> +<define name="text-section-source-attr" combine="interleave"> + <optional> + <attribute name="xlink:href"> + <ref name="anyURI"/> + </attribute> + <optional> + <attribute name="xlink:type" a:defaultValue="simple"> + <value>simple</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:show" a:defaultValue="embed"> + <value>embed</value> + </attribute> + </optional> + </optional> +</define> +<define name="text-section-source-attr" combine="interleave"> + <optional> + <attribute name="text:section-name"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="text-section-source-attr" combine="interleave"> + <optional> + <attribute name="text:filter-name"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="text-section-source-dde"> + <ref name="office-dde-source"/> +</define> +<define name="text-tracked-changes"> + <optional> + <element name="text:tracked-changes"> + <ref name="text-tracked-changes-attr"/> + <zeroOrMore> + <ref name="text-changed-region"/> + </zeroOrMore> + </element> + </optional> +</define> +<define name="text-tracked-changes-attr" combine="interleave"> + <optional> + <attribute name="text:track-changes" a:defaultValue="true"> + <ref name="boolean"/> + </attribute> + </optional> +</define> +<define name="text-changed-region"> + <element name="text:changed-region"> + <ref name="text-changed-region-attr"/> + <ref name="text-changed-region-content"/> + </element> +</define> +<define name="text-changed-region-attr" combine="interleave"> + <attribute name="text:id"> + <ref name="ID"/> + </attribute> +</define> +<define name="text-changed-region-content" combine="choice"> + <element name="text:insertion"> + <ref name="office-change-info"/> + </element> +</define> +<define name="text-changed-region-content" combine="choice"> + <element name="text:deletion"> + <ref name="office-change-info"/> + <zeroOrMore> + <ref name="text-content"/> + </zeroOrMore> + </element> +</define> +<define name="text-changed-region-content" combine="choice"> + <element name="text:format-change"> + <ref name="office-change-info"/> + </element> +</define> +<define name="change-marks"> + <choice> + <element name="text:change"> + <ref name="change-mark-attr"/> + </element> + <element name="text:change-start"> + <ref name="change-mark-attr"/> + </element> + <element name="text:change-end"> + <ref name="change-mark-attr"/> + </element> + </choice> +</define> +<define name="change-mark-attr"> + <attribute name="text:change-id"> + <ref name="IDREF"/> + </attribute> +</define> +<define name="text-decls"> + <optional> + <element name="text:variable-decls"> + <zeroOrMore> + <ref name="text-variable-decl"/> + </zeroOrMore> + </element> + </optional> + <optional> + <element name="text:sequence-decls"> + <zeroOrMore> + <ref name="text-sequence-decl"/> + </zeroOrMore> + </element> + </optional> + <optional> + <element name="text:user-field-decls"> + <zeroOrMore> + <ref name="text-user-field-decl"/> + </zeroOrMore> + </element> + </optional> + <optional> + <element name="text:dde-connection-decls"> + <zeroOrMore> + <ref name="text-dde-connection-decl"/> + </zeroOrMore> + </element> + </optional> + <optional> + <ref name="text-alphabetical-index-auto-mark-file"/> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <text/> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:s"> + <optional> + <attribute name="text:c"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:tab"> + <ref name="text-tab-attr"/> + </element> +</define> +<define name="text-tab-attr"> + <optional> + <attribute name="text:tab-ref"> + <ref name="nonNegativeInteger"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:line-break"> + <empty/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:span"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> + <optional> + <attribute name="text:class-names"> + <ref name="styleNameRefs"/> + </attribute> + </optional> + <zeroOrMore> + <ref name="paragraph-content"/> + </zeroOrMore> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:a"> + <ref name="text-a-attlist"/> + <optional> + <ref name="office-event-listeners"/> + </optional> + <zeroOrMore> + <ref name="paragraph-content"/> + </zeroOrMore> + </element> +</define> +<define name="text-a-attlist" combine="interleave"> + <optional> + <attribute name="office:name"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="text-a-attlist" combine="interleave"> + <attribute name="xlink:href"> + <ref name="anyURI"/> + </attribute> + <optional> + <attribute name="xlink:type" a:defaultValue="simple"> + <value>simple</value> + </attribute> + </optional> + <optional> + <attribute name="xlink:actuate" a:defaultValue="onRequest"> + <value>onRequest</value> + </attribute> + </optional> +</define> +<define name="text-a-attlist" combine="interleave"> + <optional> + <attribute name="office:target-frame-name"> + <ref name="targetFrameName"/> + </attribute> + </optional> + <optional> + <attribute name="xlink:show"> + <choice> + <value>new</value> + <value>replace</value> + </choice> + </attribute> + </optional> +</define> +<define name="text-a-attlist" combine="interleave"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> + <optional> + <attribute name="text:visited-style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <choice> + <element name="text:bookmark"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> + <element name="text:bookmark-start"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> + <element name="text:bookmark-end"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> + </choice> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:reference-mark"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <choice> + <element name="text:reference-mark-start"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> + <element name="text:reference-mark-end"> + <attribute name="text:name"> + <ref name="string"/> + </attribute> + </element> + </choice> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:note"> + <ref name="text-note-class"/> + <optional> + <attribute name="text:id"> + <ref name="string"/> + </attribute> + </optional> + <element name="text:note-citation"> + <optional> + <attribute name="text:label"> + <ref name="string"/> + </attribute> + </optional> + <text/> + </element> + <element name="text:note-body"> + <zeroOrMore> + <ref name="text-content"/> + </zeroOrMore> + </element> + </element> +</define> +<define name="text-note-class"> + <attribute name="text:note-class"> + <choice> + <value>footnote</value> + <value>endnote</value> + </choice> + </attribute> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:ruby"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> + <element name="text:ruby-base"> + <ref name="paragraph-content"/> + </element> + <element name="text:ruby-text"> + <optional> + <attribute name="text:style-name"> + <ref name="styleNameRef"/> + </attribute> + </optional> + <text/> + </element> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <ref name="office-annotation"/> +</define> +<define name="paragraph-content" combine="choice"> + <ref name="change-marks"/> +</define> +<define name="paragraph-content" combine="choice"> + <choice> + <ref name="shape"/> + <ref name="draw-a"/> + </choice> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:date"> + <ref name="text-date-attlist"/> + <text/> + </element> +</define> +<define name="text-date-attlist" combine="interleave"> + <interleave> + <ref name="common-field-fixed-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> +</define> +<define name="text-date-attlist" combine="interleave"> + <optional> + <attribute name="text:date-value"> + <ref name="dateOrDateTime"/> + </attribute> + </optional> +</define> +<define name="text-date-attlist" combine="interleave"> + <optional> + <attribute name="text:date-adjust"> + <ref name="duration"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:time"> + <ref name="text-time-attlist"/> + <text/> + </element> +</define> +<define name="text-time-attlist" combine="interleave"> + <interleave> + <ref name="common-field-fixed-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> +</define> +<define name="text-time-attlist" combine="interleave"> + <optional> + <attribute name="text:time-value"> + <ref name="timeOrDateTime"/> + </attribute> + </optional> +</define> +<define name="text-time-attlist" combine="interleave"> + <optional> + <attribute name="text:time-adjust"> + <ref name="duration"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:page-number"> + <ref name="text-page-number-attlist"/> + <text/> + </element> +</define> +<define name="text-page-number-attlist" combine="interleave"> + <interleave> + <ref name="common-field-num-format-attlist"/> + <ref name="common-field-fixed-attlist"/> + </interleave> +</define> +<define name="text-page-number-attlist" combine="interleave"> + <optional> + <attribute name="text:page-adjust"> + <ref name="integer"/> + </attribute> + </optional> +</define> +<define name="text-page-number-attlist" combine="interleave"> + <optional> + <attribute name="text:select-page"> + <choice> + <value>previous</value> + <value>current</value> + <value>next</value> + </choice> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:page-continuation"> + <ref name="text-page-continuation-attlist"/> + <text/> + </element> +</define> +<define name="text-page-continuation-attlist" combine="interleave"> + <attribute name="text:select-page"> + <choice> + <value>previous</value> + <value>next</value> + </choice> + </attribute> +</define> +<define name="text-page-continuation-attlist" combine="interleave"> + <optional> + <attribute name="text:string-value"> + <ref name="string"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-firstname"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-lastname"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-initials"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-title"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-position"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-email"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-phone-private"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-fax"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-company"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-phone-work"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-street"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-city"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-postal-code"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-country"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sender-state-or-province"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:author-name"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:author-initials"> + <ref name="common-field-fixed-attlist"/> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:chapter"> + <ref name="text-chapter-attlist"/> + <text/> + </element> +</define> +<define name="text-chapter-attlist" combine="interleave"> + <attribute name="text:display"> + <choice> + <value>name</value> + <value>number</value> + <value>number-and-name</value> + <value>plain-number-and-name</value> + <value>plain-number</value> + </choice> + </attribute> +</define> +<define name="text-chapter-attlist" combine="interleave"> + <attribute name="text:outline-level"> + <ref name="nonNegativeInteger"/> + </attribute> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:file-name"> + <ref name="text-file-name-attlist"/> + <text/> + </element> +</define> +<define name="text-file-name-attlist" combine="interleave"> + <optional> + <attribute name="text:display"> + <choice> + <value>full</value> + <value>path</value> + <value>name</value> + <value>name-and-extension</value> + </choice> + </attribute> + </optional> +</define> +<define name="text-file-name-attlist" combine="interleave"> + <ref name="common-field-fixed-attlist"/> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:template-name"> + <ref name="text-template-name-attlist"/> + <text/> + </element> +</define> +<define name="text-template-name-attlist"> + <optional> + <attribute name="text:display"> + <choice> + <value>full</value> + <value>path</value> + <value>name</value> + <value>name-and-extension</value> + <value>area</value> + <value>title</value> + </choice> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sheet-name"> + <text/> + </element> +</define> +<define name="text-variable-decl"> + <element name="text:variable-decl"> + <ref name="common-field-name-attlist"/> + <ref name="common-value-type-attlist"/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:variable-set"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-formula-attlist"/> + <ref name="common-value-and-type-attlist"/> + <ref name="common-field-display-value-none-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:variable-get"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-display-value-formula-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:variable-input"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-description-attlist"/> + <ref name="common-value-type-attlist"/> + <ref name="common-field-display-value-none-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> + <text/> + </element> +</define> +<define name="text-user-field-decl"> + <element name="text:user-field-decl"> + <ref name="common-field-name-attlist"/> + <optional> + <ref name="common-field-formula-attlist"/> + </optional> + <ref name="common-value-and-type-attlist"/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:user-field-get"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-display-value-formula-none-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> + <text/> + </element> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:user-field-input"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-description-attlist"/> + <ref name="common-field-data-style-name-attlist"/> + </interleave> + <text/> + </element> +</define> +<define name="text-sequence-decl"> + <element name="text:sequence-decl"> + <ref name="text-sequence-decl-attlist"/> + </element> +</define> +<define name="text-sequence-decl-attlist" combine="interleave"> + <ref name="common-field-name-attlist"/> +</define> +<define name="text-sequence-decl-attlist" combine="interleave"> + <attribute name="text:display-outline-level"> + <ref name="nonNegativeInteger"/> + </attribute> +</define> +<define name="text-sequence-decl-attlist" combine="interleave"> + <optional> + <attribute name="text:separation-character"> + <ref name="character"/> + </attribute> + </optional> +</define> +<define name="paragraph-content" combine="choice"> + <element name="text:sequence"> + <interleave> + <ref name="common-field-name-attlist"/> + <ref name="common-field-f... [truncated message content] |
From: <nma...@us...> - 2006-03-13 08:14:26
|
Revision: 19 Author: nmarkgraf Date: 2006-03-13 00:14:08 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=19&view=rev Log Message: ----------- This is a major bug fixing and new stuff commit. - Reverted Alex deletion of TestOutput.php, because my new version is better than the old. - Put some new namespaces in OpenDocumentObjectAbstract to match more namespaces used in OpenDocument format documentation. - Rewrite OpenDocumentContent and OpenDocumentStyle classes to use style/FontFaceDeclaration and a new way to submit fo: and style: attributes. Take a look at samples/TestOutput.php to see what is new (compared to OpenDocumentOutput) - Also some comments and tiny typos are corrected. @Alex: I don't think we need an extra OpenDocumentOutput class, but I haven't changed it by now. Norman Modified Paths: -------------- poc/src/OpenDocumentContent.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentStyle.php Added Paths: ----------- poc/src/samples/TestOutput.php poc/src/styles/ poc/src/styles/FontFaceDeclaration.php Modified: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php 2006-03-13 07:42:56 UTC (rev 18) +++ poc/src/OpenDocumentContent.php 2006-03-13 08:14:08 UTC (rev 19) @@ -7,6 +7,8 @@ * @version $Revision$ * @package OpenDocument * + * @since 0.4.0 + * * $Id$ */ @@ -18,10 +20,13 @@ private $body; private $text; - /**I - * - */ - public function __construct( $dom=0 ) { + /** + * + * @access public + * + * @since 0.4.0 + */ + public function __construct( $dom=0, $root=0 ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentContent." ); if (empty($dom)) { @@ -36,21 +41,19 @@ } else { // this is part of a single document $this->dom = $dom; - $this->content = $this->dom; + $this->content = $root; $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:content" ); } - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->FontFaceDecl = new FontFaceDelcation(); $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" ); -*/ - } - /** - * - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function __destruct() { unset( $this->dom ); unset( $this->root ); @@ -58,22 +61,54 @@ unset( $this->FontFaceDecl ); } + /** + * + * @access public + * + * @since 0.4.0 + */ 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 ); + /** + * + * @deprecated + * + * @access public + * + * @since 0.4.0 + */ + public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { + $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); } + /** + * + * @access public + * + * @since 0.4.2 + */ + public function getFontFaceDecl() { + return $this->FontFaceDecl; + } + + /** + * + * @access public + * + * @since 0.4.0 + */ public function addAutomaticStyles() { } + /** + * + * @access public + * + * @since 0.4.0 + */ public function addNoAutomaticStyles() { $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:automatics-sytles" ) ); } @@ -89,26 +124,42 @@ */ - public function getBody() { - return $this->body; - } + /** + * + * @return + * + * @access public + * + * @since 0.4.0 + */ + public function getBody() { + return $this->body; + } - /** - * - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function commit() { - $this->root->appendChild( $this->FontFaceDecl ); - // $this->body->appendChild( $this->text ); + $this->root->appendChild( $this->FontFaceDecl->get() ); $this->root->appendChild( $this->body->get() ); $this->content->appendChild( $this->root ); $this->dom->normalize(); $this->isCommited = true; } - /** - * @return - */ + /** + * + * @return DOMDocument + * + * @access public + * @final + * + * @since 0.4.0 + */ final public function get() { if (!$this->isCommited) { $this->commit(); @@ -116,13 +167,18 @@ return $this->dom; } - /** - * - */ + /** + * + * @param $filename string + * + * @access public + * @final + * + * @since 0.4.0 + */ final public function save( $filename ) { $this->get()->save( $filename ); } } - ?> \ No newline at end of file Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 07:42:56 UTC (rev 18) +++ poc/src/OpenDocumentMeta.php 2006-03-13 08:14:08 UTC (rev 19) @@ -3,7 +3,7 @@ * OpenDocumentMeta Class * * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et. al. + * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument @@ -24,7 +24,7 @@ * * @since 0.3.0 */ - public function __construct( $dom=0 ) { + public function __construct( $dom=0, $root=0 ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentMeta." ); @@ -43,7 +43,7 @@ } else { // this is part of a single document $this->dom = $dom; - $this->meta = $this->dom; + $this->meta = $root; } $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); } Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-13 07:42:56 UTC (rev 18) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-13 08:14:08 UTC (rev 19) @@ -2,8 +2,8 @@ /** * OpenDocumentObjectAbstract Class * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et. al. + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument @@ -16,14 +16,9 @@ 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"; + const NS_META = "urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; /** * namespace OpenDocument office @@ -41,16 +36,6 @@ 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"; @@ -79,9 +64,85 @@ * namespace OpenDocument form */ const NS_FORM = "urn:oasis:names:tc:opendocument:xmlns:form:1.0"; - + + /** + * namespace OpenDocument config + */ + const NS_CONFIG = "urn:oasis:names:tc:opendocument:xmlns:config:1.0"; + + /** + * namespace OpenDocument presentation + */ + const NS_PRESENTATION = "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"; + + /** + * namespace OpenDocument dr3d + */ + const NS_DR3D = "urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; + + /** + * namespace OpenDocument animation + */ + const NS_ANIM = "urn:oasis:names:tc:opendocument:xmlns:animation:1.0"; + + /** + * namespace OpenDocument chart + */ + const NS_CHART = "urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; + + /** + * namespace OpenDocument script + */ + const NS_SCRIPT = "urn:oasis:names:tc:opendocument:xmlns:script:1.0"; + + /** + * namespace OpenDocument number + */ + const NS_NUMBER = "urn:oasis:names:tc:opendocument:xmlns:number: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 smil + */ + const NS_SMIL = "urn:oasis:names:tc:opendocument:xmlns:smil-compartible:1.0"; + + /** + * namespace Dublin Core + */ + const NS_DC = "http://purl.org/dc/elements/1.1/"; + + /** + * namespace XLink + */ + const NS_XLINK = "http://www.w3.org/1999/xlink"; + + /** + * namespace XForms + */ + const NS_XFORMS = "http://www.w3.org/2002/xforms"; + + /** + * namespace MathML + */ + const NS_MATHML = "http://www.w3.org/1998/Math/MathML"; + + /** + * @access protected + */ protected $dom; + /** + * @access protected + */ protected $isCommited; /** Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-13 07:42:56 UTC (rev 18) +++ poc/src/OpenDocumentSingle.php 2006-03-13 08:14:08 UTC (rev 19) @@ -2,10 +2,13 @@ /** * OpenDocumentSingle Class * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument + * + * @since 0.3.0 * * $Id$ */ @@ -13,11 +16,15 @@ class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { private $isCommited; private $dom; + private $root; - /** - * - */ - public function __construct( $mimetype = "application/vnd.oasis.opendocument.text" ) { + /** + * + * @access public + * + * @since 0.3.0 + */ + public function __construct( $mimetype = self::defaultMimeType ) { parent::__construct( $mimetype ); $this->logger->debug( "Constructing OpenDocumentSingle." ); @@ -25,42 +32,66 @@ $this->isCommited = false; $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document" ); + $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); } - /** - * - */ + /** + * + * @access public + * + * @since 0.3.0 + */ public function __destruct() { $this->logger->debug( "OpenDocumentSingle destructed." ); parent::__destruct(); } - /** - * - */ + /** + * + * @access public + * + * @since 0.3.0 + */ public function addImage( $fullpath, $origimage, $mimetype ) { $this->copyFileToPackage( $origimage, $fullpath ); $this->makeSubDir( "Pictures" ); $this->manifest->addEntryToManifest( $fullpath, $mimetype ); } - /** - * - */ + /** + * + * @access public + * + * @since 0.3.0 + */ 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 ); } + /** + * + * @access private + * + * @since 0.3.0 + */ private function commit() { $this->logger->debug( "OpenDocumentSingle->commit()" ); foreach( $this->DocumentObjects as $key => $class) { $class->commit(); } + $this->dom->appendChild( $this->root ); $this->isCommited = true; } + /** + * + * @access public + * + * @since 0.3.0 + */ public function get() { if (!($this->isCommited)) { $this->commit(); @@ -69,31 +100,53 @@ return $this->dom->saveXML(); } + /** + * + * @access public + * + * @since 0.3.0 + */ public function save( $altFilename=0 ) { $this->writeZIPFile( $this->get() ); } + /** + * + * @access public + * + * @since 0.3.0 + */ public function getMeta() { - if (!array_key_exists ( "meta", $this->DocumentObjects) ) { - $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta( $this->dom ); + if ( !array_key_exists( "meta", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta( $this->dom, $this->root ); } return $this->DocumentObjects[ "meta" ]; } + /** + * + * @access public + * + * @since 0.3.0 + */ public function getContent() { - if (!array_key_exists ( "content", $this->DocumentObjects) ) { - $this->DocumentObjects[ "content" ] = new OpenDocumentContent( $this->dom ); + if ( !array_key_exists( "content", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "content" ] = new OpenDocumentContent( $this->dom, $this->root ); } return $this->DocumentObjects[ "content" ]; } + /** + * + * @access public + * + * @since 0.3.0 + */ public function getStyle() { - if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = new OpenDocumentStyle( $this->dom ); + if ( !array_key_exists( "style", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "style" ] = new OpenDocumentStyle( $this->dom, $this->root ); } return $this->DocumentObjects[ "style" ]; } - } - ?> \ No newline at end of file Modified: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php 2006-03-13 07:42:56 UTC (rev 18) +++ poc/src/OpenDocumentStyle.php 2006-03-13 08:14:08 UTC (rev 19) @@ -2,14 +2,19 @@ /** * OpenDocumentStyle Class * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * + * @since 0.4.0 + * * $Id$ */ +//require_once( "styles/FontFaceDecl.php" ); + class OpenDocumentStyle extends OpenDocumentObjectAbstract { private $root; @@ -17,10 +22,14 @@ private $FontFaceDecl; private $Styles; private $DefaultStyles; - /** - * - */ - public function __construct( $dom=0 ) { + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function __construct( $dom=0, $root=0 ) { parent::__construct(); if (empty($dom)) { @@ -35,104 +44,215 @@ } else { // this is part of a single document $this->dom = $dom; - $this->style = $this->dom; + $this->style = $root; $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); } - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->FontFaceDecl = new FontFaceDeclaration( $this->dom ); $this->Styles = array(); $this->DefaultStyles = array(); } - /** - * - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function __destruct() { unset( $this->dom ); unset( $this->root ); unset( $this->style ); } + /** + * + * @deprecated + * + * @access public + * + * @since 0.4.0 + */ 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 ); + $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); } - public function getDom() { - return $this->dom; + /** + * + * common family names: graphic, paragraph, table, table-row + * + * @access public + * + * @since 0.4.2 + */ + public function addDefaultStyle( $family = 0 ) { + $node = $this->dom->createElementNS( self::NS_STYLE, "style:default-style" ); + if (!empty($family)) { + $node->setAttributeNS( self::NS_STYLE, "style:family", $family ); + } + $this->DefaultStyles[ $family ] = $node; } - /** - * - * 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 ); + /** + * + * + * @access private + * + * @since 0.4.2 + */ + private function addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ) { + $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:paragraph-properties" ); + if (!empty($styleAttr)) { + foreach( $styleAttr as $key=>$value ) { + $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + } + } + if (!empty($foAttr)) { + foreach( $foAttr as $key=>$value ) { + $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); + } + } + $node->appendChild( $ParProp ); + } + + /** + * + * + * @access private + * + * @since 0.4.2 + */ + private function addTextPropertiesToNode( $node, $styleAttr, $foAttr ) { + $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:text-properties" ); + if (!empty($styleAttr)) { + foreach( $styleAttr as $key=>$value ) { + $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + } + } + if (!empty($foAttr)) { + foreach( $foAttr as $key=>$value ) { + $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); + } + } + $node->appendChild( $ParProp ); + } + + /** + * + * + * @access public + * + * @since 0.4.2 + */ + public function addDefaultStyleParagraphProperties( $family, $styleAttr=0, $foAttr=0 ) { + $node = $this->getDefaultStyle( $family ); + if (empty($node)) { + die("W\xFCrg:" . $family ); } - return $node; - } + $this->addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ); } - /** - * - * 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; - } + + /** + * + * + * @access public + * + * @since 0.4.2 + */ + public function addStyleParagraphProperties( $name, $styleAttr=0, $foAttr=0 ) { + $node = $this->getStyle( $name ); + $this->addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ); } + + /** + * + * + * @access public + * + * @since 0.4.2 + */ + public function addDefaultStyleTextProperties( $family, $styleAttr, $foAttr ) { + $node = $this->getDefaultStyle( $family ); + $this->addTextPropertiesToNode( $node, $styleAttr, $foAttr ); + } + + /** + * + * + * @access public + * + * @since 0.4.2 + */ + public function addStyleTextProperties( $name, $styleAttr, $foAttr ) { + $node = $this->getStyle( $name ); + $this->addTextPropertiesToNode( $node, $styleAttr, $foAttr ); + } + + /** + * + * common family names: graphic, paragraph, table, table-row + * + * @access public + * + * @since 0.4.2 + */ + public function getDefaultStyle( $family = 0 ) { + return $this->DefaultStyles[ $family ]; + } - 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; - } + /** + * + * @access public + * + * @since 0.4.2 + */ + public function addStyle( $name, $styleAttr=0 ) { + $node = $this->dom->createElementNS( self::NS_STYLE, "style:style" ); + $node->setAttributeNS( self::NS_STYLE, "style:name", $name ); + if (!empty($styleAttr)) { + foreach( $styleAttr as $key=>$value ) { + $node->setAttributeNS ( self::NS_STYLE, "style:".$key, $value ); + } + } + $this->Styles[ $name ] = $node; } - public function addStyle( $Style, $name=0 ) { - if (empty($name)) { - $this->Styles[] = $Style; - } else { - $this->Styles[$name] = $Style; - } + /** + * + * @access public + * + * @since 0.4.2 + */ + public function getStyle( $name=0 ) { + return $this->Styles[ $name ]; } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function getFontFaceDecl() { + return $this->FontFaceDecl; + } - - /** - * - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function commit() { - $this->root->appendChild( $this->FontFaceDecl ); + $this->root->appendChild( $this->FontFaceDecl->get() ); $styleStyle = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); // Add all DefaultStyles - foreach( $this->DefaultStyles as $aDefaultStyle) { + foreach( $this->DefaultStyles as $aDefaultStyle ) { $styleStyle->appendChild( $aDefaultStyle ); } // Add all Styles - foreach( $this->Styles as $aStyle) { + foreach( $this->Styles as $aStyle ) { $styleStyle->appendChild( $aStyle ); } $this->root->appendChild( $styleStyle ); @@ -142,9 +262,14 @@ $this->isCommited = true; } - /** - * @return - */ + /** + * + * @return DOMDocument + * + * @access public + * + * @since 0.4.0 + */ final public function get() { if (!$this->isCommited) { $this->commit(); @@ -152,13 +277,15 @@ return $this->dom; } - /** - * - */ + /** + * + * @access public + * @final + * + * @since 0.4.0 + */ final public function save( $filename ) { $this->get()->save( $filename ); - } - + } } - ?> \ No newline at end of file Added: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php (rev 0) +++ poc/src/samples/TestOutput.php 2006-03-13 08:14:08 UTC (rev 19) @@ -0,0 +1,194 @@ +<?php +/** + * SampleClass produces a little OpenDocument and send it to the client + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yan...@us...> + * @version $Revision$ + * @package OpenDocument/Samples + * @since 0.4.2 + * + * $Id$ + */ + +ini_set( "include_path", ini_get( "include_path" ). ";..\\;..\\styles" ); + +require_once( "OpenDocumentFactory.php" ); +require_once( "Log/observer.php" ); + +class TestOutput { + + const DocumentName = "test.odt"; + + const PathToDocument = "D:/PHP/OpenDocument/"; + + 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, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { + $meta->addDublinCore( "title", $title ); + $meta->addDublinCore( "creator", $creator ); + $meta->addDublinCore( "language", "en-EN" ); + $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); + $meta->addGenerator( "" ); + $meta->addInitialCreator( $creator ); + $meta->addCreationDate(); + } + + 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 ) { + $styleAttr = array(); + $styleAttr[ "font-family" ] ="Tahoma"; + $style->getFontFaceDecl()->addFontFace( "Test", $styleAttr ); + unset( $styleAttr ); + + // Set default style + $style->addDefaultStyle( "paragraph" ); + + $foAttr = array( "hypenation-ladder-count" => "no-limit" ); + + $styleAttr = array(); + $styleAttr[ "text-autospace" ] = "ideograph-alpha"; + $styleAttr[ "punctuation-wrap" ] = "hanging"; + $styleAttr[ "line-break" ] = "strict"; + $styleAttr[ "tab-stop-distance" ] = "1.251cm"; + $styleAttr[ "writeing-mode" ] = "page"; + + $style->addDefaultStyleParagraphProperties( "paragraph", $styleAttr, $foAttr ); + + unset( $foAttr ); + unset( $styleAttr ); + + $foAttr = array(); + $foAttr[ "font-size" ] = "12pt"; + $foAttr[ "language" ] = "de"; + $foAttr[ "country" ] = "DE"; + $foAttr[ "hyphenate" ] = "false"; + $foAttr[ "hypenation-remain-char-count" ] = "2"; + $foAttr[ "hypenation-push-char-count" ] = "2"; + + $styleAttr = array(); + $styleAttr[ "use-window-font-color" ] = "true"; + $styleAttr[ "font-name" ] = "Times New Roman"; + $styleAttr[ "font-name-asian" ] = "Arial Unicode MS"; + $styleAttr[ "font-size-asian" ] = "12pt"; + $styleAttr[ "language-asian" ] = "none"; + $styleAttr[ "country-asian" ] = "none"; + $styleAttr[ "font-name-complex" ] = "Tahoma"; + $styleAttr[ "font-site-complex" ] = "12pt"; + $styleAttr[ "language-complex" ] = "none"; + $styleAttr[ "country-complex" ] = "none"; + + $style->addDefaultStyleTextProperties( "paragraph", $styleAttr, $foAttr ); + + //Set a style + $styleAttr = array( "family"=>"paragraph", "class"=>"text" ); + $style->addStyle( "Paragraph", $styleAttr ); + + //Set a style + $style->addStyle( "Heading", $styleAttr ); + + unset( $styleAttr ); + unset( $foAttr ); + + $foAttr = array( "margin-top"=>"0.423cm", "margin-bottom"=>"0.212cm", "keep-with-next"=>"always" ); + $style->addStyleParagraphProperties( "Heading", 0, $foAttr ); + + unset( $foAttr ); + + $foAttr = array( "font-size" => "20pt" ); + $styleAttr = array(); + $styleAttr[ "font-name" ] = "Arial"; + $styleAttr[ "font-name-asian" ] = "MS Mincho"; + $styleAttr[ "font-size" ] = "20pt"; + $styleAttr[ "font-name-complex" ] = "Tahoma1"; + $styleAttr[ "font-size-complex" ] = "20pt"; + $style->addStyleTextProperties( "Heading", $styleAttr, $foAttr ); + } + + function run($post) { + 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; + } + + $SingleDocument = ($post["SingleDocument"] == "true"); + $creator = $post["Creator"]; + $title = $post["Title"]; + + + + header( "Content-type: application/odt" ); + header( "Content-Disposition: attachment; filename=".self::DocumentName ); + header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 + header( "Cache-Control: post-check=0, pre-check=0", false ); + header( "Pragma: no-cache" ); + + // Get a OpenDocument object from the factory: + + if(isset($SingleDocument)) + { + $TestDoc = OpenDocumentFactory::createOpenDocument( + self::DocumentName, + self::PathToDocument, + $SingleDocument + ); + + /* + $TestDoc->attachObserverToLogger( $this->logger ); + */ + + $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); + $this->makeStyle( $TestDoc->getStyle() ); + $this->makeContent( $TestDoc->getContent() ); + + echo $TestDoc->get(); + + //$TestDoc->save(); + } + + + } +} + +if(isset($_POST['SingleDocument'])) +{ + $TestOutput = new TestOutput(); + $TestOutput->run($_POST); +} + +// Do TestInput again ... +?> Property changes on: poc/src/samples/TestOutput.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php (rev 0) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-13 08:14:08 UTC (rev 19) @@ -0,0 +1,168 @@ +<?php +/** + * FontFaceDeclaration Class + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * + * @since 0.4.2 + * + * $Id$ + */ + +class FontFaceDeclaration extends OpenDocumentObjectAbstract { + + private $FontFaceDecl; + + /** + * + * @param DOMDocument $dom + * + * @access public + * + * @since 0.4.2 + */ + public function __construct( $dom ) { + parent::__construct(); + + $this->dom = $dom; + + $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + private function checkStyle( $key, $value ) { + switch ($key) { + case "font-family" : + case "font-style" : + case "font-variant" : + case "font-weight" : + case "font-size" : + case "unicode-range" : + case "units-per-em" : + case "panose-1" : + case "stemv" : + case "stemh" : + case "slope" : + case "cap-height" : + case "x-height" : + case "accent-height" : + case "ascent" : + case "descent" : + case "widths" : + case "bbox" : + case "ideographics" : + case "alphabetic" : + case "mathematical" : + case "hanging" : + // ***FIX ME*** here should be more ... + case "font-face-name" : + case "font-face-format" : return true; + case "font-strech" : + $values = array( "normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", + "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" ); + return in_array( $value, $values ); + break; + default: // ***FIX ME*** should be "false"! + return true; + } + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + private function checkStyle( $key, $value ) { + switch ($key) { + default: // ***FIX ME*** should be "false"! + return true; + } + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function addFontFace( $name, $styleAttr=0, $SVGAttr=0 ) { + $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); + $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); + if (!empty($styleAttr)) { + foreach( $styleAttr as $key => $value ) { + // ***FIX ME*** Here we should check if the keys are possible + if ($this->checkStyle($key, $value)) { + $font->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); + } + } + } + if (!empty($SVGAtrr)) { + foreach( $SVGAttr as $key => $value ) { + // ***FIX ME*** Here we should check if the keys are possible + if ($this->checkSVG( $key, $value )) { + $font->setAttributeNS( self::NS_SVG, "svg:".$key, $value ); + } + } + } + $this->FontFaceDecl->appendChild( $font ); + unset( $font ); + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function addFontFaceOld( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { + $styleAttr = array( "font-family" => $fontFamily ); + if (!empty($genericFamily)) { + $styleAttr[ "font-family-generic" ] = $gernericFamily; + } + if (!empty($fontPitch)) { + $styleAttr[ "font-pitch" ] = $fontPitch; + } + if (!empty($fontCharset)) { + $styleAttr[ "font-charset" ] = $fontCharset; + } + $this->addFontFace( $name, $styleAttr ); + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function commit() { + $this->isCommited = true; + } + + /** + * + * @return DOMDocument + * + * @access public + * @final + * + * @since 0.4.2 + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + return $this->FontFaceDecl; + } + +} +?> \ No newline at end of file Property changes on: poc/src/styles/FontFaceDeclaration.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-13 10:13:45
|
Revision: 21 Author: nmarkgraf Date: 2006-03-13 02:13:38 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=21&view=rev Log Message: ----------- Bug fixes. Modified Paths: -------------- poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 08:58:48 UTC (rev 20) +++ poc/src/OpenDocumentMeta.php 2006-03-13 10:13:38 UTC (rev 21) @@ -165,7 +165,7 @@ * * @since 0.4.0 */ - public function addGenerator( $generator ) { + public function addGenerator( $generator=0 ) { $lgenerator = ""; if (empty($generator)) { Modified: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-13 08:58:48 UTC (rev 20) +++ poc/src/OpenDocumentMetaTest.php 2006-03-13 10:13:38 UTC (rev 21) @@ -13,121 +13,181 @@ require_once "PHPUnit2/Framework/TestCase.php"; require_once "OpenDocumentMeta.php"; - 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/"; +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/"; + + const PathToRNG = "./etc/test/"; + const MetaRNG = "OpenDocument-schema-v1.0-os.rng"; - public function testConstructWithoutDom(){ - $ODM = new OpenDocumentMeta(); + /** + * + * @since 0.4.0 + */ + 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!" ); + $this->assertNotNull( $ODM ); + + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); + + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + + } + + /** + * + * @since 0.4.0 + */ + public function testConstructWithDom(){ +/* ***FIX ME*** + $mimetype = "application/vnd.oasis.opendocument.text"; + $testDom = new DOMDocument( "1.0", "utf-8" ); + + $root = $testDom->createElementNS( self::NS_OFFICE, "office:document" ); + $root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); + $testDom->appendChild( $root ); + + $node = $testDom->createElementNS( self::NS_OFFICE, "office:meta" ); - $xpath = new DOMXPath( $resultDom ); - $xpath->registerNamespace( "office", self::NS_OFFICE ); + $ODM = new OpenDocumentMeta( $testDom, $node ); - // 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." ); + + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); + + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); +*/ + } + + /** + * + * @since 0.4.1 + */ + public function testAddGetDublinCore() { + $ODM = new OpenDocumentMeta(); + $dc_creator_tag = "creator"; + $dc_creator = "Willy Testo"; + + $this->assertNotNull( $ODM ); + + $this->assertEquals( "", $ODM->getDublicCore( $dc_creator_tag ), + "Returned Dublin Core should be empty, was not." ); - // 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(); - $node = $testDom->createElementNS( self::NS_OFFICE, "office:meta" ); + + $ODM->addDublinCore( $dc_creator_tag, $dc_creator ); + $ODM->commit(); - $ODM = new OpenDocumentMeta( $testDom, $node ); - $testDom->appendChild( $node ); - - $this->assertNotNull( $ODM ); + $this->assertEquals( $dc_creator, $ODM->getDublicCore( $dc_creator_tag ), + "Dublin Core entry was not correctly returned." ); - $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(); + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); + + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } + + /** + * + * @since 0.4.2 + */ + public function testAddGetGeneratorWithGenerator() { + $ODM = new OpenDocumentMeta(); + $generator = "Testo Generator"; - $this->assertNotNull( $ODM ); + $this->assertNotNull( $ODM ); - $this->assertEquals( "", $ODM->getDublicCore( "xxx" ), "Returned Dublin Core should be empty, was not." ); + $this->assertEquals( "", $ODM->getGenerator(), + "Generator 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 ); - } + $ODM->addGenerator( $generator ); + $ODM->commit(); + + $this->assertEquals( $generator, $ODM->getGenerator(), + "Generator was not correctly returned. (".$ODM->getGenerator().")" ); + + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); - public function testAddGetGenerator() { - $ODM = new OpenDocumentMeta(); + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } + + /** + * + * @since 0.4.2 + */ + public function testAddGetGeneratorWithOutGenerator() { + $ODM = new OpenDocumentMeta(); - $this->assertNotNull( $ODM ); + $this->assertNotNull( $ODM ); - $this->assertEquals( "", $ODM->getGenerator(), "Generator should be empty, was not." ); + $this->assertEquals( "", $ODM->getGenerator(), + "Generator should be empty, was not." ); - $ODM->addGenerator( "TEST" ); - $ODM->commit(); + $ODM->addGenerator( ); + $ODM->commit(); - $this->assertEquals( "TEST", $ODM->getGenerator(), "Generator was not correctly returned. (".$ODM->getGenerator().")" ); + $this->assertNotNull( $ODM->getGenerator(), + "Generator was not correctly returned, but was null" ); + + $this->assertNotEquals( "", $ODM->getGenerator(), + "Generator was not correctly returned. (".$ODM->getGenerator().")" ); - unset( $ODM ); - } + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); + + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } - public function testAddGetInitialCreator() { - $ODM = new OpenDocumentMeta(); + /** + * + * @since 0.4.2 + */ + public function testAddGetInitialCreator() { + $ODM = new OpenDocumentMeta(); - $this->assertNotNull( $ODM ); + $this->assertNotNull( $ODM ); - $this->assertEquals( "", $ODM->getInitialCreator(), "InitialCreator should be empty, was not." ); + $this->assertEquals( "", $ODM->getInitialCreator(), + "InitialCreator should be empty, was not." ); - $ODM->addInitialCreator( "InitCreator" ); - $ODM->commit(); + $ODM->addInitialCreator( "InitCreator" ); + $ODM->commit(); - $this->assertEquals( "InitCreator", $ODM->getInitialCreator(), "InitialCreator was not correctly returned." ); + $this->assertEquals( "InitCreator", $ODM->getInitialCreator(), + "InitialCreator was not correctly returned." ); - unset( $ODM ); - } - + $Document = $ODM->get(); + $this->assertNotNull($Document, "No result." ); - } \ No newline at end of file + $RelaxNG = self::PathToRNG . self::MetaRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } +} +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-13 10:28:15
|
Revision: 22 Author: nmarkgraf Date: 2006-03-13 02:27:58 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=22&view=rev Log Message: ----------- After making some new test cases for OpenDocumentManifest, I found and fix some tiny bugs. Modified Paths: -------------- poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php Modified: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-13 10:13:38 UTC (rev 21) +++ poc/src/OpenDocumentManifest.php 2006-03-13 10:27:58 UTC (rev 22) @@ -82,8 +82,8 @@ */ 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 ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:media-type", $mimetype ); + $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", $fullpath ); if ( $size >= 0 ) { $node->setAttributeNS( self::NS_MANIFEST, "manifest:size", $size ); } Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-13 10:13:38 UTC (rev 21) +++ poc/src/OpenDocumentManifestTest.php 2006-03-13 10:27:58 UTC (rev 22) @@ -17,49 +17,87 @@ require_once "OpenDocumentManifest.php"; class OpenDocumentManifestTest extends PHPUnit2_Framework_TestCase { - const PathToRNG = "./etc/test/"; - const ManifestRNG = "OpenDocument-manifest-schema-v1.0-os.rng"; + const PathToRNG = "./etc/test/"; + const ManifestRNG = "OpenDocument-manifest-schema-v1.0-os.rng"; - function testConstructionWithOutMimeType() { + /** + * @since 0.4.0 + */ + function testConstructionWithOutMimeType() { - /** - * @since 0.4.0 - */ $ODM = new OpenDocumentManifest(); $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + } + + /** + * @since 0.4.2 + */ + function testConstructionWithMimeType() { + $ODMMT = new OpenDocumentManifest( "alternateMimeType" ); + $this->assertNotNull( $ODMMT, "Error constructing OpenDocumentManifest with a given mimetype." ); + } + + /** + * @since 0.4.2 + */ + function testEmptyManifest() { + $ODM = new OpenDocumentManifest(); + + $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + + $Document = $ODM->get(); + + $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); + + $RelaxNG = self::PathToRNG . self::ManifestRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } - /** - * @since 0.4.2 - */ - function testConstructionWithMimeType() { - $ODMMT = new OpenDocumentManifest( "alternateMimeType" ); + /** + * @since 0.4.2 + */ + function testEntryToManifest() { + $ODM = new OpenDocumentManifest(); - $this->assertNotNull( $ODMMT, "Error constructing OpenDocumentManifest with a given mimetype." ); + $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + + $ODM->addEntryToManifest( "content.xml", "application/vnd.oasis.opendocument.text" ); + + $Document = $ODM->get(); + + $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); + + $RelaxNG = self::PathToRNG . self::ManifestRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } + + /** + * @since 0.4.2 + */ + function testEntryToManifestWithSize() { + $ODM = new OpenDocumentManifest(); - } + $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - /** - * @since 0.4.2 - */ - function testEmptyManifest() { - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); + $ODM->addEntryToManifest( "content.xml", "application/vnd.oasis.opendocument.text", "12345" ); - $Document = $ODM->get(); + $Document = $ODM->get(); - $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); + $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); - $RelaxNG = self::PathToRNG . self::ManifestRNG; + $RelaxNG = self::PathToRNG . self::ManifestRNG; - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), "Manifest does not match Manifest Relax NG schema." ); - - } - - + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "Manifest does not match Manifest Relax NG schema." ); + } + } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-13 11:06:51
|
Revision: 23 Author: nmarkgraf Date: 2006-03-13 03:06:19 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=23&view=rev Log Message: ----------- Minor bug fixes, mostly in PHPDoc comments. Modified Paths: -------------- poc/src/OpenDocument.php poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentContent.php poc/src/OpenDocumentContentBody.php poc/src/OpenDocumentContentBodyText.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentOutput.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentStyle.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php poc/src/samples/TestTranslate.php poc/src/styles/FontFaceDeclaration.php Modified: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocument.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,12 +2,14 @@ /** * OpenDocument interface * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * - * $Id$ + * @since 0.3.0 */ interface OpenDocument { /** Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentAbstract.php 2006-03-13 11:06:19 UTC (rev 23) @@ -5,13 +5,15 @@ * * OpenDocumentAbstract is the basic class for all OpenDocument classes * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * - * $Id$ + * @since 0.3.0 */ class OpenDocumentAbstract { Modified: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentContent.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,14 +2,14 @@ /** * OpenDocumentContent Class * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * * @since 0.4.0 - * - * $Id$ */ class OpenDocumentContent extends OpenDocumentObjectAbstract { Modified: poc/src/OpenDocumentContentBody.php =================================================================== --- poc/src/OpenDocumentContentBody.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentContentBody.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,13 +2,13 @@ /** * OpenDocumentContentBody Class * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument.Content.Body * @since POC 0.5 - * - * $Id$ */ class OpenDocumentContentBody extends OpenDocumentObjectAbstract { Modified: poc/src/OpenDocumentContentBodyText.php =================================================================== --- poc/src/OpenDocumentContentBodyText.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentContentBodyText.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,17 +2,22 @@ /** * OpenDocumentContentBodyText Class * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument.Content.Body.Text - * @since POC 0.5 - * - * $Id$ + * @since 0.4.2 */ class OpenDocumentContentBodyText extends OpenDocumentObjectAbstract { - + /** + * + * @access public + * + * @since 0.4.0 + */ public function __construct( $dom ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); @@ -21,11 +26,23 @@ $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); } + /** + * + * @access public + * + * @since 0.4.0 + */ public function commit() { $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); $this->isCommited = true; } + /** + * + * @access public + * + * @since 0.4.0 + */ public function getTextParagraph( $styleName, $parText=0 ) { $this->logger->debug( "OpenDocumentContentBodyText->getTextParagraph(\"".$styleName."\",\"".$parText."\")" ); if (empty($parText)) { @@ -37,11 +54,23 @@ return $par; } + /** + * + * @access public + * + * @since 0.4.0 + */ public function addToText( $Node ) { $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); $this->text->appendChild( $Node ); } + /** + * + * @access public + * + * @since 0.4.0 + */ public function getTextHeading( $styleName, $headText=0 ) { $this->logger->debug( "OpenDocumentContentBodyText->getTextHeading()" ); if (empty($headText)) { @@ -53,6 +82,12 @@ return $head; } + /** + * + * @access public + * + * @since 0.4.0 + */ public function addNoForms() { $this->logger->debug( "OpenDocumentContentBodyText->addNoForms()" ); $forms = $this->dom->createElementNS( self::NS_OFFICE, "office:forms" ); @@ -63,10 +98,13 @@ $this->text->appendChild( $forms ); unset( $forms ); } - - /** - * @return DOMDocumentFragment body fragment - */ + + /** + * @return DOMDocumentFragment body fragment + * @access public + * + * @since 0.4.0 + */ final public function get() { $this->logger->debug( "OpenDocumentContentBodyText->get()" ); if (!$this->isCommited) { Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentFactory.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,6 +2,8 @@ /** * OpenDocumentFactoy Class * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et. al. * @author Norman Markgraf <nma...@us...> @@ -9,8 +11,6 @@ * @version $Revision$ * @package OpenDocument.Factory * @since 0.4.0 - * - * $Id$ */ /** Modified: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-13 11:06:19 UTC (rev 23) @@ -1,14 +1,16 @@ <?php /** * OpenDocumentFactoyTest Class + * + * $Id$ * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument + * @license GNU General Public License + * @copyright Copyright %copy; 2006, Norman Markgraf, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument * @subpackage UnitTest - * - * $Id$ + * @since 0.4.0 */ require_once "PHPUnit2/Framework/TestCase.php"; require_once( "OpenDocumentFactory.php" ); Modified: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentManifest.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,6 +2,8 @@ /** * OpenDocumentManifest.php * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et. al. * @author Norman Markgraf <nma...@us...> @@ -9,8 +11,6 @@ * @package OpenDocument * * @since 0.3.0 - * - * $Id$ */ class OpenDocumentManifest extends OpenDocumentObjectAbstract { @@ -135,5 +135,4 @@ $this->get()->save( $filename ); } } - ?> \ No newline at end of file Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentManifestTest.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,16 +2,15 @@ /** * Test Class for OpenDocumentManifest * + * $Id$ + * * @copyright Copyright © 2006, Norman Markgraf, et al. * @lecense GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * @subpackage UnitTest - * * @since 0.4.0 - * - * $Id$ */ require_once "PHPUnit2/Framework/TestCase.php"; require_once "OpenDocumentManifest.php"; Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentMeta.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,15 +2,15 @@ /** * OpenDocumentMeta Class * - * @license GNU General Public License + * $Id$ + * + * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument * * @since 0.3.0 - * - * $Id$ */ class OpenDocumentMeta extends OpenDocumentObjectAbstract { Modified: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentMetaTest.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,13 +2,14 @@ /** * Test class for OpenDocumentMeta * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument + * $Id$ + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument * @subpackage UnitTest - * - * $Id$ + * @since 0.4.0 */ require_once "PHPUnit2/Framework/TestCase.php"; require_once "OpenDocumentMeta.php"; Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,15 +2,14 @@ /** * OpenDocumentObjectAbstract Class * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument - * - * @since 0.4.0 - * - * $Id$ + * @since 0.4.0 */ class OpenDocumentObjectAbstract extends OpenDocumentAbstract { Modified: poc/src/OpenDocumentOutput.php =================================================================== --- poc/src/OpenDocumentOutput.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentOutput.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,14 +2,14 @@ /** * SampleClass produces a little OpenDocument and send it to the client * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @since 0.4.2 - * - * $Id$ */ ini_set( "include_path", ini_get( "include_path" ). ";..\\" ); Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentPackage.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,12 +2,13 @@ /** * OpenDocumentPackage Class * + * $Id$ + * * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument - * - * $Id$ + * @since 0.4.0 */ class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { @@ -20,9 +21,11 @@ public $tmp = "c:/TEMP/"; public $path = ""; - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function __construct( $documentName=0, $documentPath=0, $mimetype="application/vnd.oasis.opendocument.text" ) { parent::__construct( $mimetype ); @@ -43,9 +46,11 @@ } } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function __destruct() { $this->logger->debug( "Destructing OpenDocumentPackage." ); $this->removeTmpPackage(); @@ -61,16 +66,20 @@ parent::__destruct(); } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function createPackage() { //$this->compartibility->makeDir( $this->packagetmp ); } - /** - * - */ + /** + * + * @access private + * @since 0.4.0 + */ private function writeDOMToPackage( $fullpath, $dom ) { //$dom->save( str_replace( "\\", "/", $this->packagetmp . $fullpath) ); $tmp = str_replace( "\\", "/", $fullpath ); @@ -81,9 +90,11 @@ unset( $tmp ); } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function writeZIPFile( $data, $alt=0 ) { if (empty($alt)) { $tmp = $this->path . $this->packagename; @@ -104,23 +115,31 @@ unset( $tmp ); } - /** - * - */ + /** + * + * @access private + * @depricated + * @since 0.4.0 + */ private function removeTmpPackage() { // $this->compartibility->removeDir( $this->packagetmp ); } - /** - * - */ + /** + * + * @access private + * @depricated + * @since 0.4.0 + */ private function makeSubDir( $path ) { //$this->compartibility->makeDir( $this->packagetmp . $this->compartibility->sep . $path ); } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function setPackageName( $filename ) { global $logger; $this->logger->debug( "OpenDocumentPackage->setPackageName(" . $filename . ")." ); @@ -130,34 +149,42 @@ $this->logger->debug( "OpenDocumentPackage->set packagetmp to \"" . $this->packagetmp . "\" ..." ); } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function getPackageName() { return $this->packagename; } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function addManifest( $manifest ) { $this->logger->debug( "OpenDocumentPackage->addManifest(...)." ); $this->manifest = $manifest; } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function addImage( $fullpath, $origimage, $mimetype ) { $this->copyFileToPackage( $origimage, $fullpath ); $this->makeSubDir( "Pictures" ); $this->manifest->addEntryToManifest( $fullpath, $mimetype ); } - /** - * - */ + /** + * + * @access public + * @since 0.4.0 + */ public function addXMLDocument( $fullpath, $dom, $mimetype="text/xml" ) { $this->logger->info( "OpenDocumentPackage->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); @@ -165,6 +192,11 @@ $this->writeDOMToPackage( $fullpath, $dom ); } + /** + * + * @access private + * @since 0.4.0 + */ private function commit() { $this->logger->debug( "OpenDocumentPackage->commit()." ); foreach($this->DocumentObjects as $key => $docObj) { @@ -195,6 +227,11 @@ $this->isCommited = true; } + /** + * + * @access public + * @since 0.4.0 + */ public function get() { if (!($this->isCommited)) { $this->commit(); @@ -203,10 +240,20 @@ return $this->zip->file(); } + /** + * + * @access public + * @since 0.4.0 + */ public function save( $altFilename=0 ) { $this->writeZIPFile( $this->get() ); } + /** + * + * @access public + * @since 0.4.0 + */ public function getMeta() { if (!array_key_exists ( "meta", $this->DocumentObjects) ) { $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta(); @@ -214,6 +261,11 @@ return $this->DocumentObjects[ "meta" ]; } + /** + * + * @access public + * @since 0.4.0 + */ public function getContent() { if (!array_key_exists ( "content", $this->DocumentObjects) ) { $this->DocumentObjects[ "content" ] = new OpenDocumentContent(); @@ -221,6 +273,11 @@ return $this->DocumentObjects[ "content" ]; } + /** + * + * @access public + * @since 0.4.0 + */ public function getStyle() { if (!array_key_exists ( "style", $this->DocumentObjects) ) { $this->DocumentObjects[ "style" ] = new OpenDocumentStyle(); Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentSingle.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,6 +2,8 @@ /** * OpenDocumentSingle Class * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> @@ -9,8 +11,6 @@ * @package OpenDocument * * @since 0.3.0 - * - * $Id$ */ class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { Modified: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/OpenDocumentStyle.php 2006-03-13 11:06:19 UTC (rev 23) @@ -1,6 +1,8 @@ <?php /** * OpenDocumentStyle Class + * + * $Id$ * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf et al. @@ -9,8 +11,6 @@ * @package OpenDocument * * @since 0.4.0 - * - * $Id$ */ //require_once( "styles/FontFaceDecl.php" ); Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/samples/TestInput.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,14 +2,16 @@ /** * SampleClass produces a little OpenDocument and send it to the client * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument/input - * @since 0.4.2 + * $Id$ * - * $Id$ + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @licens GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yaw...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage samples + * @since 0.4.2 */ ?> <html> Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/samples/TestOutput.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,14 +2,16 @@ /** * SampleClass produces a little OpenDocument and send it to the client * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yan...@us...> - * @version $Revision$ - * @package OpenDocument/Samples - * @since 0.4.2 + * $Id$ * - * $Id$ + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yan...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage samples + * @since 0.4.2 */ ini_set( "include_path", ini_get( "include_path" ). ";..\\;..\\styles" ); Modified: poc/src/samples/TestTranslate.php =================================================================== --- poc/src/samples/TestTranslate.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/samples/TestTranslate.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,13 +2,15 @@ /** * TestTranslate class that will translate a given formatting style to ODF formatting. * - * @copyright GNU General Public License - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument/input - * @since 0.4.2 + * $Id$ * - * $Id$ + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Alex Latchford <yaw...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage samles + * @since 0.4.2 */ require_once( "Log/observer.php" ); Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-13 10:27:58 UTC (rev 22) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-13 11:06:19 UTC (rev 23) @@ -2,15 +2,16 @@ /** * FontFaceDeclaration Class * + * $Id$ + * * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument + * @subpackage styles * - * @since 0.4.2 - * - * $Id$ + * @since 0.4.2 */ class FontFaceDeclaration extends OpenDocumentObjectAbstract { @@ -121,7 +122,7 @@ /** * * @access public - * + * @depricated * @since 0.4.2 */ public function addFontFaceOld( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-13 15:14:04
|
Revision: 24 Author: nmarkgraf Date: 2006-03-13 07:13:43 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=24&view=rev Log Message: ----------- THIS IS THE FIRST RELEASE OF 0.4.3! Major changes - Moved and renamed OpenDocumentContentBody*.php to content/Body*.php. - Change OpenDocumentContent to match this moving and renaming. Minor changes: - Added some new comments - New revision tag in OpenDocumentAbstract. - New release tag -> 0.4.3 Modified Paths: -------------- poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentContent.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentStyle.php poc/src/samples/TestTranslate.php Added Paths: ----------- poc/src/content/ poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php Removed Paths: ------------- poc/src/OpenDocumentContentBody.php poc/src/OpenDocumentContentBodyText.php Modified: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentAbstract.php 2006-03-13 15:13:43 UTC (rev 24) @@ -8,7 +8,7 @@ * $Id$ * * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et. al. + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument @@ -18,28 +18,74 @@ class OpenDocumentAbstract { /** - * + * Is this ALPHA, BETA or STABLE code? */ const Revision = "ALPHA"; - const Release = "0.4.2"; - const Copyright = "(C) in 2006 by Norman Markgraf published under GPL 2.0"; + + /** + * Release number: X.Y.Z + * + * X = 0 : "proof of concept" (a.k.a POC) code + * X = 1 : "stage 1" code + */ + const Release = "0.4.3"; + + /** + * Copyright notice for this package. + */ + const Copyright = "(C) in 2006 by Norman Markgraf, Alex Latchford, et al."; + + /** + * Name of this package. + */ const PackageName = "OpenDocumentPHP"; + + /** + * Default mime type is set to a text document. + */ const defaultMimeType = "application/vnd.oasis.opendocument.text"; + /** + * The PEAR::Log logger + * + * @access protected + * @since 0.4.0 + */ protected $logger; + /** + * The mime type of the document + * + * @access protected + * @since 0.4.0 + */ protected $mimetype; - /** - * This is the storage for all OpenDocument objects - */ + /** + * This is the storage for all OpenDocument objects + * + * @access protected + * @since 0.3.0 + */ protected $DocumentObjects; + /** + * This construtor will set the mimetype of this document and start logging. + * + * Therefor this line is included in this constructor: + * <code> + * $this->logger = &Log::factory( "null", "", "OpenDocument" ); + * </code> + * + * @param string $mimetype The mime type of this document. + * @access public + * @since 0.3.0 + */ 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." ); + // make an array for all the Document Objects. $this->DocumentObjects = array(); if (!empty($mimetype)) { @@ -48,34 +94,73 @@ } /** - * - */ + * + * @access public + * @since 0.3.0 + */ public function __destruct() { $this->logger->debug( "OpenDocumentAbstract destructed." ); $this->logger->close(); } + /** + * Returns revision information + * + * @return string Revision information. + * @access public + * @final + * @since 0.4.0 + */ final public function getRevision() { - return self::Revision; + $Revision = ""; + return "(".substr("$Revision$",-2).")".self::Revision; } + /** + * Returns release and revision information. + * + * @return string Release and revision information. + * @access public + * @final + * @since 0.4.0 + */ final public function getRelease() { return self::Release.".".self::Revision; } + /** + * Returns some informations about this package, release and copyright. + * + * @return string Package name, release and copyright. + * @access public + * @final + * @since 0.4.0 + */ final public function getPackageInformation() { return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; } + /** + * + * @access public + * @final + * @since 0.4.0 + */ final public function attachObserverToLogger( $observer ) { $this->logger->attach( $observer ); } + /** + * Returns the setted mime type of this document. + * + * @return string Current mime type of this document. + * @access public + * @final + * @since 0.4.0 + */ final public function getMimeType() { return $this->mimetype; } - } - ?> \ No newline at end of file Modified: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentContent.php 2006-03-13 15:13:43 UTC (rev 24) @@ -4,7 +4,8 @@ * * $Id$ * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument @@ -12,6 +13,8 @@ * @since 0.4.0 */ +require_once( "content/Body.php" ); + class OpenDocumentContent extends OpenDocumentObjectAbstract { private $root; @@ -21,7 +24,10 @@ private $text; /** + * Class construtor. * + * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. + * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. * @access public * * @since 0.4.0 @@ -45,7 +51,7 @@ $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:content" ); } $this->FontFaceDecl = new FontFaceDelcation(); - $this->body = new OpenDocumentContentBody( $this->dom ); + $this->body = new Body( $this->dom ); } /** @@ -169,7 +175,7 @@ /** * - * @param $filename string + * @param string $filename * * @access public * @final Deleted: poc/src/OpenDocumentContentBody.php =================================================================== --- poc/src/OpenDocumentContentBody.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentContentBody.php 2006-03-13 15:13:43 UTC (rev 24) @@ -1,76 +0,0 @@ -<?php -/** - * OpenDocumentContentBody Class - * - * $Id$ - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument.Content.Body - * @since POC 0.5 - */ - -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.php =================================================================== --- poc/src/OpenDocumentContentBodyText.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentContentBodyText.php 2006-03-13 15:13:43 UTC (rev 24) @@ -1,116 +0,0 @@ -<?php -/** - * OpenDocumentContentBodyText Class - * - * $Id$ - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument.Content.Body.Text - * @since 0.4.2 - */ - -class OpenDocumentContentBodyText extends OpenDocumentObjectAbstract { - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __construct( $dom ) { - parent::__construct(); - $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); - - $this->dom = $dom; - $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function commit() { - $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); - $this->isCommited = true; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function addToText( $Node ) { - $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); - $this->text->appendChild( $Node ); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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 - * @access public - * - * @since 0.4.0 - */ - final public function get() { - $this->logger->debug( "OpenDocumentContentBodyText->get()" ); - if (!$this->isCommited) { - $this->commit(); - } - return $this->text; - } -} -?> \ No newline at end of file Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentFactory.php 2006-03-13 15:13:43 UTC (rev 24) @@ -5,11 +5,11 @@ * $Id$ * * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et. al. + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> * @author Alex Latchford <yaw...@us...> * @version $Revision$ - * @package OpenDocument.Factory + * @package OpenDocument * @since 0.4.0 */ @@ -50,7 +50,7 @@ final class OpenDocumentFactory { const defaultMimeType = "application/vnd.oasis.opendocument.text"; /** - * Creates a OpenDocument. + * Creates an OpenDocument. * * @param string $documentName * @param string $documentPath Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentMeta.php 2006-03-13 15:13:43 UTC (rev 24) @@ -2,6 +2,9 @@ /** * OpenDocumentMeta Class * + * In this class we will store all meta stuff. + * + * * $Id$ * * @license GNU General Public License @@ -15,16 +18,29 @@ class OpenDocumentMeta extends OpenDocumentObjectAbstract { + /** + * This points to the "root" element of the meta data. + * + * @since 0.3.0 + */ private $root; - private $meta; - + /** - * - * @access public + * This points to the "root" element of the document meta data structure. * - * @since 0.3.0 + * @since 0.4.0 */ - public function __construct( $dom=0, $_root=0 ) { + private $meta; + + /** + * + * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. + * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. + * @access public + * + * @since 0.3.0 + */ + public function __construct( $dom=0, $root=0 ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentMeta." ); @@ -42,17 +58,17 @@ } else { // this is part of a single document $this->dom = $dom; - $this->meta = $_root; + $this->meta = $root; } $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); } - /** - * - * @access public - * - * @since 0.3.0 - */ + /** + * + * @access public + * + * @since 0.3.0 + */ public function __destruct() { unset( $dom ); unset( $root ); @@ -63,12 +79,13 @@ parent::__destruct(); } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * + * @todo THIS CODE IS HIGHLY UNTESTED AND CURRENTLY NOT USEABLE AT ALL!!! + * @access public + * + * @since 0.4.0 + */ public function load( $filename ) { $tmpDom = new DOMDocument(); @@ -95,12 +112,15 @@ return true; } - /** - * - * @access public - * - * @since 0.3.2 - */ + /** + * Add Dublin Core meta data. + * + * @param string $dc Tag (without "dc:") for Dublin Core meta data. + * @param string $value Value of the Dublin Core meta data. + * @access public + * + * @since 0.3.2 + */ public function addDublinCore( $dc, $value) { $this->logger->debug( "OpenDocumentMeta->addDublinCore: ". $value ."." ); $node = $this->dom->createElementNS( self::NS_DC, "dc:".$dc, $value ); @@ -108,12 +128,16 @@ unset( $node ); } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * Retrieve Dublin Core meta data. + * + * @param string $dc Tag (without "dc:") for Dublin Core meta data. + * @return string Value of the Dublin Core meta data. + * + * @access public + * + * @since 0.4.0 + */ public function getDublicCore( $dc ) { $retValue = ""; $nodelist = $this->dom->getElementsByTagNameNS( self::NS_DC, $dc ); @@ -128,15 +152,16 @@ /** * Add the "Creation Date" of the current OpenDocument to the Meta file. * - * You can give a timestamp made by <c>mktime()</c> or nothing as parameter. + * You can give a timestamp made by <b>mktime()</b> or nothing as a parameter. * If no parameter is given, the current time and date will be used. * <code> + * // Let $Document be a class implementing the OpenDocument interface. * // This will set the current date and time: - * Document->getMeta()->addCreationDate() - * // This will set the creation date to (April, 4th 1968 - 10:11:12) - * Document->getMeta()->addCreationDate( mktime( 10, 11, 12, 4, 3, 1968 ) ); + * $Document->getMeta()->addCreationDate() + * // This will set the creation date to (April, 3th 1968 - 10:11:12) + * $Document->getMeta()->addCreationDate( mktime( 10, 11, 12, 4, 3, 1968 ) ); * </code> - * @param $date Timestamp or 0 = now. + * @param timestamp $date Timestamp or 0 = now. * * @access public * @@ -159,12 +184,25 @@ } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * Add a "Generator" to the Meta file. + * + * You can give your own generator message or use the default value, given by + * OpenDocumentPHP. + * <code> + * // Let $Document be a class implementing the OpenDocument interface. + * // This will set the default value of the generator: + * $Document->getMeta()->addGenerator() + * // This will set the the generator message to "My OD generator": + * $Document->getMeta()->addGenerator( "My OD generator" ); + * </code> + * + * @param string $generator New generator message, of default if 0. + * + * @access public + * + * @since 0.4.0 + */ public function addGenerator( $generator=0 ) { $lgenerator = ""; @@ -183,12 +221,27 @@ unset( $lgenerator ); } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * Retrieve the current generator message. + * + * You can get the current information about the generator of the Meta file by: + * <code> + * // Let $Document be a class implementing the OpenDocument interface. + * $IsGeneratedByOpenDocumentPHP = stripos( $Document->getGenerator(), "OpenDocumentPHP/" ); + * if ( $IsGeneratedByOpenDocumentPHP === false ) { + * echo "This file was (probably) not created by OpenDocumentPHP!"; + * } + * if ( $IfGeneratedByOpenDocumentPHP !== false ) { + * echo "This file was generated by OpenDocumentPHP!"; + * } + * </code> + * + * @return string Current generator information stored in Meta. + * + * @access public + * + * @since 0.4.0 + */ public function getGenerator() { $retValue = ""; @@ -202,24 +255,24 @@ return $retValue; } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * + * @access public + * + * @since 0.4.0 + */ 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 ); } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function getInitialCreator() { $retValue = ""; $nodelist = $this->dom->getElementsByTagNameNS( self::NS_META, "initial-creator" ); @@ -231,12 +284,12 @@ return $retValue; } - /** - * - * @access public - * - * @since 0.4.0 - */ + /** + * + * @access public + * + * @since 0.4.0 + */ public function addUserDefinedMetadata( $name, $type, $value ) { $node = $this->dom->createElementNS( self::NS_META, "meta:user-defined" ); $node->setAttributeNS( self::NS_META, "meta:name", $name ); @@ -250,14 +303,15 @@ unset( $node ); } - /** - * Commits all changes to Meta and normalize them. After a commit call, you couldn't add - * new things to Meta. - * - * @access public - * - * @since 0.4.0 - */ + /** + * Commits all changes to Meta and normalize them. + * + * After a commit call, you couldn't add new things to Meta. + * + * @access public + * + * @since 0.4.0 + */ public function commit() { $this->meta->appendChild( $this->root ); $this->dom->normalize(); @@ -265,19 +319,19 @@ $this->logger->debug( "OpenDocumentMeta->commit()." ); } - /** - * Get Meta as DOMDocument. - * - * If this object is not commited, this method will first call <c>commit()</c> and return the - * Meta as DOMDocument after that. - * - * @return DOMDocument Meta as DOMDocument. - * - * @access public - * @final - * - * @since 0.4.0 - */ + /** + * Get Meta as DOMDocument. + * + * If this object is not commited, this method will first call <b>commit()</b> and return the + * Meta as DOMDocument after that. + * + * @return DOMDocument Meta as DOMDocument. + * + * @access public + * @final + * + * @since 0.4.0 + */ final public function get() { if (!$this->isCommited) { $this->commit(); @@ -286,13 +340,13 @@ return $this->dom; } - /** - * - * @access public - * @final - * - * @since 0.4.0 - */ + /** + * + * @access public + * @final + * + * @since 0.4.0 + */ final public function save( $filename ) { $this->logger->debug( "OpenDocumentMeta->save(". $filename .")." ); $this->get()->save( $filename ); Modified: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/OpenDocumentStyle.php 2006-03-13 15:13:43 UTC (rev 24) @@ -24,7 +24,10 @@ private $DefaultStyles; /** + * Class construtor. * + * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. + * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. * @access public * * @since 0.4.0 @@ -53,6 +56,7 @@ } /** + * Class destructor. * * @access public * Added: poc/src/content/Body.php =================================================================== --- poc/src/content/Body.php (rev 0) +++ poc/src/content/Body.php 2006-03-13 15:13:43 UTC (rev 24) @@ -0,0 +1,123 @@ +<?php +/** + * body (former OpenDocumentContentBody) Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage content + * @since 0.4.3 + */ + +class Body extends OpenDocumentObjectAbstract { + + /** + * + * @access private + * @since 0.4.3 + */ + private $DomFragment; + + /** + * + * @access private + * @since 0.4.3 + */ + private $body; + + /** + * + * @access private + * @since 0.4.3 + */ + private $Fragments; + + /** + * Class construtor. + * + * @access public + * @since 0.4.3 + */ + public function __construct( $dom ) { + parent::__construct(); + $this->logger->debug( "Constructing content/Body." ); + + $this->dom = $dom; + $this->BodyFragment = $this->dom->createDocumentFragment(); + $this->body = $this->dom->createElementNS( self::NS_OFFICE, "office:body" ); + $this->Fragments = array(); + } + + /** + * + * @access public + * @since 0.4.3 + */ + public function commit() { + $this->logger->debug( "content/Body->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; + } + + /** + * + * @access private + * @since 0.4.3 + */ + private function getByNamespace( $NS, $class ) { + $this->logger->debug( "content/Body->getByNamespace(\"".$NS."\", \"".$class."\")" ); + if (!array_key_exists( $NS, $this->Fragments ) ) { + $this->Fragments[ $NS ] = new $class( $this->dom ); + } + return $this->Fragments[ $NS ]; + } + + /** + * + * @access public + * @since 0.4.3 + */ + public function getText() { + $this->logger->debug( "content/Body->getText()" ); + return $this->getByNamespace( self::NS_TEXT, "BodyText" ); + } + + /** + * + * @access public + * @since 0.4.3 + */ + public function getTable() { + $this->logger->debug( "content/Body->getTable()" ); + return $this->getByNamespace( self::NS_TABLE, "BodyTable" ); + } + + /** + * + * @return DOMDocumentFragment body fragment + * @access public + * @since 0.4.3 + */ + final public function get() { + $this->logger->debug( "content/Body->get()" ); + if (!$this->isCommited) { + $this->commit(); + } + return $this->body; + } + +} + +?> \ No newline at end of file Property changes on: poc/src/content/Body.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/content/BodyTable.php =================================================================== --- poc/src/content/BodyTable.php (rev 0) +++ poc/src/content/BodyTable.php 2006-03-13 15:13:43 UTC (rev 24) @@ -0,0 +1,53 @@ +<?php +/** + * BodyTable (former OpenDocumentContentBodyTable) Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage content + * @since 0.4.3 + */ + +class BodyTable extends OpenDocumentObjectAbstract { + /** + * Class construtor. + * + * @access public + * @since 0.4.3 + */ + public function __construct( $dom ) { + parent::__construct(); + + $this->dom = $dom; + $this->DomFragment = $dom->createDocumentFragment(); + $this->body = $this->DomFragment->createElementNS( self::NS_OFFICE, "office:table" ); + } + + /** + * + * @access public + * @since 0.4.3 + */ + public function commit() { + $this->isCommited = true; + } + + /** + * @return DOMDocumentFragment body fragment + * @access public + * @final + * @since 0.4.3 + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + return $this->DomFragment; + } +} +?> \ No newline at end of file Property changes on: poc/src/content/BodyTable.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/content/BodyText.php =================================================================== --- poc/src/content/BodyText.php (rev 0) +++ poc/src/content/BodyText.php 2006-03-13 15:13:43 UTC (rev 24) @@ -0,0 +1,118 @@ +<?php +/** + * BodyTest (former OpenDocumentContentBodyText) Class + * + * $Id$ + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage content + * @since 0.4.0 + */ + +class BodyText extends OpenDocumentObjectAbstract { + /** + * Class construtor. + * + * @access public + * + * @since 0.4.0 + */ + public function __construct( $dom ) { + parent::__construct(); + $this->logger->debug( "Constructing OpenDocumentContentBodyText." ); + + $this->dom = $dom; + $this->text = $this->dom->createElementNS( self::NS_OFFICE, "office:text" ); + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function commit() { + $this->logger->debug( "OpenDocumentContentBodyText->commit()" ); + $this->isCommited = true; + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + 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; + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function addToText( $Node ) { + $this->logger->debug( "OpenDocumentContentBodyText->addToText()" ); + $this->text->appendChild( $Node ); + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + 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; + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + 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 + * @access public + * + * @since 0.4.0 + */ + final public function get() { + $this->logger->debug( "OpenDocumentContentBodyText->get()" ); + if (!$this->isCommited) { + $this->commit(); + } + return $this->text; + } +} +?> \ No newline at end of file Property changes on: poc/src/content/BodyText.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/samples/TestTranslate.php =================================================================== --- poc/src/samples/TestTranslate.php 2006-03-13 11:06:19 UTC (rev 23) +++ poc/src/samples/TestTranslate.php 2006-03-13 15:13:43 UTC (rev 24) @@ -9,7 +9,7 @@ * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument - * @subpackage samles + * @subpackage samples * @since 0.4.2 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-15 08:54:30
|
Revision: 26 Author: nmarkgraf Date: 2006-03-15 00:54:17 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=26&view=rev Log Message: ----------- One add and some bug fixes: - Added a new test case, OpenDocumentSingleTest, which proves that our current OpenDocumentSingle implementation has some bugs. - Minor bug fixes in OpenDocumentManifestTest and samples/TestOutput @Alex: Maybe you can try to fix the bug in OpenDocumentSingle? Norman Modified Paths: -------------- poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentSingle.php poc/src/samples/TestOutput.php Added Paths: ----------- poc/src/OpenDocumentSingleTest.php Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-14 13:57:51 UTC (rev 25) +++ poc/src/OpenDocumentManifestTest.php 2006-03-15 08:54:17 UTC (rev 26) @@ -5,7 +5,7 @@ * $Id$ * * @copyright Copyright © 2006, Norman Markgraf, et al. - * @lecense GNU General Public License + * @license GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-14 13:57:51 UTC (rev 25) +++ poc/src/OpenDocumentSingle.php 2006-03-15 08:54:17 UTC (rev 26) @@ -14,13 +14,31 @@ */ class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { + /** + * + * @access private + * @since 0.3.0 + */ private $isCommited; + + /** + * + * @access private + * @since 0.3.0 + */ private $dom; + + /** + * + * @access private + * @since 0.3.0 + */ private $root; - /** - * namespace OpenDocument office - */ + /** + * namespace OpenDocument office + * @since 0.3.0 + */ const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; /** @@ -84,9 +102,15 @@ */ private function commit() { $this->logger->debug( "OpenDocumentSingle->commit()" ); - foreach( $this->DocumentObjects as $key => $class) { - $class->commit(); - } + if (array_key_exists( "meta", $this->DocumentObjects )) { + $this->DocumentObjects["meta"]->commit(); + } + if (array_key_exists( "style", $this->DocumentObjects )) { + $this->DocumentObjects["style"]->commit(); + } + if (array_key_exists( "content", $this->DocumentObjects )) { + $this->DocumentObjects["content"]->commit(); + } $this->dom->appendChild( $this->root ); $this->isCommited = true; } @@ -98,17 +122,29 @@ * @since 0.3.0 */ public function get() { - if (!($this->isCommited)) { - $this->commit(); - } $this->logger->debug( "OpenDocumentSingle->get()" ); - return $this->dom->saveXML(); + return $this->getAsDOM()->saveXML(); } /** * * @access public * + * @since 0.4.3 + */ + public function getAsDOM() { + if (!($this->isCommited)) { + $this->commit(); + } + $this->logger->debug( "OpenDocumentSingle->getAsDOM()" ); + return $this->dom; + } + + + /** + * + * @access public + * * @since 0.3.0 */ public function save( $altFilename=0 ) { Added: poc/src/OpenDocumentSingleTest.php =================================================================== --- poc/src/OpenDocumentSingleTest.php (rev 0) +++ poc/src/OpenDocumentSingleTest.php 2006-03-15 08:54:17 UTC (rev 26) @@ -0,0 +1,138 @@ +<?php +/** + * TestCase for OpenDocumentSingle class + * + * $Id$ + * + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @license GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage UnitTest + * @since 0.4.3 + */ + +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "OpenDocumentSingle.php"; + +class OpenDocumentSingleTest extends PHPUnit2_Framework_TestCase { + const PathToRNG = "./etc/test/"; + const DocumentRNG = "OpenDocument-schema-v1.0-os.rng"; + + /** + * @since 0.4.3 + */ + function testLittleSingleDocument() { + $ODT = new OpenDocumentSingle(); + + $this->assertNotNull( $ODT, "Error constructing OpenDocumentManifest without a given mimetype." ); + + $meta = $ODT->getMeta(); + $meta->addDublinCore( "title", "Test" ); + $meta->addDublinCore( "creator", "Testo Tester" ); + $meta->addDublinCore( "language", "en-EN" ); + $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); + $meta->addGenerator( ); + $meta->addInitialCreator( "Testo Tester" ); + $meta->addCreationDate(); + + $content = $ODT->getContent(); + + $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!" ) ); + + $style = $ODT->getStyle(); + + $styleAttr = array(); + $styleAttr[ "font-family" ] ="Tahoma"; + $style->getFontFaceDecl()->addFontFace( "Test", $styleAttr ); + unset( $styleAttr ); + + // Set default style + $style->addDefaultStyle( "paragraph" ); + + $foAttr = array( "hypenation-ladder-count" => "no-limit" ); + + $styleAttr = array(); + $styleAttr[ "text-autospace" ] = "ideograph-alpha"; + $styleAttr[ "punctuation-wrap" ] = "hanging"; + $styleAttr[ "line-break" ] = "strict"; + $styleAttr[ "tab-stop-distance" ] = "1.251cm"; + $styleAttr[ "writeing-mode" ] = "page"; + + $style->addDefaultStyleParagraphProperties( "paragraph", $styleAttr, $foAttr ); + + unset( $foAttr ); + unset( $styleAttr ); + + $foAttr = array(); + $foAttr[ "font-size" ] = "12pt"; + $foAttr[ "language" ] = "de"; + $foAttr[ "country" ] = "DE"; + $foAttr[ "hyphenate" ] = "false"; + $foAttr[ "hypenation-remain-char-count" ] = "2"; + $foAttr[ "hypenation-push-char-count" ] = "2"; + + $styleAttr = array(); + $styleAttr[ "use-window-font-color" ] = "true"; + $styleAttr[ "font-name" ] = "Times New Roman"; + $styleAttr[ "font-name-asian" ] = "Arial Unicode MS"; + $styleAttr[ "font-size-asian" ] = "12pt"; + $styleAttr[ "language-asian" ] = "none"; + $styleAttr[ "country-asian" ] = "none"; + $styleAttr[ "font-name-complex" ] = "Tahoma"; + $styleAttr[ "font-site-complex" ] = "12pt"; + $styleAttr[ "language-complex" ] = "none"; + $styleAttr[ "country-complex" ] = "none"; + + $style->addDefaultStyleTextProperties( "paragraph", $styleAttr, $foAttr ); + + //Set a style + $styleAttr = array( "family"=>"paragraph", "class"=>"text" ); + $style->addStyle( "Paragraph", $styleAttr ); + + //Set a style + $style->addStyle( "Heading", $styleAttr ); + + unset( $styleAttr ); + unset( $foAttr ); + + $foAttr = array( "margin-top"=>"0.423cm", "margin-bottom"=>"0.212cm", + "keep-with-next"=>"always" ); + $style->addStyleParagraphProperties( "Heading", 0, $foAttr ); + + unset( $foAttr ); + + $foAttr = array( "font-size" => "20pt" ); + $styleAttr = array(); + $styleAttr[ "font-name" ] = "Arial"; + $styleAttr[ "font-name-asian" ] = "MS Mincho"; + $styleAttr[ "font-size" ] = "20pt"; + $styleAttr[ "font-name-complex" ] = "Tahoma1"; + $styleAttr[ "font-size-complex" ] = "20pt"; + $style->addStyleTextProperties( "Heading", $styleAttr, $foAttr ); + + $Document = $ODT->getAsDOM(); + + $this->assertNotNull( $Document, "Returned value of OpenDocumentSingle->get() is NULL." ); + + $RelaxNG = self::PathToRNG . self::DocumentRNG; + + $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), + "SingleDocument does not match OpenDocument Relax NG schema." ); + + } + +} +?> \ No newline at end of file Property changes on: poc/src/OpenDocumentSingleTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-14 13:57:51 UTC (rev 25) +++ poc/src/samples/TestOutput.php 2006-03-15 08:54:17 UTC (rev 26) @@ -49,7 +49,7 @@ $meta->addDublinCore( "creator", $creator ); $meta->addDublinCore( "language", "en-EN" ); $meta->addDublinCore( "date", date("Y-m-d\TH:i:s") ); - $meta->addGenerator( "" ); + $meta->addGenerator( ); $meta->addInitialCreator( $creator ); $meta->addCreationDate(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-20 08:06:20
|
Revision: 30 Author: nmarkgraf Date: 2006-03-20 00:05:41 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=30&view=rev Log Message: ----------- BIG UPDATE! Before we publish POC 0.5 I did a lot of updates to make it easier to fix the SingleDocument bug. - Renamed, moved or deleted some classes. You will find OpenDocument*.php know sorted and without OpenDocument prefix in the sub directories manifest, meta, content, styles, settings. - New abstract methods in OpenDocument.php which OpenDocumentSingle and OpenDocumentPackage have to implement. Mostly this just a serving of Body, Styles, AutomaticStyles, MasterStyles, Settings, ... classes to the user. This is a big update with many fixes before SVN is in a stable condition again. Modified Paths: -------------- poc/src/AllInclude.inc poc/src/OpenDocument.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/styles/FontFaceDeclaration.php Added Paths: ----------- poc/src/content/Content.php poc/src/content/Scripts.php poc/src/manifest/ poc/src/manifest/Manifest.php poc/src/manifest/ManifestTest.php poc/src/meta/ poc/src/meta/Meta.php poc/src/meta/MetaTest.php poc/src/settings/ poc/src/settings/Settings.php poc/src/styles/AutomaticStyles.php poc/src/styles/MasterStyles.php poc/src/styles/Style.php poc/src/styles/Styles.php Removed Paths: ------------- poc/src/OpenDocumentContent.php poc/src/OpenDocumentManifest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentStyle.php Modified: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/AllInclude.inc 2006-03-20 08:05:41 UTC (rev 30) @@ -22,10 +22,11 @@ require_once( "OpenDocumentObjectAbstract.php" ); require_once( "OpenDocumentSingle.php" ); require_once( "OpenDocumentPackage.php" ); -require_once( "OpenDocumentStyle.php" ); -require_once( "OpenDocumentContent.php" ); -require_once( "OpenDocumentMeta.php" ); -require_once( "OpenDocumentManifest.php" ); +require_once( "styles/Style.php" ); +require_once( "styles/Styles.php" ); +require_once( "content/Content.php" ); +require_once( "meta/Meta.php" ); +require_once( "manifest/Manifest.php" ); require_once( "content/Body.php" ); require_once( "content/BodyText.php" ); require_once( "content/BodyTable.php" ); Modified: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocument.php 2006-03-20 08:05:41 UTC (rev 30) @@ -2,32 +2,118 @@ /** * OpenDocument interface * + * This is the main interface for OpenDocumentPHP. There are two implementations + * of this interface: + * <ol> + * <li>OpenDocumentSingle</li> This implements one OpenDocument in one XML file. + * <li>OpenDocumentPackage</li> This implements one OpenDocument in one ZIP file with several XML files. + * </ol> + * + * <b>OpenDocumentSingle</b> + * This class will include Meta, Settings, Scripts, FontFaceDeclarations, Styles, + * Automatic Styles, Master Styles, and Body classes in one single XML file. + * + * <b>OpenDocuemntPackage</b> + * This class will include the following files in one ZIP file with a Manifest file (like JAR files + * for Java) Meta in meta.xml, Settings in settings.xml, Scripts, FontFaceDeclarations, Automatic Styles, + * Body in content.xml, FontFaceDelarations, Styles, Automatic Styles, Master Styles in styles.xml. + * <i>Be aware:</i> FontFaceDeclarations and Automatic Styles are the same in content.xml and styles.xml. + * * $Id$ * - * @copyright GNU General Public License + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> * @version $Revision$ * @package OpenDocument - * * @since 0.3.0 */ interface OpenDocument { - /** - * get the whole OpenDocument as string. - */ + + /** + * Get the whole OpenDocument as string. + * + * @access public + * + * @since 0.4.0 + */ public function get(); + /** + * + * @access public + * + * @since 0.4.0 + */ public function getMeta(); - public function getContent(); + /** + * + * @access public + * + * @since 0.4.0 + */ + public function getBody(); + /** + * This method is depricated, please use <b>getStyles()</b> + * + * @access public + * @depricated + * + * @since 0.4.0 + */ public function getStyle(); + + - /** - * get mimetype of the document - * - * @return string Mimetype of the document - */ + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getFontFaceDeclaration(); + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getSettings(); + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getStyles(); + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getAutomaticStyles(); + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getMasterStyles(); + + + /** + * Get the mime type of the document. + * + * @return string Mimetype of the document + * @since 0.4.0 + */ public function getMimeType(); // public function getSetting(); Deleted: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentContent.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,192 +0,0 @@ -<?php -/** - * OpenDocumentContent Class - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.4.0 - */ - -require_once( "content/Body.php" ); -require_once( "styles/FontFaceDeclaration.php" ); -require_once( "OpenDocumentObjectAbstract.php" ); - -class OpenDocumentContent extends OpenDocumentObjectAbstract { - - private $root; - private $meta; - private $FontFaceDecl; - private $body; - private $text; - - /** - * Class construtor. - * - * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. - * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. - * @access public - * - * @since 0.4.0 - */ - public function __construct( $dom=0, $root=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 = $root; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:content" ); - } - $this->FontFaceDecl = new FontFaceDeclaration( $this->dom ); - $this->body = new Body( $this->dom ); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __destruct() { - unset( $this->dom ); - unset( $this->root ); - unset( $this->meta ); - unset( $this->FontFaceDecl ); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function addNoScript() { - $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:script" ) ); - } - - /** - * - * @deprecated - * - * @access public - * - * @since 0.4.0 - */ - public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { - $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); - } - - /** - * - * @access public - * - * @since 0.4.2 - */ - public function getFontFaceDecl() { - return $this->FontFaceDecl; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function addAutomaticStyles() { - - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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> - -*/ - - /** - * - * @return - * - * @access public - * - * @since 0.4.0 - */ - public function getBody() { - return $this->body; - } - - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function commit() { - $this->root->appendChild( $this->FontFaceDecl->get() ); - $this->root->appendChild( $this->body->get() ); - $this->content->appendChild( $this->root ); - $this->dom->normalize(); - $this->isCommited = true; - } - - /** - * - * @return DOMDocument - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - return $this->dom; - } - - /** - * - * @param string $filename - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } - -} -?> \ No newline at end of file Deleted: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentManifest.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,138 +0,0 @@ -<?php -/** - * OpenDocumentManifest.php - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et. al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.3.0 - */ - -class OpenDocumentManifest extends OpenDocumentObjectAbstract { - const odmPUBLIC = "-//OpenOffice.org//DTD Manifest 1.0//EN"; - const odmSYSTEM = "Manifest.dtd"; - const odmROOT = "manifest:manifest"; - const defaultMimeType = "application/vnd.oasis.opendocument.text"; - - private $root; - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __construct( $mimetype = self::defaultMimeType ) { - parent::__construct( $mimetype ); - $this->createManifestDOM(); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __destruct() { - unset( $dom ); - unset( $root ); - unset( $mimetype ); - } - - /** - * - * @access private - * @final - * - * @since 0.4.0 - */ - 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 ); - } - - /** - * - * @access public - * @final - * - * @since 0.4.0 - */ - 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:media-type", $mimetype ); - $node->setAttributeNS( self::NS_MANIFEST, "manifest:full-path", $fullpath ); - if ( $size >= 0 ) { - $node->setAttributeNS( self::NS_MANIFEST, "manifest:size", $size ); - } - if (!empty($encrypt)) { - $node->appendChild( $encrypt ); - } - $this->root->appendChild( $node ); - unset( $node ); - } - - /** - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function createEncryptionData( ) { - return $this->dom->createElmentNS( self::NS_MANIFEST, "manifest:encryption-data" ); - } - - /** - * Returns the whole OpenDocument Manifest as DOM. - * - * @return DOMDocument manifest as DOM. - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function get() { - $this->dom->appendChild( $this->root ); - $this->dom->normalize(); - return $this->dom; - } - - /** - * Save the whole OpenDocument Manifest in a file - * - * @param string name of file - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } -} -?> \ No newline at end of file Deleted: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentManifestTest.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,102 +0,0 @@ -<?php -/** - * Test Class for OpenDocumentManifest - * - * $Id$ - * - * @copyright Copyright © 2006, Norman Markgraf, et al. - * @license GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * @subpackage UnitTest - * @since 0.4.0 - */ -require_once "PHPUnit2/Framework/TestCase.php"; -require_once "OpenDocumentManifest.php"; - -class OpenDocumentManifestTest extends PHPUnit2_Framework_TestCase { - const PathToRNG = "./etc/test/"; - const ManifestRNG = "OpenDocument-manifest-schema-v1.0-os.rng"; - - /** - * @since 0.4.0 - */ - function testConstructionWithOutMimeType() { - - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - } - - /** - * @since 0.4.2 - */ - function testConstructionWithMimeType() { - $ODMMT = new OpenDocumentManifest( "alternateMimeType" ); - - $this->assertNotNull( $ODMMT, "Error constructing OpenDocumentManifest with a given mimetype." ); - } - - /** - * @since 0.4.2 - */ - function testEmptyManifest() { - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - - $Document = $ODM->get(); - - $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); - - $RelaxNG = self::PathToRNG . self::ManifestRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - - } - - /** - * @since 0.4.2 - */ - function testEntryToManifest() { - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - - $ODM->addEntryToManifest( "content.xml", "application/vnd.oasis.opendocument.text" ); - - $Document = $ODM->get(); - - $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); - - $RelaxNG = self::PathToRNG . self::ManifestRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } - - /** - * @since 0.4.2 - */ - function testEntryToManifestWithSize() { - $ODM = new OpenDocumentManifest(); - - $this->assertNotNull( $ODM, "Error constructing OpenDocumentManifest without a given mimetype." ); - - $ODM->addEntryToManifest( "content.xml", "application/vnd.oasis.opendocument.text", "12345" ); - - $Document = $ODM->get(); - - $this->assertNotNull( $Document, "Returned value of OpenDocumentManifest->get() is NULL." ); - - $RelaxNG = self::PathToRNG . self::ManifestRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } - -} - -?> \ No newline at end of file Deleted: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentMeta.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,355 +0,0 @@ -<?php -/** - * OpenDocumentMeta Class - * - * In this class we will store all meta stuff. - * - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.3.0 - */ - -class OpenDocumentMeta extends OpenDocumentObjectAbstract { - - /** - * This points to the "root" element of the meta data. - * - * @since 0.3.0 - */ - private $root; - - /** - * This points to the "root" element of the document meta data structure. - * - * @since 0.4.0 - */ - private $meta; - - /** - * - * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. - * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. - * @access public - * - * @since 0.3.0 - */ - public function __construct( $dom=0, $root=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; - } else { - // this is part of a single document - $this->dom = $dom; - $this->meta = $root; - } - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:meta" ); - } - - /** - * - * @access public - * - * @since 0.3.0 - */ - public function __destruct() { - unset( $dom ); - unset( $root ); - unset( $meta ); - - $this->logger->debug( "OpenDocumentMeta destructed." ); - - parent::__destruct(); - } - - /** - * - * @todo THIS CODE IS HIGHLY UNTESTED AND CURRENTLY NOT USEABLE AT ALL!!! - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * Add Dublin Core meta data. - * - * @param string $dc Tag (without "dc:") for Dublin Core meta data. - * @param string $value Value of the Dublin Core meta data. - * @access public - * - * @since 0.3.2 - */ - 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 ); - } - - /** - * Retrieve Dublin Core meta data. - * - * @param string $dc Tag (without "dc:") for Dublin Core meta data. - * @return string Value of the Dublin Core meta data. - * - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * Add the "Creation Date" of the current OpenDocument to the Meta file. - * - * You can give a timestamp made by <b>mktime()</b> or nothing as a parameter. - * If no parameter is given, the current time and date will be used. - * <code> - * // Let $Document be a class implementing the OpenDocument interface. - * // This will set the current date and time: - * $Document->getMeta()->addCreationDate() - * // This will set the creation date to (April, 3th 1968 - 10:11:12) - * $Document->getMeta()->addCreationDate( mktime( 10, 11, 12, 4, 3, 1968 ) ); - * </code> - * @param timestamp $date Timestamp or 0 = now. - * - * @access public - * - * @since 0.4.2 - */ - public function addCreationDate( $date=0 ) { - if (empty($time)) { - // 2006-02-14T16:36:10 - $creation_time = date( "Y-m-d\TH:i:s" ); - } else { - $creation_time = date( "Y-m-d\TH:i:s", $date ); - } - $this->logger->debug( "OpenDocumentMeta->addCreationTime: ". $creation_time ."." ); - - $node = $this->dom->createElementNS( self::NS_META, "meta:creation-date", $creation_time ); - - $this->root->appendChild( $node ); - - unset( $creation_time ); - - } - - /** - * Add a "Generator" to the Meta file. - * - * You can give your own generator message or use the default value, given by - * OpenDocumentPHP. - * <code> - * // Let $Document be a class implementing the OpenDocument interface. - * // This will set the default value of the generator: - * $Document->getMeta()->addGenerator() - * // This will set the the generator message to "My OD generator": - * $Document->getMeta()->addGenerator( "My OD generator" ); - * </code> - * - * @param string $generator New generator message, of default if 0. - * - * @access public - * - * @since 0.4.0 - */ - public function addGenerator( $generator=0 ) { - $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 ); - } - - /** - * Retrieve the current generator message. - * - * You can get the current information about the generator of the Meta file by: - * <code> - * // Let $Document be a class implementing the OpenDocument interface. - * $IsGeneratedByOpenDocumentPHP = stripos( $Document->getGenerator(), "OpenDocumentPHP/" ); - * if ( $IsGeneratedByOpenDocumentPHP === false ) { - * echo "This file was (probably) not created by OpenDocumentPHP!"; - * } - * if ( $IfGeneratedByOpenDocumentPHP !== false ) { - * echo "This file was generated by OpenDocumentPHP!"; - * } - * </code> - * - * @return string Current generator information stored in Meta. - * - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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 ); - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - 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 ); - } - - /** - * Commits all changes to Meta and normalize them. - * - * After a commit call, you couldn't add new things to Meta. - * - * @access public - * - * @since 0.4.0 - */ - public function commit() { - $this->meta->appendChild( $this->root ); - $this->dom->normalize(); - $this->isCommited = true; - $this->logger->debug( "OpenDocumentMeta->commit()." ); - } - - /** - * Get Meta as DOMDocument. - * - * If this object is not commited, this method will first call <b>commit()</b> and return the - * Meta as DOMDocument after that. - * - * @return DOMDocument Meta as DOMDocument. - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - $this->logger->debug( "OpenDocumentMeta->get()." ); - return $this->dom; - } - - /** - * - * @access public - * @final - * - * @since 0.4.0 - */ - 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.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentMetaTest.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,194 +0,0 @@ -<?php -/** - * Test class for OpenDocumentMeta - * - * $Id$ - * - * @copyright GNU General Public License - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * @subpackage UnitTest - * @since 0.4.0 - */ -require_once "PHPUnit2/Framework/TestCase.php"; -require_once "OpenDocumentMeta.php"; - -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/"; - - const PathToRNG = "./etc/test/"; - const MetaRNG = "OpenDocument-schema-v1.0-os.rng"; - - /** - * - * @since 0.4.0 - */ - public function testConstructWithoutDom() { - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - - } - - /** - * - * @since 0.4.0 - */ - public function testConstructWithDom(){ -/* ***FIX ME*** - $mimetype = "application/vnd.oasis.opendocument.text"; - $testDom = new DOMDocument( "1.0", "utf-8" ); - - $root = $testDom->createElementNS( self::NS_OFFICE, "office:document" ); - $root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); - $testDom->appendChild( $root ); - - $node = $testDom->createElementNS( self::NS_OFFICE, "office:meta" ); - - $ODM = new OpenDocumentMeta( $testDom, $node ); - - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); -*/ - } - - /** - * - * @since 0.4.1 - */ - public function testAddGetDublinCore() { - $ODM = new OpenDocumentMeta(); - $dc_creator_tag = "creator"; - $dc_creator = "Willy Testo"; - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getDublicCore( $dc_creator_tag ), - "Returned Dublin Core should be empty, was not." ); - - - $ODM->addDublinCore( $dc_creator_tag, $dc_creator ); - $ODM->commit(); - - $this->assertEquals( $dc_creator, $ODM->getDublicCore( $dc_creator_tag ), - "Dublin Core entry was not correctly returned." ); - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } - - /** - * - * @since 0.4.2 - */ - public function testAddGetGeneratorWithGenerator() { - $ODM = new OpenDocumentMeta(); - $generator = "Testo Generator"; - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getGenerator(), - "Generator should be empty, was not." ); - - $ODM->addGenerator( $generator ); - $ODM->commit(); - - $this->assertEquals( $generator, $ODM->getGenerator(), - "Generator was not correctly returned. (".$ODM->getGenerator().")" ); - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } - - /** - * - * @since 0.4.2 - */ - public function testAddGetGeneratorWithOutGenerator() { - $ODM = new OpenDocumentMeta(); - - $this->assertNotNull( $ODM ); - - $this->assertEquals( "", $ODM->getGenerator(), - "Generator should be empty, was not." ); - - $ODM->addGenerator( ); - $ODM->commit(); - - $this->assertNotNull( $ODM->getGenerator(), - "Generator was not correctly returned, but was null" ); - - $this->assertNotEquals( "", $ODM->getGenerator(), - "Generator was not correctly returned. (".$ODM->getGenerator().")" ); - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } - - /** - * - * @since 0.4.2 - */ - 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." ); - - $Document = $ODM->get(); - $this->assertNotNull($Document, "No result." ); - - $RelaxNG = self::PathToRNG . self::MetaRNG; - - $this->assertTrue( $Document->relaxNGValidate( $RelaxNG ), - "Manifest does not match Manifest Relax NG schema." ); - } -} -?> Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentPackage.php 2006-03-20 08:05:41 UTC (rev 30) @@ -10,6 +10,15 @@ * @package OpenDocument * @since 0.4.0 */ +require_once( "meta/Meta.php" ); +require_once( "settings/Settings.php" ); +require_once( "content/Scripts.php" ); +require_once( "styles/FontFaceDeclaration.php" ); +require_once( "styles/Style.php" ); +require_once( "styles/AutomaticStyles.php" ); +require_once( "styles/MasterStyles.php" ); +require_once( "content/Body.php" ); +require_once( "OpenDocumentAbstract.php" ); class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { private $manifest; @@ -35,8 +44,8 @@ $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() ); + $this->logger->debug( "Generating Manifest with mimetype \"".$this->getMimeType()."\"." ); + $this->manifest = new Manifest( $this->getMimeType() ); if ( !empty( $documentName ) ) { $this->setPackageName( $documentName ); @@ -256,7 +265,7 @@ */ public function getMeta() { if (!array_key_exists ( "meta", $this->DocumentObjects) ) { - $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta(); + $this->DocumentObjects[ "meta" ] = new Meta(); } return $this->DocumentObjects[ "meta" ]; } @@ -268,7 +277,7 @@ */ public function getContent() { if (!array_key_exists ( "content", $this->DocumentObjects) ) { - $this->DocumentObjects[ "content" ] = new OpenDocumentContent(); + $this->DocumentObjects[ "content" ] = new Content(); } return $this->DocumentObjects[ "content" ]; } @@ -280,11 +289,70 @@ */ public function getStyle() { if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = new OpenDocumentStyle(); + $this->DocumentObjects[ "style" ] = new Style(); } return $this->DocumentObjects[ "style" ]; } - + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function getBody(){ + return 0; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getFontFaceDeclaration(){ + return 0; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getSettings(){ + return 0; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getStyles(){ + return 0; + } + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getAutomaticStyles(){ + return 0; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getMasterStyles() { + return 0; + } + } ?> \ No newline at end of file Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentSingle.php 2006-03-20 08:05:41 UTC (rev 30) @@ -2,6 +2,9 @@ /** * OpenDocumentSingle Class * + * This class will include Meta, Settings, Scripts, FontFaceDeclarations, Styles, + * Automatic Styles, Master Styles, and Body classes in one single XML file. + * * $Id$ * * @license GNU General Public License @@ -12,6 +15,15 @@ * * @since 0.3.0 */ +require_once( "meta/Meta.php" ); +require_once( "settings/Settings.php" ); +require_once( "content/Scripts.php" ); +require_once( "styles/FontFaceDeclaration.php" ); +require_once( "styles/Style.php" ); +require_once( "styles/AutomaticStyles.php" ); +require_once( "styles/MasterStyles.php" ); +require_once( "content/Body.php" ); +require_once( "OpenDocumentAbstract.php" ); class OpenDocumentSingle extends OpenDocumentAbstract implements OpenDocument { /** @@ -56,7 +68,17 @@ $this->dom = new DOMDocument( "1.0", "utf-8" ); $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document" ); - $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); + $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); + + $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); + $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); + $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); + $this->DocumentObjects[ "automaticstyles" ] = new Style( $this->dom, $this->root ); + $this->DocumentObjects[ "masterstyles" ] = new Style( $this->dom, $this->root ); + $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); + } /** @@ -90,7 +112,8 @@ * @since 0.3.0 */ public function addXMLDocument( $fullpath, $domFrag, $mimetype="text/xml" ) { - $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); + $this->logger->info( "OpenDocumentSingle->addXMLDocument(" . $fullpath . + ") with mimetype '" . $mimetype . "' to package '". $this->packagetmp . "'" ); $this->dom->appendChild( $domFrag ); } @@ -102,16 +125,17 @@ */ private function commit() { $this->logger->debug( "OpenDocumentSingle->commit()" ); - if (array_key_exists( "meta", $this->DocumentObjects )) { - $this->DocumentObjects["meta"]->commit(); - } - if (array_key_exists( "style", $this->DocumentObjects )) { - $this->DocumentObjects["style"]->commit(); - } - if (array_key_exists( "content", $this->DocumentObjects )) { - $this->DocumentObjects["content"]->commit(); - } - $this->dom->appendChild( $this->root ); + + $this->root->appendChild( $this->DocumentObjects[ "meta" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "settings" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "fontfacedecl" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "style" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); + $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); + + $this->dom->appendChild( $this->root ); $this->isCommited = true; } @@ -159,7 +183,7 @@ */ public function getMeta() { if ( !array_key_exists( "meta", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "meta" ] = new OpenDocumentMeta( $this->dom, $this->root ); + $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); } return $this->DocumentObjects[ "meta" ]; } @@ -167,27 +191,87 @@ /** * * @access public + * @depricated * * @since 0.3.0 */ public function getContent() { - if ( !array_key_exists( "content", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "content" ] = new OpenDocumentContent( $this->dom, $this->root ); - } - return $this->DocumentObjects[ "content" ]; + return 0; } /** * * @access public + * @depricated * * @since 0.3.0 */ public function getStyle() { + return $this->getStyles(); + } + + /** + * + * @access public + * + * @since 0.3.0 + */ + public function getStyles() { if ( !array_key_exists( "style", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "style" ] = new OpenDocumentStyle( $this->dom, $this->root ); + $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); } return $this->DocumentObjects[ "style" ]; } + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function getBody() { + return $this->DocumentObjects[ "body" ]; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getFontFaceDeclaration(){ + return $this->DocumentObjects[ "fontfacedecl" ]; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getSettings(){ + return $this->DocumentObjects[ "setting" ]; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getAutomaticStyles(){ + return $this->DocumentObjects[ "automaticstyles" ]; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getMasterStyles(){ + return $this->DocumentObjects[ "masterstyles" ]; + } + } ?> \ No newline at end of file Deleted: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php 2006-03-18 22:12:38 UTC (rev 29) +++ poc/src/OpenDocumentStyle.php 2006-03-20 08:05:41 UTC (rev 30) @@ -1,295 +0,0 @@ -<?php -/** - * OpenDocumentStyle Class - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.4.0 - */ - -//require_once( "styles/FontFaceDecl.php" ); - -class OpenDocumentStyle extends OpenDocumentObjectAbstract { - - private $root; - private $style; - private $FontFaceDecl; - private $Styles; - private $DefaultStyles; - - /** - * Class construtor. - * - * @param DOMDocument $dom Main DOM document. If 0, than we produce a <b>meta.xml</b> document. - * @param DOMElement $root Root element of DOM document, needed if <b>$dom</b> was not 0. - * @access public - * - * @since 0.4.0 - */ - public function __construct( $dom=0, $root=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 = $root; - $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:style" ); - } - $this->FontFaceDecl = new FontFaceDeclaration( $this->dom ); - $this->Styles = array(); - $this->DefaultStyles = array(); - } - - /** - * Class destructor. - * - * @access public - * - * @since 0.4.0 - */ - public function __destruct() { - unset( $this->dom ); - unset( $this->root ); - unset( $this->style ); - } - - /** - * - * @deprecated - * - * @access public - * - * @since 0.4.0 - */ - public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { - $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); - } - - /** - * - * common family names: graphic, paragraph, table, table-row - * - * @access public - * - * @since 0.4.2 - */ - public function addDefaultStyle( $family = 0 ) { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:default-style" ); - if (!empty($family)) { - $node->setAttributeNS( self::NS_STYLE, "style:family", $family ); - } - $this->DefaultStyles[ $family ] = $node; - } - - /** - * - * - * @access private - * - * @since 0.4.2 - */ - private function addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ) { - $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:paragraph-properties" ); - if (!empty($styleAttr)) { - foreach( $styleAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); - } - } - if (!empty($foAttr)) { - foreach( $foAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); - } - } - $node->appendChild( $ParProp ); - } - - /** - * - * - * @access private - * - * @since 0.4.2 - */ - private function addTextPropertiesToNode( $node, $styleAttr, $foAttr ) { - $ParProp = $this->dom->createElementNS( self::NS_STYLE, "style:text-properties" ); - if (!empty($styleAttr)) { - foreach( $styleAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); - } - } - if (!empty($foAttr)) { - foreach( $foAttr as $key=>$value ) { - $ParProp->setAttributeNS( self::NS_FO, "fo:".$key, $value ); - } - } - $node->appendChild( $ParProp ); - } - - /** - * - * - * @access public - * - * @since 0.4.2 - */ - public function addDefaultStyleParagraphProperties( $family, $styleAttr=0, $foAttr=0 ) { - $node = $this->getDefaultStyle( $family ); - if (empty($node)) { - die("W\xFCrg:" . $family ); - } - $this->addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ); - } - - /** - * - * - * @access public - * - * @since 0.4.2 - */ - public function addStyleParagraphProperties( $name, $styleAttr=0, $foAttr=0 ) { - $node = $this->getStyle( $name ); - $this->addParagraphPropertiesToNode( $node, $styleAttr, $foAttr ); - } - - /** - * - * - * @access public - * - * @since 0.4.2 - */ - public function addDefaultStyleTextProperties( $family, $styleAttr, $foAttr ) { - $node = $this->getDefaultStyle( $family ); - $this->addTextPropertiesToNode( $node, $styleAttr, $foAttr ); - } - - /** - * - * - * @access public - * - * @since 0.4.2 - */ - public function addStyleTextProperties( $name, $styleAttr, $foAttr ) { - $node = $this->getStyle( $name ); - $this->addTextPropertiesToNode( $node, $styleAttr, $foAttr ); - } - - /** - * - * common family names: graphic, paragraph, table, table-row - * - * @access public - * - * @since 0.4.2 - */ - public function getDefaultStyle( $family = 0 ) { - return $this->DefaultStyles[ $family ]; - } - - /** - * - * @access public - * - * @since 0.4.2 - */ - public function addStyle( $name, $styleAttr=0 ) { - $node = $this->dom->createElementNS( self::NS_STYLE, "style:style" ); - $node->setAttributeNS( self::NS_STYLE, "style:name", $name ); - if (!empty($styleAttr)) { - foreach( $styleAttr as $key=>$value ) { - $node->setAttributeNS ( self::NS_STYLE, "style:".$key, $value ); - } - } - $this->Styles[ $name ] = $node; - } - - /** - * - * @access public - * - * @since 0.4.2 - */ - public function getStyle( $name=0 ) { - return $this->Styles[ $name ]; - } - - /** - * - * @access public - * - * @since 0.4.2 - */ - public function getFontFaceDecl() { - return $this->FontFaceDecl; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function commit() { - $this->root->appendChild( $this->FontFaceDecl->get() ); - $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 DOMDocument - * - * @access public - * - * @since 0.4.0 - */ - final public function get() { - if (!$this->isCommited) { - $this->commit(); - } - return $this->dom; - } - - /** - * - * @access public - * @final - * - * @since 0.4.0 - */ - final public function save( $filename ) { - $this->get()->save( $filename ); - } -} -?> \ No newline at end of file Added: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php (rev 0) +++ poc/src/content/Content.php 2006-03-20 08:05:41 UTC (rev 30) @@ -0,0 +1,191 @@ +<?php +/** + * Content Class (former OpenDocumentContent Class) + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * + * @since 0.4.4 + */ + +require_once( "content/Script.php" ); +require_once( "styles/FontFaceDeclaration.php" ); +require_once( "styles/AutomaticStyles.php" ); +require_once( "content/Body.php" ); +require_once( "OpenDocumentObjectAbstract.php" ); + +class Content extends OpenDocumentObjectAbstract { + + private $root; + private $Scripts; + private $FontFaceDecl; + private $AutomaticStyles; + private $Body; + private $text; + + /** + * Class construtor. + * + * @access public + * + * @since 0.4.0 + */ + public function __construct() { + parent::__construct(); + $this->logger->debug( "Constructing content/Content." ); + // 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; + $this->Scripts = new Scripts( $this->dom, $this->root ); + $this->FontFaceDecl = new FontFaceDeclaration( $this->dom, $this->root ); + $this->AutomaticStyles = new AutomaticStyles( $this->dom, $this->root ); + $this->Body = new Body( $this->dom, $this->root ); + } + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function __destruct() { + unset( $this->dom ); + unset( $this->root ); + } + + /** + * + * @access public + * @depricated + * + * @since 0.4.0 + */ + public function addNoScript() { + $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:script" ) ); + } + + /** + * + * @depricated + * + * @access public + * + * @since 0.4.0 + */ + public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { + $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); + } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function getFontFaceDecl() { + return $this->FontFaceDecl; + } + + /** + * + * @access public + * @depricated + * + * @since 0.4.0 + */ + public function addAutomaticStyles() { + + } + + /** + * + * @access public + * @depricated + * + * @since 0.4.0 + */ + 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> + +*/ + + /** + * + * @return + * + * @access public + * + * @since 0.4.0 + */ + public function getBody() { + return $this->Body; + } + + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function commit() { + $this->root->appendChild( $this->Scripts->get() ); + $this->root->appendChild( $this->FontFaceDecl->get() ); + $this->root->appendChild( $this->AutomaticStyles->get() ); + $this->root->appendChild( $this->Body->get() ); + $this->dom->appendChild( $this->root ); + $this->dom->normalize(); + $this->isCommited = true; + } + + /** + * + * @return DOMDocument + * + * @access public + * @final + * + * @since 0.4.0 + */ + final public function get() { + if (!$this->isCommited) { + $this->commit(); + } + return $this->dom; + } + + /** + * + * @param string $filename + * + * @access public + * @final + * + * @since 0.4.0 + */ + final public function save( $filename ) { + $this->get()->save( $filename ); + } + +} +?> \ No newline at end of file Property changes on: poc/src/content/Content.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Added: poc/src/content/Scripts.php =================================================================== --- poc/src/content/Scripts.php (rev 0) +++ poc/src/content/Scripts.php 2006-03-20 08:05:41 UTC (rev 30) @@ -0,0 +1,101 @@ +\xFF\xFE< |
From: <nma...@us...> - 2006-03-20 08:36:33
|
Revision: 31 Author: nmarkgraf Date: 2006-03-20 00:36:20 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=31&view=rev Log Message: ----------- Minor bugfixes: - Still OpenDocumentPackage is not working, but OpenDocumentSingle is on a good way. - Fixed a lot of tiny bugs, mostly typos. Modified Paths: -------------- poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/Content.php poc/src/content/Scripts.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/Style.php Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 08:05:41 UTC (rev 30) +++ poc/src/OpenDocumentSingle.php 2006-03-20 08:36:20 UTC (rev 31) @@ -135,7 +135,7 @@ $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); - $this->dom->appendChild( $this->root ); +// $this->dom->appendChild( $this->root ); $this->isCommited = true; } Modified: poc/src/OpenDocumentSingleTest.php =================================================================== --- poc/src/OpenDocumentSingleTest.php 2006-03-20 08:05:41 UTC (rev 30) +++ poc/src/OpenDocumentSingleTest.php 2006-03-20 08:36:20 UTC (rev 31) @@ -27,7 +27,8 @@ $ODT = new OpenDocumentSingle(); $this->assertNotNull( $ODT, "Error constructing OpenDocumentManifest without a given mimetype." ); - + + /* Initialize Meta data: */ $meta = $ODT->getMeta(); $meta->addDublinCore( "title", "Test" ); $meta->addDublinCore( "creator", "Testo Tester" ); @@ -36,29 +37,24 @@ $meta->addGenerator( ); $meta->addInitialCreator( "Testo Tester" ); $meta->addCreationDate(); - - $content = $ODT->getContent(); - - $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!" ) ); - - $style = $ODT->getStyle(); + /* Initialize Font Face Declarations: */ $styleAttr = array(); $styleAttr[ "font-family" ] ="Tahoma"; - $style->getFontFaceDecl()->addFontFace( "Test", $styleAttr ); + + $fontfacedelc = $ODT->getFontFaceDeclaration(); + $fontfacedelc->addFontFace( "Test", $styleAttr ); unset( $styleAttr ); - + + /* Add text to Body: */ + $text = $ODT->getBody()->getText(); + + $text->addToText( $text->getTextHeading( "Heading", "The first step" ) ); + $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); + + /* Initialize Styles: */ + $style = $ODT->getStyle(); + // Set default style $style->addDefaultStyle( "paragraph" ); Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-03-20 08:05:41 UTC (rev 30) +++ poc/src/content/Content.php 2006-03-20 08:36:20 UTC (rev 31) @@ -13,7 +13,7 @@ * @since 0.4.4 */ -require_once( "content/Script.php" ); +require_once( "content/Scripts.php" ); require_once( "styles/FontFaceDeclaration.php" ); require_once( "styles/AutomaticStyles.php" ); require_once( "content/Body.php" ); Modified: poc/src/content/Scripts.php =================================================================== --- poc/src/content/Scripts.php 2006-03-20 08:05:41 UTC (rev 30) +++ poc/src/content/Scripts.php 2006-03-20 08:36:20 UTC (rev 31) @@ -1,101 +1,105 @@ -\xFF\xFE< |
From: <nma...@us...> - 2006-03-20 09:44:14
|
Revision: 32 Author: nmarkgraf Date: 2006-03-20 01:43:58 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=32&view=rev Log Message: ----------- This revision is a great success for OpenDocumentPHP. OpenDocumentSingle will output a valid OpenDocument as a single document according to the Relax NG schema. Sadly OpenDocumentPackage is still broken and samples/TestOutput needs some fixes. The role model is OpenDocumentSingleTest.php. Modified Paths: -------------- poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/BodyText.php poc/src/settings/Settings.php poc/src/styles/AutomaticStyles.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/Style.php Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/OpenDocumentSingle.php 2006-03-20 09:43:58 UTC (rev 32) @@ -75,8 +75,8 @@ $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); - $this->DocumentObjects[ "automaticstyles" ] = new Style( $this->dom, $this->root ); - $this->DocumentObjects[ "masterstyles" ] = new Style( $this->dom, $this->root ); + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); } @@ -126,16 +126,17 @@ private function commit() { $this->logger->debug( "OpenDocumentSingle->commit()" ); - $this->root->appendChild( $this->DocumentObjects[ "meta" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "settings" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); + $this->DocumentObjects[ "meta" ]->commit(); +// $this->DocumentObjects[ "settings" ]->commit(); +// $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); $this->root->appendChild( $this->DocumentObjects[ "fontfacedecl" ]->get() ); $this->root->appendChild( $this->DocumentObjects[ "style" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); +// $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); +// $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); -// $this->dom->appendChild( $this->root ); + $this->dom->appendChild( $this->root ); + $this->dom->normalize(); $this->isCommited = true; } Modified: poc/src/OpenDocumentSingleTest.php =================================================================== --- poc/src/OpenDocumentSingleTest.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/OpenDocumentSingleTest.php 2006-03-20 09:43:58 UTC (rev 32) @@ -49,7 +49,7 @@ /* Add text to Body: */ $text = $ODT->getBody()->getText(); - $text->addToText( $text->getTextHeading( "Heading", "The first step" ) ); + $text->addToText( $text->getTextHeading( "Heading", 1, "The first step" ) ); $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); /* Initialize Styles: */ @@ -121,6 +121,8 @@ $Document = $ODT->getAsDOM(); + //DEBUG: echo $ODT->get(); + $this->assertNotNull( $Document, "Returned value of OpenDocumentSingle->get() is NULL." ); $RelaxNG = self::PathToRNG . self::DocumentRNG; Modified: poc/src/content/BodyText.php =================================================================== --- poc/src/content/BodyText.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/content/BodyText.php 2006-03-20 09:43:58 UTC (rev 32) @@ -54,7 +54,7 @@ } else { $par = $this->dom->createElementNS( self::NS_TEXT, "text:p", $parText ); } - $par->setAttributeNS( self::NS_STYLE, "style:name", $styleName ); + $par->setAttributeNS( self::NS_TEXT, "text:style-name", $styleName ); return $par; } @@ -75,14 +75,15 @@ * * @since 0.4.0 */ - public function getTextHeading( $styleName, $headText=0 ) { + public function getTextHeading( $styleName, $outlineLevel=1, $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 ); + $head->setAttributeNS( self::NS_TEXT, "text:style-name", $styleName ); + $head->setAttributeNS( self::NS_TEXT, "text:outline-level", $outlineLevel ); return $head; } Modified: poc/src/settings/Settings.php =================================================================== --- poc/src/settings/Settings.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/settings/Settings.php 2006-03-20 09:43:58 UTC (rev 32) @@ -33,6 +33,13 @@ * @since 0.4.4 */ private $root; + + /** + * This is true, if something was added to settings. + * @accedd private + * @since 0.4.4 + */ + private $somethingAdded; /** * Class construtor. Modified: poc/src/styles/AutomaticStyles.php =================================================================== --- poc/src/styles/AutomaticStyles.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/styles/AutomaticStyles.php 2006-03-20 09:43:58 UTC (rev 32) @@ -38,13 +38,12 @@ * * @since 0.4.4 */ - public function __construct( $dom, $root) { + public function __construct( $dom, $root=0) { parent::__construct(); $this->logger->debug( "Constructing styles/AutomaticStyles." ); $this->dom = $dom; - $this->style = $root; $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:automatic-styles" ); } Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-20 09:43:58 UTC (rev 32) @@ -44,18 +44,18 @@ * * @since 0.4.2 */ - public function __construct( $dom, $root, $dom2=0 ) { + public function __construct( $dom, $root=0, $dom2=0 ) { parent::__construct(); $this->dom = $dom; $this->dom2 = $dom2; $this->useDom2 = false; - $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decls" ); if (!empty($dom2)) { // Package Document with two DOM documents, $dom <-> content.xml $dom2 <-> styles.xml - $this->FontFaceDecl2 = $this->dom2->createElementNS( self::NS_OFFICE, "office:font-face-decl" ); + $this->FontFaceDecl2 = $this->dom2->createElementNS( self::NS_OFFICE, "office:font-face-decls" ); $this->useDom2 = true; } } Modified: poc/src/styles/Style.php =================================================================== --- poc/src/styles/Style.php 2006-03-20 08:36:20 UTC (rev 31) +++ poc/src/styles/Style.php 2006-03-20 09:43:58 UTC (rev 32) @@ -48,13 +48,12 @@ * * @since 0.4.4 */ - public function __construct( $dom, $root) { + public function __construct( $dom, $root=0) { parent::__construct(); $this->logger->debug( "Constructing style/Style." ); $this->dom = $dom; - $this->style = $root; $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:styles" ); $this->Styles = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-20 13:49:58
|
Revision: 33 Author: nmarkgraf Date: 2006-03-20 05:49:26 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=33&view=rev Log Message: ----------- done. This could be the last revision before POC 0.5. Please test it a lot and tell me every error you found. Updated: - etc/coverage-frames.xsl copied from PHing svn distribution. - samples/TestOutput.php now acts with the new classes and methods. - OpenDocument, OpenDocumentSingle, OpenDocumentPackage are now running. - content/Content and styles/Styles are up to date and using FontFaceDeclSplitter to share FontFaceDeclarations. To do: - Like FontFaceDeclSplitter we need a AutomaticStylesSplitter to share AutomaticStyles between content.xml and styles.xml - Maybe FontFaceDecl could be a interface implemeted by FontFaceDeclaration and FontFaceDeclSplitter - ... Norman Modified Paths: -------------- poc/etc/coverage-frames.xsl poc/src/OpenDocument.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/content/Content.php poc/src/samples/TestOutput.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/Styles.php Added Paths: ----------- poc/src/styles/FontFaceDeclSplitter.php Modified: poc/etc/coverage-frames.xsl =================================================================== --- poc/etc/coverage-frames.xsl 2006-03-20 09:43:58 UTC (rev 32) +++ poc/etc/coverage-frames.xsl 2006-03-20 13:49:26 UTC (rev 33) @@ -291,6 +291,7 @@ <td class="small">Classes: <xsl:value-of select="count(package/class)"/></td> <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> <td class="small">LOC: <xsl:value-of select="count(package/class/sourcefile/sourceline)"/></td> + <td class="small">Statements: <xsl:value-of select="@statementcount"/></td> </tr> </table> <br/> @@ -414,6 +415,7 @@ <td class="small">Classes: <xsl:value-of select="count(class)"/></td> <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> <td class="small">LOC: <xsl:value-of select="count(class/sourcefile/sourceline)"/></td> + <td class="small">Statements: <xsl:value-of select="@statementcount"/></td> </tr> </table> <br/> @@ -462,6 +464,7 @@ <tr class="a"> <td class="small">Methods: <xsl:value-of select="@methodcount"/></td> <td class="small">LOC: <xsl:value-of select="count(sourcefile/sourceline)"/></td> + <td class="small">Statements: <xsl:value-of select="@statementcount"/></td> </tr> </table> <br/> Modified: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/OpenDocument.php 2006-03-20 13:49:26 UTC (rev 33) @@ -65,7 +65,13 @@ */ public function getStyle(); - + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getScripts(); /** * Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/OpenDocumentPackage.php 2006-03-20 13:49:26 UTC (rev 33) @@ -2,6 +2,11 @@ /** * OpenDocumentPackage Class * + * This class will include the following files in one ZIP file with a Manifest file (like JAR files + * for Java) Meta in meta.xml, Settings in settings.xml, Scripts, FontFaceDeclarations, Automatic Styles, + * Body in content.xml, FontFaceDelarations, Styles, Automatic Styles, Master Styles in styles.xml. + * <i>Be aware:</i> FontFaceDeclarations and Automatic Styles are the same in content.xml and styles.xml. + * * $Id$ * * @copyright GNU General Public License @@ -14,6 +19,7 @@ require_once( "settings/Settings.php" ); require_once( "content/Scripts.php" ); require_once( "styles/FontFaceDeclaration.php" ); +require_once( "styles/FontFaceDeclSplitter.php" ); require_once( "styles/Style.php" ); require_once( "styles/AutomaticStyles.php" ); require_once( "styles/MasterStyles.php" ); @@ -21,7 +27,7 @@ require_once( "OpenDocumentAbstract.php" ); class OpenDocumentPackage extends OpenDocumentAbstract implements OpenDocument { - private $manifest; + private $packagename; private $packagetmp; private $zip; @@ -44,8 +50,6 @@ $this->logger->debug( "Generating ZipFile object." ); $this->zip = new ZipFile; - $this->logger->debug( "Generating Manifest with mimetype \"".$this->getMimeType()."\"." ); - $this->manifest = new Manifest( $this->getMimeType() ); if ( !empty( $documentName ) ) { $this->setPackageName( $documentName ); @@ -53,6 +57,27 @@ $this->path = $documentPath; } } + $this->logger->debug( "Generating Manifest with mimetype \"".$this->getMimeType()."\"." ); + $this->DocumentObjects[ "manifest" ] = new Manifest( $this->getMimeType() ); + $this->DocumentObjects[ "meta" ] = new Meta( ); +// $this->DocumentObjects[ "settings" ] = new Settings( ); + + $content = new Content( ); + $this->DocumentObjects[ "content" ] = $content; + + $styles = new Styles( ); + $this->DocumentObjects[ "styles" ] = $styles; + +// $this->DocumentObjects[ "scripts" ] = new Scripts( $contentDom ); +// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $contentDom ); + $this->DocumentObjects[ "body" ] = $content->getBody(); + + + $this->DocumentObjects[ "style" ] = $styles->getStyle(); + $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $content->getFontFaceDecl(), + $styles->getFontFaceDecl() ); +// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStylesSpliter(... ); +// $this->DocumentObjects[ "masterstyles" ] = $styles->getMasterStyles(); } /** @@ -197,7 +222,7 @@ 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->DocumentObjects[ "manifest" ]->addEntryToManifest( $fullpath, $mimetype ); $this->writeDOMToPackage( $fullpath, $dom ); } @@ -214,8 +239,8 @@ case "meta" : $this->addXMLDocument( "meta.xml", $docObj->get() ); break; - case "style" : - $this->addXMLDocument( "style.xml", $docObj->get() ); + case "styles" : + $this->addXMLDocument( "styles.xml", $docObj->get() ); break; case "content" : $this->addXMLDocument( "content.xml", $docObj->get() ); @@ -228,7 +253,7 @@ } } - $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->manifest->get() ); + $this->writeDOMToPackage( "META-INF/manifest.xml" , $this->DocumentObjects[ "manifest" ]->get() ); $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 . "\"..." ); @@ -289,21 +314,21 @@ */ public function getStyle() { if (!array_key_exists ( "style", $this->DocumentObjects) ) { - $this->DocumentObjects[ "style" ] = new Style(); + $this->DocumentObjects[ "style" ] = $this->DocumentObjects[ "styles" ]->getStyle(); } return $this->DocumentObjects[ "style" ]; } - + /** * * @access public - * * @since 0.4.0 */ - public function getBody(){ - return 0; + public function getStyles() { + return getStyle(); } - + + /** * * @access public @@ -311,7 +336,7 @@ * @since 0.4.4 */ public function getFontFaceDeclaration(){ - return 0; + return $this->DocumentObjects[ "fontfacedecl" ]; } /** @@ -323,6 +348,16 @@ public function getSettings(){ return 0; } + + /** + * + * @access public + * + * @since 0.4.0 + */ + public function getBody() { + return $this->DocumentObjects[ "body" ]; + } /** * @@ -330,9 +365,14 @@ * * @since 0.4.4 */ - public function getStyles(){ - return 0; + public function getScripts(){ + if ( !array_key_exists( "scripts", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "scripts" ] = $this->DocumentObjects[ "content" ]->getScripts(); + } + return $this->DocumentObjects[ "scripts" ]; } + + /** * * @access public @@ -340,7 +380,10 @@ * @since 0.4.4 */ public function getAutomaticStyles(){ - return 0; + if ( !array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "automaticstyles" ] = 0; + } + return $this->DocumentObjects[ "automaticstyles" ]; } /** @@ -349,10 +392,12 @@ * * @since 0.4.4 */ - public function getMasterStyles() { - return 0; + public function getMasterStyles(){ + if ( !array_key_exists( "masterstyles", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "masterstyles" ] = 0; + } + return $this->DocumentObjects[ "masterstyles" ]; } - } ?> \ No newline at end of file Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/OpenDocumentSingle.php 2006-03-20 13:49:26 UTC (rev 33) @@ -71,14 +71,13 @@ $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); - $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); - $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); +// $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); +// $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); - $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); - $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); - $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); - +// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); +// $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); + $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); } /** @@ -125,18 +124,35 @@ */ private function commit() { $this->logger->debug( "OpenDocumentSingle->commit()" ); - - $this->DocumentObjects[ "meta" ]->commit(); -// $this->DocumentObjects[ "settings" ]->commit(); -// $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "fontfacedecl" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "style" ]->get() ); -// $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); -// $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); - $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); - + // Add Meta data + $this->DocumentObjects[ "meta" ]->commit(); + // Add settings, if needed + if ( array_key_exists( "settings", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "settings" ]->commit(); + } + // Add scripts, if needed + if ( array_key_exists( "scripts", $this->DocumentObjects ) ) { + $this->root->appendChild( $this->DocumentObjects[ "scripts" ]->get() ); + } + // Add FontFaceDeclarations + $this->root->appendChild( $this->DocumentObjects[ "fontfacedecl" ]->get() ); + // Add Style + $this->root->appendChild( $this->DocumentObjects[ "style" ]->get() ); + // Add AutomaticSytles, if needed + if ( array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { + $this->root->appendChild( $this->DocumentObjects[ "automaticstyles" ]->get() ); + } + // Add MasterStyles, if needed + if ( array_key_exists( "masterstyles", $this->DocumentObjects ) ) { + $this->root->appendChild( $this->DocumentObjects[ "masterstyles" ]->get() ); + } + // Add Body + $this->root->appendChild( $this->DocumentObjects[ "body" ]->get() ); + // Add all to DOM document $this->dom->appendChild( $this->root ); + // Normalzise DOM document $this->dom->normalize(); + // Set everthing to commited. $this->isCommited = true; } @@ -207,8 +223,8 @@ * * @since 0.3.0 */ - public function getStyle() { - return $this->getStyles(); + public function getStyles() { + return $this->getStyle(); } /** @@ -217,7 +233,7 @@ * * @since 0.3.0 */ - public function getStyles() { + public function getStyle() { if ( !array_key_exists( "style", $this->DocumentObjects ) ) { $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); } @@ -251,7 +267,10 @@ * @since 0.4.4 */ public function getSettings(){ - return $this->DocumentObjects[ "setting" ]; + if ( !array_key_exists( "settings", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); + } + return $this->DocumentObjects[ "settings" ]; } /** @@ -260,7 +279,24 @@ * * @since 0.4.4 */ + public function getScripts(){ + if ( !array_key_exists( "scripts", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + } + return $this->DocumentObjects[ "scripts" ]; + } + + + /** + * + * @access public + * + * @since 0.4.4 + */ public function getAutomaticStyles(){ + if ( !array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + } return $this->DocumentObjects[ "automaticstyles" ]; } @@ -271,6 +307,9 @@ * @since 0.4.4 */ public function getMasterStyles(){ + if ( !array_key_exists( "masterstyles", $this->DocumentObjects ) ) { + $this->DocumentObjects[ "masterstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + } return $this->DocumentObjects[ "masterstyles" ]; } Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/content/Content.php 2006-03-20 13:49:26 UTC (rev 33) @@ -66,71 +66,16 @@ /** * * @access public - * @depricated * - * @since 0.4.0 - */ - public function addNoScript() { - $this->root->appendChild( $this->dom->createElementNS( self::NS_OFFICE, "office:script" ) ); - } - - /** - * - * @depricated - * - * @access public - * - * @since 0.4.0 - */ - public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { - $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); - } - - /** - * - * @access public - * * @since 0.4.2 */ public function getFontFaceDecl() { return $this->FontFaceDecl; } - /** - * - * @access public - * @depricated - * - * @since 0.4.0 - */ - public function addAutomaticStyles() { - - } /** * - * @access public - * @depricated - * - * @since 0.4.0 - */ - 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> - -*/ - - /** - * * @return * * @access public Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/samples/TestOutput.php 2006-03-20 13:49:26 UTC (rev 33) @@ -65,16 +65,17 @@ $text->addNoForms(); - $text->addToText( $text->getTextHeading( "Heading", "The first step" ) ); + $text->addToText( $text->getTextHeading( "Heading", 1, "The first step" ) ); $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); } - - function makeStyle( $style ) { + + function makeFontFaceDecl( $fontfacedecl ) { $styleAttr = array(); $styleAttr[ "font-family" ] ="Tahoma"; - $style->getFontFaceDecl()->addFontFace( "Test", $styleAttr ); - unset( $styleAttr ); - + $fontFaceDecl->addFontFace( "Test", $styleAttr ); + } + + function makeStyle( $style ) { // Set default style $style->addDefaultStyle( "paragraph" ); @@ -162,8 +163,7 @@ // Get a OpenDocument object from the factory: - if(isset($SingleDocument)) - { + if(isset($SingleDocument)) { $TestDoc = OpenDocumentFactory::createOpenDocument( self::DocumentName, self::PathToDocument, @@ -175,15 +175,14 @@ */ $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); + $this->makeFontFaceDecl( $TestDoc->getFontFaceDeclaration() ); $this->makeStyle( $TestDoc->getStyle() ); $this->makeContent( $TestDoc->getContent() ); echo $TestDoc->get(); //$TestDoc->save(); - } - - + } } } Added: poc/src/styles/FontFaceDeclSplitter.php =================================================================== --- poc/src/styles/FontFaceDeclSplitter.php (rev 0) +++ poc/src/styles/FontFaceDeclSplitter.php 2006-03-20 13:49:26 UTC (rev 33) @@ -0,0 +1,56 @@ +<?php +/** + * FontFaceDeclSplitter Class + * + * $Id$ + * + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage styles + * @since 0.4.4 + */ +require_once( "OpenDocumentObjectAbstract.php" ); + +class FontFaceDeclSplitter extends OpenDocumentObjectAbstract { + private $FFD1; + private $FFD2; + /** + * + * @param DOMDocument $dom + * + * @access public + * + * @since 0.4.4 + */ + public function __construct( $f1, $f2 ) { + parent::__construct(); + + $this->FFD1 = $f1; + $this->FFD2 = $f2; + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function addFontFace( $name, $styleAttr=0, $SVGAttr=0 ) { + $this->FFD1->addFontFace( $name, $styleAttr, $SVGAttr); + $this->FFD2->addFontFace( $name, $styleAttr, $SVGAttr); + } + + /** + * + * @access public + * + * @since 0.4.4 + */ + public function commit() { + $this->isCommited = true; + } + +} Property changes on: poc/src/styles/FontFaceDeclSplitter.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-20 13:49:26 UTC (rev 33) @@ -20,44 +20,22 @@ * */ private $FontFaceDecl; - + /** * - */ - private $FontFaceDecl2; - - /** - * - */ - private $dom2; - - /** - * - */ - private $useDom2; - - /** - * * @param DOMDocument $dom * * @access public * * @since 0.4.2 */ - public function __construct( $dom, $root=0, $dom2=0 ) { + public function __construct( $dom, $root=0) { parent::__construct(); $this->dom = $dom; - $this->dom2 = $dom2; $this->useDom2 = false; $this->FontFaceDecl = $this->dom->createElementNS( self::NS_OFFICE, "office:font-face-decls" ); - - if (!empty($dom2)) { - // Package Document with two DOM documents, $dom <-> content.xml $dom2 <-> styles.xml - $this->FontFaceDecl2 = $this->dom2->createElementNS( self::NS_OFFICE, "office:font-face-decls" ); - $this->useDom2 = true; - } } /** @@ -138,18 +116,11 @@ public function addFontFace( $name, $styleAttr=0, $SVGAttr=0 ) { $font = $this->dom->createElementNS( self::NS_STYLE, "style:font-face" ); $font->setAttributeNS( self::NS_STYLE, "style:name", $name ); - if ($this->useDom2) { - $font2 = $this->dom2->createElementNS( self::NS_STYLE, "style:font-face" ); - $font2->setAttributeNS( self::NS_STYLE, "style:name", $name ); - } if (!empty($styleAttr)) { foreach( $styleAttr as $key => $value ) { // ***FIX ME*** Here we should check if the keys are possible if ($this->checkStyle($key, $value)) { $font->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); - if ($this->useDom2) { - $font2->setAttributeNS( self::NS_STYLE, "style:".$key, $value ); - } } } } @@ -158,17 +129,10 @@ // ***FIX ME*** Here we should check if the keys are possible if ($this->checkSVG( $key, $value )) { $font->setAttributeNS( self::NS_SVG, "svg:".$key, $value ); - if ($this->useDom2) { - $font2->setAttributeNS( self::NS_SVG, "svg:".$key, $value ); - } } } } $this->FontFaceDecl->appendChild( $font ); - if ($this->useDom2) { - $this->FontFaceDecl2->appendChild( $font2 ); - unset( $font2 ); - } unset( $font ); } @@ -218,21 +182,5 @@ return $this->FontFaceDecl; } - /** - * - * @return DOMDocument - * - * @access public - * @final - * - * @since 0.4.4 - */ - final public function get2() { - if (!$this->isCommited) { - $this->commit(); - } - return $this->FontFaceDecl; - } - } ?> \ No newline at end of file Modified: poc/src/styles/Styles.php =================================================================== --- poc/src/styles/Styles.php 2006-03-20 09:43:58 UTC (rev 32) +++ poc/src/styles/Styles.php 2006-03-20 13:49:26 UTC (rev 33) @@ -47,7 +47,7 @@ $this->root->setAttributeNS( self::NS_OFFICE, "office:version", "1.0" ); $this->styles = $this->dom; - $this->FontFaceDecl = new FontFaceDecl( $this->dom, $this->root ); + $this->FontFaceDecl = new FontFaceDeclaration( $this->dom, $this->root ); $this->Style = new Style( $this->dom, $this->root ); $this->AutomaticStyles = new AutomaticStyles( $this->dom, $this->root ); $this->MasterStyles = new MasterStyles( $this->dom, $this->root ); @@ -66,30 +66,45 @@ unset( $this->root ); unset( $this->style ); } + + /** + * + * @access public + * + * @since 0.4.2 + */ + public function getFontFaceDecl() { + return $this->FontFaceDecl; + } - + /** + * + * @access public + * + * @since 0.4.4 + */ + public function getStyle() { + return $this->Style; + } /** * - * @depricated * @access public * - * @since 0.4.0 + * @since 0.4.4 */ - public function addFontFace( $name, $fontFamily, $genericFamily=0, $fontPitch=0, $fontCharset=0 ) { - $this->FontFaceDecl->addFontFaceOld( $name, $fontFamily, $genericFamily, $fontPitch, $fontCharset ); + public function getAutomaticStyles() { + return $this->AutomaticStyles; } - /** * - * @depricated * @access public * - * @since 0.4.2 + * @since 0.4.4 */ - public function getFontFaceDecl() { - return $this->FontFaceDecl; + public function getMasterStyles() { + return $this->MasterStyles; } /** @@ -104,7 +119,7 @@ $this->root->appendChild( $this->AutomaticStyles->get() ); $this->root->appendChild( $this->MasterStyles->get() ); - $this->style->appendChild( $this->root ); + $this->styles->appendChild( $this->root ); $this->dom->normalize(); $this->isCommited = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yaw...@us...> - 2006-03-20 18:05:09
|
Revision: 34 Author: yawnster Date: 2006-03-20 10:04:48 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=34&view=rev Log Message: ----------- - Added in modular support for Scripts and AutoStyles. - Should output correctly now in both modes. - Started on ZipFile Task, added scope declarations. - Norman.. Its now OOo 2.0.2 :P Modified Paths: -------------- poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/ZipFile.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php Removed Paths: ------------- poc/src/samples/TestTranslate.php Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/OpenDocumentPackage.php 2006-03-20 18:04:48 UTC (rev 34) @@ -46,6 +46,9 @@ $this->logger->debug( "Constructing OpenDocumentPackage." ); + $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->dom->formatOutput = true; + $this->isCommited = false; $this->logger->debug( "Generating ZipFile object." ); @@ -62,20 +65,18 @@ $this->DocumentObjects[ "meta" ] = new Meta( ); // $this->DocumentObjects[ "settings" ] = new Settings( ); - $content = new Content( ); - $this->DocumentObjects[ "content" ] = $content; + $this->DocumentObjects[ "content" ] = new Content();; - $styles = new Styles( ); - $this->DocumentObjects[ "styles" ] = $styles; + $this->DocumentObjects[ "styles" ] = new Styles(); -// $this->DocumentObjects[ "scripts" ] = new Scripts( $contentDom ); -// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $contentDom ); - $this->DocumentObjects[ "body" ] = $content->getBody(); + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom ); + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom ); + $this->DocumentObjects[ "body" ] = $this->DocumentObjects["content"]->getBody(); - $this->DocumentObjects[ "style" ] = $styles->getStyle(); - $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $content->getFontFaceDecl(), - $styles->getFontFaceDecl() ); + $this->DocumentObjects[ "style" ] = $this->DocumentObjects["styles"]->getStyle(); + $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $this->DocumentObjects["content"]->getFontFaceDecl(), + $this->DocumentObjects["styles"]->getFontFaceDecl() ); // $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStylesSpliter(... ); // $this->DocumentObjects[ "masterstyles" ] = $styles->getMasterStyles(); } Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/OpenDocumentSingle.php 2006-03-20 18:04:48 UTC (rev 34) @@ -10,6 +10,7 @@ * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @@ -72,10 +73,10 @@ $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); // $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); -// $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); -// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); // $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); } Modified: poc/src/ZipFile.php =================================================================== --- poc/src/ZipFile.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/ZipFile.php 2006-03-20 18:04:48 UTC (rev 34) @@ -25,28 +25,28 @@ * * @var array $datasec */ - var $datasec = array(); + private $datasec = array(); /** * Central directory * * @var array $ctrl_dir */ - var $ctrl_dir = array(); + private $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"; + private $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; /** * Last offset position * * @var integer $old_offset */ - var $old_offset = 0; + private $old_offset = 0; /** @@ -59,7 +59,7 @@ * * @access private */ - function unix2DosTime($unixtime = 0) { + private function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); if ($timearray['year'] < 1980) { @@ -85,7 +85,7 @@ * * @access public */ - function addFile($data, $name, $time = 0) + public function addFile($data, $name, $time = 0) { $name = str_replace('\\', '/', $name); @@ -164,7 +164,7 @@ * * @access public */ - function file() + public function file() { $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir); Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestInput.php 2006-03-20 18:04:48 UTC (rev 34) @@ -55,7 +55,7 @@ <legend>Document Type:</legend> <label for="single">Single </label><input type="radio" id="single" name="SingleDocument" value="true" checked="checked" /> <label for="package">Package </label><input type="radio" id="package" name="SingleDocument" value="false" /><br /> - <p>If you want to display the results in <strong>OpenOffice 2.0.1</strong>, you should take the <em>package</em> document type.</p> + <p>If you want to display the results in <strong>OpenOffice 2.0.2</strong>, you should take the <em>package</em> document type.</p> </fieldset> <fieldset> <legend>Metadata:</legend> Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestOutput.php 2006-03-20 18:04:48 UTC (rev 34) @@ -7,7 +7,7 @@ * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yan...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @subpackage samples @@ -29,19 +29,9 @@ 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" ); - */ + $conf = array( "mode" => 0600 ); + $this->logger = &Log::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); + $this->logger = &Log::factory( "console", "", "OpenDocument" ); } function makeMeta( $meta, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { @@ -55,25 +45,28 @@ } function makeContent( $content ) { - $content->addNoScript(); - $content->addFontFace( "Test", "Tahoma" ); - - $content->addNoAutomaticStyles(); + $text = $content->getText(); - $text = $content->getBody()->getText(); - $text->addNoForms(); $text->addToText( $text->getTextHeading( "Heading", 1, "The first step" ) ); $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); } - function makeFontFaceDecl( $fontfacedecl ) { + function makeFontFaceDecl( $fontFaceDecl ) { $styleAttr = array(); $styleAttr[ "font-family" ] ="Tahoma"; $fontFaceDecl->addFontFace( "Test", $styleAttr ); } + + function makeAutomaticStyles( $automaticStyles ) { + return $automaticStyles; + } + + function makeScripts( $scripts ) { + return $scripts; + } function makeStyle( $style ) { // Set default style @@ -175,9 +168,11 @@ */ $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); - $this->makeFontFaceDecl( $TestDoc->getFontFaceDeclaration() ); + $this->makeAutomaticStyles( $TestDoc->getAutomaticStyles() ); + $this->makeScripts( $TestDoc->getScripts() ); + $this->makeFontFaceDecl( $TestDoc->getFontFaceDeclaration() ); $this->makeStyle( $TestDoc->getStyle() ); - $this->makeContent( $TestDoc->getContent() ); + $this->makeContent( $TestDoc->getBody() ); echo $TestDoc->get(); Deleted: poc/src/samples/TestTranslate.php =================================================================== --- poc/src/samples/TestTranslate.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestTranslate.php 2006-03-20 18:04:48 UTC (rev 34) @@ -1,48 +0,0 @@ -<?php -/** - * TestTranslate class that will translate a given formatting style to ODF formatting. - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument - * @subpackage samples - * @since 0.4.2 - */ - -require_once( "Log/observer.php" ); - -class TestTranslate { - - private $expression; - private $logger; - private $matches = array(); - - public function __construct() { - $this->logger = &Log::factory( "null", "", "OpenDocument" ); - $this->logger->debug( "Constructing TestTranslate." ); - } - - public function __destruct() { - $this->logger->debug( "Destructing TestTranslate." ); - } - - public function getParagraphs($document_content) { - - $matches = preg_split( "/\n/", $document_content, 0, PREG_SPLIT_NO_EMPTY); - - return $matches; - } - - public function getHeadings($document_content) { - - $matches = preg_split( "/(<h[1-6])+\w.+(<\/h[1-6]>)+/", $document_content, 0, PREG_SPLIT_NO_EMPTY); - - return $matches; - } - -} - ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-20 22:15:08
|
Revision: 35 Author: nmarkgraf Date: 2006-03-20 14:14:51 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=35&view=rev Log Message: ----------- Minor changes: - Reverted to changes on OpenDocumentPackage and OpenDocumentSingle. Comment is in the source. - Minor bug fix in content/Content Modified Paths: -------------- poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/content/Content.php Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-20 18:04:48 UTC (rev 34) +++ poc/src/OpenDocumentPackage.php 2006-03-20 22:14:51 UTC (rev 35) @@ -46,9 +46,6 @@ $this->logger->debug( "Constructing OpenDocumentPackage." ); - $this->dom = new DOMDocument( "1.0", "utf-8" ); - $this->dom->formatOutput = true; - $this->isCommited = false; $this->logger->debug( "Generating ZipFile object." ); @@ -61,24 +58,23 @@ } } $this->logger->debug( "Generating Manifest with mimetype \"".$this->getMimeType()."\"." ); - $this->DocumentObjects[ "manifest" ] = new Manifest( $this->getMimeType() ); - $this->DocumentObjects[ "meta" ] = new Meta( ); -// $this->DocumentObjects[ "settings" ] = new Settings( ); + $this->DocumentObjects[ "manifest" ] = new Manifest( $this->getMimeType() ); + $this->DocumentObjects[ "meta" ] = new Meta( ); +// $this->DocumentObjects[ "settings" ] = new Settings( ); - $this->DocumentObjects[ "content" ] = new Content();; + $this->DocumentObjects[ "content" ] = new Content();; - $this->DocumentObjects[ "styles" ] = new Styles(); + $this->DocumentObjects[ "styles" ] = new Styles(); - $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom ); - $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom ); - $this->DocumentObjects[ "body" ] = $this->DocumentObjects["content"]->getBody(); - + $this->DocumentObjects[ "body" ] = $this->DocumentObjects["content"]->getBody(); - $this->DocumentObjects[ "style" ] = $this->DocumentObjects["styles"]->getStyle(); - $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $this->DocumentObjects["content"]->getFontFaceDecl(), - $this->DocumentObjects["styles"]->getFontFaceDecl() ); -// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStylesSpliter(... ); -// $this->DocumentObjects[ "masterstyles" ] = $styles->getMasterStyles(); + $this->DocumentObjects[ "style" ] = $this->DocumentObjects["styles"]->getStyle(); + $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( + $this->DocumentObjects[ "content" ]->getFontFaceDecl(), + $this->DocumentObjects[ "styles" ]->getFontFaceDecl() + ); + // Because all other parts will be inserted on demand, there is no need to initialise them here! + } /** @@ -246,11 +242,9 @@ case "content" : $this->addXMLDocument( "content.xml", $docObj->get() ); break; -/* case "settings" : - $this->addXMLDocument( "settings.xml", $dom ); + $this->addXMLDocument( "settings.xml", $domObj->get() ); break; -*/ } } @@ -347,7 +341,10 @@ * @since 0.4.4 */ public function getSettings(){ - return 0; + if (!array_key_exists ( "settings", $this->DocumentObjects) ) { + $this->DocumentObjects[ "settings" ] = new Settings(); + } + return $this->DocumentObjects[ "settings" ]; } /** @@ -383,6 +380,14 @@ public function getAutomaticStyles(){ if ( !array_key_exists( "automaticstyles", $this->DocumentObjects ) ) { $this->DocumentObjects[ "automaticstyles" ] = 0; +/* +// This should be something like: + $this->DocumentObjects[ "automaticstyles" ] = new AutmaticStylesSplitter( + $this->DocumentObjects[ "content" ]->getAutmaticStyles(), + $this->DocumentObjects[ "styles" ]->getAutomaticStyles() + ); + +*/ } return $this->DocumentObjects[ "automaticstyles" ]; } @@ -395,7 +400,7 @@ */ public function getMasterStyles(){ if ( !array_key_exists( "masterstyles", $this->DocumentObjects ) ) { - $this->DocumentObjects[ "masterstyles" ] = 0; + $this->DocumentObjects[ "masterstyles" ] = $this->DocumentObjects[ "styles" ]->getMasterStyles(); } return $this->DocumentObjects[ "masterstyles" ]; } Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 18:04:48 UTC (rev 34) +++ poc/src/OpenDocumentSingle.php 2006-03-20 22:14:51 UTC (rev 35) @@ -71,14 +71,11 @@ $this->root = $this->dom->createElementNS( self::NS_OFFICE, "office:document" ); $this->root->setAttributeNS( self::NS_OFFICE, "office:mimetype", $mimetype ); - $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); -// $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); - $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); - $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); -// $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); - $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); + $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); + // Because all other parts will be inserted on demand, there is no need to initialise them here! } /** Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-03-20 18:04:48 UTC (rev 34) +++ poc/src/content/Content.php 2006-03-20 22:14:51 UTC (rev 35) @@ -4,13 +4,13 @@ * * $Id$ * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.4.4 + * @license GNU General Public License + * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage content + * @since 0.4.4 */ require_once( "content/Scripts.php" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-29 13:59:38
|
Revision: 41 Author: nmarkgraf Date: 2006-03-29 05:59:14 -0800 (Wed, 29 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=41&view=rev Log Message: ----------- Fixed some very bad typos. Therefor I added a new unit test just for the name spaces. Modified Paths: -------------- poc/src/OpenDocumentObjectAbstract.php Added Paths: ----------- poc/src/OpenDocumentObjectAbstractTest.php Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-29 11:01:01 UTC (rev 40) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-29 13:59:14 UTC (rev 41) @@ -93,18 +93,18 @@ /** * namespace OpenDocument svg - */ - const NS_SVG = "urn:oasis:names:tc:openedocument:xmlsns:svg-compartible:1.0"; + */ + const NS_SVG = "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; /** * namespace OpenDocument fo (formation objects) */ - const NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compartible:1.0"; + const NS_FO = "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; /** * namespace OpenDocument smil */ - const NS_SMIL = "urn:oasis:names:tc:opendocument:xmlns:smil-compartible:1.0"; + const NS_SMIL = "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"; /** * namespace Dublin Core Added: poc/src/OpenDocumentObjectAbstractTest.php =================================================================== --- poc/src/OpenDocumentObjectAbstractTest.php (rev 0) +++ poc/src/OpenDocumentObjectAbstractTest.php 2006-03-29 13:59:14 UTC (rev 41) @@ -0,0 +1,74 @@ +<?php +/** + * TestCase for OpenDocumentObjectAbstract class + * + * $Id$ + * + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @license GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage UnitTest + * @since 0.5.0 + */ + +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "OpenDocumentObjectAbstract.php"; + +class OpenDocumentObjectAbstractTest extends PHPUnit2_Framework_TestCase { + +const office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"; +const style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"; +const text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"; +const table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"; +const draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"; +const fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"; +const xlink="http://www.w3.org/1999/xlink"; +const dc="http://purl.org/dc/elements/1.1/"; +const meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"; +const number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"; +const svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"; +const chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"; +const dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"; +const math="http://www.w3.org/1998/Math/MathML"; +const form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"; +const script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"; +const ooo="http://openoffice.org/2004/office"; +const ooow="http://openoffice.org/2004/writer"; +const oooc="http://openoffice.org/2004/calc"; +const dom="http://www.w3.org/2001/xml-events"; + + /** + * This test will check all name spaces. The namespaces in this file are extracted from + * an OpenOffice document, so they are not written by hand out of the OpenDocument documentation. + * This should help to fix typos. (And it did!!!) + * + * @since 0.5.0 + */ + function testNamespaces() { + $this->assertEquals( OpenDocumentObjectAbstract::NS_OFFICE, self::office ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_STYLE, self::style ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_TEXT, self::text ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_TABLE, self::table ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_DRAW, self::draw ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_FO, self::fo ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_XLINK, self::xlink ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_DC, self::dc ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_META, self::meta ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_NUMBER, self::number ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_SVG, self::svg ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_CHART, self::chart ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_DR3D, self::dr3d ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_MATHML, self::math ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_FORM, self::form ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_SCRIPT, self::script ); +/* + $this->assertEquals( OpenDocumentObjectAbstract::NS_OOO, self::ooo ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_OOOW, self::ooow ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_OOOC, self::oooc ); + $this->assertEquals( OpenDocumentObjectAbstract::NS_DOM, self::dom ); +*/ + } +} +?> \ No newline at end of file Property changes on: poc/src/OpenDocumentObjectAbstractTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-05 19:48:08
|
Revision: 48 Author: nmarkgraf Date: 2006-04-05 12:47:43 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=48&view=rev Log Message: ----------- More refactoring: - Deleted AllInclude.inc, OpenDocumentObjectAbstract and OpenDocumentAbstract. They are no longer needed. - Added a new test case for the MimeTypes class. Modified Paths: -------------- poc/src/OpenDocumentFactory.php poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentPackage.php poc/src/content/Content.php poc/src/util/AbstractDocument.php poc/src/util/MimeTypes.php Added Paths: ----------- poc/src/util/MimeTypesTest.php Removed Paths: ------------- poc/src/AllInclude.inc poc/src/OpenDocumentAbstract.php poc/src/OpenDocumentObjectAbstract.php Deleted: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/AllInclude.inc 2006-04-05 19:47:43 UTC (rev 48) @@ -1,38 +0,0 @@ -<?php -/** - * AllInclude include file - * - * I hope this is a temporay solution to the massiv require_once problem, - * but Axel is working on this, I hope. - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.4.3 - */ - -// Our own stuff: -require_once( "OpenDocument.php" ); -require_once( "OpenDocumentAbstract.php" ); -require_once( "OpenDocumentObjectAbstract.php" ); -require_once( "OpenDocumentSingle.php" ); -require_once( "OpenDocumentPackage.php" ); -require_once( "styles/Style.php" ); -require_once( "styles/Styles.php" ); -require_once( "content/Content.php" ); -require_once( "meta/Meta.php" ); -require_once( "manifest/Manifest.php" ); -require_once( "content/Body.php" ); -require_once( "content/BodyText.php" ); -require_once( "content/BodyTable.php" ); -require_once( "styles/FontFaceDeclaration.php" ); -// Non-PEAR and not our stuff: -require_once( "others/ZipFile.php" ); -// PEAR stuff: -require_once( "Log.php" ); -?> \ No newline at end of file Deleted: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/OpenDocumentAbstract.php 2006-04-05 19:47:43 UTC (rev 48) @@ -1,156 +0,0 @@ -<?php -/** - * OpenDocumentAbstract Class - * (C) by Norman Markgraf in 2006 - * - * OpenDocumentAbstract is the basic class for all OpenDocument classes - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * - * @since 0.3.0 - */ - -require_once( "util/ReleaseInformation.php" ); - -class OpenDocumentAbstract { - - /** - * Copyright notice for this package. - */ - const Copyright = "(C) in 2006 by Norman Markgraf, Alex Latchford, et al."; - - /** - * Name of this package. - */ - const PackageName = "OpenDocumentPHP"; - - /** - * Default mime type is set to a text document. - */ - const defaultMimeType = "application/vnd.oasis.opendocument.text"; - - /** - * The PEAR::Log logger - * - * @access protected - * @since 0.4.0 - */ - protected $logger; - - /** - * The mime type of the document - * - * @access protected - * @since 0.4.0 - */ - protected $mimetype; - - /** - * This is the storage for all OpenDocument objects - * - * @access protected - * @since 0.3.0 - */ - protected $DocumentObjects; - - /** - * This construtor will set the mimetype of this document and start logging. - * - * Therefor this line is included in this constructor: - * <code> - * $this->logger = &Log::factory( "null", "", "OpenDocument" ); - * </code> - * - * @param string $mimetype The mime type of this document. - * @access public - * @since 0.3.0 - */ - public function __construct( $mimetype = 0 ) { - $this->logger = &Log::factory( "null", "", "OpenDocument" ); - $this->logger->debug( "Constructing OpenDocumentAbstract." ); - - // make an array for all the Document Objects. - $this->DocumentObjects = array(); - - if (!empty($mimetype)) { - $this->mimetype = $mimetype; - } - } - - /** - * - * @access public - * @since 0.3.0 - */ - public function __destruct() { - $this->logger->debug( "OpenDocumentAbstract destructed." ); - $this->logger->close(); - } - - /** - * Returns revision information - * - * @return string Revision information. - * @access public - * @final - * @since 0.4.0 - */ - final public function getRevision() { - $Revision = ""; - return "(".substr("$Revision$",-2).")".ReleaseInformation::Revision; - } - - /** - * Returns release and revision information. - * - * @return string Release and revision information. - * @access public - * @final - * @since 0.4.0 - */ - final public function getRelease() { - return ReleaseInformation::Release.".".ReleaseInformation::Revision; - } - - /** - * Returns some informations about this package, release and copyright. - * - * @return string Package name, release and copyright. - * @access public - * @final - * @since 0.4.0 - */ - final public function getPackageInformation() { - return self::PackageName . " " . $this->getRelease() . " " . self::Copyright; - } - - /** - * - * @access public - * @final - * @since 0.4.0 - */ - final public function attachObserverToLogger( $observer ) { - $this->logger->attach( $observer ); - } - - /** - * Returns the setted mime type of this document. - * - * @return string Current mime type of this document. - * @access public - * @final - * @since 0.4.0 - */ - final public function getMimeType() { - return $this->mimetype; - } - -} -?> \ No newline at end of file Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/OpenDocumentFactory.php 2006-04-05 19:47:43 UTC (rev 48) @@ -13,36 +13,18 @@ * @since 0.4.0 */ -include_once ( "AllInclude.inc" ); - +require_once( "OpenDocument.php" ); +require_once( "OpenDocumentSingle.php" ); +require_once( "OpenDocumentPackage.php" ); +require_once( "util/MimeTypes.php" ); /** - * - * @author Alex Latchford <yaw...@us...> - * - * @since 0.4.1 - */ - /* -function __autoload($class_name) { - // There is no "void" class, so we must ignore it - if ($class_name != "void" ) { - // Classes in subdirectories have '_' instead of '/' or '\\' in their names. - require_once( strtr ( $class_name, "_", "/" ) . ".php" ); - } -} -*/ - -/** * The main factory class of OpenDocumentPHP * * This is the main factory class for OpenDocumentPHP. You can use like this: * <code> * <?php - * $SingleDoc = OpenDocumentFactory::createOpenDocument( - * "test.odc", "", true, "application/vnd.oasis.opendocument.calc" - * ); - * $PackageDoc = OpenDocumentFactory::createOpenDocument( - * "test.odt", "", false - * ); + * $SingleDoc = OpenDocumentFactory::createOpenDocument( true, "application/vnd.oasis.opendocument.image" ); + * $PackageDoc = OpenDocumentFactory::createOpenDocument( false ); * ?> * </code> * @@ -52,7 +34,6 @@ * @since 0.4.0 */ final class OpenDocumentFactory { - const defaultMimeType = "application/vnd.oasis.opendocument.text"; /** * Creates an OpenDocument. * @@ -68,11 +49,11 @@ * * @since 0.4.0 */ - static public function createOpenDocument( $documentName, $documentPath=0, $singleDocument = TRUE, $mimeType=self::defaultMimeType ) { + static public function createOpenDocument( $singleDocument = TRUE, $mimeType=MimeTypes::defaultMimeType ) { if ( $singleDocument ) { return new OpenDocumentSingle( $mimeType ); } else { - return new OpenDocumentPackage( $documentName, $documentPath, $mimeType ); + return new OpenDocumentPackage( $mimeType ); } } Modified: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/OpenDocumentFactoryTest.php 2006-04-05 19:47:43 UTC (rev 48) @@ -20,7 +20,7 @@ class OpenDocumentFactoryTest extends PHPUnit2_Framework_TestCase { function testFactoryForSingleDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); + $OD = OpenDocumentFactory::createOpenDocument( true ); $this->assertNotNull( $OD ); $this->assertType( "OpenDocumentSingle", $OD ); @@ -28,20 +28,21 @@ unset( $OD ); } + function testFactoryForMimetypeInSingleDocumentDefault() { + $OD = OpenDocumentFactory::createOpenDocument( true ); + $mimetype = $OD->getMimeType(); + $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly (was:".$mimetype.")." ); + } + function testFactoryForMimetypeInSingleDocument() { - $OD = OpenDocumentFactory::createOpenDocument( "test.odf", "", true ); + $ODA = OpenDocumentFactory::createOpenDocument( true, "TestMimeType" ); + $mimetype = $ODA->getMimeType(); + $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly (was:".$mimetype.")." ); - $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 ); + $OD = OpenDocumentFactory::createOpenDocument( false ); $this->assertNotNull( $OD ); $this->assertType( "OpenDocumentPackage", $OD ); @@ -49,16 +50,16 @@ unset( $OD ); } + function testFactoryForMimetypeInPackageDocumentDefault() { + $OD = OpenDocumentFactory::createOpenDocument( false ); + $mimetype = $OD->getMimeType(); + $this->assertEquals( "application/vnd.oasis.opendocument.text", $OD->getMimeType(), "Default mimetype not set correctly (was:".$mimetype.")." ); + } + 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 ); + $ODA = OpenDocumentFactory::createOpenDocument( false, "TestMimeType" ); + $mimetype = $ODA->getMimeType(); + $this->assertEquals( "TestMimeType", $ODA->getMimeType(), "Default mimetype not set correctly (was:".$mimetype.")." ); } Deleted: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/OpenDocumentObjectAbstract.php 2006-04-05 19:47:43 UTC (rev 48) @@ -1,74 +0,0 @@ -<?php -/** - * OpenDocumentObjectAbstract Class - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, et al. - * @author Norman Markgraf <nma...@us...> - * @version $Revision$ - * @package OpenDocument - * @since 0.4.0 - */ - -require_once( "OpenDocumentAbstract.php" ); - -class OpenDocumentObjectAbstract extends OpenDocumentAbstract { - - /** - * @access protected - */ - protected $dom; - - /** - * @access protected - */ - protected $isCommited; - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __construct( $mimetype = 0 ) { - parent::__construct( $mimetype ); - $this->logger->debug( "Constructing OpenDocumentObjectAbstract." ); - $this->isCommited = false; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function __destruct() { - $this->logger->debug( "OpenDocumentObjectAbstract destructed." ); - parent::__destruct(); - } - /** - * - * @return DOMDocument - * @access public - * - * @since 0.4.0 - */ - public function get() { - return $this->dom; - } - - /** - * - * @access public - * - * @since 0.4.0 - */ - public function save( $filename ) { - $tmp =& $this->dom; - - $tmp->save( $filename ); - } -} -?> \ No newline at end of file Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/OpenDocumentPackage.php 2006-04-05 19:47:43 UTC (rev 48) @@ -17,16 +17,18 @@ */ require_once( "meta/Meta.php" ); require_once( "settings/Settings.php" ); +require_once( "content/Content.php" ); +require_once( "styles/Styles.php" ); +require_once( "content/Body.php" ); require_once( "content/Scripts.php" ); +require_once( "styles/AutomaticStyles.php" ); +require_once( "styles/AutomaticStylesSplitter.php" ); require_once( "styles/FontFaceDeclaration.php" ); require_once( "styles/FontFaceDeclSplitter.php" ); require_once( "styles/Style.php" ); -require_once( "styles/AutomaticStyles.php" ); require_once( "styles/MasterStyles.php" ); -require_once( "content/Body.php" ); -require_once( "OpenDocumentAbstract.php" ); require_once( "util/AbstractDocument.php" ); - +require_once( "util/MimeTypes.php" ); require_once( "others/ZipFile.php" ); class OpenDocumentPackage extends AbstractDocument implements OpenDocument { @@ -35,28 +37,19 @@ private $packagetmp; private $zip; private $isCommited; - // - public $tmp = "c:/TEMP/"; - public $path = ""; /** * * @access public * @since 0.4.0 */ - public function __construct( $documentName=0, $documentPath=0, $mimetype="application/vnd.oasis.opendocument.text" ) { + public function __construct( $mimetype=MimeTypes::Text ) { parent::__construct( $mimetype ); $this->isCommited = false; $this->zip = new ZipFile(); - if ( !empty( $documentName ) ) { - $this->setPackageName( $documentName ); - if ( !empty( $documentPath ) ) { - $this->path = $documentPath; - } - } $this->Manifest = new Manifest( $this->getMimeType() ); $this->Meta = new Meta(); Modified: poc/src/content/Content.php =================================================================== --- poc/src/content/Content.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/content/Content.php 2006-04-05 19:47:43 UTC (rev 48) @@ -17,7 +17,6 @@ require_once( "styles/FontFaceDeclaration.php" ); require_once( "styles/AutomaticStyles.php" ); require_once( "content/Body.php" ); -require_once( "OpenDocumentObjectAbstract.php" ); require_once( "util/NameSpaces.php" ); class Content { Modified: poc/src/util/AbstractDocument.php =================================================================== --- poc/src/util/AbstractDocument.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/util/AbstractDocument.php 2006-04-05 19:47:43 UTC (rev 48) @@ -89,9 +89,6 @@ * @since 0.4.7 */ public function __construct( $mimetype = 0 ) { - $this->logger = &Log::factory( "null", "", "OpenDocument" ); - $this->logger->debug( "Constructing AbstractDocument." ); - $this->mimetype = $mimetype; } @@ -101,8 +98,6 @@ * @since 0.3.0 */ public function __destruct() { - $this->logger->debug( "AbstractDocument destructed." ); - $this->logger->close(); } Modified: poc/src/util/MimeTypes.php =================================================================== --- poc/src/util/MimeTypes.php 2006-04-05 15:52:08 UTC (rev 47) +++ poc/src/util/MimeTypes.php 2006-04-05 19:47:43 UTC (rev 48) @@ -1,7 +1,25 @@ <?php /** - * NameSpaces Class + * MimeTypes Class * + * <b>Mimtype -> file suffix</b> + * vnd.oasis.opendocument.text -> .odt + * vnd.oasis.opendocument.text-template -> .ott + * vnd.oasis.opendocument.text-master -> .otm + * vnd.oasis.opendocument.text-web -> .oth + * vnd.oasis.opendocument.spreadsheet -> .ods + * vnd.oasis.opendocument.spreadsheet-template -> .ots + * vnd.oasis.opendocument.graphics -> .odg + * vnd.oasis.opendocument.graphics-template -> .otg + * vnd.oasis.opendocument.presentation -> .odp + * vnd.oasis.opendocument.presentation-template -> .otp + * vnd.oasis.opendocument.image -> .odi + * vnd.oasis.opendocument.image-template -> .oti + * vnd.oasis.opendocument.formula -> .odf + * vnd.oasis.opendocument.formula-template -> .otf + * vnd.oasis.opendocument.chart -> .odc + * vnd.oasis.opendocument.chart-template -> .otc + * * $Id$ * * @license GNU General Public License @@ -13,10 +31,108 @@ * @since 0.4.7 */ -class MimeTypes { - const Text = "application/vnd.oasis.opendocument.text"; - const Calc = "application/vnd.oasis.opendocument.calc"; - const defaultMimeType = "application/vnd.oasis.opendocument.text"; +class MimeTypes { + /** + * Mime type for texts + * @since 0.4.7 + */ + const Text = "application/vnd.oasis.opendocument.text"; + + /** + * Mime type for text templates + * @since 0.4.7 + */ + const TextTemplate = "application/vnd.oasis.opendocument.text-template"; + + /** + * Mime type for text master files + * @since 0.4.7 + */ + const TextMaster = "application/vnd.oasis.opendocument.text-master"; + + /** + * Mime type for text web + * @since 0.4.7 + */ + const TextWeb = "application/vnd.oasis.opendocument.text-web"; + + /** + * Mime type for spreadsheets + * @since 0.4.7 + */ + const Spreadsheet = "application/vnd.oasis.opendocument.spreadsheet"; + + /** + * Mime type for spreadsheets templates + * @since 0.4.7 + */ + const SpreadsheetTemplate = "application/vnd.oasis.opendocument.spreadsheet-template"; + + /** + * Mime type for graphics + * @since 0.4.7 + */ + const Graphics = "application/vnd.oasis.opendocument.graphics"; + + /** + * Mime type for graphics templates + * @since 0.4.7 + */ + const GraphicsTemplate = "application/vnd.oasis.opendocument.graphics-template"; + + /** + * Mime type for presentations + * @since 0.4.7 + */ + const Presentation = "application/vnd.oasis.opendocument.presentation"; + + /** + * Mime type for presentation templates + * @since 0.4.7 + */ + const PresentationTemplate = "application/vnd.oasis.opendocument.presentation-template"; + + /** + * Mime type for images + * @since 0.4.7 + */ + const Image = "application/vnd.oasis.opendocument.image"; + + /** + * Mime type for images templates + * @since 0.4.7 + */ + const ImageTemplate = "application/vnd.oasis.opendocument.image-template"; + + /** + * Mime type for formulars + * @since 0.4.7 + */ + const Formula = "application/vnd.oasis.opendocument.formula"; + + /** + * Mime type for formular templates + * @since 0.4.7 + */ + const FormulaTemplate = "application/vnd.oasis.opendocument.formula-template"; + + /** + * Mime type for charts + * @since 0.4.7 + */ + const Chart = "application/vnd.oasis.opendocument.chart"; + + /** + * Mime type for chart templates + * @since 0.4.7 + */ + const ChartTemplate = "application/vnd.oasis.opendocument.chart-template"; + + /** + * Default mime type is set to text + * @since 0.4.7 + */ + const defaultMimeType = "application/vnd.oasis.opendocument.text"; } ?> \ No newline at end of file Added: poc/src/util/MimeTypesTest.php =================================================================== --- poc/src/util/MimeTypesTest.php (rev 0) +++ poc/src/util/MimeTypesTest.php 2006-04-05 19:47:43 UTC (rev 48) @@ -0,0 +1,62 @@ +<?php +/** + * TestCase for MimeTypes class + * + * $Id$ + * + * @copyright Copyright © 2006, Norman Markgraf, et al. + * @license GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision$ + * @package OpenDocument + * @subpackage UnitTest + * @since 0.4.7 + */ + +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "util/MimeTypes.php"; + +class MimeTypesTest extends PHPUnit2_Framework_TestCase { + const Text = "application/vnd.oasis.opendocument.text"; + const TextTemplate = "application/vnd.oasis.opendocument.text-template"; + const TextMaster = "application/vnd.oasis.opendocument.text-master"; + const TextWeb = "application/vnd.oasis.opendocument.text-web"; + const Spreadsheet = "application/vnd.oasis.opendocument.spreadsheet"; + const SpreadsheetTemplate = "application/vnd.oasis.opendocument.spreadsheet-template"; + const Graphics = "application/vnd.oasis.opendocument.graphics"; + const GraphicsTemplate = "application/vnd.oasis.opendocument.graphics-template"; + const Presentation = "application/vnd.oasis.opendocument.presentation"; + const PresentationTemplate = "application/vnd.oasis.opendocument.presentation-template"; + const Image = "application/vnd.oasis.opendocument.image"; + const ImageTemplate = "application/vnd.oasis.opendocument.image-template"; + const Formula = "application/vnd.oasis.opendocument.formula"; + const FormulaTemplate = "application/vnd.oasis.opendocument.formula-template"; + const Chart = "application/vnd.oasis.opendocument.chart"; + const ChartTemplate = "application/vnd.oasis.opendocument.chart-template"; + const defaultMimeType = "application/vnd.oasis.opendocument.text"; + + /** + * This test will check all mime types. + * @since 0.4.7 + */ + function testMimeTypes() { + $this->assertEquals( MimeTypes::Text, self::Text ); + $this->assertEquals( MimeTypes::TextTemplate, self::TextTemplate ); + $this->assertEquals( MimeTypes::TextMaster, self::TextMaster ); + $this->assertEquals( MimeTypes::TextWeb, self::TextWeb ); + $this->assertEquals( MimeTypes::Spreadsheet, self::Spreadsheet ); + $this->assertEquals( MimeTypes::SpreadsheetTemplate, self::SpreadsheetTemplate ); + $this->assertEquals( MimeTypes::Graphics, self::Graphics ); + $this->assertEquals( MimeTypes::GraphicsTemplate, self::GraphicsTemplate ); + $this->assertEquals( MimeTypes::Presentation, self::Presentation ); + $this->assertEquals( MimeTypes::PresentationTemplate, self::PresentationTemplate ); + $this->assertEquals( MimeTypes::Image, self::Image ); + $this->assertEquals( MimeTypes::ImageTemplate, self::ImageTemplate ); + $this->assertEquals( MimeTypes::Formula, self::Formula ); + $this->assertEquals( MimeTypes::FormulaTemplate, self::FormulaTemplate ); + $this->assertEquals( MimeTypes::Chart, self::Chart ); + $this->assertEquals( MimeTypes::ChartTemplate, self::ChartTemplate ); + $this->assertEquals( MimeTypes::defaultMimeType, self::defaultMimeType ); + } +} +?> \ No newline at end of file Property changes on: poc/src/util/MimeTypesTest.php ___________________________________________________________________ Name: svn:keywords + Date Revision Author HeadURL Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-06 09:20:48
|
Revision: 49 Author: nmarkgraf Date: 2006-04-06 02:20:10 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=49&view=rev Log Message: ----------- Mostly refactoring to support more phpDocumentor features. But also: - Added test case for AbstractDocument - Added test case for ReleaseInformation Modified Paths: -------------- poc/etc/ReleaseInformation.tpl poc/src/OpenDocument.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/content/Body.php poc/src/content/BodyText.php poc/src/manifest/Manifest.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php poc/src/settings/Settings.php poc/src/styles/AutomaticStyles.php poc/src/styles/AutomaticStylesInterface.php poc/src/styles/AutomaticStylesSplitter.php poc/src/styles/FontFaceDeclInterface.php poc/src/styles/FontFaceDeclSplitter.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/MasterStyles.php poc/src/styles/Style.php poc/src/styles/Styles.php poc/src/util/AbstractDocument.php poc/src/util/NameSpacesTest.php Added Paths: ----------- poc/src/util/AbstractDocumentTest.php poc/src/util/ReleaseInformationTest.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-06 10:20:49
|
Revision: 50 Author: nmarkgraf Date: 2006-04-06 03:20:28 -0700 (Thu, 06 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=50&view=rev Log Message: ----------- Some more refactoring. Removed some unused and untested old work from some of the class files. Modified Paths: -------------- poc/src/OpenDocumentFactory.php poc/src/OpenDocumentSingle.php poc/src/content/Scripts.php poc/src/meta/Meta.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/Style.php poc/src/util/AbstractDocument.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-07 09:14:38
|
Revision: 51 Author: nmarkgraf Date: 2006-04-07 02:14:14 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=51&view=rev Log Message: ----------- Another refactoring session: - Added a new test case SettingsTest. - Added some new tests in OpenDocumentSingleTest so we cover now approx. 65% of our code. Modified Paths: -------------- poc/src/OpenDocument.php poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/OpenDocumentSingleTest.php poc/src/content/Scripts.php poc/src/meta/Meta.php poc/src/meta/MetaTest.php poc/src/settings/Settings.php poc/src/styles/FontFaceDeclaration.php Added Paths: ----------- poc/src/settings/SettingsTest.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-04-07 13:58:15
|
Revision: 52 Author: nmarkgraf Date: 2006-04-07 06:57:30 -0700 (Fri, 07 Apr 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=52&view=rev Log Message: ----------- More refactoring work: - Added new OpenDocumentPackageTest class. - Some bug fixes of some minor bugs found by the new test case. We now have 83% of the code covered by unit tests. Modified Paths: -------------- poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingleTest.php poc/src/content/Content.php poc/src/manifest/Manifest.php poc/src/styles/AutomaticStyles.php poc/src/styles/FontFaceDeclaration.php poc/src/styles/MasterStyles.php poc/src/styles/Styles.php poc/src/util/NameSpaces.php Added Paths: ----------- poc/src/OpenDocumentPackageTest.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |