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\Writer\PowerPoint2007; |
19
|
|
|
|
20
|
|
|
use PhpOffice\Common\Drawing as CommonDrawing; |
21
|
|
|
use PhpOffice\Common\Text; |
22
|
|
|
use PhpOffice\Common\XMLWriter; |
23
|
|
|
use PhpOffice\PhpPresentation\Shape\AbstractDrawing; |
24
|
|
|
use PhpOffice\PhpPresentation\Shape\Chart as ShapeChart; |
25
|
|
|
use PhpOffice\PhpPresentation\Shape\Group; |
26
|
|
|
use PhpOffice\PhpPresentation\Shape\Line; |
27
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText; |
28
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\BreakElement; |
29
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\Run; |
30
|
|
|
use PhpOffice\PhpPresentation\Shape\RichText\TextElement; |
31
|
|
|
use PhpOffice\PhpPresentation\Shape\Table; |
32
|
|
|
use PhpOffice\PhpPresentation\Slide as SlideElement; |
33
|
|
|
use PhpOffice\PhpPresentation\Slide\Note; |
34
|
|
|
use PhpOffice\PhpPresentation\Slide\Transition; |
35
|
|
|
use PhpOffice\PhpPresentation\Style\Alignment; |
36
|
|
|
use PhpOffice\PhpPresentation\Style\Border; |
37
|
|
|
use PhpOffice\PhpPresentation\Style\Bullet; |
38
|
|
|
use PhpOffice\PhpPresentation\Style\Fill; |
39
|
|
|
use PhpOffice\PhpPresentation\Style\Shadow; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Slide writer |
43
|
|
|
*/ |
44
|
|
|
class Slide extends AbstractPart |
45
|
|
|
{ |
46
|
|
|
/** |
47
|
|
|
* Write slide to XML format |
48
|
|
|
* |
49
|
|
|
* @param \PhpOffice\PhpPresentation\Slide $pSlide |
50
|
|
|
* @return string XML Output |
51
|
|
|
* @throws \Exception |
52
|
|
|
*/ |
53
|
61 |
|
public function writeSlide(SlideElement $pSlide = null) |
54
|
|
|
{ |
55
|
|
|
// Check slide |
56
|
61 |
|
if (is_null($pSlide)) { |
57
|
1 |
|
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Slide object passed."); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// Create XML writer |
61
|
60 |
|
$objWriter = $this->getXMLWriter(); |
62
|
|
|
|
63
|
|
|
// XML header |
64
|
60 |
|
$objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
65
|
|
|
|
66
|
|
|
// p:sld |
67
|
60 |
|
$objWriter->startElement('p:sld'); |
68
|
60 |
|
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
69
|
60 |
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
70
|
60 |
|
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); |
71
|
|
|
|
72
|
|
|
// p:cSld |
73
|
60 |
|
$objWriter->startElement('p:cSld'); |
74
|
|
|
|
75
|
|
|
// Background |
76
|
60 |
|
if ($pSlide->getBackground() instanceof SlideElement\AbstractBackground) { |
77
|
|
|
$oBackground = $pSlide->getBackground(); |
78
|
|
|
// p:bg |
79
|
|
|
$objWriter->startElement('p:bg'); |
80
|
|
|
|
81
|
|
|
// p:bgPr |
82
|
|
|
$objWriter->startElement('p:bgPr'); |
83
|
|
|
|
84
|
|
|
if ($oBackground instanceof SlideElement\Background\Color) { |
85
|
|
|
// a:solidFill |
86
|
|
|
$objWriter->startElement('a:solidFill'); |
87
|
|
|
|
88
|
|
|
// a:srgbClr |
89
|
|
|
$objWriter->startElement('a:srgbClr'); |
90
|
|
|
$objWriter->writeAttribute('val', $oBackground->getColor()->getRGB()); |
91
|
|
|
$objWriter->endElement(); |
92
|
|
|
|
93
|
|
|
// > a:solidFill |
94
|
|
|
$objWriter->endElement(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
if ($oBackground instanceof SlideElement\Background\Image) { |
98
|
|
|
// a:blipFill |
99
|
|
|
$objWriter->startElement('a:blipFill'); |
100
|
|
|
|
101
|
|
|
// a:blip |
102
|
|
|
$objWriter->startElement('a:blip'); |
103
|
|
|
$objWriter->writeAttribute('r:embed', $oBackground->relationId); |
104
|
|
|
|
105
|
|
|
// > a:blipFill |
106
|
|
|
$objWriter->endElement(); |
107
|
|
|
|
108
|
|
|
// a:stretch |
109
|
|
|
$objWriter->startElement('a:stretch'); |
110
|
|
|
|
111
|
|
|
// a:fillRect |
112
|
|
|
$objWriter->writeElement('a:fillRect'); |
113
|
|
|
|
114
|
|
|
// > a:stretch |
115
|
|
|
$objWriter->endElement(); |
116
|
|
|
|
117
|
|
|
// > a:blipFill |
118
|
|
|
$objWriter->endElement(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
// > p:bgPr |
122
|
|
|
$objWriter->endElement(); |
123
|
|
|
|
124
|
|
|
// > p:bg |
125
|
|
|
$objWriter->endElement(); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
// p:spTree |
129
|
60 |
|
$objWriter->startElement('p:spTree'); |
130
|
|
|
|
131
|
|
|
// p:nvGrpSpPr |
132
|
60 |
|
$objWriter->startElement('p:nvGrpSpPr'); |
133
|
|
|
|
134
|
|
|
// p:cNvPr |
135
|
60 |
|
$objWriter->startElement('p:cNvPr'); |
136
|
60 |
|
$objWriter->writeAttribute('id', '1'); |
137
|
60 |
|
$objWriter->writeAttribute('name', ''); |
138
|
60 |
|
$objWriter->endElement(); |
139
|
|
|
|
140
|
|
|
// p:cNvGrpSpPr |
141
|
60 |
|
$objWriter->writeElement('p:cNvGrpSpPr', null); |
142
|
|
|
|
143
|
|
|
// p:nvPr |
144
|
60 |
|
$objWriter->writeElement('p:nvPr', null); |
145
|
|
|
|
146
|
60 |
|
$objWriter->endElement(); |
147
|
|
|
|
148
|
|
|
// p:grpSpPr |
149
|
60 |
|
$objWriter->startElement('p:grpSpPr'); |
150
|
|
|
|
151
|
|
|
// a:xfrm |
152
|
60 |
|
$objWriter->startElement('a:xfrm'); |
153
|
|
|
|
154
|
|
|
// a:off |
155
|
60 |
|
$objWriter->startElement('a:off'); |
156
|
60 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
157
|
60 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
158
|
60 |
|
$objWriter->endElement(); // a:off |
159
|
|
|
|
160
|
|
|
// a:ext |
161
|
60 |
|
$objWriter->startElement('a:ext'); |
162
|
60 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
163
|
60 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
164
|
60 |
|
$objWriter->endElement(); // a:ext |
165
|
|
|
|
166
|
|
|
// a:chOff |
167
|
60 |
|
$objWriter->startElement('a:chOff'); |
168
|
60 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
169
|
60 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
170
|
60 |
|
$objWriter->endElement(); // a:chOff |
171
|
|
|
|
172
|
|
|
// a:chExt |
173
|
60 |
|
$objWriter->startElement('a:chExt'); |
174
|
60 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
175
|
60 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
176
|
60 |
|
$objWriter->endElement(); // a:chExt |
177
|
|
|
|
178
|
60 |
|
$objWriter->endElement(); |
179
|
|
|
|
180
|
60 |
|
$objWriter->endElement(); |
181
|
|
|
|
182
|
|
|
// Loop shapes |
183
|
60 |
|
$shapeId = 1; |
184
|
60 |
|
$shapes = $pSlide->getShapeCollection(); |
185
|
60 |
|
foreach ($shapes as $shape) { |
186
|
|
|
// Increment $shapeId |
187
|
53 |
|
++$shapeId; |
188
|
|
|
|
189
|
|
|
// Check type |
190
|
53 |
|
if ($shape instanceof RichText) { |
191
|
21 |
|
$this->writeShapeText($objWriter, $shape, $shapeId); |
192
|
53 |
|
} elseif ($shape instanceof Table) { |
193
|
10 |
|
$this->writeShapeTable($objWriter, $shape, $shapeId); |
194
|
33 |
|
} elseif ($shape instanceof Line) { |
195
|
2 |
|
$this->writeShapeLine($objWriter, $shape, $shapeId); |
196
|
24 |
|
} elseif ($shape instanceof ShapeChart) { |
197
|
20 |
|
$this->writeShapeChart($objWriter, $shape, $shapeId); |
198
|
23 |
|
} elseif ($shape instanceof AbstractDrawing) { |
199
|
4 |
|
$this->writeShapePic($objWriter, $shape, $shapeId); |
200
|
4 |
|
} elseif ($shape instanceof Group) { |
201
|
|
|
$this->writeShapeGroup($objWriter, $shape, $shapeId); |
202
|
|
|
} |
203
|
60 |
|
} |
204
|
|
|
|
205
|
|
|
// TODO |
206
|
60 |
|
$objWriter->endElement(); |
207
|
|
|
|
208
|
60 |
|
$objWriter->endElement(); |
209
|
|
|
|
210
|
|
|
// p:clrMapOvr |
211
|
60 |
|
$objWriter->startElement('p:clrMapOvr'); |
212
|
|
|
|
213
|
|
|
// a:masterClrMapping |
214
|
60 |
|
$objWriter->writeElement('a:masterClrMapping', null); |
215
|
|
|
|
216
|
60 |
|
$objWriter->endElement(); |
217
|
|
|
|
218
|
60 |
|
if (!is_null($pSlide->getTransition())) { |
219
|
1 |
|
$this->writeTransition($objWriter, $pSlide->getTransition()); |
220
|
1 |
|
} |
221
|
|
|
|
222
|
|
|
//do animation writing |
223
|
60 |
|
$shapeId = 1; |
224
|
60 |
|
$shapes = $pSlide->getShapeCollection(); |
225
|
|
|
|
226
|
60 |
|
$animations = $pSlide->getAnimations(); |
227
|
|
|
|
228
|
60 |
|
if(count($animations) > 0){ |
|
|
|
|
229
|
|
|
|
230
|
|
|
$hashToIdMap = ARRAY(); |
|
|
|
|
231
|
|
|
|
232
|
|
|
foreach($shapes as $shape){ |
|
|
|
|
233
|
|
|
$shapeId += 1; |
234
|
|
|
$hash = $shape->getHashCode(); |
235
|
|
|
$hashToIdMap[$hash] = $shapeId; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
$animationIds = ARRAY(); |
|
|
|
|
239
|
|
|
|
240
|
|
|
foreach($animations as $animation){ |
|
|
|
|
241
|
|
|
$shapesInAnimation = $animation->getShapeCollection(); |
242
|
|
|
foreach($shapesInAnimation as $shape){ |
|
|
|
|
243
|
|
|
$hash = $shape->getHashCode(); |
244
|
|
|
$animationIds[] = $hashToIdMap[$hash]; |
245
|
|
|
} |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
|
249
|
|
|
$idCount = 1; |
250
|
|
|
|
251
|
|
|
$objWriter->startElement('p:timing'); |
252
|
|
|
|
253
|
|
|
$objWriter->startElement('p:tnLst'); |
254
|
|
|
|
255
|
|
|
$objWriter->startElement('p:par'); |
256
|
|
|
|
257
|
|
|
$objWriter->startElement('p:cTn'); |
258
|
|
|
$objWriter->writeAttribute('id',$idCount); |
259
|
|
|
$idCount += 1; |
260
|
|
|
$objWriter->writeAttribute('dur','indefinite'); |
261
|
|
|
$objWriter->writeAttribute('restart','never'); |
262
|
|
|
$objWriter->writeAttribute('nodeType','tmRoot'); |
263
|
|
|
|
264
|
|
|
$objWriter->startElement('p:childTnLst'); |
265
|
|
|
|
266
|
|
|
$objWriter->startElement('p:seq'); |
267
|
|
|
$objWriter->writeAttribute('concurrent','1'); |
268
|
|
|
$objWriter->writeAttribute('nextAc','seek'); |
269
|
|
|
|
270
|
|
|
$objWriter->startElement('p:cTn'); |
271
|
|
|
$objWriter->writeAttribute('id',$idCount); |
272
|
|
|
$idCount += 1; |
273
|
|
|
$objWriter->writeAttribute('dur','indefinite'); |
274
|
|
|
$objWriter->writeAttribute('nodeType','mainSeq'); |
275
|
|
|
|
276
|
|
|
$objWriter->startElement("p:childTnLst"); |
277
|
|
|
|
278
|
|
|
//each animation has multiple shapes |
279
|
|
|
foreach($animations as $animation){ |
|
|
|
|
280
|
|
|
|
281
|
|
|
$objWriter->startElement("p:par"); |
282
|
|
|
|
283
|
|
|
$objWriter->startElement("p:cTn"); |
284
|
|
|
$objWriter->writeAttribute("id",$idCount); |
285
|
|
|
$idCount += 1; |
286
|
|
|
$objWriter->writeAttribute("fill","hold"); |
287
|
|
|
|
288
|
|
|
$objWriter->startElement('p:stCondLst'); |
289
|
|
|
|
290
|
|
|
$objWriter->startElement('p:cond'); |
291
|
|
|
$objWriter->writeAttribute("delay","indefinite"); |
292
|
|
|
$objWriter->endElement(); |
293
|
|
|
|
294
|
|
|
$objWriter->endElement(); |
295
|
|
|
|
296
|
|
|
$objWriter->startElement("p:childTnLst"); |
297
|
|
|
|
298
|
|
|
$objWriter->startElement("p:par"); |
299
|
|
|
|
300
|
|
|
$objWriter->startElement("p:cTn"); |
301
|
|
|
$objWriter->writeAttribute("id",$idCount); |
302
|
|
|
$idCount += 1; |
303
|
|
|
$objWriter->writeAttribute("fill","hold"); |
304
|
|
|
|
305
|
|
|
$objWriter->startElement('p:stCondLst'); |
306
|
|
|
|
307
|
|
|
$objWriter->startElement('p:cond'); |
308
|
|
|
$objWriter->writeAttribute("delay","0"); |
309
|
|
|
$objWriter->endElement(); |
310
|
|
|
|
311
|
|
|
$objWriter->endElement(); |
312
|
|
|
|
313
|
|
|
$objWriter->startElement("p:childTnLst"); |
314
|
|
|
|
315
|
|
|
$shapesInAnimation = $animation->getShapeCollection(); |
316
|
|
|
|
317
|
|
|
$firstShapeInAnimation = true; |
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
foreach($shapesInAnimation as $shape){ |
|
|
|
|
320
|
|
|
$hash = $shape->getHashCode(); |
|
|
|
|
321
|
|
|
$shapeId = $hashToIdMap[$hash]; |
|
|
|
|
322
|
|
|
|
323
|
|
|
$objWriter->startElement("p:par"); |
|
|
|
|
324
|
|
|
|
325
|
|
|
$objWriter->startElement("p:cTn"); |
|
|
|
|
326
|
|
|
$objWriter->writeAttribute("id", $idCount); |
|
|
|
|
327
|
|
|
$idCount += 1; |
|
|
|
|
328
|
|
|
$objWriter->writeAttribute("presetID", "1"); |
|
|
|
|
329
|
|
|
$objWriter->writeAttribute("presetClass", "entr"); |
|
|
|
|
330
|
|
|
$objWriter->writeAttribute("fill", "hold"); |
|
|
|
|
331
|
|
|
$objWriter->writeAttribute("presetSubtype", "0"); |
|
|
|
|
332
|
|
|
$objWriter->writeAttribute("grpId", "0"); |
|
|
|
|
333
|
|
|
|
334
|
|
|
$nodeType = $firstShapeInAnimation ? "clickEffect" : "withEffect"; |
|
|
|
|
335
|
|
|
|
336
|
|
|
$objWriter->writeAttribute("nodeType",$nodeType); |
|
|
|
|
337
|
|
|
|
338
|
|
|
$objWriter->startElement("p:stCondLst"); |
|
|
|
|
339
|
|
|
|
340
|
|
|
$objWriter->startElement("p:cond"); |
|
|
|
|
341
|
|
|
$objWriter->writeAttribute("delay","0"); |
|
|
|
|
342
|
|
|
$objWriter->endElement(); |
|
|
|
|
343
|
|
|
|
344
|
|
|
$objWriter->endElement(); |
|
|
|
|
345
|
|
|
|
346
|
|
|
$objWriter->startElement("p:childTnLst"); |
|
|
|
|
347
|
|
|
|
348
|
|
|
$objWriter->startElement("p:set"); |
|
|
|
|
349
|
|
|
|
350
|
|
|
$objWriter->startElement("p:cBhvr"); |
|
|
|
|
351
|
|
|
|
352
|
|
|
$objWriter->startElement("p:cTn"); |
|
|
|
|
353
|
|
|
$objWriter->writeAttribute("id",$idCount); |
|
|
|
|
354
|
|
|
$idCount += 1; |
|
|
|
|
355
|
|
|
$objWriter->writeAttribute("dur","1"); |
|
|
|
|
356
|
|
|
$objWriter->writeAttribute("fill","hold"); |
|
|
|
|
357
|
|
|
|
358
|
|
|
$objWriter->startElement("p:stCondLst"); |
|
|
|
|
359
|
|
|
|
|
|
|
|
360
|
|
|
$objWriter->startElement("p:cond"); |
|
|
|
|
361
|
|
|
$objWriter->writeAttribute("delay","0"); |
|
|
|
|
362
|
|
|
$objWriter->endElement(); |
|
|
|
|
363
|
|
|
|
364
|
|
|
$objWriter->endElement(); |
|
|
|
|
365
|
|
|
|
366
|
|
|
|
367
|
|
|
|
368
|
|
|
$objWriter->endElement(); |
|
|
|
|
369
|
|
|
|
370
|
|
|
$objWriter->startElement("p:tgtEl"); |
|
|
|
|
371
|
|
|
|
372
|
|
|
$objWriter->startElement("p:spTgt"); |
|
|
|
|
373
|
|
|
//shape id |
|
|
|
|
374
|
|
|
$objWriter->writeAttribute("spid",$shapeId); |
|
|
|
|
375
|
|
|
$objWriter->endElement(); |
|
|
|
|
376
|
|
|
|
377
|
|
|
$objWriter->endElement(); |
|
|
|
|
378
|
|
|
|
379
|
|
|
$objWriter->startElement("p:attrNameLst"); |
|
|
|
|
380
|
|
|
|
381
|
|
|
$objWriter->writeElement("p:attrName","style.visibility"); |
|
|
|
|
382
|
|
|
|
383
|
|
|
$objWriter->endElement(); |
|
|
|
|
384
|
|
|
|
385
|
|
|
$objWriter->endElement(); |
|
|
|
|
386
|
|
|
|
387
|
|
|
$objWriter->startElement("p:to"); |
|
|
|
|
388
|
|
|
|
389
|
|
|
$objWriter->startElement("p:strVal"); |
|
|
|
|
390
|
|
|
$objWriter->writeAttribute("val","visible"); |
|
|
|
|
391
|
|
|
$objWriter->endElement(); |
|
|
|
|
392
|
|
|
|
393
|
|
|
$objWriter->endElement(); |
|
|
|
|
394
|
|
|
|
395
|
|
|
$objWriter->endElement(); |
|
|
|
|
396
|
|
|
|
397
|
|
|
$objWriter->endElement(); //end child tn lst |
|
|
|
|
398
|
|
|
|
399
|
|
|
$objWriter->endElement(); //end ctn |
|
|
|
|
400
|
|
|
|
401
|
|
|
$objWriter->endElement(); |
|
|
|
|
402
|
|
|
|
403
|
|
|
$firstShapeInAnimation = false; |
|
|
|
|
404
|
|
|
} |
|
|
|
|
405
|
|
|
|
406
|
|
|
|
407
|
|
|
$objWriter->endElement(); //end child lst |
|
|
|
|
408
|
|
|
|
409
|
|
|
$objWriter->endElement(); //end ctn |
|
|
|
|
410
|
|
|
|
411
|
|
|
$objWriter->endElement(); //end par |
|
|
|
|
412
|
|
|
|
413
|
|
|
|
414
|
|
|
$objWriter->endElement(); //end childtnlist |
|
|
|
|
415
|
|
|
|
416
|
|
|
$objWriter->endElement(); //end ctn |
|
|
|
|
417
|
|
|
|
418
|
|
|
$objWriter->endElement(); //end par |
|
|
|
|
419
|
|
|
|
420
|
|
|
} |
|
|
|
|
421
|
|
|
|
422
|
|
|
|
423
|
|
|
$objWriter->endElement(); |
|
|
|
|
424
|
|
|
|
425
|
|
|
$objWriter->endElement(); |
|
|
|
|
426
|
|
|
|
427
|
|
|
///prevCondLst |
|
|
|
|
428
|
|
|
$objWriter->startElement("p:prevCondLst"); |
|
|
|
|
429
|
|
|
|
430
|
|
|
$objWriter->startElement('p:cond'); |
|
|
|
|
431
|
|
|
$objWriter->writeAttribute('evt','onPrev'); |
|
|
|
|
432
|
|
|
$objWriter->writeAttribute('delay','0'); |
|
|
|
|
433
|
|
|
|
434
|
|
|
$objWriter->startElement('p:tgtEl'); |
|
|
|
|
435
|
|
|
|
436
|
|
|
$objWriter->writeElement('p:sldTgt', null); |
|
|
|
|
437
|
|
|
|
438
|
|
|
$objWriter->endElement(); |
|
|
|
|
439
|
|
|
|
440
|
|
|
$objWriter->endElement(); |
|
|
|
|
441
|
|
|
|
442
|
|
|
$objWriter->endElement(); |
|
|
|
|
443
|
|
|
|
444
|
|
|
//nextCondLst |
|
|
|
|
445
|
|
|
$objWriter->startElement("p:nextCondLst"); |
|
|
|
|
446
|
|
|
|
447
|
|
|
$objWriter->startElement('p:cond'); |
|
|
|
|
448
|
|
|
$objWriter->writeAttribute('evt','onNext'); |
|
|
|
|
449
|
|
|
$objWriter->writeAttribute('delay','0'); |
|
|
|
|
450
|
|
|
|
451
|
|
|
$objWriter->startElement('p:tgtEl'); |
|
|
|
|
452
|
|
|
|
453
|
|
|
$objWriter->writeElement('p:sldTgt', null); |
|
|
|
|
454
|
|
|
|
455
|
|
|
$objWriter->endElement(); |
|
|
|
|
456
|
|
|
|
457
|
|
|
$objWriter->endElement(); |
|
|
|
|
458
|
|
|
|
459
|
|
|
$objWriter->endElement(); |
|
|
|
|
460
|
|
|
|
461
|
|
|
$objWriter->endElement(); //end p:seq |
|
|
|
|
462
|
|
|
|
463
|
|
|
$objWriter->endElement(); //end p:childTnLst |
|
|
|
|
464
|
|
|
|
465
|
|
|
$objWriter->endElement(); //end ctn |
|
|
|
|
466
|
|
|
|
467
|
|
|
$objWriter->endElement(); //end par |
|
|
|
|
468
|
|
|
|
469
|
|
|
$objWriter->endElement(); // end tnLst |
|
|
|
|
470
|
|
|
|
471
|
|
|
$objWriter->startElement('p:bldLst'); |
|
|
|
|
472
|
|
|
|
473
|
|
|
//add in ids of all shapes in this slides animations |
|
|
|
|
474
|
|
|
|
475
|
|
|
foreach($animationIds as $id){ |
|
|
|
|
476
|
|
|
$objWriter->startElement('p:bldP'); |
|
|
|
|
477
|
|
|
$objWriter->writeAttribute("spid",$id); |
|
|
|
|
478
|
|
|
$objWriter->writeAttribute('grpId',0); |
|
|
|
|
479
|
|
|
$objWriter->endELement(); |
|
|
|
|
480
|
|
|
} |
|
|
|
|
481
|
|
|
|
482
|
|
|
|
483
|
|
|
$objWriter->endElement(); // end bldLst |
|
|
|
|
484
|
|
|
|
485
|
|
|
$objWriter->endElement(); //end timing |
|
|
|
|
486
|
|
|
|
487
|
|
|
$objWriter->endElement(); |
|
|
|
|
488
|
|
|
} |
|
|
|
|
489
|
|
|
|
|
|
|
|
490
|
|
|
|
491
|
60 |
|
$objWriter->endElement(); |
492
|
|
|
|
493
|
|
|
// Return |
494
|
60 |
|
return $objWriter->getData(); |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* Write group |
499
|
|
|
* |
500
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
501
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Group $group |
502
|
|
|
* @param int $shapeId |
503
|
|
|
*/ |
504
|
|
|
private function writeShapeGroup(XMLWriter $objWriter, Group $group, &$shapeId) |
505
|
|
|
{ |
506
|
|
|
// p:grpSp |
507
|
|
|
$objWriter->startElement('p:grpSp'); |
508
|
|
|
|
509
|
|
|
// p:nvGrpSpPr |
510
|
|
|
$objWriter->startElement('p:nvGrpSpPr'); |
511
|
|
|
|
512
|
|
|
// p:cNvPr |
513
|
|
|
$objWriter->startElement('p:cNvPr'); |
514
|
|
|
$objWriter->writeAttribute('name', 'Group '.$shapeId++); |
515
|
|
|
$objWriter->writeAttribute('id', $shapeId); |
516
|
|
|
$objWriter->endElement(); // p:cNvPr |
517
|
|
|
// NOTE: Re: $shapeId This seems to be how PowerPoint 2010 does business. |
518
|
|
|
|
519
|
|
|
// p:cNvGrpSpPr |
520
|
|
|
$objWriter->writeElement('p:cNvGrpSpPr', null); |
521
|
|
|
|
522
|
|
|
// p:nvPr |
523
|
|
|
$objWriter->writeElement('p:nvPr', null); |
524
|
|
|
|
525
|
|
|
$objWriter->endElement(); // p:nvGrpSpPr |
526
|
|
|
|
527
|
|
|
// p:grpSpPr |
528
|
|
|
$objWriter->startElement('p:grpSpPr'); |
529
|
|
|
|
530
|
|
|
// a:xfrm |
531
|
|
|
$objWriter->startElement('a:xfrm'); |
532
|
|
|
|
533
|
|
|
// a:off |
534
|
|
|
$objWriter->startElement('a:off'); |
535
|
|
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX())); |
536
|
|
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY())); |
537
|
|
|
$objWriter->endElement(); // a:off |
538
|
|
|
|
539
|
|
|
// a:ext |
540
|
|
|
$objWriter->startElement('a:ext'); |
541
|
|
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX())); |
542
|
|
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY())); |
543
|
|
|
$objWriter->endElement(); // a:ext |
544
|
|
|
|
545
|
|
|
// a:chOff |
546
|
|
|
$objWriter->startElement('a:chOff'); |
547
|
|
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($group->getOffsetX())); |
548
|
|
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($group->getOffsetY())); |
549
|
|
|
$objWriter->endElement(); // a:chOff |
550
|
|
|
|
551
|
|
|
// a:chExt |
552
|
|
|
$objWriter->startElement('a:chExt'); |
553
|
|
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($group->getExtentX())); |
554
|
|
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($group->getExtentY())); |
555
|
|
|
$objWriter->endElement(); // a:chExt |
556
|
|
|
|
557
|
|
|
$objWriter->endElement(); // a:xfrm |
558
|
|
|
|
559
|
|
|
$objWriter->endElement(); // p:grpSpPr |
560
|
|
|
|
561
|
|
|
$shapes = $group->getShapeCollection(); |
562
|
|
|
foreach ($shapes as $shape) { |
563
|
|
|
// Increment $shapeId |
564
|
|
|
++$shapeId; |
565
|
|
|
|
566
|
|
|
// Check type |
567
|
|
|
if ($shape instanceof RichText) { |
568
|
|
|
$this->writeShapeText($objWriter, $shape, $shapeId); |
569
|
|
|
} elseif ($shape instanceof Table) { |
570
|
|
|
$this->writeShapeTable($objWriter, $shape, $shapeId); |
571
|
|
|
} elseif ($shape instanceof Line) { |
572
|
|
|
$this->writeShapeLine($objWriter, $shape, $shapeId); |
573
|
|
|
} elseif ($shape instanceof ShapeChart) { |
574
|
|
|
$this->writeShapeChart($objWriter, $shape, $shapeId); |
575
|
|
|
} elseif ($shape instanceof AbstractDrawing) { |
576
|
|
|
$this->writeShapePic($objWriter, $shape, $shapeId); |
577
|
|
|
} elseif ($shape instanceof Group) { |
578
|
|
|
$this->writeShapeGroup($objWriter, $shape, $shapeId); |
579
|
|
|
} |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
$objWriter->endElement(); // p:grpSp |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
/** |
586
|
|
|
* Write chart |
587
|
|
|
* |
588
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
589
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Chart $shape |
590
|
|
|
* @param int $shapeId |
591
|
|
|
*/ |
592
|
20 |
|
private function writeShapeChart(XMLWriter $objWriter, ShapeChart $shape, $shapeId) |
593
|
|
|
{ |
594
|
|
|
// p:graphicFrame |
595
|
20 |
|
$objWriter->startElement('p:graphicFrame'); |
596
|
|
|
|
597
|
|
|
// p:nvGraphicFramePr |
598
|
20 |
|
$objWriter->startElement('p:nvGraphicFramePr'); |
599
|
|
|
|
600
|
|
|
// p:cNvPr |
601
|
20 |
|
$objWriter->startElement('p:cNvPr'); |
602
|
20 |
|
$objWriter->writeAttribute('id', $shapeId); |
603
|
20 |
|
$objWriter->writeAttribute('name', $shape->getName()); |
604
|
20 |
|
$objWriter->writeAttribute('descr', $shape->getDescription()); |
605
|
20 |
|
$objWriter->endElement(); |
606
|
|
|
|
607
|
|
|
// p:cNvGraphicFramePr |
608
|
20 |
|
$objWriter->writeElement('p:cNvGraphicFramePr', null); |
609
|
|
|
|
610
|
|
|
// p:nvPr |
611
|
20 |
|
$objWriter->writeElement('p:nvPr', null); |
612
|
|
|
|
613
|
20 |
|
$objWriter->endElement(); |
614
|
|
|
|
615
|
|
|
// p:xfrm |
616
|
20 |
|
$objWriter->startElement('p:xfrm'); |
617
|
20 |
|
$objWriter->writeAttribute('rot', CommonDrawing::degreesToAngle($shape->getRotation())); |
618
|
|
|
|
619
|
|
|
// a:off |
620
|
20 |
|
$objWriter->startElement('a:off'); |
621
|
20 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
622
|
20 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
623
|
20 |
|
$objWriter->endElement(); |
624
|
|
|
|
625
|
|
|
// a:ext |
626
|
20 |
|
$objWriter->startElement('a:ext'); |
627
|
20 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
628
|
20 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
629
|
20 |
|
$objWriter->endElement(); |
630
|
|
|
|
631
|
20 |
|
$objWriter->endElement(); |
632
|
|
|
|
633
|
|
|
// a:graphic |
634
|
20 |
|
$objWriter->startElement('a:graphic'); |
635
|
|
|
|
636
|
|
|
// a:graphicData |
637
|
20 |
|
$objWriter->startElement('a:graphicData'); |
638
|
20 |
|
$objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); |
639
|
|
|
|
640
|
|
|
// c:chart |
641
|
20 |
|
$objWriter->startElement('c:chart'); |
642
|
20 |
|
$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); |
643
|
20 |
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
644
|
20 |
|
$objWriter->writeAttribute('r:id', $shape->relationId); |
645
|
20 |
|
$objWriter->endElement(); |
646
|
|
|
|
647
|
20 |
|
$objWriter->endElement(); |
648
|
|
|
|
649
|
20 |
|
$objWriter->endElement(); |
650
|
|
|
|
651
|
20 |
|
$objWriter->endElement(); |
652
|
20 |
|
} |
653
|
|
|
|
654
|
|
|
/** |
655
|
|
|
* Write pic |
656
|
|
|
* |
657
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
658
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\AbstractDrawing $shape |
659
|
|
|
* @param int $shapeId |
660
|
|
|
* @throws \Exception |
661
|
|
|
*/ |
662
|
4 |
|
private function writeShapePic(XMLWriter $objWriter, AbstractDrawing $shape, $shapeId) |
663
|
|
|
{ |
664
|
|
|
// p:pic |
665
|
4 |
|
$objWriter->startElement('p:pic'); |
666
|
|
|
|
667
|
|
|
// p:nvPicPr |
668
|
4 |
|
$objWriter->startElement('p:nvPicPr'); |
669
|
|
|
|
670
|
|
|
// p:cNvPr |
671
|
4 |
|
$objWriter->startElement('p:cNvPr'); |
672
|
4 |
|
$objWriter->writeAttribute('id', $shapeId); |
673
|
4 |
|
$objWriter->writeAttribute('name', $shape->getName()); |
674
|
4 |
|
$objWriter->writeAttribute('descr', $shape->getDescription()); |
675
|
|
|
|
676
|
|
|
// a:hlinkClick |
677
|
4 |
|
if ($shape->hasHyperlink()) { |
678
|
1 |
|
$this->writeHyperlink($objWriter, $shape); |
679
|
1 |
|
} |
680
|
|
|
|
681
|
4 |
|
$objWriter->endElement(); |
682
|
|
|
|
683
|
|
|
// p:cNvPicPr |
684
|
4 |
|
$objWriter->startElement('p:cNvPicPr'); |
685
|
|
|
|
686
|
|
|
// a:picLocks |
687
|
4 |
|
$objWriter->startElement('a:picLocks'); |
688
|
4 |
|
$objWriter->writeAttribute('noChangeAspect', '1'); |
689
|
4 |
|
$objWriter->endElement(); |
690
|
|
|
|
691
|
4 |
|
$objWriter->endElement(); |
692
|
|
|
|
693
|
|
|
// p:nvPr |
694
|
4 |
|
$objWriter->writeElement('p:nvPr', null); |
695
|
4 |
|
$objWriter->endElement(); |
696
|
|
|
|
697
|
|
|
// p:blipFill |
698
|
4 |
|
$objWriter->startElement('p:blipFill'); |
699
|
|
|
|
700
|
|
|
// a:blip |
701
|
4 |
|
$objWriter->startElement('a:blip'); |
702
|
4 |
|
$objWriter->writeAttribute('r:embed', $shape->relationId); |
703
|
4 |
|
$objWriter->endElement(); |
704
|
|
|
|
705
|
|
|
// a:stretch |
706
|
4 |
|
$objWriter->startElement('a:stretch'); |
707
|
4 |
|
$objWriter->writeElement('a:fillRect', null); |
708
|
4 |
|
$objWriter->endElement(); |
709
|
|
|
|
710
|
4 |
|
$objWriter->endElement(); |
711
|
|
|
|
712
|
|
|
// p:spPr |
713
|
4 |
|
$objWriter->startElement('p:spPr'); |
714
|
|
|
|
715
|
|
|
// a:xfrm |
716
|
4 |
|
$objWriter->startElement('a:xfrm'); |
717
|
4 |
|
$objWriter->writeAttribute('rot', CommonDrawing::degreesToAngle($shape->getRotation())); |
718
|
|
|
|
719
|
|
|
// a:off |
720
|
4 |
|
$objWriter->startElement('a:off'); |
721
|
4 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
722
|
4 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
723
|
4 |
|
$objWriter->endElement(); |
724
|
|
|
|
725
|
|
|
// a:ext |
726
|
4 |
|
$objWriter->startElement('a:ext'); |
727
|
4 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
728
|
4 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
729
|
4 |
|
$objWriter->endElement(); |
730
|
|
|
|
731
|
4 |
|
$objWriter->endElement(); |
732
|
|
|
|
733
|
|
|
// a:prstGeom |
734
|
4 |
|
$objWriter->startElement('a:prstGeom'); |
735
|
4 |
|
$objWriter->writeAttribute('prst', 'rect'); |
736
|
|
|
|
737
|
|
|
// a:avLst |
738
|
4 |
|
$objWriter->writeElement('a:avLst', null); |
739
|
|
|
|
740
|
4 |
|
$objWriter->endElement(); |
741
|
|
|
|
742
|
4 |
|
if ($shape->getBorder()->getLineStyle() != Border::LINE_NONE) { |
743
|
1 |
|
$this->writeBorder($objWriter, $shape->getBorder(), ''); |
744
|
1 |
|
} |
745
|
|
|
|
746
|
4 |
|
if ($shape->getShadow()->isVisible()) { |
747
|
1 |
|
$this->writeShadow($objWriter, $shape->getShadow()); |
748
|
1 |
|
} |
749
|
|
|
|
750
|
4 |
|
$objWriter->endElement(); |
751
|
|
|
|
752
|
4 |
|
$objWriter->endElement(); |
753
|
4 |
|
} |
754
|
|
|
|
755
|
|
|
/** |
756
|
|
|
* Write txt |
757
|
|
|
* |
758
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
759
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\RichText $shape |
760
|
|
|
* @param int $shapeId |
761
|
|
|
* @throws \Exception |
762
|
|
|
*/ |
763
|
21 |
|
private function writeShapeText(XMLWriter $objWriter, RichText $shape, $shapeId) |
764
|
|
|
{ |
765
|
|
|
// p:sp |
766
|
21 |
|
$objWriter->startElement('p:sp'); |
767
|
|
|
|
768
|
|
|
// p:sp\p:nvSpPr |
769
|
21 |
|
$objWriter->startElement('p:nvSpPr'); |
770
|
|
|
|
771
|
|
|
// p:sp\p:nvSpPr\p:cNvPr |
772
|
21 |
|
$objWriter->startElement('p:cNvPr'); |
773
|
21 |
|
$objWriter->writeAttribute('id', $shapeId); |
774
|
21 |
|
$objWriter->writeAttribute('name', ''); |
775
|
|
|
|
776
|
|
|
// Hyperlink |
777
|
21 |
|
if ($shape->hasHyperlink()) { |
778
|
1 |
|
$this->writeHyperlink($objWriter, $shape); |
779
|
1 |
|
} |
780
|
|
|
// > p:sp\p:nvSpPr |
781
|
21 |
|
$objWriter->endElement(); |
782
|
|
|
|
783
|
|
|
// p:sp\p:cNvSpPr |
784
|
21 |
|
$objWriter->startElement('p:cNvSpPr'); |
785
|
21 |
|
$objWriter->writeAttribute('txBox', '1'); |
786
|
21 |
|
$objWriter->endElement(); |
787
|
|
|
// p:sp\p:cNvSpPr\p:nvPr |
788
|
21 |
|
$objWriter->writeElement('p:nvPr', null); |
789
|
|
|
// > p:sp\p:cNvSpPr |
790
|
21 |
|
$objWriter->endElement(); |
791
|
|
|
|
792
|
|
|
// p:sp\p:spPr |
793
|
21 |
|
$objWriter->startElement('p:spPr'); |
794
|
|
|
|
795
|
|
|
// p:sp\p:spPr\a:xfrm |
796
|
21 |
|
$objWriter->startElement('a:xfrm'); |
797
|
21 |
|
$objWriter->writeAttribute('rot', CommonDrawing::degreesToAngle($shape->getRotation())); |
798
|
|
|
|
799
|
|
|
// p:sp\p:spPr\a:xfrm\a:off |
800
|
21 |
|
$objWriter->startElement('a:off'); |
801
|
21 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
802
|
21 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
803
|
21 |
|
$objWriter->endElement(); |
804
|
|
|
|
805
|
|
|
// p:sp\p:spPr\a:xfrm\a:ext |
806
|
21 |
|
$objWriter->startElement('a:ext'); |
807
|
21 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
808
|
21 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
809
|
21 |
|
$objWriter->endElement(); |
810
|
|
|
|
811
|
|
|
// > p:sp\p:spPr\a:xfrm |
812
|
21 |
|
$objWriter->endElement(); |
813
|
|
|
|
814
|
|
|
// p:sp\p:spPr\a:prstGeom |
815
|
21 |
|
$objWriter->startElement('a:prstGeom'); |
816
|
21 |
|
$objWriter->writeAttribute('prst', 'rect'); |
817
|
21 |
|
$objWriter->endElement(); |
818
|
|
|
|
819
|
21 |
|
if ($shape->getFill()) { |
820
|
21 |
|
$this->writeFill($objWriter, $shape->getFill()); |
821
|
21 |
|
} |
822
|
21 |
|
if ($shape->getBorder()->getLineStyle() != Border::LINE_NONE) { |
823
|
|
|
$this->writeBorder($objWriter, $shape->getBorder(), ''); |
824
|
|
|
} |
825
|
21 |
|
if ($shape->getShadow()->isVisible()) { |
826
|
1 |
|
$this->writeShadow($objWriter, $shape->getShadow()); |
827
|
1 |
|
} |
828
|
|
|
// > p:sp\p:spPr |
829
|
21 |
|
$objWriter->endElement(); |
830
|
|
|
|
831
|
|
|
// p:txBody |
832
|
21 |
|
$objWriter->startElement('p:txBody'); |
833
|
|
|
|
834
|
|
|
// a:bodyPr |
835
|
|
|
//@link :http://msdn.microsoft.com/en-us/library/documentformat.openxml.drawing.bodyproperties%28v=office.14%29.aspx |
836
|
21 |
|
$objWriter->startElement('a:bodyPr'); |
837
|
21 |
|
$verticalAlign = $shape->getActiveParagraph()->getAlignment()->getVertical(); |
838
|
21 |
|
if ($verticalAlign != Alignment::VERTICAL_BASE && $verticalAlign != Alignment::VERTICAL_AUTO) { |
839
|
3 |
|
$objWriter->writeAttribute('anchor', $verticalAlign); |
840
|
3 |
|
} |
841
|
21 |
|
if ($shape->getWrap() != RichText::WRAP_SQUARE) { |
842
|
|
|
$objWriter->writeAttribute('wrap', $shape->getWrap()); |
843
|
|
|
} |
844
|
21 |
|
$objWriter->writeAttribute('rtlCol', '0'); |
845
|
|
|
|
846
|
21 |
|
if ($shape->getHorizontalOverflow() != RichText::OVERFLOW_OVERFLOW) { |
847
|
|
|
$objWriter->writeAttribute('horzOverflow', $shape->getHorizontalOverflow()); |
848
|
|
|
} |
849
|
21 |
|
if ($shape->getVerticalOverflow() != RichText::OVERFLOW_OVERFLOW) { |
850
|
|
|
$objWriter->writeAttribute('vertOverflow', $shape->getVerticalOverflow()); |
851
|
|
|
} |
852
|
|
|
|
853
|
21 |
|
if ($shape->isUpright()) { |
854
|
1 |
|
$objWriter->writeAttribute('upright', '1'); |
855
|
1 |
|
} |
856
|
21 |
|
if ($shape->isVertical()) { |
857
|
1 |
|
$objWriter->writeAttribute('vert', 'vert'); |
858
|
1 |
|
} |
859
|
|
|
|
860
|
21 |
|
$objWriter->writeAttribute('bIns', CommonDrawing::pixelsToEmu($shape->getInsetBottom())); |
861
|
21 |
|
$objWriter->writeAttribute('lIns', CommonDrawing::pixelsToEmu($shape->getInsetLeft())); |
862
|
21 |
|
$objWriter->writeAttribute('rIns', CommonDrawing::pixelsToEmu($shape->getInsetRight())); |
863
|
21 |
|
$objWriter->writeAttribute('tIns', CommonDrawing::pixelsToEmu($shape->getInsetTop())); |
864
|
|
|
|
865
|
21 |
|
if ($shape->getColumns() <> 1) { |
866
|
|
|
$objWriter->writeAttribute('numCol', $shape->getColumns()); |
867
|
|
|
} |
868
|
|
|
|
869
|
|
|
// a:spAutoFit |
870
|
21 |
|
$objWriter->startElement('a:' . $shape->getAutoFit()); |
871
|
21 |
|
if ($shape->getAutoFit() == RichText::AUTOFIT_NORMAL) { |
872
|
1 |
|
if (!is_null($shape->getFontScale())) { |
873
|
1 |
|
$objWriter->writeAttribute('fontScale', (int)($shape->getFontScale() * 1000)); |
874
|
1 |
|
} |
875
|
1 |
|
if (!is_null($shape->getLineSpaceReduction())) { |
876
|
1 |
|
$objWriter->writeAttribute('lnSpcReduction', (int)($shape->getLineSpaceReduction() * 1000)); |
877
|
1 |
|
} |
878
|
1 |
|
} |
879
|
|
|
|
880
|
21 |
|
$objWriter->endElement(); |
881
|
|
|
|
882
|
21 |
|
$objWriter->endElement(); |
883
|
|
|
|
884
|
|
|
// a:lstStyle |
885
|
21 |
|
$objWriter->writeElement('a:lstStyle', null); |
886
|
|
|
|
887
|
|
|
// Write paragraphs |
888
|
21 |
|
$this->writeParagraphs($objWriter, $shape->getParagraphs()); |
889
|
|
|
|
890
|
21 |
|
$objWriter->endElement(); |
891
|
|
|
|
892
|
21 |
|
$objWriter->endElement(); |
893
|
21 |
|
} |
894
|
|
|
|
895
|
|
|
/** |
896
|
|
|
* Write table |
897
|
|
|
* |
898
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
899
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Table $shape |
900
|
|
|
* @param int $shapeId |
901
|
|
|
* @throws \Exception |
902
|
|
|
*/ |
903
|
10 |
|
private function writeShapeTable(XMLWriter $objWriter, Table $shape, $shapeId) |
904
|
|
|
{ |
905
|
|
|
// p:graphicFrame |
906
|
10 |
|
$objWriter->startElement('p:graphicFrame'); |
907
|
|
|
|
908
|
|
|
// p:nvGraphicFramePr |
909
|
10 |
|
$objWriter->startElement('p:nvGraphicFramePr'); |
910
|
|
|
|
911
|
|
|
// p:cNvPr |
912
|
10 |
|
$objWriter->startElement('p:cNvPr'); |
913
|
10 |
|
$objWriter->writeAttribute('id', $shapeId); |
914
|
10 |
|
$objWriter->writeAttribute('name', $shape->getName()); |
915
|
10 |
|
$objWriter->writeAttribute('descr', $shape->getDescription()); |
916
|
|
|
|
917
|
10 |
|
$objWriter->endElement(); |
918
|
|
|
|
919
|
|
|
// p:cNvGraphicFramePr |
920
|
10 |
|
$objWriter->startElement('p:cNvGraphicFramePr'); |
921
|
|
|
|
922
|
|
|
// a:graphicFrameLocks |
923
|
10 |
|
$objWriter->startElement('a:graphicFrameLocks'); |
924
|
10 |
|
$objWriter->writeAttribute('noGrp', '1'); |
925
|
10 |
|
$objWriter->endElement(); |
926
|
|
|
|
927
|
10 |
|
$objWriter->endElement(); |
928
|
|
|
|
929
|
|
|
// p:nvPr |
930
|
10 |
|
$objWriter->writeElement('p:nvPr', null); |
931
|
|
|
|
932
|
10 |
|
$objWriter->endElement(); |
933
|
|
|
|
934
|
|
|
// p:xfrm |
935
|
10 |
|
$objWriter->startElement('p:xfrm'); |
936
|
|
|
|
937
|
|
|
// a:off |
938
|
10 |
|
$objWriter->startElement('a:off'); |
939
|
10 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
940
|
10 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
941
|
10 |
|
$objWriter->endElement(); |
942
|
|
|
|
943
|
|
|
// a:ext |
944
|
10 |
|
$objWriter->startElement('a:ext'); |
945
|
10 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
946
|
10 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
947
|
10 |
|
$objWriter->endElement(); |
948
|
|
|
|
949
|
10 |
|
$objWriter->endElement(); |
950
|
|
|
|
951
|
|
|
// a:graphic |
952
|
10 |
|
$objWriter->startElement('a:graphic'); |
953
|
|
|
|
954
|
|
|
// a:graphicData |
955
|
10 |
|
$objWriter->startElement('a:graphicData'); |
956
|
10 |
|
$objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/table'); |
957
|
|
|
|
958
|
|
|
// a:tbl |
959
|
10 |
|
$objWriter->startElement('a:tbl'); |
960
|
|
|
|
961
|
|
|
// a:tblPr |
962
|
10 |
|
$objWriter->startElement('a:tblPr'); |
963
|
10 |
|
$objWriter->writeAttribute('firstRow', '1'); |
964
|
10 |
|
$objWriter->writeAttribute('bandRow', '1'); |
965
|
|
|
|
966
|
10 |
|
$objWriter->endElement(); |
967
|
|
|
|
968
|
|
|
// a:tblGrid |
969
|
10 |
|
$objWriter->startElement('a:tblGrid'); |
970
|
|
|
|
971
|
|
|
// Write cell widths |
972
|
10 |
|
$countCells = count($shape->getRow(0)->getCells()); |
973
|
10 |
|
for ($cell = 0; $cell < $countCells; $cell++) { |
974
|
|
|
// a:gridCol |
975
|
10 |
|
$objWriter->startElement('a:gridCol'); |
976
|
|
|
|
977
|
|
|
// Calculate column width |
978
|
10 |
|
$width = $shape->getRow(0)->getCell($cell)->getWidth(); |
979
|
10 |
|
if ($width == 0) { |
980
|
10 |
|
$colCount = count($shape->getRow(0)->getCells()); |
981
|
10 |
|
$totalWidth = $shape->getWidth(); |
982
|
10 |
|
$width = $totalWidth / $colCount; |
983
|
10 |
|
} |
984
|
|
|
|
985
|
10 |
|
$objWriter->writeAttribute('w', CommonDrawing::pixelsToEmu($width)); |
986
|
10 |
|
$objWriter->endElement(); |
987
|
10 |
|
} |
988
|
|
|
|
989
|
10 |
|
$objWriter->endElement(); |
990
|
|
|
|
991
|
|
|
// Colspan / rowspan containers |
992
|
10 |
|
$colSpan = array(); |
993
|
10 |
|
$rowSpan = array(); |
994
|
|
|
|
995
|
|
|
// Default border style |
996
|
10 |
|
$defaultBorder = new Border(); |
997
|
|
|
|
998
|
|
|
// Write rows |
999
|
10 |
|
$countRows = count($shape->getRows()); |
1000
|
10 |
|
for ($row = 0; $row < $countRows; $row++) { |
1001
|
|
|
// a:tr |
1002
|
10 |
|
$objWriter->startElement('a:tr'); |
1003
|
10 |
|
$objWriter->writeAttribute('h', CommonDrawing::pixelsToEmu($shape->getRow($row)->getHeight())); |
1004
|
|
|
|
1005
|
|
|
// Write cells |
1006
|
10 |
|
$countCells = count($shape->getRow($row)->getCells()); |
1007
|
10 |
|
for ($cell = 0; $cell < $countCells; $cell++) { |
1008
|
|
|
// Current cell |
1009
|
10 |
|
$currentCell = $shape->getRow($row)->getCell($cell); |
1010
|
|
|
|
1011
|
|
|
// Next cell right |
1012
|
10 |
|
$nextCellRight = $shape->getRow($row)->getCell($cell + 1, true); |
1013
|
|
|
|
1014
|
|
|
// Next cell below |
1015
|
10 |
|
$nextRowBelow = $shape->getRow($row + 1, true); |
1016
|
10 |
|
$nextCellBelow = null; |
1017
|
10 |
|
if ($nextRowBelow != null) { |
1018
|
2 |
|
$nextCellBelow = $nextRowBelow->getCell($cell, true); |
1019
|
2 |
|
} |
1020
|
|
|
|
1021
|
|
|
// a:tc |
1022
|
10 |
|
$objWriter->startElement('a:tc'); |
1023
|
|
|
// Colspan |
1024
|
10 |
|
if ($currentCell->getColSpan() > 1) { |
1025
|
1 |
|
$objWriter->writeAttribute('gridSpan', $currentCell->getColSpan()); |
1026
|
1 |
|
$colSpan[$row] = $currentCell->getColSpan() - 1; |
1027
|
10 |
|
} elseif (isset($colSpan[$row]) && $colSpan[$row] > 0) { |
1028
|
1 |
|
$colSpan[$row]--; |
1029
|
1 |
|
$objWriter->writeAttribute('hMerge', '1'); |
1030
|
1 |
|
} |
1031
|
|
|
|
1032
|
|
|
// Rowspan |
1033
|
10 |
|
if ($currentCell->getRowSpan() > 1) { |
1034
|
1 |
|
$objWriter->writeAttribute('rowSpan', $currentCell->getRowSpan()); |
1035
|
1 |
|
$rowSpan[$cell] = $currentCell->getRowSpan() - 1; |
1036
|
10 |
|
} elseif (isset($rowSpan[$cell]) && $rowSpan[$cell] > 0) { |
1037
|
1 |
|
$rowSpan[$cell]--; |
1038
|
1 |
|
$objWriter->writeAttribute('vMerge', '1'); |
1039
|
1 |
|
} |
1040
|
|
|
|
1041
|
|
|
// a:txBody |
1042
|
10 |
|
$objWriter->startElement('a:txBody'); |
1043
|
|
|
|
1044
|
|
|
// a:bodyPr |
1045
|
10 |
|
$objWriter->startElement('a:bodyPr'); |
1046
|
10 |
|
$objWriter->writeAttribute('wrap', 'square'); |
1047
|
10 |
|
$objWriter->writeAttribute('rtlCol', '0'); |
1048
|
|
|
|
1049
|
|
|
// a:spAutoFit |
1050
|
10 |
|
$objWriter->writeElement('a:spAutoFit', null); |
1051
|
|
|
|
1052
|
10 |
|
$objWriter->endElement(); |
1053
|
|
|
|
1054
|
|
|
// a:lstStyle |
1055
|
10 |
|
$objWriter->writeElement('a:lstStyle', null); |
1056
|
|
|
|
1057
|
|
|
// Write paragraphs |
1058
|
10 |
|
$this->writeParagraphs($objWriter, $currentCell->getParagraphs()); |
1059
|
|
|
|
1060
|
10 |
|
$objWriter->endElement(); |
1061
|
|
|
|
1062
|
|
|
// a:tcPr |
1063
|
10 |
|
$objWriter->startElement('a:tcPr'); |
1064
|
|
|
// Alignment (horizontal) |
1065
|
10 |
|
$firstParagraph = $currentCell->getParagraph(0); |
1066
|
10 |
|
$verticalAlign = $firstParagraph->getAlignment()->getVertical(); |
1067
|
10 |
|
if ($verticalAlign != Alignment::VERTICAL_BASE && $verticalAlign != Alignment::VERTICAL_AUTO) { |
1068
|
1 |
|
$objWriter->writeAttribute('anchor', $verticalAlign); |
1069
|
1 |
|
} |
1070
|
|
|
|
1071
|
|
|
// Determine borders |
1072
|
10 |
|
$borderLeft = $currentCell->getBorders()->getLeft(); |
1073
|
10 |
|
$borderRight = $currentCell->getBorders()->getRight(); |
1074
|
10 |
|
$borderTop = $currentCell->getBorders()->getTop(); |
1075
|
10 |
|
$borderBottom = $currentCell->getBorders()->getBottom(); |
1076
|
10 |
|
$borderDiagonalDown = $currentCell->getBorders()->getDiagonalDown(); |
1077
|
10 |
|
$borderDiagonalUp = $currentCell->getBorders()->getDiagonalUp(); |
1078
|
|
|
|
1079
|
|
|
// Fix PowerPoint implementation |
1080
|
10 |
|
if (!is_null($nextCellRight) && $nextCellRight->getBorders()->getRight()->getHashCode() != $defaultBorder->getHashCode()) { |
1081
|
1 |
|
$borderRight = $nextCellRight->getBorders()->getLeft(); |
1082
|
1 |
|
} |
1083
|
10 |
|
if (!is_null($nextCellBelow) && $nextCellBelow->getBorders()->getBottom()->getHashCode() != $defaultBorder->getHashCode()) { |
1084
|
1 |
|
$borderBottom = $nextCellBelow->getBorders()->getTop(); |
1085
|
1 |
|
} |
1086
|
|
|
|
1087
|
|
|
// Write borders |
1088
|
10 |
|
$this->writeBorder($objWriter, $borderLeft, 'L'); |
1089
|
10 |
|
$this->writeBorder($objWriter, $borderRight, 'R'); |
1090
|
10 |
|
$this->writeBorder($objWriter, $borderTop, 'T'); |
1091
|
10 |
|
$this->writeBorder($objWriter, $borderBottom, 'B'); |
1092
|
10 |
|
$this->writeBorder($objWriter, $borderDiagonalDown, 'TlToBr'); |
1093
|
10 |
|
$this->writeBorder($objWriter, $borderDiagonalUp, 'BlToTr'); |
1094
|
|
|
|
1095
|
|
|
// Fill |
1096
|
10 |
|
$this->writeFill($objWriter, $currentCell->getFill()); |
1097
|
|
|
|
1098
|
10 |
|
$objWriter->endElement(); |
1099
|
|
|
|
1100
|
10 |
|
$objWriter->endElement(); |
1101
|
10 |
|
} |
1102
|
|
|
|
1103
|
10 |
|
$objWriter->endElement(); |
1104
|
10 |
|
} |
1105
|
|
|
|
1106
|
10 |
|
$objWriter->endElement(); |
1107
|
|
|
|
1108
|
10 |
|
$objWriter->endElement(); |
1109
|
|
|
|
1110
|
10 |
|
$objWriter->endElement(); |
1111
|
|
|
|
1112
|
10 |
|
$objWriter->endElement(); |
1113
|
10 |
|
} |
1114
|
|
|
|
1115
|
|
|
/** |
1116
|
|
|
* Write paragraphs |
1117
|
|
|
* |
1118
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1119
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs |
1120
|
|
|
* @throws \Exception |
1121
|
|
|
*/ |
1122
|
31 |
|
private function writeParagraphs(XMLWriter $objWriter, $paragraphs) |
1123
|
|
|
{ |
1124
|
|
|
// Loop trough paragraphs |
1125
|
31 |
|
foreach ($paragraphs as $paragraph) { |
1126
|
|
|
// a:p |
1127
|
31 |
|
$objWriter->startElement('a:p'); |
1128
|
|
|
|
1129
|
|
|
// a:pPr |
1130
|
31 |
|
$objWriter->startElement('a:pPr'); |
1131
|
31 |
|
$objWriter->writeAttribute('algn', $paragraph->getAlignment()->getHorizontal()); |
1132
|
31 |
|
$objWriter->writeAttribute('fontAlgn', $paragraph->getAlignment()->getVertical()); |
1133
|
31 |
|
$objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginLeft())); |
1134
|
31 |
|
$objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getMarginRight())); |
1135
|
31 |
|
$objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($paragraph->getAlignment()->getIndent())); |
1136
|
31 |
|
$objWriter->writeAttribute('lvl', $paragraph->getAlignment()->getLevel()); |
1137
|
|
|
|
1138
|
|
|
// Bullet type specified? |
1139
|
31 |
|
if ($paragraph->getBulletStyle()->getBulletType() != Bullet::TYPE_NONE) { |
1140
|
|
|
// a:buFont |
1141
|
2 |
|
$objWriter->startElement('a:buFont'); |
1142
|
2 |
|
$objWriter->writeAttribute('typeface', $paragraph->getBulletStyle()->getBulletFont()); |
1143
|
2 |
|
$objWriter->endElement(); |
1144
|
|
|
|
1145
|
2 |
|
if ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_BULLET) { |
1146
|
|
|
// a:buChar |
1147
|
1 |
|
$objWriter->startElement('a:buChar'); |
1148
|
1 |
|
$objWriter->writeAttribute('char', $paragraph->getBulletStyle()->getBulletChar()); |
1149
|
1 |
|
$objWriter->endElement(); |
1150
|
2 |
|
} elseif ($paragraph->getBulletStyle()->getBulletType() == Bullet::TYPE_NUMERIC) { |
1151
|
|
|
// a:buAutoNum |
1152
|
1 |
|
$objWriter->startElement('a:buAutoNum'); |
1153
|
1 |
|
$objWriter->writeAttribute('type', $paragraph->getBulletStyle()->getBulletNumericStyle()); |
1154
|
1 |
|
if ($paragraph->getBulletStyle()->getBulletNumericStartAt() != 1) { |
1155
|
1 |
|
$objWriter->writeAttribute('startAt', $paragraph->getBulletStyle()->getBulletNumericStartAt()); |
1156
|
1 |
|
} |
1157
|
1 |
|
$objWriter->endElement(); |
1158
|
1 |
|
} |
1159
|
2 |
|
} |
1160
|
|
|
|
1161
|
31 |
|
$objWriter->endElement(); |
1162
|
|
|
|
1163
|
|
|
// Loop trough rich text elements |
1164
|
31 |
|
$elements = $paragraph->getRichTextElements(); |
1165
|
31 |
|
foreach ($elements as $element) { |
1166
|
26 |
|
if ($element instanceof BreakElement) { |
1167
|
|
|
// a:br |
1168
|
1 |
|
$objWriter->writeElement('a:br', null); |
1169
|
26 |
|
} elseif ($element instanceof Run || $element instanceof TextElement) { |
1170
|
|
|
// a:r |
1171
|
25 |
|
$objWriter->startElement('a:r'); |
1172
|
|
|
|
1173
|
|
|
// a:rPr |
1174
|
25 |
|
if ($element instanceof Run) { |
1175
|
|
|
// a:rPr |
1176
|
25 |
|
$objWriter->startElement('a:rPr'); |
1177
|
|
|
|
1178
|
|
|
// Bold |
1179
|
25 |
|
$objWriter->writeAttribute('b', ($element->getFont()->isBold() ? '1' : '0')); |
1180
|
|
|
|
1181
|
|
|
// Italic |
1182
|
25 |
|
$objWriter->writeAttribute('i', ($element->getFont()->isItalic() ? '1' : '0')); |
1183
|
|
|
|
1184
|
|
|
// Strikethrough |
1185
|
25 |
|
$objWriter->writeAttribute('strike', ($element->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike')); |
1186
|
|
|
|
1187
|
|
|
// Size |
1188
|
25 |
|
$objWriter->writeAttribute('sz', ($element->getFont()->getSize() * 100)); |
1189
|
|
|
|
1190
|
|
|
// Underline |
1191
|
25 |
|
$objWriter->writeAttribute('u', $element->getFont()->getUnderline()); |
1192
|
|
|
|
1193
|
|
|
// Superscript / subscript |
1194
|
25 |
|
if ($element->getFont()->isSuperScript() || $element->getFont()->isSubScript()) { |
1195
|
2 |
|
if ($element->getFont()->isSuperScript()) { |
1196
|
1 |
|
$objWriter->writeAttribute('baseline', '30000'); |
1197
|
2 |
|
} elseif ($element->getFont()->isSubScript()) { |
1198
|
1 |
|
$objWriter->writeAttribute('baseline', '-25000'); |
1199
|
1 |
|
} |
1200
|
2 |
|
} |
1201
|
|
|
|
1202
|
|
|
// Color - a:solidFill |
1203
|
25 |
|
$objWriter->startElement('a:solidFill'); |
1204
|
|
|
|
1205
|
|
|
// a:srgbClr |
1206
|
25 |
|
$objWriter->startElement('a:srgbClr'); |
1207
|
25 |
|
$objWriter->writeAttribute('val', $element->getFont()->getColor()->getRGB()); |
1208
|
25 |
|
$objWriter->endElement(); |
1209
|
|
|
|
1210
|
25 |
|
$objWriter->endElement(); |
1211
|
|
|
|
1212
|
|
|
// Font - a:latin |
1213
|
25 |
|
$objWriter->startElement('a:latin'); |
1214
|
25 |
|
$objWriter->writeAttribute('typeface', $element->getFont()->getName()); |
1215
|
25 |
|
$objWriter->endElement(); |
1216
|
|
|
|
1217
|
|
|
// a:hlinkClick |
1218
|
25 |
|
if ($element->hasHyperlink()) { |
1219
|
3 |
|
$this->writeHyperlink($objWriter, $element); |
1220
|
3 |
|
} |
1221
|
|
|
|
1222
|
25 |
|
$objWriter->endElement(); |
1223
|
25 |
|
} |
1224
|
|
|
|
1225
|
|
|
// t |
1226
|
25 |
|
$objWriter->startElement('a:t'); |
1227
|
25 |
|
$objWriter->writeCData(Text::controlCharacterPHP2OOXML($element->getText())); |
1228
|
25 |
|
$objWriter->endElement(); |
1229
|
|
|
|
1230
|
25 |
|
$objWriter->endElement(); |
1231
|
25 |
|
} |
1232
|
31 |
|
} |
1233
|
|
|
|
1234
|
31 |
|
$objWriter->endElement(); |
1235
|
31 |
|
} |
1236
|
31 |
|
} |
1237
|
|
|
|
1238
|
|
|
/** |
1239
|
|
|
* Write Line Shape |
1240
|
|
|
* |
1241
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1242
|
|
|
* @param \PhpOffice\PhpPresentation\Shape\Line $shape |
1243
|
|
|
* @param int $shapeId |
1244
|
|
|
*/ |
1245
|
2 |
|
private function writeShapeLine(XMLWriter $objWriter, Line $shape, $shapeId) |
1246
|
|
|
{ |
1247
|
|
|
// p:sp |
1248
|
2 |
|
$objWriter->startElement('p:cxnSp'); |
1249
|
|
|
|
1250
|
|
|
// p:nvSpPr |
1251
|
2 |
|
$objWriter->startElement('p:nvCxnSpPr'); |
1252
|
|
|
|
1253
|
|
|
// p:cNvPr |
1254
|
2 |
|
$objWriter->startElement('p:cNvPr'); |
1255
|
2 |
|
$objWriter->writeAttribute('id', $shapeId); |
1256
|
2 |
|
$objWriter->writeAttribute('name', ''); |
1257
|
|
|
|
1258
|
2 |
|
$objWriter->endElement(); |
1259
|
|
|
|
1260
|
|
|
// p:cNvCxnSpPr |
1261
|
2 |
|
$objWriter->writeElement('p:cNvCxnSpPr', null); |
1262
|
|
|
|
1263
|
|
|
// p:nvPr |
1264
|
2 |
|
$objWriter->writeElement('p:nvPr', null); |
1265
|
|
|
|
1266
|
2 |
|
$objWriter->endElement(); |
1267
|
|
|
|
1268
|
|
|
// p:spPr |
1269
|
2 |
|
$objWriter->startElement('p:spPr'); |
1270
|
|
|
|
1271
|
|
|
// a:xfrm |
1272
|
2 |
|
$objWriter->startElement('a:xfrm'); |
1273
|
|
|
|
1274
|
2 |
|
if ($shape->getWidth() >= 0 && $shape->getHeight() >= 0) { |
1275
|
|
|
// a:off |
1276
|
2 |
|
$objWriter->startElement('a:off'); |
1277
|
2 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
1278
|
2 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
1279
|
2 |
|
$objWriter->endElement(); |
1280
|
|
|
|
1281
|
|
|
// a:ext |
1282
|
2 |
|
$objWriter->startElement('a:ext'); |
1283
|
2 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
1284
|
2 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
1285
|
2 |
|
$objWriter->endElement(); |
1286
|
2 |
|
} elseif ($shape->getWidth() < 0 && $shape->getHeight() < 0) { |
1287
|
|
|
// a:off |
1288
|
1 |
|
$objWriter->startElement('a:off'); |
1289
|
1 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX() + $shape->getWidth())); |
1290
|
1 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY() + $shape->getHeight())); |
1291
|
1 |
|
$objWriter->endElement(); |
1292
|
|
|
|
1293
|
|
|
// a:ext |
1294
|
1 |
|
$objWriter->startElement('a:ext'); |
1295
|
1 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu(-$shape->getWidth())); |
1296
|
1 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu(-$shape->getHeight())); |
1297
|
1 |
|
$objWriter->endElement(); |
1298
|
1 |
|
} elseif ($shape->getHeight() < 0) { |
1299
|
1 |
|
$objWriter->writeAttribute('flipV', 1); |
1300
|
|
|
|
1301
|
|
|
// a:off |
1302
|
1 |
|
$objWriter->startElement('a:off'); |
1303
|
1 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); |
1304
|
1 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY() + $shape->getHeight())); |
1305
|
1 |
|
$objWriter->endElement(); |
1306
|
|
|
|
1307
|
|
|
// a:ext |
1308
|
1 |
|
$objWriter->startElement('a:ext'); |
1309
|
1 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($shape->getWidth())); |
1310
|
1 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu(-$shape->getHeight())); |
1311
|
1 |
|
$objWriter->endElement(); |
1312
|
1 |
|
} elseif ($shape->getWidth() < 0) { |
1313
|
1 |
|
$objWriter->writeAttribute('flipV', 1); |
1314
|
|
|
|
1315
|
|
|
// a:off |
1316
|
1 |
|
$objWriter->startElement('a:off'); |
1317
|
1 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX() + $shape->getWidth())); |
1318
|
1 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($shape->getOffsetY())); |
1319
|
1 |
|
$objWriter->endElement(); |
1320
|
|
|
|
1321
|
|
|
// a:ext |
1322
|
1 |
|
$objWriter->startElement('a:ext'); |
1323
|
1 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu(-$shape->getWidth())); |
1324
|
1 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($shape->getHeight())); |
1325
|
1 |
|
$objWriter->endElement(); |
1326
|
1 |
|
} |
1327
|
|
|
|
1328
|
2 |
|
$objWriter->endElement(); |
1329
|
|
|
|
1330
|
|
|
// a:prstGeom |
1331
|
2 |
|
$objWriter->startElement('a:prstGeom'); |
1332
|
2 |
|
$objWriter->writeAttribute('prst', 'line'); |
1333
|
2 |
|
$objWriter->endElement(); |
1334
|
|
|
|
1335
|
2 |
|
if ($shape->getBorder()->getLineStyle() != Border::LINE_NONE) { |
1336
|
2 |
|
$this->writeBorder($objWriter, $shape->getBorder(), ''); |
1337
|
2 |
|
} |
1338
|
|
|
|
1339
|
2 |
|
$objWriter->endElement(); |
1340
|
|
|
|
1341
|
2 |
|
$objWriter->endElement(); |
1342
|
2 |
|
} |
1343
|
|
|
|
1344
|
|
|
/** |
1345
|
|
|
* Write Border |
1346
|
|
|
* |
1347
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1348
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Border $pBorder Border |
1349
|
|
|
* @param string $pElementName Element name |
1350
|
|
|
* @throws \Exception |
1351
|
|
|
*/ |
1352
|
30 |
|
protected function writeBorder(XMLWriter $objWriter, Border $pBorder, $pElementName = 'L') |
1353
|
|
|
{ |
1354
|
|
|
// Line style |
1355
|
30 |
|
$lineStyle = $pBorder->getLineStyle(); |
1356
|
30 |
|
if ($lineStyle == Border::LINE_NONE) { |
1357
|
10 |
|
$lineStyle = Border::LINE_SINGLE; |
1358
|
10 |
|
} |
1359
|
|
|
|
1360
|
|
|
// Line width |
1361
|
30 |
|
$lineWidth = 12700 * $pBorder->getLineWidth(); |
1362
|
|
|
|
1363
|
|
|
// a:ln $pElementName |
1364
|
30 |
|
$objWriter->startElement('a:ln' . $pElementName); |
1365
|
30 |
|
$objWriter->writeAttribute('w', $lineWidth); |
1366
|
30 |
|
$objWriter->writeAttribute('cap', 'flat'); |
1367
|
30 |
|
$objWriter->writeAttribute('cmpd', $lineStyle); |
1368
|
30 |
|
$objWriter->writeAttribute('algn', 'ctr'); |
1369
|
|
|
|
1370
|
|
|
// Fill? |
1371
|
30 |
|
if ($pBorder->getLineStyle() == Border::LINE_NONE) { |
1372
|
|
|
// a:noFill |
1373
|
10 |
|
$objWriter->writeElement('a:noFill', null); |
1374
|
10 |
|
} else { |
1375
|
|
|
// a:solidFill |
1376
|
30 |
|
$objWriter->startElement('a:solidFill'); |
1377
|
|
|
|
1378
|
|
|
// a:srgbClr |
1379
|
30 |
|
$objWriter->startElement('a:srgbClr'); |
1380
|
30 |
|
$objWriter->writeAttribute('val', $pBorder->getColor()->getRGB()); |
1381
|
30 |
|
$objWriter->endElement(); |
1382
|
|
|
|
1383
|
30 |
|
$objWriter->endElement(); |
1384
|
|
|
} |
1385
|
|
|
|
1386
|
|
|
// Dash |
1387
|
30 |
|
$objWriter->startElement('a:prstDash'); |
1388
|
30 |
|
$objWriter->writeAttribute('val', $pBorder->getDashStyle()); |
1389
|
30 |
|
$objWriter->endElement(); |
1390
|
|
|
|
1391
|
|
|
// a:round |
1392
|
30 |
|
$objWriter->writeElement('a:round', null); |
1393
|
|
|
|
1394
|
|
|
// a:headEnd |
1395
|
30 |
|
$objWriter->startElement('a:headEnd'); |
1396
|
30 |
|
$objWriter->writeAttribute('type', 'none'); |
1397
|
30 |
|
$objWriter->writeAttribute('w', 'med'); |
1398
|
30 |
|
$objWriter->writeAttribute('len', 'med'); |
1399
|
30 |
|
$objWriter->endElement(); |
1400
|
|
|
|
1401
|
|
|
// a:tailEnd |
1402
|
30 |
|
$objWriter->startElement('a:tailEnd'); |
1403
|
30 |
|
$objWriter->writeAttribute('type', 'none'); |
1404
|
30 |
|
$objWriter->writeAttribute('w', 'med'); |
1405
|
30 |
|
$objWriter->writeAttribute('len', 'med'); |
1406
|
30 |
|
$objWriter->endElement(); |
1407
|
|
|
|
1408
|
30 |
|
$objWriter->endElement(); |
1409
|
30 |
|
} |
1410
|
|
|
|
1411
|
|
|
/** |
1412
|
|
|
* Write Fill |
1413
|
|
|
* |
1414
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1415
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
1416
|
|
|
* @throws \Exception |
1417
|
|
|
*/ |
1418
|
48 |
|
protected function writeFill(XMLWriter $objWriter, Fill $pFill) |
1419
|
|
|
{ |
1420
|
|
|
// Is it a fill? |
1421
|
48 |
|
if ($pFill->getFillType() == Fill::FILL_NONE) { |
1422
|
41 |
|
return; |
1423
|
|
|
} |
1424
|
|
|
|
1425
|
|
|
// Is it a solid fill? |
1426
|
11 |
|
if ($pFill->getFillType() == Fill::FILL_SOLID) { |
1427
|
6 |
|
$this->writeSolidFill($objWriter, $pFill); |
1428
|
6 |
|
return; |
1429
|
|
|
} |
1430
|
|
|
|
1431
|
|
|
// Check if this is a pattern type or gradient type |
1432
|
5 |
|
if ($pFill->getFillType() == Fill::FILL_GRADIENT_LINEAR || $pFill->getFillType() == Fill::FILL_GRADIENT_PATH) { |
1433
|
|
|
// Gradient fill |
1434
|
4 |
|
$this->writeGradientFill($objWriter, $pFill); |
1435
|
4 |
|
} else { |
1436
|
|
|
// Pattern fill |
1437
|
1 |
|
$this->writePatternFill($objWriter, $pFill); |
1438
|
|
|
} |
1439
|
5 |
|
} |
1440
|
|
|
|
1441
|
|
|
/** |
1442
|
|
|
* Write Solid Fill |
1443
|
|
|
* |
1444
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1445
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
1446
|
|
|
* @throws \Exception |
1447
|
|
|
*/ |
1448
|
6 |
|
protected function writeSolidFill(XMLWriter $objWriter, Fill $pFill) |
1449
|
|
|
{ |
1450
|
|
|
// a:gradFill |
1451
|
6 |
|
$objWriter->startElement('a:solidFill'); |
1452
|
|
|
|
1453
|
|
|
// srgbClr |
1454
|
6 |
|
$objWriter->startElement('a:srgbClr'); |
1455
|
6 |
|
$objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); |
1456
|
6 |
|
$objWriter->endElement(); |
1457
|
|
|
|
1458
|
6 |
|
$objWriter->endElement(); |
1459
|
6 |
|
} |
1460
|
|
|
|
1461
|
|
|
/** |
1462
|
|
|
* Write Gradient Fill |
1463
|
|
|
* |
1464
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1465
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
1466
|
|
|
* @throws \Exception |
1467
|
|
|
*/ |
1468
|
4 |
|
protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill) |
1469
|
|
|
{ |
1470
|
|
|
// a:gradFill |
1471
|
4 |
|
$objWriter->startElement('a:gradFill'); |
1472
|
|
|
|
1473
|
|
|
// a:gsLst |
1474
|
4 |
|
$objWriter->startElement('a:gsLst'); |
1475
|
|
|
// a:gs |
1476
|
4 |
|
$objWriter->startElement('a:gs'); |
1477
|
4 |
|
$objWriter->writeAttribute('pos', '0'); |
1478
|
|
|
|
1479
|
|
|
// srgbClr |
1480
|
4 |
|
$objWriter->startElement('a:srgbClr'); |
1481
|
4 |
|
$objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); |
1482
|
4 |
|
$objWriter->endElement(); |
1483
|
|
|
|
1484
|
4 |
|
$objWriter->endElement(); |
1485
|
|
|
|
1486
|
|
|
// a:gs |
1487
|
4 |
|
$objWriter->startElement('a:gs'); |
1488
|
4 |
|
$objWriter->writeAttribute('pos', '100000'); |
1489
|
|
|
|
1490
|
|
|
// srgbClr |
1491
|
4 |
|
$objWriter->startElement('a:srgbClr'); |
1492
|
4 |
|
$objWriter->writeAttribute('val', $pFill->getEndColor()->getRGB()); |
1493
|
4 |
|
$objWriter->endElement(); |
1494
|
|
|
|
1495
|
4 |
|
$objWriter->endElement(); |
1496
|
|
|
|
1497
|
4 |
|
$objWriter->endElement(); |
1498
|
|
|
|
1499
|
|
|
// a:lin |
1500
|
4 |
|
$objWriter->startElement('a:lin'); |
1501
|
4 |
|
$objWriter->writeAttribute('ang', CommonDrawing::degreesToAngle($pFill->getRotation())); |
1502
|
4 |
|
$objWriter->writeAttribute('scaled', '0'); |
1503
|
4 |
|
$objWriter->endElement(); |
1504
|
|
|
|
1505
|
4 |
|
$objWriter->endElement(); |
1506
|
4 |
|
} |
1507
|
|
|
|
1508
|
|
|
/** |
1509
|
|
|
* Write Pattern Fill |
1510
|
|
|
* |
1511
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1512
|
|
|
* @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
1513
|
|
|
* @throws \Exception |
1514
|
|
|
*/ |
1515
|
1 |
|
protected function writePatternFill(XMLWriter $objWriter, Fill $pFill) |
1516
|
|
|
{ |
1517
|
|
|
// a:pattFill |
1518
|
1 |
|
$objWriter->startElement('a:pattFill'); |
1519
|
|
|
|
1520
|
|
|
// fgClr |
1521
|
1 |
|
$objWriter->startElement('a:fgClr'); |
1522
|
|
|
|
1523
|
|
|
// srgbClr |
1524
|
1 |
|
$objWriter->startElement('a:srgbClr'); |
1525
|
1 |
|
$objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB()); |
1526
|
1 |
|
$objWriter->endElement(); |
1527
|
|
|
|
1528
|
1 |
|
$objWriter->endElement(); |
1529
|
|
|
|
1530
|
|
|
// bgClr |
1531
|
1 |
|
$objWriter->startElement('a:bgClr'); |
1532
|
|
|
|
1533
|
|
|
// srgbClr |
1534
|
1 |
|
$objWriter->startElement('a:srgbClr'); |
1535
|
1 |
|
$objWriter->writeAttribute('val', $pFill->getEndColor()->getRGB()); |
1536
|
1 |
|
$objWriter->endElement(); |
1537
|
|
|
|
1538
|
1 |
|
$objWriter->endElement(); |
1539
|
|
|
|
1540
|
1 |
|
$objWriter->endElement(); |
1541
|
1 |
|
} |
1542
|
|
|
|
1543
|
2 |
|
protected function writeShadow(XMLWriter $objWriter, Shadow $oShadow) |
1544
|
|
|
{ |
1545
|
|
|
// a:effectLst |
1546
|
2 |
|
$objWriter->startElement('a:effectLst'); |
1547
|
|
|
|
1548
|
|
|
// a:outerShdw |
1549
|
2 |
|
$objWriter->startElement('a:outerShdw'); |
1550
|
2 |
|
$objWriter->writeAttribute('blurRad', CommonDrawing::pixelsToEmu($oShadow->getBlurRadius())); |
1551
|
2 |
|
$objWriter->writeAttribute('dist', CommonDrawing::pixelsToEmu($oShadow->getDistance())); |
1552
|
2 |
|
$objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle($oShadow->getDirection())); |
1553
|
2 |
|
$objWriter->writeAttribute('algn', $oShadow->getAlignment()); |
1554
|
2 |
|
$objWriter->writeAttribute('rotWithShape', '0'); |
1555
|
|
|
|
1556
|
|
|
// a:srgbClr |
1557
|
2 |
|
$objWriter->startElement('a:srgbClr'); |
1558
|
2 |
|
$objWriter->writeAttribute('val', $oShadow->getColor()->getRGB()); |
1559
|
|
|
|
1560
|
|
|
// a:alpha |
1561
|
2 |
|
$objWriter->startElement('a:alpha'); |
1562
|
2 |
|
$objWriter->writeAttribute('val', $oShadow->getAlpha() * 1000); |
1563
|
2 |
|
$objWriter->endElement(); |
1564
|
|
|
|
1565
|
2 |
|
$objWriter->endElement(); |
1566
|
|
|
|
1567
|
2 |
|
$objWriter->endElement(); |
1568
|
|
|
|
1569
|
2 |
|
$objWriter->endElement(); |
1570
|
2 |
|
} |
1571
|
|
|
|
1572
|
|
|
/** |
1573
|
|
|
* Write hyperlink |
1574
|
|
|
* |
1575
|
|
|
* @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
1576
|
|
|
* @param \PhpOffice\PhpPresentation\AbstractShape|\PhpOffice\PhpPresentation\Shape\RichText\TextElement $shape |
1577
|
|
|
*/ |
1578
|
5 |
|
private function writeHyperlink(XMLWriter $objWriter, $shape) |
1579
|
|
|
{ |
1580
|
|
|
// a:hlinkClick |
1581
|
5 |
|
$objWriter->startElement('a:hlinkClick'); |
1582
|
5 |
|
$objWriter->writeAttribute('r:id', $shape->getHyperlink()->relationId); |
1583
|
5 |
|
$objWriter->writeAttribute('tooltip', $shape->getHyperlink()->getTooltip()); |
1584
|
5 |
|
if ($shape->getHyperlink()->isInternal()) { |
1585
|
1 |
|
$objWriter->writeAttribute('action', $shape->getHyperlink()->getUrl()); |
1586
|
1 |
|
} |
1587
|
5 |
|
$objWriter->endElement(); |
1588
|
5 |
|
} |
1589
|
|
|
|
1590
|
|
|
/** |
1591
|
|
|
* Write Note Slide |
1592
|
|
|
* @param Note $pNote |
1593
|
|
|
* @throws \Exception |
1594
|
|
|
*/ |
1595
|
1 |
|
public function writeNote(Note $pNote = null) |
1596
|
|
|
{ |
1597
|
|
|
// Check slide |
1598
|
1 |
|
if (is_null($pNote)) { |
1599
|
|
|
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Slide\Note object passed."); |
1600
|
|
|
} |
1601
|
|
|
|
1602
|
|
|
// Create XML writer |
1603
|
1 |
|
$objWriter = $this->getXMLWriter(); |
1604
|
|
|
|
1605
|
|
|
// XML header |
1606
|
1 |
|
$objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
1607
|
|
|
|
1608
|
|
|
// p:notes |
1609
|
1 |
|
$objWriter->startElement('p:notes'); |
1610
|
1 |
|
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
1611
|
1 |
|
$objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); |
1612
|
1 |
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
1613
|
|
|
|
1614
|
|
|
// p:cSld |
1615
|
1 |
|
$objWriter->startElement('p:cSld'); |
1616
|
|
|
|
1617
|
|
|
// p:spTree |
1618
|
1 |
|
$objWriter->startElement('p:spTree'); |
1619
|
|
|
|
1620
|
|
|
// p:nvGrpSpPr |
1621
|
1 |
|
$objWriter->startElement('p:nvGrpSpPr'); |
1622
|
|
|
|
1623
|
|
|
// p:cNvPr |
1624
|
1 |
|
$objWriter->startElement('p:cNvPr'); |
1625
|
1 |
|
$objWriter->writeAttribute('id', '1'); |
1626
|
1 |
|
$objWriter->writeAttribute('name', ''); |
1627
|
1 |
|
$objWriter->endElement(); |
1628
|
|
|
|
1629
|
|
|
// p:cNvGrpSpPr |
1630
|
1 |
|
$objWriter->writeElement('p:cNvGrpSpPr', null); |
1631
|
|
|
|
1632
|
|
|
// p:nvPr |
1633
|
1 |
|
$objWriter->writeElement('p:nvPr', null); |
1634
|
|
|
|
1635
|
|
|
// ## p:nvGrpSpPr |
1636
|
1 |
|
$objWriter->endElement(); |
1637
|
|
|
|
1638
|
|
|
// p:grpSpPr |
1639
|
1 |
|
$objWriter->startElement('p:grpSpPr'); |
1640
|
|
|
|
1641
|
|
|
// a:xfrm |
1642
|
1 |
|
$objWriter->startElement('a:xfrm'); |
1643
|
|
|
|
1644
|
|
|
// a:off |
1645
|
1 |
|
$objWriter->startElement('a:off'); |
1646
|
1 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pNote->getOffsetX())); |
1647
|
1 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pNote->getOffsetY())); |
1648
|
1 |
|
$objWriter->endElement(); // a:off |
1649
|
|
|
|
1650
|
|
|
// a:ext |
1651
|
1 |
|
$objWriter->startElement('a:ext'); |
1652
|
1 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pNote->getExtentX())); |
1653
|
1 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pNote->getExtentY())); |
1654
|
1 |
|
$objWriter->endElement(); // a:ext |
1655
|
|
|
|
1656
|
|
|
// a:chOff |
1657
|
1 |
|
$objWriter->startElement('a:chOff'); |
1658
|
1 |
|
$objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pNote->getOffsetX())); |
1659
|
1 |
|
$objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pNote->getOffsetY())); |
1660
|
1 |
|
$objWriter->endElement(); // a:chOff |
1661
|
|
|
|
1662
|
|
|
// a:chExt |
1663
|
1 |
|
$objWriter->startElement('a:chExt'); |
1664
|
1 |
|
$objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pNote->getExtentX())); |
1665
|
1 |
|
$objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pNote->getExtentY())); |
1666
|
1 |
|
$objWriter->endElement(); // a:chExt |
1667
|
|
|
|
1668
|
|
|
// ## a:xfrm |
1669
|
1 |
|
$objWriter->endElement(); |
1670
|
|
|
|
1671
|
|
|
// ## p:grpSpPr |
1672
|
1 |
|
$objWriter->endElement(); |
1673
|
|
|
|
1674
|
|
|
// p:sp |
1675
|
1 |
|
$objWriter->startElement('p:sp'); |
1676
|
|
|
|
1677
|
|
|
// p:nvSpPr |
1678
|
1 |
|
$objWriter->startElement('p:nvSpPr'); |
1679
|
|
|
|
1680
|
1 |
|
$objWriter->startElement('p:cNvPr'); |
1681
|
1 |
|
$objWriter->writeAttribute('id', '1'); |
1682
|
1 |
|
$objWriter->writeAttribute('name', 'Notes Placeholder'); |
1683
|
1 |
|
$objWriter->endElement(); |
1684
|
|
|
|
1685
|
|
|
// p:cNvSpPr |
1686
|
1 |
|
$objWriter->startElement('p:cNvSpPr'); |
1687
|
|
|
|
1688
|
|
|
//a:spLocks |
1689
|
1 |
|
$objWriter->startElement('a:spLocks'); |
1690
|
1 |
|
$objWriter->writeAttribute('noGrp', '1'); |
1691
|
1 |
|
$objWriter->endElement(); |
1692
|
|
|
|
1693
|
|
|
// ## p:cNvSpPr |
1694
|
1 |
|
$objWriter->endElement(); |
1695
|
|
|
|
1696
|
|
|
// p:nvPr |
1697
|
1 |
|
$objWriter->startElement('p:nvPr'); |
1698
|
|
|
|
1699
|
1 |
|
$objWriter->startElement('p:ph'); |
1700
|
1 |
|
$objWriter->writeAttribute('type', 'body'); |
1701
|
1 |
|
$objWriter->writeAttribute('idx', '1'); |
1702
|
1 |
|
$objWriter->endElement(); |
1703
|
|
|
|
1704
|
|
|
// ## p:nvPr |
1705
|
1 |
|
$objWriter->endElement(); |
1706
|
|
|
|
1707
|
|
|
// ## p:nvSpPr |
1708
|
1 |
|
$objWriter->endElement(); |
1709
|
|
|
|
1710
|
1 |
|
$objWriter->writeElement('p:spPr', null); |
1711
|
|
|
|
1712
|
|
|
// p:txBody |
1713
|
1 |
|
$objWriter->startElement('p:txBody'); |
1714
|
|
|
|
1715
|
1 |
|
$objWriter->writeElement('a:bodyPr', null); |
1716
|
1 |
|
$objWriter->writeElement('a:lstStyle', null); |
1717
|
|
|
|
1718
|
|
|
// Loop shapes |
1719
|
1 |
|
$shapes = $pNote->getShapeCollection(); |
1720
|
1 |
|
foreach ($shapes as $shape) { |
1721
|
|
|
// Check type |
1722
|
1 |
|
if ($shape instanceof RichText) { |
1723
|
1 |
|
$paragraphs = $shape->getParagraphs(); |
1724
|
1 |
|
$this->writeParagraphs($objWriter, $paragraphs); |
1725
|
1 |
|
} |
1726
|
1 |
|
} |
1727
|
|
|
|
1728
|
|
|
// ## p:txBody |
1729
|
1 |
|
$objWriter->endElement(); |
1730
|
|
|
|
1731
|
|
|
// ## p:sp |
1732
|
1 |
|
$objWriter->endElement(); |
1733
|
|
|
|
1734
|
|
|
// ## p:spTree |
1735
|
1 |
|
$objWriter->endElement(); |
1736
|
|
|
|
1737
|
|
|
// ## p:cSld |
1738
|
1 |
|
$objWriter->endElement(); |
1739
|
|
|
|
1740
|
|
|
// ## p:notes |
1741
|
1 |
|
$objWriter->endElement(); |
1742
|
|
|
|
1743
|
|
|
// Return |
1744
|
1 |
|
return $objWriter->getData(); |
1745
|
|
|
} |
1746
|
|
|
|
1747
|
|
|
/** |
1748
|
|
|
* Write Transition Slide |
1749
|
|
|
* @link http://officeopenxml.com/prSlide-transitions.php |
1750
|
|
|
* @param XMLWriter $objWriter |
1751
|
|
|
* @param Transition $transition |
1752
|
|
|
*/ |
1753
|
1 |
|
public function writeTransition(XMLWriter $objWriter, Transition $transition) |
1754
|
|
|
{ |
1755
|
1 |
|
$objWriter->startElement('p:transition'); |
1756
|
1 |
|
if (!is_null($transition->getSpeed())) { |
1757
|
1 |
|
$objWriter->writeAttribute('spd', $transition->getSpeed()); |
1758
|
1 |
|
} |
1759
|
1 |
|
$objWriter->writeAttribute('advClick', $transition->hasManualTrigger() ? '1' : '0'); |
1760
|
1 |
|
if ($transition->hasTimeTrigger()) { |
1761
|
1 |
|
$objWriter->writeAttribute('advTm', $transition->getAdvanceTimeTrigger()); |
1762
|
1 |
|
} |
1763
|
|
|
|
1764
|
1 |
|
switch ($transition->getTransitionType()) { |
1765
|
1 |
|
case Transition::TRANSITION_BLINDS_HORIZONTAL: |
1766
|
1 |
|
$objWriter->startElement('p:blinds'); |
1767
|
1 |
|
$objWriter->writeAttribute('dir', 'horz'); |
1768
|
1 |
|
$objWriter->endElement(); |
1769
|
1 |
|
break; |
1770
|
1 |
|
case Transition::TRANSITION_BLINDS_VERTICAL: |
1771
|
1 |
|
$objWriter->startElement('p:blinds'); |
1772
|
1 |
|
$objWriter->writeAttribute('dir', 'vert'); |
1773
|
1 |
|
$objWriter->endElement(); |
1774
|
1 |
|
break; |
1775
|
1 |
|
case Transition::TRANSITION_CHECKER_HORIZONTAL: |
1776
|
1 |
|
$objWriter->startElement('p:checker'); |
1777
|
1 |
|
$objWriter->writeAttribute('dir', 'horz'); |
1778
|
1 |
|
$objWriter->endElement(); |
1779
|
1 |
|
break; |
1780
|
1 |
|
case Transition::TRANSITION_CHECKER_VERTICAL: |
1781
|
1 |
|
$objWriter->startElement('p:checker'); |
1782
|
1 |
|
$objWriter->writeAttribute('dir', 'vert'); |
1783
|
1 |
|
$objWriter->endElement(); |
1784
|
1 |
|
break; |
1785
|
1 |
|
case Transition::TRANSITION_CIRCLE_HORIZONTAL: |
1786
|
1 |
|
$objWriter->startElement('p:circle'); |
1787
|
1 |
|
$objWriter->writeAttribute('dir', 'horz'); |
1788
|
1 |
|
$objWriter->endElement(); |
1789
|
1 |
|
break; |
1790
|
1 |
|
case Transition::TRANSITION_CIRCLE_VERTICAL: |
1791
|
1 |
|
$objWriter->startElement('p:circle'); |
1792
|
1 |
|
$objWriter->writeAttribute('dir', 'vert'); |
1793
|
1 |
|
$objWriter->endElement(); |
1794
|
1 |
|
break; |
1795
|
1 |
|
case Transition::TRANSITION_COMB_HORIZONTAL: |
1796
|
1 |
|
$objWriter->startElement('p:comb'); |
1797
|
1 |
|
$objWriter->writeAttribute('dir', 'horz'); |
1798
|
1 |
|
$objWriter->endElement(); |
1799
|
1 |
|
break; |
1800
|
1 |
|
case Transition::TRANSITION_COMB_VERTICAL: |
1801
|
1 |
|
$objWriter->startElement('p:comb'); |
1802
|
1 |
|
$objWriter->writeAttribute('dir', 'vert'); |
1803
|
1 |
|
$objWriter->endElement(); |
1804
|
1 |
|
break; |
1805
|
1 |
|
case Transition::TRANSITION_COVER_DOWN: |
1806
|
1 |
|
$objWriter->startElement('p:cover'); |
1807
|
1 |
|
$objWriter->writeAttribute('dir', 'd'); |
1808
|
1 |
|
$objWriter->endElement(); |
1809
|
1 |
|
break; |
1810
|
1 |
|
case Transition::TRANSITION_COVER_LEFT: |
1811
|
1 |
|
$objWriter->startElement('p:cover'); |
1812
|
1 |
|
$objWriter->writeAttribute('dir', 'l'); |
1813
|
1 |
|
$objWriter->endElement(); |
1814
|
1 |
|
break; |
1815
|
1 |
|
case Transition::TRANSITION_COVER_LEFT_DOWN: |
1816
|
1 |
|
$objWriter->startElement('p:cover'); |
1817
|
1 |
|
$objWriter->writeAttribute('dir', 'ld'); |
1818
|
1 |
|
$objWriter->endElement(); |
1819
|
1 |
|
break; |
1820
|
1 |
|
case Transition::TRANSITION_COVER_LEFT_UP: |
1821
|
1 |
|
$objWriter->startElement('p:cover'); |
1822
|
1 |
|
$objWriter->writeAttribute('dir', 'lu'); |
1823
|
1 |
|
$objWriter->endElement(); |
1824
|
1 |
|
break; |
1825
|
1 |
|
case Transition::TRANSITION_COVER_RIGHT: |
1826
|
1 |
|
$objWriter->startElement('p:cover'); |
1827
|
1 |
|
$objWriter->writeAttribute('dir', 'r'); |
1828
|
1 |
|
$objWriter->endElement(); |
1829
|
1 |
|
break; |
1830
|
1 |
|
case Transition::TRANSITION_COVER_RIGHT_DOWN: |
1831
|
1 |
|
$objWriter->startElement('p:cover'); |
1832
|
1 |
|
$objWriter->writeAttribute('dir', 'rd'); |
1833
|
1 |
|
$objWriter->endElement(); |
1834
|
1 |
|
break; |
1835
|
1 |
|
case Transition::TRANSITION_COVER_RIGHT_UP: |
1836
|
1 |
|
$objWriter->startElement('p:cover'); |
1837
|
1 |
|
$objWriter->writeAttribute('dir', 'ru'); |
1838
|
1 |
|
$objWriter->endElement(); |
1839
|
1 |
|
break; |
1840
|
1 |
|
case Transition::TRANSITION_COVER_UP: |
1841
|
1 |
|
$objWriter->startElement('p:cover'); |
1842
|
1 |
|
$objWriter->writeAttribute('dir', 'u'); |
1843
|
1 |
|
$objWriter->endElement(); |
1844
|
1 |
|
break; |
1845
|
1 |
|
case Transition::TRANSITION_CUT: |
1846
|
1 |
|
$objWriter->writeElement('p:cut'); |
1847
|
1 |
|
break; |
1848
|
1 |
|
case Transition::TRANSITION_DIAMOND: |
1849
|
1 |
|
$objWriter->writeElement('p:diamond'); |
1850
|
1 |
|
break; |
1851
|
1 |
|
case Transition::TRANSITION_DISSOLVE: |
1852
|
1 |
|
$objWriter->writeElement('p:dissolve'); |
1853
|
1 |
|
break; |
1854
|
1 |
|
case Transition::TRANSITION_FADE: |
1855
|
1 |
|
$objWriter->writeElement('p:fade'); |
1856
|
1 |
|
break; |
1857
|
1 |
|
case Transition::TRANSITION_NEWSFLASH: |
1858
|
1 |
|
$objWriter->writeElement('p:newsflash'); |
1859
|
1 |
|
break; |
1860
|
1 |
|
case Transition::TRANSITION_PLUS: |
1861
|
1 |
|
$objWriter->writeElement('p:plus'); |
1862
|
1 |
|
break; |
1863
|
1 |
|
case Transition::TRANSITION_PULL_DOWN: |
1864
|
1 |
|
$objWriter->startElement('p:pull'); |
1865
|
1 |
|
$objWriter->writeAttribute('dir', 'd'); |
1866
|
1 |
|
$objWriter->endElement(); |
1867
|
1 |
|
break; |
1868
|
1 |
|
case Transition::TRANSITION_PULL_LEFT: |
1869
|
1 |
|
$objWriter->startElement('p:pull'); |
1870
|
1 |
|
$objWriter->writeAttribute('dir', 'l'); |
1871
|
1 |
|
$objWriter->endElement(); |
1872
|
1 |
|
break; |
1873
|
1 |
|
case Transition::TRANSITION_PULL_RIGHT: |
1874
|
1 |
|
$objWriter->startElement('p:pull'); |
1875
|
1 |
|
$objWriter->writeAttribute('dir', 'r'); |
1876
|
1 |
|
$objWriter->endElement(); |
1877
|
1 |
|
break; |
1878
|
1 |
|
case Transition::TRANSITION_PULL_UP: |
1879
|
1 |
|
$objWriter->startElement('p:pull'); |
1880
|
1 |
|
$objWriter->writeAttribute('dir', 'u'); |
1881
|
1 |
|
$objWriter->endElement(); |
1882
|
1 |
|
break; |
1883
|
1 |
|
case Transition::TRANSITION_PUSH_DOWN: |
1884
|
1 |
|
$objWriter->startElement('p:push'); |
1885
|
1 |
|
$objWriter->writeAttribute('dir', 'd'); |
1886
|
1 |
|
$objWriter->endElement(); |
1887
|
1 |
|
break; |
1888
|
1 |
|
case Transition::TRANSITION_PUSH_LEFT: |
1889
|
1 |
|
$objWriter->startElement('p:push'); |
1890
|
1 |
|
$objWriter->writeAttribute('dir', 'l'); |
1891
|
1 |
|
$objWriter->endElement(); |
1892
|
1 |
|
break; |
1893
|
1 |
|
case Transition::TRANSITION_PUSH_RIGHT: |
1894
|
1 |
|
$objWriter->startElement('p:push'); |
1895
|
1 |
|
$objWriter->writeAttribute('dir', 'r'); |
1896
|
1 |
|
$objWriter->endElement(); |
1897
|
1 |
|
break; |
1898
|
1 |
|
case Transition::TRANSITION_PUSH_UP: |
1899
|
1 |
|
$objWriter->startElement('p:push'); |
1900
|
1 |
|
$objWriter->writeAttribute('dir', 'u'); |
1901
|
1 |
|
$objWriter->endElement(); |
1902
|
1 |
|
break; |
1903
|
1 |
|
case Transition::TRANSITION_RANDOM: |
1904
|
1 |
|
$objWriter->writeElement('p:random'); |
1905
|
1 |
|
break; |
1906
|
1 |
|
case Transition::TRANSITION_RANDOMBAR_HORIZONTAL: |
1907
|
1 |
|
$objWriter->startElement('p:randomBar'); |
1908
|
1 |
|
$objWriter->writeAttribute('dir', 'horz'); |
1909
|
1 |
|
$objWriter->endElement(); |
1910
|
1 |
|
break; |
1911
|
1 |
|
case Transition::TRANSITION_RANDOMBAR_VERTICAL: |
1912
|
1 |
|
$objWriter->startElement('p:randomBar'); |
1913
|
1 |
|
$objWriter->writeAttribute('dir', 'vert'); |
1914
|
1 |
|
$objWriter->endElement(); |
1915
|
1 |
|
break; |
1916
|
1 |
|
case Transition::TRANSITION_SPLIT_IN_HORIZONTAL: |
1917
|
1 |
|
$objWriter->startElement('p:split'); |
1918
|
1 |
|
$objWriter->writeAttribute('dir', 'in'); |
1919
|
1 |
|
$objWriter->writeAttribute('orient', 'horz'); |
1920
|
1 |
|
$objWriter->endElement(); |
1921
|
1 |
|
break; |
1922
|
1 |
|
case Transition::TRANSITION_SPLIT_OUT_HORIZONTAL: |
1923
|
1 |
|
$objWriter->startElement('p:split'); |
1924
|
1 |
|
$objWriter->writeAttribute('dir', 'out'); |
1925
|
1 |
|
$objWriter->writeAttribute('orient', 'horz'); |
1926
|
1 |
|
$objWriter->endElement(); |
1927
|
1 |
|
break; |
1928
|
1 |
|
case Transition::TRANSITION_SPLIT_IN_VERTICAL: |
1929
|
1 |
|
$objWriter->startElement('p:split'); |
1930
|
1 |
|
$objWriter->writeAttribute('dir', 'in'); |
1931
|
1 |
|
$objWriter->writeAttribute('orient', 'vert'); |
1932
|
1 |
|
$objWriter->endElement(); |
1933
|
1 |
|
break; |
1934
|
1 |
|
case Transition::TRANSITION_SPLIT_OUT_VERTICAL: |
1935
|
1 |
|
$objWriter->startElement('p:split'); |
1936
|
1 |
|
$objWriter->writeAttribute('dir', 'out'); |
1937
|
1 |
|
$objWriter->writeAttribute('orient', 'vert'); |
1938
|
1 |
|
$objWriter->endElement(); |
1939
|
1 |
|
break; |
1940
|
1 |
|
case Transition::TRANSITION_STRIPS_LEFT_DOWN: |
1941
|
1 |
|
$objWriter->startElement('p:strips'); |
1942
|
1 |
|
$objWriter->writeAttribute('dir', 'ld'); |
1943
|
1 |
|
$objWriter->endElement(); |
1944
|
1 |
|
break; |
1945
|
1 |
|
case Transition::TRANSITION_STRIPS_LEFT_UP: |
1946
|
1 |
|
$objWriter->startElement('p:strips'); |
1947
|
1 |
|
$objWriter->writeAttribute('dir', 'lu'); |
1948
|
1 |
|
$objWriter->endElement(); |
1949
|
1 |
|
break; |
1950
|
1 |
|
case Transition::TRANSITION_STRIPS_RIGHT_DOWN: |
1951
|
1 |
|
$objWriter->startElement('p:strips'); |
1952
|
1 |
|
$objWriter->writeAttribute('dir', 'rd'); |
1953
|
1 |
|
$objWriter->endElement(); |
1954
|
1 |
|
break; |
1955
|
1 |
|
case Transition::TRANSITION_STRIPS_RIGHT_UP: |
1956
|
1 |
|
$objWriter->startElement('p:strips'); |
1957
|
1 |
|
$objWriter->writeAttribute('dir', 'ru'); |
1958
|
1 |
|
$objWriter->endElement(); |
1959
|
1 |
|
break; |
1960
|
1 |
|
case Transition::TRANSITION_WEDGE: |
1961
|
1 |
|
$objWriter->writeElement('p:wedge'); |
1962
|
1 |
|
break; |
1963
|
1 |
|
case Transition::TRANSITION_WIPE_DOWN: |
1964
|
1 |
|
$objWriter->startElement('p:wipe'); |
1965
|
1 |
|
$objWriter->writeAttribute('dir', 'd'); |
1966
|
1 |
|
$objWriter->endElement(); |
1967
|
1 |
|
break; |
1968
|
1 |
|
case Transition::TRANSITION_WIPE_LEFT: |
1969
|
1 |
|
$objWriter->startElement('p:wipe'); |
1970
|
1 |
|
$objWriter->writeAttribute('dir', 'l'); |
1971
|
1 |
|
$objWriter->endElement(); |
1972
|
1 |
|
break; |
1973
|
1 |
|
case Transition::TRANSITION_WIPE_RIGHT: |
1974
|
1 |
|
$objWriter->startElement('p:wipe'); |
1975
|
1 |
|
$objWriter->writeAttribute('dir', 'r'); |
1976
|
1 |
|
$objWriter->endElement(); |
1977
|
1 |
|
break; |
1978
|
1 |
|
case Transition::TRANSITION_WIPE_UP: |
1979
|
1 |
|
$objWriter->startElement('p:wipe'); |
1980
|
1 |
|
$objWriter->writeAttribute('dir', 'u'); |
1981
|
1 |
|
$objWriter->endElement(); |
1982
|
1 |
|
break; |
1983
|
1 |
|
case Transition::TRANSITION_ZOOM_IN: |
1984
|
1 |
|
$objWriter->startElement('p:zoom'); |
1985
|
1 |
|
$objWriter->writeAttribute('dir', 'in'); |
1986
|
1 |
|
$objWriter->endElement(); |
1987
|
1 |
|
break; |
1988
|
1 |
|
case Transition::TRANSITION_ZOOM_OUT: |
1989
|
1 |
|
$objWriter->startElement('p:zoom'); |
1990
|
1 |
|
$objWriter->writeAttribute('dir', 'out'); |
1991
|
1 |
|
$objWriter->endElement(); |
1992
|
1 |
|
break; |
1993
|
1 |
|
} |
1994
|
|
|
|
1995
|
1 |
|
$objWriter->endElement(); |
1996
|
1 |
|
} |
1997
|
|
|
} |
1998
|
|
|
|