Completed
Pull Request — develop (#207)
by Franck
24:36 queued 20:39
created

Content::writeTxtStyle()   F

Complexity

Conditions 27
Paths 17160

Size

Total Lines 104
Code Lines 74

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 81
CRAP Score 27.0331

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 104
ccs 81
cts 84
cp 0.9643
rs 2
cc 27
eloc 74
nc 17160
nop 2
crap 27.0331

How to fix   Long Method    Complexity   

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\ODPresentation;
4
5
use PhpOffice\Common\Adapter\Zip\ZipInterface;
6
use PhpOffice\Common\Drawing as CommonDrawing;
7
use PhpOffice\Common\Text;
8
use PhpOffice\Common\XMLWriter;
9
use PhpOffice\PhpPresentation\Shape\Comment;
10
use PhpOffice\PhpPresentation\Shape\Media;
11
use PhpOffice\PhpPresentation\Slide;
12
use PhpOffice\PhpPresentation\Shape\AbstractDrawing;
13
use PhpOffice\PhpPresentation\Shape\Chart;
14
use PhpOffice\PhpPresentation\Shape\Drawing as ShapeDrawing;
15
use PhpOffice\PhpPresentation\Shape\Group;
16
use PhpOffice\PhpPresentation\Shape\Line;
17
use PhpOffice\PhpPresentation\Shape\RichText\BreakElement;
18
use PhpOffice\PhpPresentation\Shape\RichText\Run;
19
use PhpOffice\PhpPresentation\Shape\RichText\TextElement;
20
use PhpOffice\PhpPresentation\Shape\RichText;
21
use PhpOffice\PhpPresentation\Shape\Table;
22
use PhpOffice\PhpPresentation\Slide\Note;
23
use PhpOffice\PhpPresentation\Slide\Transition;
24
use PhpOffice\PhpPresentation\Style\Alignment;
25
use PhpOffice\PhpPresentation\Style\Border;
26
use PhpOffice\PhpPresentation\Style\Fill;
27
use PhpOffice\PhpPresentation\Style\Shadow;
28
use PhpOffice\PhpPresentation\Writer\ODPresentation;
29
30
class Content extends AbstractDecoratorWriter
31
{
32
    /**
33
     * Stores bullet styles for text shapes that include lists.
34
     *
35
     * @var []
36
     */
37
    protected $arrStyleBullet    = array();
38
39
    /**
40
     * Stores paragraph information for text shapes.
41
     *
42
     * @var array
43
     */
44
    protected $arrStyleParagraph = array();
45
46
    /**
47
     * Stores font styles for text shapes that include lists.
48
     *
49
     * @var Run[]
50
     */
51
    protected $arrStyleTextFont  = array();
52
53
    /**
54
     * Used to track the current shape ID.
55
     *
56
     * @var integer
57
     */
58
    protected $shapeId;
59
60
    /**
61
     * @return ZipInterface
62
     */
63
    public function render()
64 59
    {
65
        $this->getZip()->addFromString('content.xml', $this->writeContent());
66 59
        return $this->getZip();
67 59
    }
68
69
70
71
    /**
72
     * Write content file to XML format
73
     *
74
     * @return string        XML Output
75
     * @throws \Exception
76
     */
77
    public function writeContent()
78 59
    {
79
        // Create XML writer
80
        $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
81 59
        $objWriter->startDocument('1.0', 'UTF-8');
82 59
83
        // office:document-content
84
        $objWriter->startElement('office:document-content');
85 59
        $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
86 59
        $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
87 59
        $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
88 59
        $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
89 59
        $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
90 59
        $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
91 59
        $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
92 59
        $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
93 59
        $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
94 59
        $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
95 59
        $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
96 59
        $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
97 59
        $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
98 59
        $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
99 59
        $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
100 59
        $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
101 59
        $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
102 59
        $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
103 59
        $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
104 59
        $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
105 59
        $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
106 59
        $objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
107 59
        $objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
108 59
        $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
109 59
        $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
110 59
        $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
111 59
        $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
112 59
        $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
113 59
        $objWriter->writeAttribute('xmlns:rdfa', 'http://docs.oasis-open.org/opendocument/meta/rdfa#');
114 59
        $objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
115 59
        $objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
116 59
        $objWriter->writeAttribute('office:version', '1.2');
117 59
118
        // office:automatic-styles
119
        $objWriter->startElement('office:automatic-styles');
120 59
121
        $this->shapeId    = 0;
122 59
        $incSlide = 0;
123 59
        foreach ($this->getPresentation()->getAllSlides() as $pSlide) {
124 59
            // Slides
125
            $this->writeStyleSlide($objWriter, $pSlide, $incSlide);
126 59
127
            // Images
128
            $shapes = $pSlide->getShapeCollection();
129 59
            foreach ($shapes as $shape) {
130 59
                // Increment $this->shapeId
131
                ++$this->shapeId;
132 51
133
                // Check type
134
                if ($shape instanceof RichText) {
135 51
                    $this->writeTxtStyle($objWriter, $shape);
136 14
                }
137 14
                if ($shape instanceof AbstractDrawing) {
0 ignored issues
show
Bug introduced by
The class PhpOffice\PhpPresentation\Shape\AbstractDrawing does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
138 51
                    $this->writeDrawingStyle($objWriter, $shape);
139 35
                }
140 35
                if ($shape instanceof Line) {
141 51
                    $this->writeLineStyle($objWriter, $shape);
142 1
                }
143 1
                if ($shape instanceof Table) {
144 51
                    $this->writeTableStyle($objWriter, $shape);
145 7
                }
146 7
                if ($shape instanceof Group) {
147 51
                    $this->writeGroupStyle($objWriter, $shape);
148 1
                }
149 1
            }
150 59
151
            $incSlide++;
152 59
        }
153 59
        // Style : Bullet
154
        if (!empty($this->arrStyleBullet)) {
155 59
            foreach ($this->arrStyleBullet as $key => $item) {
156 14
                $oStyle   = $item['oStyle'];
157 14
                $arrLevel = explode(';', $item['level']);
158 14
                // style:style
159
                $objWriter->startElement('text:list-style');
160 14
                $objWriter->writeAttribute('style:name', 'L_' . $key);
161 14
                foreach ($arrLevel as $level) {
162 14
                    if ($level != '') {
163 14
                        $oAlign = $item['oAlign_' . $level];
164 14
                        // text:list-level-style-bullet
165
                        $objWriter->startElement('text:list-level-style-bullet');
166 14
                        $objWriter->writeAttribute('text:level', $level + 1);
167 14
                        $objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
168 14
                        // style:list-level-properties
169
                        $objWriter->startElement('style:list-level-properties');
170 14
                        if ($oAlign->getIndent() < 0) {
171 14
                            $objWriter->writeAttribute('text:space-before', CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - (-1 * $oAlign->getIndent())) . 'cm');
172 1
                            $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters(-1 * $oAlign->getIndent()) . 'cm');
173 1
                        } else {
174 1
                            $objWriter->writeAttribute('text:space-before', (CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - $oAlign->getIndent())) . 'cm');
175 13
                            $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters($oAlign->getIndent()) . 'cm');
176 13
                        }
177
178
                        $objWriter->endElement();
179 14
                        // style:text-properties
180
                        $objWriter->startElement('style:text-properties');
181 14
                        $objWriter->writeAttribute('fo:font-family', $oStyle->getBulletFont());
182 14
                        $objWriter->writeAttribute('style:font-family-generic', 'swiss');
183 14
                        $objWriter->writeAttribute('style:use-window-font-color', 'true');
184 14
                        $objWriter->writeAttribute('fo:font-size', '100');
185 14
                        $objWriter->endElement();
186 14
                        $objWriter->endElement();
187 14
                    }
188 14
                }
189 14
                $objWriter->endElement();
190 14
            }
191 14
        }
192 14
        // Style : Paragraph
