Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet; 4 5 use PhpOffice\PhpSpreadsheet\RichText\RichText; 6 7 class Comment implements IComparable 8 { 9 /** 10 * Author. 11 * 12 * @var string 13 */ 14 private $author; 15 16 /** 17 * Rich text comment. 18 * 19 * @var RichText 20 */ 21 private $text; 22 23 /** 24 * Comment width (CSS style, i.e. XXpx or YYpt). 25 * 26 * @var string 27 */ 28 private $width = '96pt'; 29 30 /** 31 * Left margin (CSS style, i.e. XXpx or YYpt). 32 * 33 * @var string 34 */ 35 private $marginLeft = '59.25pt'; 36 37 /** 38 * Top margin (CSS style, i.e. XXpx or YYpt). 39 * 40 * @var string 41 */ 42 private $marginTop = '1.5pt'; 43 44 /** 45 * Visible. 46 * 47 * @var bool 48 */ 49 private $visible = false; 50 51 /** 52 * Comment height (CSS style, i.e. XXpx or YYpt). 53 * 54 * @var string 55 */ 56 private $height = '55.5pt'; 57 58 /** 59 * Comment fill color. 60 * 61 * @var Style\Color 62 */ 63 private $fillColor; 64 65 /** 66 * Alignment. 67 * 68 * @var string 69 */ 70 private $alignment; 71 72 /** 73 * Create a new Comment. 74 */ 75 public function __construct() 76 { 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; 82 } 83 84 /** 85 * Get Author. 86 * 87 * @return string 88 */ 89 public function getAuthor() 90 { 91 return $this->author; 92 } 93 94 /** 95 * Set Author. 96 * 97 * @param string $author 98 * 99 * @return $this 100 */ 101 public function setAuthor($author) 102 { 103 $this->author = $author; 104 105 return $this; 106 } 107 108 /** 109 * Get Rich text comment. 110 * 111 * @return RichText 112 */ 113 public function getText() 114 { 115 return $this->text; 116 } 117 118 /** 119 * Set Rich text comment. 120 * 121 * @return $this 122 */ 123 public function setText(RichText $pValue) 124 { 125 $this->text = $pValue; 126 127 return $this; 128 } 129 130 /** 131 * Get comment width (CSS style, i.e. XXpx or YYpt). 132 * 133 * @return string 134 */ 135 public function getWidth() 136 { 137 return $this->width; 138 } 139 140 /** 141 * Set comment width (CSS style, i.e. XXpx or YYpt). 142 * 143 * @param string $width 144 * 145 * @return $this 146 */ 147 public function setWidth($width) 148 { 149 $this->width = $width; 150 151 return $this; 152 } 153 154 /** 155 * Get comment height (CSS style, i.e. XXpx or YYpt). 156 * 157 * @return string 158 */ 159 public function getHeight() 160 { 161 return $this->height; 162 } 163 164 /** 165 * Set comment height (CSS style, i.e. XXpx or YYpt). 166 * 167 * @param string $value 168 * 169 * @return $this 170 */ 171 public function setHeight($value) 172 { 173 $this->height = $value; 174 175 return $this; 176 } 177 178 /** 179 * Get left margin (CSS style, i.e. XXpx or YYpt). 180 * 181 * @return string 182 */ 183 public function getMarginLeft() 184 { 185 return $this->marginLeft; 186 } 187 188 /** 189 * Set left margin (CSS style, i.e. XXpx or YYpt). 190 * 191 * @param string $value 192 * 193 * @return $this 194 */ 195 public function setMarginLeft($value) 196 { 197 $this->marginLeft = $value; 198 199 return $this; 200 } 201 202 /** 203 * Get top margin (CSS style, i.e. XXpx or YYpt). 204 * 205 * @return string 206 */ 207 public function getMarginTop() 208 { 209 return $this->marginTop; 210 } 211 212 /** 213 * Set top margin (CSS style, i.e. XXpx or YYpt). 214 * 215 * @param string $value 216 * 217 * @return $this 218 */ 219 public function setMarginTop($value) 220 { 221 $this->marginTop = $value; 222 223 return $this; 224 } 225 226 /** 227 * Is the comment visible by default? 228 * 229 * @return bool 230 */ 231 public function getVisible() 232 { 233 return $this->visible; 234 } 235 236 /** 237 * Set comment default visibility. 238 * 239 * @param bool $value 240 * 241 * @return $this 242 */ 243 public function setVisible($value) 244 { 245 $this->visible = $value; 246 247 return $this; 248 } 249 250 /** 251 * Get fill color. 252 * 253 * @return Style\Color 254 */ 255 public function getFillColor() 256 { 257 return $this->fillColor; 258 } 259 260 /** 261 * Set Alignment. 262 * 263 * @param string $alignment see Style\Alignment::HORIZONTAL_* 264 * 265 * @return $this 266 */ 267 public function setAlignment($alignment) 268 { 269 $this->alignment = $alignment; 270 271 return $this; 272 } 273 274 /** 275 * Get Alignment. 276 * 277 * @return string 278 */ 279 public function getAlignment() 280 { 281 return $this->alignment; 282 } 283 284 /** 285 * Get hash code. 286 * 287 * @return string Hash code 288 */ 289 public function getHashCode() 290 { 291 return md5( 292 $this->author . 293 $this->text->getHashCode() . 294 $this->width . 295 $this->height . 296 $this->marginLeft . 297 $this->marginTop . 298 ($this->visible ? 1 : 0) . 299 $this->fillColor->getHashCode() . 300 $this->alignment . 301 __CLASS__ 302 ); 303 } 304 305 /** 306 * Implement PHP __clone to create a deep clone, not just a shallow copy. 307 */ 308 public function __clone() 309 { 310 $vars = get_object_vars($this); 311 foreach ($vars as $key => $value) { 312 if (is_object($value)) { 313 $this->$key = clone $value; 314 } else { 315 $this->$key = $value; 316 } 317 } 318 } 319 320 /** 321 * Convert to string. 322 * 323 * @return string 324 */ 325 public function __toString() 326 { 327 return $this->text->getPlainText(); 328 } 329 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body