Completed
Pull Request — develop (#230)
by Franck
07:45
created

PowerPoint2007::loadSlideBG()   C

Complexity

Conditions 7
Paths 10

Size

Total Lines 42
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
ccs 0
cts 31
cp 0
rs 6.7272
cc 7
eloc 25
nc 10
nop 3
crap 56
1
<?php
2
/**
3
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4
 * presentations documents.
5
 *
6
 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7
 * General Public License version 3 as published by the Free Software Foundation.
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code. For the full list of
11
 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12
 *
13
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
18
namespace PhpOffice\PhpPresentation\Reader;
19
20
/** This file will be edited to also read slideLayout things */
21
22
use PhpOffice\PhpPresentation\Slide\AbstractSlide;
23
use PhpOffice\PhpPresentation\Shape\Placeholder;
24
use PhpOffice\PhpPresentation\Slide\Background\Image;
25
use PhpOffice\PhpPresentation\Slide\SlideMaster;
26
use PhpOffice\PhpPresentation\Shape\Drawing\Gd;
27
use ZipArchive;
28
use PhpOffice\Common\XMLReader;
29
use PhpOffice\Common\Drawing as CommonDrawing;
30
use PhpOffice\PhpPresentation\PhpPresentation;
31
use PhpOffice\PhpPresentation\Style\Bullet;
32
use PhpOffice\PhpPresentation\Style\Color;
33
use PhpOffice\PhpPresentation\Writer\PowerPoint2007\LayoutPack\TemplateBased;
34
35
/**
36
 * Serialized format reader
37
 */
38
class PowerPoint2007 implements ReaderInterface
39
{
40
    /**
41
     * Output Object
42
     * @var PhpPresentation
43
     */
44
    protected $oPhpPresentation;
45
    /**
46
     * Output Object
47
     * @var \ZipArchive
48
     */
49
    protected $oZip;
50
    /**
51
     * @var string[]
52
     */
53
    protected $arrayRels = array();
54
    /*
55
     * @var string
56
     */
57
    protected $filename;
58
59
    /**
60
     * Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
61
     *
62
     * @param  string $pFilename
63
     * @throws \Exception
64
     * @return boolean
65
     */
66 2
    public function canRead($pFilename)
67
    {
68 2
        return $this->fileSupportsUnserializePhpPresentation($pFilename);
69
    }
70
71
    /**
72
     * Does a file support UnserializePhpPresentation ?
73
     *
74
     * @param  string $pFilename
75
     * @throws \Exception
76
     * @return boolean
77
     */
78 8
    public function fileSupportsUnserializePhpPresentation($pFilename = '')
79
    {
80
        // Check if file exists
81 8
        if (!file_exists($pFilename)) {
82 2
            throw new \Exception("Could not open " . $pFilename . " for reading! File does not exist.");
83
        }
84
85 6
        $oZip = new ZipArchive();
86
        // Is it a zip ?
87 6
        if ($oZip->open($pFilename) === true) {
88
            // Is it an OpenXML Document ?
89
            // Is it a Presentation ?
90 4
            if (is_array($oZip->statName('[Content_Types].xml')) && is_array($oZip->statName('ppt/presentation.xml'))) {
91 4
                return true;
92
            }
93 1
        }
94 3
        return false;
95
    }
96
97
    /**
98
     * Loads PhpPresentation Serialized file
99
     *
100
     * @param  string $pFilename
101
     * @return \PhpOffice\PhpPresentation\PhpPresentation
102
     * @throws \Exception
103
     */
104 5
    public function load($pFilename)
105
    {
106
        // Unserialize... First make sure the file supports it!
107 5
        if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
108 1
            throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\PowerPoint2007: " . $pFilename . ".");
109
        }
110
111 3
        return $this->loadFile($pFilename);
112
    }
113
114
    /**
115
     * Load PhpPresentation Serialized file
116
     *
117
     * @param  string $pFilename
118
     * @return \PhpOffice\PhpPresentation\PhpPresentation
119
     */
120 3
    protected function loadFile($pFilename)
121
    {
122 3
        $this->oPhpPresentation = new PhpPresentation();
123 3
        $this->oPhpPresentation->removeSlideByIndex();
124 3
        $this->filename = $pFilename;
125
126 3
        $this->oZip = new ZipArchive();
127 3
        $this->oZip->open($this->filename);
128 3
        $docPropsCore = $this->oZip->getFromName('docProps/core.xml');
129 3
        if ($docPropsCore !== false) {
130 3
            $this->loadDocumentProperties($docPropsCore);
131 3
        }
132
133 3
        $docPropsCustom = $this->oZip->getFromName('docProps/custom.xml');
134 3
        if ($docPropsCustom !== false) {
135 1
            $this->loadCustomProperties($docPropsCustom);
136 1
        }
137
138 3
        $pptViewProps = $this->oZip->getFromName('ppt/viewProps.xml');
139 3
        if ($pptViewProps !== false) {
140 3
            $this->loadViewProperties($pptViewProps);
141 3
        }
142
143 3
        $pptPresentation = $this->oZip->getFromName('ppt/presentation.xml');
144 3
        if ($pptPresentation !== false) {
145 3
            $this->loadSlides($pptPresentation);
146 3
        }
147
148 3
        return $this->oPhpPresentation;
149
    }
150
151
    /**
152
     * Read Document Properties
153
     * @param string $sPart
154
     */
155 3
    protected function loadDocumentProperties($sPart)
156
    {
157 3
        $xmlReader = new XMLReader();
158 3
        if ($xmlReader->getDomFromString($sPart)) {
159
            $arrayProperties = array(
160 3
                '/cp:coreProperties/dc:creator' => 'setCreator',
161 3
                '/cp:coreProperties/cp:lastModifiedBy' => 'setLastModifiedBy',
162 3
                '/cp:coreProperties/dc:title' => 'setTitle',
163 3
                '/cp:coreProperties/dc:description' => 'setDescription',
164 3
                '/cp:coreProperties/dc:subject' => 'setSubject',
165 3
                '/cp:coreProperties/cp:keywords' => 'setKeywords',
166 3
                '/cp:coreProperties/cp:category' => 'setCategory',
167 3
                '/cp:coreProperties/dcterms:created' => 'setCreated',
168 3
                '/cp:coreProperties/dcterms:modified' => 'setModified',
169 3
            );
170 3
            $oProperties = $this->oPhpPresentation->getProperties();
0 ignored issues
show
Deprecated Code introduced by
The method PhpOffice\PhpPresentatio...tation::getProperties() has been deprecated with message: for getDocumentProperties

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
171 3
            foreach ($arrayProperties as $path => $property) {
172 3
                if (is_object($oElement = $xmlReader->getElement($path))) {
173 3
                    if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
174 3
                        $oDateTime = new \DateTime();
175 3
                        $oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
176 3
                        $oProperties->{$property}($oDateTime->getTimestamp());
177 3
                    } else {
178 3
                        $oProperties->{$property}($oElement->nodeValue);
179
                    }
180 3
                }
181 3
            }
182 3
        }
183 3
    }