193
        if (!empty($this->arrStyleParagraph)) {
194 59
            foreach ($this->arrStyleParagraph as $key => $item) {
195 14
                // style:style
196
                $objWriter->startElement('style:style');
197 14
                $objWriter->writeAttribute('style:name', 'P_' . $key);
198 14
                $objWriter->writeAttribute('style:family', 'paragraph');
199 14
                // style:paragraph-properties
200
                $objWriter->startElement('style:paragraph-properties');
201 14
                switch ($item->getAlignment()->getHorizontal()) {
202 14
                    case Alignment::HORIZONTAL_LEFT:
203 14
                        $objWriter->writeAttribute('fo:text-align', 'left');
204 14
                        break;
205 14
                    case Alignment::HORIZONTAL_RIGHT:
206 1
                        $objWriter->writeAttribute('fo:text-align', 'right');
207 1
                        break;
208 1
                    case Alignment::HORIZONTAL_CENTER:
209 1
                        $objWriter->writeAttribute('fo:text-align', 'center');
210 1
                        break;
211 1
                    case Alignment::HORIZONTAL_JUSTIFY:
212 1
                        $objWriter->writeAttribute('fo:text-align', 'justify');
213 1
                        break;
214 1
                    case Alignment::HORIZONTAL_DISTRIBUTED:
215 1
                        $objWriter->writeAttribute('fo:text-align', 'justify');
216 1
                        break;
217 1
                    default:
218 1
                        $objWriter->writeAttribute('fo:text-align', 'left');
219 1
                        break;
220 1
                }
221 14
                $objWriter->endElement();
222 14
                $objWriter->endElement();
223 14
            }
224 14
        }
225 14
        // Style : Text : Font
226
        if (!empty($this->arrStyleTextFont)) {
227 59
            foreach ($this->arrStyleTextFont as $key => $item) {
228 10
                // style:style
229
                $objWriter->startElement('style:style');
230 10
                $objWriter->writeAttribute('style:name', 'T_' . $key);
231 10
                $objWriter->writeAttribute('style:family', 'text');
232 10
                // style:text-properties
233
                $objWriter->startElement('style:text-properties');
234 10
                $objWriter->writeAttribute('fo:color', '#' . $item->getFont()->getColor()->getRGB());
235 10
                $objWriter->writeAttribute('fo:font-family', $item->getFont()->getName());
236 10
                $objWriter->writeAttribute('fo:font-size', $item->getFont()->getSize() . 'pt');
237 10
                // @todo : fo:font-style
238
                if ($item->getFont()->isBold()) {
239 10
                    $objWriter->writeAttribute('fo:font-weight', 'bold');
240 1
                }
241 1
                $objWriter->writeAttribute('fo:language', ($item->getLanguage() ? $item->getLanguage() : 'en-US'));
242 10
243
                // @todo : style:text-underline-style
244
                $objWriter->endElement();
245 10
                $objWriter->endElement();
246 10
            }
247 10
        }
248 10
        $objWriter->endElement();
249 59
250
        //===============================================
251
        // Body
252
        //===============================================
253
        // office:body
254
        $objWriter->startElement('office:body');
255 59
        // office:presentation
256
        $objWriter->startElement('office:presentation');
257 59
258
        // Write slides
259
        $slideCount = $this->getPresentation()->getSlideCount();
260 59
        $this->shapeId    = 0;
261 59
        for ($i = 0; $i < $slideCount; ++$i) {
262 59
            $pSlide = $this->getPresentation()->getSlide($i);
263 59
            $objWriter->startElement('draw:page');
264 59
            $name = $pSlide->getName();
265 59
            if (!is_null($name)) {
266 59
                $objWriter->writeAttribute('draw:name', $name);
267 1
            }
268 1
            $objWriter->writeAttribute('draw:master-page-name', 'Standard');
269 59
            $objWriter->writeAttribute('draw:style-name', 'stylePage' . $i);
270 59
            // Images
271
            $shapes = $pSlide->getShapeCollection();
272 59
            foreach ($shapes as $shape) {
273 59
                // Increment $this->shapeId
274
                ++$this->shapeId;
275 51
276
                // Check type
277
                if ($shape instanceof RichText) {
278 51
                    $this->writeShapeTxt($objWriter, $shape);
279 14
                } elseif ($shape instanceof Table) {
280 51
                    $this->writeShapeTable($objWriter, $shape);
281 7
                } elseif ($shape instanceof Line) {
282 38
                    $this->writeShapeLine($objWriter, $shape);
283 1
                } elseif ($shape instanceof Chart) {
284 32
                    $this->writeShapeChart($objWriter, $shape);
285 21
                } elseif ($shape instanceof Media) {
286 32
                    $this->writeShapeMedia($objWriter, $shape);
287 1
                } elseif ($shape instanceof ShapeDrawing\AbstractDrawingAdapter) {
288 12
                    $this->writeShapeDrawing($objWriter, $shape);
289 8
                } elseif ($shape instanceof Group) {
290 11
                    $this->writeShapeGroup($objWriter, $shape);
291 1
                } elseif ($shape instanceof Comment) {
292 3
                    $this->writeShapeComment($objWriter, $shape);
293 2
                }
294 2
            }
295 59
            // Slide Note
296
            if ($pSlide->getNote() instanceof Note) {
297 59
                $this->writeSlideNote($objWriter, $pSlide->getNote());
298 59
            }
299 59
300
            $objWriter->endElement();
301 59
        }
302 59
303
        if ($this->getPresentation()->getPresentationProperties()->isLoopContinuouslyUntilEsc()) {
304 59
            $objWriter->startElement('presentation:settings');
305
            $objWriter->writeAttribute('presentation:endless', 'true');
306
            $objWriter->writeAttribute('presentation:pause', 'P0s');
307
            $objWriter->writeAttribute('presentation:mouse-visible', 'false');
308
            $objWriter->endElement();
309
        }
310
        // > office:presentation
311
        $objWriter->endElement();
312 59
        // > office:body
313
        $objWriter->endElement();
314 59
        // > office:document-content
315
        $objWriter->endElement();
316 59
317
        // Return
318
        return $objWriter->getData();
319 59
    }
320
321
    /**
322
     * Write picture
323
     *
324
     * @param \PhpOffice\Common\XMLWriter $objWriter
325
     * @param \PhpOffice\PhpPresentation\Shape\Media $shape
326
     */
327
    public function writeShapeMedia(XMLWriter $objWriter, Media $shape)
328 1
    {
329
        // draw:frame
330
        $objWriter->startElement('draw:frame');
331 1
        $objWriter->writeAttribute('draw:name', $shape->getName());
332 1
        $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
333 1
        $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
334 1
        $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
335 1
        $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
336 1
        $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
337 1
        // draw:frame > draw:plugin
338
        $objWriter->startElement('draw:plugin');
339 1
        $objWriter->writeAttribute('xlink:href', 'Pictures/' . md5($shape->getPath()) . '.' . $shape->getExtension());
0 ignored issues
show
Bug introduced by
The method getPath() does not seem to exist on object<PhpOffice\PhpPresentation\Shape\Media>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
340 1
        $objWriter->writeAttribute('xlink:type', 'simple');
341 1
        $objWriter->writeAttribute('xlink:show', 'embed');
342 1
        $objWriter->writeAttribute('xlink:actuate', 'onLoad');
343 1
        $objWriter->writeAttribute('draw:mime-type', 'application/vnd.sun.star.media');
344 1
345
        $objWriter->startElement('draw:param');
346 1
        $objWriter->writeAttribute('draw:name', 'Loop');
347 1
        $objWriter->writeAttribute('draw:value', 'false');
348 1
        $objWriter->endElement();
349 1
        $objWriter->startElement('draw:param');
350 1
        $objWriter->writeAttribute('draw:name', 'Mute');
351 1
        $objWriter->writeAttribute('draw:value', 'false');
352 1
        $objWriter->endElement();
353 1
        $objWriter->startElement('draw:param');
354 1
        $objWriter->writeAttribute('draw:name', 'VolumeDB');
355 1
        $objWriter->writeAttribute('draw:value', 0);
356 1
        $objWriter->endElement();
357 1
        $objWriter->startElement('draw:param');
358 1
        $objWriter->writeAttribute('draw:name', 'Zoom');
359 1
        $objWriter->writeAttribute('draw:value', 'fit');
360 1
        $objWriter->endElement();
361 1
362
        // draw:frame > ## draw:plugin
363
        $objWriter->endElement();
364 1
365
        // ## draw:frame
366
        $objWriter->endElement();
367 1
    }
