You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(43) |
Apr
(20) |
May
(20) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(20) |
Feb
(28) |
Mar
(28) |
Apr
(1) |
May
(5) |
Jun
(27) |
Jul
(55) |
Aug
(30) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
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 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 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: <yaw...@us...> - 2006-03-18 22:12:44
|
Revision: 29 Author: yawnster Date: 2006-03-18 14:12:38 -0800 (Sat, 18 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=29&view=rev Log Message: ----------- Removing extra file that isn't used anymore. Removed Paths: ------------- poc/src/OpenDocumentOutput.php Deleted: poc/src/OpenDocumentOutput.php =================================================================== --- poc/src/OpenDocumentOutput.php 2006-03-16 08:08:09 UTC (rev 28) +++ poc/src/OpenDocumentOutput.php 2006-03-18 22:12:38 UTC (rev 29) @@ -1,194 +0,0 @@ -<?php -/** - * 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 - */ - -ini_set( "include_path", ini_get( "include_path" ). ";..\\" ); - -require_once( "OpenDocumentFactory.php" ); -require_once( "Log/observer.php" ); -require_once( "samples/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); - - 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 ... -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nma...@us...> - 2006-03-16 08:08:20
|
Revision: 28 Author: nmarkgraf Date: 2006-03-16 00:08:09 -0800 (Thu, 16 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=28&view=rev Log Message: ----------- Only minor changes: - Added copyright stuff to AllInclude.inc - Make some minor changes in build.xml Modified Paths: -------------- poc/build.xml poc/src/AllInclude.inc Property Changed: ---------------- poc/src/AllInclude.inc Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-15 12:34:45 UTC (rev 27) +++ poc/build.xml 2006-03-16 08:08:09 UTC (rev 28) @@ -6,6 +6,7 @@ <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> <mkdir dir="docs"/> + <mkdir dir="production"/> </target> <target name="preparedist"> @@ -88,11 +89,21 @@ </fileset> </tar> </target> + + <target name="production" depends="prepare"> + <copy todir="production"> + <fileset dir="src"> + <include name="**/*.php"/> + <include name="**/*.inc"/> + <exclude name="**/*Test.php"/> + </fileset> + </copy> + </target> <target name="build" depends="prepare,test,reports,docs,dist"> </target> - <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist"> + <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist,production"> </target> @@ -104,6 +115,7 @@ <delete dir="docs"/> <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> + <delete dir="production"/> </target> <target name="proper" depends="clean"> Modified: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc 2006-03-15 12:34:45 UTC (rev 27) +++ poc/src/AllInclude.inc 2006-03-16 08:08:09 UTC (rev 28) @@ -1,5 +1,22 @@ <?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" ); @@ -13,6 +30,8 @@ require_once( "content/BodyText.php" ); require_once( "content/BodyTable.php" ); require_once( "styles/FontFaceDeclaration.php" ); +// Non-PEAR and not our stuff: require_once( "ZipFile.php" ); +// PEAR stuff: require_once( "Log.php" ); ?> \ No newline at end of file Property changes on: poc/src/AllInclude.inc ___________________________________________________________________ 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-15 12:34:55
|
Revision: 27 Author: nmarkgraf Date: 2006-03-15 04:34:45 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=27&view=rev Log Message: ----------- Forgot this very useful file. - Sorry folks... Added Paths: ----------- poc/src/AllInclude.inc Added: poc/src/AllInclude.inc =================================================================== --- poc/src/AllInclude.inc (rev 0) +++ poc/src/AllInclude.inc 2006-03-15 12:34:45 UTC (rev 27) @@ -0,0 +1,18 @@ +<?php + +require_once( "OpenDocument.php" ); +require_once( "OpenDocumentAbstract.php" ); +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( "content/Body.php" ); +require_once( "content/BodyText.php" ); +require_once( "content/BodyTable.php" ); +require_once( "styles/FontFaceDeclaration.php" ); +require_once( "ZipFile.php" ); +require_once( "Log.php" ); +?> \ 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-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-14 13:58:22
|
Revision: 25 Author: nmarkgraf Date: 2006-03-14 05:57:51 -0800 (Tue, 14 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=25&view=rev Log Message: ----------- Lots of changes today. I mostly disable __autoload again, because it does not work for me. We can put the part in the distribution if we find a solution that works under any condition. - Added .htaccess to samples directory for better Apache support. - New /etc/* stuff for the current SVN release of PHing. - New build.xml to avoid some things that confuses PHIng and Code Coverage Reports. Modified Paths: -------------- poc/build.xml poc/etc/coverage-frames.xsl poc/etc/log.xsl poc/etc/phpunit2-frames.xsl poc/etc/phpunit2-noframes.xsl poc/etc/str.replace.function.xsl poc/src/OpenDocumentContent.php poc/src/OpenDocumentFactory.php poc/src/OpenDocumentObjectAbstract.php poc/src/content/Body.php poc/src/content/BodyTable.php poc/src/content/BodyText.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php poc/src/styles/FontFaceDeclaration.php Added Paths: ----------- poc/src/samples/.htaccess Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-13 15:13:43 UTC (rev 24) +++ poc/build.xml 2006-03-14 13:57:51 UTC (rev 25) @@ -17,8 +17,14 @@ <mkdir dir="reports/coverage"/> <mkdir dir="reports/tests"/> </target> + + <target name="preparereport"> + <mkdir dir="reports"/> + <mkdir dir="reports/coverage"/> + <mkdir dir="reports/tests"/> + </target> - <target name="reports"> + <target name="reports" depends="preparereport"> <coverage-setup database="reports/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> @@ -27,8 +33,7 @@ </fileset> </coverage-setup> - <phpunit2 codecoverage="true" haltonerror="false" haltonfailure="false" printsummary="true"> - <!-- phpunit2 --> + <phpunit2 codecoverage="true" haltonerror="false" haltonfailure="false" printsummary="false"> <formatter type="xml" todir="reports"/> <batchtest> <fileset dir="src"> @@ -39,11 +44,9 @@ <phpunit2report infile="reports/testsuites.xml" format="frames" todir="reports/tests" styledir="etc"/> - <!-- --> <coverage-report outfile="reports/coverage.xml"> <report todir="reports/coverage" styledir="etc"/> </coverage-report> - <!-- --> </target> <target name="test" depends="preparetest"> @@ -72,16 +75,32 @@ </target> <target name="dev-dist" depends="preparedist"> - <zip destfile="dist/OpenDocumentPHPdev.zip" basedir="."/> - <tar destfile="dist/OpenDocumentPHPdev.tar" basedir="."/> + <zip destfile="dist/OpenDocumentPHPdev.zip" basedir="."> + <fileset dir="."> + <include name="**/**"/> + <exclude name="**/?svn/**"/> + </fileset> + </zip> + <tar destfile="dist/OpenDocumentPHPdev.tar" basedir="."> + <fileset dir="."> + <include name="**/**"/> + <exclude name="**/?svn/**"/> + </fileset> + </tar> </target> <target name="build" depends="prepare,test,reports,docs,dist"> </target> + <target name="build-all" depends="prepare,test,reports,docs,dist,dev-dist"> + </target> + + <target name="clean"> <delete file="reports/coverage.db"/> <delete file="reports/testsuites.xml"/> + <delete dir="reports/tests"/> + <delete dir="reports/coverage"/> <delete dir="docs"/> <delete file="OpenDocumentPHP.zip"/> <delete file="OpenDocumentPHP.tar"/> Modified: poc/etc/coverage-frames.xsl =================================================================== --- poc/etc/coverage-frames.xsl 2006-03-13 15:13:43 UTC (rev 24) +++ poc/etc/coverage-frames.xsl 2006-03-14 13:57:51 UTC (rev 25) @@ -1,636 +1,666 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" - xmlns:exsl="http://exslt.org/common" - xmlns:date="http://exslt.org/dates-and-times" - extension-element-prefixes="exsl date"> -<xsl:output method="html" indent="yes"/> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> -<!-- - Copyright 2001-2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> - -<!-- - - Sample stylesheet to be used with Xdebug/Phing code coverage output. - Based on JProbe stylesheets from Apache Ant. - - It creates a set of HTML files a la javadoc where you can browse easily - through all packages and classes. - - @author Michiel Rook <a href="mailto:mi...@tr..."/> - @author Stephane Bailliez <a href="mailto:sba...@ap..."/> - ---> - -<!-- default output directory is current directory --> -<xsl:param name="output.dir" select="'.'"/> - -<!-- ====================================================================== - Root element - ======================================================================= --> -<xsl:template match="/snapshot"> - <!-- create the index.html --> - <exsl:document href="efile://{$output.dir}/index.html"> - <xsl:call-template name="index.html"/> - </exsl:document> - - <!-- create the stylesheet.css --> - <exsl:document href="efile://{$output.dir}/stylesheet.css"> - <xsl:call-template name="stylesheet.css"/> - </exsl:document> - - <!-- create the overview-packages.html at the root --> - <exsl:document href="efile://{$output.dir}/overview-summary.html"> - <xsl:apply-templates select="." mode="overview.packages"/> - </exsl:document> - - <!-- create the all-packages.html at the root --> - <exsl:document href="efile://{$output.dir}/overview-frame.html"> - <xsl:apply-templates select="." mode="all.packages"/> - </exsl:document> - - <!-- create the all-classes.html at the root --> - <exsl:document href="efile://{$output.dir}/allclasses-frame.html"> - <xsl:apply-templates select="." mode="all.classes"/> - </exsl:document> - - <!-- process all packages --> - <xsl:apply-templates select="./package" mode="write"/> -</xsl:template> - -<!-- ======================================================================= - Frameset definition. Entry point for the report. - 3 frames: packageListFrame, classListFrame, classFrame - ======================================================================= --> -<xsl:template name="index.html"> -<html> - <head><title>Coverage Results.</title></head> - <frameset cols="20%,80%"> - <frameset rows="30%,70%"> - <frame src="overview-frame.html" name="packageListFrame"/> - <frame src="allclasses-frame.html" name="classListFrame"/> - </frameset> - <frame src="overview-summary.html" name="classFrame"/> - </frameset> - <noframes> - <h2>Frame Alert</h2> - <p> - This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. - </p> - </noframes> -</html> -</xsl:template> - -<!-- ======================================================================= - Stylesheet CSS used - ======================================================================= --> -<!-- this is the stylesheet css to use for nearly everything --> -<xsl:template name="stylesheet.css"> - .bannercell { - border: 0px; - padding: 0px; - } - body { - margin-left: 10; - margin-right: 10; - background-color:#FFFFFF; - font-family: verdana,arial,sanserif; - color:#000000; - } - a { - color: #003399; - } - a:hover { - color: #888888; - } - .a td { - background: #efefef; - } - .b td { - background: #fff; - } - th, td { - text-align: left; - vertical-align: top; - } - th { - font-weight:bold; - background: #ccc; - color: black; - } - table, th, td { - font-size: 12px; - border: none - } - table.log tr td, tr th { - } - h2 { - font-weight:bold; - font-size: 12px; - margin-bottom: 5; - } - h3 { - font-size:100%; - font-weight: 12px; - background: #DFDFDF - color: white; - text-decoration: none; - padding: 5px; - margin-right: 2px; - margin-left: 2px; - margin-bottom: 0; - } - .small { - font-size: 9px; - } -TD.empty { - FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; - color: #c0c0c0; -} -TD.fullcover { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; - color: #00df00; -} -TD.covered { - FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; - color: #00df00; -} -TD.uncovered { - FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; - color: #df0000; -} -PRE.srcLine { - BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; -} -td.lineCount, td.coverageCount { - BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.lineCountHighlight { - background: #C8C8F0; PADDING-RIGHT: 3px; - text-align: right; -} -td.coverageCountHighlight { - background: #F0C8C8; PADDING-RIGHT: 3px; - text-align: right; -} -span.srcLineHighlight { - background: #F0C8C8; -} -span.srcLine { - background: #C8C8F0; -} -TD.srcLineClassStart { - WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; -} -.srcLine , .srcLine ol, .srcLine ol li {margin: 0;} -.srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} -.srcLine .imp {font-weight: bold; color: red;} -.srcLine .kw1 {color: #b1b100;} -.srcLine .kw2 {color: #000000; font-weight: bold;} -.srcLine .kw3 {color: #000066;} -.srcLine .co1 {color: #808080; font-style: italic;} -.srcLine .co2 {color: #808080; font-style: italic;} -.srcLine .coMULTI {color: #808080; font-style: italic;} -.srcLine .es0 {color: #000099; font-weight: bold;} -.srcLine .br0 {color: #66cc66;} -.srcLine .st0 {color: #ff0000;} -.srcLine .nu0 {color: #cc66cc;} -.srcLine .me1 {color: #006600;} -.srcLine .me2 {color: #006600;} -.srcLine .re0 {color: #0000ff;} -</xsl:template> - -<!-- ======================================================================= - List of all classes in all packages - This will be the first page in the classListFrame - ======================================================================= --> -<xsl:template match="snapshot" mode="all.classes"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body> - <h2>All Classes</h2> - <table width="100%"> - <xsl:for-each select="package/class"> - <xsl:sort select="@name"/> - <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> - <xsl:variable name="link"> - <xsl:if test="not($package.name='')"> - <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text> - </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text> - </xsl:variable> - <tr> - <td nowrap="nowrap"> - <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <i> (-)</i> - </xsl:when> - <xsl:otherwise> - <i> (<xsl:value-of select="format-number(@methodscovered div @methodcount, '0.0%')"/>)</i> - </xsl:otherwise> - </xsl:choose> - </td> - </tr> - </xsl:for-each> - </table> - </body> - </html> -</xsl:template> - -<!-- list of all packages --> -<xsl:template match="snapshot" mode="all.packages"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body> - <h2><a href="overview-summary.html" target="classFrame">Overview</a></h2> - <h2>All Packages</h2> - <table width="100%"> - <xsl:for-each select="package"> - <xsl:sort select="@name" order="ascending"/> - <tr> - <td nowrap="nowrap"> - <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame"> - <xsl:value-of select="@name"/> - </a> - </td> - </tr> - </xsl:for-each> - </table> - </body> - </html> -</xsl:template> - -<!-- overview of statistics in packages --> -<xsl:template match="snapshot" mode="overview.packages"> - <html> - <head> - <xsl:call-template name="create.stylesheet.link"/> - </head> - <body onload="open('allclasses-frame.html','classListFrame')"> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr class="a"> - <td class="small">Packages: <xsl:value-of select="count(package)"/></td> - <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> - </tr> - </table> - <br/> - - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%" nowrap="nowrap"></th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <tr class="a"> - <td>Total coverage</td> - <xsl:call-template name="stats.formatted"/> - </tr> - <tr> - <td colspan="3"><br/></td> - </tr> - <tr> - <th width="100%">Packages</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <!-- display packages and sort them via their coverage rate --> - <xsl:for-each select="package"> - <xsl:sort data-type="number" select="@methodscovered div @methodcount"/> - <tr> - <xsl:call-template name="alternate-row"/> - <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td> - <xsl:call-template name="stats.formatted"/> - </tr> - </xsl:for-each> - </table> - <xsl:call-template name="pageFooter"/> - </body> - </html> -</xsl:template> - -<!-- - detailed info for a package. It will output the list of classes -, the summary page, and the info for each class ---> -<xsl:template match="package" mode="write"> - <xsl:variable name="package.dir"> - <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if> - <xsl:if test="@name = ''">.</xsl:if> - </xsl:variable> - - <!-- create a classes-list.html in the package directory --> - <exsl:document href="efile://{$output.dir}/{$package.dir}/package-frame.html"> - <xsl:apply-templates select="." mode="classes.list"/> - </exsl:document> - - <!-- create a package-summary.html in the package directory --> - <exsl:document href="efile://{$output.dir}/{$package.dir}/package-summary.html"> - <xsl:apply-templates select="." mode="package.summary"/> - </exsl:document> - - <!-- for each class, creates a @name.html --> - <xsl:for-each select="class"> - <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}.html"> - <xsl:apply-templates select="." mode="class.details"/> - </exsl:document> - </xsl:for-each> -</xsl:template> - -<!-- list of classes in a package --> -<xsl:template match="package" mode="classes.list"> - <html> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="@name"/> - </xsl:call-template> - </HEAD> - <BODY> - <table width="100%"> - <tr> - <td nowrap="nowrap"> - <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2> - </td> - </tr> - </table> - - <H2>Classes</H2> - <TABLE WIDTH="100%"> - <xsl:for-each select="class"> - <xsl:sort select="@name"/> - <tr> - <td nowrap="nowrap"> - <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <i> (-)</i> - </xsl:when> - <xsl:otherwise> - <i>(<xsl:value-of select="format-number(@methodscovered div @methodcount, '0.0%')"/>)</i> - </xsl:otherwise> - </xsl:choose> - </td> - </tr> - </xsl:for-each> - </TABLE> - </BODY> - </html> -</xsl:template> - -<!-- summary of a package --> -<xsl:template match="package" mode="package.summary"> - <HTML> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="@name"/> - </xsl:call-template> - </HEAD> - <!-- when loading this package, it will open the classes into the frame --> - <BODY onload="open('package-frame.html','classListFrame')"> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr class="a"> - <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> - </tr> - </table> - <br/> - - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%">Package</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <xsl:apply-templates select="." mode="stats"/> - - <xsl:if test="count(class) > 0"> - <tr> - <td colspan="3"><br/></td> - </tr> - <tr> - <th width="100%">Classes</th> - <th width="350" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <xsl:apply-templates select="class" mode="stats"> - <xsl:sort data-type="number" select="@methodscovered div @methodcount"/> - </xsl:apply-templates> - </xsl:if> - </table> - <xsl:call-template name="pageFooter"/> - </BODY> - </HTML> -</xsl:template> - -<!-- details of a class --> -<xsl:template match="class" mode="class.details"> - <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> - <HTML> - <HEAD> - <xsl:call-template name="create.stylesheet.link"> - <xsl:with-param name="package.name" select="$package.name"/> - </xsl:call-template> - </HEAD> - <BODY> - <xsl:call-template name="pageHeader"/> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <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> - </tr> - </table> - <br/> - - <!-- class summary --> - <table class="log" cellpadding="5" cellspacing="0" width="100%"> - <tr> - <th width="100%">Source file</th> - <th width="250" colspan="2" nowrap="nowrap">Methods covered</th> - </tr> - <tr> - <xsl:call-template name="alternate-row"/> - <td><xsl:value-of select="sourcefile/@name"/></td> - <xsl:call-template name="stats.formatted"/> - </tr> - </table> - <table cellspacing="0" cellpadding="0" width="100%"> - <xsl:apply-templates select="sourcefile/sourceline"/> - </table> - <br/> - <xsl:call-template name="pageFooter"/> - </BODY> - </HTML> - -</xsl:template> - -<!-- Page Header --> -<xsl:template name="pageHeader"> - <!-- jakarta logo --> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> - <tr> - <td class="bannercell" rowspan="2"> - <a href="http://phing.info/"> - <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> - </a> - </td> - <td style="text-align:right"><h2>Source Code Coverage</h2></td> - </tr> - <tr> - <td style="text-align:right">Designed for use with <a href='http://pear.php.net/package/PHPUnit2'>PHPUnit2</a>, <a href='http://www.xdebug.org/'>Xdebug</a> and <a href='http://phing.info/'>Phing</a>.</td> - </tr> - </table> - <hr size="1"/> -</xsl:template> - -<!-- Page Footer --> -<xsl:template name="pageFooter"> - <table width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - <tr><td class="small">Report generated at <xsl:value-of select="date:date-time()"/></td></tr> - </table> -</xsl:template> - -<xsl:template match="package" mode="stats"> - <tr> - <xsl:call-template name="alternate-row"/> - <td><xsl:value-of select="@name"/></td> - <xsl:call-template name="stats.formatted"/> - </tr> -</xsl:template> - -<xsl:template match="class" mode="stats"> - <tr> - <xsl:call-template name="alternate-row"/> - <td><a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a></td> - <xsl:call-template name="stats.formatted"/> - </tr> -</xsl:template> - -<xsl:template name="stats.formatted"> - <xsl:choose> - <xsl:when test="@methodcount=0"> - <td>-</td> - <td> - <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> - <tr> - <td class="empty" width="200" height="12"> </td> - </tr> - </table> - </td> - </xsl:when> - <xsl:otherwise> - <td> - <xsl:value-of select="format-number(@methodscovered div @methodcount,'0.0%')"/> - </td> - <td> - <xsl:variable name="leftwidth"><xsl:value-of select="format-number((@methodscovered * 200) div @methodcount,'0')"/></xsl:variable> - <xsl:variable name="rightwidth"><xsl:value-of select="format-number(200 - (@methodscovered * 200) div @methodcount,'0')"/></xsl:variable> - <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> - <tr> - <xsl:choose> - <xsl:when test="$leftwidth=200"> - <td class="fullcover" width="200" height="12"> </td> - </xsl:when> - <xsl:otherwise> - <xsl:if test="not($leftwidth=0)"> - <td class="covered" width="{$leftwidth}" height="12"> </td> - </xsl:if> - <xsl:if test="not($rightwidth=0)"> - <td class="uncovered" width="{$rightwidth}" height="12"> </td> - </xsl:if> - </xsl:otherwise> - </xsl:choose> - </tr> - </table> - </td> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - -<xsl:template match="sourceline"> - <tr> - <xsl:if test="@coveredcount>0"> - <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> - <td class="lineCountHighlight"><xsl:value-of select="@coveredcount"/></td> - </xsl:if> - <xsl:if test="@coveredcount<0"> - <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> - <td class="coverageCountHighlight">0</td> - </xsl:if> - <xsl:if test="@coveredcount=0"> - <td class="lineCount"><xsl:value-of select="position()"/></td> - <td class="coverageCount"></td> - </xsl:if> - <td> - <xsl:if test="@startclass=1"> - <xsl:attribute name="class">srcLineClassStart</xsl:attribute> - </xsl:if> - <xsl:if test="@coveredcount>0"> - <span class="srcLine"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </span> - </xsl:if> - <xsl:if test="@coveredcount<0"> - <span class="srcLineHighlight"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </span> - </xsl:if> - <xsl:if test="@coveredcount=0"> - <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> - </xsl:if> - </td> - </tr> -</xsl:template> - -<!-- - transform string like a.b.c to ../../../ - @param path the path to transform into a descending directory path ---> -<xsl:template name="path"> - <xsl:param name="path"/> - <xsl:if test="contains($path,'.')"> - <xsl:text>../</xsl:text> - <xsl:call-template name="path"> - <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> - </xsl:call-template> - </xsl:if> - <xsl:if test="not(contains($path,'.')) and not($path = '')"> - <xsl:text>../</xsl:text> - </xsl:if> -</xsl:template> - - -<!-- create the link to the stylesheet based on the package name --> -<xsl:template name="create.stylesheet.link"> - <xsl:param name="package.name"/> - <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK> -</xsl:template> - -<!-- alternated row style --> -<xsl:template name="alternate-row"> -<xsl:attribute name="class"> - <xsl:if test="position() mod 2 = 1">a</xsl:if> - <xsl:if test="position() mod 2 = 0">b</xsl:if> -</xsl:attribute> -</xsl:template> - -</xsl:stylesheet> - - +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" + xmlns:exsl="http://exslt.org/common" + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="exsl date"> +<xsl:output method="html" indent="yes"/> +<xsl:decimal-format decimal-separator="." grouping-separator="," /> +<!-- + Copyright 2001-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!-- + + Sample stylesheet to be used with Xdebug/Phing code coverage output. + Based on JProbe stylesheets from Apache Ant. + + It creates a set of HTML files a la javadoc where you can browse easily + through all packages and classes. + + @author Michiel Rook <a href="mailto:mi...@tr..."/> + @author Stephane Bailliez <a href="mailto:sba...@ap..."/> + +--> + +<!-- default output directory is current directory --> +<xsl:param name="output.dir" select="'.'"/> + +<!-- ====================================================================== + Root element + ======================================================================= --> +<xsl:template match="/snapshot"> + <!-- create the index.html --> + <exsl:document href="efile://{$output.dir}/index.html"> + <xsl:call-template name="index.html"/> + </exsl:document> + + <!-- create the stylesheet.css --> + <exsl:document href="efile://{$output.dir}/stylesheet.css"> + <xsl:call-template name="stylesheet.css"/> + </exsl:document> + + <!-- create the overview-packages.html at the root --> + <exsl:document href="efile://{$output.dir}/overview-summary.html"> + <xsl:apply-templates select="." mode="overview.packages"/> + </exsl:document> + + <!-- create the all-packages.html at the root --> + <exsl:document href="efile://{$output.dir}/overview-frame.html"> + <xsl:apply-templates select="." mode="all.packages"/> + </exsl:document> + + <!-- create the all-classes.html at the root --> + <exsl:document href="efile://{$output.dir}/allclasses-frame.html"> + <xsl:apply-templates select="." mode="all.classes"/> + </exsl:document> + + <!-- process all packages --> + <xsl:apply-templates select="./package" mode="write"/> +</xsl:template> + +<!-- ======================================================================= + Frameset definition. Entry point for the report. + 3 frames: packageListFrame, classListFrame, classFrame + ======================================================================= --> +<xsl:template name="index.html"> +<html> + <head><title>Coverage Results.</title></head> + <frameset cols="20%,80%"> + <frameset rows="30%,70%"> + <frame src="overview-frame.html" name="packageListFrame"/> + <frame src="allclasses-frame.html" name="classListFrame"/> + </frameset> + <frame src="overview-summary.html" name="classFrame"/> + </frameset> + <noframes> + <h2>Frame Alert</h2> + <p> + This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. + </p> + </noframes> +</html> +</xsl:template> + +<!-- ======================================================================= + Stylesheet CSS used + ======================================================================= --> +<!-- this is the stylesheet css to use for nearly everything --> +<xsl:template name="stylesheet.css"> + .bannercell { + border: 0px; + padding: 0px; + } + body { + margin-left: 10; + margin-right: 10; + background-color:#FFFFFF; + font-family: verdana,arial,sanserif; + color:#000000; + } + a { + color: #003399; + } + a:hover { + color: #888888; + } + .a td { + background: #efefef; + } + .b td { + background: #fff; + } + th, td { + text-align: left; + vertical-align: top; + } + th { + font-weight:bold; + background: #ccc; + color: black; + } + table, th, td { + font-size: 12px; + border: none + } + table.log tr td, tr th { + } + h2 { + font-weight:bold; + font-size: 12px; + margin-bottom: 5; + } + h3 { + font-size:100%; + font-weight: 12px; + background: #DFDFDF + color: white; + text-decoration: none; + padding: 5px; + margin-right: 2px; + margin-left: 2px; + margin-bottom: 0; + } + .small { + font-size: 9px; + } +TD.empty { + FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; + color: #c0c0c0; +} +TD.fullcover { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; + color: #00df00; +} +TD.covered { + FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER-LEFT:#9c9c9c 1px solid;BORDER-TOP:#9c9c9c 1px solid;BORDER-BOTTOM:#9c9c9c 1px solid; + color: #00df00; +} +TD.uncovered { + FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER:#9c9c9c 1px solid; + color: #df0000; +} +PRE.srcLine { + BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; +} +td.lineCount, td.coverageCount { + BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; + text-align: right; +} +td.lineCountHighlight { + background: #C8C8F0; PADDING-RIGHT: 3px; + text-align: right; +} +td.coverageCountHighlight { + background: #F0C8C8; PADDING-RIGHT: 3px; + text-align: right; +} +span.srcLineHighlight { + background: #F0C8C8; +} +span.srcLine { + background: #C8C8F0; +} +TD.srcLineClassStart { + WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; +} +.srcLine , .srcLine ol, .srcLine ol li {margin: 0;} +.srcLine .de1, .srcLine .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal;} +.srcLine .imp {font-weight: bold; color: red;} +.srcLine .kw1 {color: #b1b100;} +.srcLine .kw2 {color: #000000; font-weight: bold;} +.srcLine .kw3 {color: #000066;} +.srcLine .co1 {color: #808080; font-style: italic;} +.srcLine .co2 {color: #808080; font-style: italic;} +.srcLine .coMULTI {color: #808080; font-style: italic;} +.srcLine .es0 {color: #000099; font-weight: bold;} +.srcLine .br0 {color: #66cc66;} +.srcLine .st0 {color: #ff0000;} +.srcLine .nu0 {color: #cc66cc;} +.srcLine .me1 {color: #006600;} +.srcLine .me2 {color: #006600;} +.srcLine .re0 {color: #0000ff;} +</xsl:template> + +<!-- ======================================================================= + List of all classes in all packages + This will be the first page in the classListFrame + ======================================================================= --> +<xsl:template match="snapshot" mode="all.classes"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body> + <h2>All Classes</h2> + <table width="100%"> + <xsl:for-each select="package/class"> + <xsl:sort select="@name"/> + <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> + <xsl:variable name="link"> + <xsl:if test="not($package.name='')"> + <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text> + </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text> + </xsl:variable> + <tr> + <td nowrap="nowrap"> + <a target="classFrame" href="{$link}"><xsl:value-of select="@name"/></a> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <i> (-)</i> + </xsl:when> + <xsl:otherwise> + <i> (<xsl:value-of select="format-number(@totalcovered div @totalcount, '0.0%')"/>)</i> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + </xsl:for-each> + </table> + </body> + </html> +</xsl:template> + +<!-- list of all packages --> +<xsl:template match="snapshot" mode="all.packages"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body> + <h2><a href="overview-summary.html" target="classFrame">Overview</a></h2> + <h2>All Packages</h2> + <table width="100%"> + <xsl:for-each select="package"> + <xsl:sort select="@name" order="ascending"/> + <tr> + <td nowrap="nowrap"> + <a href="{translate(@name,'.','/')}/package-summary.html" target="classFrame"> + <xsl:value-of select="@name"/> + </a> + </td> + </tr> + </xsl:for-each> + </table> + </body> + </html> +</xsl:template> + +<!-- overview of statistics in packages --> +<xsl:template match="snapshot" mode="overview.packages"> + <html> + <head> + <xsl:call-template name="create.stylesheet.link"/> + </head> + <body onload="open('allclasses-frame.html','classListFrame')"> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr class="a"> + <td class="small">Packages: <xsl:value-of select="count(package)"/></td> + <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> + </tr> + </table> + <br/> + + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%" nowrap="nowrap"></th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <tr class="a"> + <td><b>Project</b></td> + <xsl:call-template name="stats.formatted"/> + </tr> + <tr> + <td colspan="3"><br/></td> + </tr> + <tr> + <th width="100%">Packages</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <!-- display packages and sort them via their coverage rate --> + <xsl:for-each select="package"> + <xsl:sort data-type="number" select="@totalcovered div @totalcount"/> + <tr> + <xsl:call-template name="alternate-row"/> + <td><a href="{translate(@name,'.','/')}/package-summary.html"><xsl:value-of select="@name"/></a></td> + <xsl:call-template name="stats.formatted"/> + </tr> + </xsl:for-each> + </table> + <xsl:call-template name="pageFooter"/> + </body> + </html> +</xsl:template> + +<!-- + detailed info for a package. It will output the list of classes +, the summary page, and the info for each class +--> +<xsl:template match="package" mode="write"> + <xsl:variable name="package.dir"> + <xsl:if test="not(@name = '')"><xsl:value-of select="translate(@name,'.','/')"/></xsl:if> + <xsl:if test="@name = ''">.</xsl:if> + </xsl:variable> + + <!-- create a classes-list.html in the package directory --> + <exsl:document href="efile://{$output.dir}/{$package.dir}/package-frame.html"> + <xsl:apply-templates select="." mode="classes.list"/> + </exsl:document> + + <!-- create a package-summary.html in the package directory --> + <exsl:document href="efile://{$output.dir}/{$package.dir}/package-summary.html"> + <xsl:apply-templates select="." mode="package.summary"/> + </exsl:document> + + <!-- for each class, creates a @name.html --> + <xsl:for-each select="class"> + <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}.html"> + <xsl:apply-templates select="." mode="class.details"/> + </exsl:document> + </xsl:for-each> +</xsl:template> + +<!-- list of classes in a package --> +<xsl:template match="package" mode="classes.list"> + <html> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="@name"/> + </xsl:call-template> + </HEAD> + <BODY> + <table width="100%"> + <tr> + <td nowrap="nowrap"> + <H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="@name"/></a></H2> + </td> + </tr> + </table> + + <H2>Classes</H2> + <TABLE WIDTH="100%"> + <xsl:for-each select="class"> + <xsl:sort select="@name"/> + <tr> + <td nowrap="nowrap"> + <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <i> (-)</i> + </xsl:when> + <xsl:otherwise> + <i>(<xsl:value-of select="format-number(@totalcovered div @totalcount, '0.0%')"/>)</i> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> + </xsl:for-each> + </TABLE> + </BODY> + </html> +</xsl:template> + +<!-- summary of a package --> +<xsl:template match="package" mode="package.summary"> + <HTML> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="@name"/> + </xsl:call-template> + </HEAD> + <!-- when loading this package, it will open the classes into the frame --> + <BODY onload="open('package-frame.html','classListFrame')"> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr class="a"> + <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> + </tr> + </table> + <br/> + + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%">Package</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <xsl:apply-templates select="." mode="stats"/> + + <xsl:if test="count(class) > 0"> + <tr> + <td colspan="3"><br/></td> + </tr> + <tr> + <th width="100%">Classes</th> + <th>Statements</th> + <th>Methods</th> + <th width="350" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <xsl:apply-templates select="class" mode="stats"> + <xsl:sort data-type="number" select="@totalcovered div @totalcount"/> + </xsl:apply-templates> + </xsl:if> + </table> + <xsl:call-template name="pageFooter"/> + </BODY> + </HTML> +</xsl:template> + +<!-- details of a class --> +<xsl:template match="class" mode="class.details"> + <xsl:variable name="package.name" select="(ancestor::package)[last()]/@name"/> + <HTML> + <HEAD> + <xsl:call-template name="create.stylesheet.link"> + <xsl:with-param name="package.name" select="$package.name"/> + </xsl:call-template> + </HEAD> + <BODY> + <xsl:call-template name="pageHeader"/> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <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> + </tr> + </table> + <br/> + + <!-- class summary --> + <table class="log" cellpadding="5" cellspacing="0" width="100%"> + <tr> + <th width="100%">Source file</th> + <th>Statements</th> + <th>Methods</th> + <th width="250" colspan="2" nowrap="nowrap">Total coverage</th> + </tr> + <tr> + <xsl:call-template name="alternate-row"/> + <td><xsl:value-of select="sourcefile/@name"/></td> + <xsl:call-template name="stats.formatted"/> + </tr> + </table> + <table cellspacing="0" cellpadding="0" width="100%"> + <xsl:apply-templates select="sourcefile/sourceline"/> + </table> + <br/> + <xsl:call-template name="pageFooter"/> + </BODY> + </HTML> + +</xsl:template> + +<!-- Page Header --> +<xsl:template name="pageHeader"> + <!-- jakarta logo --> + <table border="0" cellpadding="0" cellspacing="0" width="100%"> + <tr> + <td class="bannercell" rowspan="2"> + <a href="http://phing.info/"> + <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> + </a> + </td> + <td style="text-align:right"><h2>Source Code Coverage</h2></td> + </tr> + <tr> + <td style="text-align:right">Designed for use with <a href='http://pear.php.net/package/PHPUnit2'>PHPUnit2</a>, <a href='http://www.xdebug.org/'>Xdebug</a> and <a href='http://phing.info/'>Phing</a>.</td> + </tr> + </table> + <hr size="1"/> +</xsl:template> + +<!-- Page Footer --> +<xsl:template name="pageFooter"> + <table width="100%"> + <tr><td><hr noshade="yes" size="1"/></td></tr> + <tr><td class="small">Report generated at <xsl:value-of select="date:date-time()"/></td></tr> + </table> +</xsl:template> + +<xsl:template match="package" mode="stats"> + <tr> + <xsl:call-template name="alternate-row"/> + <td><xsl:value-of select="@name"/></td> + <xsl:call-template name="stats.formatted"/> + </tr> +</xsl:template> + +<xsl:template match="class" mode="stats"> + <tr> + <xsl:call-template name="alternate-row"/> + <td><a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a></td> + <xsl:call-template name="stats.formatted"/> + </tr> +</xsl:template> + +<xsl:template name="stats.formatted"> + <xsl:choose> + <xsl:when test="@statementcount=0"> + <td>-</td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@statementscovered div @statementcount,'0.0%')"/> + </td> + </xsl:otherwise> + </xsl:choose> + <xsl:choose> + <xsl:when test="@methodcount=0"> + <td>-</td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@methodscovered div @methodcount,'0.0%')"/> + </td> + </xsl:otherwise> + </xsl:choose> + <xsl:choose> + <xsl:when test="@totalcount=0"> + <td>-</td> + <td> + <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> + <tr> + <td class="empty" width="200" height="12"> </td> + </tr> + </table> + </td> + </xsl:when> + <xsl:otherwise> + <td> + <xsl:value-of select="format-number(@totalcovered div @totalcount,'0.0%')"/> + </td> + <td> + <xsl:variable name="leftwidth"><xsl:value-of select="format-number((@totalcovered * 200) div @totalcount,'0')"/></xsl:variable> + <xsl:variable name="rightwidth"><xsl:value-of select="format-number(200 - (@totalcovered * 200) div @totalcount,'0')"/></xsl:variable> + <table cellspacing="0" cellpadding="0" border="0" width="100%" style="display: inline"> + <tr> + <xsl:choose> + <xsl:when test="$leftwidth=200"> + <td class="fullcover" width="200" height="12"> </td> + </xsl:when> + <xsl:otherwise> + <xsl:if test="not($leftwidth=0)"> + <td class="covered" width="{$leftwidth}" height="12"> </td> + </xsl:if> + <xsl:if test="not($rightwidth=0)"> + <td class="uncovered" width="{$rightwidth}" height="12"> </td> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </tr> + </table> + </td> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="sourceline"> + <tr> + <xsl:if test="@coveredcount>0"> + <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> + <td class="lineCountHighlight"><xsl:value-of select="@coveredcount"/></td> + </xsl:if> + <xsl:if test="@coveredcount<0"> + <td class="lineCountHighlight"><xsl:value-of select="position()"/></td> + <td class="coverageCountHighlight">0</td> + </xsl:if> + <xsl:if test="@coveredcount=0"> + <td class="lineCount"><xsl:value-of select="position()"/></td> + <td class="coverageCount"></td> + </xsl:if> + <td> + <xsl:if test="@startclass=1"> + <xsl:attribute name="class">srcLineClassStart</xsl:attribute> + </xsl:if> + <xsl:if test="@coveredcount>0"> + <span class="srcLine"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </span> + </xsl:if> + <xsl:if test="@coveredcount<0"> + <span class="srcLineHighlight"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </span> + </xsl:if> + <xsl:if test="@coveredcount=0"> + <pre class="srcLine"><xsl:value-of select="." disable-output-escaping="yes"/></pre> + </xsl:if> + </td> + </tr> +</xsl:template> + +<!-- + transform string like a.b.c to ../../../ + @param path the path to transform into a descending directory path +--> +<xsl:template name="path"> + <xsl:param name="path"/> + <xsl:if test="contains($path,'.')"> + <xsl:text>../</xsl:text> + <xsl:call-template name="path"> + <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> + </xsl:call-template> + </xsl:if> + <xsl:if test="not(contains($path,'.')) and not($path = '')"> + <xsl:text>../</xsl:text> + </xsl:if> +</xsl:template> + + +<!-- create the link to the stylesheet based on the package name --> +<xsl:template name="create.stylesheet.link"> + <xsl:param name="package.name"/> + <LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK> +</xsl:template> + +<!-- alternated row style --> +<xsl:template name="alternate-row"> +<xsl:attribute name="class"> + <xsl:if test="position() mod 2 = 1">a</xsl:if> + <xsl:if test="position() mod 2 = 0">b</xsl:if> +</xsl:attribute> +</xsl:template> + +</xsl:stylesheet> + + Modified: poc/etc/log.xsl =================================================================== --- poc/etc/log.xsl 2006-03-13 15:13:43 UTC (rev 24) +++ poc/etc/log.xsl 2006-03-14 13:57:51 UTC (rev 25) @@ -1,216 +1,216 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> -<xsl:output method="html" indent="yes" encoding="US-ASCII"/> -<!-- - Copyright 2000-2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> - -<!-- - - The purpose have this XSL is to provide a nice way to look at the output - from the Ant XmlLogger (ie: ant -listener org.apache.tools.ant.XmlLogger ) - - @author <a href="mailto:mi...@tr...>Michiel Rook</a> - @author <a href="mailto:sba...@ap...">Stephane Bailliez</a> - ---> -<xsl:decimal-format decimal-separator="." grouping-separator="," /> - -<xsl:template match="/"> -<html> - <head> - <title>Phing Build Log</title> - <style type="text/css"> - .bannercell { - border: 0px; - padding: 0px; - } - body { - margin: 0; - font:normal 100% arial,helvetica,sanserif; - background-color:#FFFFFF; - color:#000000; - } - table.status { - font:bold 80% arial,helvetica,sanserif; - background-color:#525D76; - color:#ffffff; - } - table.log tr td, tr th { - font-size: 80%; - } - .error { - color:red; - } - .warn { - color:brown; - } - .info { - color:gray; - } - .debug{ - color:gray; - } - .failed { - font-size:80%; - background-color: red; - color:#FFFFFF; - font-weight: bold - } - .complete { - font-size:80%; - background-color: #525D76; - color:#FFFFFF; - font-weight: bold - } - .a td { - background: #efefef; - } - .b td { - background: #fff; - } - th, td { - text-align: left; - vertical-align: top; - } - th { - background: #ccc; - color: black; - } - table, th, td { - border: none - } - h3 { - font:bold 80% arial,helvetica,sanserif; - background: #525D76; - color: white; - text-decoration: none; - padding: 5px; - margin-right: 2px; - margin-left: 2px; - margin-bottom: 0; - } - a { - color: #003399; - } - a:hover { - color: #888888; - } - </style> - </head> - <body> - <!-- jakarta logo --> - <table border="0" cellpadding="0" cellspacing="0" width="100%"> - <tr> - <td valign="top" class="bannercell"> - <a href="http://phing.info/"> - <img src="http://phing.info/images/phing.gif" alt="http://phing.info/" align="left" border="0"/> - </a> - </td> - <td style="text-align:right;vertical-align:bottom"> - <a href="http://phing.info/">Phing</a> - </td> - </tr> - </table> - - <table border="0" width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - </table> - - <xsl:apply-templates select="build"/> - - <!-- FOOTER --> - <table width="100%"> - <tr><td><hr noshade="yes" size="1"/></td></tr> - <tr><td> - <div align="center"><font color="#525D76" size="-1"><em> - <a href="http://phing.info/">Phing</a> - </em></font></div> - </td></tr> - </table> - </body> -</html> -</xsl:template> - -<xsl:template match="build"> - <!-- build status --> - <table width="100%"> - <xsl:attribute name="class"> - <xsl:if test="@error">failed</xsl:if> - <xsl:if test="not(@error)">complete</xsl:if> - </xsl:attribute> - <tr> - <xsl:if test="@error"> - <td nowrap="yes">Build Failed</td> - </xsl:if> - <xsl:if test="not(@error)"> - <td nowrap="yes">Build Complete</td> - </xsl:if> - <td style="text-align:right" nowrap="yes">Total Time: <xsl:value-of select="@time"/></td> - </tr> - <tr> - <td colspan="2"> - <xsl:if test="@error"> - <tt><xsl:value-of select="@error"/></tt><br/> - <i style="font-size:80%">See the <a href="#stacktrace" alt="Click for details">stacktrace</a>.</i> - </xsl:if> - </td> - </tr> - </table> - <table border="1" cellspacing="2" cellpadding="3" width="100%" style="font-size:80%"> - <tr class="a"><td width="1">phing.file</td><td><xsl:value-of select="substring-after(//message[contains(text(),'phing.file')], '->')"/></td></tr> - <tr class="b"><td width="1">phing.version</td><td><xsl:value-of select="substring-after(//message[contains(text(),'phing.version')], '->')"/></td></tr> - </table> - <!-- build information --> - <h3>Build events</h3> - <table class="log" border="1" cellspacing="2" cellpadding="3" width="100%"> - <tr> - <th nowrap="yes" align="left" width="1%">target</th> - <th nowrap="yes" align="left" width="1%">task</th> - <th nowrap="yes" align="left">message</th> - </tr> - <xsl:apply-templates select=".//message[@priority != 'debug']"/> - </table> - <p> - <!-- stacktrace --> - <xsl:if test="stacktrace"> - <a name="stacktrace"/> - <h3>Error details</h3> - <table width="100%"> - <tr><td> - <pre><xsl:value-of select="stacktrace"/></pre> - </td></tr> - </table> - </xsl:if> - </p> -</xsl:template> - -<!-- report every message but those with debug priority --> -<xsl:template match="message[@priority!='debug']"> - <tr valign="top"> - <!-- alternated row style --> - <xsl:attribute name="class"> - <xsl:if test="position() mod 2 = 1">a</xsl:if> - <xsl:if test="position() mod 2 = 0">b</xsl:if> - </xsl:attribute> - <td nowrap="yes" width="1%"><xsl:value-of select="../../@name"/></td> - <td nowrap="yes" style="text-align:right" width="1%">[ <xsl:value-of select="../@name"/> ]</td> - <td class="{@priority}" nowrap="yes"> - <xsl:value-of select="text()"/> - </td> - </tr> -</xsl:template> - -</xsl:stylesheet> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> +<xsl:output method="html" indent="yes" encoding="US-ASCII"/> +<!-- + Copyright 2000-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> + +<!-- + + The purpose have this XSL is to provide a nice way to look at the output + from the An... [truncated message content] |
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-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 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 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 08:59:07
|
Revision: 20 Author: nmarkgraf Date: 2006-03-13 00:58:48 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=20&view=rev Log Message: ----------- Only a few bug fixes: - build.xml was updated to run only on non-samples. - all test needs to be in an new subpackage - minor things in FontFaceDeclaration and OpenDocumentSingle class. :D Norman Modified Paths: -------------- poc/build.xml poc/src/OpenDocumentFactoryTest.php poc/src/OpenDocumentManifestTest.php poc/src/OpenDocumentMeta.php poc/src/OpenDocumentMetaTest.php poc/src/OpenDocumentObjectAbstract.php poc/src/OpenDocumentSingle.php poc/src/styles/FontFaceDeclaration.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-13 08:14:08 UTC (rev 19) +++ poc/build.xml 2006-03-13 08:58:48 UTC (rev 20) @@ -23,6 +23,7 @@ <fileset dir="src"> <include name="**/*.php"/> <exclude name="**/*Test.php"/> + <exclude name="**/samples/*.php"/> </fileset> </coverage-setup> Modified: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -5,7 +5,8 @@ * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentTest + * @package OpenDocument + * @subpackage UnitTest * * $Id$ */ Modified: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentManifestTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -6,7 +6,8 @@ * @lecense GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentUnitTest + * @package OpenDocument + * @subpackage UnitTest * * @since 0.4.0 * Modified: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentMeta.php 2006-03-13 08:58:48 UTC (rev 20) @@ -24,7 +24,7 @@ * * @since 0.3.0 */ - public function __construct( $dom=0, $root=0 ) { + public function __construct( $dom=0, $_root=0 ) { parent::__construct(); $this->logger->debug( "Constructing OpenDocumentMeta." ); @@ -39,11 +39,10 @@ $this->dom->appendChild( $node ); $this->meta = $node; - unset( $node ); } 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" ); } Modified: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentMetaTest.php 2006-03-13 08:58:48 UTC (rev 20) @@ -5,7 +5,8 @@ * @copyright GNU General Public License * @author Norman Markgraf <nma...@us...> * @version $Revision$ - * @package OpenDocumentUnitTest + * @package OpenDocument + * @subpackage UnitTest * * $Id$ */ @@ -21,7 +22,7 @@ /** * namespace Dublin Core */ - const NS_DC = "http://purl.org/dc/elements/1.1"; + const NS_DC = "http://purl.org/dc/elements/1.1/"; public function testConstructWithoutDom(){ $ODM = new OpenDocumentMeta(); @@ -58,8 +59,11 @@ public function testConstructWithDom(){ $testDom = new DOMDocument(); + $node = $testDom->createElementNS( self::NS_OFFICE, "office:meta" ); - $ODM = new OpenDocumentMeta( $testDom ); + $ODM = new OpenDocumentMeta( $testDom, $node ); + $testDom->appendChild( $node ); + $this->assertNotNull( $ODM ); $resultDom = $ODM->get(); Modified: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-13 08:58:48 UTC (rev 20) @@ -86,19 +86,9 @@ 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 Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/OpenDocumentSingle.php 2006-03-13 08:58:48 UTC (rev 20) @@ -18,6 +18,11 @@ private $dom; private $root; + /** + * namespace OpenDocument office + */ + const NS_OFFICE = "urn:oasis:names:tc:opendocument:xmlns:office:1.0"; + /** * * @access public Modified: poc/src/styles/FontFaceDeclaration.php =================================================================== --- poc/src/styles/FontFaceDeclaration.php 2006-03-13 08:14:08 UTC (rev 19) +++ poc/src/styles/FontFaceDeclaration.php 2006-03-13 08:58:48 UTC (rev 20) @@ -82,7 +82,7 @@ * * @since 0.4.2 */ - private function checkStyle( $key, $value ) { + private function checkSVG( $key, $value ) { switch ($key) { default: // ***FIX ME*** should be "false"! return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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 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: <yaw...@us...> - 2006-03-11 18:35:21
|
Revision: 17 Author: yawnster Date: 2006-03-11 10:35:11 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=17&view=rev Log Message: ----------- Woops tiny bug-fix. The single generation is still failing BTW. @ Norman - I tried to rename the samples directory to input as I think that we are beyond samples but I couldn't do it. Everything should be working again now.. Modified Paths: -------------- poc/src/OpenDocumentOutput.php Modified: poc/src/OpenDocumentOutput.php =================================================================== --- poc/src/OpenDocumentOutput.php 2006-03-11 18:20:53 UTC (rev 16) +++ poc/src/OpenDocumentOutput.php 2006-03-11 18:35:11 UTC (rev 17) @@ -16,7 +16,7 @@ require_once( "OpenDocumentFactory.php" ); require_once( "Log/observer.php" ); -require_once( "input/TestTranslate.php" ); +require_once( "samples/TestTranslate.php" ); class OpenDocumentOutput { @@ -58,7 +58,6 @@ $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 ) ); 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: <Yaw...@us...> - 2006-03-11 00:11:59
|
Revision: 15 Author: Yawnster Date: 2006-03-10 16:11:52 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=15&view=rev Log Message: ----------- - Redo the changes Norman overwrote earlier today. - Added in some HTML for a commit tomorrow which will include inputted document content, instead of just a pre-defined string. Modified Paths: -------------- poc/src/samples/TestInput.php poc/src/samples/TestOutput.php Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-10 15:08:52 UTC (rev 14) +++ poc/src/samples/TestInput.php 2006-03-11 00:11:52 UTC (rev 15) @@ -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.2 @@ -22,22 +22,26 @@ <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 /> + <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 /> </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> + <td><input type="text" id="author" 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> + <td><input type="text" id="title" name="Title" size="80" maxsize="180" value="This is a sample OpenDocument file." /></td> </tr> </table> </fieldset> + <fieldset> + <legend>Document Content:</legend> + <textarea rows="10" cols="50" id="content" name="Content"></textarea> + </fieldset> <legend>Try it:</legend> <input type="submit" value="Submit!" /> </fieldset> Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-10 15:08:52 UTC (rev 14) +++ poc/src/samples/TestOutput.php 2006-03-11 00:11:52 UTC (rev 15) @@ -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.2 @@ -26,19 +26,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" ) { 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: <nma...@us...> - 2006-03-10 10:48:32
|
Revision: 13 Author: nmarkgraf Date: 2006-03-10 02:48:24 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=13&view=rev Log Message: ----------- Forgot this one :D Modified Paths: -------------- poc/src/OpenDocumentFactory.php Modified: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php 2006-03-10 10:45:55 UTC (rev 12) +++ poc/src/OpenDocumentFactory.php 2006-03-10 10:48:24 UTC (rev 13) @@ -6,28 +6,30 @@ * @author Norman Markgraf <nma...@us...> * @author Alex Latchford <yaw...@us...> * @version $Revision$ - * @package OpenDocument + * @package OpenDocument.Factory * @since 0.4.0 * * $Id$ */ function __autoload($class_name) { - // Classes in subdirectories have '_' instead of '/' or '\\' in their names. - require_once( strtr ( $class_name, "_", "/" ) . ".php" ); + // 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" ); + } } final class OpenDocumentFactory { /** * Creates a OpenDocument. - * + * @since 0.4.0 * @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 ); } 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: <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-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-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: <yaw...@us...> - 2006-03-08 23:15:33
|
Revision: 8 Author: yawnster Date: 2006-03-08 15:15:08 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=8&view=rev Log Message: ----------- - Restructured class inclusion, it now uses __autoload() to do this automatically. - Now using a single file extension, (.php), this was done to help the __autoload() function, please check your Inbox for documentation on this. - Built in a UI to TestOutput.php to select Document Type - Removed all traces of .php3-5 extensions from the build.xml file. Modified Paths: -------------- poc/build.xml Added 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 poc/src/ZipFile.php Modified: poc/build.xml =================================================================== --- poc/build.xml 2006-03-08 10:31:35 UTC (rev 7) +++ poc/build.xml 2006-03-08 23:15:08 UTC (rev 8) @@ -22,11 +22,7 @@ <coverage-setup database="reports/coverage.db"> <fileset dir="src"> <include name="**/*.php"/> - <include name="**/*.php3"/> - <include name="**/*.php5"/> <exclude name="**/*Test.php"/> - <exclude name="**/*Test.php3"/> - <exclude name="**/*Test.php5"/> </fileset> </coverage-setup> @@ -36,8 +32,6 @@ <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> - <include name="**/*Test.php3"/> - <include name="**/*Test.php5"/> </fileset> </batchtest> </phpunit2> @@ -57,8 +51,6 @@ <batchtest> <fileset dir="src"> <include name="**/*Test.php"/> - <include name="**/*Test.php5"/> - <include name="**/*Test.php3"/> </fileset> </batchtest> </phpunit2> Added: poc/src/OpenDocument.php =================================================================== --- poc/src/OpenDocument.php (rev 0) +++ poc/src/OpenDocument.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,34 @@ +<?php +/** + * OpenDocument interface + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 5 $ + * @package OpenDocument + * + * $Id: OpenDocument.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ +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 Added: poc/src/OpenDocumentAbstract.php =================================================================== --- poc/src/OpenDocumentAbstract.php (rev 0) +++ poc/src/OpenDocumentAbstract.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,77 @@ +<?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: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentContent.php =================================================================== --- poc/src/OpenDocumentContent.php (rev 0) +++ poc/src/OpenDocumentContent.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,128 @@ +<?php +/** + * OpenDocumentContent Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentContent.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentContentBody.php =================================================================== --- poc/src/OpenDocumentContentBody.php (rev 0) +++ poc/src/OpenDocumentContentBody.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,76 @@ +<?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 $ + */ + +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 Added: poc/src/OpenDocumentContentBodyText.php =================================================================== --- poc/src/OpenDocumentContentBodyText.php (rev 0) +++ poc/src/OpenDocumentContentBodyText.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,78 @@ +<?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 Added: poc/src/OpenDocumentFactory.php =================================================================== --- poc/src/OpenDocumentFactory.php (rev 0) +++ poc/src/OpenDocumentFactory.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,38 @@ +<?php +/** + * OpenDocumentFactoy Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 7 $ + * @package OpenDocument + * + * $Id: OpenDocumentFactory.php5 7 2006-03-08 10:31:35Z nmarkgraf $ + */ + +function __autoload($class_name) { + if($class_name != 'Log_null') + { + require_once("$class_name.php"); + } +} + +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 Added: poc/src/OpenDocumentFactoryTest.php =================================================================== --- poc/src/OpenDocumentFactoryTest.php (rev 0) +++ poc/src/OpenDocumentFactoryTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,78 @@ +<?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.php" ); +require_once( "OpenDocumentSingle.php" ); +require_once( "OpenDocumentPackage.php" ); + +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 Added: poc/src/OpenDocumentManifest.php =================================================================== --- poc/src/OpenDocumentManifest.php (rev 0) +++ poc/src/OpenDocumentManifest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,125 @@ +<?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: 5 $ + * @package OpenDocument + * + * $Id: OpenDocumentManifest.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentManifestTest.php =================================================================== --- poc/src/OpenDocumentManifestTest.php (rev 0) +++ poc/src/OpenDocumentManifestTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,31 @@ +<?php +/** + * Test Class for OpenDocumentManifest + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocumentUnitTest + * + * $Id: OpenDocumentManifestTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ +require_once "PHPUnit2/Framework/TestCase.php"; +require_once "OpenDocumentManifest.php"; + +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 Added: poc/src/OpenDocumentMeta.php =================================================================== --- poc/src/OpenDocumentMeta.php (rev 0) +++ poc/src/OpenDocumentMeta.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,220 @@ +<?php +/** + * OpenDocumentMeta Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocument + * + * $Id: OpenDocumentMeta.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentMetaTest.php =================================================================== --- poc/src/OpenDocumentMetaTest.php (rev 0) +++ poc/src/OpenDocumentMetaTest.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,129 @@ +<?php +/** + * Test class for OpenDocumentMeta + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 3 $ + * @package OpenDocumentUnitTest + * + * $Id: OpenDocumentMetaTest.php5 3 2006-03-04 20:33:26Z nmarkgraf $ + */ +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"; + + 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 Added: poc/src/OpenDocumentObjectAbstract.php =================================================================== --- poc/src/OpenDocumentObjectAbstract.php (rev 0) +++ poc/src/OpenDocumentObjectAbstract.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,115 @@ +<?php +/** + * OpenDocumentObjectAbstract Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 6 $ + * @package OpenDocument + * + * $Id: OpenDocumentObjectAbstract.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php (rev 0) +++ poc/src/OpenDocumentPackage.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,233 @@ +<?php +/** + * OpenDocumentPackage Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 5 $ + * @package OpenDocument + * + * $Id: OpenDocumentPackage.php5 5 2006-03-07 08:16:08Z nmarkgraf $ + */ + +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 Added: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php (rev 0) +++ poc/src/OpenDocumentSingle.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,99 @@ +<?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 $ + */ + +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 Added: poc/src/OpenDocumentStyle.php =================================================================== --- poc/src/OpenDocumentStyle.php (rev 0) +++ poc/src/OpenDocumentStyle.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,164 @@ +<?php +/** + * OpenDocumentStyle Class + * + * @copyright GNU General Public License + * @author Norman Markgraf <nma...@us...> + * @version $Revision: 2 $ + * @package OpenDocument + * + * $Id: OpenDocumentStyle.php5 2 2006-02-28 13:10:42Z nmarkgraf $ + */ + +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 Added: poc/src/TestOutput.php =================================================================== --- poc/src/TestOutput.php (rev 0) +++ poc/src/TestOutput.php 2006-03-08 23:15:08 UTC (rev 8) @@ -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...> + * @version $Revision: 6 $ + * @package OpenDocument.Samples + * + * $Id: TestOutput.php5 6 2006-03-08 09:19:19Z nmarkgraf $ + */ + +require_once( "OpenDocumentFactory.php" ); +require_once( "Log/observer.php" ); + +class TestOutput { + + 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($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/ZipFile.php =================================================================== --- poc/src/ZipFile.php (rev 0) +++ poc/src/ZipFile.php 2006-03-08 23:15:08 UTC (rev 8) @@ -0,0 +1,184 @@ +<?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); + + ... [truncated message content] |