OpenDocumentPHP
[ 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 164 2007-04-10 11:24:30Z 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/util/Validator.php';
  30. /**
  31.  * DefaultStyle 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: 164 $
  37.  * @package        OpenDocumentPHP
  38.  * @since         0.5.0 - 08.02.2007
  39.  */
  40. class DefaultStyle extends ODPElement {
  41.     /**
  42.      * 
  43.      * @access    private
  44.      * @var        ParagraphProperties 
  45.      */
  46.     private $paragraphProp null;
  47.     /**
  48.      * @access    private
  49.      * @var        TextProperties 
  50.      */
  51.     private $textProp null;
  52.     /**
  53.      * Set element to 'style:default-style'.
  54.      * 
  55.      * @access         protected
  56.      * @since         0.5.0 - 08.02.2007
  57.      * @deprecated  0.5.2 - 19.03.2007 No longer needed!
  58.      */
  59.     protected function __setRoot({
  60.         $this->root $this->domFragment->createElementNS(self :: STYLE'style:default-style');
  61.     }
  62.     /* ------------ */
  63.     /* Style Family */
  64.     /* ------------ */
  65.     /**
  66.      * Set family.
  67.      * 
  68.      * @access        public
  69.      * @since         0.5.0 - 08.02.2007
  70.      * @param         string $value Must be a value out of 'ruby','control', 'presentation',
  71.      *                                'drawing-page', 'default', 'chart', 'table-page',
  72.      *                                'table-cell', 'table-row', 'table-column',
  73.      *                                'section', 'text', 'table', 'paragraph' or 'graphic'.
  74.      */
  75.     function setFamily($value{
  76.         $ret Validator :: checkFamilyValues($value);
  77.         if ($ret{
  78.             //$this->setAttributeNS(self :: STYLE, 'style:family', $value);
  79.             $this->putStyleAttribute('family'$value);
  80.         }
  81.         return $ret;
  82.     }
  83.     /**
  84.          * Retrieve family.
  85.          * 
  86.      * @access        public
  87.      * @since         0.5.0 - 08.02.2007
  88.      */
  89.     function getFamily({
  90.         return $this->getStyleAttribute('family');
  91.     }
  92.     /**
  93.      * Checks if the current default style has an paragraph-properties
  94.      * element as child.
  95.      * 
  96.      * @return bool True if there is an <style:paragraph-properties> tag as child of the current <style:default-style> tag.
  97.      * @access        public
  98.      * @since         0.5.2 - 04.03.2007
  99.      */
  100.     function hasParagraphProperties({
  101.         return $this->hasChildNS(self :: STYLE'paragraph-properties');
  102.     }
  103.     /**
  104.      * Checks if the current default style has an text-properties
  105.      * element as child.
  106.      * 
  107.      * @return bool True if there is an <style:text-properties> tag as child of the current <style:default-style> tag.
  108.      * @access        public
  109.      * @since         0.5.2 - 04.03.2007
  110.      */
  111.     function hasTextProperties({
  112.         return $this->hasChildNS(self :: STYLE'text-properties');
  113.     }
  114.     /**
  115.      * Checks if the current default style has an graphic-properties
  116.      * element as child.
  117.      * 
  118.      * @return bool True if there is an <style:graphic-properties> tag as child of the current <style:default-style> tag.
  119.      * @access        public
  120.      * @since         0.5.2 - 04.03.2007
  121.      */
  122.     function hasGraphicProperties({
  123.         return $this->hasChildNS(self :: STYLE'graphic-properties');
  124.     }
  125.     /**
  126.      * Retrieve a <style:paragraph-properties> tag.
  127.      * If it does not exists, create on and add it as a child.
  128.      * 
  129.      * @access        public
  130.      * @since         0.5.2 - 03.03.2007
  131.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  132.      */
  133.     function getParagraphProperties({
  134.         if ($this->paragraphProp == null{
  135.             // Look up <style:paragraph-properties> in current child list.
  136.             if ($this->hasParagraphProperties()) {
  137.                 // Get the found properties, and set class attribute.
  138.                 $tmp $this->getElementByTagNameNS(self :: STYLE'paragraph-properties');
  139.                 $this->paragraphProp new ParagraphProperties($tmp);
  140.             else {
  141.                 // If not found, create a new on
  142.                 $this->paragraphProp $this->getElement()->ownerDocument->createParagraphPropertiesElement();
  143.                 $this->appendChild($this->paragraphProp);
  144.             }
  145.         }
  146.         return $this->paragraphProp;
  147.     }
  148.     /**
  149.      * Retrieve a <style:text-properties> tag.
  150.      * If it does not exists, create on and add it as a child.
  151.      * 
  152.      * @access        public
  153.      * @since         0.5.2 - 03.03.2007
  154.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  155.      */
  156.     function getTextProperties({
  157.         /*
  158.         echo 'Retrieving text-properties:'."\n";
  159.         if ($this->root->ownerDocument instanceof AbstractDocument) {
  160.             echo 'The root is an AbstactDocument :-)'."\n";
  161.         } else {
  162.             echo 'The root is *NOT* an AbstactDocument :('."\n";
  163.         }
  164.         */
  165.         if ($this->textProp == null{
  166.             // Look up <style:text-properties> in current child list.
  167.             if ($this->hasTextProperties()) {
  168.                 // Get the found properties, and set class attribute.
  169.                 $tmp $this->getElementByTagNameNS(self :: STYLE'text-properties');
  170.                 $this->textProp new TextProperties($tmp);
  171.             else {
  172.                 // If not found, create a new on
  173.                 $this->textProp $this->getElement()->ownerDocument->createTextPropertiesElement();
  174.                 $this->appendChild($this->textProp->getElement());
  175.             }
  176.         }
  177.         return $this->textProp;
  178.     }
  179.     /**
  180.      * Retrieve a <style:graphic-properties> tag.
  181.      * If it does not exists, create on and add it as a child.
  182.      * 
  183.      * @access        public
  184.      * @since         0.5.2 - 03.03.2007
  185.      * @todo        Replace the else path by something which uses $this->getChild(..)!
  186.      */
  187.     function getGraphicProperties({
  188.         if ($this->textProp == null{
  189.             // Look up <style:graphic-properties> in current child list.
  190.             if ($this->hasGraphicProperties()) {
  191.                 // Get the found properties, and set class attribute.
  192.                 $tmp $this->getElementByTagNameNS(self :: STYLE'graphic-properties');
  193.                 $this->graphicProp new GraphicProperties($tmp);
  194.             else {
  195.                 // If not found, create a new on
  196.                 $this->graphicProp $this->getElement()->ownerDocument->createGraphicPropertiesElement();
  197.                 ;
  198.                 $this->appendChild($this->graphicProp->getElement());
  199.             }
  200.         }
  201.         return $this->graphicProp;
  202.     }
  203. }
  204. ?>

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