Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.05% covered (success)
90.05%
1285 / 1427
80.00% covered (warning)
80.00%
16 / 20
CRAP
0.00% covered (danger)
0.00%
0 / 1
MsDoc
90.05% covered (success)
90.05%
1285 / 1427
80.00% covered (warning)
80.00%
16 / 20
243.61
0.00% covered (danger)
0.00%
0 / 1
 load
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 loadOLE
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 getNumInLcb
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getArrayCP
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 readFib
88.51% covered (warning)
88.51%
77 / 87
0.00% covered (danger)
0.00%
0 / 1
7.07
 readBlockFibRgFcLcb
100.00% covered (success)
100.00%
738 / 738
100.00% covered (success)
100.00%
1 / 1
6
 readFibContent
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 readRecordPlcfSed
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
3
 readRecordSttbfFfn
100.00% covered (success)
100.00%
33 / 33
100.00% covered (success)
100.00%
1 / 1
7
 readRecordPlcfBtePapx
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
8
 readRecordPlcfBteChpx
100.00% covered (success)
100.00%
32 / 32
100.00% covered (success)
100.00%
1 / 1
6
 readSprm
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 readSprmSpra
90.70% covered (success)
90.70%
39 / 43
0.00% covered (danger)
0.00%
0 / 1
14.16
 readPrl
66.57% covered (warning)
66.57%
239 / 359
0.00% covered (danger)
0.00%
0 / 1
647.88
 loadRecordHeader
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
 generatePhpWord
