Completed
Pull Request — develop (#336)
by Franck
15:32 queued 06:12
created

PptSlides::writeNote()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 280
Code Lines 130

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 132
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 280
ccs 132
cts 132
cp 1
rs 8.2857
c 2
b 0
f 0
cc 3
eloc 130
nc 3
nop 1
crap 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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