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

Source for file TextFragment.php

Documentation is available at TextFragment.php

  1. <?php
  2. /*
  3.  * Created on 26.02.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: TextFragment.php 136 2007-03-02 18:02:29Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/content/body/text/Heading.php';
  26. require_once 'OpenDocumentPHP/content/body/text/Paragraph.php';
  27. require_once 'OpenDocumentPHP/content/body/text/UserFieldDecl.php';
  28. require_once 'OpenDocumentPHP/content/body/text/UserFieldGet.php';
  29. require_once 'OpenDocumentPHP/content/body/text/UserFieldDecls.php';
  30. require_once 'OpenDocumentPHP/util/Fragment.php';
  31. /**
  32.  * TextFragment class.
  33.  * 
  34.  * Here we store the <office:text>...<office:text> part of the content tree.
  35.  *  
  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        $Revision: 136 $
  40.  * @package        OpenDocumentPHP
  41.  * @subpackage  content_body_text
  42.  * @since         0.5.2 - 26.02.2007
  43.  */
  44. class TextFragment extends Fragment {
  45.     private $forms NULL;
  46.     private $sequenzDecl NULL;
  47.     private $userFieldDecl NULL;
  48.     /**
  49.      * Constructor method.
  50.      * 
  51.      * @since         0.5.2 - 26.02.2007
  52.      */
  53.     function __construct($domFragment$root null{
  54.         parent :: __construct($domFragment$root);
  55.         if (isset ($root&& $root != null{
  56.         else {
  57.             $this->root = $this->createOfficeElement('text');
  58.             // $this->root = $this->domFragment->createElementNS(self :: OFFICE, 'office:z');
  59.         }
  60.     }
  61.     /**
  62.      * Create a new paragraph and append it to the document.
  63.      * 
  64.      * @access         public
  65.      * @since         0.5.2 - 26.02.2007
  66.      */
  67.     function nextParagraph({
  68.         $par new Paragraph($this->domFragment);
  69.         $this->root->appendChild($par->getElement());
  70.         return $par;
  71.     }
  72.     /**
  73.      * Create a new heading and append it to the document.
  74.      * 
  75.      * @param        int $outlineLevel  Outline level of this heading.
  76.      * @access         public
  77.      * @since         0.5.2 - 26.02.2007
  78.      */
  79.     function nextHeading($outlineLevel 1{
  80.         $par new Heading($this->domFragment);
  81.         $par->setHeadingLevel($outlineLevel);
  82.         $this->root->appendChild($par->getElement());
  83.         return $par;
  84.     }
  85.     /**
  86.      * Update User Field Decl(aration)
  87.      * 
  88.      * @param        string $name  The name of the user-field-decl(aration) to be updated.
  89.      * @param        string $value The new value.
  90.      * @access         public
  91.      * @since         0.5.2 - 26.02.2007
  92.      */    
  93.     function updateUserFieldDecl($name$value{
  94.         if ($this->userFieldDecl == NULL{
  95.             $node $this->getTag('/office:document-content/office:body/office:text/text:user-field-decls'''''-1);
  96.             if ($node == ''{
  97.                 $this->userFieldDecl new UserFieldDecls($this->domFragment);                
  98.             else {
  99.                 $this->userFieldDecl new UserFieldDecls($this->domFragment$node);
  100.             }
  101.         }
  102.         $this->userFieldDecl->setUserFieldDecl($name$value);
  103.         // *** FIX ME ***
  104.         // We must now scan the document for <text:user-field-get> tags and update them!
  105.         $this->initXpath();
  106.         $result $this->xpath->query('/*/text:user-field-get[@name="' $name '"]');
  107.         foreach ($result as $node{
  108.             $ufd new UserFieldGet($this->domFragment$node);
  109.             $ufd->updateValue($value);
  110.         }
  111.     }
  112. }
  113. ?>

Documentation generated on Tue, 12 Jun 2007 10:00:57 +0200 by phpDocumentor 1.3.2