7ae940e7a9f8455551fdce3f925b12c2f745ec6a.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 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_Reader_Excel5
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPExcel_Reader_Excel5_Escher
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Reader_Excel5
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Reader_Excel5_Escher
  35. {
  36. const DGGCONTAINER = 0xF000;
  37. const BSTORECONTAINER = 0xF001;
  38. const DGCONTAINER = 0xF002;
  39. const SPGRCONTAINER = 0xF003;
  40. const SPCONTAINER = 0xF004;
  41. const DGG = 0xF006;
  42. const BSE = 0xF007;
  43. const DG = 0xF008;
  44. const SPGR = 0xF009;
  45. const SP = 0xF00A;
  46. const OPT = 0xF00B;
  47. const CLIENTTEXTBOX = 0xF00D;
  48. const CLIENTANCHOR = 0xF010;
  49. const CLIENTDATA = 0xF011;
  50. const BLIPJPEG = 0xF01D;
  51. const BLIPPNG = 0xF01E;
  52. const SPLITMENUCOLORS = 0xF11E;
  53. const TERTIARYOPT = 0xF122;
  54. /**
  55. * Escher stream data (binary)
  56. *
  57. * @var string
  58. */
  59. private $_data;
  60. /**
  61. * Size in bytes of the Escher stream data
  62. *
  63. * @var int
  64. */
  65. private $_dataSize;
  66. /**
  67. * Current position of stream pointer in Escher stream data
  68. *
  69. * @var int
  70. */
  71. private $_pos;
  72. /**
  73. * The object to be returned by the reader. Modified during load.
  74. *
  75. * @var mixed
  76. */
  77. private $_object;
  78. /**
  79. * Create a new PHPExcel_Reader_Excel5_Escher instance
  80. *
  81. * @param mixed $object
  82. */
  83. public function __construct($object)
  84. {
  85. $this->_object = $object;
  86. }
  87. /**
  88. * Load Escher stream data. May be a partial Escher stream.
  89. *
  90. * @param string $data
  91. */
  92. public function load($data)
  93. {
  94. $this->_data = $data;
  95. // total byte size of Excel data (workbook global substream + sheet substreams)
  96. $this->_dataSize = strlen($this->_data);
  97. $this->_pos = 0;
  98. // Parse Escher stream
  99. while ($this->_pos < $this->_dataSize) {
  100. // offset: 2; size: 2: Record Type
  101. $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
  102. switch ($fbt) {
  103. case self::DGGCONTAINER: $this->_readDggContainer(); break;
  104. case self::DGG: $this->_readDgg(); break;
  105. case self::BSTORECONTAINER: $this->_readBstoreContainer(); break;
  106. case self::BSE: $this->_readBSE(); break;
  107. case self::BLIPJPEG: $this->_readBlipJPEG(); break;
  108. case self::BLIPPNG: $this->_readBlipPNG(); break;
  109. case self::OPT: $this->_readOPT(); break;
  110. case self::TERTIARYOPT: $this->_readTertiaryOPT(); break;
  111. case self::SPLITMENUCOLORS: $this->_readSplitMenuColors(); break;
  112. case self::DGCONTAINER: $this->_readDgContainer(); break;
  113. case self::DG: $this->_readDg(); break;
  114. case self::SPGRCONTAINER: $this->_readSpgrContainer(); break;
  115. case self::SPCONTAINER: $this->_readSpContainer(); break;
  116. case self::SPGR: $this->_readSpgr(); break;
  117. case self::SP: $this->_readSp(); break;
  118. case self::CLIENTTEXTBOX: $this->_readClientTextbox(); break;
  119. case self::CLIENTANCHOR: $this->_readClientAnchor(); break;
  120. case self::CLIENTDATA: $this->_readClientData(); break;
  121. default: $this->_readDefault(); break;
  122. }
  123. }
  124. return $this->_object;
  125. }
  126. /**
  127. * Read a generic record
  128. */
  129. private function _readDefault()
  130. {
  131. // offset 0; size: 2; recVer and recInstance
  132. $verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos);
  133. // offset: 2; size: 2: Record Type
  134. $fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos + 2);
  135. // bit: 0-3; mask: 0x000F; recVer
  136. $recVer = (0x000F & $verInstance) >> 0;
  137. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  138. $recordData = substr($this->_data, $this->_pos + 8, $length);
  139. // move stream pointer to next record
  140. $this->_pos += 8 + $length;
  141. }
  142. /**
  143. * Read DggContainer record (Drawing Group Container)
  144. */
  145. private function _readDggContainer()
  146. {
  147. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  148. $recordData = substr($this->_data, $this->_pos + 8, $length);
  149. // move stream pointer to next record
  150. $this->_pos += 8 + $length;
  151. // record is a container, read contents
  152. $dggContainer = new PHPExcel_Shared_Escher_DggContainer();
  153. $this->_object->setDggContainer($dggContainer);
  154. $reader = new PHPExcel_Reader_Excel5_Escher($dggContainer);
  155. $reader->load($recordData);
  156. }
  157. /**
  158. * Read Dgg record (Drawing Group)
  159. */
  160. private function _readDgg()
  161. {
  162. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  163. $recordData = substr($this->_data, $this->_pos + 8, $length);
  164. // move stream pointer to next record
  165. $this->_pos += 8 + $length;
  166. }
  167. /**
  168. * Read BstoreContainer record (Blip Store Container)
  169. */
  170. private function _readBstoreContainer()
  171. {
  172. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  173. $recordData = substr($this->_data, $this->_pos + 8, $length);
  174. // move stream pointer to next record
  175. $this->_pos += 8 + $length;
  176. // record is a container, read contents
  177. $bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
  178. $this->_object->setBstoreContainer($bstoreContainer);
  179. $reader = new PHPExcel_Reader_Excel5_Escher($bstoreContainer);
  180. $reader->load($recordData);
  181. }
  182. /**
  183. * Read BSE record
  184. */
  185. private function _readBSE()
  186. {
  187. // offset: 0; size: 2; recVer and recInstance
  188. // bit: 4-15; mask: 0xFFF0; recInstance
  189. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  190. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  191. $recordData = substr($this->_data, $this->_pos + 8, $length);
  192. // move stream pointer to next record
  193. $this->_pos += 8 + $length;
  194. // add BSE to BstoreContainer
  195. $BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
  196. $this->_object->addBSE($BSE);
  197. $BSE->setBLIPType($recInstance);
  198. // offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
  199. $btWin32 = ord($recordData[0]);
  200. // offset: 1; size: 1; btWin32 (MSOBLIPTYPE)
  201. $btMacOS = ord($recordData[1]);
  202. // offset: 2; size: 16; MD4 digest
  203. $rgbUid = substr($recordData, 2, 16);
  204. // offset: 18; size: 2; tag
  205. $tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18);
  206. // offset: 20; size: 4; size of BLIP in bytes
  207. $size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20);
  208. // offset: 24; size: 4; number of references to this BLIP
  209. $cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24);
  210. // offset: 28; size: 4; MSOFO file offset
  211. $foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28);
  212. // offset: 32; size: 1; unused1
  213. $unused1 = ord($recordData{32});
  214. // offset: 33; size: 1; size of nameData in bytes (including null terminator)
  215. $cbName = ord($recordData{33});
  216. // offset: 34; size: 1; unused2
  217. $unused2 = ord($recordData{34});
  218. // offset: 35; size: 1; unused3
  219. $unused3 = ord($recordData{35});
  220. // offset: 36; size: $cbName; nameData
  221. $nameData = substr($recordData, 36, $cbName);
  222. // offset: 36 + $cbName, size: var; the BLIP data
  223. $blipData = substr($recordData, 36 + $cbName);
  224. // record is a container, read contents
  225. $reader = new PHPExcel_Reader_Excel5_Escher($BSE);
  226. $reader->load($blipData);
  227. }
  228. /**
  229. * Read BlipJPEG record. Holds raw JPEG image data
  230. */
  231. private function _readBlipJPEG()
  232. {
  233. // offset: 0; size: 2; recVer and recInstance
  234. // bit: 4-15; mask: 0xFFF0; recInstance
  235. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  236. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  237. $recordData = substr($this->_data, $this->_pos + 8, $length);
  238. // move stream pointer to next record
  239. $this->_pos += 8 + $length;
  240. $pos = 0;
  241. // offset: 0; size: 16; rgbUid1 (MD4 digest of)
  242. $rgbUid1 = substr($recordData, 0, 16);
  243. $pos += 16;
  244. // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
  245. if (in_array($recInstance, array(0x046B, 0x06E3))) {
  246. $rgbUid2 = substr($recordData, 16, 16);
  247. $pos += 16;
  248. }
  249. // offset: var; size: 1; tag
  250. $tag = ord($recordData{$pos});
  251. $pos += 1;
  252. // offset: var; size: var; the raw image data
  253. $data = substr($recordData, $pos);
  254. $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
  255. $blip->setData($data);
  256. $this->_object->setBlip($blip);
  257. }
  258. /**
  259. * Read BlipPNG record. Holds raw PNG image data
  260. */
  261. private function _readBlipPNG()
  262. {
  263. // offset: 0; size: 2; recVer and recInstance
  264. // bit: 4-15; mask: 0xFFF0; recInstance
  265. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  266. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  267. $recordData = substr($this->_data, $this->_pos + 8, $length);
  268. // move stream pointer to next record
  269. $this->_pos += 8 + $length;
  270. $pos = 0;
  271. // offset: 0; size: 16; rgbUid1 (MD4 digest of)
  272. $rgbUid1 = substr($recordData, 0, 16);
  273. $pos += 16;
  274. // offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
  275. if ($recInstance == 0x06E1) {
  276. $rgbUid2 = substr($recordData, 16, 16);
  277. $pos += 16;
  278. }
  279. // offset: var; size: 1; tag
  280. $tag = ord($recordData{$pos});
  281. $pos += 1;
  282. // offset: var; size: var; the raw image data
  283. $data = substr($recordData, $pos);
  284. $blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
  285. $blip->setData($data);
  286. $this->_object->setBlip($blip);
  287. }
  288. /**
  289. * Read OPT record. This record may occur within DggContainer record or SpContainer
  290. */
  291. private function _readOPT()
  292. {
  293. // offset: 0; size: 2; recVer and recInstance
  294. // bit: 4-15; mask: 0xFFF0; recInstance
  295. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  296. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  297. $recordData = substr($this->_data, $this->_pos + 8, $length);
  298. // move stream pointer to next record
  299. $this->_pos += 8 + $length;
  300. $this->_readOfficeArtRGFOPTE($recordData, $recInstance);
  301. }
  302. /**
  303. * Read TertiaryOPT record
  304. */
  305. private function _readTertiaryOPT()
  306. {
  307. // offset: 0; size: 2; recVer and recInstance
  308. // bit: 4-15; mask: 0xFFF0; recInstance
  309. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  310. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  311. $recordData = substr($this->_data, $this->_pos + 8, $length);
  312. // move stream pointer to next record
  313. $this->_pos += 8 + $length;
  314. }
  315. /**
  316. * Read SplitMenuColors record
  317. */
  318. private function _readSplitMenuColors()
  319. {
  320. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  321. $recordData = substr($this->_data, $this->_pos + 8, $length);
  322. // move stream pointer to next record
  323. $this->_pos += 8 + $length;
  324. }
  325. /**
  326. * Read DgContainer record (Drawing Container)
  327. */
  328. private function _readDgContainer()
  329. {
  330. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  331. $recordData = substr($this->_data, $this->_pos + 8, $length);
  332. // move stream pointer to next record
  333. $this->_pos += 8 + $length;
  334. // record is a container, read contents
  335. $dgContainer = new PHPExcel_Shared_Escher_DgContainer();
  336. $this->_object->setDgContainer($dgContainer);
  337. $reader = new PHPExcel_Reader_Excel5_Escher($dgContainer);
  338. $escher = $reader->load($recordData);
  339. }
  340. /**
  341. * Read Dg record (Drawing)
  342. */
  343. private function _readDg()
  344. {
  345. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  346. $recordData = substr($this->_data, $this->_pos + 8, $length);
  347. // move stream pointer to next record
  348. $this->_pos += 8 + $length;
  349. }
  350. /**
  351. * Read SpgrContainer record (Shape Group Container)
  352. */
  353. private function _readSpgrContainer()
  354. {
  355. // context is either context DgContainer or SpgrContainer
  356. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  357. $recordData = substr($this->_data, $this->_pos + 8, $length);
  358. // move stream pointer to next record
  359. $this->_pos += 8 + $length;
  360. // record is a container, read contents
  361. $spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
  362. if ($this->_object instanceof PHPExcel_Shared_Escher_DgContainer) {
  363. // DgContainer
  364. $this->_object->setSpgrContainer($spgrContainer);
  365. } else {
  366. // SpgrContainer
  367. $this->_object->addChild($spgrContainer);
  368. }
  369. $reader = new PHPExcel_Reader_Excel5_Escher($spgrContainer);
  370. $escher = $reader->load($recordData);
  371. }
  372. /**
  373. * Read SpContainer record (Shape Container)
  374. */
  375. private function _readSpContainer()
  376. {
  377. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  378. $recordData = substr($this->_data, $this->_pos + 8, $length);
  379. // add spContainer to spgrContainer
  380. $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
  381. $this->_object->addChild($spContainer);
  382. // move stream pointer to next record
  383. $this->_pos += 8 + $length;
  384. // record is a container, read contents
  385. $reader = new PHPExcel_Reader_Excel5_Escher($spContainer);
  386. $escher = $reader->load($recordData);
  387. }
  388. /**
  389. * Read Spgr record (Shape Group)
  390. */
  391. private function _readSpgr()
  392. {
  393. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  394. $recordData = substr($this->_data, $this->_pos + 8, $length);
  395. // move stream pointer to next record
  396. $this->_pos += 8 + $length;
  397. }
  398. /**
  399. * Read Sp record (Shape)
  400. */
  401. private function _readSp()
  402. {
  403. // offset: 0; size: 2; recVer and recInstance
  404. // bit: 4-15; mask: 0xFFF0; recInstance
  405. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  406. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  407. $recordData = substr($this->_data, $this->_pos + 8, $length);
  408. // move stream pointer to next record
  409. $this->_pos += 8 + $length;
  410. }
  411. /**
  412. * Read ClientTextbox record
  413. */
  414. private function _readClientTextbox()
  415. {
  416. // offset: 0; size: 2; recVer and recInstance
  417. // bit: 4-15; mask: 0xFFF0; recInstance
  418. $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->_data, $this->_pos)) >> 4;
  419. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  420. $recordData = substr($this->_data, $this->_pos + 8, $length);
  421. // move stream pointer to next record
  422. $this->_pos += 8 + $length;
  423. }
  424. /**
  425. * Read ClientAnchor record. This record holds information about where the shape is anchored in worksheet
  426. */
  427. private function _readClientAnchor()
  428. {
  429. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  430. $recordData = substr($this->_data, $this->_pos + 8, $length);
  431. // move stream pointer to next record
  432. $this->_pos += 8 + $length;
  433. // offset: 2; size: 2; upper-left corner column index (0-based)
  434. $c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2);
  435. // offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
  436. $startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4);
  437. // offset: 6; size: 2; upper-left corner row index (0-based)
  438. $r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6);
  439. // offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
  440. $startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8);
  441. // offset: 10; size: 2; bottom-right corner column index (0-based)
  442. $c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10);
  443. // offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
  444. $endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12);
  445. // offset: 14; size: 2; bottom-right corner row index (0-based)
  446. $r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14);
  447. // offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
  448. $endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16);
  449. // set the start coordinates
  450. $this->_object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
  451. // set the start offsetX
  452. $this->_object->setStartOffsetX($startOffsetX);
  453. // set the start offsetY
  454. $this->_object->setStartOffsetY($startOffsetY);
  455. // set the end coordinates
  456. $this->_object->setEndCoordinates(PHPExcel_Cell::stringFromColumnIndex($c2) . ($r2 + 1));
  457. // set the end offsetX
  458. $this->_object->setEndOffsetX($endOffsetX);
  459. // set the end offsetY
  460. $this->_object->setEndOffsetY($endOffsetY);
  461. }
  462. /**
  463. * Read ClientData record
  464. */
  465. private function _readClientData()
  466. {
  467. $length = PHPExcel_Reader_Excel5::_GetInt4d($this->_data, $this->_pos + 4);
  468. $recordData = substr($this->_data, $this->_pos + 8, $length);
  469. // move stream pointer to next record
  470. $this->_pos += 8 + $length;
  471. }
  472. /**
  473. * Read OfficeArtRGFOPTE table of property-value pairs
  474. *
  475. * @param string $data Binary data
  476. * @param int $n Number of properties
  477. */
  478. private function _readOfficeArtRGFOPTE($data, $n) {
  479. $splicedComplexData = substr($data, 6 * $n);
  480. // loop through property-value pairs
  481. for ($i = 0; $i < $n; ++$i) {
  482. // read 6 bytes at a time
  483. $fopte = substr($data, 6 * $i, 6);
  484. // offset: 0; size: 2; opid
  485. $opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0);
  486. // bit: 0-13; mask: 0x3FFF; opid.opid
  487. $opidOpid = (0x3FFF & $opid) >> 0;
  488. // bit: 14; mask 0x4000; 1 = value in op field is BLIP identifier
  489. $opidFBid = (0x4000 & $opid) >> 14;
  490. // bit: 15; mask 0x8000; 1 = this is a complex property, op field specifies size of complex data
  491. $opidFComplex = (0x8000 & $opid) >> 15;
  492. // offset: 2; size: 4; the value for this property
  493. $op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2);
  494. if ($opidFComplex) {
  495. $complexData = substr($splicedComplexData, 0, $op);
  496. $splicedComplexData = substr($splicedComplexData, $op);
  497. // we store string value with complex data
  498. $value = $complexData;
  499. } else {
  500. // we store integer value
  501. $value = $op;
  502. }
  503. $this->_object->setOPT($opidOpid, $value);
  504. }
  505. }
  506. }