368 1
369
    /**
370
     * Write picture
371
     *
372
     * @param \PhpOffice\Common\XMLWriter $objWriter
373
     * @param \PhpOffice\PhpPresentation\Shape\AbstractDrawing $shape
374
     */
375
    public function writeShapeDrawing(XMLWriter $objWriter, ShapeDrawing\AbstractDrawingAdapter $shape)
376 9
    {
377
        // draw:frame
378
        $objWriter->startElement('draw:frame');
379 9
        $objWriter->writeAttribute('draw:name', $shape->getName());
380 9
        $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
381 9
        $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
382 9
        $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
383 9
        $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
384 9
        $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
385 9
        // draw:image
386
        $objWriter->startElement('draw:image');
387 9
        if ($shape instanceof ShapeDrawing\AbstractDrawingAdapter) {
388 9
            $objWriter->writeAttribute('xlink:href', 'Pictures/' . $shape->getIndexedFilename());
389 8
        }
390 9
        $objWriter->writeAttribute('xlink:type', 'simple');
391 1
        $objWriter->writeAttribute('xlink:show', 'embed');
392 1
        $objWriter->writeAttribute('xlink:actuate', 'onLoad');
393 9
        $objWriter->writeElement('text:p');
394 9
        $objWriter->endElement();
395 9
396 9
        if ($shape->hasHyperlink()) {
397 9
            // office:event-listeners
398
            $objWriter->startElement('office:event-listeners');
399 9
            // presentation:event-listener
400
            $objWriter->startElement('presentation:event-listener');
401 2
            $objWriter->writeAttribute('script:event-name', 'dom:click');
402
            $objWriter->writeAttribute('presentation:action', 'show');
403 2
            $objWriter->writeAttribute('xlink:href', $shape->getHyperlink()->getUrl());
404 2
            $objWriter->writeAttribute('xlink:type', 'simple');
405 2
            $objWriter->writeAttribute('xlink:show', 'embed');
406 2
            $objWriter->writeAttribute('xlink:actuate', 'onRequest');
407 2
            // > presentation:event-listener
408 2
            $objWriter->endElement();
409 2
            // > office:event-listeners
410
            $objWriter->endElement();
411 2
        }
412
413 2
        $objWriter->endElement();
414 2
    }
415
416 9
    /**
417 9
     * Write text
418
     *
419
     * @param \PhpOffice\Common\XMLWriter $objWriter
420
     * @param \PhpOffice\PhpPresentation\Shape\RichText $shape
421
     */
422
    public function writeShapeTxt(XMLWriter $objWriter, RichText $shape)
423
    {
424
        // draw:frame
425 15
        $objWriter->startElement('draw:frame');
426
        $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
427
        $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
428 15
        $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
429 15
        $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
430 15
        $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
431 15
        // draw:text-box
432 15
        $objWriter->startElement('draw:text-box');
433 15
434
        $paragraphs             = $shape->getParagraphs();
435 15
        $paragraphId            = 0;
436
        $sCstShpLastBullet      = '';
437 15
        $iCstShpLastBulletLvl   = 0;
438 15
        $bCstShpHasBullet       = false;
439 15
440 15
        foreach ($paragraphs as $paragraph) {
441 15
            // Close the bullet list
442
            if ($sCstShpLastBullet != 'bullet' && $bCstShpHasBullet === true) {
443 15
                for ($iInc = $iCstShpLastBulletLvl; $iInc >= 0; $iInc--) {
444
                    // text:list-item
445 15
                    $objWriter->endElement();
446
                    // text:list
447
                    $objWriter->endElement();
448
                }
449
            }
450
            //===============================================
451
            // Paragraph
452
            //===============================================
453
            if ($paragraph->getBulletStyle()->getBulletType() == 'none') {
454
                ++$paragraphId;
455
                // text:p
456 15
                $objWriter->startElement('text:p');
457 12
                $objWriter->writeAttribute('text:style-name', 'P_' . $paragraph->getHashCode());
458
459 12
                // Loop trough rich text elements
460 12
                $richtexts  = $paragraph->getRichTextElements();
461
                $richtextId = 0;
462
                foreach ($richtexts as $richtext) {
463 12
                    ++$richtextId;
464 12
                    if ($richtext instanceof TextElement || $richtext instanceof Run) {
465 12
                        // text:span
466 6
                        $objWriter->startElement('text:span');
467 6
                        if ($richtext instanceof Run) {
468
                            $objWriter->writeAttribute('text:style-name', 'T_' . $richtext->getHashCode());
469 6
                        }
470 6
                        if ($richtext->hasHyperlink() === true && $richtext->getHyperlink()->getUrl() != '') {
471 6
                            // text:a
472 6
                            $objWriter->startElement('text:a');
473 6
                            $objWriter->writeAttribute('xlink:href', $richtext->getHyperlink()->getUrl());
474
                            $objWriter->text($richtext->getText());
475 1
                            $objWriter->endElement();
476 1
                        } else {
477 1
                            $objWriter->text($richtext->getText());
478 1
                        }
479 1
                        $objWriter->endElement();
480 6
                    } elseif ($richtext instanceof BreakElement) {
481
                        // text:span
482 6
                        $objWriter->startElement('text:span');
483 6
                        // text:line-break
484
                        $objWriter->startElement('text:line-break');
485 1
                        $objWriter->endElement();
486
                        $objWriter->endElement();
487 1
                    } else {
488 1
                        //echo '<pre>'.print_r($richtext, true).'</pre>';
489 1
                    }
490 1
                }
491
                $objWriter->endElement();
492
                //===============================================
493 12
                // Bullet list
494 12
                //===============================================
495
            } elseif ($paragraph->getBulletStyle()->getBulletType() == 'bullet') {
496
                $bCstShpHasBullet = true;
497
                // Open the bullet list
498 15
                if ($sCstShpLastBullet != 'bullet' || ($sCstShpLastBullet == $paragraph->getBulletStyle()->getBulletType() && $iCstShpLastBulletLvl < $paragraph->getAlignment()->getLevel())) {
499 3
                    // text:list
500
                    $objWriter->startElement('text:list');
501 3
                    $objWriter->writeAttribute('text:style-name', 'L_' . $paragraph->getBulletStyle()->getHashCode());
502
                }
503 3
                if ($sCstShpLastBullet == 'bullet') {
504 3
                    if ($iCstShpLastBulletLvl == $paragraph->getAlignment()->getLevel()) {
505 3
                        // text:list-item
506 3
                        $objWriter->endElement();
507 2
                    } elseif ($iCstShpLastBulletLvl > $paragraph->getAlignment()->getLevel()) {
508
                        // text:list-item
509 2
                        $objWriter->endElement();
510 2
                        // text:list
511
                        $objWriter->endElement();
512 1
                        // text:list-item
513
                        $objWriter->endElement();
514 1
                    }
515
                }
516 1
517 1
                // text:list-item
518 2
                $objWriter->startElement('text:list-item');
519
                ++$paragraphId;
520
                // text:p
521 3
                $objWriter->startElement('text:p');
522 3
                $objWriter->writeAttribute('text:style-name', 'P_' . $paragraph->getHashCode());
523
524 3
                // Loop trough rich text elements
525 3
                $richtexts  = $paragraph->getRichTextElements();
526
                $richtextId = 0;
527
                foreach ($richtexts as $richtext) {
528 3
                    ++$richtextId;
529 3
                    if ($richtext instanceof TextElement || $richtext instanceof Run) {
530 3
                        // text:span
531 3
                        $objWriter->startElement('text:span');
532 3
                        if ($richtext instanceof Run) {
533
                            $objWriter->writeAttribute('text:style-name', 'T_' . $richtext->getHashCode());
534 3
                        }
535 3
                        if ($richtext->hasHyperlink() === true && $richtext->getHyperlink()->getUrl() != '') {
536 3
                            // text:a
537 3
                            $objWriter->startElement('text:a');
538 3
                            $objWriter->writeAttribute('xlink:href', $richtext->getHyperlink()->getUrl());
539
                            $objWriter->text($richtext->getText());
540 1
                            $objWriter->endElement();
541 1
                        } else {
542 1
                            $objWriter->text($richtext->getText());
543 1
                        }
544 1
                        $objWriter->endElement();
545 3
                    } elseif ($richtext instanceof BreakElement) {
546
                        // text:span
547 3
                        $objWriter->startElement('text:span');
548 3
                        // text:line-break
549
                        $objWriter->startElement('text:line-break');
550 1
                        $objWriter->endElement();
551
                        $objWriter->endElement();
552 1
                    } else {
553 1
                        //echo '<pre>'.print_r($richtext, true).'</pre>';
554 1
                    }
555 1
                }
556
                $objWriter->endElement();
557
            }
558 3
            $sCstShpLastBullet      = $paragraph->getBulletStyle()->getBulletType();
559 3
            $iCstShpLastBulletLvl = $paragraph->getAlignment()->getLevel();
560 3
        }
561 15
562 15
        // Close the bullet list
563 15
        if ($sCstShpLastBullet == 'bullet' && $bCstShpHasBullet === true) {
564
            for ($iInc = $iCstShpLastBulletLvl; $iInc >= 0; $iInc--) {
565
                // text:list-item
566 15
                $objWriter->endElement();
567 3
                // text:list
568
                $objWriter->endElement();
569 3
            }
570
        }
571 3
572 3
        // > draw:text-box
573 3
        $objWriter->endElement();
574
        // > draw:frame
575
        $objWriter->endElement();
576 15
    }