184
185
    /**
186
     * Read Custom Properties
187
     * @param string $sPart
188
     */
189 1
    protected function loadCustomProperties($sPart)
190
    {
191 1
        $xmlReader = new XMLReader();
192 1
        $sPart = str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
193 1
        if ($xmlReader->getDomFromString($sPart)) {
194 1
            $pathMarkAsFinal = '/Properties/property[@pid="2"][@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"][@name="_MarkAsFinal"]/vt:bool';
195 1
            if (is_object($oElement = $xmlReader->getElement($pathMarkAsFinal))) {
196 1
                if ($oElement->nodeValue == 'true') {
197 1
                    $this->oPhpPresentation->markAsFinal(true);
0 ignored issues
show
Deprecated Code introduced by
The method PhpOffice\PhpPresentatio...entation::markAsFinal() has been deprecated with message: for getPresentationProperties()->markAsFinal()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
198 1
                }
199 1
            }
200 1
        }
201 1
    }
202
203
    /**
204
     * Read View Properties
205
     * @param string $sPart
206
     */
207 3
    protected function loadViewProperties($sPart)
208
    {
209 3
        $xmlReader = new XMLReader();
210 3
        if ($xmlReader->getDomFromString($sPart)) {
211 3
            $pathZoom = '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx';
212 3
            if (is_object($oElement = $xmlReader->getElement($pathZoom))) {
213 2
                if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
214 2
                    $this->oPhpPresentation->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d'));
0 ignored issues
show
Deprecated Code introduced by
The method PhpOffice\PhpPresentatio...Presentation::setZoom() has been deprecated with message: for getPresentationProperties()->setZoom()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
215 2
                }
216 2
            }
217 3
        }
