OpenDocumentPHP
[ class tree: OpenDocumentPHP ] [ index: OpenDocumentPHP ] [ all elements ]

Source for file ContentDocument.php

Documentation is available at ContentDocument.php

  1. <?php
  2. /*
  3.  * Created on 04.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the GPL. For more information please see
  19.  * <http://opendocumentphp.org>.
  20.  * 
  21.  * $Id: ContentDocument.php 136 2007-03-02 18:02:29Z nmarkgraf $
  22.  */
  23. require_once 'OpenDocumentPHP/content/body/BodyFragment.php';
  24. require_once 'OpenDocumentPHP/global/FontFaceDeclFragment.php';
  25. require_once 'OpenDocumentPHP/global/AutomaticStylesFragment.php';
  26. require_once 'OpenDocumentPHP/content/ScriptsFragment.php';
  27. require_once 'OpenDocumentPHP/util/AbstractDocument.php';
  28. /**
  29.  * ContentDocument class.
  30.  *  
  31.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  32.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  33.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  34.  * @version        $Revision: 136 $
  35.  * @package        OpenDocumentPHP
  36.  * @subpackage  content
  37.  * @since         0.5.0 - 08.02.2007
  38.  */
  39. class ContentDocument extends AbstractDocument {
  40.     /**
  41.      * @var         ScriptsFragment 
  42.      * @access        private
  43.      * @since         0.5.0 - 08.02.2007
  44.      */
  45.     private $scripts;
  46.     /**
  47.      * @var         FontFaceDeclFragment 
  48.      * @access        private
  49.      * @since         0.5.0 - 08.02.2007
  50.      */
  51.     private $fontfacedecl;
  52.     /**
  53.      * @var         AutomaticStylesFragment 
  54.      * @access        private
  55.      * @since         0.5.0 - 08.02.2007
  56.      */
  57.     private $automaticstyles;
  58.     /**
  59.      * @var         BodyFragment 
  60.      * @access        private
  61.      * @since         0.5.0 - 08.02.2007
  62.      */
  63.     private $body;
  64.     /**
  65.      * Constructor method.
  66.      * 
  67.      * @since         0.5.0 - 08.02.2007
  68.      */
  69.     function __construct({
  70.         parent :: __construct('office:document-content');
  71.         // append ScriptFragment
  72.         $this->scripts new ScriptsFragment($this);
  73.         $this->root->appendChild($this->scripts->getDocumentFragment());
  74.         // append FontFaceDeclFragment
  75.         $this->fontfacedecl new FontFaceDeclFragment($this);
  76.         $this->root->appendChild($this->fontfacedecl->getDocumentFragment());
  77.         // append AutomaticStylesFragment
  78.         $this->automaticstyles new AutomaticStylesFragment($this);
  79.         $this->root->appendChild($this->automaticstyles->getDocumentFragment());
  80.         // append BodyFramgent
  81.         $this->body new BodyFragment($this);
  82.         $this->root->appendChild($this->body->getDocumentFragment());
  83.     }
  84.     /**
  85.      * 
  86.      * @access         public
  87.      * @since         0.5.0 - 08.02.2007
  88.      */
  89.     function setSpreadsheet({
  90.         $this->body->setSpreadsheet();
  91.     }
  92.     /**
  93.      * 
  94.      * @access         public
  95.      * @since         0.5.0 - 08.02.2007
  96.      */
  97.     function setText({
  98.         $this->body->setText();
  99.     }
  100.     /**
  101.      * 
  102.      * @access         public
  103.      * @since         0.5.0 - 08.02.2007
  104.      */
  105.     function getTable($name{
  106.         $table $this->body->getNewTableFragment($name);
  107.         return $table;
  108.     }
  109.     /**
  110.      * 
  111.      * @access         public
  112.      * @since         0.5.0 - 08.02.2007
  113.      */
  114.     function getFontFaceDeclarations({
  115.         return $this->fontfacedecl;
  116.     }
  117.     /**
  118.      * 
  119.      * @access         public
  120.      * @since         0.5.0 - 08.02.2007
  121.      */
  122.     function getBody({
  123.         return $this->body;
  124.     }
  125.     /**
  126.      * Loads a content document into this ContentDocument.
  127.      * 
  128.      * @access     public
  129.      * @since     0.5.2 - 26.02.2007
  130.      */
  131.     function loadXML($source{
  132.         $ret parent :: loadXML($source);
  133.         if ($ret === TRUE{
  134.             $this->root = $this->documentElement;
  135.             $this->initXpath();
  136.             $result $this->xpath->query('/office:document-content');
  137.             $tmp $result;
  138.             if ($tmp->length == 1{
  139.                 $this->content $tmp->item(0);
  140.                 $result $this->xpath->query('/office:document-content/office:scripts');
  141.                 if ($result->length == 1{
  142.                     $node $result->item(0);
  143.                     $this->scripts new ScriptsFragment($this$node);
  144.                 else {
  145.                     $ret false;
  146.                 }
  147.                 $result $this->xpath->query('/office:document-content/office:font-face-decls');
  148.                 if ($result->length == 1{
  149.                     $node $result->item(0);
  150.                     $this->fontfacedecl new FontFaceDeclFragment($this$node);
  151.                 else {
  152.                     $ret false;
  153.                 }
  154.                 $result $this->xpath->query('/office:document-content/office:automatic-styles');
  155.                 if ($result->length == 1{
  156.                     $node $result->item(0);
  157.                     $this->automaticstyles new AutomaticStylesFragment($this$node);
  158.                 else {
  159.                     $ret false;
  160.                 }
  161.                 $result $this->xpath->query('/office:document-content/office:body');
  162.                 if ($result->length == 1{
  163.                     $node $result->item(0);
  164.                     $this->body new BodyFragment($this$node);
  165.                 else {
  166.                     $ret false;
  167.                 }
  168.             else {
  169.                 // This should never happend!
  170.                 $ret FALSE;
  171.             }
  172.         }
  173.         return $ret;
  174.     }
  175. }
  176. ?>

Documentation generated on Tue, 12 Jun 2007 09:59:34 +0200 by phpDocumentor 1.3.2