577
    /**
578 15
     * Write Comment
579 15
     * @param XMLWriter $objWriter
580
     * @param Comment $oShape
581
     */
582
    public function writeShapeComment(XMLWriter $objWriter, Comment $oShape)
583
    {
584
        // officeooo:annotation
585 2
        $objWriter->startElement('officeooo:annotation');
586
        $objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetX()), 2, '.', '').'cm');
587
        $objWriter->writeAttribute('svg:y', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetY()), 2, '.', '').'cm');
588 2
589 2
        if ($oShape->getAuthor() instanceof Comment\Author) {
590 2
            $objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName());
591
        }
592 2
        $objWriter->writeElement('dc:date', date('Y-m-d\TH:i:s', $oShape->getDate()));
593 1
        $objWriter->writeElement('text:p', $oShape->getText());
594 1
595 2
        // ## officeooo:annotation
596 2
        $objWriter->endElement();
597
    }
598
599 2
    /**
600 2
     * @param XMLWriter $objWriter
601
     * @param Line $shape
602
     */
603
    public function writeShapeLine(XMLWriter $objWriter, Line $shape)
604
    {
605
        // draw:line
606 1
        $objWriter->startElement('draw:line');
607
        $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId);
608
        $objWriter->writeAttribute('svg:x1', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
609 1
        $objWriter->writeAttribute('svg:y1', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
610 1
        $objWriter->writeAttribute('svg:x2', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()+$shape->getWidth()), 3) . 'cm');
611 1
        $objWriter->writeAttribute('svg:y2', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()+$shape->getHeight()), 3) . 'cm');
612 1
613 1
        // text:p
614 1
        $objWriter->writeElement('text:p');
615
616
        $objWriter->endElement();
617 1
    }
618
619 1
    /**
620 1
     * Write table Shape
621
     * @param XMLWriter $objWriter
622
     * @param Table $shape
623
     */
624
    public function writeShapeTable(XMLWriter $objWriter, Table $shape)
625
    {
626
        // draw:frame
627 7
        $objWriter->startElement('draw:frame');
628
        $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
629
        $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
630 7
        $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
631 7
        $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
632 7
633 7
        // table:table
634 7
        $objWriter->startElement('table:table');
635
636
        foreach ($shape->getRows() as $keyRow => $shapeRow) {
637 7
            // table:table-row
638
            $objWriter->startElement('table:table-row');
639 7
            $objWriter->writeAttribute('table:style-name', 'gr'.$this->shapeId.'r'.$keyRow);
640
            //@todo getFill
641 6
642 6
            $numColspan = 0;
643
            foreach ($shapeRow->getCells() as $keyCell => $shapeCell) {
644
                if ($numColspan == 0) {
645 6
                    // table:table-cell
646 6
                    $objWriter->startElement('table:table-cell');
647 6
                    $objWriter->writeAttribute('table:style-name', 'gr' . $this->shapeId.'r'.$keyRow.'c'.$keyCell);
648
                    if ($shapeCell->getColspan() > 1) {
649 6
                        $objWriter->writeAttribute('table:number-columns-spanned', $shapeCell->getColspan());
650 6
                        $numColspan = $shapeCell->getColspan() - 1;
651 6
                    }
652 1
653 1
                    // text:p
654 1
                    $objWriter->startElement('text:p');
655
656
                    // text:span
657 6
                    foreach ($shapeCell->getParagraphs() as $shapeParagraph) {
658
                        foreach ($shapeParagraph->getRichTextElements() as $shapeRichText) {
659
                            if ($shapeRichText instanceof TextElement || $shapeRichText instanceof Run) {
660 6
                                // text:span
661 6
                                $objWriter->startElement('text:span');
662 2
                                if ($shapeRichText instanceof Run) {
663
                                    $objWriter->writeAttribute('text:style-name', 'T_' . $shapeRichText->getHashCode());
664 2
                                }
665 2
                                if ($shapeRichText->hasHyperlink() === true && $shapeRichText->getHyperlink()->getUrl() != '') {
666 2
                                    // text:a
667 2
                                    $objWriter->startElement('text:a');
668 2
                                    $objWriter->writeAttribute('xlink:href', $shapeRichText->getHyperlink()->getUrl());
669
                                    $objWriter->text($shapeRichText->getText());
670 1
                                    $objWriter->endElement();
671 1
                                } else {
672 1
                                    $objWriter->text($shapeRichText->getText());
673 1
                                }
674 1
                                $objWriter->endElement();
675 1
                            } elseif ($shapeRichText instanceof BreakElement) {
676
                                // text:span
677 2
                                $objWriter->startElement('text:span');
678 2
                                // text:line-break
679
                                $objWriter->startElement('text:line-break');
680 1
                                $objWriter->endElement();
681
                                $objWriter->endElement();
682 1
                            }
683 1
                        }
684 1
                    }
685 1
686 6
                    // > text:p
687 6
                    $objWriter->endElement();
688
689
                    // > table:table-cell
690 6
                    $objWriter->endElement();
691
                } else {
692
                    // table:covered-table-cell
693 6
                    $objWriter->writeElement('table:covered-table-cell');
694 6
                    $numColspan--;
695
                }
696 1
            }
697 1
            // > table:table-row
698
            $objWriter->endElement();
699 6
        }
700
        // > table:table
701 6
        $objWriter->endElement();
702 7
        // > draw:frame
703
        $objWriter->endElement();
704 7
    }
705
706 7
    /**
707 7
     * Write table Chart
708
     * @param XMLWriter $objWriter
709
     * @param Chart $shape
710
     * @throws \Exception
711
     */
712
    public function writeShapeChart(XMLWriter $objWriter, Chart $shape)
