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

Documentation generated on Mon, 10 Aug 2009 08:02:47 +0200 by phpDocumentor 1.4.1