|
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
|
|
|
namespace PhpOffice\PhpPresentation\Slide; |
|
18
|
|
|
|
|
19
|
|
|
use PhpOffice\PhpPresentation\AbstractShape; |
|
20
|
|
|
use PhpOffice\PhpPresentation\ComparableInterface; |
|
21
|
|
|
use PhpOffice\PhpPresentation\GeometryCalculator; |
|
22
|
|
|
use PhpOffice\PhpPresentation\PhpPresentation; |
|
23
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart; |
|
24
|
|
|
use PhpOffice\PhpPresentation\Shape\Drawing; |
|
25
|
|
|
use PhpOffice\PhpPresentation\Shape\Group; |
|
26
|
|
|
use PhpOffice\PhpPresentation\Shape\Line; |
|
27
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText; |
|
28
|
|
|
use PhpOffice\PhpPresentation\Shape\Table; |
|
29
|
|
|
use PhpOffice\PhpPresentation\ShapeContainerInterface; |
|
30
|
|
|
use PhpOffice\PhpPresentation\Slide; |
|
31
|
|
|
|
|
32
|
|
|
abstract class AbstractSlide implements ComparableInterface, ShapeContainerInterface |
|
33
|
|
|
{ |
|
34
|
|
|
protected $relsIndex; |
|
35
|
|
|
/** |
|
36
|
|
|
* |
|
37
|
|
|
* @var \PhpOffice\PhpPresentation\Slide\Transition |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $slideTransition; |
|
40
|
|
|
|
|
41
|
98 |
|
public function getRelsIndex() |
|
42
|
|
|
{ |
|
43
|
98 |
|
return $this->relsIndex; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
98 |
|
public function setRelsIndex($indexName) |
|
47
|
|
|
{ |
|
48
|
98 |
|
$this->relsIndex = $indexName; |
|
49
|
98 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Collection of shapes |
|
53
|
|
|
* |
|
54
|
|
|
* @var \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[] |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $shapeCollection = null; |
|
57
|
|
|
/** |
|
58
|
|
|
* Extent Y |
|
59
|
|
|
* |
|
60
|
|
|
* @var int |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $extentY; |
|
63
|
|
|
/** |
|
64
|
|
|
* Extent X |
|
65
|
|
|
* |
|
66
|
|
|
* @var int |
|
67
|
|
|
*/ |
|
68
|
|
|
protected $extentX; |
|
69
|
|
|
/** |
|
70
|
|
|
* Offset X |
|
71
|
|
|
* |
|
72
|
|
|
* @var int |
|
73
|
|
|
*/ |
|
74
|
|
|
protected $offsetX; |
|
75
|
|
|
/** |
|
76
|
|
|
* Offset Y |
|
77
|
|
|
* |
|
78
|
|
|
* @var int |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $offsetY; |
|
81
|
|
|
/** |
|
82
|
|
|
* Slide identifier |
|
83
|
|
|
* |
|
84
|
|
|
* @var string |
|
85
|
|
|
*/ |
|
86
|
|
|
protected $identifier; |
|
87
|
|
|
/** |
|
88
|
|
|
* Hash index |
|
89
|
|
|
* |
|
90
|
|
|
* @var string |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $hashIndex; |
|
93
|
|
|
/** |
|
94
|
|
|
* Parent presentation |
|
95
|
|
|
* |
|
96
|
|
|
* @var PhpPresentation |
|
97
|
|
|
*/ |
|
98
|
|
|
protected $parent; |
|
99
|
|
|
/** |
|
100
|
|
|
* Background of the slide |
|
101
|
|
|
* |
|
102
|
|
|
* @var AbstractBackground |
|
103
|
|
|
*/ |
|
104
|
|
|
protected $background; |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Get collection of shapes |
|
108
|
|
|
* |
|
109
|
|
|
* @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[] |
|
110
|
|
|
*/ |
|
111
|
174 |
|
public function getShapeCollection() |
|
112
|
|
|
{ |
|
113
|
174 |
|
return $this->shapeCollection; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Add shape to slide |
|
118
|
|
|
* |
|
119
|
|
|
* @param \PhpOffice\PhpPresentation\AbstractShape $shape |
|
120
|
|
|
* @return \PhpOffice\PhpPresentation\AbstractShape |
|
121
|
|
|
*/ |
|
122
|
140 |
|
public function addShape(AbstractShape $shape) |
|
123
|
|
|
{ |
|
124
|
140 |
|
$shape->setContainer($this); |
|
125
|
140 |
|
return $shape; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Get X Offset |
|
130
|
|
|
* |
|
131
|
|
|
* @return int |
|
132
|
|
|
*/ |
|
133
|
96 |
|
public function getOffsetX() |
|
134
|
|
|
{ |
|
135
|
96 |
|
if ($this->offsetX === null) { |
|
136
|
96 |
|
$offsets = GeometryCalculator::calculateOffsets($this); |
|
137
|
96 |
|
$this->offsetX = $offsets[GeometryCalculator::X]; |
|
138
|
96 |
|
$this->offsetY = $offsets[GeometryCalculator::Y]; |
|
139
|
96 |
|
} |
|
140
|
96 |
|
return $this->offsetX; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Get Y Offset |
|
145
|
|
|
* |
|
146
|
|
|
* @return int |
|
147
|
|
|
*/ |
|
148
|
96 |
|
public function getOffsetY() |
|
149
|
|
|
{ |
|
150
|
96 |
|
if ($this->offsetY === null) { |
|
151
|
1 |
|
$offsets = GeometryCalculator::calculateOffsets($this); |
|
152
|
1 |
|
$this->offsetX = $offsets[GeometryCalculator::X]; |
|
153
|
1 |
|
$this->offsetY = $offsets[GeometryCalculator::Y]; |
|
154
|
1 |
|
} |
|
155
|
96 |
|
return $this->offsetY; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* Get X Extent |
|
160
|
|
|
* |
|
161
|
|
|
* @return int |
|
162
|
|
|
*/ |
|
163
|
96 |
|
public function getExtentX() |
|
164
|
|
|
{ |
|
165
|
96 |
|
if ($this->extentX === null) { |
|
166
|
96 |
|
$extents = GeometryCalculator::calculateExtents($this); |
|
167
|
96 |
|
$this->extentX = $extents[GeometryCalculator::X]; |
|
168
|
96 |
|
$this->extentY = $extents[GeometryCalculator::Y]; |
|
169
|
96 |
|
} |
|
170
|
96 |
|
return $this->extentX; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Get Y Extent |
|
175
|
|
|
* |
|
176
|
|
|
* @return int |
|
177
|
|
|
*/ |
|
178
|
96 |
|
public function getExtentY() |
|
179
|
|
|
{ |
|
180
|
96 |
|
if ($this->extentY === null) { |
|
181
|
1 |
|
$extents = GeometryCalculator::calculateExtents($this); |
|
182
|
1 |
|
$this->extentX = $extents[GeometryCalculator::X]; |
|
183
|
1 |
|
$this->extentY = $extents[GeometryCalculator::Y]; |
|
184
|
1 |
|
} |
|
185
|
96 |
|
return $this->extentY; |
|
186
|
|
|
} |
|
187
|
|
|
|
|
188
|
|
|
/** |
|
189
|
|
|
* Get hash code |
|
190
|
|
|
* |
|
191
|
|
|
* @return string Hash code |
|
192
|
|
|
*/ |
|
193
|
135 |
|
public function getHashCode() |
|
194
|
|
|
{ |
|
195
|
135 |
|
return md5($this->identifier . __CLASS__); |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Get hash index |
|
200
|
|
|
* |
|
201
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
|
202
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
|
203
|
|
|
* |
|
204
|
|
|
* @return string Hash index |
|
205
|
|
|
*/ |
|
206
|
4 |
|
public function getHashIndex() |
|
207
|
|
|
{ |
|
208
|
4 |
|
return $this->hashIndex; |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Set hash index |
|
213
|
|
|
* |
|
214
|
|
|
* Note that this index may vary during script execution! Only reliable moment is |
|
215
|
|
|
* while doing a write of a workbook and when changes are not allowed. |
|
216
|
|
|
* |
|
217
|
|
|
* @param string $value Hash index |
|
218
|
|
|
*/ |
|
219
|
4 |
|
public function setHashIndex($value) |
|
220
|
|
|
{ |
|
221
|
4 |
|
$this->hashIndex = $value; |
|
222
|
4 |
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Create rich text shape |
|
226
|
|
|
* |
|
227
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\RichText |
|
228
|
|
|
*/ |
|
229
|
42 |
|
public function createRichTextShape() |
|
230
|
|
|
{ |
|
231
|
42 |
|
$shape = new RichText(); |
|
232
|
42 |
|
$this->addShape($shape); |
|
233
|
42 |
|
return $shape; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Create line shape |
|
238
|
|
|
* |
|
239
|
|
|
* @param int $fromX Starting point x offset |
|
240
|
|
|
* @param int $fromY Starting point y offset |
|
241
|
|
|
* @param int $toX Ending point x offset |
|
242
|
|
|
* @param int $toY Ending point y offset |
|
243
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Line |
|
244
|
|
|
*/ |
|
245
|
2 |
|
public function createLineShape($fromX, $fromY, $toX, $toY) |
|
246
|
|
|
{ |
|
247
|
2 |
|
$shape = new Line($fromX, $fromY, $toX, $toY); |
|
248
|
2 |
|
$this->addShape($shape); |
|
249
|
2 |
|
return $shape; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Create chart shape |
|
254
|
|
|
* |
|
255
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Chart |
|
256
|
|
|
*/ |
|
257
|
46 |
|
public function createChartShape() |
|
258
|
|
|
{ |
|
259
|
46 |
|
$shape = new Chart(); |
|
260
|
46 |
|
$this->addShape($shape); |
|
261
|
46 |
|
return $shape; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Create drawing shape |
|
266
|
|
|
* |
|
267
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Drawing |
|
268
|
|
|
*/ |
|
269
|
13 |
|
public function createDrawingShape() |
|
270
|
|
|
{ |
|
271
|
13 |
|
$shape = new Drawing(); |
|
|
|
|
|
|
272
|
13 |
|
$this->addShape($shape); |
|
273
|
13 |
|
return $shape; |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
/** |
|
277
|
|
|
* Create table shape |
|
278
|
|
|
* |
|
279
|
|
|
* @param int $columns Number of columns |
|
280
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Table |
|
281
|
|
|
*/ |
|
282
|
16 |
|
public function createTableShape($columns = 1) |
|
283
|
|
|
{ |
|
284
|
16 |
|
$shape = new Table($columns); |
|
285
|
16 |
|
$this->addShape($shape); |
|
286
|
16 |
|
return $shape; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Creates a group within this slide |
|
291
|
|
|
* |
|
292
|
|
|
* @return \PhpOffice\PhpPresentation\Shape\Group |
|
293
|
|
|
*/ |
|
294
|
2 |
|
public function createGroup() |
|
295
|
|
|
{ |
|
296
|
2 |
|
$shape = new Group(); |
|
297
|
2 |
|
$this->addShape($shape); |
|
298
|
2 |
|
return $shape; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* Get parent |
|
303
|
|
|
* |
|
304
|
|
|
* @return PhpPresentation |
|
305
|
|
|
*/ |
|
306
|
96 |
|
public function getParent() |
|
307
|
|
|
{ |
|
308
|
96 |
|
return $this->parent; |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
/** |
|
312
|
|
|
* Re-bind parent |
|
313
|
|
|
* |
|
314
|
|
|
* @param \PhpOffice\PhpPresentation\PhpPresentation $parent |
|
315
|
|
|
* @return \PhpOffice\PhpPresentation\Slide |
|
316
|
|
|
*/ |
|
317
|
2 |
|
public function rebindParent(PhpPresentation $parent) |
|
318
|
|
|
{ |
|
319
|
2 |
|
$this->parent->removeSlideByIndex($this->parent->getIndex($this)); |
|
|
|
|
|
|
320
|
2 |
|
$this->parent = $parent; |
|
321
|
2 |
|
return $this; |
|
322
|
|
|
} |
|
323
|
|
|
|
|
324
|
|
|
/** |
|
325
|
|
|
* @return AbstractBackground |
|
326
|
|
|
*/ |
|
327
|
155 |
|
public function getBackground() |
|
328
|
|
|
{ |
|
329
|
155 |
|
return $this->background; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
/** |
|
333
|
|
|
* @param AbstractBackground $background |
|
334
|
|
|
* @return Slide |
|
335
|
|
|
*/ |
|
336
|
5 |
|
public function setBackground(AbstractBackground $background = null) |
|
337
|
|
|
{ |
|
338
|
5 |
|
$this->background = $background; |
|
339
|
5 |
|
return $this; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
/** |
|
343
|
|
|
* |
|
344
|
|
|
* @return \PhpOffice\PhpPresentation\Slide\Transition |
|
345
|
|
|
*/ |
|
346
|
155 |
|
public function getTransition() |
|
347
|
|
|
{ |
|
348
|
155 |
|
return $this->slideTransition; |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
/** |
|
352
|
|
|
* |
|
353
|
|
|
* @param \PhpOffice\PhpPresentation\Slide\Transition $transition |
|
354
|
|
|
* @return \PhpOffice\PhpPresentation\Slide |
|
355
|
|
|
*/ |
|
356
|
3 |
|
public function setTransition(Transition $transition = null) |
|
357
|
|
|
{ |
|
358
|
3 |
|
$this->slideTransition = $transition; |
|
359
|
3 |
|
return $this; |
|
360
|
|
|
} |
|
361
|
|
|
} |
|
362
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.