713
    {
714
        $arrayChart = $this->getArrayChart();
715 21
        $arrayChart[$this->shapeId] = $shape;
716
        $this->setArrayChart($arrayChart);
717 21
718 21
        // draw:frame
719 21
        $objWriter->startElement('draw:frame');
720
        $objWriter->writeAttribute('draw:name', $shape->getTitle()->getText());
721
        $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm');
722 21
        $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm');
723 21
        $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm');
724 21
        $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm');
725 21
726 21
        // draw:object
727 21
        $objWriter->startElement('draw:object');
728
        $objWriter->writeAttribute('xlink:href', './Object '.$this->shapeId);
729
        $objWriter->writeAttribute('xlink:type', 'simple');
730 21
        $objWriter->writeAttribute('xlink:show', 'embed');
731 21
732 21
        // > draw:object
733 21
        $objWriter->endElement();
734
        // > draw:frame
735
        $objWriter->endElement();
736 21
    }
737
738 21
    /**
739 21
     * Writes a group of shapes
740
     *
741
     * @param XMLWriter $objWriter
742
     * @param Group $group
743
     */
744
    public function writeShapeGroup(XMLWriter $objWriter, Group $group)
745
    {
746
        // draw:g
747 1
        $objWriter->startElement('draw:g');
748
749
        $shapes = $group->getShapeCollection();
750 1
        foreach ($shapes as $shape) {
751
            // Increment $this->shapeId
752 1
            ++$this->shapeId;
753 1
754
            // Check type
755 1
            if ($shape instanceof RichText) {
756
                $this->writeShapeTxt($objWriter, $shape);
757
            } elseif ($shape instanceof Table) {
758 1
                $this->writeShapeTable($objWriter, $shape);
759
            } elseif ($shape instanceof Line) {
760 1
                $this->writeShapeLine($objWriter, $shape);
761
            } elseif ($shape instanceof Chart) {
762 1
                $this->writeShapeChart($objWriter, $shape);
763
            } elseif ($shape instanceof ShapeDrawing\AbstractDrawingAdapter) {
764 1
                $this->writeShapeDrawing($objWriter, $shape);
765
            } elseif ($shape instanceof Group) {
766 1
                $this->writeShapeGroup($objWriter, $shape);
767 1
            }
768 1
        }
769
770
        $objWriter->endElement(); // draw:g
771 1
    }
772
773 1
    /**
774 1
     * Writes the style information for a group of shapes
775
     *
776
     * @param XMLWriter $objWriter
777
     * @param Group $group
778
     */
779
    public function writeGroupStyle(XMLWriter $objWriter, Group $group)
780
    {
781
        $shapes = $group->getShapeCollection();
782 1
        foreach ($shapes as $shape) {
783
            // Increment $this->shapeId
784 1
            ++$this->shapeId;
785 1
786
            // Check type
787 1
            if ($shape instanceof RichText) {
788
                $this->writeTxtStyle($objWriter, $shape);
789
            }
790 1
            if ($shape instanceof AbstractDrawing) {
0 ignored issues
show
Bug introduced by
The class PhpOffice\PhpPresentation\Shape\AbstractDrawing does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
791
                $this->writeDrawingStyle($objWriter, $shape);
792
            }
793 1
            if ($shape instanceof Line) {
794 1
                $this->writeLineStyle($objWriter, $shape);
795 1
            }
796 1
            if ($shape instanceof Table) {
797
                $this->writeTableStyle($objWriter, $shape);
798
            }
799 1
        }
800
    }
801
802 1
    /**
803 1
     * Write the default style information for a RichText shape
804
     *
805
     * @param \PhpOffice\Common\XMLWriter $objWriter
806
     * @param \PhpOffice\PhpPresentation\Shape\RichText $shape
807
     */
808
    public function writeTxtStyle(XMLWriter $objWriter, RichText $shape)
809
    {
810
        // style:style
811 14
        $objWriter->startElement('style:style');
812
        $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId);
813
        $objWriter->writeAttribute('style:family', 'graphic');
814 14
        $objWriter->writeAttribute('style:parent-style-name', 'standard');
815 14
        // style:graphic-properties
816 14
        $objWriter->startElement('style:graphic-properties');
817 14
        if ($shape->getShadow()->isVisible()) {
818
            $this->writeStylePartShadow($objWriter, $shape->getShadow());
819 14
        }
820 14
        if (is_bool($shape->hasAutoShrinkVertical())) {
821 1
            $objWriter->writeAttribute('draw:auto-grow-height', var_export($shape->hasAutoShrinkVertical(), true));
822 1
        }
823 14
        if (is_bool($shape->hasAutoShrinkHorizontal())) {
824 1
            $objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->hasAutoShrinkHorizontal(), true));
825 1
        }
826 14
        // Fill
827 1
        switch ($shape->getFill()->getFillType()) {
828 1
            case Fill::FILL_GRADIENT_LINEAR:
829
            case Fill::FILL_GRADIENT_PATH:
830 14
                $objWriter->writeAttribute('draw:fill', 'gradient');
831 14
                $objWriter->writeAttribute('draw:fill-gradient-name', 'gradient_'.$shape->getFill()->getHashCode());
832 14
                break;
833 1
            case Fill::FILL_SOLID:
834 1
                $objWriter->writeAttribute('draw:fill', 'solid');
835 1
                $objWriter->writeAttribute('draw:fill-color', '#'.$shape->getFill()->getStartColor()->getRGB());
836 13
                break;
837 1
            case Fill::FILL_NONE:
838 1
            default:
839 1
                $objWriter->writeAttribute('draw:fill', 'none');
840 12
                $objWriter->writeAttribute('draw:fill-color', '#'.$shape->getFill()->getStartColor()->getRGB());
841 12
                break;
842 12
        }
843 12
        // Border
844 12
        if ($shape->getBorder()->getLineStyle() == Border::LINE_NONE) {
845 14
            $objWriter->writeAttribute('draw:stroke', 'none');
846
        } else {
847 14
            $objWriter->writeAttribute('svg:stroke-color', '#'.$shape->getBorder()->getColor()->getRGB());
848 13
            $objWriter->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($shape->getBorder()->getLineWidth()), 3, '.', '').'cm');
849 13
            switch ($shape->getBorder()->getDashStyle()) {
850 2
                case Border::DASH_SOLID:
851 2
                    $objWriter->writeAttribute('draw:stroke', 'solid');
852 2
                    break;
853 2
                case Border::DASH_DASH:
854 1
                case Border::DASH_DASHDOT:
855 1
                case Border::DASH_DOT:
856 2
                case Border::DASH_LARGEDASH:
857 2
                case Border::DASH_LARGEDASHDOT:
858 2
                case Border::DASH_LARGEDASHDOTDOT:
859 2
                case Border::DASH_SYSDASH:
860 2
                case Border::DASH_SYSDASHDOT:
861 2
                case Border::DASH_SYSDASHDOTDOT:
862 2
                case Border::DASH_SYSDOT:
863 2
                    $objWriter->writeAttribute('draw:stroke', 'dash');
864 2
                    $objWriter->writeAttribute('draw:stroke-dash', 'strokeDash_'.$shape->getBorder()->getDashStyle());
865 2
                    break;
866 2
                default:
867 2
                    $objWriter->writeAttribute('draw:stroke', 'none');
868 2
                    break;
869
            }
870
        }
871
872 2
        $objWriter->writeAttribute('fo:wrap-option', 'wrap');
873
        // > style:graphic-properties
874
        $objWriter->endElement();
875 14
        // > style:style
876
        $objWriter->endElement();
877 14
878
        $paragraphs  = $shape->getParagraphs();
879 14
        $paragraphId = 0;
880
        foreach ($paragraphs as $paragraph) {
881 14
            ++$paragraphId;
882 14
883 14
            // Style des paragraphes
884 14
            if (!isset($this->arrStyleParagraph[$paragraph->getHashCode()])) {
885
                $this->arrStyleParagraph[$paragraph->getHashCode()] = $paragraph;
886
            }
887 14
888 14
            // Style des listes
889 14
            if (!isset($this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()])) {
890
                $this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['oStyle'] = $paragraph->getBulletStyle();
891
                $this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level']  = '';
892 14
            }
