prop2.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  1. /*
  2. * prop2.c
  3. * Copyright (C) 2002-2005 A.J. van Os; Released under GPL
  4. *
  5. * Description:
  6. * Read the property information from a WinWord 1 or 2 file
  7. */
  8. #include <string.h>
  9. #include "antiword.h"
  10. #define MAX_FILESIZE 0x2000000UL /* 32 Mb */
  11. /*
  12. * iGet2InfoLength - the length of the information for WinWord 1/2 files
  13. */
  14. static int
  15. iGet2InfoLength(int iByteNbr, const UCHAR *aucGrpprl)
  16. {
  17. int iTmp, iDel, iAdd;
  18. switch (ucGetByte(iByteNbr, aucGrpprl)) {
  19. case 3: case 15: case 78: case 152: case 154: case 155:
  20. return 2 + (int)ucGetByte(iByteNbr + 1, aucGrpprl);
  21. case 16: case 17: case 18: case 19: case 21: case 22: case 26:
  22. case 27: case 28: case 30: case 31: case 32: case 33: case 34:
  23. case 35: case 36: case 38: case 39: case 40: case 41: case 42:
  24. case 43: case 45: case 46: case 47: case 48: case 49: case 68:
  25. case 71: case 72: case 82: case 83: case 96: case 97: case 98:
  26. case 99: case 115: case 116: case 119: case 120: case 123: case 124:
  27. case 129: case 130: case 131: case 132: case 135: case 136: case 139:
  28. case 140: case 141: case 142: case 143: case 144: case 145: case 146:
  29. case 147: case 148: case 153: case 159: case 161: case 162:
  30. return 1 + 2;
  31. case 23:
  32. iTmp = (int)ucGetByte(iByteNbr + 1, aucGrpprl);
  33. if (iTmp == 255) {
  34. iDel = (int)ucGetByte(iByteNbr + 2, aucGrpprl);
  35. iAdd = (int)ucGetByte(
  36. iByteNbr + 3 + iDel * 4, aucGrpprl);
  37. iTmp = 2 + iDel * 4 + iAdd * 3;
  38. }
  39. return 2 + iTmp;
  40. case 70:
  41. return 1 + 3;
  42. case 95:
  43. return 1 + 13;
  44. case 157: case 163:
  45. return 1 + 5;
  46. case 158: case 160: case 164:
  47. return 1 + 4;
  48. default:
  49. return 1 + 1;
  50. }
  51. } /* end of iGet2InfoLength */
  52. /*
  53. * Build the lists with Document Property Information for WinWord 1/2 files
  54. */
  55. void
  56. vGet2DopInfo(FILE *pFile, const UCHAR *aucHeader)
  57. {
  58. document_block_type tDocument;
  59. UCHAR *aucBuffer;
  60. ULONG ulBeginDocpInfo, ulTmp;
  61. size_t tDocpInfoLen;
  62. USHORT usTmp;
  63. ulBeginDocpInfo = ulGetLong(0x112, aucHeader); /* fcDop */
  64. DBG_HEX(ulBeginDocpInfo);
  65. tDocpInfoLen = (size_t)usGetWord(0x116, aucHeader); /* cbDop */
  66. DBG_DEC(tDocpInfoLen);
  67. if (tDocpInfoLen < 28) {
  68. DBG_MSG("No Document information");
  69. return;
  70. }
  71. aucBuffer = xmalloc(tDocpInfoLen);
  72. if (!bReadBytes(aucBuffer, tDocpInfoLen, ulBeginDocpInfo, pFile)) {
  73. aucBuffer = xfree(aucBuffer);
  74. return;
  75. }
  76. usTmp = usGetWord(0x00, aucBuffer);
  77. tDocument.ucHdrFtrSpecification = (UCHAR)(usTmp >> 8); /* grpfIhdt */
  78. tDocument.usDefaultTabWidth = usGetWord(0x0a, aucBuffer); /* dxaTab */
  79. ulTmp = ulGetLong(0x14, aucBuffer); /* dttmCreated */
  80. tDocument.tCreateDate = tConvertDTTM(ulTmp);
  81. ulTmp = ulGetLong(0x18, aucBuffer); /* dttmRevised */
  82. tDocument.tRevisedDate = tConvertDTTM(ulTmp);
  83. vCreateDocumentInfoList(&tDocument);
  84. aucBuffer = xfree(aucBuffer);
  85. } /* end of vGet2DopInfo */
  86. /*
  87. * Fill the section information block with information
  88. * from a WinWord 1/2 file.
  89. */
  90. static void
  91. vGet2SectionInfo(const UCHAR *aucGrpprl, size_t tBytes,
  92. section_block_type *pSection)
  93. {
  94. int iFodoOff, iInfoLen;
  95. USHORT usCcol;
  96. UCHAR ucTmp;
  97. fail(aucGrpprl == NULL || pSection == NULL);
  98. iFodoOff = 0;
  99. while (tBytes >= (size_t)iFodoOff + 1) {
  100. switch (ucGetByte(iFodoOff, aucGrpprl)) {
  101. case 117: /* bkc */
  102. ucTmp = ucGetByte(iFodoOff + 1, aucGrpprl);
  103. DBG_DEC(ucTmp);
  104. pSection->bNewPage = ucTmp != 0 && ucTmp != 1;
  105. break;
  106. case 119: /* ccolM1 */
  107. usCcol = 1 + usGetWord(iFodoOff + 1, aucGrpprl);
  108. DBG_DEC(usCcol);
  109. break;
  110. case 128: /* grpfIhdt */
  111. pSection->ucHdrFtrSpecification =
  112. ucGetByte(iFodoOff + 1, aucGrpprl);
  113. break;
  114. default:
  115. break;
  116. }
  117. iInfoLen = iGet2InfoLength(iFodoOff, aucGrpprl);
  118. fail(iInfoLen <= 0);
  119. iFodoOff += iInfoLen;
  120. }
  121. } /* end of vGet2SectionInfo */
  122. /*
  123. * Build the lists with Section Property Information for WinWord 1/2 files
  124. */
  125. void
  126. vGet2SepInfo(FILE *pFile, const UCHAR *aucHeader)
  127. {
  128. section_block_type tSection;
  129. ULONG *aulSectPage, *aulCharPos;
  130. UCHAR *aucBuffer, *aucFpage;
  131. ULONG ulBeginOfText, ulTextOffset, ulBeginSectInfo;
  132. size_t tSectInfoLen, tIndex, tOffset, tLen, tBytes;
  133. UCHAR aucTmp[1];
  134. fail(pFile == NULL || aucHeader == NULL);
  135. ulBeginOfText = ulGetLong(0x18, aucHeader); /* fcMin */
  136. NO_DBG_HEX(ulBeginOfText);
  137. ulBeginSectInfo = ulGetLong(0x7c, aucHeader); /* fcPlcfsed */
  138. DBG_HEX(ulBeginSectInfo);
  139. tSectInfoLen = (size_t)usGetWord(0x80, aucHeader); /* cbPlcfsed */
  140. DBG_DEC(tSectInfoLen);
  141. if (tSectInfoLen < 4) {
  142. DBG_DEC(tSectInfoLen);
  143. return;
  144. }
  145. aucBuffer = xmalloc(tSectInfoLen);
  146. if (!bReadBytes(aucBuffer, tSectInfoLen, ulBeginSectInfo, pFile)) {
  147. aucBuffer = xfree(aucBuffer);
  148. return;
  149. }
  150. NO_DBG_PRINT_BLOCK(aucBuffer, tSectInfoLen);
  151. /* Read the Section Descriptors */
  152. tLen = (tSectInfoLen - 4) / 10;
  153. /* Save the section offsets */
  154. aulCharPos = xcalloc(tLen, sizeof(ULONG));
  155. for (tIndex = 0, tOffset = 0;
  156. tIndex < tLen;
  157. tIndex++, tOffset += 4) {
  158. ulTextOffset = ulGetLong(tOffset, aucBuffer);
  159. NO_DBG_HEX(ulTextOffset);
  160. aulCharPos[tIndex] = ulBeginOfText + ulTextOffset;
  161. NO_DBG_HEX(aulCharPos[tIndex]);
  162. }
  163. /* Save the Sepx offsets */
  164. aulSectPage = xcalloc(tLen, sizeof(ULONG));
  165. for (tIndex = 0, tOffset = (tLen + 1) * 4;
  166. tIndex < tLen;
  167. tIndex++, tOffset += 6) {
  168. aulSectPage[tIndex] = ulGetLong(tOffset + 2, aucBuffer);
  169. NO_DBG_HEX(aulSectPage[tIndex]); /* fcSepx */
  170. }
  171. aucBuffer = xfree(aucBuffer);
  172. /* Read the Section Properties */
  173. for (tIndex = 0; tIndex < tLen; tIndex++) {
  174. if (aulSectPage[tIndex] == FC_INVALID) {
  175. vDefault2SectionInfoList(aulCharPos[tIndex]);
  176. continue;
  177. }
  178. /* Get the number of bytes to read */
  179. if (!bReadBytes(aucTmp, 1, aulSectPage[tIndex], pFile)) {
  180. continue;
  181. }
  182. tBytes = 1 + (size_t)ucGetByte(0, aucTmp);
  183. NO_DBG_DEC(tBytes);
  184. /* Read the bytes */
  185. aucFpage = xmalloc(tBytes);
  186. if (!bReadBytes(aucFpage, tBytes, aulSectPage[tIndex], pFile)) {
  187. aucFpage = xfree(aucFpage);
  188. continue;
  189. }
  190. NO_DBG_PRINT_BLOCK(aucFpage, tBytes);
  191. /* Process the bytes */
  192. vGetDefaultSection(&tSection);
  193. vGet2SectionInfo(aucFpage + 1, tBytes - 1, &tSection);
  194. vAdd2SectionInfoList(&tSection, aulCharPos[tIndex]);
  195. aucFpage = xfree(aucFpage);
  196. }
  197. aulCharPos = xfree(aulCharPos);
  198. aulSectPage = xfree(aulSectPage);
  199. } /* end of vGet2SepInfo */
  200. /*
  201. * Build the list with Header/Footer Information for WinWord 1/2 files
  202. */
  203. void
  204. vGet2HdrFtrInfo(FILE *pFile, const UCHAR *aucHeader)
  205. {
  206. ULONG *aulCharPos;
  207. UCHAR *aucBuffer;
  208. ULONG ulHdrFtrOffset, ulBeginHdrFtrInfo;
  209. size_t tHdrFtrInfoLen, tIndex, tOffset, tLen;
  210. fail(pFile == NULL || aucHeader == NULL);
  211. ulBeginHdrFtrInfo = ulGetLong(0x9a, aucHeader); /* fcPlcfhdd */
  212. NO_DBG_HEX(ulBeginHdrFtrInfo);
  213. tHdrFtrInfoLen = (size_t)usGetWord(0x9e, aucHeader); /* cbPlcfhdd */
  214. NO_DBG_DEC(tHdrFtrInfoLen);
  215. if (tHdrFtrInfoLen < 8) {
  216. DBG_DEC_C(tHdrFtrInfoLen != 0, tHdrFtrInfoLen);
  217. return;
  218. }
  219. aucBuffer = xmalloc(tHdrFtrInfoLen);
  220. if (!bReadBytes(aucBuffer, tHdrFtrInfoLen, ulBeginHdrFtrInfo, pFile)) {
  221. aucBuffer = xfree(aucBuffer);
  222. return;
  223. }
  224. NO_DBG_PRINT_BLOCK(aucBuffer, tHdrFtrInfoLen);
  225. tLen = tHdrFtrInfoLen / 4 - 1;
  226. /* Save the header/footer offsets */
  227. aulCharPos = xcalloc(tLen, sizeof(ULONG));
  228. for (tIndex = 0, tOffset = 0;
  229. tIndex < tLen;
  230. tIndex++, tOffset += 4) {
  231. ulHdrFtrOffset = ulGetLong(tOffset, aucBuffer);
  232. NO_DBG_HEX(ulHdrFtrOffset);
  233. aulCharPos[tIndex] = ulHdrFtrOffset2CharPos(ulHdrFtrOffset);
  234. NO_DBG_HEX(aulCharPos[tIndex]);
  235. }
  236. vCreat2HdrFtrInfoList(aulCharPos, tLen);
  237. aulCharPos = xfree(aulCharPos);
  238. aucBuffer = xfree(aucBuffer);
  239. } /* end of vGet2HdrFtrInfo */
  240. /*
  241. * Translate the rowinfo to a member of the row_info enumeration
  242. */
  243. row_info_enum
  244. eGet2RowInfo(int iFodo,
  245. const UCHAR *aucGrpprl, int iBytes, row_block_type *pRow)
  246. {
  247. int iFodoOff, iInfoLen;
  248. int iIndex, iSize, iCol;
  249. int iPosCurr, iPosPrev;
  250. USHORT usTmp;
  251. BOOL bFound24_0, bFound24_1, bFound25_0, bFound25_1, bFound154;
  252. fail(iFodo < 0 || aucGrpprl == NULL || pRow == NULL);
  253. iFodoOff = 0;
  254. bFound24_0 = FALSE;
  255. bFound24_1 = FALSE;
  256. bFound25_0 = FALSE;
  257. bFound25_1 = FALSE;
  258. bFound154 = FALSE;
  259. while (iBytes >= iFodoOff + 1) {
  260. iInfoLen = 0;
  261. switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
  262. case 24: /* fIntable */
  263. if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
  264. bFound24_1 = TRUE;
  265. } else {
  266. bFound24_0 = TRUE;
  267. }
  268. break;
  269. case 25: /* fTtp */
  270. if (odd(ucGetByte(iFodo + iFodoOff + 1, aucGrpprl))) {
  271. bFound25_1 = TRUE;
  272. } else {
  273. bFound25_0 = TRUE;
  274. }
  275. break;
  276. case 30: /* brcTop10 */
  277. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  278. usTmp &= 0x01ff;
  279. NO_DBG_DEC(usTmp >> 6);
  280. if (usTmp == 0) {
  281. pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
  282. } else {
  283. pRow->ucBorderInfo |= TABLE_BORDER_TOP;
  284. }
  285. break;
  286. case 31: /* brcLeft10 */
  287. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  288. usTmp &= 0x01ff;
  289. NO_DBG_DEC(usTmp >> 6);
  290. if (usTmp == 0) {
  291. pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
  292. } else {
  293. pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
  294. }
  295. break;
  296. case 32: /* brcBottom10 */
  297. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  298. usTmp &= 0x01ff;
  299. NO_DBG_DEC(usTmp >> 6);
  300. if (usTmp == 0) {
  301. pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
  302. } else {
  303. pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
  304. }
  305. break;
  306. case 33: /* brcRight10 */
  307. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  308. usTmp &= 0x01ff;
  309. NO_DBG_DEC(usTmp >> 6);
  310. if (usTmp == 0) {
  311. pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
  312. } else {
  313. pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
  314. }
  315. break;
  316. case 38: /* brcTop */
  317. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  318. usTmp &= 0x0018;
  319. NO_DBG_DEC(usTmp >> 3);
  320. if (usTmp == 0) {
  321. pRow->ucBorderInfo &= ~TABLE_BORDER_TOP;
  322. } else {
  323. pRow->ucBorderInfo |= TABLE_BORDER_TOP;
  324. }
  325. break;
  326. case 39: /* brcLeft */
  327. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  328. usTmp &= 0x0018;
  329. NO_DBG_DEC(usTmp >> 3);
  330. if (usTmp == 0) {
  331. pRow->ucBorderInfo &= ~TABLE_BORDER_LEFT;
  332. } else {
  333. pRow->ucBorderInfo |= TABLE_BORDER_LEFT;
  334. }
  335. break;
  336. case 40: /* brcBottom */
  337. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  338. usTmp &= 0x0018;
  339. NO_DBG_DEC(usTmp >> 3);
  340. if (usTmp == 0) {
  341. pRow->ucBorderInfo &= ~TABLE_BORDER_BOTTOM;
  342. } else {
  343. pRow->ucBorderInfo |= TABLE_BORDER_BOTTOM;
  344. }
  345. break;
  346. case 41: /* brcRight */
  347. usTmp = usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  348. usTmp &= 0x0018;
  349. NO_DBG_DEC(usTmp >> 3);
  350. if (usTmp == 0) {
  351. pRow->ucBorderInfo &= ~TABLE_BORDER_RIGHT;
  352. } else {
  353. pRow->ucBorderInfo |= TABLE_BORDER_RIGHT;
  354. }
  355. break;
  356. case 152: /* cDefTable10 */
  357. case 154: /* cDefTable */
  358. iSize = (int)usGetWord(iFodo + iFodoOff + 1, aucGrpprl);
  359. if (iSize < 6 || iBytes < iFodoOff + 7) {
  360. DBG_DEC(iSize);
  361. DBG_DEC(iBytes);
  362. DBG_DEC(iFodoOff);
  363. iInfoLen = 1;
  364. break;
  365. }
  366. iCol = (int)ucGetByte(iFodo + iFodoOff + 3, aucGrpprl);
  367. if (iCol < 1 ||
  368. iBytes < iFodoOff + 3 + (iCol + 1) * 2) {
  369. DBG_DEC(iCol);
  370. DBG_DEC(iBytes);
  371. DBG_DEC(iFodoOff);
  372. DBG_DEC(ucGetByte(iFodo + iFodoOff, aucGrpprl));
  373. iInfoLen = 1;
  374. break;
  375. }
  376. if (iCol >= (int)elementsof(pRow->asColumnWidth)) {
  377. DBG_DEC(iCol);
  378. werr(1, "The number of columns is corrupt");
  379. }
  380. pRow->ucNumberOfColumns = (UCHAR)iCol;
  381. iPosPrev = (int)(short)usGetWord(
  382. iFodo + iFodoOff + 4,
  383. aucGrpprl);
  384. for (iIndex = 0; iIndex < iCol; iIndex++) {
  385. iPosCurr = (int)(short)usGetWord(
  386. iFodo + iFodoOff + 6 + iIndex * 2,
  387. aucGrpprl);
  388. pRow->asColumnWidth[iIndex] =
  389. (short)(iPosCurr - iPosPrev);
  390. iPosPrev = iPosCurr;
  391. }
  392. bFound154 = TRUE;
  393. break;
  394. default:
  395. break;
  396. }
  397. if (iInfoLen <= 0) {
  398. iInfoLen =
  399. iGet2InfoLength(iFodo + iFodoOff, aucGrpprl);
  400. fail(iInfoLen <= 0);
  401. }
  402. iFodoOff += iInfoLen;
  403. }
  404. if (bFound24_1 && bFound25_1 && bFound154) {
  405. return found_end_of_row;
  406. }
  407. if (bFound24_0 && bFound25_0 && !bFound154) {
  408. return found_not_end_of_row;
  409. }
  410. if (bFound24_1) {
  411. return found_a_cell;
  412. }
  413. if (bFound24_0) {
  414. return found_not_a_cell;
  415. }
  416. return found_nothing;
  417. } /* end of eGet2RowInfo */
  418. /*
  419. * Fill the style information block with information
  420. * from a WinWord 1/2 file.
  421. */
  422. void
  423. vGet2StyleInfo(int iFodo,
  424. const UCHAR *aucGrpprl, int iBytes, style_block_type *pStyle)
  425. {
  426. int iFodoOff, iInfoLen;
  427. int iTmp, iDel, iAdd;
  428. short sTmp;
  429. UCHAR ucTmp;
  430. fail(iFodo < 0 || aucGrpprl == NULL || pStyle == NULL);
  431. NO_DBG_DEC(pStyle->usIstd);
  432. iFodoOff = 0;
  433. while (iBytes >= iFodoOff + 1) {
  434. iInfoLen = 0;
  435. switch (ucGetByte(iFodo + iFodoOff, aucGrpprl)) {
  436. case 2: /* istd */
  437. sTmp = (short)ucGetByte(
  438. iFodo + iFodoOff + 1, aucGrpprl);
  439. NO_DBG_DEC(sTmp);
  440. break;
  441. case 5: /* jc */
  442. pStyle->ucAlignment = ucGetByte(
  443. iFodo + iFodoOff + 1, aucGrpprl);
  444. break;
  445. case 12: /* nfcSeqNumb */
  446. pStyle->ucNFC = ucGetByte(
  447. iFodo + iFodoOff + 1, aucGrpprl);
  448. break;
  449. case 13: /* nLvlAnm */
  450. ucTmp = ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
  451. pStyle->ucNumLevel = ucTmp;
  452. pStyle->bNumPause =
  453. eGetNumType(ucTmp) == level_type_pause;
  454. break;
  455. case 15: /* ChgTabsPapx */
  456. case 23: /* ChgTabs */
  457. iTmp = (int)ucGetByte(iFodo + iFodoOff + 1, aucGrpprl);
  458. if (iTmp < 2) {
  459. iInfoLen = 1;
  460. break;
  461. }
  462. NO_DBG_DEC(iTmp);
  463. iDel = (int)ucGetByte(iFodo + iFodoOff + 2, aucGrpprl);
  464. if (iTmp < 2 + 2 * iDel) {
  465. iInfoLen = 1;
  466. break;
  467. }
  468. NO_DBG_DEC(iDel);
  469. iAdd = (int)ucGetByte(
  470. iFodo + iFodoOff + 3 + 2 * iDel, aucGrpprl);
  471. if (iTmp < 2 + 2 * iDel + 2 * iAdd) {
  472. iInfoLen = 1;
  473. break;
  474. }
  475. NO_DBG_DEC(iAdd);
  476. break;
  477. case 16: /* dxaRight */
  478. pStyle->sRightIndent = (short)usGetWord(
  479. iFodo + iFodoOff + 1, aucGrpprl);
  480. NO_DBG_DEC(pStyle->sRightIndent);
  481. break;
  482. case 17: /* dxaLeft */
  483. pStyle->sLeftIndent = (short)usGetWord(
  484. iFodo + iFodoOff + 1, aucGrpprl);
  485. NO_DBG_DEC(pStyle->sLeftIndent);
  486. break;
  487. case 18: /* Nest dxaLeft */
  488. sTmp = (short)usGetWord(
  489. iFodo + iFodoOff + 1, aucGrpprl);
  490. pStyle->sLeftIndent += sTmp;
  491. if (pStyle->sLeftIndent < 0) {
  492. pStyle->sLeftIndent = 0;
  493. }
  494. NO_DBG_DEC(sTmp);
  495. NO_DBG_DEC(pStyle->sLeftIndent);
  496. break;
  497. case 19: /* dxaLeft1 */
  498. pStyle->sLeftIndent1 = (short)usGetWord(
  499. iFodo + iFodoOff + 1, aucGrpprl);
  500. NO_DBG_DEC(pStyle->sLeftIndent1);
  501. break;
  502. case 21: /* dyaBefore */
  503. pStyle->usBeforeIndent = usGetWord(
  504. iFodo + iFodoOff + 1, aucGrpprl);
  505. NO_DBG_DEC(pStyle->usBeforeIndent);
  506. break;
  507. case 22: /* dyaAfter */
  508. pStyle->usAfterIndent = usGetWord(
  509. iFodo + iFodoOff + 1, aucGrpprl);
  510. NO_DBG_DEC(pStyle->usAfterIndent);
  511. break;
  512. default:
  513. break;
  514. }
  515. if (iInfoLen <= 0) {
  516. iInfoLen =
  517. iGet2InfoLength(iFodo + iFodoOff, aucGrpprl);
  518. fail(iInfoLen <= 0);
  519. }
  520. iFodoOff += iInfoLen;
  521. }
  522. } /* end of vGet2StyleInfo */
  523. /*
  524. * Build the lists with Paragraph Information for WinWord 1/2 files
  525. */
  526. void
  527. vGet2PapInfo(FILE *pFile, const UCHAR *aucHeader)
  528. {
  529. row_block_type tRow;
  530. style_block_type tStyle;
  531. USHORT *ausParfPage;
  532. UCHAR *aucBuffer;
  533. ULONG ulCharPos, ulCharPosFirst, ulCharPosLast;
  534. ULONG ulBeginParfInfo;
  535. size_t tParfInfoLen, tParfPageNum, tOffset, tSize, tLenOld, tLen;
  536. int iIndex, iIndex2, iRun, iFodo, iLen;
  537. row_info_enum eRowInfo;
  538. USHORT usParfFirstPage, usCount, usIstd;
  539. UCHAR ucStc;
  540. UCHAR aucFpage[BIG_BLOCK_SIZE];
  541. fail(pFile == NULL || aucHeader == NULL);
  542. ulBeginParfInfo = ulGetLong(0xa6, aucHeader); /* fcPlcfbtePapx */
  543. NO_DBG_HEX(ulBeginParfInfo);
  544. tParfInfoLen = (size_t)usGetWord(0xaa, aucHeader); /* cbPlcfbtePapx */
  545. NO_DBG_DEC(tParfInfoLen);
  546. if (tParfInfoLen < 4) {
  547. DBG_DEC(tParfInfoLen);
  548. return;
  549. }
  550. aucBuffer = xmalloc(tParfInfoLen);
  551. if (!bReadBytes(aucBuffer, tParfInfoLen, ulBeginParfInfo, pFile)) {
  552. aucBuffer = xfree(aucBuffer);
  553. return;
  554. }
  555. NO_DBG_PRINT_BLOCK(aucBuffer, tParfInfoLen);
  556. tLen = (tParfInfoLen - 4) / 6;
  557. ausParfPage = xcalloc(tLen, sizeof(USHORT));
  558. for (iIndex = 0, tOffset = (tLen + 1) * 4;
  559. iIndex < (int)tLen;
  560. iIndex++, tOffset += 2) {
  561. ausParfPage[iIndex] = usGetWord(tOffset, aucBuffer);
  562. NO_DBG_DEC(ausParfPage[iIndex]);
  563. }
  564. DBG_HEX(ulGetLong(0, aucBuffer));
  565. aucBuffer = xfree(aucBuffer);
  566. tParfPageNum = (size_t)usGetWord(0x144, aucHeader); /* cpnBtePap */
  567. DBG_DEC(tParfPageNum);
  568. if (tLen < tParfPageNum) {
  569. /* Replace ParfPage by a longer version */
  570. tLenOld = tLen;
  571. usParfFirstPage = usGetWord(0x140, aucHeader); /* pnPapFirst */
  572. DBG_DEC(usParfFirstPage);
  573. tLen += tParfPageNum - 1;
  574. tSize = tLen * sizeof(USHORT);
  575. ausParfPage = xrealloc(ausParfPage, tSize);
  576. /* Add new values */
  577. usCount = usParfFirstPage + 1;
  578. for (iIndex = (int)tLenOld; iIndex < (int)tLen; iIndex++) {
  579. ausParfPage[iIndex] = usCount;
  580. NO_DBG_DEC(ausParfPage[iIndex]);
  581. usCount++;
  582. }
  583. }
  584. (void)memset(&tRow, 0, sizeof(tRow));
  585. ulCharPosFirst = CP_INVALID;
  586. for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
  587. if (!bReadBytes(aucFpage, BIG_BLOCK_SIZE,
  588. (ULONG)ausParfPage[iIndex] * BIG_BLOCK_SIZE,
  589. pFile)) {
  590. break;
  591. }
  592. NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
  593. iRun = (int)ucGetByte(0x1ff, aucFpage);
  594. NO_DBG_DEC(iRun);
  595. for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
  596. if ((iRun + 1) * 4 + iIndex2 * 1 >= BIG_BLOCK_SIZE) {
  597. break;
  598. }
  599. NO_DBG_HEX(ulGetLong(iIndex2 * 4, aucFpage));
  600. iFodo = 2 * (int)ucGetByte(
  601. (iRun + 1) * 4 + iIndex2 * 1, aucFpage);
  602. if (iFodo <= 0) {
  603. continue;
  604. }
  605. iLen = 2 * (int)ucGetByte(iFodo, aucFpage);
  606. ucStc = ucGetByte(iFodo + 1, aucFpage);
  607. usIstd = usStc2istd(ucStc);
  608. vFillStyleFromStylesheet(usIstd, &tStyle);
  609. vGet2StyleInfo(iFodo, aucFpage + 8, iLen - 8, &tStyle);
  610. ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
  611. NO_DBG_HEX(ulCharPos);
  612. tStyle.ulFileOffset = ulCharPos;
  613. vAdd2StyleInfoList(&tStyle);
  614. eRowInfo = eGet2RowInfo(iFodo,
  615. aucFpage + 8, iLen - 8, &tRow);
  616. switch(eRowInfo) {
  617. case found_a_cell:
  618. if (ulCharPosFirst != CP_INVALID) {
  619. break;
  620. }
  621. ulCharPosFirst = ulGetLong(
  622. iIndex2 * 4, aucFpage);
  623. NO_DBG_HEX(ulCharPosFirst);
  624. tRow.ulCharPosStart = ulCharPosFirst;
  625. tRow.ulFileOffsetStart = ulCharPosFirst;
  626. break;
  627. case found_end_of_row:
  628. ulCharPosLast = ulGetLong(
  629. iIndex2 * 4, aucFpage);
  630. NO_DBG_HEX(ulCharPosLast);
  631. tRow.ulCharPosEnd = ulCharPosLast;
  632. /* Add 1 for compatiblity with Word 6 and up */
  633. tRow.ulFileOffsetEnd = ulCharPosLast + 1;
  634. vAdd2RowInfoList(&tRow);
  635. (void)memset(&tRow, 0, sizeof(tRow));
  636. ulCharPosFirst = CP_INVALID;
  637. break;
  638. case found_nothing:
  639. break;
  640. default:
  641. DBG_DEC(eRowInfo);
  642. break;
  643. }
  644. }
  645. }
  646. ausParfPage = xfree(ausParfPage);
  647. } /* end of vGet2PapInfo */
  648. /*
  649. * Fill the font information block with information
  650. * from a WinWord 1 file.
  651. */
  652. void
  653. vGet1FontInfo(int iFodo,
  654. const UCHAR *aucGrpprl, size_t tBytes, font_block_type *pFont)
  655. {
  656. BOOL bIcoChange, bFtcChange, bHpsChange, bKulChange;
  657. USHORT usTmp;
  658. UCHAR ucTmp;
  659. UCHAR aucChpx[12];
  660. fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
  661. if (tBytes > sizeof(aucChpx)) {
  662. NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
  663. return;
  664. }
  665. /* Build the CHPX structure */
  666. (void)memset(aucChpx, 0, sizeof(aucChpx));
  667. (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
  668. usTmp = usGetWord(0, aucChpx);
  669. if ((usTmp & BIT(0)) != 0) {
  670. pFont->usFontStyle ^= FONT_BOLD;
  671. }
  672. if ((usTmp & BIT(1)) != 0) {
  673. pFont->usFontStyle ^= FONT_ITALIC;
  674. }
  675. if ((usTmp & BIT(2)) != 0) {
  676. pFont->usFontStyle ^= FONT_STRIKE;
  677. }
  678. if ((usTmp & BIT(5)) != 0) {
  679. pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
  680. }
  681. if ((usTmp & BIT(6)) != 0) {
  682. pFont->usFontStyle ^= FONT_CAPITALS;
  683. }
  684. if ((usTmp & BIT(7)) != 0) {
  685. pFont->usFontStyle ^= FONT_HIDDEN;
  686. }
  687. ucTmp = ucGetByte(5, aucChpx);
  688. if (ucTmp != 0) {
  689. if (ucTmp < 128) {
  690. pFont->usFontStyle |= FONT_SUPERSCRIPT;
  691. DBG_MSG("Superscript");
  692. } else {
  693. pFont->usFontStyle |= FONT_SUBSCRIPT;
  694. DBG_MSG("Subscript");
  695. }
  696. }
  697. bIcoChange = (usTmp & BIT(10)) != 0;
  698. bFtcChange = (usTmp & BIT(11)) != 0;
  699. bHpsChange = (usTmp & BIT(12)) != 0;
  700. bKulChange = (usTmp & BIT(13)) != 0;
  701. if (bFtcChange) {
  702. usTmp = usGetWord(2, aucChpx);
  703. if (usTmp <= (USHORT)UCHAR_MAX) {
  704. pFont->ucFontNumber = (UCHAR)usTmp;
  705. } else {
  706. pFont->ucFontNumber = 0;
  707. }
  708. }
  709. if (bHpsChange) {
  710. pFont->usFontSize = (USHORT)ucGetByte(4, aucChpx);
  711. }
  712. if (bIcoChange || bKulChange) {
  713. usTmp = usGetWord(6, aucChpx);
  714. if (bIcoChange) {
  715. pFont->ucFontColor = (UCHAR)((usTmp & 0x0f00) >> 8);
  716. if (pFont->ucFontColor <= 7) {
  717. /* Add 1 for compatibility with Word 2 and up */
  718. pFont->ucFontColor++;
  719. } else {
  720. DBG_DEC(pFont->ucFontColor);
  721. pFont->ucFontColor = 0;
  722. }
  723. }
  724. if (bKulChange) {
  725. usTmp = (usTmp & 0x7000) >> 12;
  726. DBG_DEC_C(usTmp > 4, usTmp);
  727. if (usTmp == 0) {
  728. pFont->usFontStyle &= ~FONT_UNDERLINE;
  729. } else {
  730. pFont->usFontStyle |= FONT_UNDERLINE;
  731. }
  732. }
  733. }
  734. } /* end of vGet1FontInfo */
  735. /*
  736. * Fill the font information block with information
  737. * from a WinWord 1/2 file.
  738. */
  739. void
  740. vGet2FontInfo(int iFodo,
  741. const UCHAR *aucGrpprl, size_t tBytes, font_block_type *pFont)
  742. {
  743. BOOL bIcoChange, bFtcChange, bHpsChange, bKulChange;
  744. USHORT usTmp;
  745. UCHAR ucTmp;
  746. UCHAR aucChpx[18];
  747. fail(iFodo < 0 || aucGrpprl == NULL || pFont == NULL);
  748. if (tBytes > sizeof(aucChpx)) {
  749. NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
  750. return;
  751. }
  752. /* Build the CHPX structure */
  753. (void)memset(aucChpx, 0, sizeof(aucChpx));
  754. (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
  755. usTmp = usGetWord(0, aucChpx);
  756. if ((usTmp & BIT(0)) != 0) {
  757. pFont->usFontStyle ^= FONT_BOLD;
  758. }
  759. if ((usTmp & BIT(1)) != 0) {
  760. pFont->usFontStyle ^= FONT_ITALIC;
  761. }
  762. if (usTmp & BIT(3)) {
  763. pFont->usFontStyle ^= FONT_MARKDEL;
  764. }
  765. if ((usTmp & BIT(5)) != 0) {
  766. pFont->usFontStyle ^= FONT_SMALL_CAPITALS;
  767. }
  768. if ((usTmp & BIT(6)) != 0) {
  769. pFont->usFontStyle ^= FONT_CAPITALS;
  770. }
  771. if ((usTmp & BIT(7)) != 0) {
  772. pFont->usFontStyle ^= FONT_HIDDEN;
  773. }
  774. if (usTmp & BIT(10)) {
  775. pFont->usFontStyle ^= FONT_STRIKE;
  776. }
  777. ucTmp = ucGetByte(10, aucChpx);
  778. DBG_MSG_C(ucTmp != 0 && ucTmp < 128, "Superscript");
  779. DBG_MSG_C(ucTmp >= 128, "Subscript");
  780. usTmp = usGetWord(2, aucChpx);
  781. if (usTmp == 0) {
  782. /* No changes, nothing to do */
  783. return;
  784. }
  785. bIcoChange = (usTmp & BIT(0)) != 0;
  786. bFtcChange = (usTmp & BIT(1)) != 0;
  787. bHpsChange = (usTmp & BIT(2)) != 0;
  788. bKulChange = (usTmp & BIT(3)) != 0;
  789. if (bFtcChange) {
  790. usTmp = usGetWord(4, aucChpx);
  791. if (usTmp <= (USHORT)UCHAR_MAX) {
  792. pFont->ucFontNumber = (UCHAR)usTmp;
  793. } else {
  794. pFont->ucFontNumber = 0;
  795. }
  796. }
  797. if (bHpsChange) {
  798. pFont->usFontSize = usGetWord(6, aucChpx);
  799. }
  800. if (bIcoChange || bKulChange) {
  801. ucTmp = ucGetByte(9, aucChpx);
  802. if (bIcoChange) {
  803. pFont->ucFontColor = ucTmp & 0x1f;
  804. if (pFont->ucFontColor > 16) {
  805. DBG_DEC(pFont->ucFontColor);
  806. pFont->ucFontColor = 0;
  807. }
  808. }
  809. if (bKulChange) {
  810. ucTmp = (ucTmp & 0xe0) >> 5;
  811. DBG_DEC_C(ucTmp > 4, ucTmp);
  812. if (ucTmp == 0) {
  813. pFont->usFontStyle &= ~FONT_UNDERLINE;
  814. } else {
  815. pFont->usFontStyle |= FONT_UNDERLINE;
  816. }
  817. }
  818. }
  819. } /* end of vGet2FontInfo */
  820. /*
  821. * Fill the picture information block with information from a WinWord 1 file.
  822. * Returns TRUE when successful, otherwise FALSE
  823. */
  824. static BOOL
  825. bGet1PicInfo(int iFodo,
  826. const UCHAR *aucGrpprl, size_t tBytes, picture_block_type *pPicture)
  827. {
  828. ULONG ulTmp;
  829. UCHAR aucChpx[12];
  830. fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);
  831. if (tBytes > sizeof(aucChpx)) {
  832. NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
  833. tBytes = sizeof(aucChpx);
  834. }
  835. /* Build the CHPX structure */
  836. (void)memset(aucChpx, 0, sizeof(aucChpx));
  837. (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
  838. ulTmp = ulGetLong(8, aucChpx);
  839. if (ulTmp != 0 && ulTmp < MAX_FILESIZE) {
  840. pPicture->ulPictureOffset = ulTmp;
  841. DBG_HEX(pPicture->ulPictureOffset);
  842. return TRUE;
  843. }
  844. return FALSE;
  845. } /* end of bGet1PicInfo */
  846. /*
  847. * Fill the picture information block with information from a WinWord 2 file.
  848. * Returns TRUE when successful, otherwise FALSE
  849. */
  850. static BOOL
  851. bGet2PicInfo(int iFodo,
  852. const UCHAR *aucGrpprl, size_t tBytes, picture_block_type *pPicture)
  853. {
  854. ULONG ulTmp;
  855. UCHAR aucChpx[18];
  856. fail(iFodo < 0 || aucGrpprl == NULL || pPicture == NULL);
  857. if (tBytes > sizeof(aucChpx)) {
  858. NO_DBG_PRINT_BLOCK(aucGrpprl + iFodo, tBytes);
  859. tBytes = sizeof(aucChpx);
  860. }
  861. /* Build the CHPX structure */
  862. (void)memset(aucChpx, 0, sizeof(aucChpx));
  863. (void)memcpy(aucChpx, aucGrpprl + iFodo, min(tBytes, sizeof(aucChpx)));
  864. ulTmp = ulGetLong(14, aucChpx);
  865. if (ulTmp != 0 && ulTmp < MAX_FILESIZE) {
  866. pPicture->ulPictureOffset = ulTmp;
  867. DBG_HEX(pPicture->ulPictureOffset);
  868. DBG_DEC(tBytes);
  869. return TRUE;
  870. }
  871. return FALSE;
  872. } /* end of bGet2PicInfo */
  873. /*
  874. * Build the lists with Character Information for WinWord 1/2 files
  875. */
  876. void
  877. vGet2ChrInfo(FILE *pFile, int iWordVersion, const UCHAR *aucHeader)
  878. {
  879. font_block_type tFont;
  880. picture_block_type tPicture;
  881. USHORT *ausCharPage;
  882. UCHAR *aucBuffer;
  883. ULONG ulFileOffset, ulCharPos, ulBeginCharInfo;
  884. size_t tCharInfoLen, tOffset, tSize, tChrLen, tCharPageNum;
  885. size_t tLenOld, tLen;
  886. int iIndex, iIndex2, iRun, iFodo;
  887. BOOL bSuccess1, bSuccess2;
  888. USHORT usCharFirstPage, usCount, usIstd;
  889. UCHAR aucFpage[BIG_BLOCK_SIZE];
  890. fail(pFile == NULL || aucHeader == NULL);
  891. fail(iWordVersion != 1 && iWordVersion != 2);
  892. ulBeginCharInfo = ulGetLong(0xa0, aucHeader); /* fcPlcfbteChpx */
  893. DBG_HEX(ulBeginCharInfo);
  894. tCharInfoLen = (size_t)usGetWord(0xa4, aucHeader); /* cbPlcfbteChpx */
  895. DBG_DEC(tCharInfoLen);
  896. if (tCharInfoLen < 4) {
  897. DBG_DEC(tCharInfoLen);
  898. return;
  899. }
  900. aucBuffer = xmalloc(tCharInfoLen);
  901. if (!bReadBytes(aucBuffer, tCharInfoLen, ulBeginCharInfo, pFile)) {
  902. aucBuffer = xfree(aucBuffer);
  903. return;
  904. }
  905. NO_DBG_PRINT_BLOCK(aucBuffer, tCharInfoLen);
  906. tLen = (tCharInfoLen - 4) / 6;
  907. ausCharPage = xcalloc(tLen, sizeof(USHORT));
  908. for (iIndex = 0, tOffset = (tLen + 1) * 4;
  909. iIndex < (int)tLen;
  910. iIndex++, tOffset += 2) {
  911. ausCharPage[iIndex] = usGetWord(tOffset, aucBuffer);
  912. NO_DBG_DEC(ausCharPage[iIndex]);
  913. }
  914. DBG_HEX(ulGetLong(0, aucBuffer));
  915. aucBuffer = xfree(aucBuffer);
  916. tCharPageNum = (size_t)usGetWord(0x142, aucHeader); /* cpnBteChp */
  917. DBG_DEC(tCharPageNum);
  918. if (tLen < tCharPageNum) {
  919. /* Replace CharPage by a longer version */
  920. tLenOld = tLen;
  921. usCharFirstPage = usGetWord(0x13e, aucHeader); /* pnChrFirst */
  922. NO_DBG_DEC(usCharFirstPage);
  923. tLen += tCharPageNum - 1;
  924. tSize = tLen * sizeof(USHORT);
  925. ausCharPage = xrealloc(ausCharPage, tSize);
  926. /* Add new values */
  927. usCount = usCharFirstPage + 1;
  928. for (iIndex = (int)tLenOld; iIndex < (int)tLen; iIndex++) {
  929. ausCharPage[iIndex] = usCount;
  930. NO_DBG_DEC(ausCharPage[iIndex]);
  931. usCount++;
  932. }
  933. }
  934. for (iIndex = 0; iIndex < (int)tLen; iIndex++) {
  935. if (!bReadBytes(aucFpage, BIG_BLOCK_SIZE,
  936. (ULONG)ausCharPage[iIndex] * BIG_BLOCK_SIZE,
  937. pFile)) {
  938. break;
  939. }
  940. NO_DBG_PRINT_BLOCK(aucFpage, BIG_BLOCK_SIZE);
  941. iRun = (int)ucGetByte(0x1ff, aucFpage);
  942. NO_DBG_DEC(iRun);
  943. for (iIndex2 = 0; iIndex2 < iRun; iIndex2++) {
  944. if ((iRun + 1) * 4 + iIndex2 >= BIG_BLOCK_SIZE) {
  945. break;
  946. }
  947. ulCharPos = ulGetLong(iIndex2 * 4, aucFpage);
  948. ulFileOffset = ulCharPos;
  949. iFodo = 2 * (int)ucGetByte(
  950. (iRun + 1) * 4 + iIndex2, aucFpage);
  951. tChrLen = (size_t)ucGetByte(iFodo, aucFpage);
  952. usIstd = usGetIstd(ulFileOffset);
  953. vFillFontFromStylesheet(usIstd, &tFont);
  954. if (iFodo != 0) {
  955. if (iWordVersion == 1) {
  956. vGet1FontInfo(iFodo,
  957. aucFpage + 1, tChrLen, &tFont);
  958. } else if (iWordVersion == 2) {
  959. vGet2FontInfo(iFodo,
  960. aucFpage + 1, tChrLen, &tFont);
  961. }
  962. }
  963. tFont.ulFileOffset = ulFileOffset;
  964. vAdd2FontInfoList(&tFont);
  965. if (iFodo <= 0) {
  966. continue;
  967. }
  968. (void)memset(&tPicture, 0, sizeof(tPicture));
  969. bSuccess1 = iWordVersion == 1 &&
  970. bGet1PicInfo(iFodo, aucFpage + 1,
  971. tChrLen, &tPicture);
  972. bSuccess2 = iWordVersion == 2 &&
  973. bGet2PicInfo(iFodo, aucFpage + 1,
  974. tChrLen, &tPicture);
  975. if (bSuccess1 || bSuccess2) {
  976. tPicture.ulFileOffset = ulFileOffset;
  977. tPicture.ulFileOffsetPicture =
  978. tPicture.ulPictureOffset;
  979. vAdd2PictInfoList(&tPicture);
  980. }
  981. }
  982. }
  983. ausCharPage = xfree(ausCharPage);
  984. } /* end of vGet2ChrInfo */