Няма описание

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