218 3
    }
219
220
    /**
221
     * Extract all slides
222
     */
223 3
    protected function loadSlides($sPart)
224
    {
225 3
        $xmlReader = new XMLReader();
226 3
        if ($xmlReader->getDomFromString($sPart)) {
227 3
            $fileRels = 'ppt/_rels/presentation.xml.rels';
228 3
            $this->loadRels($fileRels);
229
            // Load the Masterslides
230 3
            $this->loadMasterSlides($xmlReader, $fileRels);
231
            // Continue with loading the slides
232 3
            foreach ($xmlReader->getElements('/p:presentation/p:sldIdLst/p:sldId') as $oElement) {
233 3
                $rId = $oElement->getAttribute('r:id');
234 3
                $pathSlide = isset($this->arrayRels[$fileRels][$rId]) ? $this->arrayRels[$fileRels][$rId]['Target'] : '';
235 3
                if (!empty($pathSlide)) {
236 3
                    $pptSlide = $this->oZip->getFromName('ppt/' . $pathSlide);
237 3
                    if ($pptSlide !== false) {
238 3
                        $this->loadRels('ppt/slides/_rels/' . basename($pathSlide) . '.rels');
239 3
                        $this->loadSlide($pptSlide, basename($pathSlide));
240 3
                    }
241 3
                }
242 3
            }
243 3
        }
244 3
    }
245
246
    /**
247
     * Extract all MasterSlides
248
     * @param XMLReader $xmlReader
249
     * @param $fileRels
250
     */
251 3
    protected function loadMasterSlides(XMLReader $xmlReader, $fileRels)
252
    {
253
        // Get all the MasterSlide Id's from the presentation.xml file
254 3
        foreach ($xmlReader->getElements('/p:presentation/p:sldMasterIdLst/p:sldMasterId') as $oElement) {
255 3
            $rId = $oElement->getAttribute('r:id');
256
            // Get the path to the masterslide from the array with _rels files
257 3
            $pathMasterSlide = isset($this->arrayRels[$fileRels][$rId]) ?
258 3
                $this->arrayRels[$fileRels][$rId]['Target'] : '';
259 3
            if (!empty($pathMasterSlide)) {
260 3
                $pptMasterSlide = $this->oZip->getFromName('ppt/' . $pathMasterSlide);
261 3
                if ($pptMasterSlide !== false) {
262 3
                    $this->loadRels('ppt/slideMasters/_rels/' . basename($pathMasterSlide) . '.rels');
263 3
                    $this->loadMasterSlide($pptMasterSlide, basename($pathMasterSlide));
264 3
                }
265 3
            }
266 3
        }
267 3
    }
268
269
    /**
270
     * Extract data from slide
271
     * @param string $sPart
272
     * @param string $baseFile
273
     */
274 3
    protected function loadSlide($sPart, $baseFile)
