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

Source for file BodyFragment.php

Documentation is available at BodyFragment.php

  1. <?php
  2. /*
  3.  * Created on 04.01.2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  4.  *
  5.  * PHP versions 5.2 or better.
  6.  *
  7.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  11.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  12.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  13.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  16.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  17.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18.  *
  19.  * This software consists of voluntary contributions made by many individuals
  20.  * and is licensed under the GPL. For more information please see
  21.  * <http://opendocumentphp.org>.
  22.  * 
  23.  * $Id: BodyFragment.php 183 2007-06-12 07:58:41Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/content/body/TableFragment.php';
  26. require_once 'OpenDocumentPHP/content/body/text/Heading.php';
  27. require_once 'OpenDocumentPHP/content/body/text/Paragraph.php';
  28. require_once 'OpenDocumentPHP/content/body/text/TextFragment.php';
  29. require_once 'OpenDocumentPHP/util/Fragment.php';
  30. /**
  31.  * BodyFragment class.
  32.  *  
  33.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  34.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  35.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  36.  * @version        $Revision: 183 $
  37.  * @package        OpenDocumentPHP
  38.  * @subpackage    content_body
  39.  * @since         0.5.0 - 08.02.2007
  40.  */
  41. class BodyFragment extends Fragment {
  42.     /**
  43.      * @var         array Array of tables in this document.
  44.      * @access        private
  45.      * @since         0.5.0 - 08.02.2007
  46.      */
  47.     private $tables;
  48.     /**
  49.      * @var         DOMElement 
  50.      * @access        private
  51.      * @since         0.5.0 - 08.02.2007
  52.      */
  53.     private $root2 null;
  54.     /**
  55.      * Constructor method.
  56.      * 
  57.      * @since         0.5.0 - 08.02.2007
  58.      */
  59.     function __construct($domFragment{
  60.         parent :: __construct($domFragment);
  61.         $this->root = $this->createOfficeElement('body');
  62.         $this->tables array ();
  63.     }
  64.     /**
  65.      * 
  66.      * @access         public
  67.      * @since         0.5.0 - 08.02.2007
  68.      */
  69.     function setSpreadsheet({
  70.         //*** FIX ME ***
  71.         // $this->root2 = $this->createOfficeElement('spreadsheet');
  72.         //$this->root->appendChild($this->root2);
  73.     }
  74.     /**
  75.      * 
  76.      * @access         public
  77.      * @since         0.5.0 - 08.02.2007
  78.      */
  79.     function setText({
  80.         $this->root2 new TextFragment($this->domFragment);
  81.         $this->root->appendChild($this->root2->getDocumentFragment());
  82.     }
  83.     /**
  84.      * 
  85.      * @access         public
  86.      * @since         0.5.0 - 08.02.2007
  87.      */
  88.     function getNewTableFragment($name{
  89.         $ret new TableFragment($this->domFragment);
  90.         $ret->setTableName($name);
  91.         $this->tables[$name$ret;
  92.         return $ret;
  93.     }
  94.     /**
  95.      * 
  96.      * @access         public
  97.      * @since         0.5.0 - 08.02.2007
  98.      */
  99.     function getDocumentFragment({
  100.         foreach ($this->tables as $elem{
  101.             $this->root2->appendChild($elem->getDocumentFragment());
  102.         }
  103.         return $this->root;
  104.     }
  105.     /**
  106.      * 
  107.      * @access         public
  108.      * @deprecated    0.5.2 - 26.02.2007
  109.      * @since         0.5.0 - 08.02.2007
  110.      */
  111.     function nextParagraph({
  112.         return $this->root2->nextParagraph();
  113.     }
  114.     /**
  115.      * 
  116.      * @access         public
  117.      * @deprecated    0.5.2 - 26.02.2007
  118.      * @since         0.5.0 - 08.02.2007
  119.      */
  120.     function nextHeading($outlineLevel '1'{
  121.         return $this->root2->nextHeading($outlineLevel);
  122.     }
  123.     
  124.     function getTextFragment({
  125.         if ($this->root2 == null{
  126.             $this->initXpath();
  127.             $result $this->xpath->query('/office:document-content/office:body/office:text');
  128.             if ($result->length == 1{
  129.                     $node $result->item(0);
  130.                     $this->root2 new TextFragment($this->domFragment$node);
  131.             else {
  132.                     $ret false;
  133.             }
  134.             
  135.         }
  136.         return $this->root2;
  137.     }
  138. }
  139. ?>

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