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