893 14
            if (strpos($this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level'], ';' . $paragraph->getAlignment()->getLevel()) === false) {
894 14
                $this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['level'] .= ';' . $paragraph->getAlignment()->getLevel();
895 14
                $this->arrStyleBullet[$paragraph->getBulletStyle()->getHashCode()]['oAlign_' . $paragraph->getAlignment()->getLevel()] = $paragraph->getAlignment();
896 14
            }
897 14
898 14
            $richtexts  = $paragraph->getRichTextElements();
899 14
            $richtextId = 0;
900
            foreach ($richtexts as $richtext) {
901 14
                ++$richtextId;
902 14
                // Not a line break
903 14
                if ($richtext instanceof Run) {
904 8
                    // Style des font text
905
                    if (!isset($this->arrStyleTextFont[$richtext->getHashCode()])) {
906 8
                        $this->arrStyleTextFont[$richtext->getHashCode()] = $richtext;
907
                    }
908 8
                }
909 8
            }
910 8
        }
911 8
    }
912 14
913 14
    /**
914 14
     * Write the default style information for an AbstractDrawing
915
     *
916
     * @param \PhpOffice\Common\XMLWriter $objWriter
917
     * @param \PhpOffice\PhpPresentation\Shape\AbstractDrawing $shape
918
     */
919
    public function writeDrawingStyle(XMLWriter $objWriter, AbstractDrawing $shape)
920
    {
921
        // style:style
922 36
        $objWriter->startElement('style:style');
923
        $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId);
924
        $objWriter->writeAttribute('style:family', 'graphic');
925 36
        $objWriter->writeAttribute('style:parent-style-name', 'standard');
926 36
927 36
        // style:graphic-properties
928 36
        $objWriter->startElement('style:graphic-properties');
929
        $objWriter->writeAttribute('draw:stroke', 'none');
930
        $objWriter->writeAttribute('draw:fill', 'none');
931 36
        if ($shape->getShadow()->isVisible()) {
932 36
            $this->writeStylePartShadow($objWriter, $shape->getShadow());
933 36
        }
934 36
        $objWriter->endElement();
935
936
        $objWriter->endElement();
937 36
    }
938
939 36
    /**
940 36
     * Write the default style information for a Line shape.
941
     *
942
     * @param XMLWriter $objWriter
943
     * @param Line $shape
944
     */
945
    public function writeLineStyle(XMLWriter $objWriter, Line $shape)
946
    {
947
        // style:style
948 1
        $objWriter->startElement('style:style');
949
        $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId);
950
        $objWriter->writeAttribute('style:family', 'graphic');
951 1
        $objWriter->writeAttribute('style:parent-style-name', 'standard');
952 1
953 1
        // style:graphic-properties
954 1
        $objWriter->startElement('style:graphic-properties');
955
        $objWriter->writeAttribute('draw:fill', 'none');
956
        switch ($shape->getBorder()->getLineStyle()) {
957 1
            case Border::LINE_NONE:
958 1
                $objWriter->writeAttribute('draw:stroke', 'none');
959 1
                break;
960 1
            case Border::LINE_SINGLE:
961
                $objWriter->writeAttribute('draw:stroke', 'solid');
962
                break;
963 1
            default:
964 1
                $objWriter->writeAttribute('draw:stroke', 'none');
965 1
                break;
966
        }
967
        $objWriter->writeAttribute('svg:stroke-color', '#'.$shape->getBorder()->getColor()->getRGB());
968
        $objWriter->writeAttribute('svg:stroke-width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((CommonDrawing::pointsToPixels($shape->getBorder()->getLineWidth()))), 3).'cm');
969 1
        $objWriter->endElement();
970 1
971 1
        $objWriter->endElement();
972 1
    }
973
974 1
    /**
975 1
     * Write the default style information for a Table shape
976
     *
977
     * @param XMLWriter $objWriter
978
     * @param Table $shape
979
     */
980
    public function writeTableStyle(XMLWriter $objWriter, Table $shape)