79.49% covered (warning)
79.49%
31 / 39
0.00% covered (danger)
0.00%
0 / 1
23.45
 getInt1d
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInt2d
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInt3d
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getInt4d
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * This file is part of PHPWord - A pure PHP library for reading and writing
4 * word processing documents.
5 *
6 * PHPWord 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/PHPWord/contributors.
12 *
13 * @see         https://github.com/PHPOffice/PHPWord
14 *
15 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16 */
17
18namespace PhpOffice\PhpWord\Reader;
19
20use PhpOffice\PhpWord\PhpWord;
21use PhpOffice\PhpWord\Shared\Drawing;
22use PhpOffice\PhpWord\Shared\OLERead;
23use PhpOffice\PhpWord\Style;
24use stdClass;
25
26/**
27 * Reader for Word97.
28 *
29 * @since 0.10.0
30 */
31class MsDoc extends AbstractReader implements ReaderInterface
32{
33    /**
34     * PhpWord object.
35     *
36     * @var PhpWord
37     */
38    private $phpWord;
39
40    /**
41     * WordDocument Stream.
42     */
43    private $dataWorkDocument;
44
45    /**
46     * 1Table Stream.
47     */
48    private $data1Table;
49
50    /**
51     * Data Stream.
52     */
53    private $dataData;
54
55    /**
56     * Object Pool Stream.
57     */
58    private $dataObjectPool;
59
60    /**
61     * @var stdClass[]
62     */
63    private $arrayCharacters = [];
64
65    /**
66     * @var array
67     */
68    private $arrayFib = [];
69
70    /**
71     * @var string[]
72     */
73    private $arrayFonts = [];
74
75    /**
76     * @var string[]
77     */
78    private $arrayParagraphs = [];
79
80    /**
81     * @var stdClass[]
82     */
83    private $arraySections = [];
84
85    /** @var string */
86    private $summaryInformation;
87
88    /** @var string */
89    private $documentSummaryInformation;
90
91    const VERSION_97 = '97';
92    const VERSION_2000 = '2000';
93    const VERSION_2002 = '2002';
94    const VERSION_2003 = '2003';
95    const VERSION_2007 = '2007';
96
97    const SPRA_VALUE = 10;
98    const SPRA_VALUE_OPPOSITE = 20;
99
100    const OFFICEARTBLIPEMF = 0xF01A;
101    const OFFICEARTBLIPWMF = 0xF01B;
102    const OFFICEARTBLIPPICT = 0xF01C;
103    const OFFICEARTBLIPJPG = 0xF01D;
104    const OFFICEARTBLIPPNG = 0xF01E;
105    const OFFICEARTBLIPDIB = 0xF01F;
106    const OFFICEARTBLIPTIFF = 0xF029;
107    const OFFICEARTBLIPJPEG = 0xF02A;
108
109    const MSOBLIPERROR = 0x00;
110    const MSOBLIPUNKNOWN = 0x01;
111    const MSOBLIPEMF = 0x02;
112    const MSOBLIPWMF = 0x03;
113    const MSOBLIPPICT = 0x04;
114    const MSOBLIPJPEG = 0x05;
115    const MSOBLIPPNG = 0x06;
116    const MSOBLIPDIB = 0x07;
117    const MSOBLIPTIFF = 0x11;
118    const MSOBLIPCMYKJPEG = 0x12;
119
120    /**
121     * Loads PhpWord from file.
122     *
123     * @param string $filename
124     *
125     * @return PhpWord
126     */
127    public function load($filename)
128    {
129        $this->phpWord = new PhpWord();
130
131        $this->loadOLE($filename);
132
133        $this->readFib($this->dataWorkDocument);
134        $this->readFibContent();
135
136        return $this->phpWord;
137    }
138
139    /**
140     * Load an OLE Document.
141     *
142     * @param string $filename
143     */
144    private function loadOLE($filename): void
145    {
146        // OLE reader
147        $ole = new OLERead();
148        $ole->read($filename);
149
150        // Get WorkDocument stream
151        $this->dataWorkDocument = $ole->getStream($ole->wrkdocument);
152        // Get 1Table stream
153        $this->data1Table = $ole->getStream($ole->wrk1Table);
154        // Get Data stream
155        $this->dataData = $ole->getStream($ole->wrkData);
156        // Get Data stream
157        $this->dataObjectPool = $ole->getStream($ole->wrkObjectPool);
158        // Get Summary Information data
159        $this->summaryInformation = $ole->getStream($ole->summaryInformation);
160        // Get Document Summary Information data
161        $this->documentSummaryInformation = $ole->getStream($ole->docSummaryInfos);
162    }
163
164    private function getNumInLcb($lcb, $iSize)
165    {
166        return ($lcb - 4) / (4 + $iSize);
167    }
168
169    private function getArrayCP($data, $posMem, $iNum)
170    {
171        $arrayCP = [];
172        for ($inc = 0; $inc < $iNum; ++$inc) {
173            $arrayCP[$inc] = self::getInt4d($data, $posMem);
174            $posMem += 4;
175        }
176
177        return $arrayCP;
178    }
179
180    /**
181     * @see  http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
182     * @see  https://igor.io/2012/09/24/binary-parsing.html
183     *
184     * @param string $data
185     */
186    private function readFib($data)
187    {
188        $pos = 0;
189        //----- FibBase
190        // wIdent
191        $pos += 2;
192        // nFib
193        $pos += 2;
194        // unused
195        $pos += 2;
196        // lid : Language Identifier
197        $pos += 2;
198        // pnNext
199        $pos += 2;
200
201        // $mem = self::getInt2d($data, $pos);
202        // $fDot = ($mem >> 15) & 1;
203        // $fGlsy = ($mem >> 14) & 1;
204        // $fComplex = ($mem >> 13) & 1;
205        // $fHasPic = ($mem >> 12) & 1;
206        // $cQuickSaves = ($mem >> 8) & bindec('1111');
207        // $fEncrypted = ($mem >> 7) & 1;
208        // $fWhichTblStm = ($mem >> 6) & 1;
209        // $fReadOnlyRecommended = ($mem >> 5) & 1;
210        // $fWriteReservation = ($mem >> 4) & 1;
211        // $fExtChar = ($mem >> 3) & 1;
212        // $fLoadOverride = ($mem >> 2) & 1;
213        // $fFarEast = ($mem >> 1) & 1;
214        // $fObfuscated = ($mem >> 0) & 1;
215        $pos += 2;
216        // nFibBack
217        $pos += 2;
218        // lKey
219        $pos += 4;
220        // envr
221        ++$pos;
222
223        // $mem = self::getInt1d($data, $pos);
224        // $fMac = ($mem >> 7) & 1;
225        // $fEmptySpecial = ($mem >> 6) & 1;
226        // $fLoadOverridePage = ($mem >> 5) & 1;
227        // $reserved1 = ($mem >> 4) & 1;
228        // $reserved2 = ($mem >> 3) & 1;
229        // $fSpare0 = ($mem >> 0) & bindec('111');
230        ++$pos;
231
232        // reserved3
233        $pos += 2;
234        // reserved4
235        $pos += 2;
236        // reserved5
237        $pos += 4;
238        // reserved6
239        $pos += 4;
240
241        //----- csw
242        $pos += 2;
243
244        //----- fibRgW
245        // reserved1
246        $pos += 2;
247        // reserved2
248        $pos += 2;
249        // reserved3
250        $pos += 2;
251        // reserved4
252        $pos += 2;
253        // reserved5
254        $pos += 2;
255        // reserved6
256        $pos += 2;
257        // reserved7
258        $pos += 2;
259        // reserved8
260        $pos += 2;
261        // reserved9
262        $pos += 2;
263        // reserved10
264        $pos += 2;
265        // reserved11
266        $pos += 2;
267        // reserved12
268        $pos += 2;
269        // reserved13
270        $pos += 2;
271        // lidFE
272        $pos += 2;
273
274        //----- cslw
275        $pos += 2;
276
277        //----- fibRgLw
278        // cbMac
279        $pos += 4;
280        // reserved1
281        $pos += 4;
282        // reserved2
283        $pos += 4;
284        $this->arrayFib['ccpText'] = self::getInt4d($data, $pos);
285        $pos += 4;
286        $this->arrayFib['ccpFtn'] = self::getInt4d($data, $pos);
287        $pos += 4;
288        $this->arrayFib['ccpHdd'] = self::getInt4d($data, $pos);
289        $pos += 4;
290        // reserved3
291        $pos += 4;
292        // ccpAtn
293        $pos += 4;
294        // ccpEdn
295        $pos += 4;
296        // ccpTxbx
297        $pos += 4;
298        // ccpHdrTxbx
299        $pos += 4;
300        // reserved4
301        $pos += 4;
302        // reserved5
303        $pos += 4;
304        // reserved6
305        $pos += 4;
306        // reserved7
307        $pos += 4;
308        // reserved8
309        $pos += 4;
310        // reserved9
311        $pos += 4;
312        // reserved10
313        $pos += 4;
314        // reserved11
315        $pos += 4;
316        // reserved12
317        $pos += 4;
318        // reserved13
319        $pos += 4;
320        // reserved14
321        $pos += 4;
322
323        //----- cbRgFcLcb
324        $cbRgFcLcb = self::getInt2d($data, $pos);
325        $pos += 2;
326        //----- fibRgFcLcbBlob
327        switch ($cbRgFcLcb) {
328            case 0x005D:
329                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97);
330
331                break;
332            case 0x006C:
333                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97);
334                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000);
335
336                break;
337            case 0x0088:
338                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97);
339                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000);
340                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002);
341
342                break;
343            case 0x00A4:
344                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97);
345                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000);
346                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002);
347                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2003);
348
349                break;
350            case 0x00B7:
351                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_97);
352                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2000);
353                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2002);
354                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2003);
355                $pos = $this->readBlockFibRgFcLcb($data, $pos, self::VERSION_2007);
356
357                break;
358        }
359        //----- cswNew
360        $this->arrayFib['cswNew'] = self::getInt2d($data, $pos);
361        $pos += 2;
362
363        if ($this->arrayFib['cswNew'] != 0) {
364            //@todo : fibRgCswNew
365        }
366
367        return $pos;
368    }
369
370    private function readBlockFibRgFcLcb($data, $pos, $version)
371    {
372        if ($version == self::VERSION_97) {
373            $this->arrayFib['fcStshfOrig'] = self::getInt4d($data, $pos);
374            $pos += 4;
375            $this->arrayFib['lcbStshfOrig'] = self::getInt4d($data, $pos);
376            $pos += 4;
377            $this->arrayFib['fcStshf'] = self::getInt4d($data, $pos);
378            $pos += 4;
379            $this->arrayFib['lcbStshf'] = self::getInt4d($data, $pos);
380            $pos += 4;
381            $this->arrayFib['fcPlcffndRef'] = self::getInt4d($data, $pos);
382            $pos += 4;
383            $this->arrayFib['lcbPlcffndRef'] = self::getInt4d($data, $pos);
384            $pos += 4;
385            $this->arrayFib['fcPlcffndTxt'] = self::getInt4d($data, $pos);
386            $pos += 4;
387            $this->arrayFib['lcbPlcffndTxt'] = self::getInt4d($data, $pos);
388            $pos += 4;
389            $this->arrayFib['fcPlcfandRef'] = self::getInt4d($data, $pos);
390            $pos += 4;
391            $this->arrayFib['lcbPlcfandRef'] = self::getInt4d($data, $pos);
392            $pos += 4;
393            $this->arrayFib['fcPlcfandTxt'] = self::getInt4d($data, $pos);
394            $pos += 4;
395            $this->arrayFib['lcbPlcfandTxt '] = self::getInt4d($data, $pos);
396            $pos += 4;
397            $this->arrayFib['fcPlcfSed'] = self::getInt4d($data, $pos);
398            $pos += 4;
399            $this->arrayFib['lcbPlcfSed'] = self::getInt4d($data, $pos);
400            $pos += 4;
401            $this->arrayFib['fcPlcPad'] = self::getInt4d($data, $pos);
402            $pos += 4;
403            $this->arrayFib['lcbPlcPad'] = self::getInt4d($data, $pos);
404            $pos += 4;
405            $this->arrayFib['fcPlcfPhe'] = self::getInt4d($data, $pos);
406            $pos += 4;
407            $this->arrayFib['lcbPlcfPhe'] = self::getInt4d($data, $pos);
408            $pos += 4;
409            $this->arrayFib['fcSttbfGlsy'] = self::getInt4d($data, $pos);
410            $pos += 4;
411            $this->arrayFib['lcbSttbfGlsy'] = self::getInt4d($data, $pos);
412            $pos += 4;
413            $this->arrayFib['fcPlcfGlsy'] = self::getInt4d($data, $pos);
414            $pos += 4;
415            $this->arrayFib['lcbPlcfGlsy'] = self::getInt4d($data, $pos);
416            $pos += 4;
417            $this->arrayFib['fcPlcfHdd'] = self::getInt4d($data, $pos);
418            $pos += 4;
419            $this->arrayFib['lcbPlcfHdd'] = self::getInt4d($data, $pos);
420            $pos += 4;
421            $this->arrayFib['fcPlcfBteChpx'] = self::getInt4d($data, $pos);
422            $pos += 4;
423            $this->arrayFib['lcbPlcfBteChpx'] = self::getInt4d($data, $pos);
424            $pos += 4;
425            $this->arrayFib['fcPlcfBtePapx'] = self::getInt4d($data, $pos);
426            $pos += 4;
427            $this->arrayFib['lcbPlcfBtePapx'] = self::getInt4d($data, $pos);
428            $pos += 4;
429            $this->arrayFib['fcPlcfSea'] = self::getInt4d($data, $pos);
430            $pos += 4;
431            $this->arrayFib['lcbPlcfSea'] = self::getInt4d($data, $pos);
432            $pos += 4;
433            $this->arrayFib['fcSttbfFfn'] = self::getInt4d($data, $pos);
434            $pos += 4;
435            $this->arrayFib['lcbSttbfFfn'] = self::getInt4d($data, $pos);
436            $pos += 4;
437            $this->arrayFib['fcPlcfFldMom'] = self::getInt4d($data, $pos);
438            $pos += 4;
439            $this->arrayFib['lcbPlcfFldMom'] = self::getInt4d($data, $pos);
440            $pos += 4;
441            $this->arrayFib['fcPlcfFldHdr'] = self::getInt4d($data, $pos);
442            $pos += 4;
443            $this->arrayFib['lcbPlcfFldHdr'] = self::getInt4d($data, $pos);
444            $pos += 4;
445            $this->arrayFib['fcPlcfFldFtn'] = self::getInt4d($data, $pos);
446            $pos += 4;
447            $this->arrayFib['lcbPlcfFldFtn'] = self::getInt4d($data, $pos);
448            $pos += 4;
449            $this->arrayFib['fcPlcfFldAtn'] = self::getInt4d($data, $pos);
450            $pos += 4;
451            $this->arrayFib['lcbPlcfFldAtn'] = self::getInt4d($data, $pos);
452            $pos += 4;
453            $this->arrayFib['fcPlcfFldMcr'] = self::getInt4d($data, $pos);
454            $pos += 4;
455            $this->arrayFib['lcbPlcfFldMcr'] = self::getInt4d($data, $pos);
456            $pos += 4;
457            $this->arrayFib['fcSttbfBkmk'] = self::getInt4d($data, $pos);
458            $pos += 4;
459            $this->arrayFib['lcbSttbfBkmk'] = self::getInt4d($data, $pos);
460            $pos += 4;
461            $this->arrayFib['fcPlcfBkf'] = self::getInt4d($data, $pos);
462            $pos += 4;
463            $this->arrayFib['lcbPlcfBkf'] = self::getInt4d($data, $pos);
464            $pos += 4;
465            $this->arrayFib['fcPlcfBkl'] = self::getInt4d($data, $pos);
466            $pos += 4;
467            $this->arrayFib['lcbPlcfBkl'] = self::getInt4d($data, $pos);
468            $pos += 4;
469            $this->arrayFib['fcCmds'] = self::getInt4d($data, $pos);
470            $pos += 4;
471            $this->arrayFib['lcbCmds'] = self::getInt4d($data, $pos);
472            $pos += 4;
473            $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos);
474            $pos += 4;
475            $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos);
476            $pos += 4;
477            $this->arrayFib['fcSttbfMcr'] = self::getInt4d($data, $pos);
478            $pos += 4;
479            $this->arrayFib['lcbSttbfMcr'] = self::getInt4d($data, $pos);
480            $pos += 4;
481            $this->arrayFib['fcPrDrvr'] = self::getInt4d($data, $pos);
482            $pos += 4;
483            $this->arrayFib['lcbPrDrvr'] = self::getInt4d($data, $pos);
484            $pos += 4;
485            $this->arrayFib['fcPrEnvPort'] = self::getInt4d($data, $pos);
486            $pos += 4;
487            $this->arrayFib['lcbPrEnvPort'] = self::getInt4d($data, $pos);
488            $pos += 4;
489            $this->arrayFib['fcPrEnvLand'] = self::getInt4d($data, $pos);
490            $pos += 4;
491            $this->arrayFib['lcbPrEnvLand'] = self::getInt4d($data, $pos);
492            $pos += 4;
493            $this->arrayFib['fcWss'] = self::getInt4d($data, $pos);
494            $pos += 4;
495            $this->arrayFib['lcbWss'] = self::getInt4d($data, $pos);
496            $pos += 4;
497            $this->arrayFib['fcDop'] = self::getInt4d($data, $pos);
498            $pos += 4;
499            $this->arrayFib['lcbDop'] = self::getInt4d($data, $pos);
500            $pos += 4;
501            $this->arrayFib['fcSttbfAssoc'] = self::getInt4d($data, $pos);
502            $pos += 4;
503            $this->arrayFib['lcbSttbfAssoc'] = self::getInt4d($data, $pos);
504            $pos += 4;
505            $this->arrayFib['fcClx'] = self::getInt4d($data, $pos);
506            $pos += 4;
507            $this->arrayFib['lcbClx'] = self::getInt4d($data, $pos);
508            $pos += 4;
509            $this->arrayFib['fcPlcfPgdFtn'] = self::getInt4d($data, $pos);
510            $pos += 4;
511            $this->arrayFib['lcbPlcfPgdFtn'] = self::getInt4d($data, $pos);
512            $pos += 4;
513            $this->arrayFib['fcAutosaveSource'] = self::getInt4d($data, $pos);
514            $pos += 4;
515            $this->arrayFib['lcbAutosaveSource'] = self::getInt4d($data, $pos);
516            $pos += 4;
517            $this->arrayFib['fcGrpXstAtnOwners'] = self::getInt4d($data, $pos);
518            $pos += 4;
519            $this->arrayFib['lcbGrpXstAtnOwners'] = self::getInt4d($data, $pos);
520            $pos += 4;
521            $this->arrayFib['fcSttbfAtnBkmk'] = self::getInt4d($data, $pos);
522            $pos += 4;
523            $this->arrayFib['lcbSttbfAtnBkmk'] = self::getInt4d($data, $pos);
524            $pos += 4;
525            $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos);
526            $pos += 4;
527            $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos);
528            $pos += 4;
529            $this->arrayFib['fcUnused3'] = self::getInt4d($data, $pos);
530            $pos += 4;
531            $this->arrayFib['lcbUnused3'] = self::getInt4d($data, $pos);
532            $pos += 4;
533            $this->arrayFib['fcPlcSpaMom'] = self::getInt4d($data, $pos);
534            $pos += 4;
535            $this->arrayFib['lcbPlcSpaMom'] = self::getInt4d($data, $pos);
536            $pos += 4;
537            $this->arrayFib['fcPlcSpaHdr'] = self::getInt4d($data, $pos);
538            $pos += 4;
539            $this->arrayFib['lcbPlcSpaHdr'] = self::getInt4d($data, $pos);
540            $pos += 4;
541            $this->arrayFib['fcPlcfAtnBkf'] = self::getInt4d($data, $pos);
542            $pos += 4;
543            $this->arrayFib['lcbPlcfAtnBkf'] = self::getInt4d($data, $pos);
544            $pos += 4;
545            $this->arrayFib['fcPlcfAtnBkl'] = self::getInt4d($data, $pos);
546            $pos += 4;
547            $this->arrayFib['lcbPlcfAtnBkl'] = self::getInt4d($data, $pos);
548            $pos += 4;
549            $this->arrayFib['fcPms'] = self::getInt4d($data, $pos);
550            $pos += 4;
551            $this->arrayFib['lcbPms'] = self::getInt4d($data, $pos);
552            $pos += 4;
553            $this->arrayFib['fcFormFldSttbs'] = self::getInt4d($data, $pos);
554            $pos += 4;
555            $this->arrayFib['lcbFormFldSttbs'] = self::getInt4d($data, $pos);
556            $pos += 4;
557            $this->arrayFib['fcPlcfendRef'] = self::getInt4d($data, $pos);
558            $pos += 4;
559            $this->arrayFib['lcbPlcfendRef'] = self::getInt4d($data, $pos);
560            $pos += 4;
561            $this->arrayFib['fcPlcfendTxt'] = self::getInt4d($data, $pos);
562            $pos += 4;
563            $this->arrayFib['lcbPlcfendTxt'] = self::getInt4d($data, $pos);
564            $pos += 4;
565            $this->arrayFib['fcPlcfFldEdn'] = self::getInt4d($data, $pos);
566            $pos += 4;
567            $this->arrayFib['lcbPlcfFldEdn'] = self::getInt4d($data, $pos);
568            $pos += 4;
569            $this->arrayFib['fcUnused4'] = self::getInt4d($data, $pos);
570            $pos += 4;
571            $this->arrayFib['lcbUnused4'] = self::getInt4d($data, $pos);
572            $pos += 4;
573            $this->arrayFib['fcDggInfo'] = self::getInt4d($data, $pos);
574            $pos += 4;
575            $this->arrayFib['lcbDggInfo'] = self::getInt4d($data, $pos);
576            $pos += 4;
577            $this->arrayFib['fcSttbfRMark'] = self::getInt4d($data, $pos);
578            $pos += 4;
579            $this->arrayFib['lcbSttbfRMark'] = self::getInt4d($data, $pos);
580            $pos += 4;
581            $this->arrayFib['fcSttbfCaption'] = self::getInt4d($data, $pos);
582            $pos += 4;
583            $this->arrayFib['lcbSttbfCaption'] = self::getInt4d($data, $pos);
584            $pos += 4;
585            $this->arrayFib['fcSttbfAutoCaption'] = self::getInt4d($data, $pos);
586            $pos += 4;
587            $this->arrayFib['lcbSttbfAutoCaption'] = self::getInt4d($data, $pos);
588            $pos += 4;
589            $this->arrayFib['fcPlcfWkb'] = self::getInt4d($data, $pos);
590            $pos += 4;
591            $this->arrayFib['lcbPlcfWkb'] = self::getInt4d($data, $pos);
592            $pos += 4;
593            $this->arrayFib['fcPlcfSpl'] = self::getInt4d($data, $pos);
594            $pos += 4;
595            $this->arrayFib['lcbPlcfSpl'] = self::getInt4d($data, $pos);
596            $pos += 4;
597            $this->arrayFib['fcPlcftxbxTxt'] = self::getInt4d($data, $pos);
598            $pos += 4;
599            $this->arrayFib['lcbPlcftxbxTxt'] = self::getInt4d($data, $pos);
600            $pos += 4;
601            $this->arrayFib['fcPlcfFldTxbx'] = self::getInt4d($data, $pos);
602            $pos += 4;
603            $this->arrayFib['lcbPlcfFldTxbx'] = self::getInt4d($data, $pos);
604            $pos += 4;
605            $this->arrayFib['fcPlcfHdrtxbxTxt'] = self::getInt4d($data, $pos);
606            $pos += 4;
607            $this->arrayFib['lcbPlcfHdrtxbxTxt'] = self::getInt4d($data, $pos);
608            $pos += 4;
609            $this->arrayFib['fcPlcffldHdrTxbx'] = self::getInt4d($data, $pos);
610            $pos += 4;
611            $this->arrayFib['lcbPlcffldHdrTxbx'] = self::getInt4d($data, $pos);
612            $pos += 4;
613            $this->arrayFib['fcStwUser'] = self::getInt4d($data, $pos);
614            $pos += 4;
615            $this->arrayFib['lcbStwUser'] = self::getInt4d($data, $pos);
616            $pos += 4;
617            $this->arrayFib['fcSttbTtmbd'] = self::getInt4d($data, $pos);
618            $pos += 4;
619            $this->arrayFib['lcbSttbTtmbd'] = self::getInt4d($data, $pos);
620            $pos += 4;
621            $this->arrayFib['fcCookieData'] = self::getInt4d($data, $pos);
622            $pos += 4;
623            $this->arrayFib['lcbCookieData'] = self::getInt4d($data, $pos);
624            $pos += 4;
625            $this->arrayFib['fcPgdMotherOldOld'] = self::getInt4d($data, $pos);
626            $pos += 4;
627            $this->arrayFib['lcbPgdMotherOldOld'] = self::getInt4d($data, $pos);
628            $pos += 4;
629            $this->arrayFib['fcBkdMotherOldOld'] = self::getInt4d($data, $pos);
630            $pos += 4;
631            $this->arrayFib['lcbBkdMotherOldOld'] = self::getInt4d($data, $pos);
632            $pos += 4;
633            $this->arrayFib['fcPgdFtnOldOld'] = self::getInt4d($data, $pos);
634            $pos += 4;
635            $this->arrayFib['lcbPgdFtnOldOld'] = self::getInt4d($data, $pos);
636            $pos += 4;
637            $this->arrayFib['fcBkdFtnOldOld'] = self::getInt4d($data, $pos);
638            $pos += 4;
639            $this->arrayFib['lcbBkdFtnOldOld'] = self::getInt4d($data, $pos);
640            $pos += 4;
641            $this->arrayFib['fcPgdEdnOldOld'] = self::getInt4d($data, $pos);
642            $pos += 4;
643            $this->arrayFib['lcbPgdEdnOldOld'] = self::getInt4d($data, $pos);
644            $pos += 4;
645            $this->arrayFib['fcBkdEdnOldOld'] = self::getInt4d($data, $pos);
646            $pos += 4;
647            $this->arrayFib['lcbBkdEdnOldOld'] = self::getInt4d($data, $pos);
648            $pos += 4;
649            $this->arrayFib['fcSttbfIntlFld'] = self::getInt4d($data, $pos);
650            $pos += 4;
651            $this->arrayFib['lcbSttbfIntlFld'] = self::getInt4d($data, $pos);
652            $pos += 4;
653            $this->arrayFib['fcRouteSlip'] = self::getInt4d($data, $pos);
654            $pos += 4;
655            $this->arrayFib['lcbRouteSlip'] = self::getInt4d($data, $pos);
656            $pos += 4;
657            $this->arrayFib['fcSttbSavedBy'] = self::getInt4d($data, $pos);
658            $pos += 4;
659            $this->arrayFib['lcbSttbSavedBy'] = self::getInt4d($data, $pos);
660            $pos += 4;
661            $this->arrayFib['fcSttbFnm'] = self::getInt4d($data, $pos);
662            $pos += 4;
663            $this->arrayFib['lcbSttbFnm'] = self::getInt4d($data, $pos);
664            $pos += 4;
665            $this->arrayFib['fcPlfLst'] = self::getInt4d($data, $pos);
666            $pos += 4;
667            $this->arrayFib['lcbPlfLst'] = self::getInt4d($data, $pos);
668            $pos += 4;
669            $this->arrayFib['fcPlfLfo'] = self::getInt4d($data, $pos);
670            $pos += 4;
671            $this->arrayFib['lcbPlfLfo'] = self::getInt4d($data, $pos);
672            $pos += 4;
673            $this->arrayFib['fcPlcfTxbxBkd'] = self::getInt4d($data, $pos);
674            $pos += 4;
675            $this->arrayFib['lcbPlcfTxbxBkd'] = self::getInt4d($data, $pos);
676            $pos += 4;
677            $this->arrayFib['fcPlcfTxbxHdrBkd'] = self::getInt4d($data, $pos);
678            $pos += 4;
679            $this->arrayFib['lcbPlcfTxbxHdrBkd'] = self::getInt4d($data, $pos);
680            $pos += 4;
681            $this->arrayFib['fcDocUndoWord9'] = self::getInt4d($data, $pos);
682            $pos += 4;
683            $this->arrayFib['lcbDocUndoWord9'] = self::getInt4d($data, $pos);
684            $pos += 4;
685            $this->arrayFib['fcRgbUse'] = self::getInt4d($data, $pos);
686            $pos += 4;
687            $this->arrayFib['lcbRgbUse'] = self::getInt4d($data, $pos);
688            $pos += 4;
689            $this->arrayFib['fcUsp'] = self::getInt4d($data, $pos);
690            $pos += 4;
691            $this->arrayFib['lcbUsp'] = self::getInt4d($data, $pos);
692            $pos += 4;
693            $this->arrayFib['fcUskf'] = self::getInt4d($data, $pos);
694            $pos += 4;
695            $this->arrayFib['lcbUskf'] = self::getInt4d($data, $pos);
696            $pos += 4;
697            $this->arrayFib['fcPlcupcRgbUse'] = self::getInt4d($data, $pos);
698            $pos += 4;
699            $this->arrayFib['lcbPlcupcRgbUse'] = self::getInt4d($data, $pos);
700            $pos += 4;
701            $this->arrayFib['fcPlcupcUsp'] = self::getInt4d($data, $pos);
702            $pos += 4;
703            $this->arrayFib['lcbPlcupcUsp'] = self::getInt4d($data, $pos);
704            $pos += 4;
705            $this->arrayFib['fcSttbGlsyStyle'] = self::getInt4d($data, $pos);
706            $pos += 4;
707            $this->arrayFib['lcbSttbGlsyStyle'] = self::getInt4d($data, $pos);
708            $pos += 4;
709            $this->arrayFib['fcPlgosl'] = self::getInt4d($data, $pos);
710            $pos += 4;
711            $this->arrayFib['lcbPlgosl'] = self::getInt4d($data, $pos);
712            $pos += 4;
713            $this->arrayFib['fcPlcocx'] = self::getInt4d($data, $pos);
714            $pos += 4;
715            $this->arrayFib['lcbPlcocx'] = self::getInt4d($data, $pos);
716            $pos += 4;
717            $this->arrayFib['fcPlcfBteLvc'] = self::getInt4d($data, $pos);
718            $pos += 4;
719            $this->arrayFib['lcbPlcfBteLvc'] = self::getInt4d($data, $pos);
720            $pos += 4;
721            $this->arrayFib['dwLowDateTime'] = self::getInt4d($data, $pos);
722            $pos += 4;
723            $this->arrayFib['dwHighDateTime'] = self::getInt4d($data, $pos);
724            $pos += 4;
725            $this->arrayFib['fcPlcfLvcPre10'] = self::getInt4d($data, $pos);
726            $pos += 4;
727            $this->arrayFib['lcbPlcfLvcPre10'] = self::getInt4d($data, $pos);
728            $pos += 4;
729            $this->arrayFib['fcPlcfAsumy'] = self::getInt4d($data, $pos);
730            $pos += 4;
731            $this->arrayFib['lcbPlcfAsumy'] = self::getInt4d($data, $pos);
732            $pos += 4;
733            $this->arrayFib['fcPlcfGram'] = self::getInt4d($data, $pos);
734            $pos += 4;
735            $this->arrayFib['lcbPlcfGram'] = self::getInt4d($data, $pos);
736            $pos += 4;
737            $this->arrayFib['fcSttbListNames'] = self::getInt4d($data, $pos);
738            $pos += 4;
739            $this->arrayFib['lcbSttbListNames'] = self::getInt4d($data, $pos);
740            $pos += 4;
741            $this->arrayFib['fcSttbfUssr'] = self::getInt4d($data, $pos);
742            $pos += 4;
743            $this->arrayFib['lcbSttbfUssr'] = self::getInt4d($data, $pos);
744            $pos += 4;
745        }
746        if ($version == self::VERSION_2000) {
747            $this->arrayFib['fcPlcfTch'] = self::getInt4d($data, $pos);
748            $pos += 4;
749            $this->arrayFib['lcbPlcfTch'] = self::getInt4d($data, $pos);
750            $pos += 4;
751            $this->arrayFib['fcRmdThreading'] = self::getInt4d($data, $pos);
752            $pos += 4;
753            $this->arrayFib['lcbRmdThreading'] = self::getInt4d($data, $pos);
754            $pos += 4;
755            $this->arrayFib['fcMid'] = self::getInt4d($data, $pos);
756            $pos += 4;
757            $this->arrayFib['lcbMid'] = self::getInt4d($data, $pos);
758            $pos += 4;
759            $this->arrayFib['fcSttbRgtplc'] = self::getInt4d($data, $pos);
760            $pos += 4;
761            $this->arrayFib['lcbSttbRgtplc'] = self::getInt4d($data, $pos);
762            $pos += 4;
763            $this->arrayFib['fcMsoEnvelope'] = self::getInt4d($data, $pos);
764            $pos += 4;
765            $this->arrayFib['lcbMsoEnvelope'] = self::getInt4d($data, $pos);
766            $pos += 4;
767            $this->arrayFib['fcPlcfLad'] = self::getInt4d($data, $pos);
768            $pos += 4;
769            $this->arrayFib['lcbPlcfLad'] = self::getInt4d($data, $pos);
770            $pos += 4;
771            $this->arrayFib['fcRgDofr'] = self::getInt4d($data, $pos);
772            $pos += 4;
773            $this->arrayFib['lcbRgDofr'] = self::getInt4d($data, $pos);
774            $pos += 4;
775            $this->arrayFib['fcPlcosl'] = self::getInt4d($data, $pos);
776            $pos += 4;
777            $this->arrayFib['lcbPlcosl'] = self::getInt4d($data, $pos);
778            $pos += 4;
779            $this->arrayFib['fcPlcfCookieOld'] = self::getInt4d($data, $pos);
780            $pos += 4;
781            $this->arrayFib['lcbPlcfCookieOld'] = self::getInt4d($data, $pos);
782            $pos += 4;
783            $this->arrayFib['fcPgdMotherOld'] = self::getInt4d($data, $pos);
784            $pos += 4;
785            $this->arrayFib['lcbPgdMotherOld'] = self::getInt4d($data, $pos);
786            $pos += 4;
787            $this->arrayFib['fcBkdMotherOld'] = self::getInt4d($data, $pos);
788            $pos += 4;
789            $this->arrayFib['lcbBkdMotherOld'] = self::getInt4d($data, $pos);
790            $pos += 4;
791            $this->arrayFib['fcPgdFtnOld'] = self::getInt4d($data, $pos);
792            $pos += 4;
793            $this->arrayFib['lcbPgdFtnOld'] = self::getInt4d($data, $pos);
794            $pos += 4;
795            $this->arrayFib['fcBkdFtnOld'] = self::getInt4d($data, $pos);
796            $pos += 4;
797            $this->arrayFib['lcbBkdFtnOld'] = self::getInt4d($data, $pos);
798            $pos += 4;
799            $this->arrayFib['fcPgdEdnOld'] = self::getInt4d($data, $pos);
800            $pos += 4;
801            $this->arrayFib['lcbPgdEdnOld'] = self::getInt4d($data, $pos);
802            $pos += 4;
803            $this->arrayFib['fcBkdEdnOld'] = self::getInt4d($data, $pos);
804            $pos += 4;
805            $this->arrayFib['lcbBkdEdnOld'] = self::getInt4d($data, $pos);
806            $pos += 4;
807        }
808        if ($version == self::VERSION_2002) {
809            $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos);
810            $pos += 4;
811            $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos);
812            $pos += 4;
813            $this->arrayFib['fcPlcfPgp'] = self::getInt4d($data, $pos);
814            $pos += 4;
815            $this->arrayFib['lcbPlcfPgp'] = self::getInt4d($data, $pos);
816            $pos += 4;
817            $this->arrayFib['fcPlcfuim'] = self::getInt4d($data, $pos);
818            $pos += 4;
819            $this->arrayFib['lcbPlcfuim'] = self::getInt4d($data, $pos);
820            $pos += 4;
821            $this->arrayFib['fcPlfguidUim'] = self::getInt4d($data, $pos);
822            $pos += 4;
823            $this->arrayFib['lcbPlfguidUim'] = self::getInt4d($data, $pos);
824            $pos += 4;
825            $this->arrayFib['fcAtrdExtra'] = self::getInt4d($data, $pos);
826            $pos += 4;
827            $this->arrayFib['lcbAtrdExtra'] = self::getInt4d($data, $pos);
828            $pos += 4;
829            $this->arrayFib['fcPlrsid'] = self::getInt4d($data, $pos);
830            $pos += 4;
831            $this->arrayFib['lcbPlrsid'] = self::getInt4d($data, $pos);
832            $pos += 4;
833            $this->arrayFib['fcSttbfBkmkFactoid'] = self::getInt4d($data, $pos);
834            $pos += 4;
835            $this->arrayFib['lcbSttbfBkmkFactoid'] = self::getInt4d($data, $pos);
836            $pos += 4;
837            $this->arrayFib['fcPlcfBkfFactoid'] = self::getInt4d($data, $pos);
838            $pos += 4;
839            $this->arrayFib['lcbPlcfBkfFactoid'] = self::getInt4d($data, $pos);
840            $pos += 4;
841            $this->arrayFib['fcPlcfcookie'] = self::getInt4d($data, $pos);
842            $pos += 4;
843            $this->arrayFib['lcbPlcfcookie'] = self::getInt4d($data, $pos);
844            $pos += 4;
845            $this->arrayFib['fcPlcfBklFactoid'] = self::getInt4d($data, $pos);
846            $pos += 4;
847            $this->arrayFib['lcbPlcfBklFactoid'] = self::getInt4d($data, $pos);
848            $pos += 4;
849            $this->arrayFib['fcFactoidData'] = self::getInt4d($data, $pos);
850            $pos += 4;
851            $this->arrayFib['lcbFactoidData'] = self::getInt4d($data, $pos);
852            $pos += 4;
853            $this->arrayFib['fcDocUndo'] = self::getInt4d($data, $pos);
854            $pos += 4;
855            $this->arrayFib['lcbDocUndo'] = self::getInt4d($data, $pos);
856            $pos += 4;
857            $this->arrayFib['fcSttbfBkmkFcc'] = self::getInt4d($data, $pos);
858            $pos += 4;
859            $this->arrayFib['lcbSttbfBkmkFcc'] = self::getInt4d($data, $pos);
860            $pos += 4;
861            $this->arrayFib['fcPlcfBkfFcc'] = self::getInt4d($data, $pos);
862            $pos += 4;
863            $this->arrayFib['lcbPlcfBkfFcc'] = self::getInt4d($data, $pos);
864            $pos += 4;
865            $this->arrayFib['fcPlcfBklFcc'] = self::getInt4d($data, $pos);
866            $pos += 4;
867            $this->arrayFib['lcbPlcfBklFcc'] = self::getInt4d($data, $pos);
868            $pos += 4;
869            $this->arrayFib['fcSttbfbkmkBPRepairs'] = self::getInt4d($data, $pos);
870            $pos += 4;
871            $this->arrayFib['lcbSttbfbkmkBPRepairs'] = self::getInt4d($data, $pos);
872            $pos += 4;
873            $this->arrayFib['fcPlcfbkfBPRepairs'] = self::getInt4d($data, $pos);
874            $pos += 4;
875            $this->arrayFib['lcbPlcfbkfBPRepairs'] = self::getInt4d($data, $pos);
876            $pos += 4;
877            $this->arrayFib['fcPlcfbklBPRepairs'] = self::getInt4d($data, $pos);
878            $pos += 4;
879            $this->arrayFib['lcbPlcfbklBPRepairs'] = self::getInt4d($data, $pos);
880            $pos += 4;
881            $this->arrayFib['fcPmsNew'] = self::getInt4d($data, $pos);
882            $pos += 4;
883            $this->arrayFib['lcbPmsNew'] = self::getInt4d($data, $pos);
884            $pos += 4;
885            $this->arrayFib['fcODSO'] = self::getInt4d($data, $pos);
886            $pos += 4;
887            $this->arrayFib['lcbODSO'] = self::getInt4d($data, $pos);
888            $pos += 4;
889            $this->arrayFib['fcPlcfpmiOldXP'] = self::getInt4d($data, $pos);
890            $pos += 4;
891            $this->arrayFib['lcbPlcfpmiOldXP'] = self::getInt4d($data, $pos);
892            $pos += 4;
893            $this->arrayFib['fcPlcfpmiNewXP'] = self::getInt4d($data, $pos);
894            $pos += 4;
895            $this->arrayFib['lcbPlcfpmiNewXP'] = self::getInt4d($data, $pos);
896            $pos += 4;
897            $this->arrayFib['fcPlcfpmiMixedXP'] = self::getInt4d($data, $pos);
898            $pos += 4;
899            $this->arrayFib['lcbPlcfpmiMixedXP'] = self::getInt4d($data, $pos);
900            $pos += 4;
901            $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos);
902            $pos += 4;
903            $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos);
904            $pos += 4;
905            $this->arrayFib['fcPlcffactoid'] = self::getInt4d($data, $pos);
906            $pos += 4;
907            $this->arrayFib['lcbPlcffactoid'] = self::getInt4d($data, $pos);
908            $pos += 4;
909            $this->arrayFib['fcPlcflvcOldXP'] = self::getInt4d($data, $pos);
910            $pos += 4;
911            $this->arrayFib['lcbPlcflvcOldXP'] = self::getInt4d($data, $pos);
912            $pos += 4;
913            $this->arrayFib['fcPlcflvcNewXP'] = self::getInt4d($data, $pos);
914            $pos += 4;
915            $this->arrayFib['lcbPlcflvcNewXP'] = self::getInt4d($data, $pos);
916            $pos += 4;
917            $this->arrayFib['fcPlcflvcMixedXP'] = self::getInt4d($data, $pos);
918            $pos += 4;
919            $this->arrayFib['lcbPlcflvcMixedXP'] = self::getInt4d($data, $pos);
920            $pos += 4;
921        }
922        if ($version == self::VERSION_2003) {
923            $this->arrayFib['fcHplxsdr'] = self::getInt4d($data, $pos);
924            $pos += 4;
925            $this->arrayFib['lcbHplxsdr'] = self::getInt4d($data, $pos);
926            $pos += 4;
927            $this->arrayFib['fcSttbfBkmkSdt'] = self::getInt4d($data, $pos);
928            $pos += 4;
929            $this->arrayFib['lcbSttbfBkmkSdt'] = self::getInt4d($data, $pos);
930            $pos += 4;
931            $this->arrayFib['fcPlcfBkfSdt'] = self::getInt4d($data, $pos);
932            $pos += 4;
933            $this->arrayFib['lcbPlcfBkfSdt'] = self::getInt4d($data, $pos);
934            $pos += 4;
935            $this->arrayFib['fcPlcfBklSdt'] = self::getInt4d($data, $pos);
936            $pos += 4;
937            $this->arrayFib['lcbPlcfBklSdt'] = self::getInt4d($data, $pos);
938            $pos += 4;
939            $this->arrayFib['fcCustomXForm'] = self::getInt4d($data, $pos);
940            $pos += 4;
941            $this->arrayFib['lcbCustomXForm'] = self::getInt4d($data, $pos);
942            $pos += 4;
943            $this->arrayFib['fcSttbfBkmkProt'] = self::getInt4d($data, $pos);
944            $pos += 4;
945            $this->arrayFib['lcbSttbfBkmkProt'] = self::getInt4d($data, $pos);
946            $pos += 4;
947            $this->arrayFib['fcPlcfBkfProt'] = self::getInt4d($data, $pos);
948            $pos += 4;
949            $this->arrayFib['lcbPlcfBkfProt'] = self::getInt4d($data, $pos);
950            $pos += 4;
951            $this->arrayFib['fcPlcfBklProt'] = self::getInt4d($data, $pos);
952            $pos += 4;
953            $this->arrayFib['lcbPlcfBklProt'] = self::getInt4d($data, $pos);
954            $pos += 4;
955            $this->arrayFib['fcSttbProtUser'] = self::getInt4d($data, $pos);
956            $pos += 4;
957            $this->arrayFib['lcbSttbProtUser'] = self::getInt4d($data, $pos);
958            $pos += 4;
959            $this->arrayFib['fcUnused'] = self::getInt4d($data, $pos);
960            $pos += 4;
961            $this->arrayFib['lcbUnused'] = self::getInt4d($data, $pos);
962            $pos += 4;
963            $this->arrayFib['fcPlcfpmiOld'] = self::getInt4d($data, $pos);
964            $pos += 4;
965            $this->arrayFib['lcbPlcfpmiOld'] = self::getInt4d($data, $pos);
966            $pos += 4;
967            $this->arrayFib['fcPlcfpmiOldInline'] = self::getInt4d($data, $pos);
968            $pos += 4;
969            $this->arrayFib['lcbPlcfpmiOldInline'] = self::getInt4d($data, $pos);
970            $pos += 4;
971            $this->arrayFib['fcPlcfpmiNew'] = self::getInt4d($data, $pos);
972            $pos += 4;
973            $this->arrayFib['lcbPlcfpmiNew'] = self::getInt4d($data, $pos);
974            $pos += 4;
975            $this->arrayFib['fcPlcfpmiNewInline'] = self::getInt4d($data, $pos);
976            $pos += 4;
977            $this->arrayFib['lcbPlcfpmiNewInline'] = self::getInt4d($data, $pos);
978            $pos += 4;
979            $this->arrayFib['fcPlcflvcOld'] = self::getInt4d($data, $pos);
980            $pos += 4;
981            $this->arrayFib['lcbPlcflvcOld'] = self::getInt4d($data, $pos);
982            $pos += 4;
983            $this->arrayFib['fcPlcflvcOldInline'] = self::getInt4d($data, $pos);
984            $pos += 4;
985            $this->arrayFib['lcbPlcflvcOldInline'] = self::getInt4d($data, $pos);
986            $pos += 4;
987            $this->arrayFib['fcPlcflvcNew'] = self::getInt4d($data, $pos);
988            $pos += 4;
989            $this->arrayFib['lcbPlcflvcNew'] = self::getInt4d($data, $pos);
990            $pos += 4;
991            $this->arrayFib['fcPlcflvcNewInline'] = self::getInt4d($data, $pos);
992            $pos += 4;
993            $this->arrayFib['lcbPlcflvcNewInline'] = self::getInt4d($data, $pos);
994            $pos += 4;
995            $this->arrayFib['fcPgdMother'] = self::getInt4d($data, $pos);
996            $pos += 4;
997            $this->arrayFib['lcbPgdMother'] = self::getInt4d($data, $pos);
998            $pos += 4;
999            $this->arrayFib['fcBkdMother'] = self::getInt4d($data, $pos);
1000            $pos += 4;
1001            $this->arrayFib['lcbBkdMother'] = self::getInt4d($data, $pos);
1002            $pos += 4;
1003            $this->arrayFib['fcAfdMother'] = self::getInt4d($data, $pos);
1004            $pos += 4;
1005            $this->arrayFib['lcbAfdMother'] = self::getInt4d($data, $pos);
1006            $pos += 4;
1007            $this->arrayFib['fcPgdFtn'] = self::getInt4d($data, $pos);
1008            $pos += 4;
1009            $this->arrayFib['lcbPgdFtn'] = self::getInt4d($data, $pos);
1010            $pos += 4;
1011            $this->arrayFib['fcBkdFtn'] = self::getInt4d($data, $pos);
1012            $pos += 4;
1013            $this->arrayFib['lcbBkdFtn'] = self::getInt4d($data, $pos);
1014            $pos += 4;
1015            $this->arrayFib['fcAfdFtn'] = self::getInt4d($data, $pos);
1016            $pos += 4;
1017            $this->arrayFib['lcbAfdFtn'] = self::getInt4d($data, $pos);
1018            $pos += 4;
1019            $this->arrayFib['fcPgdEdn'] = self::getInt4d($data, $pos);
1020            $pos += 4;
1021            $this->arrayFib['lcbPgdEdn'] = self::getInt4d($data, $pos);
1022            $pos += 4;
1023            $this->arrayFib['fcBkdEdn'] = self::getInt4d($data, $pos);
1024            $pos += 4;
1025            $this->arrayFib['lcbBkdEdn'] = self::getInt4d($data, $pos);
1026            $pos += 4;
1027            $this->arrayFib['fcAfdEdn'] = self::getInt4d($data, $pos);
1028            $pos += 4;
1029            $this->arrayFib['lcbAfdEdn'] = self::getInt4d($data, $pos);
1030            $pos += 4;
1031            $this->arrayFib['fcAfd'] = self::getInt4d($data, $pos);
1032            $pos += 4;
1033            $this->arrayFib['lcbAfd'] = self::getInt4d($data, $pos);
1034            $pos += 4;
1035        }
1036        if ($version == self::VERSION_2007) {
1037            $this->arrayFib['fcPlcfmthd'] = self::getInt4d($data, $pos);
1038            $pos += 4;
1039            $this->arrayFib['lcbPlcfmthd'] = self::getInt4d($data, $pos);
1040            $pos += 4;
1041            $this->arrayFib['fcSttbfBkmkMoveFrom'] = self::getInt4d($data, $pos);
1042            $pos += 4;
1043            $this->arrayFib['lcbSttbfBkmkMoveFrom'] = self::getInt4d($data, $pos);
1044            $pos += 4;
1045            $this->arrayFib['fcPlcfBkfMoveFrom'] = self::getInt4d($data, $pos);
1046            $pos += 4;
1047            $this->arrayFib['lcbPlcfBkfMoveFrom'] = self::getInt4d($data, $pos);
1048            $pos += 4;
1049            $this->arrayFib['fcPlcfBklMoveFrom'] = self::getInt4d($data, $pos);
1050            $pos += 4;
1051            $this->arrayFib['lcbPlcfBklMoveFrom'] = self::getInt4d($data, $pos);
1052            $pos += 4;
1053            $this->arrayFib['fcSttbfBkmkMoveTo'] = self::getInt4d($data, $pos);
1054            $pos += 4;
1055            $this->arrayFib['lcbSttbfBkmkMoveTo'] = self::getInt4d($data, $pos);
1056            $pos += 4;
1057            $this->arrayFib['fcPlcfBkfMoveTo'] = self::getInt4d($data, $pos);
1058            $pos += 4;
1059            $this->arrayFib['lcbPlcfBkfMoveTo'] = self::getInt4d($data, $pos);
1060            $pos += 4;
1061            $this->arrayFib['fcPlcfBklMoveTo'] = self::getInt4d($data, $pos);
1062            $pos += 4;
1063            $this->arrayFib['lcbPlcfBklMoveTo'] = self::getInt4d($data, $pos);
1064            $pos += 4;
1065            $this->arrayFib['fcUnused1'] = self::getInt4d($data, $pos);
1066            $pos += 4;
1067            $this->arrayFib['lcbUnused1'] = self::getInt4d($data, $pos);
1068            $pos += 4;
1069            $this->arrayFib['fcUnused2'] = self::getInt4d($data, $pos);
1070            $pos += 4;
1071            $this->arrayFib['lcbUnused2'] = self::getInt4d($data, $pos);
1072            $pos += 4;
1073            $this->arrayFib['fcUnused3'] = self::getInt4d($data, $pos);
1074            $pos += 4;
1075            $this->arrayFib['lcbUnused3'] = self::getInt4d($data, $pos);
1076            $pos += 4;
1077            $this->arrayFib['fcSttbfBkmkArto'] = self::getInt4d($data, $pos);
1078            $pos += 4;
1079            $this->arrayFib['lcbSttbfBkmkArto'] = self::getInt4d($data, $pos);
1080            $pos += 4;
1081            $this->arrayFib['fcPlcfBkfArto'] = self::getInt4d($data, $pos);
1082            $pos += 4;
1083            $this->arrayFib['lcbPlcfBkfArto'] = self::getInt4d($data, $pos);
1084            $pos += 4;
1085            $this->arrayFib['fcPlcfBklArto'] = self::getInt4d($data, $pos);
1086            $pos += 4;
1087            $this->arrayFib['lcbPlcfBklArto'] = self::getInt4d($data, $pos);
1088            $pos += 4;
1089            $this->arrayFib['fcArtoData'] = self::getInt4d($data, $pos);
1090            $pos += 4;
1091            $this->arrayFib['lcbArtoData'] = self::getInt4d($data, $pos);
1092            $pos += 4;
1093            $this->arrayFib['fcUnused4'] = self::getInt4d($data, $pos);
1094            $pos += 4;
1095            $this->arrayFib['lcbUnused4'] = self::getInt4d($data, $pos);
1096            $pos += 4;
1097            $this->arrayFib['fcUnused5'] = self::getInt4d($data, $pos);
1098            $pos += 4;
1099            $this->arrayFib['lcbUnused5'] = self::getInt4d($data, $pos);
1100            $pos += 4;
1101            $this->arrayFib['fcUnused6'] = self::getInt4d($data, $pos);
1102            $pos += 4;
1103            $this->arrayFib['lcbUnused6'] = self::getInt4d($data, $pos);
1104            $pos += 4;
1105            $this->arrayFib['fcOssTheme'] = self::getInt4d($data, $pos);
1106            $pos += 4;
1107            $this->arrayFib['lcbOssTheme'] = self::getInt4d($data, $pos);
1108            $pos += 4;
1109            $this->arrayFib['fcColorSchemeMapping'] = self::getInt4d($data, $pos);
1110            $pos += 4;
1111            $this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
1112            $pos += 4;
1113        }
1114
1115        return $pos;
1116    }
1117
1118    private function readFibContent(): void
1119    {
1120        // Informations about Font
1121        $this->readRecordSttbfFfn();
1122
1123        // Informations about page
1124        $this->readRecordPlcfSed();
1125
1126        // reading paragraphs
1127        //@see  https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86
1128        $this->readRecordPlcfBtePapx();
1129
1130        // reading character formattings
1131        //@see  https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94
1132        $this->readRecordPlcfBteChpx();
1133
1134        $this->generatePhpWord();
1135    }
1136
1137    /**
1138     * Section and information about them.
1139     *
1140     * @see  http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx
1141     */
1142    private function readRecordPlcfSed(): void
1143    {
1144        $posMem = $this->arrayFib['fcPlcfSed'];
1145        // PlcfSed
1146        // PlcfSed : aCP
1147        $aCP = [];
1148        $aCP[0] = self::getInt4d($this->data1Table, $posMem);
1149        $posMem += 4;
1150        $aCP[1] = self::getInt4d($this->data1Table, $posMem);
1151        $posMem += 4;
1152
1153        // PlcfSed : aSed
1154        //@see  http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx
1155        $numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12);
1156
1157        $aSed = [];
1158        for ($iInc = 0; $iInc < $numSed; ++$iInc) {
1159            // Sed : http://msdn.microsoft.com/en-us/library/dd950982%28v=office.12%29.aspx
1160            // fn
1161            $posMem += 2;
1162            // fnMpr
1163            $aSed[$iInc] = self::getInt4d($this->data1Table, $posMem);
1164            $posMem += 4;
1165            // fnMpr
1166            $posMem += 2;
1167            // fcMpr
1168            $posMem += 4;
1169        }
1170
1171        foreach ($aSed as $offsetSed) {
1172            // Sepx : http://msdn.microsoft.com/en-us/library/dd921348%28v=office.12%29.aspx
1173            $cb = self::getInt2d($this->dataWorkDocument, $offsetSed);
1174            $offsetSed += 2;
1175
1176            $oStylePrl = $this->readPrl($this->dataWorkDocument, $offsetSed, $cb);
1177            $offsetSed += $oStylePrl->length;
1178
1179            $this->arraySections[] = $oStylePrl;
1180        }
1181    }
1182
1183    /**
1184     * Specifies the fonts that are used in the document.
1185     *
1186     * @see  http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx
1187     */
1188    private function readRecordSttbfFfn(): void
1189    {
1190        $posMem = $this->arrayFib['fcSttbfFfn'];
1191
1192        $cData = self::getInt2d($this->data1Table, $posMem);
1193        $posMem += 2;
1194        $cbExtra = self::getInt2d($this->data1Table, $posMem);
1195        $posMem += 2;
1196
1197        if ($cData < 0x7FF0 && $cbExtra == 0) {
1198            for ($inc = 0; $inc < $cData; ++$inc) {
1199                // len
1200                ++$posMem;
1201                // ffid
1202                ++$posMem;
1203                // wWeight (400 : Normal - 700 bold)
1204                $posMem += 2;
1205                // chs
1206                ++$posMem;
1207                // ixchSzAlt
1208                $ixchSzAlt = self::getInt1d($this->data1Table, $posMem);
1209                ++$posMem;
1210                // panose
1211                $posMem += 10;
1212                // fs
1213                $posMem += 24;
1214                // xszFfn
1215                $xszFfn = '';
1216                do {
1217                    $char = self::getInt2d($this->data1Table, $posMem);
1218                    $posMem += 2;
1219                    if ($char > 0) {
1220                        $xszFfn .= chr($char);
1221                    }
1222                } while ($char != 0);
1223                // xszAlt
1224                $xszAlt = '';
1225                if ($ixchSzAlt > 0) {
1226                    do {
1227                        $char = self::getInt2d($this->data1Table, $posMem);
1228                        $posMem += 2;
1229                        if ($char == 0) {
1230                            break;
1231                        }
1232                        $xszAlt .= chr($char);
1233                    } while ($char != 0);
1234                }
1235                $this->arrayFonts[] = [
1236                    'main' => $xszFfn,
1237                    'alt' => $xszAlt,
1238                ];
1239            }
1240        }
1241    }
1242
1243    /**
1244     * Paragraph and information about them.
1245     *
1246     * @see  http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx
1247     */
1248    private function readRecordPlcfBtePapx(): void
1249    {
1250        $posMem = $this->arrayFib['fcPlcfBtePapx'];
1251        $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBtePapx'], 4);
1252        $posMem += 4 * ($num + 1);
1253        $arrAPnBtePapx = $this->getArrayCP($this->data1Table, $posMem, $num);
1254        $posMem += 4 * $num;
1255
1256        foreach ($arrAPnBtePapx as $aPnBtePapx) {
1257            $offsetBase = $aPnBtePapx * 512;
1258            $offset = $offsetBase;
1259
1260            $string = '';
1261
1262            $numRun = self::getInt1d($this->dataWorkDocument, $offset + 511);
1263            $arrayRGFC = [];
1264            for ($inc = 0; $inc <= $numRun; ++$inc) {
1265                $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset);
1266                $offset += 4;
1267            }
1268            $arrayRGB = [];
1269            for ($inc = 1; $inc <= $numRun; ++$inc) {
1270                // @see  http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx
1271                $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset);
1272                ++$offset;
1273                // reserved
1274                $offset += 12;
1275            }
1276
1277            foreach (array_keys($arrayRGFC) as $key) {
1278                if (!isset($arrayRGFC[$key + 1])) {
1279                    break;
1280                }
1281                $strLen = $arrayRGFC[$key + 1] - $arrayRGFC[$key] - 1;
1282                for ($inc = 0; $inc < ($strLen * 2); ++$inc) {
1283                    $byte = self::getInt2d($this->dataWorkDocument, $arrayRGFC[$key] + ($inc * 2));
1284                    if ($byte > 0) {
1285                        $string .= mb_chr($byte, 'UTF-8');
1286                    } else {
1287                        break;
1288                    }
1289                }
1290            }
1291            $this->arrayParagraphs[] = $string;
1292
1293            //@todo readPrl for paragraphs
1294            /*// use $this->readPrl()
1295            foreach ($arrayRGB as $key => $rgb) {
1296                $offset = $offsetBase + ($rgb * 2);
1297
1298                $cb = self::getInt1d($this->dataWorkDocument, $offset);
1299                $offset += 1;
1300                print_r('$cb : '.$cb.PHP_EOL);
1301                if ($cb == 0) {
1302                    $cb = self::getInt1d($this->dataWorkDocument, $offset);
1303                    $cb = $cb * 2;
1304                    $offset += 1;
1305                    print_r('$cb0 : '.$cb.PHP_EOL);
1306                } else {
1307                    $cb = $cb * 2 - 1;
1308                    print_r('$cbD : '.$cb.PHP_EOL);
1309                }
1310                $istd = self::getInt2d($this->dataWorkDocument, $offset);
1311                $offset += 2;
1312                $cb -= 2;
1313                print_r('$istd : '.$istd.($istd == 0 ? ' (Normal)' : '').PHP_EOL);
1314                if ($cb > 0) {
1315                    do{
1316                        $sprm = self::getInt2d($this->dataWorkDocument, $offset);
1317                        $offset += 2;
1318                        $cb -= 2;
1319                        $sprm_IsPmd = $sprm & 0x01FF;
1320                        $sprm_F = ($sprm/512) & 0x0001;
1321                        $sprm_Sgc = ($sprm/1024) & 0x0007;
1322                        $sprm_Spra = ($sprm/8192);
1323
1324                        print_r('$sprm : 0x'.dechex($sprm).PHP_EOL);
1325                        print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
1326                        print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
1327                        print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
1328                        switch (dechex($sprm_Sgc)) {
1329                            case 0x01:
1330                                print_r(' (Paragraph property)');
1331                                break;
1332                            case 0x02:
1333                                print_r(' (Character property)');
1334                                break;
1335                            case 0x03:
1336                                print_r(' (Picture property)');
1337                                break;
1338                            case 0x04:
1339                                print_r(' (Section property)');
1340                                break;
1341                            case 0x05:
1342                                print_r(' (Table property)');
1343                                break;
1344                        }
1345                        print_r(PHP_EOL);
1346                        print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
1347                        switch (dechex($sprm_Spra)) {
1348                            case 0x0:
1349                                $operand = self::getInt1d($this->dataWorkDocument, $offset);
1350                                $offset += 1;
1351                                $cb -= 1;
1352                                switch (dechex($operand)) {
1353                                    case 0x00:
1354                                        $operand = 'OFF';
1355                                        break;
1356                                    case 0x01:
1357                                        $operand = 'ON';
1358                                        break;
1359                                    case 0x80:
1360                                        $operand = 'CURRENT VALUE';
1361                                        print_r(''.PHP_EOL.PHP_EOL);
1362                                        break;
1363                                    case 0x81:
1364                                        $operand = 'OPPOSITE OF THE CURRENT VALUE';
1365                                        break;
1366                                }
1367                                break;
1368                            case 0x1:
1369                                $operand = self::getInt1d($this->dataWorkDocument, $offset);
1370                                $offset += 1;
1371                                $cb -= 1;
1372                                print_r('$operand : 0x'.dechex($operand).PHP_EOL);
1373                                break;
1374                            case 0x2:
1375                            case 0x4:
1376                            case 0x5:
1377                                $operand = self::getInt2d($this->dataWorkDocument, $offset);
1378                                $offset += 2;
1379                                $cb -= 2;
1380                                print_r('$operand : 0x'.dechex($operand).PHP_EOL);
1381                                break;
1382                            case 0x3:
1383                                if ($sprm_IsPmd != 0x70) {
1384                                    $operand = self::getInt4d($this->dataWorkDocument, $offset);
1385                                    $offset += 4;
1386                                    $cb -= 4;
1387                                    print_r('$operand : 0x'.dechex($operand).PHP_EOL);
1388                                }
1389                                break;
1390                            case 0x7:
1391                                $operand = self::getInt3d($this->dataWorkDocument, $offset);
1392                                $offset += 3;
1393                                $cb -= 3;
1394                                print_r('$operand : 0x'.dechex($operand).PHP_EOL);
1395                                break;
1396                            default:
1397                                print_r('YO YO YO : '.PHP_EOL);
1398                        }
1399
1400                        //
1401                        switch (dechex($sprm_Sgc)) {
1402                            case 0x01: // Sprm is modifying a paragraph property.
1403                                switch ($sprm_IsPmd) {
1404                                    case 0x0A: // sprmPIlvl
1405                                        print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
1406                                        break;
1407                                    case 0x0B: // sprmPIlfo
1408                                        print_r('sprmPIlfo : '.$operand.PHP_EOL.PHP_EOL);
1409                                        break;
1410                                    default:
1411                                        print_r('$sprm_IsPmd(1) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
1412                                        break;
1413                                }
1414                                break;
1415                            case 0x02: // Sprm is modifying a character property.
1416                                switch ($sprm_IsPmd) {
1417                                    default:
1418                                        print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
1419                                        break;
1420                                }
1421                                break;
1422                            case 0x03: // Sprm is modifying a picture property.
1423                                switch ($sprm_IsPmd) {
1424                                    default:
1425                                        print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
1426                                        break;
1427                                }
1428                                break;
1429                            case 0x04: // Sprm is modifying a section property.
1430                                switch ($sprm_IsPmd) {
1431                                    default:
1432                                        print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
1433                                        break;
1434                                }
1435                                break;
1436                            case 0x05: // Sprm is modifying a table property.
1437                                switch ($sprm_IsPmd) {
1438                                    default:
1439                                        print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
1440                                        break;
1441                                }
1442                                break;
1443                            default:
1444                                print_r('$sprm_Sgc : '.dechex($sprm_Sgc).PHP_EOL.PHP_EOL);
1445                                break;
1446                        }
1447                    } while ($cb > 0);
1448                } else {
1449                    if ($istd > 0) {
1450                        // @todo : Determining Properties of a Paragraph Style
1451                        # @see  http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx
1452                    }
1453                }
1454            }*/
1455        }
1456    }
1457
1458    /**
1459     * Character formatting properties to text in a document.
1460     *
1461     * @see  http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx
1462     */
1463    private function readRecordPlcfBteChpx(): void
1464    {
1465        $posMem = $this->arrayFib['fcPlcfBteChpx'];
1466        $num = $this->getNumInLcb($this->arrayFib['lcbPlcfBteChpx'], 4);
1467        $aPnBteChpx = [];
1468        for ($inc = 0; $inc <= $num; ++$inc) {
1469            $aPnBteChpx[$inc] = self::getInt4d($this->data1Table, $posMem);
1470            $posMem += 4;
1471        }
1472        $pnFkpChpx = self::getInt4d($this->data1Table, $posMem);
1473        $posMem += 4;
1474
1475        $offsetBase = $pnFkpChpx * 512;
1476        $offset = $offsetBase;
1477
1478        // ChpxFkp
1479        // @see  http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx
1480        $numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511);
1481        $arrayRGFC = [];
1482        for ($inc = 0; $inc <= $numRGFC; ++$inc) {
1483            $arrayRGFC[$inc] = self::getInt4d($this->dataWorkDocument, $offset);
1484            $offset += 4;
1485        }
1486
1487        $arrayRGB = [];
1488        for ($inc = 1; $inc <= $numRGFC; ++$inc) {
1489            $arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset);
1490            ++$offset;
1491        }
1492
1493        $start = 0;
1494        foreach ($arrayRGB as $keyRGB => $rgb) {
1495            $oStyle = new stdClass();
1496            $oStyle->pos_start = $start;
1497            $oStyle->pos_len = (int) ceil((($arrayRGFC[$keyRGB] - 1) - $arrayRGFC[$keyRGB - 1]) / 2);
1498            $start += $oStyle->pos_len;
1499
1500            if ($rgb > 0) {
1501                // Chp Structure
1502                // @see  http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
1503                $posRGB = $offsetBase + $rgb * 2;
1504
1505                $cb = self::getInt1d($this->dataWorkDocument, $posRGB);
1506                ++$posRGB;
1507
1508                $oStyle->style = $this->readPrl($this->dataWorkDocument, $posRGB, $cb);
1509                $posRGB += $oStyle->style->length;
1510            }
1511            $this->arrayCharacters[] = $oStyle;
1512        }
1513    }
1514
1515    /**
1516     * @return stdClass
1517     */
1518    private function readSprm($sprm)
1519    {
1520        $oSprm = new stdClass();
1521        $oSprm->isPmd = $sprm & 0x01FF;
1522        $oSprm->f = (int) ($sprm / 512) & 0x0001;
1523        $oSprm->sgc = (int) ($sprm / 1024) & 0x0007;
1524        $oSprm->spra = (int) ($sprm / 8192);
1525
1526        return $oSprm;
1527    }
1528
1529    /**
1530     * @param string $data
1531     * @param int $pos
1532     * @param stdClass $oSprm
1533     *
1534     * @return array
1535     */
1536    private function readSprmSpra($data, $pos, $oSprm)
1537    {
1538        $length = 0;
1539        $operand = null;
1540
1541        switch (dechex($oSprm->spra)) {
1542            case 0x0:
1543                $operand = self::getInt1d($data, $pos);
1544                $length = 1;
1545                switch (dechex($operand)) {
1546                    case 0x00:
1547                        $operand = false;
1548
1549                        break;
1550                    case 0x01:
1551                        $operand = true;
1552
1553                        break;
1554                    case 0x80:
1555                        $operand = self::SPRA_VALUE;
1556
1557                        break;
1558                    case 0x81:
1559                        $operand = self::SPRA_VALUE_OPPOSITE;
1560
1561                        break;
1562                }
1563
1564                break;
1565            case 0x1:
1566                $operand = self::getInt1d($data, $pos);
1567                $length = 1;
1568
1569                break;
1570            case 0x2:
1571            case 0x4:
1572            case 0x5:
1573                $operand = self::getInt2d($data, $pos);
1574                $length = 2;
1575
1576                break;
1577            case 0x3:
1578                if ($oSprm->isPmd != 0x70) {
1579                    $operand = self::getInt4d($data, $pos);
1580                    $length = 4;
1581                }
1582
1583                break;
1584            case 0x7:
1585                $operand = self::getInt3d($data, $pos);
1586                $length = 3;
1587
1588                break;
1589            default:
1590                // print_r('YO YO YO : '.PHP_EOL);
1591        }
1592
1593        return [
1594            'length' => $length,
1595            'operand' => $operand,
1596        ];
1597    }
1598
1599    /**
1600     * @param $data int
1601     * @param $pos int
1602     * @param $cbNum int
1603     *
1604     * @return stdClass
1605     *
1606     * @see  http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
1607     */
1608    private function readPrl($data, $pos, $cbNum)
1609    {
1610        $posStart = $pos;
1611        $oStylePrl = new stdClass();
1612
1613        // Variables
1614        $sprmCPicLocation = null;
1615        $sprmCFData = null;
1616        //$sprmCFSpec = null;
1617
1618        do {
1619            // Variables
1620            $operand = null;
1621
1622            $sprm = self::getInt2d($data, $pos);
1623            $oSprm = $this->readSprm($sprm);
1624            $pos += 2;
1625            $cbNum -= 2;
1626
1627            $arrayReturn = $this->readSprmSpra($data, $pos, $oSprm);
1628            $pos += $arrayReturn['length'];
1629            $cbNum -= $arrayReturn['length'];
1630            $operand = $arrayReturn['operand'];
1631
1632            switch (dechex($oSprm->sgc)) {
1633                // Paragraph property
1634                case 0x01:
1635                    break;
1636                    // Character property
1637                case 0x02:
1638                    if (!isset($oStylePrl->styleFont)) {
1639                        $oStylePrl->styleFont = [];
1640                    }
1641                    switch ($oSprm->isPmd) {
1642                        // sprmCFRMarkIns
1643                        case 0x01:
1644                            break;
1645                            // sprmCFFldVanish
1646                        case 0x02:
1647                            break;
1648                            // sprmCPicLocation
1649                        case 0x03:
1650                            $sprmCPicLocation = $operand;
1651
1652                            break;
1653                            // sprmCFData
1654                        case 0x06:
1655                            $sprmCFData = dechex($operand) != 0x00;
1656
1657                            break;
1658                            // sprmCFItalic
1659                        case 0x36:
1660                            // By default, text is not italicized.
1661                            switch ($operand) {
1662                                case false:
1663                                case true:
1664                                    $oStylePrl->styleFont['italic'] = $operand;
1665
1666                                    break;
1667                                case self::SPRA_VALUE:
1668                                    $oStylePrl->styleFont['italic'] = false;
1669
1670                                    break;
1671                                case self::SPRA_VALUE_OPPOSITE:
1672                                    $oStylePrl->styleFont['italic'] = true;
1673
1674                                    break;
1675                            }
1676
1677                            break;
1678                            // sprmCIstd
1679                        case 0x30:
1680                            //print_r('sprmCIstd : '.dechex($operand).PHP_EOL.PHP_EOL);
1681                            break;
1682                            // sprmCFBold
1683                        case 0x35:
1684                            // By default, text is not bold.
1685                            switch ($operand) {
1686                                case false:
1687                                case true:
1688                                    $oStylePrl->styleFont['bold'] = $operand;
1689
1690                                    break;
1691                                case self::SPRA_VALUE:
1692                                    $oStylePrl->styleFont['bold'] = false;
1693
1694                                    break;
1695                                case self::SPRA_VALUE_OPPOSITE:
1696                                    $oStylePrl->styleFont['bold'] = true;
1697
1698                                    break;
1699                            }
1700
1701                            break;
1702                            // sprmCFStrike
1703                        case 0x37:
1704                            // By default, text is not struck through.
1705                            switch ($operand) {
1706                                case false:
1707                                case true:
1708                                    $oStylePrl->styleFont['strikethrough'] = $operand;
1709
1710                                    break;
1711                                case self::SPRA_VALUE:
1712                                    $oStylePrl->styleFont['strikethrough'] = false;
1713
1714                                    break;
1715                                case self::SPRA_VALUE_OPPOSITE:
1716                                    $oStylePrl->styleFont['strikethrough'] = true;
1717
1718                                    break;
1719                            }
1720
1721                            break;
1722                            // sprmCKul
1723                        case 0x3E:
1724                            switch (dechex($operand)) {
1725                                case 0x00:
1726                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
1727
1728                                    break;
1729                                case 0x01:
1730                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_SINGLE;
1731
1732                                    break;
1733                                case 0x02:
1734                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WORDS;
1735
1736                                    break;
1737                                case 0x03:
1738                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOUBLE;
1739
1740                                    break;
1741                                case 0x04:
1742                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTTED;
1743
1744                                    break;
1745                                case 0x06:
1746                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_HEAVY;
1747
1748                                    break;
1749                                case 0x07:
1750                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASH;
1751
1752                                    break;
1753                                case 0x09:
1754                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASH;
1755
1756                                    break;
1757                                case 0x0A:
1758                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASH;
1759
1760                                    break;
1761                                case 0x0B:
1762                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVY;
1763
1764                                    break;
1765                                case 0x14:
1766                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTTEDHEAVY;
1767
1768                                    break;
1769                                case 0x17:
1770                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHHEAVY;
1771
1772                                    break;
1773                                case 0x19:
1774                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDASHHEAVY;
1775
1776                                    break;
1777                                case 0x1A:
1778                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DOTDOTDASHHEAVY;
1779
1780                                    break;
1781                                case 0x1B:
1782                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVYHEAVY;
1783
1784                                    break;
1785                                case 0x27:
1786                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHLONG;
1787
1788                                    break;
1789                                case 0x2B:
1790                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_WAVYDOUBLE;
1791
1792                                    break;
1793                                case 0x37:
1794                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_DASHLONGHEAVY;
1795
1796                                    break;
1797                                default:
1798                                    $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
1799
1800                                    break;
1801                            }
1802
1803                            break;
1804                            // sprmCIco
1805                            //@see  http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
1806                        case 0x42:
1807                            switch (dechex($operand)) {
1808                                case 0x00:
1809                                case 0x01:
1810                                    $oStylePrl->styleFont['color'] = '000000';
1811
1812                                    break;
1813                                case 0x02:
1814                                    $oStylePrl->styleFont['color'] = '0000FF';
1815
1816                                    break;
1817                                case 0x03:
1818                                    $oStylePrl->styleFont['color'] = '00FFFF';
1819
1820                                    break;
1821                                case 0x04:
1822                                    $oStylePrl->styleFont['color'] = '00FF00';
1823
1824                                    break;
1825                                case 0x05:
1826                                    $oStylePrl->styleFont['color'] = 'FF00FF';
1827
1828                                    break;
1829                                case 0x06:
1830                                    $oStylePrl->styleFont['color'] = 'FF0000';
1831
1832                                    break;
1833                                case 0x07:
1834                                    $oStylePrl->styleFont['color'] = 'FFFF00';
1835
1836                                    break;
1837                                case 0x08:
1838                                    $oStylePrl->styleFont['color'] = 'FFFFFF';
1839
1840                                    break;
1841                                case 0x09:
1842                                    $oStylePrl->styleFont['color'] = '000080';
1843
1844                                    break;
1845                                case 0x0A:
1846                                    $oStylePrl->styleFont['color'] = '008080';
1847
1848                                    break;
1849                                case 0x0B:
1850                                    $oStylePrl->styleFont['color'] = '008000';
1851
1852                                    break;
1853                                case 0x0C:
1854                                    $oStylePrl->styleFont['color'] = '800080';
1855
1856                                    break;
1857                                case 0x0D:
1858                                    $oStylePrl->styleFont['color'] = '800080';
1859
1860                                    break;
1861                                case 0x0E:
1862                                    $oStylePrl->styleFont['color'] = '808000';
1863
1864                                    break;
1865                                case 0x0F:
1866                                    $oStylePrl->styleFont['color'] = '808080';
1867
1868                                    break;
1869                                case 0x10:
1870                                    $oStylePrl->styleFont['color'] = 'C0C0C0';
1871                            }
1872
1873                            break;
1874                            // sprmCHps
1875                        case 0x43:
1876                            $oStylePrl->styleFont['size'] = $operand / 2;
1877
1878                            break;
1879                            // sprmCIss
1880                        case 0x48:
1881                            if (!isset($oStylePrl->styleFont['superScript'])) {
1882                                $oStylePrl->styleFont['superScript'] = false;
1883                            }
1884                            if (!isset($oStylePrl->styleFont['subScript'])) {
1885                                $oStylePrl->styleFont['subScript'] = false;
1886                            }
1887                            switch (dechex($operand)) {
1888                                case 0x00:
1889                                    // Normal text
1890                                    break;
1891                                case 0x01:
1892                                    $oStylePrl->styleFont['superScript'] = true;
1893
1894                                    break;
1895                                case 0x02:
1896                                    $oStylePrl->styleFont['subScript'] = true;
1897
1898                                    break;
1899                            }
1900
1901                            break;
1902                            // sprmCRgFtc0
1903                        case 0x4F:
1904                            $oStylePrl->styleFont['name'] = '';
1905                            if (isset($this->arrayFonts[$operand])) {
1906                                $oStylePrl->styleFont['name'] = $this->arrayFonts[$operand]['main'];
1907                            }
1908
1909                            break;
1910                            // sprmCRgFtc1
1911                        case 0x50:
1912                            // if the language for the text is an East Asian language
1913                            break;
1914                            // sprmCRgFtc2
1915                        case 0x51:
1916                            // if the character falls outside the Unicode character range
1917                            break;
1918                            // sprmCFSpec
1919                        case 0x55:
1920                            //$sprmCFSpec = $operand;
1921                            break;
1922                            // sprmCFtcBi
1923                        case 0x5E:
1924                            break;
1925                            // sprmCFItalicBi
1926                        case 0x5D:
1927                            break;
1928                            // sprmCHpsBi
1929                        case 0x61:
1930                            break;
1931                            // sprmCShd80
1932                            //@see  http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx
1933                        case 0x66:
1934                            // $operand = self::getInt2d($data, $pos);
1935                            $pos += 2;
1936                            $cbNum -= 2;
1937
1938                            // $ipat = ($operand >> 0) && bindec('111111');
1939                            // $icoBack = ($operand >> 6) && bindec('11111');
1940                            // $icoFore = ($operand >> 11) && bindec('11111');
1941                            break;
1942                            // sprmCCv
1943                            //@see  http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx
1944                        case 0x70:
1945                            $red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
1946                            ++$pos;
1947                            $green = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
1948                            ++$pos;
1949                            $blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
1950                            ++$pos;
1951                            ++$pos;
1952                            $oStylePrl->styleFont['color'] = $red . $green . $blue;
1953                            $cbNum -= 4;
1954
1955                            break;
1956                        default:
1957                            // print_r('@todo Character : 0x'.dechex($oSprm->isPmd));
1958                            // print_r(PHP_EOL);
1959                    }
1960
1961                    break;
1962                    // Picture property
1963                case 0x03:
1964                    break;
1965                    // Section property
1966                case 0x04:
1967                    if (!isset($oStylePrl->styleSection)) {
1968                        $oStylePrl->styleSection = [];
1969                    }
1970                    switch ($oSprm->isPmd) {
1971                        // sprmSNfcPgn
1972                        case 0x0E:
1973                            // numbering format used for page numbers
1974                            break;
1975                            // sprmSXaPage
1976                        case 0x1F:
1977                            $oStylePrl->styleSection['pageSizeW'] = $operand;
1978
1979                            break;
1980                            // sprmSYaPage
1981                        case 0x20:
1982                            $oStylePrl->styleSection['pageSizeH'] = $operand;
1983
1984                            break;
1985                            // sprmSDxaLeft
1986                        case 0x21:
1987                            $oStylePrl->styleSection['marginLeft'] = $operand;
1988
1989                            break;
1990                            // sprmSDxaRight
1991                        case 0x22:
1992                            $oStylePrl->styleSection['marginRight'] = $operand;
1993
1994                            break;
1995                            // sprmSDyaTop
1996                        case 0x23:
1997                            $oStylePrl->styleSection['marginTop'] = $operand;
1998
1999                            break;
2000                            // sprmSDyaBottom
2001                        case 0x24:
2002                            $oStylePrl->styleSection['marginBottom'] = $operand;
2003
2004                            break;
2005                            // sprmSFBiDi
2006                        case 0x28:
2007                            // RTL layout
2008                            break;
2009                            // sprmSDxtCharSpace
2010                        case 0x30:
2011                            // characpter pitch
2012                            break;
2013                            // sprmSDyaLinePitch
2014                        case 0x31:
2015                            // line height
2016                            break;
2017                            // sprmSClm
2018                        case 0x32:
2019                            // document grid mode
2020                            break;
2021                            // sprmSTextFlow
2022                        case 0x33:
2023                            // text flow
2024                            break;
2025                        default:
2026                            // print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
2027                            // print_r(PHP_EOL);
2028                    }
2029
2030                    break;
2031                    // Table property
2032                case 0x05:
2033                    break;
2034            }
2035        } while ($cbNum > 0);
2036
2037        if (null !== $sprmCPicLocation) {
2038            if (null !== $sprmCFData && $sprmCFData == 0x01) {
2039                // NilPICFAndBinData
2040                //@todo Read Hyperlink structure
2041                /*$lcb = self::getInt4d($this->dataData, $sprmCPicLocation);
2042                $sprmCPicLocation += 4;
2043                $cbHeader = self::getInt2d($this->dataData, $sprmCPicLocation);
2044                $sprmCPicLocation += 2;
2045                // ignored
2046                $sprmCPicLocation += 62;
2047                // depending of the element
2048                // Hyperlink => HFD
2049                // HFD > bits
2050                $sprmCPicLocation += 1;
2051                // HFD > clsid
2052                $sprmCPicLocation += 16;
2053                // HFD > hyperlink
2054                //@see  http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx
2055                $streamVersion = self::getInt4d($this->dataData, $sprmCPicLocation);
2056                $sprmCPicLocation += 4;
2057                $data = self::getInt4d($this->dataData, $sprmCPicLocation);
2058                $sprmCPicLocation += 4;
2059                $hlstmfAbsFromGetdataRel = ($data >> 9) & bindec('1');
2060                $hlstmfMonikerSavedAsStr = ($data >> 8) & bindec('1');
2061                $hlstmfHasFrameName = ($data >> 7) & bindec('1');
2062                $hlstmfHasCreationTime = ($data >> 6) & bindec('1');
2063                $hlstmfHasGUID = ($data >> 5) & bindec('1');
2064                $hlstmfHasDisplayName = ($data >> 4) & bindec('1');
2065                $hlstmfHasLocationStr = ($data >> 3) & bindec('1');
2066                $hlstmfSiteGaveDisplayName = ($data >> 2) & bindec('1');
2067                $hlstmfIsAbsolute = ($data >> 1) & bindec('1');
2068                $hlstmfHasMoniker = ($data >> 0) & bindec('1');
2069                for ($inc = 0; $inc <= 32; $inc++) {
2070                    echo ($data >> $inc) & bindec('1');
2071                }
2072
2073                print_r('$hlstmfHasMoniker > '.$hlstmfHasMoniker.PHP_EOL);
2074                print_r('$hlstmfIsAbsolute > '.$hlstmfIsAbsolute.PHP_EOL);
2075                print_r('$hlstmfSiteGaveDisplayName > '.$hlstmfSiteGaveDisplayName.PHP_EOL);
2076                print_r('$hlstmfHasLocationStr > '.$hlstmfHasLocationStr.PHP_EOL);
2077                print_r('$hlstmfHasDisplayName > '.$hlstmfHasDisplayName.PHP_EOL);
2078                print_r('$hlstmfHasGUID > '.$hlstmfHasGUID.PHP_EOL);
2079                print_r('$hlstmfHasCreationTime > '.$hlstmfHasCreationTime.PHP_EOL);
2080                print_r('$hlstmfHasFrameName > '.$hlstmfHasFrameName.PHP_EOL);
2081                print_r('$hlstmfMonikerSavedAsStr > '.$hlstmfMonikerSavedAsStr.PHP_EOL);
2082                print_r('$hlstmfAbsFromGetdataRel > '.$hlstmfAbsFromGetdataRel.PHP_EOL);
2083                if ($streamVersion == 2) {
2084                    $AAA = self::getInt4d($this->dataData, $sprmCPicLocation);
2085                    echo 'AAAA : '.$AAA.PHP_EOL;
2086                    if ($hlstmfHasDisplayName == 1) {
2087                        echo 'displayName'.PHP_EOL;
2088                    }
2089                    if ($hlstmfHasFrameName == 1) {
2090                        echo 'targetFrameName'.PHP_EOL;
2091                    }
2092                    if ($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1) {
2093                        $sprmCPicLocation += 16;
2094                        $length = self::getInt4d($this->dataData, $sprmCPicLocation);
2095                        $sprmCPicLocation += 4;
2096                        for ($inc = 0; $inc < ($length / 2); $inc++) {
2097                            $chr = self::getInt2d($this->dataData, $sprmCPicLocation);
2098                            $sprmCPicLocation += 2;
2099                            print_r(chr($chr));
2100                        }
2101                        echo PHP_EOL;
2102                        echo 'moniker : '.$length.PHP_EOL;
2103                    }
2104                    if ($hlstmfHasMoniker == 1 || $hlstmfMonikerSavedAsStr == 1) {
2105                        echo 'oleMoniker'.PHP_EOL;
2106                    }
2107                    if ($hlstmfHasLocationStr == 1) {
2108                        echo 'location'.PHP_EOL;
2109                    }
2110                    if ($hlstmfHasGUID == 1) {
2111                        echo 'guid'.PHP_EOL;
2112                        $sprmCPicLocation += 16;
2113                    }
2114                    if ($hlstmfHasCreationTime == 1) {
2115                        echo 'fileTime'.PHP_EOL;
2116                        $sprmCPicLocation += 4;
2117                    }
2118                    echo 'HYPERLINK'.PHP_EOL;
2119                }*/
2120            } else {
2121                // Pictures
2122                //@see  http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
2123                //@see  http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx
2124                // PICF : lcb
2125                $sprmCPicLocation += 4;
2126                // PICF : cbHeader
2127                $sprmCPicLocation += 2;
2128                // PICF : mfpf : mm
2129                $mfpfMm = self::getInt2d($this->dataData, $sprmCPicLocation);
2130                $sprmCPicLocation += 2;
2131                // PICF : mfpf : xExt
2132                $sprmCPicLocation += 2;
2133                // PICF : mfpf : yExt
2134                $sprmCPicLocation += 2;
2135                // PICF : mfpf : swHMF
2136                $sprmCPicLocation += 2;
2137                // PICF : innerHeader : grf
2138                $sprmCPicLocation += 4;
2139                // PICF : innerHeader : padding1
2140                $sprmCPicLocation += 4;
2141                // PICF : innerHeader : mmPM
2142                $sprmCPicLocation += 2;
2143                // PICF : innerHeader : padding2
2144                $sprmCPicLocation += 4;
2145                // PICF : picmid : dxaGoal
2146                $picmidDxaGoal = self::getInt2d($this->dataData, $sprmCPicLocation);
2147                $sprmCPicLocation += 2;
2148                // PICF : picmid : dyaGoal
2149                $picmidDyaGoal = self::getInt2d($this->dataData, $sprmCPicLocation);
2150                $sprmCPicLocation += 2;
2151                // PICF : picmid : mx
2152                $picmidMx = self::getInt2d($this->dataData, $sprmCPicLocation);
2153                $sprmCPicLocation += 2;
2154                // PICF : picmid : my
2155                $picmidMy = self::getInt2d($this->dataData, $sprmCPicLocation);
2156                $sprmCPicLocation += 2;
2157                // PICF : picmid : dxaReserved1
2158                $picmidDxaCropLeft = self::getInt2d($this->dataData, $sprmCPicLocation);
2159                $sprmCPicLocation += 2;
2160                // PICF : picmid : dyaReserved1
2161                $picmidDxaCropTop = self::getInt2d($this->dataData, $sprmCPicLocation);
2162                $sprmCPicLocation += 2;
2163                // PICF : picmid : dxaReserved2
2164                $picmidDxaCropRight = self::getInt2d($this->dataData, $sprmCPicLocation);
2165                $sprmCPicLocation += 2;
2166                // PICF : picmid : dyaReserved2
2167                $picmidDxaCropBottom = self::getInt2d($this->dataData, $sprmCPicLocation);
2168                $sprmCPicLocation += 2;
2169                // PICF : picmid : fReserved
2170                ++$sprmCPicLocation;
2171                // PICF : picmid : bpp
2172                ++$sprmCPicLocation;
2173                // PICF : picmid : brcTop80
2174                $sprmCPicLocation += 4;
2175                // PICF : picmid : brcLeft80
2176                $sprmCPicLocation += 4;
2177                // PICF : picmid : brcBottom80
2178                $sprmCPicLocation += 4;
2179                // PICF : picmid : brcRight80
2180                $sprmCPicLocation += 4;
2181                // PICF : picmid : dxaReserved3
2182                $sprmCPicLocation += 2;
2183                // PICF : picmid : dyaReserved3
2184                $sprmCPicLocation += 2;
2185                // PICF : cProps
2186                $sprmCPicLocation += 2;
2187
2188                if ($mfpfMm == 0x0066) {
2189                    // cchPicName
2190                    $cchPicName = self::getInt1d($this->dataData, $sprmCPicLocation);
2191                    ++$sprmCPicLocation;
2192
2193                    // stPicName
2194                    //$stPicName = '';
2195                    for ($inc = 0; $inc <= $cchPicName; ++$inc) {
2196                        //$chr = self::getInt1d($this->dataData, $sprmCPicLocation);
2197                        ++$sprmCPicLocation;
2198                        //$stPicName .= chr($chr);
2199                    }
2200                }
2201
2202                // picture (OfficeArtInlineSpContainer)
2203                // picture : shape
2204                $shapeRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
2205                $sprmCPicLocation += 8;
2206                if ($shapeRH['recVer'] == 0xF && $shapeRH['recInstance'] == 0x000 && $shapeRH['recType'] == 0xF004) {
2207                    $sprmCPicLocation += $shapeRH['recLen'];
2208                }
2209                // picture : rgfb
2210                //@see  http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx
2211                $fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
2212                while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) {
2213                    $sprmCPicLocation += 8;
2214                    switch ($fileBlockRH['recType']) {
2215                        // OfficeArtFBSE
2216                        //@see  http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx
2217                        case 0xF007:
2218                            // btWin32
2219                            ++$sprmCPicLocation;
2220                            // btMacOS
2221                            ++$sprmCPicLocation;
2222                            // rgbUid
2223                            $sprmCPicLocation += 16;
2224                            // tag
2225                            $sprmCPicLocation += 2;
2226                            // size
2227                            $sprmCPicLocation += 4;
2228                            // cRef
2229                            $sprmCPicLocation += 4;
2230                            // foDelay
2231                            $sprmCPicLocation += 4;
2232                            // unused1
2233                            ++$sprmCPicLocation;
2234                            // cbName
2235                            $cbName = self::getInt1d($this->dataData, $sprmCPicLocation);
2236                            ++$sprmCPicLocation;
2237                            // unused2
2238                            ++$sprmCPicLocation;
2239                            // unused3
2240                            ++$sprmCPicLocation;
2241                            // nameData
2242                            if ($cbName > 0) {
2243                                //$nameData = '';
2244                                for ($inc = 0; $inc <= ($cbName / 2); ++$inc) {
2245                                    //$chr = self::getInt2d($this->dataData, $sprmCPicLocation);
2246                                    $sprmCPicLocation += 2;
2247                                    //$nameData .= chr($chr);
2248                                }
2249                            }
2250                            // embeddedBlip
2251                            //@see  http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx
2252                            $embeddedBlipRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
2253                            switch ($embeddedBlipRH['recType']) {
2254                                case self::OFFICEARTBLIPJPG:
2255                                case self::OFFICEARTBLIPJPEG:
2256                                    if (!isset($oStylePrl->image)) {
2257                                        $oStylePrl->image = [];
2258                                    }
2259                                    $sprmCPicLocation += 8;
2260                                    // embeddedBlip : rgbUid1
2261                                    $sprmCPicLocation += 16;
2262                                    if ($embeddedBlipRH['recInstance'] == 0x6E1) {
2263                                        // rgbUid2
2264                                        $sprmCPicLocation += 16;
2265                                    }
2266                                    // embeddedBlip : tag
2267                                    ++$sprmCPicLocation;
2268                                    // embeddedBlip : BLIPFileData
2269                                    $oStylePrl->image['data'] = substr($this->dataData, $sprmCPicLocation, $embeddedBlipRH['recLen']);
2270                                    $oStylePrl->image['format'] = 'jpg';
2271                                    // Image Size
2272                                    $iCropWidth = $picmidDxaGoal - ($picmidDxaCropLeft + $picmidDxaCropRight);
2273                                    $iCropHeight = $picmidDyaGoal - ($picmidDxaCropTop + $picmidDxaCropBottom);
2274                                    if (!$iCropWidth) {
2275                                        $iCropWidth = 1;
2276                                    }
2277                                    if (!$iCropHeight) {
2278                                        $iCropHeight = 1;
2279                                    }
2280                                    $oStylePrl->image['width'] = Drawing::twipsToPixels($iCropWidth * $picmidMx / 1000);
2281                                    $oStylePrl->image['height'] = Drawing::twipsToPixels($iCropHeight * $picmidMy / 1000);
2282
2283                                    $sprmCPicLocation += $embeddedBlipRH['recLen'];
2284
2285                                    break;
2286                                case self::OFFICEARTBLIPPNG:
2287                                    break;
2288                                default:
2289                                    // print_r(dechex($embeddedBlipRH['recType']));
2290                            }
2291
2292                            break;
2293                    }
2294                    $fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
2295                }
2296            }
2297        }
2298
2299        $oStylePrl->length = $pos - $posStart;
2300
2301        return $oStylePrl;
2302    }
2303
2304    /**
2305     * Read a record header.
2306     *
2307     * @param string $stream
2308     * @param int $pos
2309     *
2310     * @return array
2311     */
2312    private function loadRecordHeader($stream, $pos)
2313    {
2314        $rec = self::getInt2d($stream, $pos);
2315        $recType = self::getInt2d($stream, $pos + 2);
2316        $recLen = self::getInt4d($stream, $pos + 4);
2317
2318        return [
2319            'recVer' => ($rec >> 0) & bindec('1111'),
2320            'recInstance' => ($rec >> 4) & bindec('111111111111'),
2321            'recType' => $recType,
2322            'recLen' => $recLen,
2323        ];
2324    }
2325
2326    private function generatePhpWord(): void
2327    {
2328        foreach ($this->arraySections as $itmSection) {
2329            $oSection = $this->phpWord->addSection();
2330            $oSection->setStyle($itmSection->styleSection);
2331
2332            $sHYPERLINK = '';
2333            foreach ($this->arrayParagraphs as $itmParagraph) {
2334                $textPara = $itmParagraph;
2335                foreach ($this->arrayCharacters as $oCharacters) {
2336                    $subText = mb_substr($textPara, $oCharacters->pos_start, $oCharacters->pos_len);
2337                    $subText = str_replace(chr(13), PHP_EOL, $subText);
2338                    $arrayText = explode(PHP_EOL, $subText);
2339                    if (end($arrayText) == '') {
2340                        array_pop($arrayText);
2341                    }
2342                    if (reset($arrayText) == '') {
2343                        array_shift($arrayText);
2344                    }
2345
2346                    // Style Character
2347                    $styleFont = [];
2348                    if (isset($oCharacters->style)) {
2349                        if (isset($oCharacters->style->styleFont)) {
2350                            $styleFont = $oCharacters->style->styleFont;
2351                        }
2352                    }
2353
2354                    foreach ($arrayText as $sText) {
2355                        // HyperLink
2356                        if (empty($sText) && !empty($sHYPERLINK)) {
2357                            $arrHYPERLINK = explode('"', $sHYPERLINK);
2358                            $oSection->addLink($arrHYPERLINK[1], null);
2359                            // print_r('>addHyperLink<'.$sHYPERLINK.'>'.ord($sHYPERLINK[0]).EOL);
2360                            $sHYPERLINK = '';
2361                        }
2362
2363                        // TextBreak
2364                        if (empty($sText)) {
2365                            $oSection->addTextBreak();
2366                            $sHYPERLINK = '';
2367                            // print_r('>addTextBreak<' . EOL);
2368                        }
2369
2370                        if (!empty($sText)) {
2371                            if (!empty($sHYPERLINK) && ord($sText[0]) > 20) {
2372                                $sHYPERLINK .= $sText;
2373                            }
2374                            if (empty($sHYPERLINK)) {
2375                                if (ord($sText[0]) > 20) {
2376                                    if (strpos(trim($sText), 'HYPERLINK "') === 0) {
2377                                        $sHYPERLINK = $sText;
2378                                    } else {
2379                                        $oSection->addText($sText, $styleFont);
2380                                        // print_r('>addText<'.$sText.'>'.ord($sText[0]).EOL);
2381                                    }
2382                                }
2383                                if (ord($sText[0]) == 1) {
2384                                    if (isset($oCharacters->style->image)) {
2385                                        $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc') . '.' . $oCharacters->style->image['format'];
2386                                        file_put_contents($fileImage, $oCharacters->style->image['data']);
2387                                        $oSection->addImage($fileImage, ['width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']]);
2388                                        // print_r('>addImage<'.$fileImage.'>'.EOL);
2389                                    }
2390                                }
2391                            }
2392                        }
2393                    }
2394                }
2395            }
2396        }
2397    }
2398
2399    /**
2400     * Read 8-bit unsigned integer.
2401     *
2402     * @param string $data
2403     * @param int $pos
2404     *
2405     * @return int
2406     */
2407    public static function getInt1d($data, $pos)
2408    {
2409        return ord($data[$pos]);
2410    }
2411
2412    /**
2413     * Read 16-bit unsigned integer.
2414     *
2415     * @param string $data
2416     * @param int $pos
2417     *
2418     * @return int
2419     */
2420    public static function getInt2d($data, $pos)
2421    {
2422        return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
2423    }
2424
2425    /**
2426     * Read 24-bit signed integer.
2427     *
2428     * @param string $data
2429     * @param int $pos
2430     *
2431     * @return int
2432     */
2433    public static function getInt3d($data, $pos)
2434    {
2435        return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16);
2436    }
2437
2438    /**
2439     * Read 32-bit signed integer.
2440     *
2441     * @param string $data
2442     * @param int $pos
2443     *
2444     * @return int
2445     */
2446    public static function getInt4d($data, $pos)
2447    {
2448        // FIX: represent numbers correctly on 64-bit system
2449        // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
2450        // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
2451        $or24 = ord($data[$pos + 3]);
2452        if ($or24 >= 128) {
2453            // negative number
2454            $ord24 = -abs((256 - $or24) << 24);
2455        } else {
2456            $ord24 = ($or24 & 127) << 24;
2457        }
2458
2459        return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
2460    }
2461}