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

Source for file BodyFragment.php

Documentation is available at BodyFragment.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.  * BodyFragment 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: BodyFragment.php 256 2007-08-01 14:16:10Z nmarkgraf $
  32.  * 
  33.  * @category    File Formats
  34.  * @package     OpenDocumentPHP
  35.  * @subpackage  content_body
  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: BodyFragment.php 256 2007-08-01 14:16:10Z 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/table/SpreadsheetFragment.php';
  48. require_once 'OpenDocumentPHP/content/body/table/TableFragment.php';
  49. require_once 'OpenDocumentPHP/content/body/text/Heading.php';
  50. require_once 'OpenDocumentPHP/content/body/text/Paragraph.php';
  51. require_once 'OpenDocumentPHP/content/body/text/TextFragment.php';
  52. require_once 'OpenDocumentPHP/util/ODPElement.php';
  53.  
  54. /**
  55.  * BodyFragment class.
  56.  *  
  57.  * @category    File Formats
  58.  * @package     OpenDocumentPHP
  59.  * @subpackage  content_body
  60.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  61.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  62.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  63.  * @version     Release: @package_version@
  64.  * @link        http://opendocumentphp.org
  65.  * @since       0.5.0 - 08. Feb. 2007
  66.  */
  67. class BodyFragment extends ODPElement 
  68. {
  69.  
  70.     /**
  71.      * @var         array Array of tables in this document.
  72.      * @access        private
  73.      * @since         0.5.0 - 08. Feb. 2007
  74.      */
  75.     private $tables;
  76.     
  77.     /**
  78.      * @var         DOMElement 
  79.      * @access        private
  80.      * @since         0.5.0 - 08. Feb. 2007
  81.      */
  82.     private $root;
  83.  
  84.     /**
  85.      * Constructor method.
  86.      * 
  87.      * @since       0.5.0 - 08. Feb. 2007
  88.      */
  89.     function __construct($elem=null
  90.     {         
  91.         if (is_null($elem)) {
  92.            parent::__construct('office:body'''self::OFFICE);
  93.         else {
  94.            parent::__construct($elem);         
  95.         }
  96.         $this->tables array ();
  97.     }
  98.     
  99.     /**
  100.      * Set current OpenDocument to a spreadsheet document.
  101.      * 
  102.      * No mime-type fixing is made, just the <b><office:spreadsheet></b> tag is added.
  103.      * 
  104.      * @access         public
  105.      * @since         0.5.0 - 08. Feb. 2007
  106.      */
  107.     function setSpreadsheet(
  108.     {        
  109.         $this->root new SpreadsheetFragment();        
  110.         $this->appendChild($this->root);
  111.     }
  112.     
  113.     /**
  114.      * Set current OpenDocument to a text document.
  115.      *
  116.      * No mime-type fixing is made, just the <b><office:text></b> tag is added.
  117.      *  
  118.      * @access         public
  119.      * @since         0.5.0 - 08. Feb. 2007
  120.      */
  121.     function setText(
  122.     {
  123.         $this->root new TextFragment();
  124.         $this->appendChild($this->root);
  125.     }
  126.     
  127.     /**
  128.      * Retrieve a new table
  129.      * 
  130.      * @todo           This should be a method in the SpreadsheetFragment class!
  131.      * @access            public
  132.      * @since            0.5.0 - 08. Feb. 2007
  133.      * @deprecated     0.5.2 - 30. Jul. 2007
  134.      */
  135.     function getNewTableFragment($name
  136.     {
  137.         /*
  138.          * Create new table (fragment).
  139.          */
  140.         $newTable new TableFragment();
  141.         /*
  142.          * append newTable to document, to make it writaable!
  143.          */
  144.         $this->root->appendChild($newTable);
  145.         /*
  146.          * Set the name of the new table
  147.          */
  148.         $newTable->setName($name);
  149.         /*
  150.          * Add new table to table list under its name.
  151.          * 
  152.          * We might check if it exists and do something here ..
  153.          */
  154.         $this->tables[$name$newTable;
  155.         /*
  156.          * return freshly made new table
  157.          */
  158.         return $newTable;
  159.     }
  160.     
  161.     /**
  162.      * 
  163.      * @access         public
  164.      * @deprecated     0.5.2 - 30. Jul. 2007
  165.      * @since            0.5.0 - 08. Feb. 2007
  166.      */
  167.     function getDocumentFragment(
  168.     {
  169.         return $this;
  170.     }
  171.     
  172.     /**
  173.      * 
  174.      * @access            public
  175.      * @deprecated     0.5.2 - 26. Feb. 2007
  176.      * @since            0.5.0 - 08. Feb. 2007
  177.      */
  178.     function nextParagraph(
  179.     {
  180.         if (is_null($this->root)) {
  181.             $this->getTextFragment();
  182.         }
  183.         return $this->root->nextParagraph();
  184.     }
  185.     
  186.     /**
  187.      * 
  188.      * @access         public
  189.      * @deprecated    0.5.2 - 26. Feb. 2007
  190.      * @since         0.5.0 - 08. Feb. 2007
  191.      */
  192.     function nextHeading($outlineLevel '1'
  193.     {
  194.         if (is_null($this->root)) {
  195.             $this->getTextFragment();
  196.         }    
  197.         return $this->root->nextHeading($outlineLevel);
  198.     }
  199.  
  200.     /**
  201.      * 
  202.      * @access      public
  203.      * @since       0.5.0 - 08. Feb. 2007
  204.      */
  205.     function getTextFragment(
  206.     {
  207.         if ($this->root == null{
  208.             $this->root new TextFragment($this->getElementByTagNameNS(self::OFFICE'text'));            
  209.         }
  210.         return $this->root;
  211.     }
  212.  
  213.     /**
  214.      * 
  215.      * @access      public
  216.      * @since       0.5.3 - 29. Jul. 2007
  217.      */
  218.     function getSpreadsheetFragment(
  219.     {
  220.         if ($this->root == null{
  221.             $this->root new SpreadsheetFragment($this->getElementByTagNameNS(self::OFFICE'spreadsheet'));            
  222.         }
  223.         return $this->root;
  224.     }    
  225. }
  226. ?>

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