Completed
Pull Request — develop (#565)
by
unknown
06:14
created

PowerPoint97::readRecordDrawingGroupContainer()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 9.7666
c 0
b 0
f 0
cc 4
nc 2
nop 2
crap 4
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
use PhpOffice\Common\Microsoft\OLERead;
21
use PhpOffice\Common\Text;
22
use PhpOffice\PhpPresentation\AbstractShape;
23
use PhpOffice\PhpPresentation\PhpPresentation;
24
use PhpOffice\PhpPresentation\Shape\Drawing;
25
use PhpOffice\PhpPresentation\Shape\Group;
26
use PhpOffice\PhpPresentation\Shape\Hyperlink;
27
use PhpOffice\PhpPresentation\Shape\Line;
28
use PhpOffice\PhpPresentation\Shape\RichText;
29
use PhpOffice\PhpPresentation\Style\Alignment;
30
use PhpOffice\PhpPresentation\Style\Bullet;
31
use PhpOffice\PhpPresentation\Style\Color;
32
33
/**
34
 * Serialized format reader
35
 */
36
class PowerPoint97 implements ReaderInterface
37
{
38
    const OFFICEARTBLIPEMF = 0xF01A;
39
    const OFFICEARTBLIPWMF = 0xF01B;
40
    const OFFICEARTBLIPPICT = 0xF01C;
41
    const OFFICEARTBLIPJPG = 0xF01D;
42
    const OFFICEARTBLIPPNG = 0xF01E;
43
    const OFFICEARTBLIPDIB = 0xF01F;
44
    const OFFICEARTBLIPTIFF = 0xF029;
45
    const OFFICEARTBLIPJPEG = 0xF02A;
46
47
    /**
48
     * @link http://msdn.microsoft.com/en-us/library/dd945336(v=office.12).aspx
49
     */
50
    const RT_ANIMATIONINFO = 0x1014;
51
    const RT_ANIMATIONINFOATOM = 0x0FF1;
52
    const RT_BINARYTAGDATABLOB = 0x138B;
53
    const RT_BLIPCOLLECTION9 = 0x07F8;
54
    const RT_BLIPENTITY9ATOM = 0x07F9;
55
    const RT_BOOKMARKCOLLECTION = 0x07E3;
56
    const RT_BOOKMARKENTITYATOM = 0x0FD0;
57
    const RT_BOOKMARKSEEDATOM = 0x07E9;
58
    const RT_BROADCASTDOCINFO9 = 0x177E;
59
    const RT_BROADCASTDOCINFO9ATOM = 0x177F;
60
    const RT_BUILDATOM = 0x2B03;
61
    const RT_BUILDLIST = 0x2B02;
62
    const RT_CHARTBUILD = 0x2B04;
63
    const RT_CHARTBUILDATOM = 0x2B05;
64
    const RT_COLORSCHEMEATOM = 0x07F0;
65
    const RT_COMMENT10 = 0x2EE0;
66
    const RT_COMMENT10ATOM = 0x2EE1;
67
    const RT_COMMENTINDEX10 = 0x2EE4;
68
    const RT_COMMENTINDEX10ATOM = 0x2EE5;
69
    const RT_CRYPTSESSION10CONTAINER = 0x2F14;
70
    const RT_CURRENTUSERATOM = 0x0FF6;
71
    const RT_CSTRING = 0x0FBA;
72
    const RT_DATETIMEMETACHARATOM = 0x0FF7;
73
    const RT_DEFAULTRULERATOM = 0x0FAB;
74
    const RT_DOCROUTINGSLIPATOM = 0x0406;
75
    const RT_DIAGRAMBUILD = 0x2B06;
76
    const RT_DIAGRAMBUILDATOM = 0x2B07;
77
    const RT_DIFF10 = 0x2EED;
78
    const RT_DIFF10ATOM = 0x2EEE;
79
    const RT_DIFFTREE10 = 0x2EEC;
80
    const RT_DOCTOOLBARSTATES10ATOM = 0x36B1;
81
    const RT_DOCUMENT = 0x03E8;
82
    const RT_DOCUMENTATOM = 0x03E9;
83
    const RT_DRAWING = 0x040C;
84
    const RT_DRAWINGGROUP = 0x040B;
85
    const RT_ENDDOCUMENTATOM = 0x03EA;
86
    const RT_EXTERNALAVIMOVIE = 0x1006;
87
    const RT_EXTERNALCDAUDIO = 0x100E;
88
    const RT_EXTERNALCDAUDIOATOM = 0x1012;
89
    const RT_EXTERNALHYPERLINK = 0x0FD7;
90
    const RT_EXTERNALHYPERLINK9 = 0x0FE4;
91
    const RT_EXTERNALHYPERLINKATOM = 0x0FD3;
92
    const RT_EXTERNALHYPERLINKFLAGSATOM = 0x1018;
93
    const RT_EXTERNALMCIMOVIE = 0x1007;
94
    const RT_EXTERNALMEDIAATOM = 0x1004;
95
    const RT_EXTERNALMIDIAUDIO = 0x100D;
96
    const RT_EXTERNALOBJECTLIST = 0x0409;
97
    const RT_EXTERNALOBJECTLISTATOM = 0x040A;
98
    const RT_EXTERNALOBJECTREFATOM = 0x0BC1;
99
    const RT_EXTERNALOLECONTROL = 0x0FEE;
100
    const RT_EXTERNALOLECONTROLATOM = 0x0FFB;
101
    const RT_EXTERNALOLEEMBED = 0x0FCC;
102
    const RT_EXTERNALOLEEMBEDATOM = 0x0FCD;
103
    const RT_EXTERNALOLELINK = 0x0FCE;
104
    const RT_EXTERNALOLELINKATOM = 0x0FD1;
105
    const RT_EXTERNALOLEOBJECTATOM = 0x0FC3;
106
    const RT_EXTERNALOLEOBJECTSTG = 0x1011;
107
    const RT_EXTERNALVIDEO = 0x1005;
108
    const RT_EXTERNALWAVAUDIOEMBEDDED = 0x100F;
109
    const RT_EXTERNALWAVAUDIOEMBEDDEDATOM = 0x1013;
110
    const RT_EXTERNALWAVAUDIOLINK = 0x1010;
111
    const RT_ENVELOPEDATA9ATOM = 0x1785;
112
    const RT_ENVELOPEFLAGS9ATOM = 0x1784;
113
    const RT_ENVIRONMENT = 0x03F2;
114
    const RT_FONTCOLLECTION = 0x07D5;
115
    const RT_FONTCOLLECTION10 = 0x07D6;
116
    const RT_FONTEMBEDDATABLOB = 0x0FB8;
117
    const RT_FONTEMBEDFLAGS10ATOM = 0x32C8;
118
    const RT_FILTERPRIVACYFLAGS10ATOM = 0x36B0;
119
    const RT_FONTENTITYATOM = 0x0FB7;
120
    const RT_FOOTERMETACHARATOM = 0x0FFA;
121
    const RT_GENERICDATEMETACHARATOM = 0x0FF8;
122
    const RT_GRIDSPACING10ATOM = 0x040D;
123
    const RT_GUIDEATOM = 0x03FB;
124
    const RT_HANDOUT = 0x0FC9;
125
    const RT_HASHCODEATOM = 0x2B00;
126
    const RT_HEADERSFOOTERS = 0x0FD9;
127
    const RT_HEADERSFOOTERSATOM = 0x0FDA;
128
    const RT_HEADERMETACHARATOM = 0x0FF9;
129
    const RT_HTMLDOCINFO9ATOM = 0x177B;
130
    const RT_HTMLPUBLISHINFOATOM = 0x177C;
131
    const RT_HTMLPUBLISHINFO9 = 0x177D;
132
    const RT_INTERACTIVEINFO = 0x0FF2;
133
    const RT_INTERACTIVEINFOATOM = 0x0FF3;
134
    const RT_KINSOKU = 0x0FC8;
135
    const RT_KINSOKUATOM = 0x0FD2;
136
    const RT_LEVELINFOATOM = 0x2B0A;
137
    const RT_LINKEDSHAPE10ATOM = 0x2EE6;
138
    const RT_LINKEDSLIDE10ATOM = 0x2EE7;
139
    const RT_LIST = 0x07D0;
140
    const RT_MAINMASTER = 0x03F8;
141
    const RT_MASTERTEXTPROPATOM = 0x0FA2;
142
    const RT_METAFILE = 0x0FC1;
143
    const RT_NAMEDSHOW = 0x0411;
144
    const RT_NAMEDSHOWS = 0x0410;
145
    const RT_NAMEDSHOWSLIDESATOM = 0x0412;
146
    const RT_NORMALVIEWSETINFO9 = 0x0414;
147
    const RT_NORMALVIEWSETINFO9ATOM = 0x0415;
148
    const RT_NOTES= 0x03F0;
149
    const RT_NOTESATOM = 0x03F1;
150
    const RT_NOTESTEXTVIEWINFO9 = 0x0413;
151
    const RT_OUTLINETEXTPROPS9 = 0x0FAE;
152
    const RT_OUTLINETEXTPROPS10 = 0x0FB3;
153
    const RT_OUTLINETEXTPROPS11 = 0x0FB5;
154
    const RT_OUTLINETEXTPROPSHEADER9ATOM = 0x0FAF;
155
    const RT_OUTLINETEXTREFATOM = 0x0F9E;
156
    const RT_OUTLINEVIEWINFO = 0x0407;
157
    const RT_PERSISTDIRECTORYATOM = 0x1772;
158
    const RT_PARABUILD = 0x2B08;
159
    const RT_PARABUILDATOM = 0x2B09;
160
    const RT_PHOTOALBUMINFO10ATOM = 0x36B2;
161
    const RT_PLACEHOLDERATOM = 0x0BC3;
162
    const RT_PRESENTATIONADVISORFLAGS9ATOM = 0x177A;
163
    const RT_PRINTOPTIONSATOM = 0x1770;
164
    const RT_PROGBINARYTAG = 0x138A;
165
    const RT_PROGSTRINGTAG = 0x1389;
166
    const RT_PROGTAGS = 0x1388;
167
    const RT_RECOLORINFOATOM = 0x0FE7;
168
    const RT_RTFDATETIMEMETACHARATOM = 0x1015;
169
    const RT_ROUNDTRIPANIMATIONATOM12ATOM = 0x2B0B;
170
    const RT_ROUNDTRIPANIMATIONHASHATOM12ATOM = 0x2B0D;
171
    const RT_ROUNDTRIPCOLORMAPPING12ATOM = 0x040F;
172
    const RT_ROUNDTRIPCOMPOSITEMASTERID12ATOM = 0x041D;
173
    const RT_ROUNDTRIPCONTENTMASTERID12ATOM = 0x0422;
174
    const RT_ROUNDTRIPCONTENTMASTERINFO12ATOM = 0x041E;
175
    const RT_ROUNDTRIPCUSTOMTABLESTYLES12ATOM = 0x0428;
176
    const RT_ROUNDTRIPDOCFLAGS12ATOM = 0x0425;
177
    const RT_ROUNDTRIPHEADERFOOTERDEFAULTS12ATOM = 0x0424;
178
    const RT_ROUNDTRIPHFPLACEHOLDER12ATOM = 0x0420;
179
    const RT_ROUNDTRIPNEWPLACEHOLDERID12ATOM = 0x0BDD;
180
    const RT_ROUNDTRIPNOTESMASTERTEXTSTYLES12ATOM = 0x0427;
181
    const RT_ROUNDTRIPOARTTEXTSTYLES12ATOM = 0x0423;
182
    const RT_ROUNDTRIPORIGINALMAINMASTERID12ATOM = 0x041C;
183
    const RT_ROUNDTRIPSHAPECHECKSUMFORCL12ATOM = 0x0426;
184
    const RT_ROUNDTRIPSHAPEID12ATOM = 0x041F;
185
    const RT_ROUNDTRIPSLIDESYNCINFO12 = 0x3714;
186
    const RT_ROUNDTRIPSLIDESYNCINFOATOM12 = 0x3715;
187
    const RT_ROUNDTRIPTHEME12ATOM = 0x040E;
188
    const RT_SHAPEATOM = 0x0BDB;
189
    const RT_SHAPEFLAGS10ATOM = 0x0BDC;
190
    const RT_SLIDE = 0x03EE;
191
    const RT_SLIDEATOM = 0x03EF;
192
    const RT_SLIDEFLAGS10ATOM = 0x2EEA;
193
    const RT_SLIDELISTENTRY10ATOM = 0x2EF0;
194
    const RT_SLIDELISTTABLE10 = 0x2EF1;
195
    const RT_SLIDELISTWITHTEXT = 0x0FF0;
196
    const RT_SLIDELISTTABLESIZE10ATOM = 0x2EEF;
197
    const RT_SLIDENUMBERMETACHARATOM = 0x0FD8;
198
    const RT_SLIDEPERSISTATOM = 0x03F3;
199
    const RT_SLIDESHOWDOCINFOATOM = 0x0401;
200
    const RT_SLIDESHOWSLIDEINFOATOM = 0x03F9;
201
    const RT_SLIDETIME10ATOM = 0x2EEB;
202
    const RT_SLIDEVIEWINFO = 0x03FA;
203
    const RT_SLIDEVIEWINFOATOM = 0x03FE;
204
    const RT_SMARTTAGSTORE11CONTAINER = 0x36B3;
205
    const RT_SOUND = 0x07E6;
206
    const RT_SOUNDCOLLECTION = 0x07E4;
207
    const RT_SOUNDCOLLECTIONATOM = 0x07E5;
208
    const RT_SOUNDDATABLOB = 0x07E7;
209
    const RT_SORTERVIEWINFO = 0x0408;
210
    const RT_STYLETEXTPROPATOM = 0x0FA1;
211
    const RT_STYLETEXTPROP10ATOM = 0x0FB1;
212
    const RT_STYLETEXTPROP11ATOM = 0x0FB6;
213
    const RT_STYLETEXTPROP9ATOM = 0x0FAC;
214
    const RT_SUMMARY = 0x0402;
215
    const RT_TEXTBOOKMARKATOM = 0x0FA7;
216
    const RT_TEXTBYTESATOM = 0x0FA8;
217
    const RT_TEXTCHARFORMATEXCEPTIONATOM = 0x0FA4;
218
    const RT_TEXTCHARSATOM = 0x0FA0;
219
    const RT_TEXTDEFAULTS10ATOM = 0x0FB4;
220
    const RT_TEXTDEFAULTS9ATOM = 0x0FB0;
221
    const RT_TEXTHEADERATOM = 0x0F9F;
222
    const RT_TEXTINTERACTIVEINFOATOM = 0x0FDF;
223
    const RT_TEXTMASTERSTYLEATOM = 0x0FA3;
224
    const RT_TEXTMASTERSTYLE10ATOM = 0x0FB2;
225
    const RT_TEXTMASTERSTYLE9ATOM = 0x0FAD;
226
    const RT_TEXTPARAGRAPHFORMATEXCEPTIONATOM = 0x0FA5;
227
    const RT_TEXTRULERATOM = 0x0FA6;
228
    const RT_TEXTSPECIALINFOATOM = 0x0FAA;
229
    const RT_TEXTSPECIALINFODEFAULTATOM = 0x0FA9;
230
    const RT_TIMEANIMATEBEHAVIOR = 0xF134;
231
    const RT_TIMEANIMATEBEHAVIORCONTAINER = 0xF12B;
232
    const RT_TIMEANIMATIONVALUE = 0xF143;
233
    const RT_TIMEANIMATIONVALUELIST = 0xF13F;
234
    const RT_TIMEBEHAVIOR = 0xF133;
235
    const RT_TIMEBEHAVIORCONTAINER = 0xF12A;
236
    const RT_TIMECOLORBEHAVIOR = 0xF135;
237
    const RT_TIMECOLORBEHAVIORCONTAINER = 0xF12C;
238
    const RT_TIMECLIENTVISUALELEMENT = 0xF13C;
239
    const RT_TIMECOMMANDBEHAVIOR = 0xF13B;
240
    const RT_TIMECOMMANDBEHAVIORCONTAINER = 0xF132;
241
    const RT_TIMECONDITION = 0xF128;
242
    const RT_TIMECONDITIONCONTAINER = 0xF125;
243
    const RT_TIMEEFFECTBEHAVIOR = 0xF136;
244
    const RT_TIMEEFFECTBEHAVIORCONTAINER = 0xF12D;
245
    const RT_TIMEEXTTIMENODECONTAINER = 0xF144;
246
    const RT_TIMEITERATEDATA = 0xF140;
247
    const RT_TIMEMODIFIER = 0xF129;
248
    const RT_TIMEMOTIONBEHAVIOR = 0xF137;
249
    const RT_TIMEMOTIONBEHAVIORCONTAINER = 0xF12E;
250
    const RT_TIMENODE = 0xF127;
251
    const RT_TIMEPROPERTYLIST = 0xF13D;
252
    const RT_TIMEROTATIONBEHAVIOR = 0xF138;
253
    const RT_TIMEROTATIONBEHAVIORCONTAINER = 0xF12F;
254
    const RT_TIMESCALEBEHAVIOR = 0xF139;
255
    const RT_TIMESCALEBEHAVIORCONTAINER = 0xF130;
256
    const RT_TIMESEQUENCEDATA = 0xF141;
257
    const RT_TIMESETBEHAVIOR = 0xF13A;
258
    const RT_TIMESETBEHAVIORCONTAINER = 0xF131;
259
    const RT_TIMESUBEFFECTCONTAINER = 0xF145;
260
    const RT_TIMEVARIANT = 0xF142;
261
    const RT_TIMEVARIANTLIST = 0xF13E;
262
    const RT_USEREDITATOM = 0x0FF5;
263
    const RT_VBAINFO = 0x03FF;
264
    const RT_VBAINFOATOM = 0x0400;
265
    const RT_VIEWINFOATOM = 0x03FD;
266
    const RT_VISUALPAGEATOM = 0x2B01;
267
    const RT_VISUALSHAPEATOM = 0x2AFB;
268
269
    /**
270
     * @var http://msdn.microsoft.com/en-us/library/dd926394(v=office.12).aspx
271
     */
272
    const SL_BIGOBJECT = 0x0000000F;
273
    const SL_BLANK = 0x00000010;
274
    const SL_COLUMNTWOROWS = 0x0000000A;
275
    const SL_FOUROBJECTS = 0x0000000E;
276
    const SL_MASTERTITLE = 0x00000002;
277
    const SL_TITLEBODY = 0x00000001;
278
    const SL_TITLEONLY = 0x00000007;
279
    const SL_TITLESLIDE = 0x00000000;
280
    const SL_TWOCOLUMNS = 0x00000008;
281
    const SL_TWOCOLUMNSROW = 0x0000000D;
282
    const SL_TWOROWS = 0x00000009;
283
    const SL_TWOROWSCOLUMN = 0x0000000B;
284
    const SL_VERTICALTITLEBODY = 0x00000011;
285
    const SL_VERTICALTWOROWS = 0x00000012;
286
287
    /**
288
     * Array with Fonts
289
     */
290
    private $arrayFonts = array();
291
    /**
292
     * Array with Hyperlinks
293
     */
294
    private $arrayHyperlinks = array();
295
    /**
296
     * Array with Notes
297
     */
298
    private $arrayNotes = array();
299
    /**
300
     * Array with Pictures
301
     */
302
    private $arrayPictures = array();
303
    /**
304
     * Offset (in bytes) from the beginning of the PowerPoint Document Stream to the UserEditAtom record for the most recent user edit.
305
     * @var int
306
     */
307
    private $offsetToCurrentEdit;
308
    /**
309
     * A structure that specifies a compressed table of sequential persist object identifiers and stream offsets to associated persist objects.
310
     * @var int[]
311
     */
312
    private $rgPersistDirEntry;
313
    /**
314
     * Offset (in bytes) from the beginning of the PowerPoint Document Stream to the PersistDirectoryAtom record for this user edit
315
     * @var int
316
     */
317
    private $offsetPersistDirectory;
318
    /**
319
     * Output Object
320
     * @var PhpPresentation
321
     */
322
    private $oPhpPresentation;
323
    /**
324
     * Group Object
325
     * @var Group
326
     */
327
    private $oCurrentGroup;
328
    /**
329
     * @var boolean
330
     */
331
    private $bFirstShapeGroup = false;
332
    /**
333
     * Stream "Powerpoint Document"
334
     * @var string
335
     */
336
    private $streamPowerpointDocument;
337
    /**
338
     * Stream "Current User"
339
     * @var string
340
     */
341
    private $streamCurrentUser;
342
    /**
343
     * Stream "Summary Information"
344
     * @var string
345
     */
346
    private $streamSummaryInformation;
347
    /**
348
     * Stream "Document Summary Information"
349
     * @var string
350
     */
351
    private $streamDocumentSummaryInformation;
352
    /**
353
     * Stream "Pictures"
354
     * @var string
355
     */
356
    private $streamPictures;
357
    /**
358
     * @var integer
359
     */
360
    private $inMainType;
361
    /**
362
     * @var integer
363
     */
364
    private $currentNote;
365
366
    /**
367
     * Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file?
368
     *
369
     * @param  string $pFilename
370
     * @throws \Exception
371
     * @return boolean
372
     */
373 3
    public function canRead($pFilename)
374
    {
375 3
        return $this->fileSupportsUnserializePhpPresentation($pFilename);
376
    }
377
378
    /**
379
     * Does a file support UnserializePhpPresentation ?
380
     *
381
     * @param  string    $pFilename
382
     * @throws \Exception
383
     * @return boolean
384
     */
385 10
    public function fileSupportsUnserializePhpPresentation($pFilename = '')
386
    {
387
        // Check if file exists
388 10
        if (!file_exists($pFilename)) {
389 2
            throw new \Exception('Could not open ' . $pFilename . ' for reading! File does not exist.');
390
        }
391
392
        try {
393
            // Use ParseXL for the hard work.
394 8
            $ole = new OLERead();
395
            // get excel data
396 8
            $ole->read($pFilename);
397 5
            return true;
398 3
        } catch (\Exception $e) {
399 3
            return false;
400
        }
401
    }
402
403
    /**
404
     * Loads PhpPresentation Serialized file
405
     *
406
     * @param  string        $pFilename
407
     * @return \PhpOffice\PhpPresentation\PhpPresentation
408
     * @throws \Exception
409
     */
410 6
    public function load($pFilename)
411
    {
412
        // Unserialize... First make sure the file supports it!
413 6
        if (!$this->fileSupportsUnserializePhpPresentation($pFilename)) {
414 1
            throw new \Exception("Invalid file format for PhpOffice\PhpPresentation\Reader\PowerPoint97: " . $pFilename . '.');
415
        }
416
417 4
        return $this->loadFile($pFilename);
418
    }
419
420
    /**
421
     * Load PhpPresentation Serialized file
422
     *
423
     * @param  string $pFilename
424
     * @return \PhpOffice\PhpPresentation\PhpPresentation
425
     * @throws \Exception
426
     */
427 4
    private function loadFile($pFilename)
428
    {
429 4
        $this->oPhpPresentation = new PhpPresentation();
430 4
        $this->oPhpPresentation->removeSlideByIndex();
431
432
        // Read OLE Blocks
433 4
        $this->loadOLE($pFilename);
434
        // Read pictures in the Pictures Stream
435 4
        $this->loadPicturesStream();
436
        // Read information in the Current User Stream
437 4
        $this->loadCurrentUserStream();
438
        // Read information in the PowerPoint Document Stream
439 4
        $this->loadPowerpointDocumentStream();
440
441 4
        return $this->oPhpPresentation;
442
    }
443
444
    /**
445
     * Read OLE Part
446
     * @param string $pFilename
447
     * @throws \Exception
448
     */
449 4
    private function loadOLE($pFilename)
450
    {
451
        // OLE reader
452 4
        $oOLE = new OLERead();
453 4
        $oOLE->read($pFilename);
454
455
        // PowerPoint Document Stream
456 4
        $this->streamPowerpointDocument = $oOLE->getStream($oOLE->powerpointDocument);
457
458
        // Current User Stream
459 4
        $this->streamCurrentUser = $oOLE->getStream($oOLE->currentUser);
460
461
        // Get summary information data
462 4
        $this->streamSummaryInformation = $oOLE->getStream($oOLE->summaryInformation);
463
464
        // Get additional document summary information data
465 4
        $this->streamDocumentSummaryInformation = $oOLE->getStream($oOLE->docSummaryInfos);
466
467
        // Get pictures data
468 4
        $this->streamPictures = $oOLE->getStream($oOLE->pictures);
469 4
    }
470
471
    /**
472
     * Stream Pictures
473
     * @link http://msdn.microsoft.com/en-us/library/dd920746(v=office.12).aspx
474
     */
475 4
    private function loadPicturesStream()
476
    {
477 4
        $stream = $this->streamPictures;
478
479 4
        $pos = 0;
480
        do {
481 4
            $arrayRH = $this->loadRecordHeader($stream, $pos);
482 4
            $pos += 8;
483 4
            $readSuccess = false;
484 4
            if ($arrayRH['recVer'] == 0x00 && ($arrayRH['recType'] == 0xF007 || ($arrayRH['recType'] >= 0xF018 && $arrayRH['recType'] <= 0xF117))) {
485
                //@link : http://msdn.microsoft.com/en-us/library/dd950560(v=office.12).aspx
486 4
                if ($arrayRH['recType'] == 0xF007) {
487
                    // OfficeArtFBSE
488
                    throw new \Exception('Feature not implemented (l.'.__LINE__.')');
489
                }
490 4
                if ($arrayRH['recType'] >= 0xF018 && $arrayRH['recType'] <= 0xF117) {
491 4
                    $arrayRecord = $this->readRecordOfficeArtBlip($stream, $pos - 8);
492 4
                    if ($arrayRecord['length'] > 0) {
493 4
                        $pos += $arrayRecord['length'];
494 4
                        $this->arrayPictures[] = $arrayRecord['picture'];
495
                    }
496
                }
497 4
                $readSuccess = true;
498
            }
499 4
        } while ($readSuccess === true);
500 4
    }
501
502
    /**
503
     * Stream Current User
504
     * @link http://msdn.microsoft.com/en-us/library/dd908567(v=office.12).aspx
505
     */
506 4
    private function loadCurrentUserStream()
507
    {
508 4
        $pos = 0;
509
510
        /**
511
         * CurrentUserAtom : http://msdn.microsoft.com/en-us/library/dd948895(v=office.12).aspx
512
         */
513
        // RecordHeader : http://msdn.microsoft.com/en-us/library/dd926377(v=office.12).aspx
514 4
        $rHeader = $this->loadRecordHeader($this->streamCurrentUser, $pos);
515 4
        $pos += 8;
516 4
        if ($rHeader['recVer'] != 0x0 || $rHeader['recInstance'] != 0x000 || $rHeader['recType'] != self::RT_CURRENTUSERATOM) {
517
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > RecordHeader).');
518
        }
519
520
        // Size
521 4
        $size = self::getInt4d($this->streamCurrentUser, $pos);
522 4
        $pos += 4;
523 4
        if ($size !=  0x00000014) {
524
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > Size).');
525
        }
526
527
        // headerToken
528 4
        $headerToken = self::getInt4d($this->streamCurrentUser, $pos);
529 4
        $pos += 4;
530 4
        if ($headerToken == 0xF3D1C4DF && $headerToken != 0xE391C05F) {
531
            throw new \Exception('Feature not implemented (l.'.__LINE__.') : Encrypted file');
532
        }
533
534
        // offsetToCurrentEdit
535 4
        $this->offsetToCurrentEdit = self::getInt4d($this->streamCurrentUser, $pos);
536 4
        $pos += 4;
537
538
        // lenUserName
539 4
        $lenUserName = self::getInt2d($this->streamCurrentUser, $pos);
540 4
        $pos += 2;
541 4
        if ($lenUserName > 255) {
542
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > lenUserName).');
543
        }
