MsDoc.php 102 KB

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