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

Source for file ContentDocument.php

Documentation is available at ContentDocument.php

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

Documentation generated on Wed, 18 Jun 2008 06:27:49 +0200 by phpDocumentor 1.3.2