275
    {
276 3
        $xmlReader = new XMLReader();
277 3
        if ($xmlReader->getDomFromString($sPart)) {
278
            // Core
279 3
            $oSlide = $this->oPhpPresentation->createSlide();
280 3
            $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
281 3
            $oSlide->setRelsIndex('ppt/slides/_rels/' . $baseFile . '.rels');
282
283
            // Background
284 3
            $oElement = $xmlReader->getElement('/p:sld/p:cSld/p:bg/p:bgPr');
285 3
            if ($oElement) {
286
                $oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
0 ignored issues
show
Documentation introduced by
$oElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
287
                if ($oElementColor) {
288
                    // Color
289
                    $oColor = new Color();
290
                    $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
291
                    // Background
292
                    $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
293
                    $oBackground->setColor($oColor);
294
                    // Slide Background
295
                    $oSlide = $this->oPhpPresentation->getActiveSlide();
296
                    $oSlide->setBackground($oBackground);
297
                }
298
                $oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement);
0 ignored issues
show
Documentation introduced by
$oElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
299
                if ($oElementImage) {
300
                    $relImg = $this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'][$oElementImage->getAttribute('r:embed')];
301
                    if (is_array($relImg)) {
302
                        // File
303
                        $pathImage = 'ppt/slides/' . $relImg['Target'];
304
                        $pathImage = explode('/', $pathImage);
305
                        foreach ($pathImage as $key => $partPath) {
306
                            if ($partPath == '..') {
307
                                unset($pathImage[$key - 1]);
308
                                unset($pathImage[$key]);
309
                            }
310
                        }
311
                        $pathImage = implode('/', $pathImage);
312
                        $contentImg = $this->oZip->getFromName($pathImage);
313
314
                        $tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
315
                        file_put_contents($tmpBkgImg, $contentImg);
316
                        // Background
317
                        $oBackground = new Image();
318
                        $oBackground->setPath($tmpBkgImg);
319
                        // Slide Background
320
                        $oSlide = $this->oPhpPresentation->getActiveSlide();
321
                        $oSlide->setBackground($oBackground);
322
                    }
323
                }
324
            }
325
326
            // Shapes
327 3
            foreach ($xmlReader->getElements('/p:sld/p:cSld/p:spTree/*') as $oNode) {
328 3
                switch ($oNode->tagName) {
329 3
                    case 'p:pic':
330 3
                        $this->loadShapeDrawing($xmlReader, $oNode, $oSlide);
331 3
                        break;
332 3
                    case 'p:sp':
333 3
                        $this->loadShapeRichText($xmlReader, $oNode, $oSlide);
334 3
                        break;
335 3
                    default:
336
                        //var_export($oNode->tagName);
337 3
                }
338 3
            }
339
            // Layout
340 3
            $oLayoutPack = new TemplateBased($this->filename);
341 3
            $oSlide = $this->oPhpPresentation->getActiveSlide();
342 3
            foreach ($this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'] as $valueRel) {
0 ignored issues
show
Bug introduced by
The expression $this->arrayRels['ppt/sl... . $baseFile . '.rels'] of type string is not traversable.
Loading history...
343 3
                if ($valueRel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout') {
344 3
                    $layoutId = $valueRel['Target'];
345 3
                    $layoutId = str_replace('../slideLayouts/slideLayout', '', $layoutId);
346 3
                    $layoutId = str_replace('.xml', '', $layoutId);
347 3
                    $layoutName = $oLayoutPack->findLayoutName((int)$layoutId, $oSlide->getSlideMasterId());
348 3
                    $oSlide->setSlideLayout($layoutName);
349 3
                    break;
350
                }
351 3
            }
352 3
        }
353 3
    }
354
355 3
    private function loadMasterSlide($sPart, $baseFile)
