PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / trunk
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder vtrunk
6.2.15 6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 All 197 releases
fluentform / vendor / openspout / openspout / src / Common / Entity / Style / Style.php

Style.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder trunk, at vendor/openspout/openspout/src/Common/Entity/Style/Style.php

550 lines 11.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace OpenSpout\Common\Entity\Style;
4
5 /**
6 * Represents a style to be applied to a cell.
7 */
8 class Style
9 {
10 /** Default values */
11 public const DEFAULT_FONT_SIZE = 11;
12 public const DEFAULT_FONT_COLOR = Color::BLACK;
13 public const DEFAULT_FONT_NAME = 'Arial';
14
15 /** @var null|int Style ID */
16 private $id;
17
18 /** @var bool Whether the font should be bold */
19 private $fontBold = false;
20 /** @var bool Whether the bold property was set */
21 private $hasSetFontBold = false;
22
23 /** @var bool Whether the font should be italic */
24 private $fontItalic = false;
25 /** @var bool Whether the italic property was set */
26 private $hasSetFontItalic = false;
27
28 /** @var bool Whether the font should be underlined */
29 private $fontUnderline = false;
30 /** @var bool Whether the underline property was set */
31 private $hasSetFontUnderline = false;
32
33 /** @var bool Whether the font should be struck through */
34 private $fontStrikethrough = false;
35 /** @var bool Whether the strikethrough property was set */
36 private $hasSetFontStrikethrough = false;
37
38 /** @var int Font size */
39 private $fontSize = self::DEFAULT_FONT_SIZE;
40 /** @var bool Whether the font size property was set */
41 private $hasSetFontSize = false;
42
43 /** @var string Font color */
44 private $fontColor = self::DEFAULT_FONT_COLOR;
45 /** @var bool Whether the font color property was set */
46 private $hasSetFontColor = false;
47
48 /** @var string Font name */
49 private $fontName = self::DEFAULT_FONT_NAME;
50 /** @var bool Whether the font name property was set */
51 private $hasSetFontName = false;
52
53 /** @var bool Whether specific font properties should be applied */
54 private $shouldApplyFont = false;
55
56 /** @var bool Whether specific cell alignment should be applied */
57 private $shouldApplyCellAlignment = false;
58 /** @var string Cell alignment */
59 private $cellAlignment;
60 /** @var bool Whether the cell alignment property was set */
61 private $hasSetCellAlignment = false;
62
63 /** @var bool Whether the text should wrap in the cell (useful for long or multi-lines text) */
64 private $shouldWrapText = false;
65 /** @var bool Whether the wrap text property was set */
66 private $hasSetWrapText = false;
67
68 /** @var bool Whether the cell should shrink to fit to content */
69 private $shouldShrinkToFit = false;
70 /** @var bool Whether the shouldShrinkToFit text property was set */
71 private $hasSetShrinkToFit = false;
72
73 /** @var null|Border */
74 private $border;
75
76 /** @var bool Whether border properties should be applied */
77 private $shouldApplyBorder = false;
78
79 /** @var null|string Background color */
80 private $backgroundColor;
81
82 /** @var bool */
83 private $hasSetBackgroundColor = false;
84
85 /** @var null|string Format */
86 private $format;
87
88 /** @var bool */
89 private $hasSetFormat = false;
90
91 /** @var bool */
92 private $isRegistered = false;
93
94 /** @var bool */
95 private $isEmpty = true;
96
97 /**
98 * @return null|int
99 */
100 public function getId()
101 {
102 return $this->id;
103 }
104
105 /**
106 * @param int $id
107 *
108 * @return Style
109 */
110 public function setId($id)
111 {
112 $this->id = $id;
113
114 return $this;
115 }
116
117 /**
118 * @return null|Border
119 */
120 public function getBorder()
121 {
122 return $this->border;
123 }
124
125 /**
126 * @return Style
127 */
128 public function setBorder(Border $border)
129 {
130 $this->shouldApplyBorder = true;
131 $this->border = $border;
132 $this->isEmpty = false;
133
134 return $this;
135 }
136
137 /**
138 * @return bool
139 */
140 public function shouldApplyBorder()
141 {
142 return $this->shouldApplyBorder;
143 }
144
145 /**
146 * @return bool
147 */
148 public function isFontBold()
149 {
150 return $this->fontBold;
151 }
152
153 /**
154 * @return Style
155 */
156 public function setFontBold()
157 {
158 $this->fontBold = true;
159 $this->hasSetFontBold = true;
160 $this->shouldApplyFont = true;
161 $this->isEmpty = false;
162
163 return $this;
164 }
165
166 /**
167 * @return bool
168 */
169 public function hasSetFontBold()
170 {
171 return $this->hasSetFontBold;
172 }
173
174 /**
175 * @return bool
176 */
177 public function isFontItalic()
178 {
179 return $this->fontItalic;
180 }
181
182 /**
183 * @return Style
184 */
185 public function setFontItalic()
186 {
187 $this->fontItalic = true;
188 $this->hasSetFontItalic = true;
189 $this->shouldApplyFont = true;
190 $this->isEmpty = false;
191
192 return $this;
193 }
194
195 /**
196 * @return bool
197 */
198 public function hasSetFontItalic()
199 {
200 return $this->hasSetFontItalic;
201 }
202
203 /**
204 * @return bool
205 */
206 public function isFontUnderline()
207 {
208 return $this->fontUnderline;
209 }
210
211 /**
212 * @return Style
213 */
214 public function setFontUnderline()
215 {
216 $this->fontUnderline = true;
217 $this->hasSetFontUnderline = true;
218 $this->shouldApplyFont = true;
219 $this->isEmpty = false;
220
221 return $this;
222 }
223
224 /**
225 * @return bool
226 */
227 public function hasSetFontUnderline()
228 {
229 return $this->hasSetFontUnderline;
230 }
231
232 /**
233 * @return bool
234 */
235 public function isFontStrikethrough()
236 {
237 return $this->fontStrikethrough;
238 }
239
240 /**
241 * @return Style
242 */
243 public function setFontStrikethrough()
244 {
245 $this->fontStrikethrough = true;
246 $this->hasSetFontStrikethrough = true;
247 $this->shouldApplyFont = true;
248 $this->isEmpty = false;
249
250 return $this;
251 }
252
253 /**
254 * @return bool
255 */
256 public function hasSetFontStrikethrough()
257 {
258 return $this->hasSetFontStrikethrough;
259 }
260
261 /**
262 * @return int
263 */
264 public function getFontSize()
265 {
266 return $this->fontSize;
267 }
268
269 /**
270 * @param int $fontSize Font size, in pixels
271 *
272 * @return Style
273 */
274 public function setFontSize($fontSize)
275 {
276 $this->fontSize = $fontSize;
277 $this->hasSetFontSize = true;
278 $this->shouldApplyFont = true;
279 $this->isEmpty = false;
280
281 return $this;
282 }
283
284 /**
285 * @return bool
286 */
287 public function hasSetFontSize()
288 {
289 return $this->hasSetFontSize;
290 }
291
292 /**
293 * @return string
294 */
295 public function getFontColor()
296 {
297 return $this->fontColor;
298 }
299
300 /**
301 * Sets the font color.
302 *
303 * @param string $fontColor ARGB color (@see Color)
304 *
305 * @return Style
306 */
307 public function setFontColor($fontColor)
308 {
309 $this->fontColor = $fontColor;
310 $this->hasSetFontColor = true;
311 $this->shouldApplyFont = true;
312 $this->isEmpty = false;
313
314 return $this;
315 }
316
317 /**
318 * @return bool
319 */
320 public function hasSetFontColor()
321 {
322 return $this->hasSetFontColor;
323 }
324
325 /**
326 * @return string
327 */
328 public function getFontName()
329 {
330 return $this->fontName;
331 }
332
333 /**
334 * @param string $fontName Name of the font to use
335 *
336 * @return Style
337 */
338 public function setFontName($fontName)
339 {
340 $this->fontName = $fontName;
341 $this->hasSetFontName = true;
342 $this->shouldApplyFont = true;
343 $this->isEmpty = false;
344
345 return $this;
346 }
347
348 /**
349 * @return bool
350 */
351 public function hasSetFontName()
352 {
353 return $this->hasSetFontName;
354 }
355
356 /**
357 * @return string
358 */
359 public function getCellAlignment()
360 {
361 return $this->cellAlignment;
362 }
363
364 /**
365 * @param string $cellAlignment The cell alignment
366 *
367 * @return Style
368 */
369 public function setCellAlignment($cellAlignment)
370 {
371 $this->cellAlignment = $cellAlignment;
372 $this->hasSetCellAlignment = true;
373 $this->shouldApplyCellAlignment = true;
374 $this->isEmpty = false;
375
376 return $this;
377 }
378
379 /**
380 * @return bool
381 */
382 public function hasSetCellAlignment()
383 {
384 return $this->hasSetCellAlignment;
385 }
386
387 /**
388 * @return bool Whether specific cell alignment should be applied
389 */
390 public function shouldApplyCellAlignment()
391 {
392 return $this->shouldApplyCellAlignment;
393 }
394
395 /**
396 * @return bool
397 */
398 public function shouldWrapText()
399 {
400 return $this->shouldWrapText;
401 }
402
403 /**
404 * @param bool $shouldWrap Should the text be wrapped
405 *
406 * @return Style
407 */
408 public function setShouldWrapText($shouldWrap = true)
409 {
410 $this->shouldWrapText = $shouldWrap;
411 $this->hasSetWrapText = true;
412 $this->isEmpty = false;
413
414 return $this;
415 }
416
417 /**
418 * @return bool
419 */
420 public function hasSetWrapText()
421 {
422 return $this->hasSetWrapText;
423 }
424
425 /**
426 * @return bool Whether specific font properties should be applied
427 */
428 public function shouldApplyFont()
429 {
430 return $this->shouldApplyFont;
431 }
432
433 /**
434 * Sets the background color.
435 *
436 * @param string $color ARGB color (@see Color)
437 *
438 * @return Style
439 */
440 public function setBackgroundColor($color)
441 {
442 $this->hasSetBackgroundColor = true;
443 $this->backgroundColor = $color;
444 $this->isEmpty = false;
445
446 return $this;
447 }
448
449 /**
450 * @return null|string
451 */
452 public function getBackgroundColor()
453 {
454 return $this->backgroundColor;
455 }
456
457 /**
458 * @return bool Whether the background color should be applied
459 */
460 public function shouldApplyBackgroundColor()
461 {
462 return $this->hasSetBackgroundColor;
463 }
464
465 /**
466 * Sets format.
467 *
468 * @param string $format
469 *
470 * @return Style
471 */
472 public function setFormat($format)
473 {
474 $this->hasSetFormat = true;
475 $this->format = $format;
476 $this->isEmpty = false;
477
478 return $this;
479 }
480
481 /**
482 * @return null|string
483 */
484 public function getFormat()
485 {
486 return $this->format;
487 }
488
489 /**
490 * @return bool Whether format should be applied
491 */
492 public function shouldApplyFormat()
493 {
494 return $this->hasSetFormat;
495 }
496
497 public function isRegistered(): bool
498 {
499 return $this->isRegistered;
500 }
501
502 public function markAsRegistered(?int $id): void
503 {
504 $this->setId($id);
505 $this->isRegistered = true;
506 }
507
508 public function unmarkAsRegistered(): void
509 {
510 $this->setId(0);
511 $this->isRegistered = false;
512 }
513
514 public function isEmpty(): bool
515 {
516 return $this->isEmpty;
517 }
518
519 /**
520 * Sets should shrink to fit.
521 *
522 * @param bool $shrinkToFit
523 *
524 * @return Style
525 */
526 public function setShouldShrinkToFit($shrinkToFit = true)
527 {
528 $this->hasSetShrinkToFit = true;
529 $this->shouldShrinkToFit = $shrinkToFit;
530
531 return $this;
532 }
533
534 /**
535 * @return bool Whether format should be applied
536 */
537 public function shouldShrinkToFit()
538 {
539 return $this->shouldShrinkToFit;
540 }
541
542 /**
543 * @return bool
544 */
545 public function hasSetShrinkToFit()
546 {
547 return $this->hasSetShrinkToFit;
548 }
549 }
550