544
545
        // docFileVersion
546 4
        $docFileVersion = self::getInt2d($this->streamCurrentUser, $pos);
547 4
        $pos += 2;
548 4
        if ($docFileVersion != 0x03F4) {
549
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > docFileVersion).');
550
        }
551
552
        // majorVersion
553 4
        $majorVersion = self::getInt1d($this->streamCurrentUser, $pos);
554 4
        $pos += 1;
555 4
        if ($majorVersion != 0x03) {
556
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > majorVersion).');
557
        }
558
559
        // minorVersion
560 4
        $minorVersion = self::getInt1d($this->streamCurrentUser, $pos);
561 4
        $pos += 1;
562 4
        if ($minorVersion != 0x00) {
563
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > minorVersion).');
564
        }
565
566
        // unused
567 4
        $pos += 2;
568
569
        // ansiUserName
570 4
        $ansiUserName = '';
571
        do {
572 4
            $char = self::getInt1d($this->streamCurrentUser, $pos);
573 4
            if (($char >= 0x00 && $char <= 0x1F) || ($char >= 0x7F && $char <= 0x9F)) {
574 4
                $char = false;
575
            } else {
576 4
                $ansiUserName .= chr($char);
577 4
                $pos += 1;
578
            }
579 4
        } while ($char !== false);
580
581
        // relVersion
582 4
        $relVersion = self::getInt4d($this->streamCurrentUser, $pos);
583 4
        $pos += 4;
584 4
        if ($relVersion != 0x00000008 && $relVersion != 0x00000009) {
585
            throw new \Exception('File PowerPoint 97 in error (Location : CurrentUserAtom > relVersion).');
586
        }
587
588
        // unicodeUserName
589 4
        $unicodeUserName = '';
590 4
        for ($inc = 0; $inc < $lenUserName; $inc++) {
591 4
            $char = self::getInt2d($this->streamCurrentUser, $pos);
592 4
            if (($char >= 0x00 && $char <= 0x1F) || ($char >= 0x7F && $char <= 0x9F)) {
593 4
                break;
594
            }
595
            $unicodeUserName .= chr($char);
596
            $pos += 2;
597
        }
598 4
    }
599
600
    /**
601
     * Stream Powerpoint Document
602
     * @link http://msdn.microsoft.com/en-us/library/dd921564(v=office.12).aspx
603
     */
604 4
    private function loadPowerpointDocumentStream()
605
    {
606 4
        $this->readRecordUserEditAtom($this->streamPowerpointDocument, $this->offsetToCurrentEdit);
607
608 4
        $this->readRecordPersistDirectoryAtom($this->streamPowerpointDocument, $this->offsetPersistDirectory);
609
610 4
        foreach ($this->rgPersistDirEntry as $offsetDir) {
611 4
            $pos = $offsetDir;
612
613 4
            $rh = $this->loadRecordHeader($this->streamPowerpointDocument, $pos);
614 4
            $pos += 8;
615 4
            $this->inMainType = $rh['recType'];
616 4
            $this->currentNote = null;
617 4
            switch ($rh['recType']) {
618 4
                case self::RT_DOCUMENT:
619 4
                    $this->readRecordDocumentContainer($this->streamPowerpointDocument, $pos);
620 4
                    break;
621 4
                case self::RT_NOTES:
622 4
                    $this->readRecordNotesContainer($this->streamPowerpointDocument, $pos);
623 4
                    break;
624 4
                case self::RT_SLIDE:
625 4
                    $this->readRecordSlideContainer($this->streamPowerpointDocument, $pos);
626 4
                    break;
627
                default:
628
                    // throw new \Exception('Feature not implemented : l.'.__LINE__.'('.dechex($rh['recType']).')');
629 4
                    break;
630
            }
631
        }
632 4
    }
633
634
    /**
635
     * Read a record header
636
     * @param string $stream
637
     * @param integer $pos
638
     * @return array
639
     */
640 4
    private function loadRecordHeader($stream, $pos)
641
    {
642 4
        $rec = self::getInt2d($stream, $pos);
643 4
        $recType = self::getInt2d($stream, $pos + 2);
644 4
        $recLen = self::getInt4d($stream, $pos + 4);
645
        return array(
646 4
            'recVer' => ($rec >> 0) & bindec('1111'),
647 4
            'recInstance' => ($rec >> 4) & bindec('111111111111'),
648 4
            'recType' => $recType,
649 4
            'recLen' => $recLen,
650
        );
651
    }
652
653
    /**
654
     * Read 8-bit unsigned integer
655
     *
656
     * @param string $data
657
     * @param int $pos
658
     * @return int
659
     */
660 4
    public static function getInt1d($data, $pos)
661
    {
662 4
        return ord($data[$pos]);
663
    }
664
665
    /**
666
     * Read 16-bit unsigned integer
667
     *
668
     * @param string $data
669
     * @param int $pos
670
     * @return int
671
     */
672 4
    public static function getInt2d($data, $pos)
673
    {
674 4
        return ord($data[$pos]) | (ord($data[$pos+1]) << 8);
675
    }
676
677
    /**
678
     * Read 32-bit signed integer
679
     *
680
     * @param string $data
681
     * @param int $pos
682
     * @return int
683
     */
684 4
    public static function getInt4d($data, $pos)
685
    {
686
        // FIX: represent numbers correctly on 64-bit system
687
        // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
688
        // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
689 4
        $or24 = ord($data[$pos + 3]);
690
691 4
        $ord24 = ($or24 & 127) << 24;
692 4
        if ($or24 >= 128) {
693
            // negative number
694 4
            $ord24 = -abs((256 - $or24) << 24);
695
        }
696 4
        return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24;
697
    }
698
699
    /**
700
     * A container record that specifies the animation and sound information for a shape.
701
     * @param string $stream
702
     * @param integer $pos
703
     * @return array
704
     * @throws \Exception
705
     * @link https://msdn.microsoft.com/en-us/library/dd772900(v=office.12).aspx
706
     */
707 4
    private function readRecordAnimationInfoContainer($stream, $pos)
708
    {
709
        $arrayReturn = array(
710 4
            'length' => 0,
711
        );
712
713 4
        $data = $this->loadRecordHeader($stream, $pos);
714 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_ANIMATIONINFO) {
715
            // Record Header
716
            $arrayReturn['length'] += 8;
717
            // animationAtom
718
            // animationSound
719
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
720
        }
721
722 4
        return $arrayReturn;
723
    }
724
725
    /**
726
     * A container record that specifies information about the document.
727
     * @param string $stream
728
     * @param integer $pos
729
     * @throws \Exception
730
     * @link http://msdn.microsoft.com/en-us/library/dd947357(v=office.12).aspx
731
     */
732 4
    private function readRecordDocumentContainer($stream, $pos)