356
    {
357 3
        $xmlReader = new XMLReader();
358 3
        if ($xmlReader->getDomFromString($sPart)) {
359
            // Core
360 3
            $oSlideMaster = $this->oPhpPresentation->createMasterSlide();
361 3
            $oSlideMaster->setRelsIndex('ppt/slideMasters/_rels/' . $baseFile . '.rels');
362
363
            // Background
364 3
            $oElement = $xmlReader->getElement('/p:sldMaster/p:cSld/p:bg/p:bgPr');
365 3
            if ($oElement) {
366
                $this->loadSlideBG($xmlReader, $oElement, $oSlideMaster);
0 ignored issues
show
Compatibility introduced by
$oElement of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
367
            }
368
369
            // Shapes
370 3
            $oElements = $xmlReader->getElements('/p:sldMaster/p:cSld/p:spTree/*');
371 3
            if ($oElements) {
372 3
                $this->loadSlideShapes($oSlideMaster, $oElements, $xmlReader);
373 3
            }
374
            // Header & Footer
375
376
            // ColorMapping
377 3
            $colorMap = array();
378 3
            $oElement = $xmlReader->getElement('/p:sldMaster/p:clrMap');
379 3
            if ($oElement->hasAttributes()) {
380 3
                foreach ($oElement->attributes as $attr) {
381 3
                    $colorMap[$attr->nodeName] = $attr->nodeValue;
382 3
                }
383 3
                $oSlideMaster->colorMap->setNewMapping($colorMap);
384 3
            }
385
386
            // Load the Layoutslide
387 3
            foreach ($xmlReader->getElements('/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId') as $oElement) {
388 3
                $rId = $oElement->getAttribute('r:id');
389
                // Get the path to the masterslide from the array with _rels files
390 3
                $pathLayoutSlide = isset($this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]) ?
391 3
                    $this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]['Target'] : '';
392 3
                if (!empty($pathLayoutSlide)) {
393 3
                    $pptLayoutSlide = $this->oZip->getFromName('ppt/' . substr($pathLayoutSlide, strrpos($pathLayoutSlide, "../")));
394 3
                    if ($pptLayoutSlide !== false) {
395
                        $this->loadRels('ppt/slideLayouts/_rels/' . basename($pathLayoutSlide) . '.rels');
396
                        $oSlideMaster->addSlideLayout(
397
                            $this->loadLayoutSlide($pptLayoutSlide, basename($pathLayoutSlide), $oSlideMaster)
398
                        );
399
                    }
400 3
                }
401 3
            }
402 3
        }
403 3
    }
404
405
    private function loadLayoutSlide($sPart, $baseFile, SlideMaster $oSlideMaster)
406
    {
407
        $xmlReader = new XMLReader();
408
        if ($xmlReader->getDomFromString($sPart)) {
409
            // Core
410
            $oSlideLayout = $oSlideMaster->createSlideLayout($oSlideMaster);
0 ignored issues
show
Unused Code introduced by
The call to SlideMaster::createSlideLayout() has too many arguments starting with $oSlideMaster.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
411
            $oSlideLayout->setRelsIndex('ppt/slideLayouts/_rels/' . $baseFile . '.rels');
412
413
            // Background
414
            $oElement = $xmlReader->getElement('/p:sldLayout/p:cSld/p:bg/p:bgPr');
415
            if ($oElement) {
416
                $this->loadSlideBG($xmlReader, $oElement, $oSlideLayout);
0 ignored issues
show
Compatibility introduced by
$oElement of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
417
            }
418
419
            // Shapes
420
            $oElements = $xmlReader->getElements('/p:sldLayout/p:cSld/p:spTree/*');
421
            if ($oElements) {
422
                $this->loadSlideShapes($oSlideLayout, $oElements, $xmlReader);
423
            }
424
            return $oSlideLayout;
425
        }
426
        return null;
427
    }
428
429
    /**
430
     * @param XMLReader $xmlReader
431
     * @param \DOMElement $oElement
432
     * @param AbstractSlide $oSlide
433
     */
434
    private function loadSlideBG(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide)
435
    {
436
        // Background color
437
        $oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
438
        if ($oElementColor) {
439
            // Color
440
            $oColor = new Color();
441
            $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
442
            // Background
443
            $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
444
            $oBackground->setColor($oColor);
445
            // Slide Background
446
            $oSlide->setBackground($oBackground);
447
        }
448
449
        // Background image
450
        $oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement);
451
        if ($oElementImage) {
452
            $relImg = $this->arrayRels[$oSlide->getRelsIndex()][$oElementImage->getAttribute('r:embed')];
453
            if (is_array($relImg)) {
454
                // File
455
                $pathImage = 'ppt/slides/' . $relImg['Target'];
456
                $pathImage = explode('/', $pathImage);
457
                foreach ($pathImage as $key => $partPath) {
458
                    if ($partPath == '..') {
459
                        unset($pathImage[$key - 1]);
460
                        unset($pathImage[$key]);
461
                    }
462
                }
463
                $pathImage = implode('/', $pathImage);
464
                $contentImg = $this->oZip->getFromName($pathImage);
465
466
                $tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
467
                file_put_contents($tmpBkgImg, $contentImg);
468
                // Background
469
                $oBackground = new Image();
470
                $oBackground->setPath($tmpBkgImg);
471
                // Slide Background
472
                $oSlide->setBackground($oBackground);
473
            }
474
        }
