|
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< |