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
|
|
|
* Bottom inset (in pixels) |
109
|
|
|
* |
110
|
|
|
* @var float |
111
|
|
|
*/ |
112
|
|
|
private $bottomInset = 4.8; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Left inset (in pixels) |
116
|
|
|
* |
117
|
|
|
* @var float |
118
|
|
|
*/ |
119
|
|
|
private $leftInset = 9.6; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Right inset (in pixels) |
123
|
|
|
* |
124
|
|
|
* @var float |
125
|
|
|
*/ |
126
|
|
|
private $rightInset = 9.6; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Top inset (in pixels) |
130
|
|
|
* |
131
|
|
|
* @var float |
132
|
|
|
*/ |
133
|
|
|
private $topInset = 4.8; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Horizontal Auto Shrink |
137
|
|
|
* @var boolean |
138
|
|
|
*/ |
139
|
|
|
private $autoShrinkHorizontal; |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Vertical Auto Shrink |
143
|
|
|
* @var boolean |
144
|
|
|
*/ |
145
|
|
|
private $autoShrinkVertical; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* The percentage of the original font size to which the text is scaled |
149
|
|
|
* @var float |
150
|
|
|
*/ |
151
|
|
|
private $fontScale; |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* The percentage of the reduction of the line spacing |
155
|
|
|
* @var float |
156
|
|
|
*/ |
157
|
|
|
private $lnSpcReduction; |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Create a new \PhpOffice\PhpPresentation\Shape\RichText instance |
161
|
|
|
*/ |
162
|
86 |
|
public function __construct() |
163
|
|
|
{ |
164
|
|
|
// Initialise variables |
165
|
86 |
|
$this->richTextParagraphs = array( |
166
|
86 |
|
new Paragraph() |
167
|
|
|
); |
168
|
86 |
|
$this->activeParagraph = 0; |
169
|
|
|
|
170
|
|
|
// Initialize parent |
171
|
86 |
|
parent::__construct(); |
172
|
86 |
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get active paragraph index |
176
|
|
|
* |
177
|
|
|
* @return int |
178
|
|
|
*/ |
179
|
3 |
|
public function getActiveParagraphIndex() |
180
|
|
|
{ |
181
|
3 |
|
return $this->activeParagraph; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Get active paragraph |
186
|
|
|
* |
187
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
188
|
|
|
*/ |
189
|
41 |
|
public function getActiveParagraph() |
190
|
|
|
{ |
191
|
41 |
|
return $this->richTextParagraphs[$this->activeParagraph]; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Set active paragraph |
196
|
|
|
* |
197
|
|
|
* @param int $index |
198
|
|
|
* @throws \Exception |
199
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
200
|
|
|
*/ |
201
|
8 |
|
public function setActiveParagraph($index = 0) |
202
|
|
|
{ |
203
|
8 |
|
if ($index >= count($this->richTextParagraphs)) { |
204
|
1 |
|
throw new \Exception("Invalid paragraph count."); |
205
|
|
|
} |
206
|
|
|
|
207
|
7 |
|
$this->activeParagraph = $index; |
208
|
|
|
|
209
|
7 |
|
return $this->getActiveParagraph(); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get paragraph |
214
|
|
|
* |
215
|
|
|
* @param int $index |
216
|
|
|
* @throws \Exception |
217
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
218
|
|
|
*/ |
219
|
3 |
|
public function getParagraph($index = 0) |
220
|
|
|
{ |
221
|
3 |
|
if ($index >= count($this->richTextParagraphs)) { |
222
|
1 |
|
throw new \Exception("Invalid paragraph count."); |
223
|
|
|
} |
224
|
|
|
|
225
|
2 |
|
return $this->richTextParagraphs[$index]; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* Create paragraph |
230
|
|
|
* |
231
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
232
|
|
|
* @throws \Exception |
233
|
|
|
*/ |
234
|
12 |
|
public function createParagraph() |
235
|
|
|
{ |
236
|
12 |
|
$numParagraphs = count($this->richTextParagraphs); |
237
|
12 |
|
if ($numParagraphs > 0) { |
238
|
11 |
|
$alignment = clone $this->getActiveParagraph()->getAlignment(); |
239
|
11 |
|
$font = clone $this->getActiveParagraph()->getFont(); |
240
|
11 |
|
$bulletStyle = clone $this->getActiveParagraph()->getBulletStyle(); |
241
|
|
|
} |
242
|
|
|
|
243
|
12 |
|
$this->richTextParagraphs[] = new Paragraph(); |
244
|
12 |
|
$this->activeParagraph = count($this->richTextParagraphs) - 1; |
245
|
|
|
|
246
|
12 |
|
if (isset($alignment)) { |
247
|
11 |
|
$this->getActiveParagraph()->setAlignment($alignment); |
248
|
|
|
} |
249
|
12 |
|
if (isset($font)) { |
250
|
11 |
|
$this->getActiveParagraph()->setFont($font); |
251
|
|
|
} |
252
|
12 |
|
if (isset($bulletStyle)) { |
253
|
11 |
|
$this->getActiveParagraph()->setBulletStyle($bulletStyle); |
254
|
|
|
} |
255
|
12 |
|
return $this->getActiveParagraph(); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Add text |
260
|
|
|
* |
261
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface $pText Rich text element |
262
|
|
|
* @throws \Exception |
263
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
264
|
|
|
*/ |
265
|
1 |
|
public function addText(TextElementInterface $pText = null) |
266
|
|
|
{ |
267
|
1 |
|
$this->richTextParagraphs[$this->activeParagraph]->addText($pText); |
268
|
|
|
|
269
|
1 |
|
return $this; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Create text (can not be formatted !) |
274
|
|
|
* |
275
|
|
|
* @param string $pText Text |
276
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\TextElement |
277
|
|
|
* @throws \Exception |
278
|
|
|
*/ |
279
|
2 |
|
public function createText($pText = '') |
280
|
|
|
{ |
281
|
2 |
|
return $this->richTextParagraphs[$this->activeParagraph]->createText($pText); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Create break |
286
|
|
|
* |
287
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\BreakElement |
288
|
|
|
* @throws \Exception |
289
|
|
|
*/ |
290
|
4 |
|
public function createBreak() |
291
|
|
|
{ |
292
|
4 |
|
return $this->richTextParagraphs[$this->activeParagraph]->createBreak(); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* Create text run (can be formatted) |
297
|
|
|
* |
298
|
|
|
* @param string $pText Text |
299
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Run |
300
|
|
|
* @throws \Exception |
301
|
|
|
*/ |
302
|
33 |
|
public function createTextRun($pText = '') |
303
|
|
|
{ |
304
|
33 |
|
return $this->richTextParagraphs[$this->activeParagraph]->createTextRun($pText); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* Get plain text |
309
|
|
|
* |
310
|
|
|
* @return string |
311
|
|
|
*/ |
312
|
1 |
|
public function getPlainText() |
313
|
|
|
{ |
314
|
|
|
// Return value |
315
|
1 |
|
$returnValue = ''; |
316
|
|
|
|
317
|
|
|
// Loop trough all \PhpOffice\PhpPresentation\Shape\RichText\Paragraph |
318
|
1 |
|
foreach ($this->richTextParagraphs as $p) { |
319
|
1 |
|
$returnValue .= $p->getPlainText(); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
// Return |
323
|
1 |
|
return $returnValue; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Convert to string |
328
|
|
|
* |
329
|
|
|
* @return string |
330
|
|
|
*/ |
331
|
1 |
|
public function __toString() |
332
|
|
|
{ |
333
|
1 |
|
return $this->getPlainText(); |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
/** |
337
|
|
|
* Get paragraphs |
338
|
|
|
* |
339
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] |
340
|
|
|
*/ |
341
|
50 |
|
public function getParagraphs() |
342
|
|
|
{ |
343
|
50 |
|
return $this->richTextParagraphs; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Set paragraphs |
348
|
|
|
* |
349
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs Array of paragraphs |
350
|
|
|
* @throws \Exception |
351
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
352
|
|
|
*/ |
353
|
9 |
|
public function setParagraphs($paragraphs = null) |
354
|
|
|
{ |
355
|
9 |
|
if (!is_array($paragraphs)) { |
356
|
1 |
|
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed."); |
357
|
|
|
} |
358
|
|
|
|
359
|
8 |
|
$this->richTextParagraphs = $paragraphs; |
360
|
8 |
|
$this->activeParagraph = count($this->richTextParagraphs) - 1; |
361
|
8 |
|
return $this; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* Get text wrapping |
366
|
|
|
* |
367
|
|
|
* @return string |
368
|
|
|
*/ |
369
|
25 |
|
public function getWrap() |
370
|
|
|
{ |
371
|
25 |
|
return $this->wrap; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* Set text wrapping |
376
|
|
|
* |
377
|
|
|
* @param $value string |
378
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
379
|
|
|
*/ |
380
|
2 |
|
public function setWrap($value = self::WRAP_SQUARE) |
381
|
|
|
{ |
382
|
2 |
|
$this->wrap = $value; |
383
|
|
|
|
384
|
2 |
|
return $this; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Get autofit |
389
|
|
|
* |
390
|
|
|
* @return string |
391
|
|
|
*/ |
392
|
25 |
|
public function getAutoFit() |
393
|
|
|
{ |
394
|
25 |
|
return $this->autoFit; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Get pourcentage of fontScale |
399
|
|
|
* |
400
|
|
|
* @return float |
401
|
|
|
*/ |
402
|
1 |
|
public function getFontScale() |
403
|
|
|
{ |
404
|
1 |
|
return $this->fontScale; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* Get pourcentage of the line space reduction |
409
|
|
|
* |
410
|
|
|
* @return float |
411
|
|
|
*/ |
412
|
1 |
|
public function getLineSpaceReduction() |
413
|
|
|
{ |
414
|
1 |
|
return $this->lnSpcReduction; |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* Set autofit |
419
|
|
|
* |
420
|
|
|
* @param $value string |
421
|
|
|
* @param $fontScale float |
422
|
|
|
* @param $lnSpcReduction float |
423
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
424
|
|
|
*/ |
425
|
2 |
|
public function setAutoFit($value = self::AUTOFIT_DEFAULT, $fontScale = null, $lnSpcReduction = null) |
426
|
|
|
{ |
427
|
2 |
|
$this->autoFit = $value; |
428
|
|
|
|
429
|
2 |
|
if (!is_null($fontScale)) { |
430
|
1 |
|
$this->fontScale = $fontScale; |
431
|
|
|
} |
432
|
|
|
|
433
|
2 |
|
if (!is_null($lnSpcReduction)) { |
434
|
1 |
|
$this->lnSpcReduction = $lnSpcReduction; |
435
|
|
|
} |
436
|
|
|
|
437
|
2 |
|
return $this; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Get horizontal overflow |
442
|
|
|
* |
443
|
|
|
* @return string |
444
|
|
|
*/ |
445
|
25 |
|
public function getHorizontalOverflow() |
446
|
|
|
{ |
447
|
25 |
|
return $this->horizontalOverflow; |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* Set horizontal overflow |
452
|
|
|
* |
453
|
|
|
* @param $value string |
454
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
455
|
|
|
*/ |
456
|
1 |
|
public function setHorizontalOverflow($value = self::OVERFLOW_OVERFLOW) |
457
|
|
|
{ |
458
|
1 |
|
$this->horizontalOverflow = $value; |
459
|
|
|
|
460
|
1 |
|
return $this; |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* Get vertical overflow |
465
|
|
|
* |
466
|
|
|
* @return string |
467
|
|
|
*/ |
468
|
25 |
|
public function getVerticalOverflow() |
469
|
|
|
{ |
470
|
25 |
|
return $this->verticalOverflow; |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Set vertical overflow |
475
|
|
|
* |
476
|
|
|
* @param $value string |
477
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
478
|
|
|
*/ |
479
|
1 |
|
public function setVerticalOverflow($value = self::OVERFLOW_OVERFLOW) |
480
|
|
|
{ |
481
|
1 |
|
$this->verticalOverflow = $value; |
482
|
|
|
|
483
|
1 |
|
return $this; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* Get upright |
488
|
|
|
* |
489
|
|
|
* @return boolean |
490
|
|
|
*/ |
491
|
25 |
|
public function isUpright() |
492
|
|
|
{ |
493
|
25 |
|
return $this->upright; |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
/** |
497
|
|
|
* Set vertical |
498
|
|
|
* |
499
|
|
|
* @param $value boolean |
500
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
501
|
|
|
*/ |
502
|
2 |
|
public function setUpright($value = false) |
503
|
|
|
{ |
504
|
2 |
|
$this->upright = $value; |
505
|
|
|
|
506
|
2 |
|
return $this; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* Get vertical |
511
|
|
|
* |
512
|
|
|
* @return boolean |
513
|
|
|
*/ |
514
|
25 |
|
public function isVertical() |
515
|
|
|
{ |
516
|
25 |
|
return $this->vertical; |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* Set vertical |
521
|
|
|
* |
522
|
|
|
* @param $value boolean |
523
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
524
|
|
|
*/ |
525
|
2 |
|
public function setVertical($value = false) |
526
|
|
|
{ |
527
|
2 |
|
$this->vertical = $value; |
528
|
|
|
|
529
|
2 |
|
return $this; |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
/** |
533
|
|
|
* Get columns |
534
|
|
|
* |
535
|
|
|
* @return int |
536
|
|
|
*/ |
537
|
25 |
|
public function getColumns() |
538
|
|
|
{ |
539
|
25 |
|
return $this->columns; |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* Set columns |
544
|
|
|
* |
545
|
|
|
* @param $value int |
546
|
|
|
* @throws \Exception |
547
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
548
|
|
|
*/ |
549
|
2 |
|
public function setColumns($value = 1) |
550
|
|
|
{ |
551
|
2 |
|
if ($value > 16 || $value < 1) { |
552
|
1 |
|
throw new \Exception('Number of columns should be 1-16'); |
553
|
|
|
} |
554
|
|
|
|
555
|
1 |
|
$this->columns = $value; |
556
|
|
|
|
557
|
1 |
|
return $this; |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
/** |
561
|
|
|
* Get bottom inset |
562
|
|
|
* |
563
|
|
|
* @return float |
564
|
|
|
*/ |
565
|
25 |
|
public function getInsetBottom() |
566
|
|
|
{ |
567
|
25 |
|
return $this->bottomInset; |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
571
|
|
|
* Set bottom inset |
572
|
|
|
* |
573
|
|
|
* @param $value float |
574
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
575
|
|
|
*/ |
576
|
5 |
|
public function setInsetBottom($value = 4.8) |
577
|
|
|
{ |
578
|
5 |
|
$this->bottomInset = $value; |
579
|
|
|
|
580
|
5 |
|
return $this; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
/** |
584
|
|
|
* Get left inset |
585
|
|
|
* |
586
|
|
|
* @return float |
587
|
|
|
*/ |
588
|
25 |
|
public function getInsetLeft() |
589
|
|
|
{ |
590
|
25 |
|
return $this->leftInset; |
591
|
|
|
} |
592
|
|
|
|
593
|
|
|
/** |
594
|
|
|
* Set left inset |
595
|
|
|
* |
596
|
|
|
* @param $value float |
597
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
598
|
|
|
*/ |
599
|
5 |
|
public function setInsetLeft($value = 9.6) |
600
|
|
|
{ |
601
|
5 |
|
$this->leftInset = $value; |
602
|
|
|
|
603
|
5 |
|
return $this; |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
/** |
607
|
|
|
* Get right inset |
608
|
|
|
* |
609
|
|
|
* @return float |
610
|
|
|
*/ |
611
|
25 |
|
public function getInsetRight() |
612
|
|
|
{ |
613
|
25 |
|
return $this->rightInset; |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
/** |
617
|
|
|
* Set left inset |
618
|
|
|
* |
619
|
|
|
* @param $value float |
620
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
621
|
|
|
*/ |
622
|
5 |
|
public function setInsetRight($value = 9.6) |
623
|
|
|
{ |
624
|
5 |
|
$this->rightInset = $value; |
625
|
|
|
|
626
|
5 |
|
return $this; |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* Get top inset |
631
|
|
|
* |
632
|
|
|
* @return float |
633
|
|
|
*/ |
634
|
25 |
|
public function getInsetTop() |
635
|
|
|
{ |
636
|
25 |
|
return $this->topInset; |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
/** |
640
|
|
|
* Set top inset |
641
|
|
|
* |
642
|
|
|
* @param $value float |
643
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
644
|
|
|
*/ |
645
|
5 |
|
public function setInsetTop($value = 4.8) |
646
|
|
|
{ |
647
|
5 |
|
$this->topInset = $value; |
648
|
|
|
|
649
|
5 |
|
return $this; |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
/** |
653
|
|
|
* Set horizontal auto shrink |
654
|
|
|
* @param bool $value |
655
|
|
|
* @return RichText |
656
|
|
|
*/ |
657
|
2 |
|
public function setAutoShrinkHorizontal($value = null) |
658
|
|
|
{ |
659
|
2 |
|
if (is_bool($value)) { |
660
|
2 |
|
$this->autoShrinkHorizontal = $value; |
661
|
|
|
} |
662
|
2 |
|
return $this; |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
/** |
666
|
|
|
* Get horizontal auto shrink |
667
|
|
|
* @return bool |
668
|
|
|
*/ |
669
|
15 |
|
public function hasAutoShrinkHorizontal() |
670
|
|
|
{ |
671
|
15 |
|
return $this->autoShrinkHorizontal; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
/** |
675
|
|
|
* Set vertical auto shrink |
676
|
|
|
* @param bool $value |
677
|
|
|
* @return RichText |
678
|
|
|
*/ |
679
|
2 |
|
public function setAutoShrinkVertical($value = null) |
680
|
|
|
{ |
681
|
2 |
|
if (is_bool($value)) { |
682
|
2 |
|
$this->autoShrinkVertical = $value; |
683
|
|
|
} |
684
|
2 |
|
return $this; |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
/** |
688
|
|
|
* Set vertical auto shrink |
689
|
|
|
* @return bool |
690
|
|
|
*/ |
691
|
15 |
|
public function hasAutoShrinkVertical() |
692
|
|
|
{ |
693
|
15 |
|
return $this->autoShrinkVertical; |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* Get hash code |
698
|
|
|
* |
699
|
|
|
* @return string Hash code |
700
|
|
|
*/ |
701
|
3 |
|
public function getHashCode() |
702
|
|
|
{ |
703
|
3 |
|
$hashElements = ''; |
704
|
3 |
|
foreach ($this->richTextParagraphs as $element) { |
705
|
3 |
|
$hashElements .= $element->getHashCode(); |
706
|
|
|
} |
707
|
|
|
|
708
|
3 |
|
return md5($hashElements . $this->wrap . $this->autoFit . $this->horizontalOverflow . $this->verticalOverflow . ($this->upright ? '1' : '0') . ($this->vertical ? '1' : '0') . $this->columns . $this->bottomInset . $this->leftInset . $this->rightInset . $this->topInset . parent::getHashCode() . __CLASS__); |
709
|
|
|
} |
710
|
|
|
} |
711
|
|
|
|