733
    {
734 4
        $documentAtom = $this->loadRecordHeader($stream, $pos);
735 4
        $pos += 8;
736 4
        if ($documentAtom['recVer'] != 0x1 || $documentAtom['recInstance'] != 0x000 || $documentAtom['recType'] != self::RT_DOCUMENTATOM) {
737
            throw new \Exception('File PowerPoint 97 in error (Location : RTDocument > DocumentAtom).');
738
        }
739 4
        $pos += $documentAtom['recLen'];
740
741 4
        $exObjList = $this->loadRecordHeader($stream, $pos);
742 4
        if ($exObjList['recVer'] == 0xF && $exObjList['recInstance'] == 0x000 && $exObjList['recType'] == self::RT_EXTERNALOBJECTLIST) {
743 1
            $pos += 8;
744
            // exObjListAtom > rh
745 1
            $exObjListAtom = $this->loadRecordHeader($stream, $pos);
746 1
            if ($exObjListAtom['recVer'] != 0x0 || $exObjListAtom['recInstance'] != 0x000 || $exObjListAtom['recType'] != self::RT_EXTERNALOBJECTLISTATOM || $exObjListAtom['recLen'] != 0x00000004) {
747
                throw new \Exception('File PowerPoint 97 in error (Location : RTDocument > DocumentAtom > exObjList > exObjListAtom).');
748
            }
749 1
            $pos += 8;
750
            // exObjListAtom > exObjIdSeed
751 1
            $pos += 4;
752
            // rgChildRec
753 1
            $exObjList['recLen'] -= 12;
754
            do {
755 1
                $childRec = $this->loadRecordHeader($stream, $pos);
756 1
                $pos += 8;
757 1
                $exObjList['recLen'] -= 8;
758 1
                switch ($childRec['recType']) {
759 1
                    case self::RT_EXTERNALHYPERLINK:
760
                        //@link : http://msdn.microsoft.com/en-us/library/dd944995(v=office.12).aspx
761
                        // exHyperlinkAtom > rh
762 1
                        $exHyperlinkAtom = $this->loadRecordHeader($stream, $pos);
763 1
                        if ($exHyperlinkAtom['recVer'] != 0x0 || $exHyperlinkAtom['recInstance'] != 0x000 || $exHyperlinkAtom['recType'] != self::RT_EXTERNALHYPERLINKATOM || $exObjListAtom['recLen'] != 0x00000004) {
764
                            throw new \Exception('File PowerPoint 97 in error (Location : RTDocument > DocumentAtom > exObjList > rgChildRec > RT_ExternalHyperlink).');
765
                        }
766 1
                        $pos += 8;
767 1
                        $exObjList['recLen'] -= 8;
768
                        // exHyperlinkAtom > exHyperlinkId
769 1
                        $exHyperlinkId = self::getInt4d($stream, $pos);
770 1
                        $pos += 4;
771 1
                        $exObjList['recLen'] -= 4;
772
773 1
                        $this->arrayHyperlinks[$exHyperlinkId] = array();
774
                        // friendlyNameAtom
775 1
                        $friendlyNameAtom  = $this->loadRecordHeader($stream, $pos);
776 1
                        if ($friendlyNameAtom['recVer'] == 0x0 && $friendlyNameAtom['recInstance'] == 0x000 && $friendlyNameAtom['recType'] == self::RT_CSTRING && $friendlyNameAtom['recLen'] % 2 == 0) {
777 1
                            $pos += 8;
778 1
                            $exObjList['recLen'] -= 8;
779 1
                            $this->arrayHyperlinks[$exHyperlinkId]['text'] = '';
780 1
                            for ($inc = 0; $inc < ($friendlyNameAtom['recLen'] / 2); $inc++) {
781 1
                                $char = self::getInt2d($stream, $pos);
782 1
                                $pos += 2;
783 1
                                $exObjList['recLen'] -= 2;
784 1
                                $this->arrayHyperlinks[$exHyperlinkId]['text'] .= chr($char);
785
                            }
786
                        }
787
                        // targetAtom
788 1
                        $targetAtom  = $this->loadRecordHeader($stream, $pos);
789 1
                        if ($targetAtom['recVer'] == 0x0 && $targetAtom['recInstance'] == 0x001 && $targetAtom['recType'] == self::RT_CSTRING && $targetAtom['recLen'] % 2 == 0) {
790 1
                            $pos += 8;
791 1
                            $exObjList['recLen'] -= 8;
792 1
                            $this->arrayHyperlinks[$exHyperlinkId]['url'] = '';
793 1
                            for ($inc = 0; $inc < ($targetAtom['recLen'] / 2); $inc++) {
794 1
                                $char = self::getInt2d($stream, $pos);
795 1
                                $pos += 2;
796 1
                                $exObjList['recLen'] -= 2;
797 1
                                $this->arrayHyperlinks[$exHyperlinkId]['url'] .= chr($char);
798
                            }
799
                        }
800
                        // locationAtom
801 1
                        $locationAtom  = $this->loadRecordHeader($stream, $pos);
802 1
                        if ($locationAtom['recVer'] == 0x0 && $locationAtom['recInstance'] == 0x003 && $locationAtom['recType'] == self::RT_CSTRING && $locationAtom['recLen'] % 2 == 0) {
803
                            $pos += 8;
804
                            $exObjList['recLen'] -= 8;
805
                            $string = '';
806
                            for ($inc = 0; $inc < ($locationAtom['recLen'] / 2); $inc++) {
807
                                $char = self::getInt2d($stream, $pos);
808
                                $pos += 2;
809
                                $exObjList['recLen'] -= 2;
810
                                $string .= chr($char);
811
                            }
812
                        }
813 1
                        break;
814
                    default:
815
                        throw new \Exception('Feature not implemented (l.'.__LINE__.' : '.dechex($childRec['recType'].')'));
816
                }
817 1
            } while ($exObjList['recLen'] > 0);
818
        }
819
820
        //@link : http://msdn.microsoft.com/en-us/library/dd907813(v=office.12).aspx
821 4
        $documentTextInfo = $this->loadRecordHeader($stream, $pos);
822 4
        if ($documentTextInfo['recVer'] == 0xF && $documentTextInfo['recInstance'] == 0x000 && $documentTextInfo['recType'] == self::RT_ENVIRONMENT) {
823 4
            $pos += 8;
824
            //@link : http://msdn.microsoft.com/en-us/library/dd952717(v=office.12).aspx
825 4
            $kinsoku = $this->loadRecordHeader($stream, $pos);
826 4
            if ($kinsoku['recVer'] == 0xF && $kinsoku['recInstance'] == 0x002 && $kinsoku['recType'] == self::RT_KINSOKU) {
827 4
                $pos += 8;
828 4
                $pos += $kinsoku['recLen'];
829
            }
830
831
            //@link : http://msdn.microsoft.com/en-us/library/dd948152(v=office.12).aspx
832 4
            $fontCollection = $this->loadRecordHeader($stream, $pos);
833 4
            if ($fontCollection['recVer'] == 0xF && $fontCollection['recInstance'] == 0x000 && $fontCollection['recType'] == self::RT_FONTCOLLECTION) {
834 4
                $pos += 8;
835
                do {
836 4
                    $fontEntityAtom = $this->loadRecordHeader($stream, $pos);
837 4
                    $pos += 8;
838 4
                    $fontCollection['recLen'] -= 8;
839 4
                    if ($fontEntityAtom['recVer'] != 0x0 || $fontEntityAtom['recInstance'] > 128 || $fontEntityAtom['recType'] != self::RT_FONTENTITYATOM) {
840
                        throw new \Exception('File PowerPoint 97 in error (Location : RTDocument > RT_Environment > RT_FontCollection > RT_FontEntityAtom).');
841
                    }
842 4
                    $string = '';
843 4
                    for ($inc = 0; $inc < 32; $inc++) {
844 4
                        $char = self::getInt2d($stream, $pos);
845 4
                        $pos += 2;
846 4
                        $fontCollection['recLen'] -= 2;
847 4
                        $string .= chr($char);
848
                    }
849 4
                    $this->arrayFonts[] = $string;
850
851
                    // lfCharSet (1 byte)
852 4
                    $pos += 1;
853 4
                    $fontCollection['recLen'] -= 1;
854
855
                    // fEmbedSubsetted (1 bit)
856
                    // unused (7 bits)
857 4
                    $pos += 1;
858 4
                    $fontCollection['recLen'] -= 1;
859
860
                    // rasterFontType (1 bit)
861
                    // deviceFontType (1 bit)
862
                    // truetypeFontType (1 bit)
863
                    // fNoFontSubstitution (1 bit)
864
                    // reserved (4 bits)
865 4
                    $pos += 1;
866 4
                    $fontCollection['recLen'] -= 1;
867
868
                    // lfPitchAndFamily (1 byte)
869 4
                    $pos += 1;
870 4
                    $fontCollection['recLen'] -= 1;
871
872 4
                    $fontEmbedData1 = $this->loadRecordHeader($stream, $pos);
873 4
                    if ($fontEmbedData1['recVer'] == 0x0 && $fontEmbedData1['recInstance'] >= 0x000 && $fontEmbedData1['recInstance'] <= 0x003 && $fontEmbedData1['recType'] == self::RT_FONTEMBEDDATABLOB) {
874
                        $pos += 8;
875
                        $fontCollection['recLen'] -= 8;
876
                        $pos += $fontEmbedData1['recLen'];
877
                        $fontCollection['recLen'] -= $fontEmbedData1['recLen'];
878
                    }
879
880 4
                    $fontEmbedData2 = $this->loadRecordHeader($stream, $pos);
881 4
                    if ($fontEmbedData2['recVer'] == 0x0 && $fontEmbedData2['recInstance'] >= 0x000 && $fontEmbedData2['recInstance'] <= 0x003 && $fontEmbedData2['recType'] == self::RT_FONTEMBEDDATABLOB) {
882
                        $pos += 8;
883
                        $fontCollection['recLen'] -= 8;
884
                        $pos += $fontEmbedData2['recLen'];
885
                        $fontCollection['recLen'] -= $fontEmbedData2['recLen'];
886
                    }
887
888 4
                    $fontEmbedData3 = $this->loadRecordHeader($stream, $pos);
889 4
                    if ($fontEmbedData3['recVer'] == 0x0 && $fontEmbedData3['recInstance'] >= 0x000 && $fontEmbedData3['recInstance'] <= 0x003 && $fontEmbedData3['recType'] == self::RT_FONTEMBEDDATABLOB) {
890
                        $pos += 8;
891
                        $fontCollection['recLen'] -= 8;
892
                        $pos += $fontEmbedData3['recLen'];
893
                        $fontCollection['recLen'] -= $fontEmbedData3['recLen'];
894
                    }
895
896 4
                    $fontEmbedData4 = $this->loadRecordHeader($stream, $pos);
897 4
                    if ($fontEmbedData4['recVer'] == 0x0 && $fontEmbedData4['recInstance'] >= 0x000 && $fontEmbedData4['recInstance'] <= 0x003 && $fontEmbedData4['recType'] == self::RT_FONTEMBEDDATABLOB) {
898
                        $pos += 8;
899
                        $fontCollection['recLen'] -= 8;
900
                        $pos += $fontEmbedData4['recLen'];
901
                        $fontCollection['recLen'] -= $fontEmbedData4['recLen'];
902
                    }
903 4
                } while ($fontCollection['recLen'] > 0);
904
            }
905
906 4
            $textCFDefaultsAtom = $this->loadRecordHeader($stream, $pos);
907 4
            if ($textCFDefaultsAtom['recVer'] == 0x0 && $textCFDefaultsAtom['recInstance'] == 0x000 && $textCFDefaultsAtom['recType'] == self::RT_TEXTCHARFORMATEXCEPTIONATOM) {
908 4
                $pos += 8;
909 4
                $pos += $textCFDefaultsAtom['recLen'];
910
            }
911
912 4
            $textPFDefaultsAtom = $this->loadRecordHeader($stream, $pos);
913 4
            if ($textPFDefaultsAtom['recVer'] == 0x0 && $textPFDefaultsAtom['recInstance'] == 0x000 && $textPFDefaultsAtom['recType'] == self::RT_TEXTPARAGRAPHFORMATEXCEPTIONATOM) {
914
                $pos += 8;
915
                $pos += $textPFDefaultsAtom['recLen'];
916
            }
917
918 4
            $defaultRulerAtom = $this->loadRecordHeader($stream, $pos);
919 4
            if ($defaultRulerAtom['recVer'] == 0x0 && $defaultRulerAtom['recInstance'] == 0x000 && $defaultRulerAtom['recType'] == self::RT_DEFAULTRULERATOM) {
920
                $pos += 8;
921
                $pos += $defaultRulerAtom['recLen'];
922
            }
923
924 4
            $textSIDefaultsAtom = $this->loadRecordHeader($stream, $pos);
925 4
            if ($textSIDefaultsAtom['recVer'] == 0x0 && $textSIDefaultsAtom['recInstance'] == 0x000 && $textSIDefaultsAtom['recType'] == self::RT_TEXTSPECIALINFODEFAULTATOM) {
926 4
                $pos += 8;
927 4
                $pos += $textSIDefaultsAtom['recLen'];
928
            }
929
930 4
            $textMasterStyleAtom = $this->loadRecordHeader($stream, $pos);
931 4
            if ($textMasterStyleAtom['recVer'] == 0x0 && $textMasterStyleAtom['recType'] == self::RT_TEXTMASTERSTYLEATOM) {
932 4
                $pos += 8;
933 4
                $pos += $textMasterStyleAtom['recLen'];
934
            }
935
        }
936
937 4
        $soundCollection = $this->loadRecordHeader($stream, $pos);
938 4
        if ($soundCollection['recVer'] == 0xF && $soundCollection['recInstance'] == 0x005 && $soundCollection['recType'] == self::RT_SOUNDCOLLECTION) {
939
            $pos += 8;
940
            $pos += $soundCollection['recLen'];
941
        }
942
943 4
        $drawingGroup = $this->loadRecordHeader($stream, $pos);
944 4
        if ($drawingGroup['recVer'] == 0xF && $drawingGroup['recInstance'] == 0x000 && $drawingGroup['recType'] == self::RT_DRAWINGGROUP) {
945 4
            $drawing = $this->readRecordDrawingGroupContainer($stream, $pos);
946 4
            $pos += 8;
947 4
            $pos += $drawing['length'];
948
        }
949
950 4
        $masterList = $this->loadRecordHeader($stream, $pos);
951 4
        if ($masterList['recVer'] == 0xF && $masterList['recInstance'] == 0x001 && $masterList['recType'] == self::RT_SLIDELISTWITHTEXT) {
952
            $pos += 8;
953
            $pos += $masterList['recLen'];
954
        }
955
956 4
        $docInfoList = $this->loadRecordHeader($stream, $pos);
957 4
        if ($docInfoList['recVer'] == 0xF && $docInfoList['recInstance'] == 0x000 && $docInfoList['recType'] == self::RT_LIST) {
958
            $pos += 8;
959
            $pos += $docInfoList['recLen'];
960
        }
961
962 4
        $slideHF = $this->loadRecordHeader($stream, $pos);
963 4
        if ($slideHF['recVer'] == 0xF && $slideHF['recInstance'] == 0x003 && $slideHF['recType'] == self::RT_HEADERSFOOTERS) {
964
            $pos += 8;
965
            $pos += $slideHF['recLen'];
966
        }
967
968 4
        $notesHF = $this->loadRecordHeader($stream, $pos);
969 4
        if ($notesHF['recVer'] == 0xF && $notesHF['recInstance'] == 0x004 && $notesHF['recType'] == self::RT_HEADERSFOOTERS) {
970
            $pos += 8;
971
            $pos += $notesHF['recLen'];
972
        }
973
974
        // SlideListWithTextContainer
975 4
        $slideList = $this->loadRecordHeader($stream, $pos);
976 4
        if ($slideList['recVer'] == 0xF && $slideList['recInstance'] == 0x000 && $slideList['recType'] == self::RT_SLIDELISTWITHTEXT) {
977
            $pos += 8;
978
            do {
979
                // SlideListWithTextSubContainerOrAtom
980
                $rhSlideList = $this->loadRecordHeader($stream, $pos);
981
                if ($rhSlideList['recVer'] == 0x0 && $rhSlideList['recInstance'] == 0x000 && $rhSlideList['recType'] == self::RT_SLIDEPERSISTATOM && $rhSlideList['recLen'] == 0x00000014) {
982
                    $pos += 8;
983
                    $slideList['recLen'] -= 8;
984
                    // persistIdRef
985
                    $pos += 4;
986
                    $slideList['recLen'] -= 4;
987
                    // reserved1 - fShouldCollapse - fNonOutlineData - reserved2
988
                    $pos += 4;
989
                    $slideList['recLen'] -= 4;
990
                    // cTexts
991
                    $pos += 4;
992
                    $slideList['recLen'] -= 4;
993
                    // slideId
994
                    $slideId = self::getInt4d($stream, $pos);
995
                    if ($slideId == -2147483648) {
996
                        $slideId = 0;
997
                    }
998
                    if ($slideId > 0) {
999
                        $this->arrayNotes[$this->oPhpPresentation->getActiveSlideIndex()] = $slideId;
1000
                    }
1001
                    $pos += 4;
1002
                    $slideList['recLen'] -= 4;
1003
                    // reserved3
1004
                    $pos += 4;
1005
                    $slideList['recLen'] -= 4;
1006
                }
1007
            } while ($slideList['recLen'] > 0);
1008
        }
1009 4
    }
1010
1011
    /**
1012
     * An atom record that specifies information about a slide.
1013
     * @param string $stream
1014
     * @param integer $pos
1015
     * @return array
1016
     * @throws \Exception
1017
     * @link https://msdn.microsoft.com/en-us/library/dd923801(v=office.12).aspx
1018
     */
1019 4
    private function readRecordDrawingContainer($stream, $pos)
1020
    {
1021
        $arrayReturn = array(
1022 4
            'length' => 0,
1023
        );
1024
1025 4
        $data = $this->loadRecordHeader($stream, $pos);
1026 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_DRAWING) {
1027
            // Record Header
1028 4
            $arrayReturn['length'] += 8;
1029
1030 4
            $officeArtDg = $this->readRecordOfficeArtDgContainer($stream, $pos + $arrayReturn['length']);
1031 4
            $arrayReturn['length'] += $officeArtDg['length'];
1032
        }
1033 4
        return $arrayReturn;
1034
    }
1035
1036 4
    private function readRecordDrawingGroupContainer($stream, $pos)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
1037
    {
1038
1039
        $arrayReturn = array(
1040 4
            'length' => 0,
1041
        );
1042
1043 4
        $data = $this->loadRecordHeader($stream, $pos);
1044 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_DRAWINGGROUP) {
1045
            // Record Header
1046 4
            $arrayReturn['length'] += 8;
1047 4
            $arrayReturn['length'] += $data['recLen'];
1048
        }
1049 4
        return $arrayReturn;
1050
    }
1051
1052
    /**
1053
     * An atom record that specifies a reference to an external object.
1054
     * @param string $stream
1055
     * @param integer $pos
1056
     * @return array
1057
     * @link https://msdn.microsoft.com/en-us/library/dd910388(v=office.12).aspx
1058
     */
1059 4
    private function readRecordExObjRefAtom($stream, $pos)
1060
    {
1061
        $arrayReturn = array(
1062 4
            'length' => 0,
1063
        );
1064
1065 4
        $data = $this->loadRecordHeader($stream, $pos);
1066 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_EXTERNALOBJECTREFATOM && $data['recLen'] == 0x00000004) {
1067
            // Record Header
1068
            $arrayReturn['length'] += 8;
1069
            // Datas
1070
            $arrayReturn['length'] += $data['recLen'];
1071
        }
1072
1073 4
        return $arrayReturn;
1074
    }
1075
1076
    /**
1077
     * An atom record that specifies a type of action to be performed.
1078
     * @param string $stream
1079
     * @param integer $pos
1080
     * @return array
1081
     * @link https://msdn.microsoft.com/en-us/library/dd953300(v=office.12).aspx
1082
     */
1083 1
    private function readRecordInteractiveInfoAtom($stream, $pos)
1084
    {
1085
        $arrayReturn = array(
1086 1
            'length' => 0,
1087
        );
1088
1089 1
        $data = $this->loadRecordHeader($stream, $pos);
1090 1
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_INTERACTIVEINFOATOM && $data['recLen'] == 0x00000010) {
1091
            // Record Header
1092 1
            $arrayReturn['length'] += 8;
1093
            // soundIdRef
1094 1
            $arrayReturn['length'] += 4;
1095
            // exHyperlinkIdRef
1096 1
            $arrayReturn['exHyperlinkIdRef'] = self::getInt4d($stream, $pos + $arrayReturn['length']);
1097 1
            $arrayReturn['length'] += 4;
1098
            // action
1099 1
            $arrayReturn['length'] += 1;
1100
            // oleVerb
1101 1
            $arrayReturn['length'] += 1;
1102
            // jump
1103 1
            $arrayReturn['length'] += 1;
1104
            // fAnimated (1 bit)
1105
            // fStopSound (1 bit)
1106
            // fCustomShowReturn (1 bit)
1107
            // fVisited (1 bit)
1108
            // reserved (4 bits)
1109 1
            $arrayReturn['length'] += 1;
1110
            // hyperlinkType
1111 1
            $arrayReturn['length'] += 1;
1112
            // unused
1113 1
            $arrayReturn['length'] += 3;
1114
        }
1115
1116 1
        return $arrayReturn;
1117
    }
1118
1119
    /**
1120
     * An atom record that specifies the name of a macro, a file name, or a named show.
1121
     * @param string $stream
1122
     * @param integer $pos
1123
     * @return array
1124
     * @link https://msdn.microsoft.com/en-us/library/dd925121(v=office.12).aspx
1125
     */
1126 1
    private function readRecordMacroNameAtom($stream, $pos)
1127
    {
1128
        $arrayReturn = array(
1129 1
            'length' => 0,
1130
        );
1131
1132 1
        $data = $this->loadRecordHeader($stream, $pos);
1133 1
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x002 && $data['recType'] == self::RT_CSTRING && $data['recLen'] % 2 == 0) {
1134
            // Record Header
1135
            $arrayReturn['length'] += 8;
1136
            // Datas
1137
            $arrayReturn['length'] += $data['recLen'];
1138
        }
1139
1140 1
        return $arrayReturn;
1141
    }
1142
1143
    /**
1144
     * A container record that specifies what actions to perform when interacting with an object by means of a mouse click.
1145
     * @param string $stream
1146
     * @param integer $pos
1147
     * @return array
1148
     * @link https://msdn.microsoft.com/en-us/library/dd952348(v=office.12).aspx
1149
     */
1150 4
    private function readRecordMouseClickInteractiveInfoContainer($stream, $pos)
1151
    {
1152
        $arrayReturn = array(
1153 4
            'length' => 0,
1154
        );
1155
1156 4
        $data = $this->loadRecordHeader($stream, $pos);
1157 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_INTERACTIVEINFO) {
1158
            // Record Header
1159 1
            $arrayReturn['length'] += 8;
1160
            // interactiveInfoAtom
1161 1
            $interactiveInfoAtom = $this->readRecordInteractiveInfoAtom($stream, $pos + $arrayReturn['length']);
1162 1
            $arrayReturn['length'] += $interactiveInfoAtom['length'];
1163 1
            if ($interactiveInfoAtom['length'] > 0) {
1164 1
                $arrayReturn['exHyperlinkIdRef'] = $interactiveInfoAtom['exHyperlinkIdRef'];
1165
            }
1166
            // macroNameAtom
1167 1
            $macroNameAtom = $this->readRecordMacroNameAtom($stream, $pos + $arrayReturn['length']);
1168 1
            $arrayReturn['length'] += $macroNameAtom['length'];
1169
        }
1170
1171 4
        return $arrayReturn;
1172
    }
1173
1174
    /**
1175
     * A container record that specifies what actions to perform when interacting with an object by moving the mouse cursor over it.
1176
     * @param string $stream
1177
     * @param integer $pos
1178
     * @return array
1179
     * @throws \Exception
1180
     * @link https://msdn.microsoft.com/en-us/library/dd925811(v=office.12).aspx
1181
     */
1182 4
    private function readRecordMouseOverInteractiveInfoContainer($stream, $pos)
1183
    {
1184
        $arrayReturn = array(
1185 4
            'length' => 0,
1186
        );
1187
1188 4
        $data = $this->loadRecordHeader($stream, $pos);
1189 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x001 && $data['recType'] == self::RT_INTERACTIVEINFO) {
1190
            // Record Header
1191
            $arrayReturn['length'] += 8;
1192
            // interactiveInfoAtom
1193
            // macroNameAtom
1194
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
1195
        }
1196
1197 4
        return $arrayReturn;
1198
    }
1199
1200
    /**
1201
     * The OfficeArtBlip record specifies BLIP file data.
1202
     * @param string $stream
1203
     * @param integer $pos
1204
     * @return array
1205
     * @throws \Exception
1206
     * @link https://msdn.microsoft.com/en-us/library/dd910081(v=office.12).aspx
1207
     */
1208 4
    private function readRecordOfficeArtBlip($stream, $pos)
1209
    {
1210
        $arrayReturn = array(
1211 4
            'length' => 0,
1212
            'picture' => null
1213
        );
1214
1215 4
        $data = $this->loadRecordHeader($stream, $pos);
1216 4
        if ($data['recVer'] == 0x0 && ($data['recType'] >= 0xF018 && $data['recType'] <= 0xF117)) {
1217
            // Record Header
1218 4
            $arrayReturn['length'] += 8;
1219
            // Datas
1220 4
            switch ($data['recType']) {
1221 4
                case self::OFFICEARTBLIPJPG:
1222 3
                case self::OFFICEARTBLIPPNG:
1223
                    // rgbUid1
1224 4
                    $arrayReturn['length'] += 16;
1225 4
                    $data['recLen'] -= 16;
1226 4
                    if ($data['recInstance'] == 0x6E1) {
1227
                        // rgbUid2
1228
                        $arrayReturn['length'] += 16;
1229
                        $data['recLen'] -= 16;
1230
                    }
1231
                    // tag
1232 4
                    $arrayReturn['length'] += 1;
1233 4
                    $data['recLen'] -= 1;
1234
                    // BLIPFileData
1235 4
                    $arrayReturn['picture'] = substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']);
1236 4
                    $arrayReturn['length'] += $data['recLen'];
1237 4
                    break;
1238
                default:
1239
                    throw new \Exception('Feature not implemented (l.'.__LINE__.' : '.dechex($data['recType'].')'));
1240
            }
1241
        }
1242
1243 4
        return $arrayReturn;
1244
    }
1245
1246
    /**
1247
     * The OfficeArtChildAnchor record specifies four signed integers that specify the anchor for the shape that contains this record.
1248
     * @param string $stream
1249
     * @param integer $pos
1250
     * @return array
1251
     * @link https://msdn.microsoft.com/en-us/library/dd922720(v=office.12).aspx
1252
     */
1253 4
    private function readRecordOfficeArtChildAnchor($stream, $pos)
1254
    {
1255
        $arrayReturn = array(
1256 4
            'length' => 0
1257
        );
1258
1259 4
        $data = $this->loadRecordHeader($stream, $pos);
1260 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == 0xF00F && $data['recLen'] == 0x00000010) {
1261
            // Record Header
1262
            $arrayReturn['length'] += 8;
1263
            // Datas
1264
            $arrayReturn['left'] = (int) self::getInt4d($stream, $pos + $arrayReturn['length']);
1265
            $arrayReturn['length'] += 4;
1266
            $arrayReturn['top'] = (int) self::getInt4d($stream, $pos + $arrayReturn['length']);
1267
            $arrayReturn['length'] += 4;
1268
            $arrayReturn['width'] = (int) self::getInt4d($stream, $pos + $arrayReturn['length']) - $arrayReturn['left'];
1269
            $arrayReturn['length'] += 4;
1270
            $arrayReturn['height'] = (int) self::getInt4d($stream, $pos + $arrayReturn['length']) - $arrayReturn['top'];
1271
            $arrayReturn['length'] += 4;
1272
        }
1273
1274 4
        return $arrayReturn;
1275
    }
1276
1277
    /**
1278
     * An atom record that specifies the location of a shape.
1279
     * @param string $stream
1280
     * @param integer $pos
1281
     * @return array
1282
     * @throws \Exception
1283
     * @link https://msdn.microsoft.com/en-us/library/dd922797(v=office.12).aspx
1284
     */
1285 4
    private function readRecordOfficeArtClientAnchor($stream, $pos)
1286
    {
1287
        $arrayReturn = array(
1288 4
            'length' => 0
1289
        );
1290
1291 4
        $data = $this->loadRecordHeader($stream, $pos);
1292 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == 0xF010 && ($data['recLen'] == 0x00000008 || $data['recLen'] == 0x00000010)) {
1293
            // Record Header
1294 4
            $arrayReturn['length'] += 8;
1295
            // Datas
1296 4
            switch ($data['recLen']) {
1297 4
                case 0x00000008:
1298 4
                    $arrayReturn['top'] = (int) (self::getInt2d($stream, $pos + $arrayReturn['length']) / 6);
1299 4
                    $arrayReturn['length'] += 2;
1300 4
                    $arrayReturn['left'] = (int) (self::getInt2d($stream, $pos + $arrayReturn['length']) / 6);
1301 4
                    $arrayReturn['length'] += 2;
1302 4
                    $arrayReturn['width'] = (int) (self::getInt2d($stream, $pos + $arrayReturn['length']) / 6) - $arrayReturn['left'];
1303 4
                    $arrayReturn['length'] += 2;
1304 4
                    $arrayReturn['height'] = (int) (self::getInt2d($stream, $pos + $arrayReturn['length']) / 6) - $arrayReturn['left'];
1305 4
                    $arrayReturn['length'] += 2;
1306 4
                    $pos += 8;
1307 4
                    break;
1308
                case 0x00000010:
1309
                    throw new \Exception('PowerPoint97 Reader : record OfficeArtClientAnchor (0x00000010)');
1310
            }
1311
        }
1312
1313 4
        return $arrayReturn;
1314
    }
1315
1316
    /**
1317
     * A container record that specifies text related data for a shape.
1318
     * @param string $stream
1319
     * @param integer $pos
1320
     * @return array
1321
     * @throws \Exception
1322
     * @link https://msdn.microsoft.com/en-us/library/dd910958(v=office.12).aspx
1323
     */
1324 4
    private function readRecordOfficeArtClientTextbox($stream, $pos)
1325
    {
1326
        $arrayReturn = array(
1327 4
            'length' => 0,
1328
            'text' => '',
1329
            'numParts' => 0,
1330
            'numTexts' => 0,
1331
            'hyperlink' => array(),
1332
        );
1333
1334 4
        $data = $this->loadRecordHeader($stream, $pos);
1335
        // recVer 0xF
1336
        // Doc : 0x0    https://msdn.microsoft.com/en-us/library/dd910958(v=office.12).aspx
1337
        // Sample : 0xF https://msdn.microsoft.com/en-us/library/dd953497(v=office.12).aspx
1338 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == 0xF00D) {
1339
            // Record Header
1340 4
            $arrayReturn['length'] += 8;
1341
            // Datas
1342 4
            $strLen = 0;
1343
            do {
1344 4
                $rhChild = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
1345
                /**
1346
                 * @link : https://msdn.microsoft.com/en-us/library/dd947039(v=office.12).aspx
1347
                 */
1348
                // echo dechex($rhChild['recType']).'-'.$rhChild['recType'].EOL;
1349 4
                switch ($rhChild['recType']) {
1350 4
                    case self::RT_INTERACTIVEINFO:
1351
                        //@link : http://msdn.microsoft.com/en-us/library/dd948623(v=office.12).aspx
1352 1
                        if ($rhChild['recInstance'] == 0x0000) {
1353 1
                            $mouseClickInfo = $this->readRecordMouseClickInteractiveInfoContainer($stream, $pos + $arrayReturn['length']);
1354 1
                            $arrayReturn['length'] += $mouseClickInfo['length'];
1355 1
                            $arrayReturn['hyperlink'][]['id'] = $mouseClickInfo['exHyperlinkIdRef'];
1356
                        }
1357 1
                        if ($rhChild['recInstance'] == 0x0001) {
1358
                            $mouseOverInfo = $this->readRecordMouseOverInteractiveInfoContainer($stream, $pos + $arrayReturn['length']);
1359
                            $arrayReturn['length'] += $mouseOverInfo['length'];
1360
                        }
1361 1
                        break;
1362 4
                    case self::RT_STYLETEXTPROPATOM:
1363 4
                        $arrayReturn['length'] += 8;
1364
                        // @link : http://msdn.microsoft.com/en-us/library/dd950647(v=office.12).aspx
1365
                        // rgTextPFRun
1366 4
                        $strLenRT = $strLen + 1;
1367
                        do {
1368 4
                            $strucTextPFRun = $this->readStructureTextPFRun($stream, $pos + $arrayReturn['length'], $strLenRT);
1369 4
                            $arrayReturn['numTexts']++;
1370 4
                            $arrayReturn['text'.$arrayReturn['numTexts']] = $strucTextPFRun;
1371 4
                            if (isset($strucTextPFRun['alignH'])) {
1372 4
                                $arrayReturn['alignH'] = $strucTextPFRun['alignH'];
1373
                            }
1374 4
                            $strLenRT = $strucTextPFRun['strLenRT'];
1375 4
                            $arrayReturn['length'] += $strucTextPFRun['length'];
1376 4
                        } while ($strLenRT > 0);
1377
                        // rgTextCFRun
1378 4
                        $strLenRT = $strLen + 1;
1379
                        do {
1380 4
                            $strucTextCFRun = $this->readStructureTextCFRun($stream, $pos + $arrayReturn['length'], $strLenRT);
1381 4
                            $arrayReturn['numParts']++;
1382 4
                            $arrayReturn['part'.$arrayReturn['numParts']] = $strucTextCFRun;
1383 4
                            $strLenRT = $strucTextCFRun['strLenRT'];
1384 4
                            $arrayReturn['length'] += $strucTextCFRun['length'];
1385 4
                        } while ($strLenRT > 0);
1386 4
                        break;
1387 4
                    case self::RT_TEXTBYTESATOM:
1388
                        $arrayReturn['length'] += 8;
1389
                        // @link : https://msdn.microsoft.com/en-us/library/dd947905(v=office.12).aspx
1390
                        $strLen = (int)$rhChild['recLen'];
1391
                        for ($inc = 0; $inc < $strLen; $inc++) {
1392
                            $char = self::getInt1d($stream, $pos + $arrayReturn['length']);
1393
                            if ($char == 0x0B) {
1394
                                $char = 0x20;
1395
                            }
1396
                            $arrayReturn['text'] .= Text::chr($char);
1397
                            $arrayReturn['length'] += 1;
1398
                        }
1399
                        break;
1400 4
                    case self::RT_TEXTCHARSATOM:
1401 4
                        $arrayReturn['length'] += 8;
1402
                        // @link : http://msdn.microsoft.com/en-us/library/dd772921(v=office.12).aspx
1403 4
                        $strLen = (int)($rhChild['recLen']/2);
1404 4
                        for ($inc = 0; $inc < $strLen; $inc++) {
1405 4
                            $char = self::getInt2d($stream, $pos + $arrayReturn['length']);
1406 4
                            if ($char == 0x0B) {
1407 1
                                $char = 0x20;
1408
                            }
1409 4
                            $arrayReturn['text'] .= Text::chr($char);
1410 4
                            $arrayReturn['length'] += 2;
1411
                        }
1412 4
                        break;
1413 4
                    case self::RT_TEXTHEADERATOM:
1414 4
                        $arrayReturn['length'] += 8;
1415
                        // @link : http://msdn.microsoft.com/en-us/library/dd905272(v=office.12).aspx
1416
                        // textType
1417 4
                        $arrayReturn['length'] += 4;
1418 4
                        break;
1419 4
                    case self::RT_TEXTINTERACTIVEINFOATOM:
1420 1
                        $arrayReturn['length'] += 8;
1421
                        //@link : http://msdn.microsoft.com/en-us/library/dd947973(v=office.12).aspx
1422 1
                        if ($rhChild['recInstance'] == 0x0000) {
1423
                            //@todo : MouseClickTextInteractiveInfoAtom
1424 1
                            $arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['start'] = self::getInt4d($stream, $pos +  + $arrayReturn['length']);
1425 1
                            $arrayReturn['length'] += 4;
1426
1427 1
                            $arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['end'] = self::getInt4d($stream, $pos +  + $arrayReturn['length']);
1428 1
                            $arrayReturn['length'] += 4;
1429
                        }
1430 1
                        if ($rhChild['recInstance'] == 0x0001) {
1431
                            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
1432
                        }
1433 1
                        break;
1434 4
                    case self::RT_TEXTSPECIALINFOATOM:
1435 4
                        $arrayReturn['length'] += 8;
1436
                        // @link : http://msdn.microsoft.com/en-us/library/dd945296(v=office.12).aspx
1437 4
                        $strLenRT = $strLen + 1;
1438
                        do {
1439 4
                            $structTextSIRun = $this->readStructureTextSIRun($stream, $pos + $arrayReturn['length'], $strLenRT);
1440 4
                            $strLenRT = $structTextSIRun['strLenRT'];
1441 4
                            $arrayReturn['length'] += $structTextSIRun['length'];
1442 4
                        } while ($strLenRT > 0);
1443 4
                        break;
1444 4
                    case self::RT_TEXTRULERATOM:
1445 4
                        $arrayReturn['length'] += 8;
1446
                        // @link : http://msdn.microsoft.com/en-us/library/dd953212(v=office.12).aspx
1447 4
                        $structRuler = $this->readStructureTextRuler($stream, $pos + $arrayReturn['length']);
1448 4
                        $arrayReturn['length'] += $structRuler['length'];
1449 4
                        break;
1450 4
                    case self::RT_SLIDENUMBERMETACHARATOM:
1451 4
                        $datasRecord = $this->readRecordSlideNumberMCAtom($stream, $pos + $arrayReturn['length']);
1452 4
                        $arrayReturn['length'] += $datasRecord['length'];
1453 4
                        break;
1454
                    default:
1455 4
                        $arrayReturn['length'] += 8;
1456 4
                        $arrayReturn['length'] += $rhChild['recLen'];
1457
                    // throw new \Exception('Feature not implemented (l.'.__LINE__.' : 0x'.dechex($rhChild['recType']).')');
1458
                }
1459 4
            } while (($data['recLen'] - $arrayReturn['length']) > 0);
1460
        }
1461 4
        return $arrayReturn;
1462
    }
1463
1464
    /**
1465
     * The OfficeArtSpContainer record specifies a shape container.
1466
     * @param string $stream
1467
     * @param integer $pos
1468
     * @return array
1469
     * @throws \Exception
1470
     * @link https://msdn.microsoft.com/en-us/library/dd943794(v=office.12).aspx
1471
     */
1472 4
    private function readRecordOfficeArtSpContainer($stream, $pos)
1473
    {
1474
        $arrayReturn = array(
1475 4
            'length' => 0,
1476
            'shape' => null,
1477
        );
1478
1479 4
        $data = $this->loadRecordHeader($stream, $pos);
1480 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == 0xF004) {
1481
            // Record Header
1482 4
            $arrayReturn['length'] += 8;
1483
            // shapeGroup
1484 4
            $shapeGroup = $this->readRecordOfficeArtFSPGR($stream, $pos + $arrayReturn['length']);
1485 4
            $arrayReturn['length'] += $shapeGroup['length'];
1486
1487
            // shapeProp
1488 4
            $shapeProp = $this->readRecordOfficeArtFSP($stream, $pos + $arrayReturn['length']);
1489 4
            if ($shapeProp['length'] == 0) {
1490
                throw new \Exception('PowerPoint97 Reader : record OfficeArtFSP');
1491
            }
1492 4
            $arrayReturn['length'] += $shapeProp['length'];
1493
1494 4
            if ($shapeProp['fDeleted'] == 0x1 && $shapeProp['fChild'] == 0x0) {
1495
                // deletedShape
1496
                $deletedShape = $this->readRecordOfficeArtFPSPL($stream, $pos + $arrayReturn['length']);
1497
                $arrayReturn['length'] += $deletedShape['length'];
1498
            }
1499
1500
            // shapePrimaryOptions
1501 4
            $shpPrimaryOptions = $this->readRecordOfficeArtFOPT($stream, $pos + $arrayReturn['length']);
1502 4
            $arrayReturn['length'] += $shpPrimaryOptions['length'];
1503
1504
            // shapeSecondaryOptions1
1505 4
            $shpSecondaryOptions1 = $this->readRecordOfficeArtSecondaryFOPT($stream, $pos + $arrayReturn['length']);
1506 4
            $arrayReturn['length'] += $shpSecondaryOptions1['length'];
1507
1508
            // shapeTertiaryOptions1
1509 4
            $shpTertiaryOptions1 = $this->readRecordOfficeArtTertiaryFOPT($stream, $pos + $arrayReturn['length']);
1510 4
            $arrayReturn['length'] += $shpTertiaryOptions1['length'];
1511
1512
            // childAnchor
1513 4
            $childAnchor = $this->readRecordOfficeArtChildAnchor($stream, $pos + $arrayReturn['length']);
1514 4
            $arrayReturn['length'] += $childAnchor['length'];
1515
1516
            // clientAnchor
1517 4
            $clientAnchor = $this->readRecordOfficeArtClientAnchor($stream, $pos + $arrayReturn['length']);
1518 4
            $arrayReturn['length'] += $clientAnchor['length'];
1519
1520
            // clientData
1521 4
            $clientData = $this->readRecordOfficeArtClientData($stream, $pos + $arrayReturn['length']);
1522 4
            $arrayReturn['length'] += $clientData['length'];
1523
1524
            // clientTextbox
1525 4
            $clientTextbox = $this->readRecordOfficeArtClientTextbox($stream, $pos + $arrayReturn['length']);
1526 4
            $arrayReturn['length'] += $clientTextbox['length'];
1527
1528
            // shapeSecondaryOptions2
1529 4
            if ($shpSecondaryOptions1['length'] == 0) {
1530 4
                $shpSecondaryOptions2 = $this->readRecordOfficeArtSecondaryFOPT($stream, $pos + $arrayReturn['length']);
1531 4
                $arrayReturn['length'] += $shpSecondaryOptions2['length'];
1532
            }
1533
1534
            // shapeTertiaryOptions2
1535 4
            if ($shpTertiaryOptions1['length'] == 0) {
1536 4
                $shpTertiaryOptions2 = $this->readRecordOfficeArtTertiaryFOPT($stream, $pos + $arrayReturn['length']);
1537 4
                $arrayReturn['length'] += $shpTertiaryOptions2['length'];
1538
            }
1539
1540
            // Core : Shape
1541
            // Informations about group are not defined
1542 4
            $arrayDimensions = array();
1543 4
            $bIsGroup = false;
1544 4
            if (is_object($this->oCurrentGroup)) {
1545
                if (!$this->bFirstShapeGroup) {
1546
                    if ($clientAnchor['length'] > 0) {
1547
                        // $this->oCurrentGroup->setOffsetX($clientAnchor['left']);
1548
                        // $this->oCurrentGroup->setOffsetY($clientAnchor['top']);
1549
                        // $this->oCurrentGroup->setHeight($clientAnchor['height']);
1550
                        // $this->oCurrentGroup->setWidth($clientAnchor['width']);
1551
                    }
1552
                    $bIsGroup = true;
1553
                    $this->bFirstShapeGroup = true;
1554
                } elseif ($childAnchor['length'] > 0) {
1555
                    $arrayDimensions = $childAnchor;
1556
                }
1557 4
            } elseif ($clientAnchor['length'] > 0) {
1558 4
                $arrayDimensions = $clientAnchor;
1559
            }
1560 4
            if (!$bIsGroup) {
1561
                // *** Shape ***
1562 4
                if (isset($shpPrimaryOptions['pib'])) {
1563
                    // isDrawing
1564 4
                    $drawingPib = $shpPrimaryOptions['pib'];
1565 4
                    if (isset($this->arrayPictures[$drawingPib - 1])) {
1566 4
                        $gdImage = imagecreatefromstring($this->arrayPictures[$drawingPib - 1]);
1567 4
                        $arrayReturn['shape'] = new Drawing\Gd();
1568 4
                        $arrayReturn['shape']->setImageResource($gdImage);
1569
                    }
1570 4
                } elseif (isset($shpPrimaryOptions['line']) && $shpPrimaryOptions['line']) {
1571
                    // isLine
1572 1
                    $arrayReturn['shape'] = new Line(0, 0, 0, 0);
1573 4
                } elseif ($clientTextbox['length'] > 0) {
1574 4
                    $arrayReturn['shape'] = new RichText();
1575 4
                    if (isset($clientTextbox['alignH'])) {
1576 4
                        $arrayReturn['shape']->getActiveParagraph()->getAlignment()->setHorizontal($clientTextbox['alignH']);
1577
                    }
1578
1579 4
                    $start = 0;
1580 4
                    $lastLevel = -1;
1581 4
                    $lastMarginLeft = 0;
1582 4
                    for ($inc = 1; $inc <= $clientTextbox['numParts']; $inc++) {
1583 4
                        if ($clientTextbox['numParts'] == $clientTextbox['numTexts'] && isset($clientTextbox['text'.$inc])) {
1584 4
                            if (isset($clientTextbox['text'.$inc]['bulletChar'])) {
1585 1
                                $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
1586 1
                                $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletChar($clientTextbox['text'.$inc]['bulletChar']);
1587
                            }
1588
                            // Indent
1589 4
                            $indent = 0;
1590 4
                            if (isset($clientTextbox['text'.$inc]['indent'])) {
1591 1
                                $indent = $clientTextbox['text'.$inc]['indent'];
1592
                            }
1593 4
                            if (isset($clientTextbox['text'.$inc]['leftMargin'])) {
1594 1
                                if ($lastMarginLeft > $clientTextbox['text'.$inc]['leftMargin']) {
1595 1
                                    $lastLevel--;
1596
                                }
1597 1
                                if ($lastMarginLeft < $clientTextbox['text'.$inc]['leftMargin']) {
1598 1
                                    $lastLevel++;
1599
                                }
1600 1
                                $arrayReturn['shape']->getActiveParagraph()->getAlignment()->setLevel($lastLevel);
1601 1
                                $lastMarginLeft = $clientTextbox['text'.$inc]['leftMargin'];
1602
1603 1
                                $arrayReturn['shape']->getActiveParagraph()->getAlignment()->setMarginLeft($clientTextbox['text'.$inc]['leftMargin']);
1604 1
                                $arrayReturn['shape']->getActiveParagraph()->getAlignment()->setIndent($indent - $clientTextbox['text'.$inc]['leftMargin']);
1605
                            }
1606
                        }
1607
                        // Texte
1608 4
                        $sText = substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part'.$inc]['partLength']);
1609 4
                        $sHyperlinkURL = '';
1610 4
                        if (empty($sText)) {
1611
                            // Is there a hyperlink ?
1612 1
                            if (isset($clientTextbox['hyperlink']) && is_array($clientTextbox['hyperlink']) && !empty($clientTextbox['hyperlink'])) {
1613 1
                                foreach ($clientTextbox['hyperlink'] as $itmHyperlink) {
1614 1
                                    if ($itmHyperlink['start'] == $start && ($itmHyperlink['end'] - $itmHyperlink['start']) == $clientTextbox['part'.$inc]['partLength']) {
1615 1
                                        $sText = $this->arrayHyperlinks[$itmHyperlink['id']]['text'];
1616 1
                                        $sHyperlinkURL = $this->arrayHyperlinks[$itmHyperlink['id']]['url'];
1617 1
                                        break;
1618
                                    }
1619
                                }
1620
                            }
1621
                        }
1622
                        // New paragraph
1623 4
                        $bCreateParagraph = false;
1624 4
                        if (strpos($sText, "\r") !== false) {
1625 1
                            $bCreateParagraph = true;
1626 1
                            $sText = str_replace("\r", '', $sText);
1627
                        }
1628
                        // TextRun
1629 4
                        $txtRun = $arrayReturn['shape']->createTextRun($sText);
1630 4
                        if (isset($clientTextbox['part'.$inc]['bold'])) {
1631 3
                            $txtRun->getFont()->setBold($clientTextbox['part'.$inc]['bold']);
1632
                        }
1633 4
                        if (isset($clientTextbox['part'.$inc]['italic'])) {
1634 3
                            $txtRun->getFont()->setItalic($clientTextbox['part'.$inc]['italic']);
1635
                        }
1636 4
                        if (isset($clientTextbox['part'.$inc]['underline'])) {
1637 3
                            $txtRun->getFont()->setUnderline($clientTextbox['part'.$inc]['underline']);
1638
                        }
1639 4
                        if (isset($clientTextbox['part'.$inc]['fontName'])) {
1640 4
                            $txtRun->getFont()->setName($clientTextbox['part'.$inc]['fontName']);
1641
                        }
1642 4
                        if (isset($clientTextbox['part'.$inc]['fontSize'])) {
1643 4
                            $txtRun->getFont()->setSize($clientTextbox['part'.$inc]['fontSize']);
1644
                        }
1645 4
                        if (isset($clientTextbox['part'.$inc]['color'])) {
1646 4
                            $txtRun->getFont()->setColor($clientTextbox['part'.$inc]['color']);
1647
                        }
1648
                        // Hyperlink
1649 4
                        if (!empty($sHyperlinkURL)) {
1650 1
                            $txtRun->setHyperlink(new Hyperlink($sHyperlinkURL));
1651
                        }
1652
1653 4
                        $start += $clientTextbox['part'.$inc]['partLength'];
1654 4
                        if ($bCreateParagraph) {
1655 1
                            $arrayReturn['shape']->createParagraph();
1656
                        }
1657
                    }
1658
                }
1659
1660
                // *** Properties ***
1661
                // Dimensions
1662 4
                if ($arrayReturn['shape'] instanceof AbstractShape) {
1663 4
                    if (!empty($arrayDimensions)) {
1664 4
                        $arrayReturn['shape']->setOffsetX($arrayDimensions['left']);
1665 4
                        $arrayReturn['shape']->setOffsetY($arrayDimensions['top']);
1666 4
                        $arrayReturn['shape']->setHeight($arrayDimensions['height']);
1667 4
                        $arrayReturn['shape']->setWidth($arrayDimensions['width']);
1668
                    }
1669
                    // Rotation
1670 4
                    if (isset($shpPrimaryOptions['rotation'])) {
1671
                        $rotation = $shpPrimaryOptions['rotation'];
1672
                        $arrayReturn['shape']->setRotation($rotation);
1673
                    }
1674
                    // Shadow
1675 4
                    if (isset($shpPrimaryOptions['shadowOffsetX']) && isset($shpPrimaryOptions['shadowOffsetY'])) {
1676 3
                        $shadowOffsetX = $shpPrimaryOptions['shadowOffsetX'];
1677 3
                        $shadowOffsetY = $shpPrimaryOptions['shadowOffsetY'];
1678 3
                        if ($shadowOffsetX != 0 && $shadowOffsetY != 0) {
1679 3
                            $arrayReturn['shape']->getShadow()->setVisible(true);
1680 3
                            if ($shadowOffsetX > 0 && $shadowOffsetX == $shadowOffsetY) {
1681 3
                                $arrayReturn['shape']->getShadow()->setDistance($shadowOffsetX)->setDirection(45);
1682
                            }
1683
                        }
1684
                    }
1685
                    // Specific Line
1686 4
                    if ($arrayReturn['shape'] instanceof Line) {
1687 1
                        if (isset($shpPrimaryOptions['lineColor'])) {
1688 1
                            $arrayReturn['shape']->getBorder()->getColor()->setARGB('FF'.$shpPrimaryOptions['lineColor']);
1689
                        }
1690 1
                        if (isset($shpPrimaryOptions['lineWidth'])) {
1691 1
                            $arrayReturn['shape']->setHeight($shpPrimaryOptions['lineWidth']);
1692
                        }
1693
                    }
1694
                    // Specific RichText
1695 4
                    if ($arrayReturn['shape'] instanceof RichText) {
1696 4
                        if (isset($shpPrimaryOptions['insetBottom'])) {
1697 4
                            $arrayReturn['shape']->setInsetBottom($shpPrimaryOptions['insetBottom']);
1698
                        }
1699 4
                        if (isset($shpPrimaryOptions['insetLeft'])) {
1700 4
                            $arrayReturn['shape']->setInsetLeft($shpPrimaryOptions['insetLeft']);
1701
                        }
1702 4
                        if (isset($shpPrimaryOptions['insetRight'])) {
1703 4
                            $arrayReturn['shape']->setInsetRight($shpPrimaryOptions['insetRight']);
1704
                        }
1705 4
                        if (isset($shpPrimaryOptions['insetTop'])) {
1706 4
                            $arrayReturn['shape']->setInsetTop($shpPrimaryOptions['insetTop']);
1707
                        }
1708
                    }
1709
                }
1710
            // Rotation
1711
            } elseif (isset($shpPrimaryOptions['rotation'])) {
1712
                $rotation = $shpPrimaryOptions['rotation'];
1713
                $this->oCurrentGroup->setRotation($rotation);
1714
            }
1715
        }
1716
1717 4
        return $arrayReturn;
1718
    }
1719
1720
    /**
1721
     * The OfficeArtSpgrContainer record specifies a container for groups of shapes.
1722
     * @param string $stream
1723
     * @param integer $pos
1724
     * @param boolean $bInGroup
1725
     * @return array
1726
     * @throws \Exception
1727
     * @link : https://msdn.microsoft.com/en-us/library/dd910416(v=office.12).aspx
1728
     */
1729 4
    private function readRecordOfficeArtSpgrContainer($stream, $pos, $bInGroup = false)
1730
    {
1731
        $arrayReturn = array(
1732 4
            'length' => 0,
1733
        );
1734
1735 4
        $data = $this->loadRecordHeader($stream, $pos);
1736 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == 0xF003) {
1737 4
            $arrayReturn['length'] += 8;
1738
1739
            do {
1740 4
                $rhFileBlock = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
1741 4
                if (!($rhFileBlock['recVer'] == 0xF && $rhFileBlock['recInstance'] == 0x0000 && ($rhFileBlock['recType'] == 0xF003 || $rhFileBlock['recType'] == 0xF004))) {
1742
                    throw new \Exception('PowerPoint97 Reader : readRecordOfficeArtSpgrContainer.');
1743
                }
1744
1745 4
                switch ($rhFileBlock['recType']) {
1746 4
                    case 0xF003:
1747
                        // Core
1748
                        $this->oCurrentGroup = $this->oPhpPresentation->getActiveSlide()->createGroup();
1749
                        $this->bFirstShapeGroup = false;
1750
                        // OfficeArtSpgrContainer
1751
                        $fileBlock = $this->readRecordOfficeArtSpgrContainer($stream, $pos + $arrayReturn['length'], true);
1752
                        $arrayReturn['length'] += $fileBlock['length'];
1753
                        $data['recLen'] -= $fileBlock['length'];
1754
                        break;
1755 4
                    case 0xF004:
1756
                        // Core
1757 4
                        if (!$bInGroup) {
1758 4
                            $this->oCurrentGroup = null;
1759
                        }
1760
                        // OfficeArtSpContainer
1761 4
                        $fileBlock = $this->readRecordOfficeArtSpContainer($stream, $pos + $arrayReturn['length']);
1762 4
                        $arrayReturn['length'] += $fileBlock['length'];
1763 4
                        $data['recLen'] -= $fileBlock['length'];
1764
                        // Core
1765
                        //@todo
1766 4
                        if (!is_null($fileBlock['shape'])) {
1767 4
                            switch ($this->inMainType) {
1768 4
                                case self::RT_NOTES:
1769 4
                                    $arrayIdxSlide = array_flip($this->arrayNotes);
1770 4
                                    if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
1771
                                        $oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
1772
                                        if ($oSlide->getNote()->getShapeCollection()->count() == 0) {
1773
                                            $oSlide->getNote()->addShape($fileBlock['shape']);
1774
                                        }
1775
                                    }
1776 4
                                    break;
1777 4
                                case self::RT_SLIDE:
1778 4
                                    if ($bInGroup) {
1779
                                        $this->oCurrentGroup->addShape($fileBlock['shape']);
1780
                                    } else {
1781 4
                                        $this->oPhpPresentation->getActiveSlide()->addShape($fileBlock['shape']);
1782
                                    }
1783 4
                                    break;
1784
                            }
1785
                        }
1786
1787 4
                        break;
1788
                }
1789 4
            } while ($data['recLen'] > 0);
1790
        }
1791 4
        return $arrayReturn;
1792
    }
1793
1794
    /**
1795
     * The OfficeArtTertiaryFOPT record specifies a table of OfficeArtRGFOPTE records,.
1796
     * @param string $stream
1797
     * @param integer $pos
1798
     * @return array
1799
     * @throws \Exception
1800
     * @link https://msdn.microsoft.com/en-us/library/dd950206(v=office.12).aspx
1801
     */
1802 4
    private function readRecordOfficeArtTertiaryFOPT($stream, $pos)
1803
    {
1804
        $arrayReturn = array(
1805 4
            'length' => 0,
1806
        );
1807
1808 4
        $data = $this->loadRecordHeader($stream, $pos);
1809 4
        if ($data['recVer'] == 0x3 && $data['recType'] == 0xF122) {
1810
            // Record Header
1811
            $arrayReturn['length'] += 8;
1812
1813
            $officeArtFOPTE = array();
1814
            for ($inc = 0; $inc < $data['recInstance']; $inc++) {
1815
                $opid = self::getInt2d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
1816
                $arrayReturn['length'] += 2;
1817
                $optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
1818
                $arrayReturn['length'] += 4;
1819
                $officeArtFOPTE[] = array(
1820
                    'opid' => ($opid >> 0) & bindec('11111111111111'),
1821
                    'fBid' => ($opid >> 14) & bindec('1'),
1822
                    'fComplex' => ($opid >> 15) & bindec('1'),
1823
                    'op' => $optOp,
1824
                );
1825
            }
1826
            //@link : http://code.metager.de/source/xref/kde/calligra/filters/libmso/OPID
1827
            foreach ($officeArtFOPTE as $opt) {
1828
                switch ($opt['opid']) {
1829
                    case 0x039F:
1830
                        // Table properties
1831
                        //@link : https://msdn.microsoft.com/en-us/library/dd922773(v=office.12).aspx
1832
                        break;
1833
                    case 0x03A0:
1834
                        // Table Row Properties
1835
                        //@link : https://msdn.microsoft.com/en-us/library/dd923419(v=office.12).aspx
1836
                        if ($opt['fComplex'] == 0x1) {
1837
                            $arrayReturn['length'] += $opt['op'];
1838
                        }
1839
                        break;
1840
                    case 0x03A9:
1841
                        // GroupShape : metroBlob
1842
                        //@link : https://msdn.microsoft.com/en-us/library/dd943388(v=office.12).aspx
1843
                        if ($opt['fComplex'] == 0x1) {
1844
                            $arrayReturn['length'] += $opt['op'];
1845
                        }
1846
                        break;
1847
                    case 0x01FF:
1848
                        // Line Style Boolean
1849
                        //@link : https://msdn.microsoft.com/en-us/library/dd951605(v=office.12).aspx
1850
                        break;
1851
                    default:
1852
                        throw new \Exception('Feature not implemented (l.'.__LINE__.' : 0x'.dechex($opt['opid']).')');
1853
                }
1854
            }
1855
        }
1856 4
        return $arrayReturn;
1857
    }
1858
1859
    /**
1860
     * The OfficeArtDgContainer record specifies the container for all the file records for the objects in a drawing.
1861
     * @param string $stream
1862
     * @param integer $pos
1863
     * @return array
1864
     * @throws \Exception
1865
     * @link : https://msdn.microsoft.com/en-us/library/dd924455(v=office.12).aspx
1866
     */
1867 4
    private function readRecordOfficeArtDgContainer($stream, $pos)
1868
    {
1869
        $arrayReturn = array(
1870 4
            'length' => 0,
1871
        );
1872
1873 4
        $data = $this->loadRecordHeader($stream, $pos);
1874 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == 0xF002) {
1875
            // Record Header
1876 4
            $arrayReturn['length'] += 8;
1877
            // drawingData
1878 4
            $drawingData  = $this->readRecordOfficeArtFDG($stream, $pos + $arrayReturn['length']);
1879 4
            $arrayReturn['length'] += $drawingData['length'];
1880
            // regroupItems
1881
            //@todo
1882
            // groupShape
1883 4
            $groupShape = $this->readRecordOfficeArtSpgrContainer($stream, $pos + $arrayReturn['length']);
1884 4
            $arrayReturn['length'] += $groupShape['length'];
1885
            // shape
1886 4
            $shape = $this->readRecordOfficeArtSpContainer($stream, $pos + $arrayReturn['length']);
1887 4
            $arrayReturn['length'] += $shape['length'];
1888
            // solvers1
1889
            //@todo
1890
            // deletedShapes
1891
            //@todo
1892
            // solvers1
1893
            //@todo
1894
        }
1895
1896 4
        return $arrayReturn;
1897
    }
1898
1899
    /**
1900
     * The OfficeArtFDG record specifies the number of shapes, the drawing identifier, and the shape identifier of the last shape in a drawing.
1901
     * @param string $stream
1902
     * @param integer $pos
1903
     * @return array
1904
     * @link : https://msdn.microsoft.com/en-us/library/dd946757(v=office.12).aspx
1905
     */
1906 4
    private function readRecordOfficeArtFDG($stream, $pos)
1907
    {
1908
        $arrayReturn = array(
1909 4
            'length' => 0,
1910
        );
1911
1912 4
        $data = $this->loadRecordHeader($stream, $pos);
1913 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] <= 0xFFE && $data['recType'] == 0xF008 && $data['recLen'] == 0x00000008) {
1914
            // Record Header
1915 4
            $arrayReturn['length'] += 8;
1916
            // Length
1917 4
            $arrayReturn['length'] += $data['recLen'];
1918
        }
1919
1920 4
        return $arrayReturn;
1921
    }
1922
1923
    /**
1924
     * The OfficeArtFOPT record specifies a table of OfficeArtRGFOPTE records.
1925
     * @param string $stream
1926
     * @param integer $pos
1927
     * @return array
1928
     * @link https://msdn.microsoft.com/en-us/library/dd943404(v=office.12).aspx
1929
     */
1930 4
    private function readRecordOfficeArtFOPT($stream, $pos)
1931
    {
1932
        $arrayReturn = array(
1933 4
            'length' => 0,
1934
        );
1935
1936 4
        $data = $this->loadRecordHeader($stream, $pos);
1937 4
        if ($data['recVer'] == 0x3 && $data['recType'] == 0xF00B) {
1938
            // Record Header
1939 4
            $arrayReturn['length'] += 8;
1940
1941
            //@link : http://msdn.microsoft.com/en-us/library/dd906086(v=office.12).aspx
1942 4
            $officeArtFOPTE = array();
1943 4
            for ($inc = 0; $inc < $data['recInstance']; $inc++) {
1944 4
                $opid = self::getInt2d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
1945 4
                $arrayReturn['length'] += 2;
1946 4
                $data['recLen'] -= 2;
1947 4
                $optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
1948 4
                $arrayReturn['length'] += 4;
1949 4
                $data['recLen'] -= 4;
1950 4
                $officeArtFOPTE[] = array(
1951 4
                    'opid' => ($opid >> 0) & bindec('11111111111111'),
1952 4
                    'fBid' => ($opid >> 14) & bindec('1'),
1953 4
                    'fComplex' => ($opid >> 15) & bindec('1'),
1954 4
                    'op' => $optOp,
1955
                );
1956
            }
1957
            //@link : http://code.metager.de/source/xref/kde/calligra/filters/libmso/OPID
1958 4
            foreach ($officeArtFOPTE as $opt) {
1959
                // echo $opt['opid'].'-0x'.dechex($opt['opid']).EOL;
1960 4
                switch ($opt['opid']) {
1961 4
                    case 0x0004:
1962
                        // Transform : rotation
1963
                        //@link : https://msdn.microsoft.com/en-us/library/dd949750(v=office.12).aspx
1964
                        $arrayReturn['rotation'] = $opt['op'];
1965
                        break;
1966 4
                    case 0x007F:
1967
                        // Transform : Protection Boolean Properties
1968
                        //@link : http://msdn.microsoft.com/en-us/library/dd909131(v=office.12).aspx
1969 4
                        break;
1970 4
                    case 0x0080:
1971
                        // Text : ltxid
1972
                        //@link : http://msdn.microsoft.com/en-us/library/dd947446(v=office.12).aspx
1973 4
                        break;
1974 4
                    case 0x0081:
1975
                        // Text : dxTextLeft
1976
                        //@link : http://msdn.microsoft.com/en-us/library/dd953234(v=office.12).aspx
1977 4
                        $arrayReturn['insetLeft'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
1978 4
                        break;
1979 4
                    case 0x0082:
1980
                        // Text : dyTextTop
1981
                        //@link : http://msdn.microsoft.com/en-us/library/dd925068(v=office.12).aspx
1982 4
                        $arrayReturn['insetTop'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
1983 4
                        break;
1984 4
                    case 0x0083:
1985
                        // Text : dxTextRight
1986
                        //@link : http://msdn.microsoft.com/en-us/library/dd906782(v=office.12).aspx
1987 4
                        $arrayReturn['insetRight'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
1988 4
                        break;
1989 4
                    case 0x0084:
1990
                        // Text : dyTextBottom
1991
                        //@link : http://msdn.microsoft.com/en-us/library/dd772858(v=office.12).aspx
1992 4
                        $arrayReturn['insetBottom'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
1993 4
                        break;
1994 4
                    case 0x0085:
1995
                        // Text : WrapText
1996
                        //@link : http://msdn.microsoft.com/en-us/library/dd924770(v=office.12).aspx
1997 4
                        break;
1998 4
                    case 0x0087:
1999
                        // Text : anchorText
2000
                        //@link : http://msdn.microsoft.com/en-us/library/dd948575(v=office.12).aspx
2001 4
                        break;
2002 4
                    case 0x00BF:
2003
                        // Text : Text Boolean Properties
2004
                        //@link : http://msdn.microsoft.com/en-us/library/dd950905(v=office.12).aspx
2005 4
                        break;
2006 4
                    case 0x0104:
2007
                        // Blip : pib
2008
                        //@link : http://msdn.microsoft.com/en-us/library/dd772837(v=office.12).aspx
2009 4
                        if ($opt['fComplex'] == 0) {
2010 4
                            $arrayReturn['pib'] = $opt['op'];
2011 4
                            $data['recLen'] -= $opt['op'];
2012
                        } else {
2013
                            // pib Complex
2014
                        }
2015 4
                        break;
2016 4
                    case 0x13F:
2017
                        // Blip Boolean Properties
2018
                        //@link : https://msdn.microsoft.com/en-us/library/dd944215(v=office.12).aspx
2019
                        break;
2020 4
                    case 0x140:
2021
                        // Geometry : geoLeft
2022
                        //@link : http://msdn.microsoft.com/en-us/library/dd947489(v=office.12).aspx
2023
                        // print_r('geoLeft : '.$opt['op'].EOL);
2024 2
                        break;
2025 4
                    case 0x141:
2026
                        // Geometry : geoTop
2027
                        //@link : http://msdn.microsoft.com/en-us/library/dd949459(v=office.12).aspx
2028
                        // print_r('geoTop : '.$opt['op'].EOL);
2029 2
                        break;
2030 4
                    case 0x142:
2031
                        // Geometry : geoRight
2032
                        //@link : http://msdn.microsoft.com/en-us/library/dd947117(v=office.12).aspx
2033
                        // print_r('geoRight : '.$opt['op'].EOL);
2034 2
                        break;
2035 4
                    case 0x143:
2036
                        // Geometry : geoBottom
2037
                        //@link : http://msdn.microsoft.com/en-us/library/dd948602(v=office.12).aspx
2038
                        // print_r('geoBottom : '.$opt['op'].EOL);
2039 2
                        break;
2040 4
                    case 0x144:
2041
                        // Geometry : shapePath
2042
                        //@link : http://msdn.microsoft.com/en-us/library/dd945249(v=office.12).aspx
2043 1
                        $arrayReturn['line'] = true;
2044 1
                        break;
2045 4
                    case 0x145:
2046
                        // Geometry : pVertices
2047
                        //@link : http://msdn.microsoft.com/en-us/library/dd949814(v=office.12).aspx
2048 2
                        if ($opt['fComplex'] == 1) {
2049 2
                            $arrayReturn['length'] += $opt['op'];
2050 2
                            $data['recLen'] -= $opt['op'];
2051
                        }
2052 2
                        break;
2053 4
                    case 0x146:
2054
                        // Geometry : pSegmentInfo
2055
                        //@link : http://msdn.microsoft.com/en-us/library/dd905742(v=office.12).aspx
2056 2
                        if ($opt['fComplex'] == 1) {
2057 2
                            $arrayReturn['length'] += $opt['op'];
2058 2
                            $data['recLen'] -= $opt['op'];
2059
                        }
2060 2
                        break;
2061 4
                    case 0x155:
2062
                        // Geometry : pAdjustHandles
2063
                        //@link : http://msdn.microsoft.com/en-us/library/dd905890(v=office.12).aspx
2064 2
                        if ($opt['fComplex'] == 1) {
2065 2
                            $arrayReturn['length'] += $opt['op'];
2066 2
                            $data['recLen'] -= $opt['op'];
2067
                        }
2068 2
                        break;
2069 4
                    case 0x156:
2070
                        // Geometry : pGuides
2071
                        //@link : http://msdn.microsoft.com/en-us/library/dd910801(v=office.12).aspx
2072 2
                        if ($opt['fComplex'] == 1) {
2073 2
                            $arrayReturn['length'] += $opt['op'];
2074 2
                            $data['recLen'] -= $opt['op'];
2075
                        }
2076 2
                        break;
2077 4
                    case 0x157:
2078
                        // Geometry : pInscribe
2079
                        //@link : http://msdn.microsoft.com/en-us/library/dd904889(v=office.12).aspx
2080 2
                        if ($opt['fComplex'] == 1) {
2081 2
                            $arrayReturn['length'] += $opt['op'];
2082 2
                            $data['recLen'] -= $opt['op'];
2083
                        }
2084 2
                        break;
2085 4
                    case 0x17F:
2086
                        // Geometry Boolean Properties
2087
                        //@link : http://msdn.microsoft.com/en-us/library/dd944968(v=office.12).aspx
2088 1
                        break;
2089 4
                    case 0x0180:
2090
                        // Fill : fillType
2091
                        //@link : http://msdn.microsoft.com/en-us/library/dd947909(v=office.12).aspx
2092 4
                        break;
2093 4
                    case 0x0181:
2094
                        // Fill : fillColor
2095
                        //@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx
2096 4
                        $strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2097 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2098 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2099
                        // echo 'fillColor  : '.$strColor.EOL;
2100 4
                        break;
2101 4
                    case 0x0183:
2102
                        // Fill : fillBackColor
2103
                        //@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx
2104 4
                        $strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2105 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2106 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2107
                        // echo 'fillBackColor  : '.$strColor.EOL;
2108 4
                        break;
2109 4
                    case 0x0193:
2110
                        // Fill : fillRectRight
2111
                        //@link : http://msdn.microsoft.com/en-us/library/dd951294(v=office.12).aspx
2112
                        // echo 'fillRectRight  : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL;
2113 4
                        break;
2114 4
                    case 0x0194:
2115
                        // Fill : fillRectBottom
2116
                        //@link : http://msdn.microsoft.com/en-us/library/dd910194(v=office.12).aspx
2117
                        // echo 'fillRectBottom   : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL;
2118 4
                        break;
2119 4
                    case 0x01BF:
2120
                        // Fill : Fill Style Boolean Properties
2121
                        //@link : http://msdn.microsoft.com/en-us/library/dd909380(v=office.12).aspx
2122 4
                        break;
2123 4
                    case 0x01C0:
2124
                        // Line Style : lineColor
2125
                        //@link : http://msdn.microsoft.com/en-us/library/dd920397(v=office.12).aspx
2126 4
                        $strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2127 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2128 4
                        $strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, STR_PAD_LEFT, '0');
2129 4
                        $arrayReturn['lineColor'] = $strColor;
2130 4
                        break;
2131 4
                    case 0x01C1:
2132
                        // Line Style : lineOpacity
2133
                        //@link : http://msdn.microsoft.com/en-us/library/dd923433(v=office.12).aspx
2134
                        // echo 'lineOpacity : '.dechex($opt['op']).EOL;
2135 4
                        break;
2136 4
                    case 0x01C2:
2137
                        // Line Style : lineBackColor
2138
                        //@link : http://msdn.microsoft.com/en-us/library/dd947669(v=office.12).aspx
2139 4
                        break;
2140 4
                    case 0x01CB:
2141
                        // Line Style : lineWidth
2142
                        //@link : http://msdn.microsoft.com/en-us/library/dd926964(v=office.12).aspx
2143 2
                        $arrayReturn['lineWidth'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
2144 2
                        break;
2145 4
                    case 0x01D6:
2146
                        // Line Style : lineJoinStyle
2147
                        //@link : http://msdn.microsoft.com/en-us/library/dd909643(v=office.12).aspx
2148 4
                        break;
2149 4
                    case 0x01D7:
2150
                        // Line Style : lineEndCapStyle
2151
                        //@link : http://msdn.microsoft.com/en-us/library/dd925071(v=office.12).aspx
2152 4
                        break;
2153 4
                    case 0x01FF:
2154
                        // Line Style : Line Style Boolean Properties
2155
                        //@link : http://msdn.microsoft.com/en-us/library/dd951605(v=office.12).aspx
2156 4
                        break;
2157 4
                    case 0x0201:
2158
                        // Shadow Style : shadowColor
2159
                        //@link : http://msdn.microsoft.com/en-us/library/dd923454(v=office.12).aspx
2160 4
                        break;
2161 4
                    case 0x0204:
2162
                        // Shadow Style : shadowOpacity
2163
                        //@link : http://msdn.microsoft.com/en-us/library/dd920720(v=office.12).aspx
2164 3
                        break;
2165 4
                    case 0x0205:
2166
                        // Shadow Style : shadowOffsetX
2167
                        //@link : http://msdn.microsoft.com/en-us/library/dd945280(v=office.12).aspx
2168 3
                        $arrayReturn['shadowOffsetX'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
2169 3
                        break;
2170 4
                    case 0x0206:
2171
                        // Shadow Style : shadowOffsetY
2172
                        //@link : http://msdn.microsoft.com/en-us/library/dd907855(v=office.12).aspx
2173 3
                        $arrayReturn['shadowOffsetY'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']);
2174 3
                        break;
2175 4
                    case 0x023F:
2176
                        // Shadow Style : Shadow Style Boolean Properties
2177
                        //@link : http://msdn.microsoft.com/en-us/library/dd947887(v=office.12).aspx
2178 4
                        break;
2179 4
                    case 0x0304:
2180
                        // Shape : bWMode
2181
                        //@link : http://msdn.microsoft.com/en-us/library/dd947659(v=office.12).aspx
2182 4
                        break;
2183 4
                    case 0x033F:
2184
                        // Shape Boolean Properties
2185
                        //@link : http://msdn.microsoft.com/en-us/library/dd951345(v=office.12).aspx
2186 4
                        break;
2187 1
                    case 0x0380:
2188
                        // Group Shape Property Set : wzName
2189
                        //@link : http://msdn.microsoft.com/en-us/library/dd950681(v=office.12).aspx
2190
                        if ($opt['fComplex'] == 1) {
2191
                            $arrayReturn['length'] += $opt['op'];
2192
                            $data['recLen'] -= $opt['op'];
2193
                        }
2194
                        break;
2195 1
                    case 0x03BF:
2196
                        // Group Shape Property Set : Group Shape Boolean Properties
2197
                        //@link : http://msdn.microsoft.com/en-us/library/dd949807(v=office.12).aspx
2198
                        break;
2199 4
                    default:
2200
                        // throw new \Exception('Feature not implemented (l.'.__LINE__.' : 0x'.dechex($opt['opid']).')');
2201
                }
2202
            }
2203 4
            if ($data['recLen'] > 0) {
2204 2
                $arrayReturn['length'] += $data['recLen'];
2205
            }
2206
        }
2207
2208 4
        return $arrayReturn;
2209
    }
2210
2211
    /**
2212
     * The OfficeArtFPSPL record specifies the former hierarchical position of the containing object that is either a shape or a group of shapes.
2213
     * @param string $stream
2214
     * @param integer $pos
2215
     * @return array
2216
     * @link https://msdn.microsoft.com/en-us/library/dd947479(v=office.12).aspx
2217
     */
2218
    private function readRecordOfficeArtFPSPL($stream, $pos)
2219
    {
2220
        $arrayReturn = array(
2221
            'length' => 0,
2222
        );
2223
2224
        $data = $this->loadRecordHeader($stream, $pos);
2225
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == 0xF11D && $data['recLen'] == 0x00000004) {
2226
            $arrayReturn['length'] += 8;
2227
            $arrayReturn['length'] += $data['recLen'];
2228
        }
2229
2230
        return $arrayReturn;
2231
    }
2232
2233
    /**
2234
     * The OfficeArtFSP record specifies an instance of a shape.
2235
     * @param string $stream
2236
     * @param integer $pos
2237
     * @return array
2238
     * @link https://msdn.microsoft.com/en-us/library/dd925898(v=office.12).aspx
2239
     */
2240 4
    private function readRecordOfficeArtFSP($stream, $pos)
2241
    {
2242
        $arrayReturn = array(
2243 4
            'length' => 0,
2244
        );
2245
2246 4
        $data = $this->loadRecordHeader($stream, $pos);
2247 4
        if ($data['recVer'] == 0x2 && $data['recType'] == 0xF00A && $data['recLen'] == 0x00000008) {
2248 4
            $arrayReturn['length'] += 8;
2249
            // spid
2250 4
            $arrayReturn['length'] += 4;
2251
            // data
2252 4
            $data = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
2253 4
            $arrayReturn['length'] += 4;
2254 4
            $arrayReturn['fGroup'] = ($data >> 0) & bindec('1');
2255 4
            $arrayReturn['fChild'] = ($data >> 1) & bindec('1');
2256 4
            $arrayReturn['fPatriarch'] = ($data >> 2) & bindec('1');
2257 4
            $arrayReturn['fDeleted'] = ($data >> 3) & bindec('1');
2258
        }
2259
2260 4
        return $arrayReturn;
2261
    }
2262
2263
    /**
2264
     * The OfficeArtFSPGR record specifies the coordinate system of the group shape that the anchors of the child shape are expressed in.
2265
     * @param string $stream
2266
     * @param integer $pos
2267
     * @return array
2268
     * @link https://msdn.microsoft.com/en-us/library/dd925381(v=office.12).aspx
2269
     */
2270 4
    private function readRecordOfficeArtFSPGR($stream, $pos)
2271
    {
2272
        $arrayReturn = array(
2273 4
            'length' => 0,
2274
        );
2275
2276 4
        $data = $this->loadRecordHeader($stream, $pos);
2277 4
        if ($data['recVer'] == 0x1 && $data['recInstance'] == 0x000 && $data['recType'] == 0xF009 && $data['recLen'] == 0x00000010) {
2278 4
            $arrayReturn['length'] += 8;
2279
            //$arrShapeGroup['xLeft'] = self::getInt4d($this->streamPowerpointDocument, $pos);
2280 4
            $arrayReturn['length'] += 4;
2281
            //$arrShapeGroup['yTop'] = self::getInt4d($this->streamPowerpointDocument, $pos);
2282 4
            $arrayReturn['length'] += 4;
2283
            //$arrShapeGroup['xRight'] = self::getInt4d($this->streamPowerpointDocument, $pos);
2284 4
            $arrayReturn['length'] += 4;
2285
            //$arrShapeGroup['yBottom'] = self::getInt4d($this->streamPowerpointDocument, $pos);
2286 4
            $arrayReturn['length'] += 4;
2287
        }
2288
2289 4
        return $arrayReturn;
2290
    }
2291
2292
    /**
2293
     * The OfficeArtSecondaryFOPT record specifies a table of OfficeArtRGFOPTE records.
2294
     * @param string $stream
2295
     * @param integer $pos
2296
     * @return array
2297
     * @link https://msdn.microsoft.com/en-us/library/dd950259(v=office.12).aspx
2298
     */
2299 4
    private function readRecordOfficeArtSecondaryFOPT($stream, $pos)
2300
    {
2301
        $arrayReturn = array(
2302 4
            'length' => 0,
2303
        );
2304
2305 4
        $data = $this->loadRecordHeader($stream, $pos);
2306 4
        if ($data['recVer'] == 0x3 && $data['recType'] == 0xF121) {
2307
            // Record Header
2308
            $arrayReturn['length'] += 8;
2309
            // Length
2310
            $arrayReturn['length'] += $data['recLen'];
2311
        }
2312 4
        return $arrayReturn;
2313
    }
2314
2315
    /**
2316
     * A container record that specifies information about a shape.
2317
     * @param string $stream
2318
     * @param integer $pos
2319
     * @return array
2320
     * @throws \Exception
2321
     * @link : https://msdn.microsoft.com/en-us/library/dd950927(v=office.12).aspx
2322
     */
2323 4
    private function readRecordOfficeArtClientData($stream, $pos)
2324
    {
2325
        $arrayReturn = array(
2326 4
            'length' => 0,
2327
        );
2328
2329 4
        $data = $this->loadRecordHeader($stream, $pos);
2330 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == 0xF011) {
2331 4
            $arrayReturn['length'] += 8;
2332
            // shapeFlagsAtom (9 bytes)
2333 4
            $dataShapeFlagsAtom = $this->readRecordShapeFlagsAtom($stream, $pos + $arrayReturn['length']);
2334 4
            $arrayReturn['length'] += $dataShapeFlagsAtom['length'];
2335
2336
            // shapeFlags10Atom (9 bytes)
2337 4
            $dataShapeFlags10Atom = $this->readRecordShapeFlags10Atom($stream, $pos + $arrayReturn['length']);
2338 4
            $arrayReturn['length'] += $dataShapeFlags10Atom['length'];
2339
2340
            // exObjRefAtom (12 bytes)
2341 4
            $dataExObjRefAtom = $this->readRecordExObjRefAtom($stream, $pos + $arrayReturn['length']);
2342 4
            $arrayReturn['length'] += $dataExObjRefAtom['length'];
2343
2344
            // animationInfo (variable)
2345 4
            $dataAnimationInfo = $this->readRecordAnimationInfoContainer($stream, $pos + $arrayReturn['length']);
2346 4
            $arrayReturn['length'] += $dataAnimationInfo['length'];
2347
2348
            // mouseClickInteractiveInfo (variable)
2349 4
            $mouseClickInfo = $this->readRecordMouseClickInteractiveInfoContainer($stream, $pos + $arrayReturn['length']);
2350 4
            $arrayReturn['length'] += $mouseClickInfo['length'];
2351
2352
            // mouseOverInteractiveInfo (variable)
2353 4
            $mouseOverInfo = $this->readRecordMouseOverInteractiveInfoContainer($stream, $pos + $arrayReturn['length']);
2354 4
            $arrayReturn['length'] += $mouseOverInfo['length'];
2355
2356
            // placeholderAtom (16 bytes)
2357 4
            $dataPlaceholderAtom = $this->readRecordPlaceholderAtom($stream, $pos + $arrayReturn['length']);
2358 4
            $arrayReturn['length'] += $dataPlaceholderAtom['length'];
2359
2360
            // recolorInfoAtom (variable)
2361 4
            $dataRecolorInfo = $this->readRecordRecolorInfoAtom($stream, $pos + $arrayReturn['length']);
2362 4
            $arrayReturn['length'] += $dataRecolorInfo['length'];
2363
2364
            // rgShapeClientRoundtripData (variable)
2365
            $array = array(
2366 4
                self::RT_PROGTAGS,
2367 4
                self::RT_ROUNDTRIPNEWPLACEHOLDERID12ATOM,
2368 4
                self::RT_ROUNDTRIPSHAPEID12ATOM,
2369 4
                self::RT_ROUNDTRIPHFPLACEHOLDER12ATOM,
2370 4
                self::RT_ROUNDTRIPSHAPECHECKSUMFORCL12ATOM,
2371
            );
2372
            do {
2373 4
                $dataHeaderRG = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
2374 4
                if (in_array($dataHeaderRG['recType'], $array)) {
2375
                    switch ($dataHeaderRG['recType']) {
2376
                        case self::RT_PROGTAGS:
2377
                            $dataRG = $this->readRecordShapeProgTagsContainer($stream, $pos + $arrayReturn['length']);
2378
                            $arrayReturn['length'] += $dataRG['length'];
2379
                            break;
2380
                        case self::RT_ROUNDTRIPHFPLACEHOLDER12ATOM:
2381
                            $dataRG = $this->readRecordRoundTripHFPlaceholder12Atom($stream, $pos + $arrayReturn['length']);
2382
                            $arrayReturn['length'] += $dataRG['length'];
2383
                            break;
2384
                        case self::RT_ROUNDTRIPSHAPEID12ATOM:
2385
                            $dataRG = $this->readRecordRoundTripShapeId12Atom($stream, $pos + $arrayReturn['length']);
2386
                            $arrayReturn['length'] += $dataRG['length'];
2387
                            break;
2388
                        default:
2389
                            throw new \Exception('Feature not implemented (l.'.__LINE__.' : 0x'.dechex($dataHeaderRG['recType']).')');
2390
                    }
2391
                }
2392 4
            } while (in_array($dataHeaderRG['recType'], $array));
2393
        }
2394
2395 4
        return $arrayReturn;
2396
    }
2397
2398
    /**
2399
     * An atom record that specifies a persist object directory. Each persist object identifier specified MUST be unique in that persist object directory.
2400
     * @link http://msdn.microsoft.com/en-us/library/dd952680(v=office.12).aspx
2401
     * @param string $stream
2402
     * @param integer $pos
2403
     * @throws \Exception
2404
     */
2405 4
    private function readRecordPersistDirectoryAtom($stream, $pos)
2406
    {
2407 4
        $rHeader = $this->loadRecordHeader($stream, $pos);
2408 4
        $pos += 8;
2409 4
        if ($rHeader['recVer'] != 0x0 || $rHeader['recInstance'] != 0x000 || $rHeader['recType'] != self::RT_PERSISTDIRECTORYATOM) {
2410
            throw new \Exception('File PowerPoint 97 in error (Location : PersistDirectoryAtom > RecordHeader).');
2411
        }
2412
        // rgPersistDirEntry
2413
        // @link : http://msdn.microsoft.com/en-us/library/dd947347(v=office.12).aspx
2414
        do {
2415 4
            $data = self::getInt4d($stream, $pos);
2416 4
            $pos += 4;
2417 4
            $rHeader['recLen'] -= 4;
2418
            //$persistId  = ($data >> 0) & bindec('11111111111111111111');
2419 4
            $cPersist  = ($data >> 20) & bindec('111111111111');
2420
2421 4
            $rgPersistOffset = array();
2422 4
            for ($inc = 0; $inc < $cPersist; $inc++) {
2423 4
                $rgPersistOffset[] = self::getInt4d($stream, $pos);
2424 4
                $pos += 4;
2425 4
                $rHeader['recLen'] -= 4;
2426
            }
2427 4
        } while ($rHeader['recLen'] > 0);
2428 4
        $this->rgPersistDirEntry = $rgPersistOffset;
2429 4
    }
2430
2431
    /**
2432
     * A container record that specifies information about the headers (1) and footers within a slide.
2433
     * @param string $stream
2434
     * @param integer $pos
2435
     * @link https://msdn.microsoft.com/en-us/library/dd904856(v=office.12).aspx
2436
     * @return array
2437
     */
2438 4
    private function readRecordPerSlideHeadersFootersContainer($stream, $pos)
2439
    {
2440
        $arrayReturn = array(
2441 4
            'length' => 0,
2442
        );
2443
2444 4
        $data = $this->loadRecordHeader($stream, $pos);
2445 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_HEADERSFOOTERS) {
2446
            // Record Header
2447 4
            $arrayReturn['length'] += 8;
2448
            // Length
2449 4
            $arrayReturn['length'] += $data['recLen'];
2450
        }
2451
2452 4
        return $arrayReturn;
2453
    }
2454
2455
    /**
2456
     * An atom record that specifies whether a shape is a placeholder shape.
2457
     * @param string $stream
2458
     * @param integer $pos
2459
     * @link https://msdn.microsoft.com/en-us/library/dd923930(v=office.12).aspx
2460
     * @return array
2461
     */
2462 4
    private function readRecordPlaceholderAtom($stream, $pos)
2463
    {
2464
        $arrayReturn = array(
2465 4
            'length' => 0,
2466
        );
2467
2468 4
        $data = $this->loadRecordHeader($stream, $pos);
2469 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_PLACEHOLDERATOM && $data['recLen'] == 0x00000008) {
2470
            // Record Header
2471 4
            $arrayReturn['length'] += 8;
2472
            // Datas
2473 4
            $arrayReturn['length'] += $data['recLen'];
2474
        }
2475
2476 4
        return $arrayReturn;
2477
    }
2478
2479
    /**
2480
     * An atom record that specifies a collection of re-color mappings for a metafile ([MS-WMF]).
2481
     * @param string $stream
2482
     * @param integer $pos
2483
     * @link https://msdn.microsoft.com/en-us/library/dd904899(v=office.12).aspx
2484
     * @return array
2485
     */
2486 4
    private function readRecordRecolorInfoAtom($stream, $pos)
2487
    {
2488
        $arrayReturn = array(
2489 4
            'length' => 0,
2490
        );
2491
2492 4
        $data = $this->loadRecordHeader($stream, $pos);
2493 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_RECOLORINFOATOM) {
2494
            // Record Header
2495
            $arrayReturn['length'] += 8;
2496
            // Datas
2497
            $arrayReturn['length'] += $data['recLen'];
2498
        }
2499
2500 4
        return $arrayReturn;
2501
    }
2502
2503
    /**
2504
     * An atom record that specifies that a shape is a header or footerplaceholder shape.
2505
     * @param string $stream
2506
     * @param integer $pos
2507
     * @link https://msdn.microsoft.com/en-us/library/dd910800(v=office.12).aspx
2508
     * @return array
2509
     */
2510
    private function readRecordRoundTripHFPlaceholder12Atom($stream, $pos)
2511
    {
2512
        $arrayReturn = array(
2513
            'length' => 0,
2514
        );
2515
2516
        $data = $this->loadRecordHeader($stream, $pos);
2517
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_ROUNDTRIPHFPLACEHOLDER12ATOM && $data['recLen'] == 0x00000001) {
2518
            // Record Header
2519
            $arrayReturn['length'] += 8;
2520
            // Datas
2521
            $arrayReturn['length'] += $data['recLen'];
2522
        }
2523
2524
        return $arrayReturn;
2525
    }
2526
2527
    /**
2528
     * An atom record that specifies a shape identifier.
2529
     * @param string $stream
2530
     * @param integer $pos
2531
     * @link https://msdn.microsoft.com/en-us/library/dd772926(v=office.12).aspx
2532
     * @return array
2533
     */
2534
    private function readRecordRoundTripShapeId12Atom($stream, $pos)
