1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of PHPPresentation - A pure PHP library for reading and writing |
4
|
|
|
* presentations documents. |
5
|
|
|
* |
6
|
|
|
* PHPPresentation is free software distributed under the terms of the GNU Lesser |
7
|
|
|
* General Public License version 3 as published by the Free Software Foundation. |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please read the LICENSE |
10
|
|
|
* file that was distributed with this source code. For the full list of |
11
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
12
|
|
|
* |
13
|
|
|
* @link https://github.com/PHPOffice/PHPPresentation |
14
|
|
|
* @copyright 2009-2015 PHPPresentation contributors |
15
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace PhpOffice\PhpPresentation\Shape; |
19
|
|
|
|
20
|
|
|
use PhpOffice\PhpPresentation\AbstractShape; |
21
|
|
|
use PhpOffice\PhpPresentation\ComparableInterface; |
22
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\Paragraph; |
23
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* \PhpOffice\PhpPresentation\Shape\RichText |
27
|
|
|
*/ |
28
|
|
|
class RichText extends AbstractShape implements ComparableInterface |
29
|
|
|
{ |
30
|
|
|
/** Wrapping */ |
31
|
|
|
const WRAP_NONE = 'none'; |
32
|
|
|
const WRAP_SQUARE = 'square'; |
33
|
|
|
|
34
|
|
|
/** Autofit */ |
35
|
|
|
const AUTOFIT_DEFAULT = 'spAutoFit'; |
36
|
|
|
const AUTOFIT_SHAPE = 'spAutoFit'; |
37
|
|
|
const AUTOFIT_NOAUTOFIT = 'noAutofit'; |
38
|
|
|
const AUTOFIT_NORMAL = 'normAutofit'; |
39
|
|
|
|
40
|
|
|
/** Overflow */ |
41
|
|
|
const OVERFLOW_CLIP = 'clip'; |
42
|
|
|
const OVERFLOW_OVERFLOW = 'overflow'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Rich text paragraphs |
46
|
|
|
* |
47
|
|
|
* @var \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] |
48
|
|
|
*/ |
49
|
|
|
private $richTextParagraphs; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Active paragraph |
53
|
|
|
* |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
private $activeParagraph = 0; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Text wrapping |
60
|
|
|
* |
61
|
|
|
* @var string |
62
|
|
|
*/ |
63
|
|
|
private $wrap = self::WRAP_SQUARE; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Autofit |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
private $autoFit = self::AUTOFIT_DEFAULT; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Horizontal overflow |
74
|
|
|
* |
75
|
|
|
* @var string |
76
|
|
|
*/ |
77
|
|
|
private $horizontalOverflow = self::OVERFLOW_OVERFLOW; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Vertical overflow |
81
|
|
|
* |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
private $verticalOverflow = self::OVERFLOW_OVERFLOW; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Text upright? |
88
|
|
|
* |
89
|
|
|
* @var boolean |
90
|
|
|
*/ |
91
|
|
|
private $upright = false; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Vertical text? |
95
|
|
|
* |
96
|
|
|
* @var boolean |
97
|
|
|
*/ |
98
|
|
|
private $vertical = false; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Number of columns (1 - 16) |
102
|
|
|
* |
103
|
|
|
* @var int |
104
|
|
|
*/ |
105
|
|
|
private $columns = 1; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* The spacing between columns |
109
|
|
|
* |
110
|
|
|
* @var float |
111
|
|
|
*/ |
112
|
|
|
private $columnSpacing = 0; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Bottom inset (in pixels) |
116
|
|
|
* |
117
|
|
|
* @var float |
118
|
|
|
*/ |
119
|
|
|
private $bottomInset = 4.8; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Left inset (in pixels) |
123
|
|
|
* |
124
|
|
|
* @var float |
125
|
|
|
*/ |
126
|
|
|
private $leftInset = 9.6; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Right inset (in pixels) |
130
|
|
|
* |
131
|
|
|
* @var float |
132
|
|
|
*/ |
133
|
|
|
private $rightInset = 9.6; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Top inset (in pixels) |
137
|
|
|
* |
138
|
|
|
* @var float |
139
|
|
|
*/ |
140
|
|
|
private $topInset = 4.8; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Horizontal Auto Shrink |
144
|
|
|
* @var boolean |
145
|
|
|
*/ |
146
|
|
|
private $autoShrinkHorizontal; |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Vertical Auto Shrink |
150
|
|
|
* @var boolean |
151
|
|
|
*/ |
152
|
|
|
private $autoShrinkVertical; |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* The percentage of the original font size to which the text is scaled |
156
|
|
|
* @var float |
157
|
|
|
*/ |
158
|
|
|
private $fontScale; |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* The percentage of the reduction of the line spacing |
162
|
86 |
|
* @var float |
163
|
|
|
*/ |
164
|
|
|
private $lnSpcReduction; |
165
|
86 |
|
|
166
|
86 |
|
/** |
167
|
|
|
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance |
168
|
86 |
|
*/ |
169
|
|
|
public function __construct() |
170
|
|
|
{ |
171
|
86 |
|
// Initialise variables |
172
|
86 |
|
$this->richTextParagraphs = array( |
173
|
|
|
new Paragraph() |
174
|
|
|
); |
175
|
|
|
$this->activeParagraph = 0; |
176
|
|
|
|
177
|
|
|
// Initialize parent |
178
|
|
|
parent::__construct(); |
179
|
3 |
|
} |
180
|
|
|
|
181
|
3 |
|
/** |
182
|
|
|
* Get active paragraph index |
183
|
|
|
* |
184
|
|
|
* @return int |
185
|
|
|
*/ |
186
|
|
|
public function getActiveParagraphIndex() |
187
|
|
|
{ |
188
|
|
|
return $this->activeParagraph; |
189
|
41 |
|
} |
190
|
|
|
|
191
|
41 |
|
/** |
192
|
|
|
* Get active paragraph |
193
|
|
|
* |
194
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
195
|
|
|
*/ |
196
|
|
|
public function getActiveParagraph() |
197
|
|
|
{ |
198
|
|
|
return $this->richTextParagraphs[$this->activeParagraph]; |
199
|
|
|
} |
200
|
|
|
|
201
|
8 |
|
/** |
202
|
|
|
* Set active paragraph |
203
|
8 |
|
* |
204
|
1 |
|
* @param int $index |
205
|
|
|
* @throws \Exception |
206
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
207
|
7 |
|
*/ |
208
|
|
|
public function setActiveParagraph($index = 0) |
209
|
7 |
|
{ |
210
|
|
|
if ($index >= count($this->richTextParagraphs)) { |
211
|
|
|
throw new \Exception("Invalid paragraph count."); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
$this->activeParagraph = $index; |
215
|
|
|
|
216
|
|
|
return $this->getActiveParagraph(); |
217
|
|
|
} |
218
|
|
|
|
219
|
3 |
|
/** |
220
|
|
|
* Get paragraph |
221
|
3 |
|
* |
222
|
1 |
|
* @param int $index |
223
|
|
|
* @throws \Exception |
224
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
225
|
2 |
|
*/ |
226
|
|
|
public function getParagraph($index = 0) |
227
|
|
|
{ |
228
|
|
|
if ($index >= count($this->richTextParagraphs)) { |
229
|
|
|
throw new \Exception("Invalid paragraph count."); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
return $this->richTextParagraphs[$index]; |
233
|
|
|
} |
234
|
12 |
|
|
235
|
|
|
/** |
236
|
12 |
|
* Create paragraph |
237
|
12 |
|
* |
238
|
11 |
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
239
|
11 |
|
* @throws \Exception |
240
|
11 |
|
*/ |
241
|
|
|
public function createParagraph() |
242
|
|
|
{ |
243
|
12 |
|
$numParagraphs = count($this->richTextParagraphs); |
244
|
12 |
|
if ($numParagraphs > 0) { |
245
|
|
|
$alignment = clone $this->getActiveParagraph()->getAlignment(); |
246
|
12 |
|
$font = clone $this->getActiveParagraph()->getFont(); |
247
|
11 |
|
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle(); |
248
|
|
|
} |
249
|
12 |
|
|
250
|
11 |
|
$this->richTextParagraphs[] = new Paragraph(); |
251
|
|
|
$this->activeParagraph = count($this->richTextParagraphs) - 1; |
252
|
12 |
|
|
253
|
11 |
|
if (isset($alignment)) { |
254
|
|
|
$this->getActiveParagraph()->setAlignment($alignment); |
255
|
12 |
|
} |
256
|
|
|
if (isset($font)) { |
257
|
|
|
$this->getActiveParagraph()->setFont($font); |
258
|
|
|
} |
259
|
|
|
if (isset($bulletStyle)) { |
260
|
|
|
$this->getActiveParagraph()->setBulletStyle($bulletStyle); |
261
|
|
|
} |
262
|
|
|
return $this->getActiveParagraph(); |
263
|
|
|
} |
264
|
|
|
|
265
|
1 |
|
/** |
266
|
|
|
* Add text |
267
|
1 |
|
* |
268
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element |
269
|
1 |
|
* @throws \Exception |
270
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
271
|
|
|
*/ |
272
|
|
|
public function addText(TextElementInterface $pText = null) |
273
|
|
|
{ |
274
|
|
|
$this->richTextParagraphs[$this->activeParagraph]->addText($pText); |
275
|
|
|
|
276
|
|
|
return $this; |
277
|
|
|
} |
278
|
|
|
|
279
|
2 |
|
/** |
280
|
|
|
* Create text (can not be formatted !) |
281
|
2 |
|
* |
282
|
|
|
* @param string $pText Text |
283
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement |
284
|
|
|
* @throws \Exception |
285
|
|
|
*/ |
286
|
|
|
public function createText($pText = '') |
287
|
|
|
{ |
288
|
|
|
return $this->richTextParagraphs[$this->activeParagraph]->createText($pText); |
289
|
|
|
} |
290
|
4 |
|
|
291
|
|
|
/** |
292
|
4 |
|
* Create break |
293
|
|
|
* |
294
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement |
295
|
|
|
* @throws \Exception |
296
|
|
|
*/ |
297
|
|
|
public function createBreak() |
298
|
|
|
{ |
299
|
|
|
return $this->richTextParagraphs[$this->activeParagraph]->createBreak(); |
300
|
|
|
} |
301
|
|
|
|
302
|
33 |
|
/** |
303
|
|
|
* Create text run (can be formatted) |
304
|
33 |
|
* |
305
|
|
|
* @param string $pText Text |
306
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run |
307
|
|
|
* @throws \Exception |
308
|
|
|
*/ |
309
|
|
|
public function createTextRun($pText = '') |
310
|
|
|
{ |
311
|
|
|
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText); |
312
|
1 |
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
1 |
|
* Get plain text |
316
|
|
|
* |
317
|
|
|
* @return string |
318
|
1 |
|
*/ |
319
|
1 |
|
public function getPlainText() |
320
|
|
|
{ |
321
|
|
|
// Return value |
322
|
|
|
$returnValue = ''; |
323
|
1 |
|
|
324
|
|
|
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
325
|
|
|
foreach ($this->richTextParagraphs as $p) { |
326
|
|
|
$returnValue .= $p->getPlainText(); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
// Return |
330
|
|
|
return $returnValue; |
331
|
1 |
|
} |
332
|
|
|
|
333
|
1 |
|
/** |
334
|
|
|
* Convert to string |
335
|
|
|
* |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
|
public function __toString() |
339
|
|
|
{ |
340
|
|
|
return $this->getPlainText(); |
341
|
50 |
|
} |
342
|
|
|
|
343
|
50 |
|
/** |
344
|
|
|
* Get paragraphs |
345
|
|
|
* |
346
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] |
347
|
|
|
*/ |
348
|
|
|
public function getParagraphs() |
349
|
|
|
{ |
350
|
|
|
return $this->richTextParagraphs; |
351
|
|
|
} |
352
|
|
|
|
353
|
9 |
|
/** |
354
|
|
|
* Set paragraphs |
355
|
9 |
|
* |
356
|
1 |
|
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs |
357
|
|
|
* @throws \Exception |
358
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
359
|
8 |
|
*/ |
360
|
8 |
|
public function setParagraphs($paragraphs = null) |
361
|
8 |
|
{ |
362
|
|
|
if (!is_array($paragraphs)) { |
363
|
|
|
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed."); |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
$this->richTextParagraphs = $paragraphs; |
367
|
|
|
$this->activeParagraph = count($this->richTextParagraphs) - 1; |
368
|
|
|
return $this; |
369
|
25 |
|
} |
370
|
|
|
|
371
|
25 |
|
/** |
372
|
|
|
* Get text wrapping |
373
|
|
|
* |
374
|
|
|
* @return string |
375
|
|
|
*/ |
376
|
|
|
public function getWrap() |
377
|
|
|
{ |
378
|
|
|
return $this->wrap; |
379
|
|
|
} |
380
|
2 |
|
|
381
|
|
|
/** |
382
|
2 |
|
* Set text wrapping |
383
|
|
|
* |
384
|
2 |
|
* @param $value string |
385
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
386
|
|
|
*/ |
387
|
|
|
public function setWrap($value = self::WRAP_SQUARE) |
388
|
|
|
{ |
389
|
|
|
$this->wrap = $value; |
390
|
|
|
|
391
|
|
|
return $this; |
392
|
25 |
|
} |
393
|
|
|
|
394
|
25 |
|
/** |
395
|
|
|
* Get autofit |
396
|
|
|
* |
397
|
|
|
* @return string |
398
|
|
|
*/ |
399
|
|
|
public function getAutoFit() |
400
|
|
|
{ |
401
|
|
|
return $this->autoFit; |
402
|
1 |
|
} |
403
|
|
|
|
404
|
1 |
|
/** |
405
|
|
|
* Get pourcentage of fontScale |
406
|
|
|
* |
407
|
|
|
* @return float |
408
|
|
|
*/ |
409
|
|
|
public function getFontScale() |
410
|
|
|
{ |
411
|
|
|
return $this->fontScale; |
412
|
1 |
|
} |
413
|
|
|
|
414
|
1 |
|
/** |
415
|
|
|
* Get pourcentage of the line space reduction |
416
|
|
|
* |
417
|
|
|
* @return float |
418
|
|
|
*/ |
419
|
|
|
public function getLineSpaceReduction() |
420
|
|
|
{ |
421
|
|
|
return $this->lnSpcReduction; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
/** |
425
|
2 |
|
* Set autofit |
426
|
|
|
* |
427
|
2 |
|
* @param $value string |
428
|
|
|
* @param $fontScale float |
429
|
2 |
|
* @param $lnSpcReduction float |
430
|
1 |
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
431
|
|
|
*/ |
432
|
|
|
public function setAutoFit($value = self::AUTOFIT_DEFAULT, $fontScale = null, $lnSpcReduction = null) |
433
|
2 |
|
{ |
434
|
1 |
|
$this->autoFit = $value; |
435
|
|
|
|
436
|
|
|
if (!is_null($fontScale)) { |
437
|
2 |
|
$this->fontScale = $fontScale; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
if (!is_null($lnSpcReduction)) { |
441
|
|
|
$this->lnSpcReduction = $lnSpcReduction; |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
return $this; |
445
|
25 |
|
} |
446
|
|
|
|
447
|
25 |
|
/** |
448
|
|
|
* Get horizontal overflow |
449
|
|
|
* |
450
|
|
|
* @return string |
451
|
|
|
*/ |
452
|
|
|
public function getHorizontalOverflow() |
453
|
|
|
{ |
454
|
|
|
return $this->horizontalOverflow; |
455
|
|
|
} |
456
|
1 |
|
|
457
|
|
|
/** |
458
|
1 |
|
* Set horizontal overflow |
459
|
|
|
* |
460
|
1 |
|
* @param $value string |
461
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
462
|
|
|
*/ |
463
|
|
|
public function setHorizontalOverflow($value = self::OVERFLOW_OVERFLOW) |
464
|
|
|
{ |
465
|
|
|
$this->horizontalOverflow = $value; |
466
|
|
|
|
467
|
|
|
return $this; |
468
|
25 |
|
} |
469
|
|
|
|
470
|
25 |
|
/** |
471
|
|
|
* Get vertical overflow |
472
|
|
|
* |
473
|
|
|
* @return string |
474
|
|
|
*/ |
475
|
|
|
public function getVerticalOverflow() |
476
|
|
|
{ |
477
|
|
|
return $this->verticalOverflow; |
478
|
|
|
} |
479
|
1 |
|
|
480
|
|
|
/** |
481
|
1 |
|
* Set vertical overflow |
482
|
|
|
* |
483
|
1 |
|
* @param $value string |
484
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
485
|
|
|
*/ |
486
|
|
|
public function setVerticalOverflow($value = self::OVERFLOW_OVERFLOW) |
487
|
|
|
{ |
488
|
|
|
$this->verticalOverflow = $value; |
489
|
|
|
|
490
|
|
|
return $this; |
491
|
25 |
|
} |
492
|
|
|
|
493
|
25 |
|
/** |
494
|
|
|
* Get upright |
495
|
|
|
* |
496
|
|
|
* @return boolean |
497
|
|
|
*/ |
498
|
|
|
public function isUpright() |
499
|
|
|
{ |
500
|
|
|
return $this->upright; |
501
|
|
|
} |
502
|
2 |
|
|
503
|
|
|
/** |
504
|
2 |
|
* Set vertical |
505
|
|
|
* |
506
|
2 |
|
* @param $value boolean |
507
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
508
|
|
|
*/ |
509
|
|
|
public function setUpright($value = false) |
510
|
|
|
{ |
511
|
|
|
$this->upright = $value; |
512
|
|
|
|
513
|
|
|
return $this; |
514
|
25 |
|
} |
515
|
|
|
|
516
|
25 |
|
/** |
517
|
|
|
* Get vertical |
518
|
|
|
* |
519
|
|
|
* @return boolean |
520
|
|
|
*/ |
521
|
|
|
public function isVertical() |
522
|
|
|
{ |
523
|
|
|
return $this->vertical; |
524
|
|
|
} |
525
|
2 |
|
|
526
|
|
|
/** |
527
|
2 |
|
* Set vertical |
528
|
|
|
* |
529
|
2 |
|
* @param $value boolean |
530
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
531
|
|
|
*/ |
532
|
|
|
public function setVertical($value = false) |
533
|
|
|
{ |
534
|
|
|
$this->vertical = $value; |
535
|
|
|
|
536
|
|
|
return $this; |
537
|
25 |
|
} |
538
|
|
|
|
539
|
25 |
|
/** |
540
|
|
|
* Get columns |
541
|
|
|
* |
542
|
|
|
* @return int |
543
|
|
|
*/ |
544
|
|
|
public function getColumns() |
545
|
|
|
{ |
546
|
|
|
return $this->columns; |
547
|
|
|
} |
548
|
|
|
|
549
|
2 |
|
/** |
550
|
|
|
* Set columns |
551
|
2 |
|
* |
552
|
1 |
|
* @param $value int |
553
|
|
|
* @throws \Exception |
554
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
555
|
1 |
|
*/ |
556
|
|
|
public function setColumns($value = 1) |
557
|
1 |
|
{ |
558
|
|
|
if ($value > 16 || $value < 1) { |
559
|
|
|
throw new \Exception('Number of columns should be 1-16'); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
$this->columns = $value; |
563
|
|
|
|
564
|
|
|
return $this; |
565
|
25 |
|
} |
566
|
|
|
|
567
|
25 |
|
/** |
568
|
|
|
* Get spacing between columns |
569
|
|
|
* |
570
|
|
|
* @return int |
571
|
|
|
*/ |
572
|
|
|
public function getColumnSpacing() |
573
|
|
|
{ |
574
|
|
|
return $this->columnSpacing; |
575
|
|
|
} |
576
|
5 |
|
|
577
|
|
|
/** |
578
|
5 |
|
* Set spacing between columns |
579
|
|
|
* |
580
|
5 |
|
* @param $value float |
581
|
|
|
* @throws \Exception |
582
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
583
|
|
|
*/ |
584
|
|
|
public function setColumnSpacing($value = 0) |
585
|
|
|
{ |
586
|
|
|
if ($value < 0) { |
587
|
|
|
throw new \Exception('Column spacing should be a non-negative number'); |
588
|
25 |
|
} |
589
|
|
|
|
590
|
25 |
|
$this->columnSpacing = $value; |
|
|
|
|
591
|
|
|
|
592
|
|
|
return $this; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
/** |
596
|
|
|
* Get bottom inset |
597
|
|
|
* |
598
|
|
|
* @return float |
599
|
5 |
|
*/ |
600
|
|
|
public function getInsetBottom() |
601
|
5 |
|
{ |
602
|
|
|
return $this->bottomInset; |
603
|
5 |
|
} |
604
|
|
|
|
605
|
|
|
/** |
606
|
|
|
* Set bottom inset |
607
|
|
|
* |
608
|
|
|
* @param $value float |
609
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
610
|
|
|
*/ |
611
|
25 |
|
public function setInsetBottom($value = 4.8) |
612
|
|
|
{ |
613
|
25 |
|
$this->bottomInset = $value; |
614
|
|
|
|
615
|
|
|
return $this; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Get left inset |
620
|
|
|
* |
621
|
|
|
* @return float |
622
|
5 |
|
*/ |
623
|
|
|
public function getInsetLeft() |
624
|
5 |
|
{ |
625
|
|
|
return $this->leftInset; |
626
|
5 |
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* Set left inset |
630
|
|
|
* |
631
|
|
|
* @param $value float |
632
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
633
|
|
|
*/ |
634
|
25 |
|
public function setInsetLeft($value = 9.6) |
635
|
|
|
{ |
636
|
25 |
|
$this->leftInset = $value; |
637
|
|
|
|
638
|
|
|
return $this; |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
/** |
642
|
|
|
* Get right inset |
643
|
|
|
* |
644
|
|
|
* @return float |
645
|
5 |
|
*/ |
646
|
|
|
public function getInsetRight() |
647
|
5 |
|
{ |
648
|
|
|
return $this->rightInset; |
649
|
5 |
|
} |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Set left inset |
653
|
|
|
* |
654
|
|
|
* @param $value float |
655
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
656
|
|
|
*/ |
657
|
2 |
|
public function setInsetRight($value = 9.6) |
658
|
|
|
{ |
659
|
2 |
|
$this->rightInset = $value; |
660
|
2 |
|
|
661
|
|
|
return $this; |
662
|
2 |
|
} |
663
|
|
|
|
664
|
|
|
/** |
665
|
|
|
* Get top inset |
666
|
|
|
* |
667
|
|
|
* @return float |
668
|
|
|
*/ |
669
|
15 |
|
public function getInsetTop() |
670
|
|
|
{ |
671
|
15 |
|
return $this->topInset; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
/** |
675
|
|
|
* Set top inset |
676
|
|
|
* |
677
|
|
|
* @param $value float |
678
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
679
|
2 |
|
*/ |
680
|
|
|
public function setInsetTop($value = 4.8) |
681
|
2 |
|
{ |
682
|
2 |
|
$this->topInset = $value; |
683
|
|
|
|
684
|
2 |
|
return $this; |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
/** |
688
|
|
|
* Set horizontal auto shrink |
689
|
|
|
* @param bool $value |
690
|
|
|
* @return RichText |
691
|
15 |
|
*/ |
692
|
|
|
public function setAutoShrinkHorizontal($value = null) |
693
|
15 |
|
{ |
694
|
|
|
if (is_bool($value)) { |
695
|
|
|
$this->autoShrinkHorizontal = $value; |
696
|
|
|
} |
697
|
|
|
return $this; |
698
|
|
|
} |
699
|
|
|
|
700
|
|
|
/** |
701
|
3 |
|
* Get horizontal auto shrink |
702
|
|
|
* @return bool |
703
|
3 |
|
*/ |
704
|
3 |
|
public function hasAutoShrinkHorizontal() |
705
|
3 |
|
{ |
706
|
|
|
return $this->autoShrinkHorizontal; |
707
|
|
|
} |
708
|
3 |
|
|
709
|
|
|
/** |
710
|
|
|
* Set vertical auto shrink |
711
|
|
|
* @param bool $value |
712
|
|
|
* @return RichText |
713
|
|
|
*/ |
714
|
|
|
public function setAutoShrinkVertical($value = null) |
715
|
|
|
{ |
716
|
|
|
if (is_bool($value)) { |
717
|
|
|
$this->autoShrinkVertical = $value; |
718
|
|
|
} |
719
|
|
|
return $this; |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* Set vertical auto shrink |
724
|
|
|
* @return bool |
725
|
|
|
*/ |
726
|
|
|
public function hasAutoShrinkVertical() |
727
|
|
|
{ |
728
|
|
|
return $this->autoShrinkVertical; |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
/** |
732
|
|
|
* Get hash code |
733
|
|
|
* |
734
|
|
|
* @return string Hash code |
735
|
|
|
*/ |
736
|
|
|
public function getHashCode() |
737
|
|
|
{ |
738
|
|
|
$hashElements = ''; |
739
|
|
|
foreach ($this->richTextParagraphs as $element) { |
740
|
|
|
$hashElements .= $element->getHashCode(); |
741
|
|
|
} |
742
|
|
|
|
743
|
|
|
return md5($hashElements . $this->wrap . $this->autoFit . $this->horizontalOverflow . $this->verticalOverflow . ($this->upright ? '1' : '0') . ($this->vertical ? '1' : '0') . $this->columns . $this->columnSpacing . $this->bottomInset . $this->leftInset . $this->rightInset . $this->topInset . parent::getHashCode() . __CLASS__); |
744
|
|
|
} |
745
|
|
|
} |
746
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.