475
    }
476
477
    /**
478
     *
479
     * @param XMLReader $document
480
     * @param \DOMElement $node
481
     * @param AbstractSlide $oSlide
482
     */
483 3
    protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide)
484
    {
485
        // Core
486 3
        $oShape = new Gd();
487 3
        $oShape->getShadow()->setVisible(false);
488
        // Variables
489 3
        $fileRels = $oSlide->getRelsIndex();
490
491 3
        $oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node);
492 3
        if ($oElement) {
493 3
            $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
494 3
            $oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : '');
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
495 3
        }
496
497 3
        $oElement = $document->getElement('p:blipFill/a:blip', $node);
498 3
        if ($oElement) {
499 3
            if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'])) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
500 3
                $pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'];
501 3
                $pathImage = explode('/', $pathImage);
502 3
                foreach ($pathImage as $key => $partPath) {
503 3
                    if ($partPath == '..') {
504 3
                        unset($pathImage[$key - 1]);
505 3
                        unset($pathImage[$key]);
506 3
                    }
507 3
                }
508 3
                $pathImage = implode('/', $pathImage);
509 3
                $imageFile = $this->oZip->getFromName($pathImage);
510 3
                if (!empty($imageFile)) {
511 3
                    $oShape->setImageResource(imagecreatefromstring($imageFile));
512 3
                }
513 3
            }
514 3
        }
515
516 3
        $oElement = $document->getElement('p:spPr/a:xfrm', $node);
517 3
        if ($oElement) {
518 3
            if ($oElement->hasAttribute('rot')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
519 3
                $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot')));
520 3
            }
521 3
        }
522
523 3
        $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
524 3
        if ($oElement) {
525 3
            if ($oElement->hasAttribute('x')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
526 3
                $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x')));
527 3
            }
528 3
            if ($oElement->hasAttribute('y')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
529 3
                $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y')));
530 3
            }
531 3
        }
532
533 3
        $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
534 3
        if ($oElement) {
535 3
            if ($oElement->hasAttribute('cx')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
536 3
                $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx')));
537 3
            }
538 3
            if ($oElement->hasAttribute('cy')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
539 3
                $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy')));
540 3
            }
541 3
        }
542
543 3
        $oElement = $document->getElement('p:spPr/a:effectLst', $node);
544 3
        if ($oElement) {
545 3
            $oShape->getShadow()->setVisible(true);
546
547 3
            $oSubElement = $document->getElement('a:outerShdw', $oElement);
0 ignored issues
show
Documentation introduced by
$oElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
548 3
            if ($oSubElement) {
549 3
                if ($oSubElement->hasAttribute('blurRad')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
550 3
                    $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels($oSubElement->getAttribute('blurRad')));
551 3
                }
552 3
                if ($oSubElement->hasAttribute('dist')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
553 3
                    $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels($oSubElement->getAttribute('dist')));
554 3
                }
555 3
                if ($oSubElement->hasAttribute('dir')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
556 3
                    $oShape->getShadow()->setDirection(CommonDrawing::angleToDegrees($oSubElement->getAttribute('dir')));
557 3
                }
558 3
                if ($oSubElement->hasAttribute('algn')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
559 3
                    $oShape->getShadow()->setAlignment($oSubElement->getAttribute('algn'));
560 3
                }
561 3
            }
562
563 3
            $oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement);
0 ignored issues
show
Documentation introduced by
$oElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
564 3
            if ($oSubElement) {
565 3
                if ($oSubElement->hasAttribute('val')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
566 3
                    $oColor = new Color();
567 3
                    $oColor->setRGB($oSubElement->getAttribute('val'));
568 3
                    $oShape->getShadow()->setColor($oColor);
569 3
                }
570 3
            }
571
572 3
            $oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement);
0 ignored issues
show
Documentation introduced by
$oElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
573 3
            if ($oSubElement) {
574 3
                if ($oSubElement->hasAttribute('val')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
575 3
                    $oShape->getShadow()->setAlpha((int)$oSubElement->getAttribute('val') / 1000);
576 3
                }
577 3
            }
