From: <yaw...@us...> - 2006-03-20 18:05:09
|
Revision: 34 Author: yawnster Date: 2006-03-20 10:04:48 -0800 (Mon, 20 Mar 2006) ViewCVS: http://svn.sourceforge.net/opendocumentphp/?rev=34&view=rev Log Message: ----------- - Added in modular support for Scripts and AutoStyles. - Should output correctly now in both modes. - Started on ZipFile Task, added scope declarations. - Norman.. Its now OOo 2.0.2 :P Modified Paths: -------------- poc/src/OpenDocumentPackage.php poc/src/OpenDocumentSingle.php poc/src/ZipFile.php poc/src/samples/TestInput.php poc/src/samples/TestOutput.php Removed Paths: ------------- poc/src/samples/TestTranslate.php Modified: poc/src/OpenDocumentPackage.php =================================================================== --- poc/src/OpenDocumentPackage.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/OpenDocumentPackage.php 2006-03-20 18:04:48 UTC (rev 34) @@ -46,6 +46,9 @@ $this->logger->debug( "Constructing OpenDocumentPackage." ); + $this->dom = new DOMDocument( "1.0", "utf-8" ); + $this->dom->formatOutput = true; + $this->isCommited = false; $this->logger->debug( "Generating ZipFile object." ); @@ -62,20 +65,18 @@ $this->DocumentObjects[ "meta" ] = new Meta( ); // $this->DocumentObjects[ "settings" ] = new Settings( ); - $content = new Content( ); - $this->DocumentObjects[ "content" ] = $content; + $this->DocumentObjects[ "content" ] = new Content();; - $styles = new Styles( ); - $this->DocumentObjects[ "styles" ] = $styles; + $this->DocumentObjects[ "styles" ] = new Styles(); -// $this->DocumentObjects[ "scripts" ] = new Scripts( $contentDom ); -// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $contentDom ); - $this->DocumentObjects[ "body" ] = $content->getBody(); + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom ); + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom ); + $this->DocumentObjects[ "body" ] = $this->DocumentObjects["content"]->getBody(); - $this->DocumentObjects[ "style" ] = $styles->getStyle(); - $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $content->getFontFaceDecl(), - $styles->getFontFaceDecl() ); + $this->DocumentObjects[ "style" ] = $this->DocumentObjects["styles"]->getStyle(); + $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclSplitter( $this->DocumentObjects["content"]->getFontFaceDecl(), + $this->DocumentObjects["styles"]->getFontFaceDecl() ); // $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStylesSpliter(... ); // $this->DocumentObjects[ "masterstyles" ] = $styles->getMasterStyles(); } Modified: poc/src/OpenDocumentSingle.php =================================================================== --- poc/src/OpenDocumentSingle.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/OpenDocumentSingle.php 2006-03-20 18:04:48 UTC (rev 34) @@ -10,6 +10,7 @@ * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, et al. * @author Norman Markgraf <nma...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @@ -72,10 +73,10 @@ $this->DocumentObjects[ "meta" ] = new Meta( $this->dom, $this->root ); // $this->DocumentObjects[ "settings" ] = new Settings( $this->dom, $this->root ); -// $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); + $this->DocumentObjects[ "scripts" ] = new Scripts( $this->dom, $this->root ); $this->DocumentObjects[ "fontfacedecl" ] = new FontFaceDeclaration( $this->dom, $this->root ); $this->DocumentObjects[ "style" ] = new Style( $this->dom, $this->root ); -// $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); + $this->DocumentObjects[ "automaticstyles" ] = new AutomaticStyles( $this->dom, $this->root ); // $this->DocumentObjects[ "masterstyles" ] = new MasterStyles( $this->dom, $this->root ); $this->DocumentObjects[ "body" ] = new Body( $this->dom, $this->root ); } Modified: poc/src/ZipFile.php =================================================================== --- poc/src/ZipFile.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/ZipFile.php 2006-03-20 18:04:48 UTC (rev 34) @@ -25,28 +25,28 @@ * * @var array $datasec */ - var $datasec = array(); + private $datasec = array(); /** * Central directory * * @var array $ctrl_dir */ - var $ctrl_dir = array(); + private $ctrl_dir = array(); /** * End of central directory record * * @var string $eof_ctrl_dir */ - var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + private $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; /** * Last offset position * * @var integer $old_offset */ - var $old_offset = 0; + private $old_offset = 0; /** @@ -59,7 +59,7 @@ * * @access private */ - function unix2DosTime($unixtime = 0) { + private function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); if ($timearray['year'] < 1980) { @@ -85,7 +85,7 @@ * * @access public */ - function addFile($data, $name, $time = 0) + public function addFile($data, $name, $time = 0) { $name = str_replace('\\', '/', $name); @@ -164,7 +164,7 @@ * * @access public */ - function file() + public function file() { $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir); Modified: poc/src/samples/TestInput.php =================================================================== --- poc/src/samples/TestInput.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestInput.php 2006-03-20 18:04:48 UTC (rev 34) @@ -55,7 +55,7 @@ <legend>Document Type:</legend> <label for="single">Single </label><input type="radio" id="single" name="SingleDocument" value="true" checked="checked" /> <label for="package">Package </label><input type="radio" id="package" name="SingleDocument" value="false" /><br /> - <p>If you want to display the results in <strong>OpenOffice 2.0.1</strong>, you should take the <em>package</em> document type.</p> + <p>If you want to display the results in <strong>OpenOffice 2.0.2</strong>, you should take the <em>package</em> document type.</p> </fieldset> <fieldset> <legend>Metadata:</legend> Modified: poc/src/samples/TestOutput.php =================================================================== --- poc/src/samples/TestOutput.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestOutput.php 2006-03-20 18:04:48 UTC (rev 34) @@ -7,7 +7,7 @@ * @license GNU General Public License * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. * @author Norman Markgraf <nma...@us...> - * @author Alex Latchford <yan...@us...> + * @author Alex Latchford <yaw...@us...> * @version $Revision$ * @package OpenDocument * @subpackage samples @@ -29,19 +29,9 @@ private $logger; function __construct() { - /* ***TO DO *** This raises a warning ... - // $conf = array( "mode" => 0600 ); - $this->logger = &Log_observer::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); - $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); - */ - - /* - Console output: - $this->logger = &Log_observer::factory( "console", "", "OpenDocument" ); - - File output: - $this->logger = &Log_observer::factory( "file", "OpenDocument.log", "OpenDocument" ); - */ + $conf = array( "mode" => 0600 ); + $this->logger = &Log::factory( "file", "D:/PHP/OpenDocument.log", "OpenDocument", $conf ); + $this->logger = &Log::factory( "console", "", "OpenDocument" ); } function makeMeta( $meta, $creator="Norman Markgraf", $title="This is a test!", $language="en-EN" ) { @@ -55,25 +45,28 @@ } function makeContent( $content ) { - $content->addNoScript(); - $content->addFontFace( "Test", "Tahoma" ); - - $content->addNoAutomaticStyles(); + $text = $content->getText(); - $text = $content->getBody()->getText(); - $text->addNoForms(); $text->addToText( $text->getTextHeading( "Heading", 1, "The first step" ) ); $text->addToText( $text->getTextParagraph( "Paragraph", "This is a little test!" ) ); } - function makeFontFaceDecl( $fontfacedecl ) { + function makeFontFaceDecl( $fontFaceDecl ) { $styleAttr = array(); $styleAttr[ "font-family" ] ="Tahoma"; $fontFaceDecl->addFontFace( "Test", $styleAttr ); } + + function makeAutomaticStyles( $automaticStyles ) { + return $automaticStyles; + } + + function makeScripts( $scripts ) { + return $scripts; + } function makeStyle( $style ) { // Set default style @@ -175,9 +168,11 @@ */ $this->makeMeta( $TestDoc->getMeta(), $creator, $title, "en-EN" ); - $this->makeFontFaceDecl( $TestDoc->getFontFaceDeclaration() ); + $this->makeAutomaticStyles( $TestDoc->getAutomaticStyles() ); + $this->makeScripts( $TestDoc->getScripts() ); + $this->makeFontFaceDecl( $TestDoc->getFontFaceDeclaration() ); $this->makeStyle( $TestDoc->getStyle() ); - $this->makeContent( $TestDoc->getContent() ); + $this->makeContent( $TestDoc->getBody() ); echo $TestDoc->get(); Deleted: poc/src/samples/TestTranslate.php =================================================================== --- poc/src/samples/TestTranslate.php 2006-03-20 13:49:26 UTC (rev 33) +++ poc/src/samples/TestTranslate.php 2006-03-20 18:04:48 UTC (rev 34) @@ -1,48 +0,0 @@ -<?php -/** - * TestTranslate class that will translate a given formatting style to ODF formatting. - * - * $Id$ - * - * @license GNU General Public License - * @copyright Copyright © 2006, Norman Markgraf, Alex Latchford, et al. - * @author Alex Latchford <yaw...@us...> - * @version $Revision$ - * @package OpenDocument - * @subpackage samples - * @since 0.4.2 - */ - -require_once( "Log/observer.php" ); - -class TestTranslate { - - private $expression; - private $logger; - private $matches = array(); - - public function __construct() { - $this->logger = &Log::factory( "null", "", "OpenDocument" ); - $this->logger->debug( "Constructing TestTranslate." ); - } - - public function __destruct() { - $this->logger->debug( "Destructing TestTranslate." ); - } - - public function getParagraphs($document_content) { - - $matches = preg_split( "/\n/", $document_content, 0, PREG_SPLIT_NO_EMPTY); - - return $matches; - } - - public function getHeadings($document_content) { - - $matches = preg_split( "/(<h[1-6])+\w.+(<\/h[1-6]>)+/", $document_content, 0, PREG_SPLIT_NO_EMPTY); - - return $matches; - } - -} - ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |