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

Source for file TextFragment.php

Documentation is available at TextFragment.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /*
  6.  * Created on 26. Feb. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  7.  */
  8.  
  9. /**
  10.  * TextFragment 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: TextFragment.php 250 2007-07-31 08:52:06Z nmarkgraf $
  32.  * 
  33.  * @category    File Formats
  34.  * @package     OpenDocumentPHP
  35.  * @subpackage  content_body_text
  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: TextFragment.php 250 2007-07-31 08:52:06Z nmarkgraf $
  40.  * @link        http://opendocumentphp.org
  41.  * @since       0.5.2 - 26. Feb. 2007
  42.  */
  43.  
  44. /**
  45.  * 
  46.  */
  47. require_once 'OpenDocumentPHP/content/body/text/Heading.php';
  48. require_once 'OpenDocumentPHP/content/body/text/Paragraph.php';
  49. require_once 'OpenDocumentPHP/content/body/text/UserFieldDecl.php';
  50. require_once 'OpenDocumentPHP/content/body/text/UserFieldGet.php';
  51. require_once 'OpenDocumentPHP/content/body/text/UserFieldDecls.php';
  52. require_once 'OpenDocumentPHP/util/ODPElement.php';
  53.  
  54. /**
  55.  * TextFragment class.
  56.  * 
  57.  * Here we store the <office:text>...<office:text> part of the content tree.
  58.  *  
  59.  * @category    File Formats
  60.  * @package     OpenDocumentPHP
  61.  * @subpackage  content_body_text
  62.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  63.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  64.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  65.  * @version     Release: @package_version@
  66.  * @link        http://opendocumentphp.org
  67.  * @since         0.5.2 - 26. Feb. 2007
  68.  */
  69. class TextFragment extends ODPElement {
  70.  
  71.     /**
  72.      * @access      private
  73.      */
  74.     private $forms null;
  75.  
  76.     /**
  77.      * @access      private
  78.      */
  79.     private $sequenzDecl null;
  80.  
  81.     /**
  82.      * @access      private
  83.      */
  84.     private $userFieldDecl null;
  85.     
  86.     /**
  87.      * Constructor method.
  88.      * 
  89.      * @since         0.5.2 - 26. Feb. 2007
  90.      */
  91.     function __construct($elem=null
  92.     {         
  93.         if (is_null($elem)) {
  94.            parent::__construct('office:text'''self::OFFICE);
  95.         else {
  96.            parent::__construct($elem);         
  97.         }    
  98.     }
  99.     
  100.     /**
  101.      * Create a new paragraph and append it to the document.
  102.      * 
  103.      * @access         public
  104.      * @since         0.5.2 - 26. Feb. 2007
  105.      */
  106.     function nextParagraph(
  107.     {
  108.         $par new Paragraph();
  109.         $this->appendChild($par);
  110.         return $par;
  111.     }
  112.     
  113.     /**
  114.      * Create a new heading and append it to the document.
  115.      * 
  116.      * @param        int $outlineLevel  Outline level of this heading.
  117.      * @access         public
  118.      * @since         0.5.2 - 26. Feb. 2007
  119.      */
  120.     function nextHeading($outlineLevel 1
  121.     {
  122.         $par new Heading();
  123.         $this->appendChild($par->getElement());        
  124.         $par->setHeadingLevel($outlineLevel);
  125.         return $par;
  126.     }
  127.     
  128.     /**
  129.      * Update User Field Decl(aration)
  130.      * 
  131.      * @param        string $name  The name of the user-field-decl(aration) to be updated.
  132.      * @param        string $value The new value.
  133.      * @access         public
  134.      * @since         0.5.2 - 26. Feb. 2007
  135.      */    
  136.     function updateUserFieldDecl($name$value
  137.     {
  138.         if (is_null($this->userFieldDecl)) {
  139.             $node $this->getTag('/office:document-content/office:body/office:text/text:user-field-decls'''''-1);
  140.             if ($node == ''{
  141.                 $this->userFieldDecl new UserFieldDecls();                
  142.             else {
  143.                 $this->userFieldDecl new UserFieldDecls($node);
  144.             }
  145.         }
  146.         $this->userFieldDecl->setUserFieldDecl($name$value);
  147.         // *** FIX ME ***
  148.         // We must now scan the document for <text:user-field-get> tags and update them!
  149.         $this->initXpath();
  150.         $result $this->xpath->query('/*/text:user-field-get[@name="' $name '"]');
  151.         foreach ($result as $node{
  152.             $ufd new UserFieldGet($node);
  153.             $ufd->updateValue($value);
  154.         }
  155.     }
  156. }
  157. ?>

Documentation generated on Wed, 18 Jun 2008 06:33:31 +0200 by phpDocumentor 1.3.2