578 3
        }
579
580 3
        $oSlide->addShape($oShape);
581 3
    }
582
583
    /**
584
     * @param XMLReader $document
585
     * @param \DOMElement $node
586
     * @param AbstractSlide $oSlide
587
     * @throws \Exception
588
     */
589 3
    protected function loadShapeRichText(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide)
590
    {
591
        // Core
592 3
        $oShape = $oSlide->createRichTextShape();
593 3
        $oShape->setParagraphs(array());
594
        // Variables
595 3
        $fileRels = $oSlide->getRelsIndex();
596
597 3
        $oElement = $document->getElement('p:spPr/a:xfrm', $node);
598 3
        if ($oElement && $oElement->hasAttribute('rot')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
599 3
            $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot')));
600 3
        }
601
602 3
        $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
603 3
        if ($oElement) {
604 3
            if ($oElement->hasAttribute('x')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
605 3
                $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x')));
606 3
            }
607 3
            if ($oElement->hasAttribute('y')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
608 3
                $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y')));
609 3
            }
610 3
        }
611
612 3
        $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
613 3
        if ($oElement) {
614 3
            if ($oElement->hasAttribute('cx')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
615 3
                $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx')));
616 3
            }
617 3
            if ($oElement->hasAttribute('cy')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
618 3
                $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy')));
619 3
            }
620 3
        }
621
622 3
        $oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node);
623 3
        if ($oElement) {
624 3
            if ($oElement->hasAttribute('type')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
625 3
                $placeholder = new Placeholder($oElement->getAttribute('type'));
626 3
                $oShape->setPlaceHolder($placeholder);
627 3
            }
628 3
        }
629
630 3
        $arrayElements = $document->getElements('p:txBody/a:p', $node);
631 3
        foreach ($arrayElements as $oElement) {
632
            // Core
633 3
            $oParagraph = $oShape->createParagraph();
634 3
            $oParagraph->setRichTextElements(array());
635
636 3
            $oSubElement = $document->getElement('a:pPr', $oElement);
637 3
            if ($oSubElement) {
638 3
                if ($oSubElement->hasAttribute('algn')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
639 3
                    $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn'));
640 3
                }
641 3
                if ($oSubElement->hasAttribute('fontAlgn')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
642 3
                    $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn'));
643 3
                }
644 3
                if ($oSubElement->hasAttribute('marL')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
645 3
                    $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL')));
646 3
                }
647 3
                if ($oSubElement->hasAttribute('marR')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
648 3
                    $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR')));
649 3
                }
650 3
                if ($oSubElement->hasAttribute('indent')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
651 3
                    $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent')));
652 3
                }
653 3
                if ($oSubElement->hasAttribute('lvl')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
654 3
                    $oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl'));
655 3
                }
656
657 3
                $oElementBuFont = $document->getElement('a:buFont', $oSubElement);
0 ignored issues
show
Documentation introduced by
$oSubElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
658 3
                $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
659 3
                if ($oElementBuFont) {
660 3
                    if ($oElementBuFont->hasAttribute('typeface')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
661 3
                        $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
662 3
                    }
663 3
                }
664 3
                $oElementBuChar = $document->getElement('a:buChar', $oSubElement);
0 ignored issues
show
Documentation introduced by
$oSubElement is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
665 3
                if ($oElementBuChar) {
666 3
                    $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
667 3
                    if ($oElementBuChar->hasAttribute('char')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
668 3
                        $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
669 3
                    }
670 3
                }
671
                /*$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
672
                if ($oElementBuAutoNum) {
673
                    $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
674
                    if ($oElementBuAutoNum->hasAttribute('type')) {
675
                        $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
676
                    }
677
                    if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) {
678
                        $oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt'));
679
                    }
680
                }*/
681 3
            }
682 3
            $arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
683 3
            foreach ($arraySubElements as $oSubElement) {
684 3
                if ($oSubElement->tagName == 'a:br') {
685 3
                    $oParagraph->createBreak();
686 3
                }
687 3
                if ($oSubElement->tagName == 'a:r') {
688 3
                    $oElementrPr = $document->getElement('a:rPr', $oSubElement);
689 3
                    if (is_object($oElementrPr)) {
690 3
                        $oText = $oParagraph->createTextRun();
691
692 3
                        if ($oElementrPr->hasAttribute('b')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
693 3
                            $oText->getFont()->setBold($oElementrPr->getAttribute('b') == 'true' ? true : false);
694 3
                        }
695 3
                        if ($oElementrPr->hasAttribute('i')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
696 3
                            $oText->getFont()->setItalic($oElementrPr->getAttribute('i') == 'true' ? true : false);
697 3
                        }
698 3
                        if ($oElementrPr->hasAttribute('strike')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
699 3
                            $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true);
700 3
                        }
701 3
                        if ($oElementrPr->hasAttribute('sz')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
702 3
                            $oText->getFont()->setSize((int)($oElementrPr->getAttribute('sz') / 100));
703 3
                        }
704 3
                        if ($oElementrPr->hasAttribute('u')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
705 3
                            $oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
706 3
                        }
707
                        // Color
708 3
                        $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
0 ignored issues
show
Documentation introduced by
$oElementrPr is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
709 3
                        if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
710 3
                            $oColor = new Color();
711 3
                            $oColor->setRGB($oElementSrgbClr->getAttribute('val'));
712 3
                            $oText->getFont()->setColor($oColor);
713 3
                        }
714
                        // Hyperlink
715 3
                        $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
0 ignored issues
show
Documentation introduced by
$oElementrPr is of type object<DOMNode>, but the function expects a null|object<DOMElement>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
716 3
                        if (is_object($oElementHlinkClick)) {
717 3
                            if ($oElementHlinkClick->hasAttribute('tooltip')) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
718 3
                                $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip'));
719 3
                            }
720 3
                            if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) {
0 ignored issues
show
Bug introduced by
The method hasAttribute() does not exist on DOMNode. Did you maybe mean hasAttributes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
721 3
                                $oText->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']);
722 3
                            }
723 3
                        }
