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

Source for file FontFaceDeclFragment.php

Documentation is available at FontFaceDeclFragment.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /*
  6.  * Created on 05. Jan. 2007 by Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  7.  */
  8.  
  9. /**
  10.  * FontFaceDeclFragment 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: FontFaceDeclFragment.php 282 2007-11-29 08:22:46Z nmarkgraf $
  32.  * 
  33.  * @category    File Formats
  34.  * @package     OpenDocumentPHP
  35.  * @subpackage  global
  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: FontFaceDeclFragment.php 282 2007-11-29 08:22:46Z nmarkgraf $
  40.  * @link        http://opendocumentphp.org
  41.  * @since       0.5.0 - 08. Feb. 2007
  42.  */
  43.  
  44. /**
  45.  * 
  46.  */
  47. require_once 'OpenDocumentPHP/global/FontFace.php';
  48. require_once 'OpenDocumentPHP/util/Fragment.php';
  49.  
  50. /**
  51.  * FontFaceDeclFragment class.
  52.  *   
  53.  * @category    File Formats
  54.  * @package     OpenDocumentPHP
  55.  * @subpackage  global
  56.  * @author      Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  57.  * @copyright   Copyright in 2006, 2007 by The OpenDocumentPHP Team
  58.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  59.  * @version     Release: @package_version@
  60.  * @link        http://opendocumentphp.org
  61.  * @since       0.5.0 - 08. Feb. 2007
  62.  */
  63. class FontFaceDeclFragment extends ODPElement {
  64.  
  65.     /**
  66.      * Constructor method.
  67.      * 
  68.      * @param      DOMElement|nullIf a DOMElement is given, this is will be the node, else a new node is created.
  69.      * @since        0.5.0 - 08. Feb. 2007
  70.      */
  71.     function __construct($elem null
  72.     {
  73.        if (is_null($elem)) {
  74.            parent::__construct('office:font-face-decls'''self::OFFICE);
  75.        else {
  76.            parent::__construct($elem);           
  77.        }
  78.        /*
  79.         parent :: __construct($domFragment, $root);
  80.         if (isset($root) && $root != null) {
  81.         } else {
  82.             $this->root = $this->domFragment->createElementNS(self :: OFFICE, 'office:font-face-decls');
  83.         }
  84.        */ 
  85.     }
  86.     
  87.     /**
  88.      * Create a new/next FontFace class.
  89.      * 
  90.      * @access        public
  91.      * @return      FontFace A new FontFace class.
  92.      * @since         0.5.0 - 08. Feb. 2007
  93.      */
  94.     function nextFontFace(
  95.     {
  96.        /*
  97.         * Create a new font face class,
  98.         */   
  99.         $fontface new FontFace();
  100.         /*
  101.          * add it to the current document,
  102.          */
  103.         $this->appendChild($fontface->getElement());
  104.         /*
  105.          * and return the class to the caller.
  106.          */
  107.         return $fontface;
  108.     }
  109.  
  110.     /**
  111.      * Import newnode tree as new FontFaceDecl.
  112.      *  
  113.      * @param       DOMNode $newnode Root node of a tree, which we import as new FontFaceDecl
  114.      * @param       boolean $cleanFirst True (default) if we want to remode our own old children first.
  115.      * @access        public
  116.      * @since         0.5.0 - 08. Feb. 2007
  117.      */
  118.     function importNode($newnode$cleanFirst=true
  119.     {
  120.         /*
  121.          * Check if we want to remove all our own children first?
  122.          */        
  123.         if ($cleanFirst{
  124.             /*
  125.              * So we remove every child of the current list.
  126.              */
  127.             foreach($this->childNodes as $child{
  128.                 $this->removeChild($child);
  129.             }
  130.         }
  131.         
  132.         /*
  133.          * Now add every child of $tmp to our document.
  134.          * $tmp should cover the <office:font-face-decl> tag of §newnode, so its 
  135.          * children are exactly what we want to add to our own <office:font-face-decl> 
  136.          * tag.
  137.          */
  138.         /*
  139.          * We need the real DOMElement, so we _MUST_ use the getElement() method on
  140.          * ODPElement classes to get the DOMNodeList in childNodes attribute. 
  141.          */
  142.         if ($newnode instanceof ODPElement{
  143.             $newChildren $newnode->getElement()->childNodes;
  144.         else {
  145.             $newChildren $newnode->childNodes;
  146.         }
  147.         for($i=0$l=$newChildren->length$i $l$i++{
  148.             /*
  149.              * Get next child
  150.              */
  151.             $child $newChildren->item($i);
  152.             /*
  153.              * Import (deep) the nodes temporary to our document. Again we need the real
  154.              * Element, so we _MUST_ use the getElement() method to get the ownerDocument
  155.              * attribute.
  156.              */            
  157.             $newChild $this->getElement()->ownerDocument->importNode($childtrue);
  158.             /*
  159.              * Append to this node
  160.              */            
  161.             $this->appendChild($newChild);
  162.             /*
  163.              * Remove $newChild and mark it for GC
  164.              */
  165.         }
  166.         
  167.     }
  168. }
  169. ?>

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