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

Source for file Fill.php

Documentation is available at Fill.php

  1. <?php
  2. /**
  3.  * PHPPowerPoint
  4.  *
  5.  * Copyright (c) 2009 - 2010 PHPPowerPoint
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPPowerPoint
  22.  * @package    PHPPowerPoint_Style
  23.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    0.1.0, 2009-04-27
  26.  */
  27.  
  28.  
  29. /** PHPPowerPoint_Style_Color */
  30. require_once 'PHPPowerPoint/Style/Color.php';
  31.  
  32. /** PHPPowerPoint_IComparable */
  33. require_once 'PHPPowerPoint/IComparable.php';
  34.  
  35.  
  36. /**
  37.  * PHPPowerPoint_Style_Fill
  38.  *
  39.  * @category   PHPPowerPoint
  40.  * @package    PHPPowerPoint_Style
  41.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  42.  */
  43. class PHPPowerPoint_Style_Fill implements PHPPowerPoint_IComparable
  44. {
  45.     /* Fill types */
  46.     const FILL_NONE                            'none';
  47.     const FILL_SOLID                        'solid';
  48.     const FILL_GRADIENT_LINEAR                'linear';
  49.     const FILL_GRADIENT_PATH                'path';
  50.     const FILL_PATTERN_DARKDOWN                'darkDown';
  51.     const FILL_PATTERN_DARKGRAY                'darkGray';
  52.     const FILL_PATTERN_DARKGRID                'darkGrid';
  53.     const FILL_PATTERN_DARKHORIZONTAL        'darkHorizontal';
  54.     const FILL_PATTERN_DARKTRELLIS            'darkTrellis';
  55.     const FILL_PATTERN_DARKUP                'darkUp';
  56.     const FILL_PATTERN_DARKVERTICAL            'darkVertical';
  57.     const FILL_PATTERN_GRAY0625                'gray0625';
  58.     const FILL_PATTERN_GRAY125                'gray125';
  59.     const FILL_PATTERN_LIGHTDOWN            'lightDown';
  60.     const FILL_PATTERN_LIGHTGRAY            'lightGray';
  61.     const FILL_PATTERN_LIGHTGRID            'lightGrid';
  62.     const FILL_PATTERN_LIGHTHORIZONTAL        'lightHorizontal';
  63.     const FILL_PATTERN_LIGHTTRELLIS            'lightTrellis';
  64.     const FILL_PATTERN_LIGHTUP                'lightUp';
  65.     const FILL_PATTERN_LIGHTVERTICAL        'lightVertical';
  66.     const FILL_PATTERN_MEDIUMGRAY            'mediumGray';
  67.  
  68.     /**
  69.      * Fill type
  70.      *
  71.      * @var string 
  72.      */
  73.     private $_fillType;
  74.     
  75.     /**
  76.      * Rotation
  77.      *
  78.      * @var double 
  79.      */
  80.     private $_rotation;
  81.     
  82.     /**
  83.      * Start color
  84.      * 
  85.      * @var PHPPowerPoint_Style_Color 
  86.      */
  87.     private $_startColor;
  88.     
  89.     /**
  90.      * End color
  91.      * 
  92.      * @var PHPPowerPoint_Style_Color 
  93.      */
  94.     private $_endColor;
  95.         
  96.     /**
  97.      * Create a new PHPPowerPoint_Style_Fill
  98.      */
  99.     public function __construct()
  100.     {
  101.         // Initialise values
  102.         $this->_fillType            = PHPPowerPoint_Style_Fill::FILL_NONE;
  103.         $this->_rotation            = 0;
  104.         $this->_startColor            = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_WHITE);
  105.         $this->_endColor            = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
  106.     }
  107.     
  108.     /**
  109.      * Get Fill Type
  110.      *
  111.      * @return string 
  112.      */
  113.     public function getFillType({
  114.         $this->_fillType;
  115.     }
  116.     
  117.     /**
  118.      * Set Fill Type
  119.      *
  120.      * @param string $pValue    PHPPowerPoint_Style_Fill fill type
  121.      */
  122.     public function setFillType($pValue PHPPowerPoint_Style_Fill::FILL_NONE{
  123.         $this->_fillType = $pValue;
  124.     }
  125.     
  126.     /**
  127.      * Get Rotation
  128.      *
  129.      * @return double 
  130.      */
  131.     public function getRotation({
  132.         return $this->_rotation;
  133.     }
  134.     
  135.     /**
  136.      * Set Rotation
  137.      *
  138.      * @param double $pValue 
  139.      */
  140.     public function setRotation($pValue 0{
  141.         $this->_rotation = $pValue;
  142.     }
  143.     
  144.     /**
  145.      * Get Start Color
  146.      *
  147.      * @return PHPPowerPoint_Style_Color 
  148.      */
  149.     public function getStartColor({
  150.         // It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
  151.         // So bind as an assurance.
  152.         return $this->_startColor;
  153.     }
  154.     
  155.     /**
  156.      * Set Start Color
  157.      *
  158.      * @param     PHPPowerPoint_Style_Color $pValue 
  159.      * @throws     Exception
  160.      */
  161.     public function setStartColor(PHPPowerPoint_Style_Color $pValue null{
  162.            $this->_startColor = $pValue;
  163.     }
  164.     
  165.     /**
  166.      * Get End Color
  167.      *
  168.      * @return PHPPowerPoint_Style_Color 
  169.      */
  170.     public function getEndColor({
  171.         // It's a get but it may lead to a modified color which we won't detect but in which case we must bind.
  172.         // So bind as an assurance.
  173.         return $this->_endColor;
  174.     }
  175.     
  176.     /**
  177.      * Set End Color
  178.      *
  179.      * @param     PHPPowerPoint_Style_Color $pValue 
  180.      * @throws     Exception
  181.      */
  182.     public function setEndColor(PHPPowerPoint_Style_Color $pValue null{
  183.            $this->_endColor = $pValue;
  184.     }
  185.  
  186.     /**
  187.      * Get hash code
  188.      *
  189.      * @return string    Hash code
  190.      */    
  191.     public function getHashCode({
  192.         return md5(
  193.               $this->getFillType()
  194.             . $this->getRotation()
  195.             . $this->getStartColor()->getHashCode()
  196.             . $this->getEndColor()->getHashCode()
  197.             . __CLASS__
  198.         );
  199.     }
  200.     
  201.     /**
  202.      * Hash index
  203.      *
  204.      * @var string 
  205.      */
  206.     private $_hashIndex;
  207.     
  208.     /**
  209.      * Get hash index
  210.      * 
  211.      * Note that this index may vary during script execution! Only reliable moment is
  212.      * while doing a write of a workbook and when changes are not allowed.
  213.      *
  214.      * @return string    Hash index
  215.      */
  216.     public function getHashIndex({
  217.         return $this->_hashIndex;
  218.     }
  219.     
  220.     /**
  221.      * Set hash index
  222.      * 
  223.      * Note that this index may vary during script execution! Only reliable moment is
  224.      * while doing a write of a workbook and when changes are not allowed.
  225.      *
  226.      * @param string    $value    Hash index
  227.      */
  228.     public function setHashIndex($value{
  229.         $this->_hashIndex = $value;
  230.     }
  231.         
  232.     /**
  233.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  234.      */
  235.     public function __clone({
  236.         $vars get_object_vars($this);
  237.         foreach ($vars as $key => $value{
  238.             if (is_object($value)) {
  239.                 $this->$key clone $value;
  240.             else {
  241.                 $this->$key $value;
  242.             }
  243.         }
  244.     }
  245. }

Documentation generated on Sat, 25 Apr 2009 11:37:14 +0200 by phpDocumentor 1.4.1