724
                        //} else {
725
                        // $oText = $oParagraph->createText();
726
727 3
                        $oSubSubElement = $document->getElement('a:t', $oSubElement);
728 3
                        $oText->setText($oSubSubElement->nodeValue);
729 3
                    }
730 3
                }
731 3
            }
732 3
        }
733
734 3
        if (count($oShape->getParagraphs()) > 0) {
735 3
            $oShape->setActiveParagraph(0);
736 3
        }
737 3
    }
738
739
    /**
740
     *
741
     * @param string $fileRels
742
     * @return string
743
     */
744 3
    protected function loadRels($fileRels)
745
    {
746 3
        $sPart = $this->oZip->getFromName($fileRels);
747 3
        if ($sPart !== false) {
748 3
            $xmlReader = new XMLReader();
749 3
            if ($xmlReader->getDomFromString($sPart)) {
750 3
                foreach ($xmlReader->getElements('*') as $oNode) {
751 3
                    $this->arrayRels[$fileRels][$oNode->getAttribute('Id')] = array(
752 3
                        'Target' => $oNode->getAttribute('Target'),
753 3
                        'Type' => $oNode->getAttribute('Type'),
754
                    );
755 3
                }
756 3
            }
757 3
        }
758 3
    }
759
760
    /**
761
     * @param $oSlide
762
     * @param $oElements
763
     * @param $xmlReader
764
     * @internal param $baseFile
765
     */
766 3
    private function loadSlideShapes($oSlide, $oElements, $xmlReader)
767
    {
768 3
        foreach ($oElements as $oNode) {
769 3
            switch ($oNode->tagName) {
770 3
                case 'p:pic':
771
                    $this->loadShapeDrawing($xmlReader, $oNode, $oSlide);
772
                    break;
773 3
                case 'p:sp':
774 3
                    $this->loadShapeRichText($xmlReader, $oNode, $oSlide);
775 3
                    break;
776 3
                default:
777
                    //var_export($oNode->tagName);
778 3
            }
779 3
        }
780 3
    }
781
}
782