PhpSpreadsheet/Classes/PHPExcel/Comment.php

339 lines
6.9 KiB
PHP
Raw Normal View History

<?php
/**
* PHPExcel_Comment
*
2015-05-02 22:50:37 +00:00
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
2015-05-02 22:50:37 +00:00
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
2013-01-22 19:56:41 +00:00
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Comment implements PHPExcel_IComparable
{
2013-01-22 19:56:41 +00:00
/**
* Author
*
* @var string
*/
private $_author;
2013-01-22 19:56:41 +00:00
/**
* Rich text comment
*
* @var PHPExcel_RichText
*/
private $_text;
2013-01-22 19:56:41 +00:00
/**
* Comment width (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_width = '96pt';
2013-01-22 19:56:41 +00:00
/**
* Left margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginLeft = '59.25pt';
2013-01-22 19:56:41 +00:00
/**
* Top margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginTop = '1.5pt';
2013-01-22 19:56:41 +00:00
/**
* Visible
*
* @var boolean
*/
private $_visible = false;
2013-01-22 19:56:41 +00:00
/**
* Comment height (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_height = '55.5pt';
2013-01-22 19:56:41 +00:00
/**
* Comment fill color
*
* @var PHPExcel_Style_Color
*/
private $_fillColor;
2013-01-22 19:56:41 +00:00
/**
* Alignment
*
* @var string
*/
private $_alignment;
/**
* Create a new PHPExcel_Comment
*
* @throws PHPExcel_Exception
*/
public function __construct()
{
2013-01-22 19:56:41 +00:00
// Initialise variables
2015-05-15 10:55:10 +00:00
$this->_author = 'Author';
$this->_text = new PHPExcel_RichText();
2015-05-15 10:55:10 +00:00
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
/**
* Get Author
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getAuthor()
{
2013-01-22 19:56:41 +00:00
return $this->_author;
}
/**
* Set Author
*
* @param string $pValue
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setAuthor($pValue = '')
{
2013-01-22 19:56:41 +00:00
$this->_author = $pValue;
return $this;
}
/**
* Get Rich text comment
*
* @return PHPExcel_RichText
*/
2015-05-15 10:55:10 +00:00
public function getText()
{
2013-01-22 19:56:41 +00:00
return $this->_text;
}
/**
* Set Rich text comment
*
* @param PHPExcel_RichText $pValue
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setText(PHPExcel_RichText $pValue)
{
2013-01-22 19:56:41 +00:00
$this->_text = $pValue;
return $this;
}
/**
* Get comment width (CSS style, i.e. XXpx or YYpt)
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getWidth()
{
return $this->_width;
}
/**
* Set comment width (CSS style, i.e. XXpx or YYpt)
*
* @param string $value
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setWidth($value = '96pt')
{
$this->_width = $value;
return $this;
}
/**
* Get comment height (CSS style, i.e. XXpx or YYpt)
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getHeight()
{
return $this->_height;
}
/**
* Set comment height (CSS style, i.e. XXpx or YYpt)
*
* @param string $value
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setHeight($value = '55.5pt')
{
$this->_height = $value;
return $this;
}
/**
* Get left margin (CSS style, i.e. XXpx or YYpt)
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getMarginLeft()
{
return $this->_marginLeft;
}
/**
* Set left margin (CSS style, i.e. XXpx or YYpt)
*
* @param string $value
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setMarginLeft($value = '59.25pt')
{
$this->_marginLeft = $value;
return $this;
}
/**
* Get top margin (CSS style, i.e. XXpx or YYpt)
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getMarginTop()
{
return $this->_marginTop;
}
/**
* Set top margin (CSS style, i.e. XXpx or YYpt)
*
* @param string $value
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setMarginTop($value = '1.5pt')
{
$this->_marginTop = $value;
return $this;
}
/**
* Is the comment visible by default?
*
* @return boolean
*/
2015-05-15 10:55:10 +00:00
public function getVisible()
{
return $this->_visible;
}
/**
* Set comment default visibility
*
* @param boolean $value
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setVisible($value = false)
{
$this->_visible = $value;
return $this;
}
/**
* Get fill color
*
* @return PHPExcel_Style_Color
*/
2015-05-15 10:55:10 +00:00
public function getFillColor()
{
return $this->_fillColor;
}
/**
* Set Alignment
*
* @param string $pValue
* @return PHPExcel_Comment
*/
2015-05-15 10:55:10 +00:00
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL)
{
2013-01-22 19:56:41 +00:00
$this->_alignment = $pValue;
return $this;
}
/**
* Get Alignment
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function getAlignment()
{
2013-01-22 19:56:41 +00:00
return $this->_alignment;
}
2013-01-22 19:56:41 +00:00
/**
* Get hash code
*
* @return string Hash code
*/
2015-05-15 10:55:10 +00:00
public function getHashCode()
{
2013-01-22 19:56:41 +00:00
return md5(
2015-05-15 10:55:10 +00:00
$this->_author
2013-01-22 19:56:41 +00:00
. $this->_text->getHashCode()
. $this->_width
. $this->_height
. $this->_marginLeft
. $this->_marginTop
. ($this->_visible ? 1 : 0)
. $this->_fillColor->getHashCode()
. $this->_alignment
. __CLASS__
);
}
2013-01-22 19:56:41 +00:00
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
2015-05-15 10:55:10 +00:00
public function __clone()
{
2013-01-22 19:56:41 +00:00
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
2013-04-27 15:02:07 +00:00
/**
* Convert to string
*
* @return string
*/
2015-05-15 10:55:10 +00:00
public function __toString()
{
return $this->_text->getPlainText();
}
}