1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* PHPExcel |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2006 - 2012 PHPExcel |
6
|
|
|
* |
7
|
|
|
* This library is free software; you can redistribute it and/or |
8
|
|
|
* modify it under the terms of the GNU Lesser General Public |
9
|
|
|
* License as published by the Free Software Foundation; either |
10
|
|
|
* version 2.1 of the License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This library is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15
|
|
|
* Lesser General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Lesser General Public |
18
|
|
|
* License along with this library; if not, write to the Free Software |
19
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20
|
|
|
* |
21
|
|
|
* @category PHPExcel |
22
|
|
|
* @package PHPExcel_Writer_Excel5 |
23
|
|
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
24
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL |
25
|
|
|
* @version 1.7.7, 2012-05-19 |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* PHPExcel_Writer_Excel5 |
31
|
|
|
* |
32
|
|
|
* @category PHPExcel |
33
|
|
|
* @package PHPExcel_Writer_Excel5 |
34
|
|
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) |
35
|
|
|
*/ |
36
|
|
|
class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Pre-calculate formulas |
40
|
|
|
* |
41
|
|
|
* @var boolean |
42
|
|
|
*/ |
43
|
|
|
private $_preCalculateFormulas = true; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* PHPExcel object |
47
|
|
|
* |
48
|
|
|
* @var PHPExcel |
49
|
|
|
*/ |
50
|
|
|
private $_phpExcel; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Total number of shared strings in workbook |
54
|
|
|
* |
55
|
|
|
* @var int |
56
|
|
|
*/ |
57
|
|
|
private $_str_total = 0; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Number of unique shared strings in workbook |
61
|
|
|
* |
62
|
|
|
* @var int |
63
|
|
|
*/ |
64
|
|
|
private $_str_unique = 0; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Array of unique shared strings in workbook |
68
|
|
|
* |
69
|
|
|
* @var array |
70
|
|
|
*/ |
71
|
|
|
private $_str_table = array(); |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Color cache. Mapping between RGB value and color index. |
75
|
|
|
* |
76
|
|
|
* @var array |
77
|
|
|
*/ |
78
|
|
|
private $_colors; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Formula parser |
82
|
|
|
* |
83
|
|
|
* @var PHPExcel_Writer_Excel5_Parser |
84
|
|
|
*/ |
85
|
|
|
private $_parser; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Identifier clusters for drawings. Used in MSODRAWINGGROUP record. |
89
|
|
|
* |
90
|
|
|
* @var array |
91
|
|
|
*/ |
92
|
|
|
private $_IDCLs; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Basic OLE object summary information |
96
|
|
|
* |
97
|
|
|
* @var array |
98
|
|
|
*/ |
99
|
|
|
private $_summaryInformation; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Extended OLE object document summary information |
103
|
|
|
* |
104
|
|
|
* @var array |
105
|
|
|
*/ |
106
|
|
|
private $_documentSummaryInformation; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Create a new PHPExcel_Writer_Excel5 |
110
|
|
|
* |
111
|
|
|
* @param PHPExcel $phpExcel PHPExcel object |
112
|
|
|
*/ |
113
|
|
|
public function __construct(PHPExcel $phpExcel) { |
114
|
|
|
$this->_phpExcel = $phpExcel; |
115
|
|
|
|
116
|
|
|
$this->_parser = new PHPExcel_Writer_Excel5_Parser(); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Save PHPExcel to file |
121
|
|
|
* |
122
|
|
|
* @param string $pFilename |
123
|
|
|
* @throws Exception |
124
|
|
|
*/ |
125
|
|
|
public function save($pFilename = null) { |
126
|
|
|
|
127
|
|
|
// garbage collect |
128
|
|
|
$this->_phpExcel->garbageCollect(); |
129
|
|
|
|
130
|
|
|
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog; |
131
|
|
|
PHPExcel_Calculation::getInstance()->writeDebugLog = false; |
132
|
|
|
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); |
133
|
|
|
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); |
134
|
|
|
|
135
|
|
|
// initialize colors array |
136
|
|
|
$this->_colors = array(); |
137
|
|
|
|
138
|
|
|
// Initialise workbook writer |
139
|
|
|
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, |
140
|
|
|
$this->_str_total, $this->_str_unique, $this->_str_table, |
141
|
|
|
$this->_colors, $this->_parser); |
142
|
|
|
|
143
|
|
|
// Initialise worksheet writers |
144
|
|
|
$countSheets = $this->_phpExcel->getSheetCount(); |
145
|
|
|
for ($i = 0; $i < $countSheets; ++$i) { |
146
|
|
|
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique, |
147
|
|
|
$this->_str_table, $this->_colors, |
148
|
|
|
$this->_parser, |
149
|
|
|
$this->_preCalculateFormulas, |
150
|
|
|
$this->_phpExcel->getSheet($i)); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook. |
154
|
|
|
$this->_buildWorksheetEschers(); |
155
|
|
|
$this->_buildWorkbookEscher(); |
156
|
|
|
|
157
|
|
|
// add 15 identical cell style Xfs |
158
|
|
|
// for now, we use the first cellXf instead of cellStyleXf |
159
|
|
|
$cellXfCollection = $this->_phpExcel->getCellXfCollection(); |
160
|
|
|
for ($i = 0; $i < 15; ++$i) { |
161
|
|
|
$this->_writerWorkbook->addXfWriter($cellXfCollection[0], true); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
// add all the cell Xfs |
165
|
|
|
foreach ($this->_phpExcel->getCellXfCollection() as $style) { |
166
|
|
|
$this->_writerWorkbook->addXfWriter($style, false); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
// add fonts from rich text eleemnts |
170
|
|
|
for ($i = 0; $i < $countSheets; ++$i) { |
171
|
|
|
foreach ($this->_writerWorksheets[$i]->_phpSheet->getCellCollection() as $cellID) { |
172
|
|
|
$cell = $this->_writerWorksheets[$i]->_phpSheet->getCell($cellID); |
173
|
|
|
$cVal = $cell->getValue(); |
174
|
|
|
if ($cVal instanceof PHPExcel_RichText) { |
175
|
|
|
$elements = $cVal->getRichTextElements(); |
176
|
|
|
foreach ($elements as $element) { |
177
|
|
|
if ($element instanceof PHPExcel_RichText_Run) { |
178
|
|
|
$font = $element->getFont(); |
179
|
|
|
$this->_writerWorksheets[$i]->_fntHashIndex[$font->getHashCode()] = $this->_writerWorkbook->_addFont($font); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
// initialize OLE file |
187
|
|
|
$workbookStreamName = 'Workbook'; |
188
|
|
|
$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName)); |
189
|
|
|
|
190
|
|
|
// Write the worksheet streams before the global workbook stream, |
191
|
|
|
// because the byte sizes of these are needed in the global workbook stream |
192
|
|
|
$worksheetSizes = array(); |
193
|
|
|
for ($i = 0; $i < $countSheets; ++$i) { |
194
|
|
|
$this->_writerWorksheets[$i]->close(); |
195
|
|
|
$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
// add binary data for global workbook stream |
199
|
|
|
$OLE->append( $this->_writerWorkbook->writeWorkbook($worksheetSizes) ); |
200
|
|
|
|
201
|
|
|
// add binary data for sheet streams |
202
|
|
|
for ($i = 0; $i < $countSheets; ++$i) { |
203
|
|
|
$OLE->append($this->_writerWorksheets[$i]->getData()); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
$this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation(); |
|
|
|
|
207
|
|
|
// initialize OLE Document Summary Information |
208
|
|
View Code Duplication |
if(isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)){ |
209
|
|
|
$OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation')); |
210
|
|
|
$OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
$this->_summaryInformation = $this->_writeSummaryInformation(); |
|
|
|
|
214
|
|
|
// initialize OLE Summary Information |
215
|
|
View Code Duplication |
if(isset($this->_summaryInformation) && !empty($this->_summaryInformation)){ |
216
|
|
|
$OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation')); |
217
|
|
|
$OLE_SummaryInformation->append($this->_summaryInformation); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
// define OLE Parts |
221
|
|
|
$arrRootData = array($OLE); |
222
|
|
|
// initialize OLE Properties file |
223
|
|
|
if(isset($OLE_SummaryInformation)){ |
224
|
|
|
$arrRootData[] = $OLE_SummaryInformation; |
225
|
|
|
} |
226
|
|
|
// initialize OLE Extended Properties file |
227
|
|
|
if(isset($OLE_DocumentSummaryInformation)){ |
228
|
|
|
$arrRootData[] = $OLE_DocumentSummaryInformation; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), $arrRootData); |
232
|
|
|
// save the OLE file |
233
|
|
|
$res = $root->save($pFilename); |
234
|
|
|
|
235
|
|
|
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType); |
236
|
|
|
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Set temporary storage directory |
241
|
|
|
* |
242
|
|
|
* @deprecated |
243
|
|
|
* @param string $pValue Temporary storage directory |
244
|
|
|
* @throws Exception Exception when directory does not exist |
245
|
|
|
* @return PHPExcel_Writer_Excel5 |
246
|
|
|
*/ |
247
|
|
|
public function setTempDir($pValue = '') { |
|
|
|
|
248
|
|
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Get Pre-Calculate Formulas |
253
|
|
|
* |
254
|
|
|
* @return boolean |
255
|
|
|
*/ |
256
|
|
|
public function getPreCalculateFormulas() { |
257
|
|
|
return $this->_preCalculateFormulas; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Set Pre-Calculate Formulas |
262
|
|
|
* |
263
|
|
|
* @param boolean $pValue Pre-Calculate Formulas? |
264
|
|
|
*/ |
265
|
|
|
public function setPreCalculateFormulas($pValue = true) { |
266
|
|
|
$this->_preCalculateFormulas = $pValue; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Build the Worksheet Escher objects |
271
|
|
|
* |
272
|
|
|
*/ |
273
|
|
|
private function _buildWorksheetEschers() |
274
|
|
|
{ |
275
|
|
|
// 1-based index to BstoreContainer |
276
|
|
|
$blipIndex = 0; |
277
|
|
|
|
278
|
|
|
foreach ($this->_phpExcel->getAllsheets() as $sheet) { |
279
|
|
|
// sheet index |
280
|
|
|
$sheetIndex = $sheet->getParent()->getIndex($sheet); |
281
|
|
|
|
282
|
|
|
$escher = null; |
283
|
|
|
|
284
|
|
|
// check if there are any shapes for this sheet |
285
|
|
|
if (count($sheet->getDrawingCollection()) == 0) { |
286
|
|
|
continue; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
// create intermediate Escher object |
290
|
|
|
$escher = new PHPExcel_Shared_Escher(); |
291
|
|
|
|
292
|
|
|
// dgContainer |
293
|
|
|
$dgContainer = new PHPExcel_Shared_Escher_DgContainer(); |
294
|
|
|
|
295
|
|
|
// set the drawing index (we use sheet index + 1) |
296
|
|
|
$dgId = $sheet->getParent()->getIndex($sheet) + 1; |
297
|
|
|
$dgContainer->setDgId($dgId); |
298
|
|
|
$escher->setDgContainer($dgContainer); |
299
|
|
|
|
300
|
|
|
// spgrContainer |
301
|
|
|
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer(); |
302
|
|
|
$dgContainer->setSpgrContainer($spgrContainer); |
303
|
|
|
|
304
|
|
|
// add one shape which is the group shape |
305
|
|
|
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); |
306
|
|
|
$spContainer->setSpgr(true); |
307
|
|
|
$spContainer->setSpType(0); |
308
|
|
|
$spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10); |
309
|
|
|
$spgrContainer->addChild($spContainer); |
310
|
|
|
|
311
|
|
|
// add the shapes |
312
|
|
|
|
313
|
|
|
$countShapes[$sheetIndex] = 0; // count number of shapes (minus group shape), in sheet |
|
|
|
|
314
|
|
|
|
315
|
|
|
foreach ($sheet->getDrawingCollection() as $drawing) { |
316
|
|
|
++$blipIndex; |
317
|
|
|
|
318
|
|
|
++$countShapes[$sheetIndex]; |
319
|
|
|
|
320
|
|
|
// add the shape |
321
|
|
|
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer(); |
322
|
|
|
|
323
|
|
|
// set the shape type |
324
|
|
|
$spContainer->setSpType(0x004B); |
325
|
|
|
|
326
|
|
|
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index) |
327
|
|
|
$reducedSpId = $countShapes[$sheetIndex]; |
328
|
|
|
$spId = $reducedSpId |
329
|
|
|
| ($sheet->getParent()->getIndex($sheet) + 1) << 10; |
330
|
|
|
$spContainer->setSpId($spId); |
331
|
|
|
|
332
|
|
|
// keep track of last reducedSpId |
333
|
|
|
$lastReducedSpId = $reducedSpId; |
334
|
|
|
|
335
|
|
|
// keep track of last spId |
336
|
|
|
$lastSpId = $spId; |
337
|
|
|
|
338
|
|
|
// set the BLIP index |
339
|
|
|
$spContainer->setOPT(0x4104, $blipIndex); |
340
|
|
|
|
341
|
|
|
// set coordinates and offsets, client anchor |
342
|
|
|
$coordinates = $drawing->getCoordinates(); |
343
|
|
|
$offsetX = $drawing->getOffsetX(); |
344
|
|
|
$offsetY = $drawing->getOffsetY(); |
345
|
|
|
$width = $drawing->getWidth(); |
346
|
|
|
$height = $drawing->getHeight(); |
347
|
|
|
|
348
|
|
|
$twoAnchor = PHPExcel_Shared_Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height); |
349
|
|
|
|
350
|
|
|
$spContainer->setStartCoordinates($twoAnchor['startCoordinates']); |
351
|
|
|
$spContainer->setStartOffsetX($twoAnchor['startOffsetX']); |
352
|
|
|
$spContainer->setStartOffsetY($twoAnchor['startOffsetY']); |
353
|
|
|
$spContainer->setEndCoordinates($twoAnchor['endCoordinates']); |
354
|
|
|
$spContainer->setEndOffsetX($twoAnchor['endOffsetX']); |
355
|
|
|
$spContainer->setEndOffsetY($twoAnchor['endOffsetY']); |
356
|
|
|
|
357
|
|
|
$spgrContainer->addChild($spContainer); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
// identifier clusters, used for workbook Escher object |
361
|
|
|
$this->_IDCLs[$dgId] = $lastReducedSpId; |
|
|
|
|
362
|
|
|
|
363
|
|
|
// set last shape index |
364
|
|
|
$dgContainer->setLastSpId($lastSpId); |
|
|
|
|
365
|
|
|
|
366
|
|
|
// set the Escher object |
367
|
|
|
$this->_writerWorksheets[$sheetIndex]->setEscher($escher); |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Build the Escher object corresponding to the MSODRAWINGGROUP record |
373
|
|
|
*/ |
374
|
|
|
private function _buildWorkbookEscher() |
375
|
|
|
{ |
376
|
|
|
$escher = null; |
377
|
|
|
|
378
|
|
|
// any drawings in this workbook? |
379
|
|
|
$found = false; |
380
|
|
|
foreach ($this->_phpExcel->getAllSheets() as $sheet) { |
381
|
|
|
if (count($sheet->getDrawingCollection()) > 0) { |
382
|
|
|
$found = true; |
383
|
|
|
break; |
384
|
|
|
} |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
// nothing to do if there are no drawings |
388
|
|
|
if (!$found) { |
389
|
|
|
return; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
// if we reach here, then there are drawings in the workbook |
393
|
|
|
$escher = new PHPExcel_Shared_Escher(); |
394
|
|
|
|
395
|
|
|
// dggContainer |
396
|
|
|
$dggContainer = new PHPExcel_Shared_Escher_DggContainer(); |
397
|
|
|
$escher->setDggContainer($dggContainer); |
398
|
|
|
|
399
|
|
|
// set IDCLs (identifier clusters) |
400
|
|
|
$dggContainer->setIDCLs($this->_IDCLs); |
401
|
|
|
|
402
|
|
|
// this loop is for determining maximum shape identifier of all drawing |
403
|
|
|
$spIdMax = 0; |
404
|
|
|
$totalCountShapes = 0; |
405
|
|
|
$countDrawings = 0; |
406
|
|
|
|
407
|
|
|
foreach ($this->_phpExcel->getAllsheets() as $sheet) { |
408
|
|
|
$sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet |
409
|
|
|
|
410
|
|
|
if (count($sheet->getDrawingCollection()) > 0) { |
411
|
|
|
++$countDrawings; |
412
|
|
|
|
413
|
|
|
foreach ($sheet->getDrawingCollection() as $drawing) { |
414
|
|
|
++$sheetCountShapes; |
415
|
|
|
++$totalCountShapes; |
416
|
|
|
|
417
|
|
|
$spId = $sheetCountShapes |
418
|
|
|
| ($this->_phpExcel->getIndex($sheet) + 1) << 10; |
419
|
|
|
$spIdMax = max($spId, $spIdMax); |
420
|
|
|
} |
421
|
|
|
} |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
$dggContainer->setSpIdMax($spIdMax + 1); |
425
|
|
|
$dggContainer->setCDgSaved($countDrawings); |
426
|
|
|
$dggContainer->setCSpSaved($totalCountShapes + $countDrawings); // total number of shapes incl. one group shapes per drawing |
427
|
|
|
|
428
|
|
|
// bstoreContainer |
429
|
|
|
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer(); |
430
|
|
|
$dggContainer->setBstoreContainer($bstoreContainer); |
431
|
|
|
|
432
|
|
|
// the BSE's (all the images) |
433
|
|
|
foreach ($this->_phpExcel->getAllsheets() as $sheet) { |
434
|
|
|
foreach ($sheet->getDrawingCollection() as $drawing) { |
435
|
|
|
if ($drawing instanceof PHPExcel_Worksheet_Drawing) { |
436
|
|
|
|
437
|
|
|
$filename = $drawing->getPath(); |
438
|
|
|
|
439
|
|
|
list($imagesx, $imagesy, $imageFormat) = getimagesize($filename); |
|
|
|
|
440
|
|
|
|
441
|
|
|
switch ($imageFormat) { |
442
|
|
|
|
443
|
|
|
case 1: // GIF, not supported by BIFF8, we convert to PNG |
444
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; |
445
|
|
|
ob_start(); |
446
|
|
|
imagepng(imagecreatefromgif($filename)); |
447
|
|
|
$blipData = ob_get_contents(); |
448
|
|
|
ob_end_clean(); |
449
|
|
|
break; |
450
|
|
|
|
451
|
|
|
case 2: // JPEG |
452
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; |
453
|
|
|
$blipData = file_get_contents($filename); |
454
|
|
|
break; |
455
|
|
|
|
456
|
|
|
case 3: // PNG |
457
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; |
458
|
|
|
$blipData = file_get_contents($filename); |
459
|
|
|
break; |
460
|
|
|
|
461
|
|
|
case 6: // Windows DIB (BMP), we convert to PNG |
462
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; |
463
|
|
|
ob_start(); |
464
|
|
|
imagepng(PHPExcel_Shared_Drawing::imagecreatefrombmp($filename)); |
465
|
|
|
$blipData = ob_get_contents(); |
466
|
|
|
ob_end_clean(); |
467
|
|
|
break; |
468
|
|
|
|
469
|
|
|
default: continue 2; |
|
|
|
|
470
|
|
|
|
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); |
474
|
|
|
$blip->setData($blipData); |
475
|
|
|
|
476
|
|
|
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); |
477
|
|
|
$BSE->setBlipType($blipType); |
478
|
|
|
$BSE->setBlip($blip); |
479
|
|
|
|
480
|
|
|
$bstoreContainer->addBSE($BSE); |
481
|
|
|
|
482
|
|
|
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) { |
483
|
|
|
|
484
|
|
|
switch ($drawing->getRenderingFunction()) { |
485
|
|
|
|
486
|
|
|
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG: |
487
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG; |
488
|
|
|
$renderingFunction = 'imagejpeg'; |
489
|
|
|
break; |
490
|
|
|
|
491
|
|
|
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF: |
492
|
|
|
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG: |
493
|
|
|
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT: |
494
|
|
|
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG; |
495
|
|
|
$renderingFunction = 'imagepng'; |
496
|
|
|
break; |
497
|
|
|
|
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
ob_start(); |
501
|
|
|
call_user_func($renderingFunction, $drawing->getImageResource()); |
|
|
|
|
502
|
|
|
$blipData = ob_get_contents(); |
503
|
|
|
ob_end_clean(); |
504
|
|
|
|
505
|
|
|
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip(); |
506
|
|
|
$blip->setData($blipData); |
507
|
|
|
|
508
|
|
|
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE(); |
509
|
|
|
$BSE->setBlipType($blipType); |
|
|
|
|
510
|
|
|
$BSE->setBlip($blip); |
511
|
|
|
|
512
|
|
|
$bstoreContainer->addBSE($BSE); |
513
|
|
|
} |
514
|
|
|
} |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
// Set the Escher object |
518
|
|
|
$this->_writerWorkbook->setEscher($escher); |
519
|
|
|
} |
520
|
|
|
|
521
|
|
|
/** |
522
|
|
|
* Build the OLE Part for DocumentSummary Information |
523
|
|
|
* @return string |
524
|
|
|
*/ |
525
|
|
|
private function _writeDocumentSummaryInformation(){ |
526
|
|
|
|
527
|
|
|
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) |
528
|
|
|
$data = pack('v', 0xFFFE); |
529
|
|
|
// offset: 2; size: 2; |
530
|
|
|
$data .= pack('v', 0x0000); |
531
|
|
|
// offset: 4; size: 2; OS version |
532
|
|
|
$data .= pack('v', 0x0106); |
533
|
|
|
// offset: 6; size: 2; OS indicator |
534
|
|
|
$data .= pack('v', 0x0002); |
535
|
|
|
// offset: 8; size: 16 |
536
|
|
|
$data .= pack('VVVV', 0x00, 0x00, 0x00, 0x00); |
537
|
|
|
// offset: 24; size: 4; section count |
538
|
|
|
$data .= pack('V', 0x0001); |
539
|
|
|
|
540
|
|
|
// offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae |
541
|
|
|
$data .= pack('vvvvvvvv', 0xD502, 0xD5CD, 0x2E9C, 0x101B, 0x9793, 0x0008, 0x2C2B, 0xAEF9); |
542
|
|
|
// offset: 44; size: 4; offset of the start |
543
|
|
|
$data .= pack('V', 0x30); |
544
|
|
|
|
545
|
|
|
// SECTION |
546
|
|
|
$dataSection = array(); |
547
|
|
|
$dataSection_NumProps = 0; |
548
|
|
|
$dataSection_Summary = ''; |
549
|
|
|
$dataSection_Content = ''; |
550
|
|
|
|
551
|
|
|
// GKPIDDSI_CODEPAGE: CodePage |
552
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x01), |
553
|
|
|
'offset' => array('pack' => 'V'), |
554
|
|
|
'type' => array('pack' => 'V', 'data' => 0x02), // 2 byte signed integer |
555
|
|
|
'data' => array('data' => 1252)); |
556
|
|
|
$dataSection_NumProps++; |
557
|
|
|
|
558
|
|
|
// GKPIDDSI_CATEGORY : Category |
559
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getCategory()){ |
560
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getCategory(); |
561
|
|
|
$dataProp = 'Test result file'; |
562
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), |
563
|
|
|
'offset' => array('pack' => 'V'), |
564
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), |
565
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
566
|
|
|
$dataSection_NumProps++; |
567
|
|
|
} |
568
|
|
|
// GKPIDDSI_VERSION :Version of the application that wrote the property storage |
569
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x17), |
570
|
|
|
'offset' => array('pack' => 'V'), |
571
|
|
|
'type' => array('pack' => 'V', 'data' => 0x03), |
572
|
|
|
'data' => array('pack' => 'V', 'data' => 0x000C0000)); |
573
|
|
|
$dataSection_NumProps++; |
574
|
|
|
// GKPIDDSI_SCALE : FALSE |
575
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0B), |
576
|
|
|
'offset' => array('pack' => 'V'), |
577
|
|
|
'type' => array('pack' => 'V', 'data' => 0x0B), |
578
|
|
|
'data' => array('data' => false)); |
579
|
|
|
$dataSection_NumProps++; |
580
|
|
|
// GKPIDDSI_LINKSDIRTY : True if any of the values for the linked properties have changed outside of the application |
581
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x10), |
582
|
|
|
'offset' => array('pack' => 'V'), |
583
|
|
|
'type' => array('pack' => 'V', 'data' => 0x0B), |
584
|
|
|
'data' => array('data' => false)); |
585
|
|
|
$dataSection_NumProps++; |
586
|
|
|
// GKPIDDSI_SHAREDOC : FALSE |
587
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x13), |
588
|
|
|
'offset' => array('pack' => 'V'), |
589
|
|
|
'type' => array('pack' => 'V', 'data' => 0x0B), |
590
|
|
|
'data' => array('data' => false)); |
591
|
|
|
$dataSection_NumProps++; |
592
|
|
|
// GKPIDDSI_HYPERLINKSCHANGED : True if any of the values for the _PID_LINKS (hyperlink text) have changed outside of the application |
593
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x16), |
594
|
|
|
'offset' => array('pack' => 'V'), |
595
|
|
|
'type' => array('pack' => 'V', 'data' => 0x0B), |
596
|
|
|
'data' => array('data' => false)); |
597
|
|
|
$dataSection_NumProps++; |
598
|
|
|
|
599
|
|
|
// GKPIDDSI_DOCSPARTS |
600
|
|
|
// MS-OSHARED p75 (2.3.3.2.2.1) |
601
|
|
|
// Structure is VtVecUnalignedLpstrValue (2.3.3.1.9) |
602
|
|
|
// cElements |
603
|
|
|
$dataProp = pack('v', 0x0001); |
604
|
|
|
$dataProp .= pack('v', 0x0000); |
605
|
|
|
// array of UnalignedLpstr |
606
|
|
|
// cch |
607
|
|
|
$dataProp .= pack('v', 0x000A); |
608
|
|
|
$dataProp .= pack('v', 0x0000); |
609
|
|
|
// value |
610
|
|
|
$dataProp .= 'Worksheet'.chr(0); |
611
|
|
|
|
612
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D), |
613
|
|
|
'offset' => array('pack' => 'V'), |
614
|
|
|
'type' => array('pack' => 'V', 'data' => 0x101E), |
615
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
616
|
|
|
$dataSection_NumProps++; |
617
|
|
|
|
618
|
|
|
// GKPIDDSI_HEADINGPAIR |
619
|
|
|
// VtVecHeadingPairValue |
620
|
|
|
// cElements |
621
|
|
|
$dataProp = pack('v', 0x0002); |
622
|
|
|
$dataProp .= pack('v', 0x0000); |
623
|
|
|
// Array of vtHeadingPair |
624
|
|
|
// vtUnalignedString - headingString |
625
|
|
|
// stringType |
626
|
|
|
$dataProp .= pack('v', 0x001E); |
627
|
|
|
// padding |
628
|
|
|
$dataProp .= pack('v', 0x0000); |
629
|
|
|
// UnalignedLpstr |
630
|
|
|
// cch |
631
|
|
|
$dataProp .= pack('v', 0x0013); |
632
|
|
|
$dataProp .= pack('v', 0x0000); |
633
|
|
|
// value |
634
|
|
|
$dataProp .= 'Feuilles de calcul'; |
635
|
|
|
// vtUnalignedString - headingParts |
636
|
|
|
// wType : 0x0003 = 32 bit signed integer |
637
|
|
|
$dataProp .= pack('v', 0x0300); |
638
|
|
|
// padding |
639
|
|
|
$dataProp .= pack('v', 0x0000); |
640
|
|
|
// value |
641
|
|
|
$dataProp .= pack('v', 0x0100); |
642
|
|
|
$dataProp .= pack('v', 0x0000); |
643
|
|
|
$dataProp .= pack('v', 0x0000); |
644
|
|
|
$dataProp .= pack('v', 0x0000); |
645
|
|
|
|
646
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C), |
647
|
|
|
'offset' => array('pack' => 'V'), |
648
|
|
|
'type' => array('pack' => 'V', 'data' => 0x100C), |
649
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
650
|
|
|
$dataSection_NumProps++; |
651
|
|
|
|
652
|
|
|
// 4 Section Length |
653
|
|
|
// 4 Property count |
654
|
|
|
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4)) |
655
|
|
|
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8; |
656
|
|
|
foreach ($dataSection as $dataProp){ |
657
|
|
|
// Summary |
658
|
|
|
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']); |
659
|
|
|
// Offset |
660
|
|
|
$dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset); |
661
|
|
|
// DataType |
662
|
|
|
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']); |
663
|
|
|
// Data |
664
|
|
|
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer |
665
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['data']); |
666
|
|
|
|
667
|
|
|
$dataSection_Content_Offset += 4 + 4; |
668
|
|
|
} |
669
|
|
|
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer |
670
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['data']); |
671
|
|
|
|
672
|
|
|
$dataSection_Content_Offset += 4 + 4; |
673
|
|
|
} |
674
|
|
|
elseif($dataProp['type']['data'] == 0x0B){ // Boolean |
675
|
|
|
if($dataProp['data']['data'] == false){ |
676
|
|
|
$dataSection_Content .= pack('V', 0x0000); |
677
|
|
|
} else { |
678
|
|
|
$dataSection_Content .= pack('V', 0x0001); |
679
|
|
|
} |
680
|
|
|
$dataSection_Content_Offset += 4 + 4; |
681
|
|
|
} |
682
|
|
View Code Duplication |
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length |
683
|
|
|
// Null-terminated string |
684
|
|
|
$dataProp['data']['data'] .= chr(0); |
685
|
|
|
$dataProp['data']['length'] += 1; |
686
|
|
|
// Complete the string with null string for being a %4 |
687
|
|
|
$dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4)==4 ? 0 : (4 - $dataProp['data']['length'] % 4)); |
688
|
|
|
$dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT); |
689
|
|
|
|
690
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['length']); |
691
|
|
|
$dataSection_Content .= $dataProp['data']['data']; |
692
|
|
|
|
693
|
|
|
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); |
694
|
|
|
} |
695
|
|
View Code Duplication |
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) |
696
|
|
|
$dataSection_Content .= $dataProp['data']['data']; |
697
|
|
|
|
698
|
|
|
$dataSection_Content_Offset += 4 + 8; |
699
|
|
|
} |
700
|
|
View Code Duplication |
else { |
701
|
|
|
// Data Type Not Used at the moment |
702
|
|
|
$dataSection_Content .= $dataProp['data']['data']; |
703
|
|
|
|
704
|
|
|
$dataSection_Content_Offset += 4 + $dataProp['data']['length']; |
705
|
|
|
} |
706
|
|
|
} |
707
|
|
|
// Now $dataSection_Content_Offset contains the size of the content |
708
|
|
|
|
709
|
|
|
// section header |
710
|
|
|
// offset: $secOffset; size: 4; section length |
711
|
|
|
// + x Size of the content (summary + content) |
712
|
|
|
$data .= pack('V', $dataSection_Content_Offset); |
713
|
|
|
// offset: $secOffset+4; size: 4; property count |
714
|
|
|
$data .= pack('V', $dataSection_NumProps); |
715
|
|
|
// Section Summary |
716
|
|
|
$data .= $dataSection_Summary; |
717
|
|
|
// Section Content |
718
|
|
|
$data .= $dataSection_Content; |
719
|
|
|
|
720
|
|
|
return $data; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
/** |
724
|
|
|
* Build the OLE Part for Summary Information |
725
|
|
|
* @return string |
726
|
|
|
*/ |
727
|
|
|
private function _writeSummaryInformation(){ |
728
|
|
|
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) |
729
|
|
|
$data = pack('v', 0xFFFE); |
730
|
|
|
// offset: 2; size: 2; |
731
|
|
|
$data .= pack('v', 0x0000); |
732
|
|
|
// offset: 4; size: 2; OS version |
733
|
|
|
$data .= pack('v', 0x0106); |
734
|
|
|
// offset: 6; size: 2; OS indicator |
735
|
|
|
$data .= pack('v', 0x0002); |
736
|
|
|
// offset: 8; size: 16 |
737
|
|
|
$data .= pack('VVVV', 0x00, 0x00, 0x00, 0x00); |
738
|
|
|
// offset: 24; size: 4; section count |
739
|
|
|
$data .= pack('V', 0x0001); |
740
|
|
|
|
741
|
|
|
// offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9 |
742
|
|
|
$data .= pack('vvvvvvvv', 0x85E0, 0xF29F, 0x4FF9, 0x1068, 0x91AB, 0x0008, 0x272B, 0xD9B3); |
743
|
|
|
// offset: 44; size: 4; offset of the start |
744
|
|
|
$data .= pack('V', 0x30); |
745
|
|
|
|
746
|
|
|
// SECTION |
747
|
|
|
$dataSection = array(); |
748
|
|
|
$dataSection_NumProps = 0; |
749
|
|
|
$dataSection_Summary = ''; |
750
|
|
|
$dataSection_Content = ''; |
751
|
|
|
|
752
|
|
|
// CodePage : CP-1252 |
753
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x01), |
754
|
|
|
'offset' => array('pack' => 'V'), |
755
|
|
|
'type' => array('pack' => 'V', 'data' => 0x02), // 2 byte signed integer |
756
|
|
|
'data' => array('data' => 1252)); |
757
|
|
|
$dataSection_NumProps++; |
758
|
|
|
|
759
|
|
|
// Title |
760
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getTitle()){ |
761
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getTitle(); |
762
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02), |
763
|
|
|
'offset' => array('pack' => 'V'), |
764
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
765
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
766
|
|
|
$dataSection_NumProps++; |
767
|
|
|
} |
768
|
|
|
// Subject |
769
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getSubject()){ |
770
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getSubject(); |
771
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x03), |
772
|
|
|
'offset' => array('pack' => 'V'), |
773
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
774
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
775
|
|
|
$dataSection_NumProps++; |
776
|
|
|
} |
777
|
|
|
// Author (Creator) |
778
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getCreator()){ |
779
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getCreator(); |
780
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x04), |
781
|
|
|
'offset' => array('pack' => 'V'), |
782
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
783
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
784
|
|
|
$dataSection_NumProps++; |
785
|
|
|
} |
786
|
|
|
// Keywords |
787
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getKeywords()){ |
788
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getKeywords(); |
789
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x05), |
790
|
|
|
'offset' => array('pack' => 'V'), |
791
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
792
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
793
|
|
|
$dataSection_NumProps++; |
794
|
|
|
} |
795
|
|
|
// Comments (Description) |
796
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getDescription()){ |
797
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getDescription(); |
798
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x06), |
799
|
|
|
'offset' => array('pack' => 'V'), |
800
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
801
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
802
|
|
|
$dataSection_NumProps++; |
803
|
|
|
} |
804
|
|
|
// Last Saved By (LastModifiedBy) |
805
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getLastModifiedBy()){ |
806
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy(); |
807
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x08), |
808
|
|
|
'offset' => array('pack' => 'V'), |
809
|
|
|
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length |
810
|
|
|
'data' => array('data' => $dataProp, 'length' => strlen($dataProp))); |
811
|
|
|
$dataSection_NumProps++; |
812
|
|
|
} |
813
|
|
|
// Created Date/Time |
814
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getCreated()){ |
815
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getCreated(); |
816
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C), |
817
|
|
|
'offset' => array('pack' => 'V'), |
818
|
|
|
'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) |
819
|
|
|
'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp))); |
820
|
|
|
$dataSection_NumProps++; |
821
|
|
|
} |
822
|
|
|
// Modified Date/Time |
823
|
|
View Code Duplication |
if($this->_phpExcel->getProperties()->getModified()){ |
824
|
|
|
$dataProp = $this->_phpExcel->getProperties()->getModified(); |
825
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D), |
826
|
|
|
'offset' => array('pack' => 'V'), |
827
|
|
|
'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) |
828
|
|
|
'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp))); |
829
|
|
|
$dataSection_NumProps++; |
830
|
|
|
} |
831
|
|
|
// Security |
832
|
|
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x13), |
833
|
|
|
'offset' => array('pack' => 'V'), |
834
|
|
|
'type' => array('pack' => 'V', 'data' => 0x03), // 4 byte signed integer |
835
|
|
|
'data' => array('data' => 0x00)); |
836
|
|
|
$dataSection_NumProps++; |
837
|
|
|
|
838
|
|
|
|
839
|
|
|
// 4 Section Length |
840
|
|
|
// 4 Property count |
841
|
|
|
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4)) |
842
|
|
|
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8; |
843
|
|
|
foreach ($dataSection as $dataProp){ |
844
|
|
|
// Summary |
845
|
|
|
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']); |
846
|
|
|
// Offset |
847
|
|
|
$dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset); |
848
|
|
|
// DataType |
849
|
|
|
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']); |
850
|
|
|
// Data |
851
|
|
|
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer |
852
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['data']); |
853
|
|
|
|
854
|
|
|
$dataSection_Content_Offset += 4 + 4; |
855
|
|
|
} |
856
|
|
|
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer |
857
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['data']); |
858
|
|
|
|
859
|
|
|
$dataSection_Content_Offset += 4 + 4; |
860
|
|
|
} |
861
|
|
View Code Duplication |
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length |
862
|
|
|
// Null-terminated string |
863
|
|
|
$dataProp['data']['data'] .= chr(0); |
864
|
|
|
$dataProp['data']['length'] += 1; |
865
|
|
|
// Complete the string with null string for being a %4 |
866
|
|
|
$dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4)==4 ? 0 : (4 - $dataProp['data']['length'] % 4)); |
867
|
|
|
$dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT); |
868
|
|
|
|
869
|
|
|
$dataSection_Content .= pack('V', $dataProp['data']['length']); |
870
|
|
|
$dataSection_Content .= $dataProp['data']['data']; |
871
|
|
|
|
872
|
|
|
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); |
873
|
|
|
} |
874
|
|
View Code Duplication |
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) |
875
|
|
|
$dataSection_Content .= $dataProp['data']['data']; |
876
|
|
|
|
877
|
|
|
$dataSection_Content_Offset += 4 + 8; |
878
|
|
|
} |
879
|
|
|
else { |
|
|
|
|
880
|
|
|
// Data Type Not Used at the moment |
881
|
|
|
} |
882
|
|
|
} |
883
|
|
|
// Now $dataSection_Content_Offset contains the size of the content |
884
|
|
|
|
885
|
|
|
// section header |
886
|
|
|
// offset: $secOffset; size: 4; section length |
887
|
|
|
// + x Size of the content (summary + content) |
888
|
|
|
$data .= pack('V', $dataSection_Content_Offset); |
889
|
|
|
// offset: $secOffset+4; size: 4; property count |
890
|
|
|
$data .= pack('V', $dataSection_NumProps); |
891
|
|
|
// Section Summary |
892
|
|
|
$data .= $dataSection_Summary; |
893
|
|
|
// Section Content |
894
|
|
|
$data .= $dataSection_Content; |
895
|
|
|
|
896
|
|
|
return $data; |
897
|
|
|
} |
898
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..