2535
    {
2536
        $arrayReturn = array(
2537
            'length' => 0,
2538
        );
2539
2540
        $data = $this->loadRecordHeader($stream, $pos);
2541
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_ROUNDTRIPSHAPEID12ATOM && $data['recLen'] == 0x00000004) {
2542
            // Record Header
2543
            $arrayReturn['length'] += 8;
2544
            // Length
2545
            $arrayReturn['length'] += $data['recLen'];
2546
        }
2547
2548
        return $arrayReturn;
2549
    }
2550
2551
    /**
2552
     * A container record that specifies information about a slide that synchronizes to a slide in a slide library.
2553
     * @param string $stream
2554
     * @param integer $pos
2555
     * @link https://msdn.microsoft.com/en-us/library/dd923801(v=office.12).aspx
2556
     * @return array
2557
     */
2558 4
    private function readRecordRoundTripSlideSyncInfo12Container($stream, $pos)
2559
    {
2560
        $arrayReturn = array(
2561 4
            'length' => 0,
2562
        );
2563
2564 4
        $data = $this->loadRecordHeader($stream, $pos);
2565 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_ROUNDTRIPSLIDESYNCINFO12) {
2566
            // Record Header
2567
            $arrayReturn['length'] += 8;
2568
            // Length
2569
            $arrayReturn['length'] += $data['recLen'];
2570
        }
2571
2572 4
        return $arrayReturn;
2573
    }
2574
2575
    /**
2576
     * An atom record that specifies shape-level Boolean flags.
2577
     * @param string $stream
2578
     * @param integer $pos
2579
     * @link https://msdn.microsoft.com/en-us/library/dd908949(v=office.12).aspx
2580
     * @return array
2581
     */
2582 4
    private function readRecordShapeFlags10Atom($stream, $pos)
2583
    {
2584
        $arrayReturn = array(
2585 4
            'length' => 0,
2586
        );
2587
2588 4
        $data = $this->loadRecordHeader($stream, $pos);
2589 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_SHAPEFLAGS10ATOM && $data['recLen'] == 0x00000001) {
2590
            // Record Header
2591
            $arrayReturn['length'] += 8;
2592
            // Datas
2593
            $arrayReturn['length'] += $data['recLen'];
2594
        }
2595
2596 4
        return $arrayReturn;
2597
    }
2598
2599
    /**
2600
     * An atom record that specifies shape-level Boolean flags.
2601
     * @param string $stream
2602
     * @param integer $pos
2603
     * @link https://msdn.microsoft.com/en-us/library/dd925824(v=office.12).aspx
2604
     * @return array
2605
     */
2606 4
    private function readRecordShapeFlagsAtom($stream, $pos)
2607
    {
2608
        $arrayReturn = array(
2609 4
                'length' => 0,
2610
        );
2611
2612 4
        $data = $this->loadRecordHeader($stream, $pos);
2613 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_SHAPEATOM && $data['recLen'] == 0x00000001) {
2614
            // Record Header
2615
            $arrayReturn['length'] += 8;
2616
            // Datas
2617
            $arrayReturn['length'] += $data['recLen'];
2618
        }
2619
2620 4
        return $arrayReturn;
2621
    }
2622
2623
    /**
2624
     * A container record that specifies programmable tags with additional binary shape data.
2625
     * @param string $stream
2626
     * @param integer $pos
2627
     * @link https://msdn.microsoft.com/en-us/library/dd911033(v=office.12).aspx
2628
     * @return array
2629
     */
2630
    private function readRecordShapeProgBinaryTagContainer($stream, $pos)
2631
    {
2632
        $arrayReturn = array(
2633
            'length' => 0,
2634
        );
2635
2636
        $data = $this->loadRecordHeader($stream, $pos);
2637
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_PROGBINARYTAG) {
2638
            // Record Header
2639
            $arrayReturn['length'] += 8;
2640
            // Datas
2641
            $arrayReturn['length'] += $data['recLen'];
2642
        }
2643
2644
        return $arrayReturn;
2645
    }
2646
2647
    /**
2648
     * A container record that specifies programmable tags with additional shape data.
2649
     * @param string $stream
2650
     * @param integer $pos
2651
     * @return array
2652
     * @throws \Exception
2653
     * @link https://msdn.microsoft.com/en-us/library/dd911266(v=office.12).aspx
2654
     */
2655
    private function readRecordShapeProgTagsContainer($stream, $pos)
2656
    {
2657
        $arrayReturn = array(
2658
            'length' => 0,
2659
        );
2660
2661
        $data = $this->loadRecordHeader($stream, $pos);
2662
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_PROGTAGS) {
2663
            // Record Header
2664
            $arrayReturn['length'] += 8;
2665
2666
            $length = 0;
2667
            do {
2668
                $dataHeaderRG = $this->loadRecordHeader($stream, $pos + $arrayReturn['length'] + $length);
2669
                switch ($dataHeaderRG['recType']) {
2670
                    case self::RT_PROGBINARYTAG:
2671
                        $dataRG = $this->readRecordShapeProgBinaryTagContainer($stream, $pos + $arrayReturn['length'] + $length);
2672
                        $length += $dataRG['length'];
2673
                        break;
2674
                    //case self::RT_PROGSTRINGTAG:
2675
                    default:
2676
                        throw new \Exception('Feature not implemented (l.'.__LINE__.')');
2677
                }
2678
            } while ($length < $data['recLen']);
2679
            // Datas
2680
            $arrayReturn['length'] += $data['recLen'];
2681
        }
2682
2683
        return $arrayReturn;
2684
    }
2685
2686
    /**
2687
     * An atom record that specifies information about a slide.
2688
     * @param string $stream
2689
     * @param integer $pos
2690
     * @return array
2691
     * @link https://msdn.microsoft.com/en-us/library/dd923801(v=office.12).aspx
2692
     */
2693 4
    private function readRecordSlideAtom($stream, $pos)
2694
    {
2695
        $arrayReturn = array(
2696 4
            'length' => 0,
2697
        );
2698
2699 4
        $data = $this->loadRecordHeader($stream, $pos);
2700 4
        if ($data['recVer'] == 0x2 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_SLIDEATOM) {
2701
            // Record Header
2702 4
            $arrayReturn['length'] += 8;
2703
            // slideAtom > geom
2704 4
            $arrayReturn['length'] += 4;
2705
            // slideAtom > rgPlaceholderTypes
2706 4
            $rgPlaceholderTypes = array();
2707 4
            for ($inc = 0; $inc < 8; $inc++) {
2708 4
                $rgPlaceholderTypes[] = self::getInt1d($this->streamPowerpointDocument, $pos);
2709 4
                $arrayReturn['length'] += 1;
2710
            }
2711
2712
            // slideAtom > masterIdRef
2713 4
            $arrayReturn['length'] += 4;
2714
            // slideAtom > notesIdRef
2715 4
            $arrayReturn['length'] += 4;
2716
            // slideAtom > slideFlags
2717 4
            $arrayReturn['length'] += 2;
2718
            // slideAtom > unused;
2719 4
            $arrayReturn['length'] += 2;
2720
        }
2721
2722 4
        return $arrayReturn;
2723
    }
2724
2725
    /**
2726
     * A container record that specifies a presentation slide or title master slide.
2727
     * @param string $stream
2728
     * @param int $pos
2729
     * @throws \Exception
2730
     * @link http://msdn.microsoft.com/en-us/library/dd946323(v=office.12).aspx
2731
     */
2732 4
    private function readRecordSlideContainer($stream, $pos)
2733
    {
2734
        // Core
2735 4
        $this->oPhpPresentation->createSlide();
2736 4
        $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
2737
2738
        // *** slideAtom (32 bytes)
2739 4
        $slideAtom = $this->readRecordSlideAtom($stream, $pos);
2740 4
        if ($slideAtom['length'] == 0) {
2741
            throw new \Exception('PowerPoint97 Reader : record SlideAtom');
2742
        }
2743 4
        $pos += $slideAtom['length'];
2744
2745
        // *** slideShowSlideInfoAtom (24 bytes)
2746 4
        $slideShowInfoAtom = $this->readRecordSlideShowSlideInfoAtom($stream, $pos);
2747 4
        $pos += $slideShowInfoAtom['length'];
2748
2749
        // *** perSlideHFContainer (variable) : optional
2750 4
        $perSlideHFContainer = $this->readRecordPerSlideHeadersFootersContainer($stream, $pos);
2751 4
        $pos += $perSlideHFContainer['length'];
2752
2753
        // *** rtSlideSyncInfo12 (variable) : optional
2754 4
        $rtSlideSyncInfo12 = $this->readRecordRoundTripSlideSyncInfo12Container($stream, $pos);
2755 4
        $pos += $rtSlideSyncInfo12['length'];
2756
2757
        // *** drawing (variable)
2758 4
        $drawing = $this->readRecordDrawingContainer($stream, $pos);
2759 4
        $pos += $drawing['length'];
2760
2761
        // *** slideSchemeColorSchemeAtom (40 bytes)
2762 4
        $slideSchemeColorAtom = $this->readRecordSlideSchemeColorSchemeAtom($stream, $pos);
2763 4
        if ($slideSchemeColorAtom['length'] == 0) {
2764
            throw new \Exception('PowerPoint97 Reader : record SlideSchemeColorSchemeAtom');
2765
        }
2766 4
        $pos += $slideSchemeColorAtom['length'];
2767
2768
        // *** slideNameAtom (variable)
2769 4
        $slideNameAtom = $this->readRecordSlideNameAtom($stream, $pos);
2770 4
        $pos += $slideNameAtom['length'];
2771
2772
        // *** slideProgTagsContainer (variable).
2773 4
        $slideProgTags = $this->readRecordSlideProgTagsContainer($stream, $pos);
2774 4
        $pos += $slideProgTags['length'];
2775
2776
        // *** rgRoundTripSlide (variable)
2777 4
    }
2778
2779
    /**
2780
     * An atom record that specifies the name of a slide.
2781
     * @param string $stream
2782
     * @param integer $pos
2783
     * @link https://msdn.microsoft.com/en-us/library/dd906297(v=office.12).aspx
2784
     * @return array
2785
     */
2786 4
    private function readRecordSlideNameAtom($stream, $pos)
2787
    {
2788
        $arrayReturn = array(
2789 4
            'length' => 0,
2790
            'slideName' => '',
2791
        );
2792
2793 4
        $data = $this->loadRecordHeader($stream, $pos);
2794 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x003 && $data['recType'] == self::RT_CSTRING && $data['recLen'] % 2 == 0) {
2795
            // Record Header
2796
            $arrayReturn['length'] += 8;
2797
            // Length
2798
            $strLen = ($data['recLen'] / 2);
2799
            for ($inc = 0; $inc < $strLen; $inc++) {
2800
                $char = self::getInt2d($stream, $pos + $arrayReturn['length']);
2801
                $arrayReturn['length'] += 2;
2802
                $arrayReturn['slideName'] .= Text::chr($char);
2803
            }
2804
        }
2805
2806 4
        return $arrayReturn;
2807
    }
2808
2809
    /**
2810
     * An atom record that specifies a slide number metacharacter.
2811
     * @param string $stream
2812
     * @param integer $pos
2813
     * @link https://msdn.microsoft.com/en-us/library/dd945703(v=office.12).aspx
2814
     * @return array
2815
     */
2816 4
    private function readRecordSlideNumberMCAtom($stream, $pos)
2817
    {
2818
        $arrayReturn = array(
2819 4
            'length' => 0,
2820
        );
2821
2822 4
        $data = $this->loadRecordHeader($stream, $pos);
2823 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_SLIDENUMBERMETACHARATOM && $data['recLen'] == 0x00000004) {
2824
            // Record Header
2825 4
            $arrayReturn['length'] += 8;
2826
            // Datas
2827 4
            $arrayReturn['length'] += $data['recLen'];
2828
        }
2829
2830 4
        return $arrayReturn;
2831
    }
2832
2833
    /**
2834
     * A container record that specifies programmable tags with additional slide data.
2835
     * @param string $stream
2836
     * @param integer $pos
2837
     * @link https://msdn.microsoft.com/en-us/library/dd951946(v=office.12).aspx
2838
     * @return array
2839
     */
2840 4
    private function readRecordSlideProgTagsContainer($stream, $pos)
2841
    {
2842
        $arrayReturn = array(
2843 4
            'length' => 0,
2844
        );
2845
2846 4
        $data = $this->loadRecordHeader($stream, $pos);
2847 4
        if ($data['recVer'] == 0xF && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_PROGTAGS) {
2848
            // Record Header
2849 4
            $arrayReturn['length'] += 8;
2850
            // Length
2851 4
            $arrayReturn['length'] += $data['recLen'];
2852
        }
2853
2854 4
        return $arrayReturn;
2855
    }
2856
2857
    /**
2858
     * A container record that specifies the color scheme used by a slide.
2859
     * @param string $stream
2860
     * @param integer $pos
2861
     * @link https://msdn.microsoft.com/en-us/library/dd949420(v=office.12).aspx
2862
     * @return array
2863
     */
2864 4
    private function readRecordSlideSchemeColorSchemeAtom($stream, $pos)
2865
    {
2866
        $arrayReturn = array(
2867 4
            'length' => 0,
2868
        );
2869
2870 4
        $data = $this->loadRecordHeader($stream, $pos);
2871 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x001 && $data['recType'] == self::RT_COLORSCHEMEATOM && $data['recLen'] == 0x00000020) {
2872
            // Record Header
2873 4
            $arrayReturn['length'] += 8;
2874
            // Length
2875 4
            $rgSchemeColor = array();
2876 4
            for ($inc = 0; $inc <= 7; $inc++) {
2877 4
                $rgSchemeColor[] = array(
2878 4
                    'red' => self::getInt1d($stream, $pos + $arrayReturn['length'] + $inc * 4),
2879 4
                    'green' => self::getInt1d($stream, $pos + $arrayReturn['length'] + $inc * 4 + 1),
2880 4
                    'blue' => self::getInt1d($stream, $pos + $arrayReturn['length'] + $inc * 4 + 2),
2881
                );
2882
            }
2883 4
            $arrayReturn['length'] += (8 * 4);
2884
        }
2885
2886 4
        return $arrayReturn;
2887
    }
2888
2889
    /**
2890
     * An atom record that specifies what transition effect to perform during a slide show, and how to advance to the next presentation slide.
2891
     * @param string $stream
2892
     * @param integer $pos
2893
     * @link https://msdn.microsoft.com/en-us/library/dd943408(v=office.12).aspx
2894
     * @return array
2895
     */
2896 4
    private function readRecordSlideShowSlideInfoAtom($stream, $pos)
2897
    {
2898
        $arrayReturn = array(
2899 4
            'length' => 0,
2900
        );
2901
2902 4
        $data = $this->loadRecordHeader($stream, $pos);
2903 4
        if ($data['recVer'] == 0x0 && $data['recInstance'] == 0x000 && $data['recType'] == self::RT_SLIDESHOWSLIDEINFOATOM && $data['recLen'] == 0x00000010) {
2904
            // Record Header
2905 4
            $arrayReturn['length'] += 8;
2906
            // Length;
2907 4
            $arrayReturn['length'] += $data['recLen'];
2908
        }
2909
2910 4
        return $arrayReturn;
2911
    }
2912
2913
    /**
2914
     * UserEditAtom
2915
     * @link http://msdn.microsoft.com/en-us/library/dd945746(v=office.12).aspx
2916
     * @param string $stream
2917
     * @param integer $pos
2918
     * @throws \Exception
2919
     */
2920 4
    private function readRecordUserEditAtom($stream, $pos)
2921
    {
2922 4
        $rHeader = $this->loadRecordHeader($stream, $pos);
2923 4
        $pos += 8;
2924 4
        if ($rHeader['recVer'] != 0x0 || $rHeader['recInstance'] != 0x000 || $rHeader['recType'] != self::RT_USEREDITATOM || ($rHeader['recLen'] != 0x0000001C && $rHeader['recLen'] != 0x00000020)) {
2925
            throw new \Exception('File PowerPoint 97 in error (Location : UserEditAtom > RecordHeader).');
2926
        }
2927
2928
        // lastSlideIdRef
2929 4
        $pos += 4;
2930
        // version
2931 4
        $pos += 2;
2932
2933
        // minorVersion
2934 4
        $minorVersion = self::getInt1d($stream, $pos);
2935 4
        $pos += 1;
2936 4
        if ($minorVersion != 0x00) {
2937
            throw new \Exception('File PowerPoint 97 in error (Location : UserEditAtom > minorVersion).');
2938
        }
2939
2940
        // majorVersion
2941 4
        $majorVersion = self::getInt1d($stream, $pos);
2942 4
        $pos += 1;
2943 4
        if ($majorVersion != 0x03) {
2944
            throw new \Exception('File PowerPoint 97 in error (Location : UserEditAtom > majorVersion).');
2945
        }
2946
2947
        // offsetLastEdit
2948 4
        $pos += 4;
2949
        // offsetPersistDirectory
2950 4
        $this->offsetPersistDirectory = self::getInt4d($stream, $pos);
2951 4
        $pos += 4;
2952
2953
        // docPersistIdRef
2954 4
        $docPersistIdRef  = self::getInt4d($stream, $pos);
2955 4
        $pos += 4;
2956 4
        if ($docPersistIdRef != 0x00000001) {
2957
            throw new \Exception('File PowerPoint 97 in error (Location : UserEditAtom > docPersistIdRef).');
2958
        }
2959
2960
        // persistIdSeed
2961 4
        $pos += 4;
2962
        // lastView
2963 4
        $pos += 2;
2964
        // unused
2965 4
        $pos += 2;
2966 4
    }
2967
2968
    /**
2969
     * A structure that specifies the character-level formatting of a run of text.
2970
     * @param string $stream
2971
     * @param int $pos
2972
     * @param int $strLenRT
2973
     * @return array
2974
     * @throws \Exception
2975
     * @link https://msdn.microsoft.com/en-us/library/dd945870(v=office.12).aspx
2976
     */
2977 4
    private function readStructureTextCFRun($stream, $pos, $strLenRT)
