3 namespace PhpOffice\PhpSpreadsheet
;
5 use PhpOffice\PhpSpreadsheet\RichText\RichText
;
7 class Comment
implements IComparable
24 * Comment width (CSS style, i.e. XXpx or YYpt).
28 private $width = '96pt';
31 * Left margin (CSS style, i.e. XXpx or YYpt).
35 private $marginLeft = '59.25pt';
38 * Top margin (CSS style, i.e. XXpx or YYpt).
42 private $marginTop = '1.5pt';
49 private $visible = false;
52 * Comment height (CSS style, i.e. XXpx or YYpt).
56 private $height = '55.5pt';
73 * Create a new Comment.
75 public function __construct()
77 // Initialise variables
78 $this->author
= 'Author';
79 $this->text
= new RichText();
80 $this->fillColor
= new Style\
Color('FFFFFFE1');
81 $this->alignment
= Style\Alignment
::HORIZONTAL_GENERAL
;
89 public function getAuthor()
97 * @param string $author
101 public function setAuthor($author)
103 $this->author
= $author;
109 * Get Rich text comment.
113 public function getText()
119 * Set Rich text comment.
121 * @param RichText $pValue
125 public function setText(RichText
$pValue)
127 $this->text
= $pValue;
133 * Get comment width (CSS style, i.e. XXpx or YYpt).
137 public function getWidth()
143 * Set comment width (CSS style, i.e. XXpx or YYpt).
145 * @param string $width
149 public function setWidth($width)
151 $this->width
= $width;
157 * Get comment height (CSS style, i.e. XXpx or YYpt).
161 public function getHeight()
163 return $this->height
;
167 * Set comment height (CSS style, i.e. XXpx or YYpt).
169 * @param string $value
173 public function setHeight($value)
175 $this->height
= $value;
181 * Get left margin (CSS style, i.e. XXpx or YYpt).
185 public function getMarginLeft()
187 return $this->marginLeft
;
191 * Set left margin (CSS style, i.e. XXpx or YYpt).
193 * @param string $value
197 public function setMarginLeft($value)
199 $this->marginLeft
= $value;
205 * Get top margin (CSS style, i.e. XXpx or YYpt).
209 public function getMarginTop()
211 return $this->marginTop
;
215 * Set top margin (CSS style, i.e. XXpx or YYpt).
217 * @param string $value
221 public function setMarginTop($value)
223 $this->marginTop
= $value;
229 * Is the comment visible by default?
233 public function getVisible()
235 return $this->visible
;
239 * Set comment default visibility.
245 public function setVisible($value)
247 $this->visible
= $value;
255 * @return Style\Color
257 public function getFillColor()
259 return $this->fillColor
;
265 * @param string $alignment see Style\Alignment::HORIZONTAL_*
269 public function setAlignment($alignment)
271 $this->alignment
= $alignment;
281 public function getAlignment()
283 return $this->alignment
;
289 * @return string Hash code
291 public function getHashCode()
295 $this->text
->getHashCode() .
300 ($this->visible ?
1 : 0) .
301 $this->fillColor
->getHashCode() .
308 * Implement PHP __clone to create a deep clone, not just a shallow copy.
310 public function __clone()
312 $vars = get_object_vars($this);
313 foreach ($vars as $key => $value) {
314 if (is_object($value)) {
315 $this->$key = clone $value;
317 $this->$key = $value;
327 public function __toString()
329 return $this->text
->getPlainText();