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

Source for file DefaultStyle.php

Documentation is available at DefaultStyle.php

  1. <?php
  2. /*
  3.  * Created on 21.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: DefaultStyle.php 256 2007-08-01 14:16:10Z nmarkgraf $
  24.  */
  25. require_once 'OpenDocumentPHP/util/ODPElement.php';
  26. require_once 'OpenDocumentPHP/styles/properties/TextProperties.php';
  27. require_once 'OpenDocumentPHP/styles/properties/ParagraphProperties.php';
  28. require_once 'OpenDocumentPHP/styles/properties/GraphicProperties.php';
  29. require_once 'OpenDocumentPHP/styles/properties/TableProperties.php';
  30. require_once 'OpenDocumentPHP/styles/properties/TableRowProperties.php';
  31. require_once 'OpenDocumentPHP/util/Validator.php';
  32. /**
  33.  * DefaultStyle class.
  34.  * 
  35.  * @author         Norman Markgraf (nmarkgraf(at)user.sourceforge.net)
  36.  * @copyright     Copyright in 2006, 2007 by The OpenDocumentPHP Team
  37.  * @license     http://www.gnu.org/licenses/gpl.html GNU General Public License 2.0.
  38.  * @version        $Revision: 256 $
  39.  * @package        OpenDocumentPHP
  40.  * @since         0.5.0 - 08.02.2007
  41.  */
  42. class DefaultStyle extends ODPElement {
  43.  
  44.     /**
  45.      * Constructor method.
  46.      * 
  47.      * @since       0.5.2 - 30. Feb. 2007
  48.      */
  49.     function __construct($elem=null$value=null$namespace=null
  50.     {         
  51.         if (is_null($elem)) {        
  52.             parent::__construct('style:default-style'''self::STYLE);
  53.         else {
  54.             if ($elem instanceof DOMElement{
  55.                 parent::__construct($elem);
  56.             else {
  57.                 parent::__construct($elem$value$namespace);         
  58.             }            
  59.         }   
  60.     }
  61.  
  62.     /**
  63.      * 
  64.      * @access    private
  65.      * @var        ParagraphProperties 
  66.      */
  67.     private $paragraphProp null;
  68.     /**
  69.      * @access    private
  70.      * @var        TextProperties 
  71.      */
  72.     private $textProp null;
  73.     
  74.     /* ------------ */
  75.     /* Style Family */
  76.     /* ------------ */
  77.     /**
  78.      * Set family.
  79.      * 
  80.      * @access        public
  81.      * @since         0.5.0 - 08.02.2007
  82.      * @param         string $value Must be a value out of 'ruby','control', 'presentation',
  83.      *                                'drawing-page', 'default', 'chart', 'table-page',
  84.      *                                'table-cell', 'table-row', 'table-column',
  85.      *                                'section', 'text', 'table', 'paragraph' or 'graphic'.
  86.      */
  87.     function setFamily($value{
  88.         $ret Validator :: checkFamilyValues($value);
  89.         if ($ret{
  90.             //$this->setAttributeNS(self :: STYLE, 'style:family', $value);
  91.             $this->putStyleAttribute('family'$value);
  92.         }
  93.         return $ret;
  94.     }
  95.     /**
  96.          * Retrieve family.
  97.          * 
  98.      * @access        public
  99.      * @since         0.5.0 - 08.02.2007
  100.      */
  101.     function getFamily({
  102.         return $this->getStyleAttribute('family');
  103.     }
  104.     /**
  105.      * Checks if the current default style has an paragraph-properties
  106.      * element as child.
  107.      * 
  108.      * @return bool True if there is an <style:paragraph-properties> tag as child of the current <style:default-style> tag.
  109.      * @access        public
  110.      * @since         0.5.2 - 04.03.2007
  111.      */
  112.     function hasParagraphProperties({
  113.         return $this->hasChildNS(self :: STYLE'paragraph-properties');
  114.     }
  115.     /**
  116.      * Checks if the current default style has an text-properties
  117.      * element as child.
  118.      * 
  119.      * @return bool True if there is an <style:text-properties> tag as child of the current <style:default-style> tag.
  120.      * @access        public
  121.      * @since         0.5.2 - 04.03.2007
  122.      */
  123.     function hasTextProperties({
  124.         return $this->hasChildNS(self :: STYLE'text-properties');
  125.     }
  126.     /**
  127.      * Checks if the current default style has an graphic-properties
  128.      * element as child.
  129.      * 
  130.      * @return bool True if there is an <style:graphic-properties> tag as child of the current <style:default-style> tag.
  131.      * @access        public
  132.      * @since         0.5.2 - 04.03.2007
  133.      */
  134.     function hasGraphicProperties({
  135.         return $this->hasChildNS(self :: STYLE'graphic-properties');
  136.     }
  137.     /**
  138.      * Retrieve a <style:paragraph-properties> tag.
  139.      * If it does not exists, create on and add it as a child.
  140.      * 
  141.      * @access        public
  142.      * @since         0.5.2 - 03.03.2007
  143.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  144.      */
  145.     function getParagraphProperties({
  146.         if (is_null($this->paragraphProp)) {
  147.             // Look up <style:paragraph-properties> in current child list.
  148.             if ($this->hasParagraphProperties()) {
  149.                 // Get the found properties, and set class attribute.
  150.                 $tmp $this->getElementByTagNameNS(self :: STYLE'paragraph-properties');
  151.                 $this->paragraphProp new ParagraphProperties($tmp);
  152.             else {
  153.                 // If not found, create a new on
  154.                 $this->paragraphProp new ParagraphProperties();
  155.                 $this->appendChild($this->paragraphProp);
  156.             }
  157.         }
  158.         return $this->paragraphProp;
  159.     }
  160.     /**
  161.      * Retrieve a <style:text-properties> tag.
  162.      * If it does not exists, create on and add it as a child.
  163.      * 
  164.      * @access        public
  165.      * @since         0.5.2 - 03.03.2007
  166.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  167.      */
  168.     function getTextProperties({
  169.         if (is_null($this->textProp)) {
  170.             /*
  171.              * Look up <style:text-properties> in current child list.
  172.              */
  173.             if ($this->hasTextProperties()) {
  174.                 // Get the found properties, and set class attribute.
  175.                 $tmp $this->getElementByTagNameNS(self :: STYLE'text-properties');
  176.                 $this->textProp new TextProperties($tmp);
  177.             else {
  178.                 // If not found, create a new on
  179.                 $this->textProp new TextProperties();
  180.                 $this->appendChild($this->textProp);
  181.             }
  182.         }
  183.         return $this->textProp;
  184.     }
  185.     /**
  186.      * Retrieve a <style:graphic-properties> tag.
  187.      * If it does not exists, create on and add it as a child.
  188.      * 
  189.      * @access        public
  190.      * @since         0.5.2 - 03.03.2007
  191.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  192.      */
  193.     function getGraphicProperties({
  194.         if (is_null($this->textProp)) {
  195.             // Look up <style:graphic-properties> in current child list.
  196.             if ($this->hasGraphicProperties()) {
  197.                 // Get the found properties, and set class attribute.
  198.                 $tmp $this->getElementByTagNameNS(self :: STYLE'graphic-properties');
  199.                 $this->graphicProp new GraphicProperties($tmp);
  200.             else {
  201.                 // If not found, create a new on
  202.                 $this->graphicProp new GraphicProperties();                
  203.                 $this->appendChild($this->graphicProp);
  204.             }
  205.         }
  206.         return $this->graphicProp;
  207.     }
  208. }
  209. ?>

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