2978
    {
2979
        $arrayReturn = array(
2980 4
            'length' => 0,
2981 4
            'strLenRT' => $strLenRT,
2982
        );
2983
2984
        // rgTextCFRun
2985 4
        $countRgTextCFRun = self::getInt4d($stream, $pos + $arrayReturn['length']);
2986 4
        $arrayReturn['strLenRT'] -= $countRgTextCFRun;
2987 4
        $arrayReturn['length'] += 4;
2988 4
        $arrayReturn['partLength'] = $countRgTextCFRun;
2989
2990 4
        $masks = self::getInt4d($stream, $pos + $arrayReturn['length']);
2991 4
        $arrayReturn['length'] += 4;
2992
2993 4
        $masksData = array();
2994 4
        $masksData['bold'] = ($masks >> 0) & bindec('1');
2995 4
        $masksData['italic'] = ($masks >> 1) & bindec('1');
2996 4
        $masksData['underline'] = ($masks >> 2) & bindec('1');
2997 4
        $masksData['unused1'] = ($masks >> 3) & bindec('1');
2998 4
        $masksData['shadow'] = ($masks >> 4) & bindec('1');
2999 4
        $masksData['fehint'] = ($masks >> 5) & bindec('1');
3000 4
        $masksData['unused2'] = ($masks >> 6) & bindec('1');
3001 4
        $masksData['kumi'] = ($masks >> 7) & bindec('1');
3002 4
        $masksData['unused3'] = ($masks >> 8) & bindec('1');
3003 4
        $masksData['emboss'] = ($masks >> 9) & bindec('1');
3004 4
        $masksData['fHasStyle'] = ($masks >> 10) & bindec('1111');
3005 4
        $masksData['unused4'] = ($masks >> 14) & bindec('11');
3006 4
        $masksData['typeface'] = ($masks >> 16) & bindec('1');
3007 4
        $masksData['size'] = ($masks >> 17) & bindec('1');
3008 4
        $masksData['color'] = ($masks >> 18) & bindec('1');
3009 4
        $masksData['position'] = ($masks >> 19) & bindec('1');
3010 4
        $masksData['pp10ext'] = ($masks >> 20) & bindec('1');
3011 4
        $masksData['oldEATypeface'] = ($masks >> 21) & bindec('1');
3012 4
        $masksData['ansiTypeface'] = ($masks >> 22) & bindec('1');
3013 4
        $masksData['symbolTypeface'] = ($masks >> 23) & bindec('1');
3014 4
        $masksData['newEATypeface'] = ($masks >> 24) & bindec('1');
3015 4
        $masksData['csTypeface'] = ($masks >> 25) & bindec('1');
3016 4
        $masksData['pp11ext'] = ($masks >> 26) & bindec('1');
3017 4
        if ($masksData['bold'] == 1 || $masksData['italic'] == 1 || $masksData['underline'] == 1 || $masksData['shadow'] == 1 || $masksData['fehint'] == 1 ||  $masksData['kumi'] == 1 ||  $masksData['emboss'] == 1 ||  $masksData['fHasStyle'] == 1) {
3018 3
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3019 3
            $arrayReturn['length'] += 2;
3020
3021 3
            $fontStyleFlags = array();
3022 3
            $fontStyleFlags['bold'] = ($data >> 0) & bindec('1');
3023 3
            $fontStyleFlags['italic'] = ($data >> 1) & bindec('1');
3024 3
            $fontStyleFlags['underline'] = ($data >> 2) & bindec('1');
3025 3
            $fontStyleFlags['unused1'] = ($data >> 3) & bindec('1');
3026 3
            $fontStyleFlags['shadow'] = ($data >> 4) & bindec('1');
3027 3
            $fontStyleFlags['fehint'] = ($data >> 5) & bindec('1');
3028 3
            $fontStyleFlags['unused2'] = ($data >> 6) & bindec('1');
3029 3
            $fontStyleFlags['kumi'] = ($data >> 7) & bindec('1');
3030 3
            $fontStyleFlags['unused3'] = ($data >> 8) & bindec('1');
3031 3
            $fontStyleFlags['emboss'] = ($data >> 9) & bindec('1');
3032 3
            $fontStyleFlags['pp9rt'] = ($data >> 10) & bindec('1111');
3033 3
            $fontStyleFlags['unused4'] = ($data >> 14) & bindec('11');
3034
3035 3
            $arrayReturn['bold'] = ($fontStyleFlags['bold'] == 1) ? true : false;
3036 3
            $arrayReturn['italic'] = ($fontStyleFlags['italic'] == 1) ? true : false;
3037 3
            $arrayReturn['underline'] = ($fontStyleFlags['underline'] == 1) ? true : false;
3038
        }
3039 4
        if ($masksData['typeface'] == 1) {
3040 4
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3041 4
            $arrayReturn['length'] += 2;
3042 4
            $arrayReturn['fontName'] = isset($this->arrayFonts[$data]) ? $this->arrayFonts[$data] : '';
3043
        }
3044 4
        if ($masksData['oldEATypeface'] == 1) {
3045
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3046 4
            $arrayReturn['length'] += 2;
3047
        }
3048 4
        if ($masksData['ansiTypeface'] == 1) {
3049
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3050
            $arrayReturn['length'] += 2;
3051
        }
3052 4
        if ($masksData['symbolTypeface'] == 1) {
3053
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3054
            $arrayReturn['length'] += 2;
3055
        }
3056 4
        if ($masksData['size'] == 1) {
3057 4
            $arrayReturn['fontSize'] = self::getInt2d($stream, $pos + $arrayReturn['length']);
3058 4
            $arrayReturn['length'] += 2;
3059
        }
3060 4
        if ($masksData['color'] == 1) {
3061 4
            $red = self::getInt1d($stream, $pos + $arrayReturn['length']);
3062 4
            $arrayReturn['length'] += 1;
3063 4
            $green = self::getInt1d($stream, $pos + $arrayReturn['length']);
3064 4
            $arrayReturn['length'] += 1;
3065 4
            $blue = self::getInt1d($stream, $pos + $arrayReturn['length']);
3066 4
            $arrayReturn['length'] += 1;
3067 4
            $index = self::getInt1d($stream, $pos + $arrayReturn['length']);
3068 4
            $arrayReturn['length'] += 1;
3069
3070 4
            if ($index == 0xFE) {
3071 4
                $strColor = str_pad(dechex($red), 2, STR_PAD_LEFT, '0');
3072 4
                $strColor .= str_pad(dechex($green), 2, STR_PAD_LEFT, '0');
3073 4
                $strColor .= str_pad(dechex($blue), 2, STR_PAD_LEFT, '0');
3074
3075 4
                $arrayReturn['color'] = new Color('FF'.$strColor);
3076
            }
3077
        }
3078 4
        if ($masksData['position'] == 1) {
3079
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3080
        }
3081
3082 4
        return $arrayReturn;
3083
    }
3084
3085
    /**
3086
     * A structure that specifies the paragraph-level formatting of a run of text.
3087
     * @param string $stream
3088
     * @param integer $pos
3089
     * @param integer $strLenRT
3090
     * @return array
3091
     * @throws \Exception
3092
     * @link https://msdn.microsoft.com/en-us/library/dd923535(v=office.12).aspx
3093
     */
3094 4
    private function readStructureTextPFRun($stream, $pos, $strLenRT)
3095
    {
3096
        $arrayReturn = array(
3097 4
            'length' => 0,
3098 4
            'strLenRT' => $strLenRT,
3099
        );
3100
3101
        // rgTextPFRun
3102 4
        $countRgTextPFRun = self::getInt4d($stream, $pos + $arrayReturn['length']);
3103 4
        $arrayReturn['strLenRT'] -= $countRgTextPFRun;
3104 4
        $arrayReturn['length'] += 4;
3105
3106
        // indent
3107 4
        $arrayReturn['length'] += 2;
3108
3109 4
        $masks = self::getInt4d($stream, $pos + $arrayReturn['length']);
3110 4
        $arrayReturn['length'] += 4;
3111
3112 4
        $masksData = array();
3113 4
        $masksData['hasBullet'] = ($masks >> 0) & bindec('1');
3114 4
        $masksData['bulletHasFont'] = ($masks >> 1) & bindec('1');
3115 4
        $masksData['bulletHasColor'] = ($masks >> 2) & bindec('1');
3116 4
        $masksData['bulletHasSize'] = ($masks >> 3) & bindec('1');
3117 4
        $masksData['bulletFont'] = ($masks >> 4) & bindec('1');
3118 4
        $masksData['bulletColor'] = ($masks >> 5) & bindec('1');
3119 4
        $masksData['bulletSize'] = ($masks >> 6) & bindec('1');
3120 4
        $masksData['bulletChar'] = ($masks >> 7) & bindec('1');
3121 4
        $masksData['leftMargin'] = ($masks >> 8) & bindec('1');
3122 4
        $masksData['unused'] = ($masks >> 9) & bindec('1');
3123 4
        $masksData['indent'] = ($masks >> 10) & bindec('1');
3124 4
        $masksData['align'] = ($masks >> 11) & bindec('1');
3125 4
        $masksData['lineSpacing'] = ($masks >> 12) & bindec('1');
3126 4
        $masksData['spaceBefore'] = ($masks >> 13) & bindec('1');
3127 4
        $masksData['spaceAfter'] = ($masks >> 14) & bindec('1');
3128 4
        $masksData['defaultTabSize'] = ($masks >> 15) & bindec('1');
3129 4
        $masksData['fontAlign'] = ($masks >> 16) & bindec('1');
3130 4
        $masksData['charWrap'] = ($masks >> 17) & bindec('1');
3131 4
        $masksData['wordWrap'] = ($masks >> 18) & bindec('1');
3132 4
        $masksData['overflow'] = ($masks >> 19) & bindec('1');
3133 4
        $masksData['tabStops'] = ($masks >> 20) & bindec('1');
3134 4
        $masksData['textDirection'] = ($masks >> 21) & bindec('1');
3135 4
        $masksData['reserved1'] = ($masks >> 22) & bindec('1');
3136 4
        $masksData['bulletBlip'] = ($masks >> 23) & bindec('1');
3137 4
        $masksData['bulletScheme'] = ($masks >> 24) & bindec('1');
3138 4
        $masksData['bulletHasScheme'] = ($masks >> 25) & bindec('1');
3139
3140 4
        $bulletFlags = array();
3141 4
        if ($masksData['hasBullet'] == 1 || $masksData['bulletHasFont'] == 1  || $masksData['bulletHasColor'] == 1  || $masksData['bulletHasSize'] == 1) {
3142 4
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3143 4
            $arrayReturn['length'] += 2;
3144
3145 4
            $bulletFlags['fHasBullet'] = ($data >> 0) & bindec('1');
3146 4
            $bulletFlags['fBulletHasFont'] = ($data >> 1) & bindec('1');
3147 4
            $bulletFlags['fBulletHasColor'] = ($data >> 2) & bindec('1');
3148 4
            $bulletFlags['fBulletHasSize'] = ($data >> 3) & bindec('1');
3149
        }
3150 4
        if ($masksData['bulletChar'] == 1) {
3151 1
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3152 1
            $arrayReturn['length'] += 2;
3153 1
            $arrayReturn['bulletChar'] = chr($data);
3154
        }
3155 4
        if ($masksData['bulletFont'] == 1) {
3156
            // $data = self::getInt2d($stream, $pos);
3157 1
            $arrayReturn['length'] += 2;
3158
        }
3159 4
        if ($masksData['bulletSize'] == 1) {
3160
            // $data = self::getInt2d($stream, $pos);
3161 2
            $arrayReturn['length'] += 2;
3162
        }
3163 4
        if ($masksData['bulletColor'] == 1) {
3164 1
            $red = self::getInt1d($stream, $pos + $arrayReturn['length']);
3165 1
            $arrayReturn['length'] += 1;
3166 1
            $green = self::getInt1d($stream, $pos + $arrayReturn['length']);
3167 1
            $arrayReturn['length'] += 1;
3168 1
            $blue = self::getInt1d($stream, $pos + $arrayReturn['length']);
3169 1
            $arrayReturn['length'] += 1;
3170 1
            $index = self::getInt1d($stream, $pos + $arrayReturn['length']);
3171 1
            $arrayReturn['length'] += 1;
3172
3173 1
            if ($index == 0xFE) {
3174 1
                $strColor = str_pad(dechex($red), 2, STR_PAD_LEFT, '0');
3175 1
                $strColor .= str_pad(dechex($green), 2, STR_PAD_LEFT, '0');
3176 1
                $strColor .= str_pad(dechex($blue), 2, STR_PAD_LEFT, '0');
3177
            }
3178
        }
3179 4
        if ($masksData['align'] == 1) {
3180 4
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3181 4
            $arrayReturn['length'] += 2;
3182
            switch ($data) {
3183 4
                case 0x0000:
3184 1
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_LEFT;
3185 1
                    break;
3186 4
                case 0x0001:
3187 2
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_CENTER;
3188 2
                    break;
3189 4
                case 0x0002:
3190 4
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_RIGHT;
3191 4
                    break;
3192
                case 0x0003:
3193
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_JUSTIFY;
3194
                    break;
3195
                case 0x0004:
3196
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_DISTRIBUTED;
3197
                    break;
3198
                case 0x0005:
3199
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_DISTRIBUTED;
3200
                    break;
3201
                case 0x0006:
3202
                    $arrayReturn['alignH'] = Alignment::HORIZONTAL_JUSTIFY;
3203
                    break;
3204
                default:
3205
                    break;
3206
            }
3207
        }
3208 4
        if ($masksData['lineSpacing'] == 1) {
3209
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3210 4
            $arrayReturn['length'] += 2;
3211
        }
3212 4
        if ($masksData['spaceBefore'] == 1) {
3213
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3214 2
            $arrayReturn['length'] += 2;
3215
        }
3216 4
        if ($masksData['spaceAfter'] == 1) {
3217
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3218 2
            $arrayReturn['length'] += 2;
3219
        }
3220 4
        if ($masksData['leftMargin'] == 1) {
3221 1
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3222 1
            $arrayReturn['length'] += 2;
3223 1
            $arrayReturn['leftMargin'] = (int)round($data/6);
3224
        }
3225 4
        if ($masksData['indent'] == 1) {
3226 1
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3227 1
            $arrayReturn['length'] += 2;
3228 1
            $arrayReturn['indent'] = (int)round($data/6);
3229
        }
3230 4
        if ($masksData['defaultTabSize'] == 1) {
3231
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3232
            $arrayReturn['length'] += 2;
3233
        }
3234 4
        if ($masksData['tabStops'] == 1) {
3235
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3236
        }
3237 4
        if ($masksData['fontAlign'] == 1) {
3238
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3239
            $arrayReturn['length'] += 2;
3240
        }
3241 4
        if ($masksData['charWrap'] == 1 || $masksData['wordWrap'] == 1 || $masksData['overflow'] == 1) {
3242
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3243 4
            $arrayReturn['length'] += 2;
3244
        }
3245 4
        if ($masksData['textDirection'] == 1) {
3246
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3247
        }
3248
3249 4
        return $arrayReturn;
3250
    }
3251
3252
    /**
3253
     * A structure that specifies language and spelling information for a run of text.
3254
     * @param string $stream
3255
     * @param integer $pos
3256
     * @param string $strLenRT
3257
     * @return array
3258
     * @throws \Exception
3259
     * @link https://msdn.microsoft.com/en-us/library/dd909603(v=office.12).aspx
3260
     */
3261 4
    private function readStructureTextSIRun($stream, $pos, $strLenRT)
3262
    {
3263
        $arrayReturn = array(
3264 4
            'length' => 0,
3265 4
            'strLenRT' => $strLenRT,
3266
        );
3267
3268 4
        $arrayReturn['strLenRT'] -= self::getInt4d($stream, $pos + $arrayReturn['length']);
3269 4
        $arrayReturn['length'] += 4;
3270
3271 4
        $data = self::getInt4d($stream, $pos + $arrayReturn['length']);
3272 4
        $arrayReturn['length'] += 4;
3273 4
        $masksData = array();
3274 4
        $masksData['spell'] = ($data >> 0) & bindec('1');
3275 4
        $masksData['lang'] = ($data >> 1) & bindec('1');
3276 4
        $masksData['altLang'] = ($data >> 2) & bindec('1');
3277 4
        $masksData['unused1'] = ($data >> 3) & bindec('1');
3278 4
        $masksData['unused2'] = ($data >> 4) & bindec('1');
3279 4
        $masksData['fPp10ext'] = ($data >> 5) & bindec('1');
3280 4
        $masksData['fBidi'] = ($data >> 6) & bindec('1');
3281 4
        $masksData['unused3'] = ($data >> 7) & bindec('1');
3282 4
        $masksData['reserved1'] = ($data >> 8) & bindec('1');
3283 4
        $masksData['smartTag'] = ($data >> 9) & bindec('1');
3284
3285 4
        if ($masksData['spell'] == 1) {
3286 4
            $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3287 4
            $arrayReturn['length'] += 2;
3288 4
            $masksSpell = array();
3289 4
            $masksSpell['error'] = ($data >> 0) & bindec('1');
3290 4
            $masksSpell['clean'] = ($data >> 1) & bindec('1');
3291 4
            $masksSpell['grammar'] = ($data >> 2) & bindec('1');
3292
        }
3293 4
        if ($masksData['lang'] == 1) {
3294
            // $data = self::getInt2d($stream, $pos);
3295 4
            $arrayReturn['length'] += 2;
3296
        }
3297 4
        if ($masksData['altLang'] == 1) {
3298
            // $data = self::getInt2d($stream, $pos);
3299 4
            $arrayReturn['length'] += 2;
3300
        }
3301 4
        if ($masksData['fBidi'] == 1) {
3302
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3303
        }
3304 4
        if ($masksData['fPp10ext'] == 1) {
3305
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3306
        }
3307 4
        if ($masksData['smartTag'] == 1) {
3308
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3309
        }
3310
3311 4
        return $arrayReturn;
3312
    }
3313
3314
    /**
3315
     * A structure that specifies tabbing, margins, and indentation for text.
3316
     * @param string $stream
3317
     * @param integer $pos
3318
     * @return array
3319
     * @throws \Exception
3320
     * @link https://msdn.microsoft.com/en-us/library/dd922749(v=office.12).aspx
3321
     */
3322 4
    private function readStructureTextRuler($stream, $pos)
3323
    {
3324
        $arrayReturn = array(
3325 4
            'length' => 0,
3326
        );
3327
3328 4
        $data = self::getInt4d($stream, $pos + $arrayReturn['length']);
3329 4
        $arrayReturn['length'] += 4;
3330
3331 4
        $masksData = array();
3332 4
        $masksData['fDefaultTabSize'] = ($data >> 0) & bindec('1');
3333 4
        $masksData['fCLevels'] = ($data >> 1) & bindec('1');
3334 4
        $masksData['fTabStops'] = ($data >> 2) & bindec('1');
3335 4
        $masksData['fLeftMargin1'] = ($data >> 3) & bindec('1');
3336 4
        $masksData['fLeftMargin2'] = ($data >> 4) & bindec('1');
3337 4
        $masksData['fLeftMargin3'] = ($data >> 5) & bindec('1');
3338 4
        $masksData['fLeftMargin4'] = ($data >> 6) & bindec('1');
3339 4
        $masksData['fLeftMargin5'] = ($data >> 7) & bindec('1');
3340 4
        $masksData['fIndent1'] = ($data >> 8) & bindec('1');
3341 4
        $masksData['fIndent2'] = ($data >> 9) & bindec('1');
3342 4
        $masksData['fIndent3'] = ($data >> 10) & bindec('1');
3343 4
        $masksData['fIndent4'] = ($data >> 11) & bindec('1');
3344 4
        $masksData['fIndent5'] = ($data >> 12) & bindec('1');
3345
3346 4
        if ($masksData['fCLevels'] == 1) {
3347
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3348
        }
3349 4
        if ($masksData['fDefaultTabSize'] == 1) {
3350
            throw new \Exception('Feature not implemented (l.'.__LINE__.')');
3351
        }
3352 4
        if ($masksData['fTabStops'] == 1) {
3353 4
            $count = self::getInt2d($stream, $pos + $arrayReturn['length']);
3354 4
            $arrayReturn['length'] += 2;
3355 4
            $arrayTabStops = array();
3356 4
            for ($inc = 0; $inc < $count; $inc++) {
3357 4
                $position = self::getInt2d($stream, $pos + $arrayReturn['length']);
3358 4
                $arrayReturn['length'] += 2;
3359 4
                $type = self::getInt2d($stream, $pos + $arrayReturn['length']);
3360 4
                $arrayReturn['length'] += 2;
3361 4
                $arrayTabStops[] = array(
3362 4
                    'position' => $position,
3363 4
                    'type' => $type,
3364
                );
3365
            }
3366
        }
3367 4
        if ($masksData['fLeftMargin1'] == 1) {
3368
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3369 1
            $arrayReturn['length'] += 2;
3370
        }
3371 4
        if ($masksData['fIndent1'] == 1) {
3372
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3373 1
            $arrayReturn['length'] += 2;
3374
        }
3375 4
        if ($masksData['fLeftMargin2'] == 1) {
3376
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3377 1
            $arrayReturn['length'] += 2;
3378
        }
3379 4
        if ($masksData['fIndent2'] == 1) {
3380
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3381 1
            $arrayReturn['length'] += 2;
3382
        }
3383 4
        if ($masksData['fLeftMargin3'] == 1) {
3384
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3385
            $arrayReturn['length'] += 2;
3386
        }
3387 4
        if ($masksData['fIndent3'] == 1) {
3388
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3389
            $arrayReturn['length'] += 2;
3390
        }
3391 4
        if ($masksData['fLeftMargin4'] == 1) {
3392
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3393
            $arrayReturn['length'] += 2;
3394
        }
3395 4
        if ($masksData['fIndent4'] == 1) {
3396
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3397
            $arrayReturn['length'] += 2;
3398
        }
3399 4
        if ($masksData['fLeftMargin5'] == 1) {
3400
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3401
            $arrayReturn['length'] += 2;
3402
        }
3403 4
        if ($masksData['fIndent5'] == 1) {
3404
            // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
3405
            $arrayReturn['length'] += 2;
3406
        }
3407
3408 4
        return $arrayReturn;
3409
    }
3410
3411
    /**
3412
     * @param $stream
3413
     * @param int $pos
3414
     * @throws \Exception
3415
     */
3416 4
    private function readRecordNotesContainer($stream, $pos)
3417
    {
3418
        // notesAtom
3419 4
        $notesAtom = $this->readRecordNotesAtom($stream, $pos);
3420 4
        $pos += $notesAtom['length'];
3421
3422
        // drawing
3423 4
        $drawing = $this->readRecordDrawingContainer($stream, $pos);
3424 4
        $pos += $drawing['length'];
3425
3426
        // slideSchemeColorSchemeAtom
3427
        // slideNameAtom
3428
        // slideProgTagsContainer
3429
        // rgNotesRoundTripAtom
3430 4
    }
3431
3432
    /**
3433
     * @param $stream
3434
     * @param int $pos
3435
     * @return array
3436
     * @throws \Exception
3437
     */
3438 4
    private function readRecordNotesAtom($stream, $pos)
3439
    {
3440
        $arrayReturn = array(
3441 4
            'length' => 0,
3442
        );
3443
3444 4
        $data = $this->loadRecordHeader($stream, $pos);
3445 4
        if ($data['recVer'] != 0x1 || $data['recInstance'] != 0x000 || $data['recType'] != self::RT_NOTESATOM || $data['recLen'] != 0x00000008) {
3446
            throw new \Exception('File PowerPoint 97 in error (Location : NotesAtom > RecordHeader)');
3447
        }
3448
        // Record Header
3449 4
        $arrayReturn['length'] += 8;
3450
        // NotesAtom > slideIdRef
3451 4
        $notesIdRef = self::getInt4d($stream, $pos + $arrayReturn['length']);
3452 4
        if ($notesIdRef == -2147483648) {
3453
            $notesIdRef = 0;
3454
        }
3455 4
        $this->currentNote = $notesIdRef;
3456 4
        $arrayReturn['length'] += 4;
3457
3458
        // NotesAtom > slideFlags
3459 4
        $arrayReturn['length'] += 2;
3460
        // NotesAtom > unused
3461 4
        $arrayReturn['length'] += 2;
3462
3463 4
        return $arrayReturn;
3464
    }
3465
}
3466