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

Source for file Comment.php

Documentation is available at Comment.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  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   PHPExcel
  22.  * @package    PHPExcel
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.5, 2009-01-05
  26.  */
  27.  
  28.  
  29. /** PHPExcel_RichText */
  30. require_once 'PHPExcel/RichText.php';
  31.  
  32. /** PHPExcel_Style_Color */
  33. require_once 'PHPExcel/Style/Color.php';
  34.  
  35. /** PHPExcel_IComparable */
  36. require_once 'PHPExcel/IComparable.php';
  37.  
  38.  
  39. /**
  40.  * PHPExcel_Comment
  41.  *
  42.  * @category   PHPExcel
  43.  * @package    PHPExcel
  44.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  45.  */
  46. class PHPExcel_Comment implements PHPExcel_IComparable
  47. {
  48.     /**
  49.      * Author
  50.      *
  51.      * @var string 
  52.      */
  53.     private $_author;
  54.     
  55.     /**
  56.      * Rich text comment
  57.      *
  58.      * @var PHPExcel_RichText 
  59.      */
  60.     private $_text;
  61.     
  62.     /**
  63.      * Comment width (CSS style, i.e. XXpx or YYpt)
  64.      *
  65.      * @var string 
  66.      */
  67.     private $_width = '96pt';
  68.     
  69.     /**
  70.      * Left margin (CSS style, i.e. XXpx or YYpt)
  71.      *
  72.      * @var string 
  73.      */
  74.     private $_marginLeft = '59.25pt';
  75.     
  76.     /**
  77.      * Top margin (CSS style, i.e. XXpx or YYpt)
  78.      *
  79.      * @var string 
  80.      */
  81.     private $_marginTop = '1.5pt';
  82.     
  83.     /**
  84.      * Visible
  85.      *
  86.      * @var boolean 
  87.      */
  88.     private $_visible = false;
  89.     
  90.     /**
  91.      * Comment height (CSS style, i.e. XXpx or YYpt)
  92.      *
  93.      * @var string 
  94.      */
  95.     private $_height = '55.5pt';
  96.     
  97.     /**
  98.      * Comment fill color
  99.      *
  100.      * @var PHPExcel_Style_Color 
  101.      */
  102.     private $_fillColor;
  103.         
  104.     /**
  105.      * Create a new PHPExcel_Comment
  106.      * 
  107.      * @throws    Exception
  108.      */
  109.     public function __construct()
  110.     {
  111.         // Initialise variables
  112.         $this->_author          = 'Author';
  113.         $this->_text          = new PHPExcel_RichText();
  114.         $this->_fillColor     = new PHPExcel_Style_Color('FFFFFFE1');
  115.     }
  116.     
  117.     /**
  118.      * Get Author
  119.      *
  120.      * @return string 
  121.      */
  122.     public function getAuthor({
  123.         return $this->_author;
  124.     }
  125.     
  126.     /**
  127.      * Set Author
  128.      *
  129.      * @param string $pValue 
  130.      */
  131.     public function setAuthor($pValue ''{
  132.         $this->_author = $pValue;
  133.     }
  134.     
  135.     /**
  136.      * Get Rich text comment
  137.      *
  138.      * @return PHPExcel_RichText 
  139.      */
  140.     public function getText({
  141.         return $this->_text;
  142.     }
  143.     
  144.     /**
  145.      * Set Rich text comment
  146.      *
  147.      * @param PHPExcel_RichText $pValue 
  148.      */
  149.     public function setText(PHPExcel_RichText $pValue{
  150.         $this->_text = $pValue;
  151.     }
  152.     
  153.     /**
  154.      * Get comment width (CSS style, i.e. XXpx or YYpt)
  155.      *
  156.      * @return string 
  157.      */
  158.     public function getWidth({
  159.         return $this->_width;
  160.     }
  161.     
  162.     /**
  163.      * Set comment width (CSS style, i.e. XXpx or YYpt)
  164.      *
  165.      * @param string $value 
  166.      */
  167.     public function setWidth($value '96pt'{
  168.         $this->_width = $value;
  169.     }
  170.     
  171.     /**
  172.      * Get comment height (CSS style, i.e. XXpx or YYpt)
  173.      *
  174.      * @return string 
  175.      */
  176.     public function getHeight({
  177.         return $this->_height;
  178.     }
  179.     
  180.     /**
  181.      * Set comment height (CSS style, i.e. XXpx or YYpt)
  182.      *
  183.      * @param string $value 
  184.      */
  185.     public function setHeight($value '55.5pt'{
  186.         $this->_height = $value;
  187.     }
  188.     
  189.     /**
  190.      * Get left margin (CSS style, i.e. XXpx or YYpt)
  191.      *
  192.      * @return string 
  193.      */
  194.     public function getMarginLeft({
  195.         return $this->_marginLeft;
  196.     }
  197.     
  198.     /**
  199.      * Set left margin (CSS style, i.e. XXpx or YYpt)
  200.      *
  201.      * @param string $value 
  202.      */
  203.     public function setMarginLeft($value '59.25pt'{
  204.         $this->_marginLeft = $value;
  205.     }
  206.     
  207.     /**
  208.      * Get top margin (CSS style, i.e. XXpx or YYpt)
  209.      *
  210.      * @return string 
  211.      */
  212.     public function getMarginTop({
  213.         return $this->_marginTop;
  214.     }
  215.     
  216.     /**
  217.      * Set top margin (CSS style, i.e. XXpx or YYpt)
  218.      *
  219.      * @param string $value 
  220.      */
  221.     public function setMarginTop($value '1.5pt'{
  222.         $this->_marginTop = $value;
  223.     }
  224.     
  225.     /**
  226.      * Is the comment visible by default?
  227.      *
  228.      * @return boolean 
  229.      */
  230.     public function getVisible({
  231.         return $this->_visible;
  232.     }
  233.     
  234.     /**
  235.      * Set comment default visibility
  236.      *
  237.      * @param boolean $value 
  238.      */
  239.     public function setVisible($value false{
  240.         $this->_visible = $value;   
  241.     }
  242.     
  243.     /**
  244.      * Get fill color
  245.      *
  246.      * @return PHPExcel_Style_Color 
  247.      */
  248.     public function getFillColor({
  249.         return $this->_fillColor;
  250.     }
  251.     
  252.     /**
  253.      * Get hash code
  254.      *
  255.      * @return string    Hash code
  256.      */    
  257.     public function getHashCode({
  258.         return md5(
  259.               $this->_author
  260.             . $this->_text->getHashCode()
  261.             . $this->_width
  262.             . $this->_height
  263.             . $this->_marginLeft
  264.             . $this->_marginTop
  265.             . ($this->_visible ? 0)
  266.             . $this->_fillColor->getHashCode()
  267.             . __CLASS__
  268.         );
  269.     }
  270.     
  271.     /**
  272.      * Hash index
  273.      *
  274.      * @var string 
  275.      */
  276.     private $_hashIndex;
  277.     
  278.     /**
  279.      * Get hash index
  280.      * 
  281.      * Note that this index may vary during script execution! Only reliable moment is
  282.      * while doing a write of a workbook and when changes are not allowed.
  283.      *
  284.      * @return string    Hash index
  285.      */
  286.     public function getHashIndex({
  287.         return $this->_hashIndex;
  288.     }
  289.     
  290.     /**
  291.      * Set hash index
  292.      * 
  293.      * Note that this index may vary during script execution! Only reliable moment is
  294.      * while doing a write of a workbook and when changes are not allowed.
  295.      *
  296.      * @param string    $value    Hash index
  297.      */
  298.     public function setHashIndex($value{
  299.         $this->_hashIndex = $value;
  300.     }
  301.         
  302.     /**
  303.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  304.      */
  305.     public function __clone({
  306.         $vars get_object_vars($this);
  307.         foreach ($vars as $key => $value{
  308.             if (is_object($value)) {
  309.                 $this->$key clone $value;
  310.             else {
  311.                 $this->$key $value;
  312.             }
  313.         }
  314.     }
  315. }

Documentation generated on Mon, 05 Jan 2009 20:36:42 +0100 by phpDocumentor 1.4.1