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

Source for file Alignment.php

Documentation is available at Alignment.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_IComparable */
  30. require_once 'PHPPowerPoint/IComparable.php';
  31.  
  32.  
  33. /**
  34.  * PHPPowerPoint_Style_Alignment
  35.  *
  36.  * @category   PHPPowerPoint
  37.  * @package    PHPPowerPoint_Style
  38.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  39.  */
  40. class PHPPowerPoint_Style_Alignment implements PHPPowerPoint_IComparable
  41. {    
  42.     /* Horizontal alignment styles */
  43.     const HORIZONTAL_LEFT                    'l';
  44.     const HORIZONTAL_RIGHT                    'r';
  45.     const HORIZONTAL_CENTER                    'ctr';
  46.     const HORIZONTAL_JUSTIFY                'just';
  47.     const HORIZONTAL_DISTRIBUTED            'dist';
  48.     
  49.     /* Vertical alignment styles */
  50.     const VERTICAL_BASE                        'base';
  51.     const VERTICAL_AUTO                        'auto';
  52.     const VERTICAL_BOTTOM                    'b';
  53.     const VERTICAL_TOP                        't';
  54.     const VERTICAL_CENTER                    'ctr';
  55.     
  56.     /**
  57.      * Horizontal
  58.      *
  59.      * @var string 
  60.      */
  61.     private $_horizontal;
  62.     
  63.     /**
  64.      * Vertical
  65.      *
  66.      * @var string 
  67.      */
  68.     private $_vertical;
  69.     
  70.     /**
  71.      * Level
  72.      *
  73.      * @var int 
  74.      */
  75.     private $_level;
  76.     
  77.     /**
  78.      * Indent - only possible with horizontal alignment left and right
  79.      *
  80.      * @var int 
  81.      */
  82.     private $_indent;
  83.         
  84.     /**
  85.      * Create a new PHPPowerPoint_Style_Alignment
  86.      */
  87.     public function __construct()
  88.     {
  89.         // Initialise values
  90.         $this->_horizontal            = PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
  91.         $this->_vertical            = PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
  92.         $this->_level                = 0;
  93.         $this->_indent                = 0;
  94.     }
  95.     
  96.     /**
  97.      * Get Horizontal
  98.      *
  99.      * @return string 
  100.      */
  101.     public function getHorizontal({
  102.         return $this->_horizontal;
  103.     }
  104.     
  105.     /**
  106.      * Set Horizontal
  107.      *
  108.      * @param string $pValue 
  109.      */
  110.     public function setHorizontal($pValue PHPPowerPoint_Style_Alignment::HORIZONTAL_LEF{
  111.         if ($pValue == ''{
  112.             $pValue PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT;
  113.         }
  114.         $this->_horizontal = $pValue;
  115.     }
  116.     
  117.     /**
  118.      * Get Vertical
  119.      *
  120.      * @return string 
  121.      */
  122.     public function getVertical({
  123.         return $this->_vertical;
  124.     }
  125.     
  126.     /**
  127.      * Set Vertical
  128.      *
  129.      * @param string $pValue 
  130.      */
  131.     public function setVertical($pValue PHPPowerPoint_Style_Alignment::VERTICAL_BASE{
  132.         if ($pValue == ''{
  133.             $pValue PHPPowerPoint_Style_Alignment::VERTICAL_BASE;
  134.         }
  135.         $this->_vertical = $pValue;
  136.     }
  137.     
  138.     /**
  139.      * Get Level
  140.      *
  141.      * @return int 
  142.      */
  143.     public function getLevel({
  144.         return $this->_level;
  145.     }
  146.     
  147.     /**
  148.      * Set Level
  149.      *
  150.      * @param int $pValue Ranging 0 - 8
  151.      * @throws Exception
  152.      */
  153.     public function setLevel($pValue 0{
  154.         if ($pValue || $pValue 8{
  155.             throw new Exception("Invalid value: shoul be range 0 - 8.");
  156.         }
  157.         $this->_level = $pValue;
  158.     }
  159.     
  160.     /**
  161.      * Get indent
  162.      *
  163.      * @return int 
  164.      */
  165.     public function getIndent({
  166.         return $this->_indent;
  167.     }
  168.     
  169.     /**
  170.      * Set indent
  171.      *
  172.      * @param int $pValue 
  173.      */
  174.     public function setIndent($pValue 0{
  175.         if ($pValue 0{
  176.             if ($this->getHorizontal(!= self::HORIZONTAL_GENERAL && $this->getHorizontal(!= self::HORIZONTAL_LEFT && $this->getHorizontal(!= self::HORIZONTAL_RIGHT{
  177.                 $pValue 0// indent not supported
  178.             }
  179.         }
  180.         
  181.         $this->_indent = $pValue;
  182.     }
  183.     
  184.     /**
  185.      * Get hash code
  186.      *
  187.      * @return string    Hash code
  188.      */    
  189.     public function getHashCode({
  190.         return md5(
  191.               $this->_horizontal
  192.             . $this->_vertical
  193.             . $this->_level
  194.             . $this->_indent
  195.             . __CLASS__
  196.         );
  197.     }
  198.     
  199.     /**
  200.      * Hash index
  201.      *
  202.      * @var string 
  203.      */
  204.     private $_hashIndex;
  205.     
  206.     /**
  207.      * Get hash index
  208.      * 
  209.      * Note that this index may vary during script execution! Only reliable moment is
  210.      * while doing a write of a workbook and when changes are not allowed.
  211.      *
  212.      * @return string    Hash index
  213.      */
  214.     public function getHashIndex({
  215.         return $this->_hashIndex;
  216.     }
  217.     
  218.     /**
  219.      * Set hash index
  220.      * 
  221.      * Note that this index may vary during script execution! Only reliable moment is
  222.      * while doing a write of a workbook and when changes are not allowed.
  223.      *
  224.      * @param string    $value    Hash index
  225.      */
  226.     public function setHashIndex($value{
  227.         $this->_hashIndex = $value;
  228.     }
  229.     
  230.     /**
  231.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  232.      */
  233.     public function __clone({
  234.         $vars get_object_vars($this);
  235.         foreach ($vars as $key => $value{
  236.             if (is_object($value)) {
  237.                 $this->$key clone $value;
  238.             else {
  239.                 $this->$key $value;
  240.             }
  241.         }
  242.     }
  243. }

Documentation generated on Sat, 25 Apr 2009 11:36:38 +0200 by phpDocumentor 1.4.1