981
    {
982
        foreach ($shape->getRows() as $keyRow => $shapeRow) {
983 7
            // style:style
984
            $objWriter->startElement('style:style');
985 7
            $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId.'r'.$keyRow);
986
            $objWriter->writeAttribute('style:family', 'table-row');
987 6
988 6
            // style:table-row-properties
989 6
            $objWriter->startElement('style:table-row-properties');
990
            $objWriter->writeAttribute('style:row-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::pointsToPixels($shapeRow->getHeight())), 3).'cm');
991
            $objWriter->endElement();
992 6
993 6
            $objWriter->endElement();
994 6
995
            foreach ($shapeRow->getCells() as $keyCell => $shapeCell) {
996 6
                // style:style
997
                $objWriter->startElement('style:style');
998 6
                $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId.'r'.$keyRow.'c'.$keyCell);
999
                $objWriter->writeAttribute('style:family', 'table-cell');
1000 6
1001 6
                // style:graphic-properties
1002 6
                $objWriter->startElement('style:graphic-properties');
1003
                if ($shapeCell->getFill()->getFillType() == Fill::FILL_SOLID) {
1004
                    $objWriter->writeAttribute('draw:fill', 'solid');
1005 6
                    $objWriter->writeAttribute('draw:fill-color', '#'.$shapeCell->getFill()->getStartColor()->getRGB());
1006 6
                }
1007 1
                if ($shapeCell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR) {
1008 1
                    $objWriter->writeAttribute('draw:fill', 'gradient');
1009 1
                    $objWriter->writeAttribute('draw:fill-gradient-name', 'gradient_'.$shapeCell->getFill()->getHashCode());
1010 6
                }
1011 1
                $objWriter->endElement();
1012 1
                // <style:graphic-properties
1013 1
1014 6
                // style:paragraph-properties
1015
                $objWriter->startElement('style:paragraph-properties');
1016
                if ($shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getTop()->getHashCode()
1017
                    && $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getLeft()->getHashCode()
1018 6
                    && $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getRight()->getHashCode()) {
1019 6
                    $lineStyle = 'none';
1020 6
                    $lineWidth = Text::numberFormat($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
1021 6
                    $lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
1022 6
                    switch ($shapeCell->getBorders()->getBottom()->getLineStyle()) {
1023 6
                        case Border::LINE_SINGLE:
1024 6
                            $lineStyle = 'solid';
1025 6
                    }
1026 6
                    $objWriter->writeAttribute('fo:border', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
1027 6
                } else {
1028 6
                    $lineStyle = 'none';
1029 6
                    $lineWidth = Text::numberFormat($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
1030 6
                    $lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
1031
                    switch ($shapeCell->getBorders()->getBottom()->getLineStyle()) {
1032
                        case Border::LINE_SINGLE:
1033
                            $lineStyle = 'solid';
1034
                    }
1035
                    $objWriter->writeAttribute('fo:border-bottom', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
1036
                    // TOP
1037
                    $lineStyle = 'none';
1038
                    $lineWidth = Text::numberFormat($shapeCell->getBorders()->getTop()->getLineWidth() / 1.75, 2);
1039
                    $lineColor = $shapeCell->getBorders()->getTop()->getColor()->getRGB();
1040
                    switch ($shapeCell->getBorders()->getTop()->getLineStyle()) {
1041
                        case Border::LINE_SINGLE:
1042
                            $lineStyle = 'solid';
1043
                    }
1044
                    $objWriter->writeAttribute('fo:border-top', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
1045
                    // RIGHT
1046
                    $lineStyle = 'none';
1047
                    $lineWidth = Text::numberFormat($shapeCell->getBorders()->getRight()->getLineWidth() / 1.75, 2);
1048
                    $lineColor = $shapeCell->getBorders()->getRight()->getColor()->getRGB();
1049
                    switch ($shapeCell->getBorders()->getRight()->getLineStyle()) {
1050
                        case Border::LINE_SINGLE:
1051
                            $lineStyle = 'solid';
1052
                    }
1053
                    $objWriter->writeAttribute('fo:border-right', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
1054
                    // LEFT
1055
                    $lineStyle = 'none';
1056
                    $lineWidth = Text::numberFormat($shapeCell->getBorders()->getLeft()->getLineWidth() / 1.75, 2);
1057
                    $lineColor = $shapeCell->getBorders()->getLeft()->getColor()->getRGB();
1058
                    switch ($shapeCell->getBorders()->getLeft()->getLineStyle()) {
1059
                        case Border::LINE_SINGLE:
1060
                            $lineStyle = 'solid';
1061
                    }
1062
                    $objWriter->writeAttribute('fo:border-left', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
1063
                }
1064
                $objWriter->endElement();
1065
1066
                $objWriter->endElement();
1067 6
1068
                foreach ($shapeCell->getParagraphs() as $shapeParagraph) {
1069 6
                    foreach ($shapeParagraph->getRichTextElements() as $shapeRichText) {
1070
                        if ($shapeRichText instanceof Run) {
1071 6
                            // Style des font text
1072 6
                            if (!isset($this->arrStyleTextFont[$shapeRichText->getHashCode()])) {
1073 2
                                $this->arrStyleTextFont[$shapeRichText->getHashCode()] = $shapeRichText;
1074
                            }
1075 2
                        }
1076 2
                    }
1077 2
                }
1078 2
            }
1079 6
        }
1080 6
    }
1081 6
1082 7
    /**
1083 7
     * Write the slide note
1084
     * @param XMLWriter $objWriter
1085
     * @param \PhpOffice\PhpPresentation\Slide\Note $note
1086
     */
1087
    public function writeSlideNote(XMLWriter $objWriter, Note $note)
1088
    {
1089
        $shapesNote = $note->getShapeCollection();
1090 59
        if (count($shapesNote) > 0) {
1091
            $objWriter->startElement('presentation:notes');
1092 59
1093 59
            foreach ($shapesNote as $shape) {
1094 1
                // Increment $this->shapeId
1095
                ++$this->shapeId;
1096 1
1097
                if ($shape instanceof RichText) {
1098 1
                    $this->writeShapeTxt($objWriter, $shape);
1099
                }
1100 1
            }
1101 1
1102 1
            $objWriter->endElement();
1103 1
        }
1104
    }
1105 1
1106 1
    /**
1107 59
     * Write style of a slide
1108
     * @param XMLWriter $objWriter
1109
     * @param Slide $slide
1110
     * @param int $incPage
1111
     */
1112
    public function writeStyleSlide(XMLWriter $objWriter, Slide $slide, $incPage)
1113
    {
1114
        // style:style
1115 59
        $objWriter->startElement('style:style');
1116
        $objWriter->writeAttribute('style:family', 'drawing-page');
1117
        $objWriter->writeAttribute('style:name', 'stylePage'.$incPage);
1118 59
        // style:style/style:drawing-page-properties
1119 59
        $objWriter->startElement('style:drawing-page-properties');
1120 59
        $objWriter->writeAttributeIf(!$slide->isVisible(), 'presentation:visibility', 'hidden');
1121
        if (!is_null($oTransition = $slide->getTransition())) {
1122 59
            $objWriter->writeAttribute('presentation:duration', 'PT'.number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '').'S');
1123 59
            if ($oTransition->hasManualTrigger()) {
1124 59
                $objWriter->writeAttribute('presentation:transition-type', 'manual');
1125 1
            } elseif ($oTransition->hasTimeTrigger()) {
1126 1
                $objWriter->writeAttribute('presentation:transition-type', 'automatic');
1127 1
            }
1128 1
            switch ($oTransition->getSpeed()) {
1129 1
                case Transition::SPEED_FAST:
1130 1
                    $objWriter->writeAttribute('presentation:transition-speed', 'fast');
1131 1
                    break;
1132 1
                case Transition::SPEED_MEDIUM:
1133 1
                    $objWriter->writeAttribute('presentation:transition-speed', 'medium');
1134 1
                    break;
1135 1
                case Transition::SPEED_SLOW:
1136 1
                    $objWriter->writeAttribute('presentation:transition-speed', 'slow');
1137 1
                    break;
1138 1
            }
1139 1
1140 1
            /**
1141 1
             * http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#property-presentation_transition-style
1142
             */
1143
            switch ($oTransition->getTransitionType()) {
1144
                case Transition::TRANSITION_BLINDS_HORIZONTAL:
1145
                    $objWriter->writeAttribute('presentation:transition-style', 'horizontal-stripes');
1146 1
                    break;
1147 1
                case Transition::TRANSITION_BLINDS_VERTICAL:
1148 1
                    $objWriter->writeAttribute('presentation:transition-style', 'vertical-stripes');
1149 1
                    break;
1150 1
                case Transition::TRANSITION_CHECKER_HORIZONTAL:
1151 1
                    $objWriter->writeAttribute('presentation:transition-style', 'horizontal-checkerboard');
1152 1
                    break;
1153 1
                case Transition::TRANSITION_CHECKER_VERTICAL:
1154 1
                    $objWriter->writeAttribute('presentation:transition-style', 'vertical-checkerboard');
1155 1
                    break;
1156 1
                case Transition::TRANSITION_CIRCLE_HORIZONTAL:
1157 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1158 1
                    break;
1159 1
                case Transition::TRANSITION_CIRCLE_VERTICAL:
1160 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1161 1
                    break;
1162 1
                case Transition::TRANSITION_COMB_HORIZONTAL:
1163 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1164 1
                    break;
1165 1
                case Transition::TRANSITION_COMB_VERTICAL:
1166 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1167 1
                    break;
1168 1
                case Transition::TRANSITION_COVER_DOWN:
1169 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-bottom');
1170 1
                    break;
1171 1
                case Transition::TRANSITION_COVER_LEFT:
1172 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-left');
1173 1
                    break;
1174 1
                case Transition::TRANSITION_COVER_LEFT_DOWN:
1175 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerleft');
1176 1
                    break;
1177 1
                case Transition::TRANSITION_COVER_LEFT_UP:
1178 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperleft');
1179 1
                    break;
1180 1
                case Transition::TRANSITION_COVER_RIGHT:
1181 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-right');
1182 1
                    break;
1183 1
                case Transition::TRANSITION_COVER_RIGHT_DOWN:
1184 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerright');
1185 1
                    break;
1186 1
                case Transition::TRANSITION_COVER_RIGHT_UP:
1187 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperright');
1188 1
                    break;
1189 1
                case Transition::TRANSITION_COVER_UP:
1190 1
                    $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-top');
1191 1
                    break;
1192 1
                case Transition::TRANSITION_CUT:
1193 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1194 1
                    break;
1195 1
                case Transition::TRANSITION_DIAMOND:
1196 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1197 1
                    break;
1198 1
                case Transition::TRANSITION_DISSOLVE:
1199 1
                    $objWriter->writeAttribute('presentation:transition-style', 'dissolve');
1200 1
                    break;
1201 1
                case Transition::TRANSITION_FADE:
1202 1
                    $objWriter->writeAttribute('presentation:transition-style', 'fade-from-center');
1203 1
                    break;
1204 1
                case Transition::TRANSITION_NEWSFLASH:
1205 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1206 1
                    break;
1207 1
                case Transition::TRANSITION_PLUS:
1208 1
                    $objWriter->writeAttribute('presentation:transition-style', 'close');
1209 1
                    break;
1210 1
                case Transition::TRANSITION_PULL_DOWN:
1211 1
                    $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-bottom');
1212 1
                    break;
1213 1
                case Transition::TRANSITION_PULL_LEFT:
1214 1
                    $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-left');
1215 1
                    break;
1216 1
                case Transition::TRANSITION_PULL_RIGHT:
1217 1
                    $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-right');
1218 1
                    break;
1219 1
                case Transition::TRANSITION_PULL_UP:
1220 1
                    $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-top');
1221 1
                    break;
1222 1
                case Transition::TRANSITION_PUSH_DOWN:
1223 1
                    $objWriter->writeAttribute('presentation:transition-style', 'roll-from-bottom');
1224 1
                    break;
1225 1
                case Transition::TRANSITION_PUSH_LEFT:
1226 1
                    $objWriter->writeAttribute('presentation:transition-style', 'roll-from-left');
1227 1
                    break;
1228 1
                case Transition::TRANSITION_PUSH_RIGHT:
1229 1
                    $objWriter->writeAttribute('presentation:transition-style', 'roll-from-right');
1230 1
                    break;
1231 1
                case Transition::TRANSITION_PUSH_UP:
1232 1
                    $objWriter->writeAttribute('presentation:transition-style', 'roll-from-top');
1233 1
                    break;
1234 1
                case Transition::TRANSITION_RANDOM:
1235 1
                    $objWriter->writeAttribute('presentation:transition-style', 'random');
1236 1
                    break;
1237 1
                case Transition::TRANSITION_RANDOMBAR_HORIZONTAL:
1238 1
                    $objWriter->writeAttribute('presentation:transition-style', 'horizontal-lines');
1239 1
                    break;
1240 1
                case Transition::TRANSITION_RANDOMBAR_VERTICAL:
1241 1
                    $objWriter->writeAttribute('presentation:transition-style', 'vertical-lines');
1242 1
                    break;
1243 1
                case Transition::TRANSITION_SPLIT_IN_HORIZONTAL:
1244 1
                    $objWriter->writeAttribute('presentation:transition-style', 'close-horizontal');
1245 1
                    break;
1246 1
                case Transition::TRANSITION_SPLIT_OUT_HORIZONTAL:
1247 1
                    $objWriter->writeAttribute('presentation:transition-style', 'open-horizontal');
1248 1
                    break;
1249 1
                case Transition::TRANSITION_SPLIT_IN_VERTICAL:
1250 1
                    $objWriter->writeAttribute('presentation:transition-style', 'close-vertical');
1251 1
                    break;
1252 1
                case Transition::TRANSITION_SPLIT_OUT_VERTICAL:
1253 1
                    $objWriter->writeAttribute('presentation:transition-style', 'open-vertical');
1254 1
                    break;
1255 1
                case Transition::TRANSITION_STRIPS_LEFT_DOWN:
1256 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1257 1
                    break;
1258 1
                case Transition::TRANSITION_STRIPS_LEFT_UP:
1259 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1260 1
                    break;
1261 1
                case Transition::TRANSITION_STRIPS_RIGHT_DOWN:
1262 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1263 1
                    break;
1264 1
                case Transition::TRANSITION_STRIPS_RIGHT_UP:
1265 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1266 1
                    break;
1267 1
                case Transition::TRANSITION_WEDGE:
1268 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1269 1
                    break;
1270 1
                case Transition::TRANSITION_WIPE_DOWN:
1271 1
                    $objWriter->writeAttribute('presentation:transition-style', 'fade-from-bottom');
1272 1
                    break;
1273 1
                case Transition::TRANSITION_WIPE_LEFT:
1274 1
                    $objWriter->writeAttribute('presentation:transition-style', 'fade-from-left');
1275 1
                    break;
1276 1
                case Transition::TRANSITION_WIPE_RIGHT:
1277 1
                    $objWriter->writeAttribute('presentation:transition-style', 'fade-from-right');
1278 1
                    break;
1279 1
                case Transition::TRANSITION_WIPE_UP:
1280 1
                    $objWriter->writeAttribute('presentation:transition-style', 'fade-from-top');
1281 1
                    break;
1282 1
                case Transition::TRANSITION_ZOOM_IN:
1283 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1284 1
                    break;
1285 1
                case Transition::TRANSITION_ZOOM_OUT:
1286 1
                    $objWriter->writeAttribute('presentation:transition-style', 'none');
1287 1
                    break;
1288 1
            }
1289 1
        }
1290 1
        $oBackground = $slide->getBackground();
1291 1
        if ($oBackground instanceof Slide\AbstractBackground) {
1292 1
            $objWriter->writeAttribute('presentation:background-visible', 'true');
1293 59
            if ($oBackground instanceof Slide\Background\Color) {
1294 59
                $objWriter->writeAttribute('draw:fill', 'solid');
1295 1
                $objWriter->writeAttribute('draw:fill-color', '#' . $oBackground->getColor()->getRGB());
1296 1
            }
1297
            if ($oBackground instanceof Slide\Background\Image) {
1298
                $objWriter->writeAttribute('draw:fill', 'bitmap');
1299
                $objWriter->writeAttribute('draw:fill-image-name', 'background_'.$incPage);
1300 1
                $objWriter->writeAttribute('style:repeat', 'stretch');
1301 1
            }
1302 1
        }
1303 1
        $objWriter->endElement();
1304 1
        // > style:style
1305 1
        $objWriter->endElement();
1306 59
    }
1307
1308 59
1309 59
    /**
1310
     * @param XMLWriter $objWriter
1311
     * @param Shadow $oShadow
1312
     * @todo Improve for supporting any direction (https://sinepost.wordpress.com/2012/02/16/theyve-got-atan-you-want-atan2/)
1313
     */
1314
    protected function writeStylePartShadow(XMLWriter $objWriter, Shadow $oShadow)
1315
    {
1316
        $objWriter->writeAttribute('draw:shadow', 'visible');
1317 1
        $objWriter->writeAttribute('draw:shadow-color', '#' . $oShadow->getColor()->getRGB());
1318
        if ($oShadow->getDirection() == 0 || $oShadow->getDirection() == 360) {
1319 1
            $objWriter->writeAttribute('draw:shadow-offset-x', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1320 1
            $objWriter->writeAttribute('draw:shadow-offset-y', '0cm');
1321 1
        } elseif ($oShadow->getDirection() == 45) {
1322 1
            $objWriter->writeAttribute('draw:shadow-offset-x', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1323 1
            $objWriter->writeAttribute('draw:shadow-offset-y', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1324 1
        } elseif ($oShadow->getDirection() == 90) {
1325 1
            $objWriter->writeAttribute('draw:shadow-offset-x', '0cm');
1326 1
            $objWriter->writeAttribute('draw:shadow-offset-y', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1327 1
        } elseif ($oShadow->getDirection() == 135) {
1328 1
            $objWriter->writeAttribute('draw:shadow-offset-x', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1329 1
            $objWriter->writeAttribute('draw:shadow-offset-y', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1330 1
        } elseif ($oShadow->getDirection() == 180) {
1331 1
            $objWriter->writeAttribute('draw:shadow-offset-x', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1332 1
            $objWriter->writeAttribute('draw:shadow-offset-y', '0cm');
1333 1
        } elseif ($oShadow->getDirection() == 225) {
1334 1
            $objWriter->writeAttribute('draw:shadow-offset-x', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1335 1
            $objWriter->writeAttribute('draw:shadow-offset-y', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1336 1
        } elseif ($oShadow->getDirection() == 270) {
1337 1
            $objWriter->writeAttribute('draw:shadow-offset-x', '0cm');
1338 1
            $objWriter->writeAttribute('draw:shadow-offset-y', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1339 1
        } elseif ($oShadow->getDirection() == 315) {
1340 1
            $objWriter->writeAttribute('draw:shadow-offset-x', CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1341 1
            $objWriter->writeAttribute('draw:shadow-offset-y', '-' . CommonDrawing::pixelsToCentimeters($oShadow->getDistance()) . 'cm');
1342 1
        }
1343 1
        $objWriter->writeAttribute('draw:shadow-opacity', (100 - $oShadow->getAlpha()) . '%');
1344 1
        $objWriter->writeAttribute('style:mirror', 'none');
1345 1
1346 1
    }
1347
}
1348