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

Source for file Font.php

Documentation is available at Font.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_Font
  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_Font implements PHPPowerPoint_IComparable
  44. {
  45.     /* Underline types */
  46.     const UNDERLINE_NONE                    'none';
  47.     const UNDERLINE_DASH                    'dash';
  48.     const UNDERLINE_DASHHEAVY                'dashHeavy';
  49.     const UNDERLINE_DASHLONG                'dashLong';
  50.     const UNDERLINE_DASHLONGHEAVY            'dashLongHeavy';
  51.     const UNDERLINE_DOUBLE                    'dbl';
  52.     const UNDERLINE_DOTHASH                    'dotDash';
  53.     const UNDERLINE_DOTHASHHEAVY            'dotDashHeavy';
  54.     const UNDERLINE_DOTDOTDASH                'dotDotDash';
  55.     const UNDERLINE_DOTDOTDASHHEAVY            'dotDotDashHeavy';
  56.     const UNDERLINE_DOTTED                    'dotted';
  57.     const UNDERLINE_DOTTEDHEAVY                'dottedHeavy';
  58.     const UNDERLINE_HEAVY                    'heavy';
  59.     const UNDERLINE_SINGLE                    'sng';
  60.     const UNDERLINE_WAVY                    'wavy';
  61.     const UNDERLINE_WAVYDOUBLE                'wavyDbl';
  62.     const UNDERLINE_WAVYHEAVY                'wavyHeavy';
  63.     const UNDERLINE_WORDS                    'words';
  64.     
  65.     /**
  66.      * Name
  67.      *
  68.      * @var string 
  69.      */
  70.     private $_name;
  71.     
  72.     /**
  73.      * Bold
  74.      *
  75.      * @var boolean 
  76.      */
  77.     private $_bold;
  78.     
  79.     /**
  80.      * Italic
  81.      *
  82.      * @var boolean 
  83.      */
  84.     private $_italic;
  85.     
  86.     /**
  87.      * Superscript
  88.      *
  89.      * @var boolean 
  90.      */
  91.     private $_superScript;
  92.     
  93.     /**
  94.      * Subscript
  95.      *
  96.      * @var boolean 
  97.      */
  98.     private $_subScript;
  99.     
  100.     /**
  101.      * Underline
  102.      *
  103.      * @var string 
  104.      */
  105.     private $_underline;
  106.     
  107.     /**
  108.      * Strikethrough
  109.      *
  110.      * @var boolean 
  111.      */
  112.     private $_strikethrough;
  113.     
  114.     /**
  115.      * Foreground color
  116.      * 
  117.      * @var PHPPowerPoint_Style_Color 
  118.      */
  119.     private $_color;    
  120.         
  121.     /**
  122.      * Create a new PHPPowerPoint_Style_Font
  123.      */
  124.     public function __construct()
  125.     {
  126.         // Initialise values
  127.         $this->_name                = 'Calibri';
  128.         $this->_size                10;
  129.         $this->_bold                = false;
  130.         $this->_italic                = false;
  131.         $this->_superScript            = false;
  132.         $this->_subScript            = false;
  133.         $this->_underline            = PHPPowerPoint_Style_Font::UNDERLINE_NONE;
  134.         $this->_strikethrough        = false;
  135.         $this->_color                = new PHPPowerPoint_Style_Color(PHPPowerPoint_Style_Color::COLOR_BLACK);
  136.     }
  137.     
  138.     /**
  139.      * Get Name
  140.      *
  141.      * @return string 
  142.      */
  143.     public function getName({
  144.         return $this->_name;
  145.     }
  146.     
  147.     /**
  148.      * Set Name
  149.      *
  150.      * @param string $pValue 
  151.      */
  152.     public function setName($pValue 'Calibri'{
  153.            if ($pValue == ''{
  154.             $pValue 'Calibri';
  155.         }
  156.         $this->_name = $pValue;
  157.     }
  158.     
  159.     /**
  160.      * Get Size
  161.      *
  162.      * @return double 
  163.      */
  164.     public function getSize({
  165.         return $this->_size;
  166.     }
  167.     
  168.     /**
  169.      * Set Size
  170.      *
  171.      * @param double $pValue 
  172.      */
  173.     public function setSize($pValue 10{
  174.         if ($pValue == ''{
  175.             $pValue 10;
  176.         }
  177.         $this->_size $pValue;
  178.     }
  179.     
  180.     /**
  181.      * Get Bold
  182.      *
  183.      * @return boolean 
  184.      */
  185.     public function getBold({
  186.         return $this->_bold;
  187.     }
  188.     
  189.     /**
  190.      * Set Bold
  191.      *
  192.      * @param boolean $pValue 
  193.      */
  194.     public function setBold($pValue false{
  195.         if ($pValue == ''{
  196.             $pValue false;
  197.         }
  198.         $this->_bold = $pValue;
  199.     }
  200.     
  201.     /**
  202.      * Get Italic
  203.      *
  204.      * @return boolean 
  205.      */
  206.     public function getItalic({
  207.         return $this->_italic;
  208.     }
  209.     
  210.     /**
  211.      * Set Italic
  212.      *
  213.      * @param boolean $pValue 
  214.      */
  215.     public function setItalic($pValue false{
  216.         if ($pValue == ''{
  217.             $pValue false;
  218.         }
  219.         $this->_italic = $pValue;
  220.     }
  221.     
  222.     /**
  223.      * Get SuperScript
  224.      *
  225.      * @return boolean 
  226.      */
  227.     public function getSuperScript({
  228.         return $this->_superScript;
  229.     }
  230.     
  231.     /**
  232.      * Set SuperScript
  233.      *
  234.      * @param boolean $pValue 
  235.      */
  236.     public function setSuperScript($pValue false{
  237.         if ($pValue == ''{
  238.             $pValue false;
  239.         }
  240.         $this->_superScript = $pValue;
  241.         $this->_subScript = !$pValue;
  242.     }
  243.     
  244.         /**
  245.      * Get SubScript
  246.      *
  247.      * @return boolean 
  248.      */
  249.     public function getSubScript({
  250.         return $this->_subScript;
  251.     }
  252.     
  253.     /**
  254.      * Set SubScript
  255.      *
  256.      * @param boolean $pValue 
  257.      */
  258.     public function setSubScript($pValue false{
  259.         if ($pValue == ''{
  260.             $pValue false;
  261.         }
  262.         $this->_subScript = $pValue;
  263.         $this->_superScript = !$pValue;
  264.     }
  265.     
  266.     /**
  267.      * Get Underline
  268.      *
  269.      * @return string 
  270.      */
  271.     public function getUnderline({
  272.         return $this->_underline;
  273.     }
  274.     
  275.     /**
  276.      * Set Underline
  277.      *
  278.      * @param string $pValue    PHPPowerPoint_Style_Font underline type
  279.      */
  280.     public function setUnderline($pValue PHPPowerPoint_Style_Font::UNDERLINE_NONE{
  281.         if ($pValue == ''{
  282.             $pValue PHPPowerPoint_Style_Font::UNDERLINE_NONE;
  283.         }
  284.         $this->_underline = $pValue;
  285.     }
  286.     
  287.     /**
  288.      * Get Striketrough
  289.      *
  290.      * @deprecated Use getStrikethrough() instead.
  291.      * @return boolean 
  292.      */
  293.     public function getStriketrough({
  294.         return $this->getStrikethrough();
  295.     }
  296.     
  297.     /**
  298.      * Set Striketrough
  299.      *
  300.      * @deprecated Use setStrikethrough() instead.
  301.      * @param boolean $pValue 
  302.      */
  303.     public function setStriketrough($pValue false{
  304.         $this->setStrikethrough($pValue);
  305.     }
  306.     
  307.     /**
  308.      * Get Strikethrough
  309.      *
  310.      * @return boolean 
  311.      */
  312.     public function getStrikethrough({
  313.         return $this->_strikethrough;
  314.     }
  315.     
  316.     /**
  317.      * Set Strikethrough
  318.      *
  319.      * @param boolean $pValue 
  320.      */
  321.     public function setStrikethrough($pValue false{
  322.         if ($pValue == ''{
  323.             $pValue false;
  324.         }
  325.         $this->_strikethrough = $pValue;
  326.     }
  327.  
  328.     /**
  329.      * Get Color
  330.      *
  331.      * @return PHPPowerPoint_Style_Color 
  332.      */
  333.     public function getColor({
  334.         return $this->_color;
  335.     }
  336.     
  337.     /**
  338.      * Set Color
  339.      *
  340.      * @param     PHPPowerPoint_Style_Color $pValue 
  341.      * @throws     Exception
  342.      */
  343.     public function setColor(PHPPowerPoint_Style_Color $pValue null{
  344.            $this->_color = $pValue;
  345.     }
  346.  
  347.     /**
  348.      * Get hash code
  349.      *
  350.      * @return string    Hash code
  351.      */    
  352.     public function getHashCode({
  353.         return md5(
  354.               $this->_name
  355.             . $this->_size
  356.             . ($this->_bold ? 't' 'f')
  357.             . ($this->_italic ? 't' 'f')
  358.             . ($this->_superScript ? 't' 'f')
  359.             . ($this->_subScript ? 't' 'f')
  360.             . $this->_underline
  361.             . ($this->_strikethrough ? 't' 'f')
  362.             . $this->_color->getHashCode()
  363.             . __CLASS__
  364.         );
  365.     }
  366.     
  367.     /**
  368.      * Hash index
  369.      *
  370.      * @var string 
  371.      */
  372.     private $_hashIndex;
  373.     
  374.     /**
  375.      * Get hash index
  376.      * 
  377.      * Note that this index may vary during script execution! Only reliable moment is
  378.      * while doing a write of a workbook and when changes are not allowed.
  379.      *
  380.      * @return string    Hash index
  381.      */
  382.     public function getHashIndex({
  383.         return $this->_hashIndex;
  384.     }
  385.     
  386.     /**
  387.      * Set hash index
  388.      * 
  389.      * Note that this index may vary during script execution! Only reliable moment is
  390.      * while doing a write of a workbook and when changes are not allowed.
  391.      *
  392.      * @param string    $value    Hash index
  393.      */
  394.     public function setHashIndex($value{
  395.         $this->_hashIndex = $value;
  396.     }
  397.         
  398.     /**
  399.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  400.      */
  401.     public function __clone({
  402.         $vars get_object_vars($this);
  403.         foreach ($vars as $key => $value{
  404.             if (is_object($value)) {
  405.                 $this->$key clone $value;
  406.             else {
  407.                 $this->$key $value;
  408.             }
  409.         }
  410.     }
  411. }

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