[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/ -> Comment.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_Comment
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_Comment implements PHPExcel_IComparable
  29  {
  30      /**
  31       * Author
  32       *
  33       * @var string
  34       */
  35      private $author;
  36  
  37      /**
  38       * Rich text comment
  39       *
  40       * @var PHPExcel_RichText
  41       */
  42      private $text;
  43  
  44      /**
  45       * Comment width (CSS style, i.e. XXpx or YYpt)
  46       *
  47       * @var string
  48       */
  49      private $width = '96pt';
  50  
  51      /**
  52       * Left margin (CSS style, i.e. XXpx or YYpt)
  53       *
  54       * @var string
  55       */
  56      private $marginLeft = '59.25pt';
  57  
  58      /**
  59       * Top margin (CSS style, i.e. XXpx or YYpt)
  60       *
  61       * @var string
  62       */
  63      private $marginTop = '1.5pt';
  64  
  65      /**
  66       * Visible
  67       *
  68       * @var boolean
  69       */
  70      private $visible = false;
  71  
  72      /**
  73       * Comment height (CSS style, i.e. XXpx or YYpt)
  74       *
  75       * @var string
  76       */
  77      private $height = '55.5pt';
  78  
  79      /**
  80       * Comment fill color
  81       *
  82       * @var PHPExcel_Style_Color
  83       */
  84      private $fillColor;
  85  
  86      /**
  87       * Alignment
  88       *
  89       * @var string
  90       */
  91      private $alignment;
  92  
  93      /**
  94       * Create a new PHPExcel_Comment
  95       *
  96       * @throws PHPExcel_Exception
  97       */
  98      public function __construct()
  99      {
 100          // Initialise variables
 101          $this->author    = 'Author';
 102          $this->text      = new PHPExcel_RichText();
 103          $this->fillColor = new PHPExcel_Style_Color('FFFFFFE1');
 104          $this->alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
 105      }
 106  
 107      /**
 108       * Get Author
 109       *
 110       * @return string
 111       */
 112      public function getAuthor()
 113      {
 114          return $this->author;
 115      }
 116  
 117      /**
 118       * Set Author
 119       *
 120       * @param string $pValue
 121       * @return PHPExcel_Comment
 122       */
 123      public function setAuthor($pValue = '')
 124      {
 125          $this->author = $pValue;
 126          return $this;
 127      }
 128  
 129      /**
 130       * Get Rich text comment
 131       *
 132       * @return PHPExcel_RichText
 133       */
 134      public function getText()
 135      {
 136          return $this->text;
 137      }
 138  
 139      /**
 140       * Set Rich text comment
 141       *
 142       * @param PHPExcel_RichText $pValue
 143       * @return PHPExcel_Comment
 144       */
 145      public function setText(PHPExcel_RichText $pValue)
 146      {
 147          $this->text = $pValue;
 148          return $this;
 149      }
 150  
 151      /**
 152       * Get comment width (CSS style, i.e. XXpx or YYpt)
 153       *
 154       * @return string
 155       */
 156      public function getWidth()
 157      {
 158          return $this->width;
 159      }
 160  
 161      /**
 162       * Set comment width (CSS style, i.e. XXpx or YYpt)
 163       *
 164       * @param string $value
 165       * @return PHPExcel_Comment
 166       */
 167      public function setWidth($value = '96pt')
 168      {
 169          $this->width = $value;
 170          return $this;
 171      }
 172  
 173      /**
 174       * Get comment height (CSS style, i.e. XXpx or YYpt)
 175       *
 176       * @return string
 177       */
 178      public function getHeight()
 179      {
 180          return $this->height;
 181      }
 182  
 183      /**
 184       * Set comment height (CSS style, i.e. XXpx or YYpt)
 185       *
 186       * @param string $value
 187       * @return PHPExcel_Comment
 188       */
 189      public function setHeight($value = '55.5pt')
 190      {
 191          $this->height = $value;
 192          return $this;
 193      }
 194  
 195      /**
 196       * Get left margin (CSS style, i.e. XXpx or YYpt)
 197       *
 198       * @return string
 199       */
 200      public function getMarginLeft()
 201      {
 202          return $this->marginLeft;
 203      }
 204  
 205      /**
 206       * Set left margin (CSS style, i.e. XXpx or YYpt)
 207       *
 208       * @param string $value
 209       * @return PHPExcel_Comment
 210       */
 211      public function setMarginLeft($value = '59.25pt')
 212      {
 213          $this->marginLeft = $value;
 214          return $this;
 215      }
 216  
 217      /**
 218       * Get top margin (CSS style, i.e. XXpx or YYpt)
 219       *
 220       * @return string
 221       */
 222      public function getMarginTop()
 223      {
 224          return $this->marginTop;
 225      }
 226  
 227      /**
 228       * Set top margin (CSS style, i.e. XXpx or YYpt)
 229       *
 230       * @param string $value
 231       * @return PHPExcel_Comment
 232       */
 233      public function setMarginTop($value = '1.5pt')
 234      {
 235          $this->marginTop = $value;
 236          return $this;
 237      }
 238  
 239      /**
 240       * Is the comment visible by default?
 241       *
 242       * @return boolean
 243       */
 244      public function getVisible()
 245      {
 246          return $this->visible;
 247      }
 248  
 249      /**
 250       * Set comment default visibility
 251       *
 252       * @param boolean $value
 253       * @return PHPExcel_Comment
 254       */
 255      public function setVisible($value = false)
 256      {
 257          $this->visible = $value;
 258          return $this;
 259      }
 260  
 261      /**
 262       * Get fill color
 263       *
 264       * @return PHPExcel_Style_Color
 265       */
 266      public function getFillColor()
 267      {
 268          return $this->fillColor;
 269      }
 270  
 271      /**
 272       * Set Alignment
 273       *
 274       * @param string $pValue
 275       * @return PHPExcel_Comment
 276       */
 277      public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
 278      {
 279          $this->alignment = $pValue;
 280          return $this;
 281      }
 282  
 283      /**
 284       * Get Alignment
 285       *
 286       * @return string
 287       */
 288      public function getAlignment()
 289      {
 290          return $this->alignment;
 291      }
 292  
 293      /**
 294       * Get hash code
 295       *
 296       * @return string    Hash code
 297       */
 298      public function getHashCode()
 299      {
 300          return md5(
 301              $this->author .
 302              $this->text->getHashCode() .
 303              $this->width .
 304              $this->height .
 305              $this->marginLeft .
 306              $this->marginTop .
 307              ($this->visible ? 1 : 0) .
 308              $this->fillColor->getHashCode() .
 309              $this->alignment .
 310              __CLASS__
 311          );
 312      }
 313  
 314      /**
 315       * Implement PHP __clone to create a deep clone, not just a shallow copy.
 316       */
 317      public function __clone()
 318      {
 319          $vars = get_object_vars($this);
 320          foreach ($vars as $key => $value) {
 321              if (is_object($value)) {
 322                  $this->$key = clone $value;
 323              } else {
 324                  $this->$key = $value;
 325              }
 326          }
 327      }
 328  
 329      /**
 330       * Convert to string
 331       *
 332       * @return string
 333       */
 334      public function __toString()
 335      {
 336          return $this->text->getPlainText();
 337      }
 338  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1