properties.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * properties.c
  3. * Copyright (C) 1998-2005 A.J. van Os; Released under GNU GPL
  4. *
  5. * Description:
  6. * Read the properties information from a MS Word file
  7. */
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "antiword.h"
  11. /*
  12. * Build the lists with Property Information
  13. */
  14. void
  15. vGetPropertyInfo(FILE *pFile, const pps_info_type *pPPS,
  16. const ULONG *aulBBD, size_t tBBDLen,
  17. const ULONG *aulSBD, size_t tSBDLen,
  18. const UCHAR *aucHeader, int iWordVersion)
  19. {
  20. options_type tOptions;
  21. TRACE_MSG("vGetPropertyInfo");
  22. fail(pFile == NULL);
  23. fail(pPPS == NULL && iWordVersion >= 6);
  24. fail(aulBBD == NULL && tBBDLen != 0);
  25. fail(aulSBD == NULL && tSBDLen != 0);
  26. fail(aucHeader == NULL);
  27. /* Get the options */
  28. vGetOptions(&tOptions);
  29. /* Get the property information per Word version */
  30. switch (iWordVersion) {
  31. case 0:
  32. vGet0DopInfo(pFile, aucHeader);
  33. vGet0SepInfo(pFile, aucHeader);
  34. vGet0PapInfo(pFile, aucHeader);
  35. if (tOptions.eConversionType == conversion_draw ||
  36. tOptions.eConversionType == conversion_ps ||
  37. tOptions.eConversionType == conversion_xml ||
  38. tOptions.eConversionType == conversion_fmt_text ||
  39. tOptions.eConversionType == conversion_pdf) {
  40. vGet0ChrInfo(pFile, aucHeader);
  41. }
  42. if (tOptions.eConversionType == conversion_draw ||
  43. tOptions.eConversionType == conversion_ps ||
  44. tOptions.eConversionType == conversion_pdf) {
  45. vCreate0FontTable();
  46. }
  47. vSet0SummaryInfo(pFile, aucHeader);
  48. break;
  49. case 1:
  50. case 2:
  51. vGet2Stylesheet(pFile, iWordVersion, aucHeader);
  52. vGet2DopInfo(pFile, aucHeader);
  53. vGet2SepInfo(pFile, aucHeader);
  54. vGet2PapInfo(pFile, aucHeader);
  55. if (tOptions.eConversionType == conversion_ps ||
  56. tOptions.eConversionType == conversion_pdf) {
  57. vGet2HdrFtrInfo(pFile, aucHeader);
  58. }
  59. if (tOptions.eConversionType == conversion_draw ||
  60. tOptions.eConversionType == conversion_ps ||
  61. tOptions.eConversionType == conversion_xml ||
  62. tOptions.eConversionType == conversion_fmt_text ||
  63. tOptions.eConversionType == conversion_pdf) {
  64. vGet2ChrInfo(pFile, iWordVersion, aucHeader);
  65. }
  66. if (tOptions.eConversionType == conversion_draw ||
  67. tOptions.eConversionType == conversion_ps ||
  68. tOptions.eConversionType == conversion_pdf) {
  69. vCreate2FontTable(pFile, iWordVersion, aucHeader);
  70. }
  71. vSet2SummaryInfo(pFile, iWordVersion, aucHeader);
  72. break;
  73. case 4:
  74. case 5:
  75. break;
  76. case 6:
  77. case 7:
  78. vGet6Stylesheet(pFile, pPPS->tWordDocument.ulSB,
  79. aulBBD, tBBDLen, aucHeader);
  80. vGet6DopInfo(pFile, pPPS->tWordDocument.ulSB,
  81. aulBBD, tBBDLen, aucHeader);
  82. vGet6SepInfo(pFile, pPPS->tWordDocument.ulSB,
  83. aulBBD, tBBDLen, aucHeader);
  84. vGet6PapInfo(pFile, pPPS->tWordDocument.ulSB,
  85. aulBBD, tBBDLen, aucHeader);
  86. if (tOptions.eConversionType == conversion_ps ||
  87. tOptions.eConversionType == conversion_pdf) {
  88. vGet6HdrFtrInfo(pFile, pPPS->tWordDocument.ulSB,
  89. aulBBD, tBBDLen, aucHeader);
  90. }
  91. if (tOptions.eConversionType == conversion_draw ||
  92. tOptions.eConversionType == conversion_ps ||
  93. tOptions.eConversionType == conversion_xml ||
  94. tOptions.eConversionType == conversion_fmt_text ||
  95. tOptions.eConversionType == conversion_pdf) {
  96. vGet6ChrInfo(pFile, pPPS->tWordDocument.ulSB,
  97. aulBBD, tBBDLen, aucHeader);
  98. }
  99. if (tOptions.eConversionType == conversion_draw ||
  100. tOptions.eConversionType == conversion_ps ||
  101. tOptions.eConversionType == conversion_pdf) {
  102. vCreate6FontTable(pFile, pPPS->tWordDocument.ulSB,
  103. aulBBD, tBBDLen, aucHeader);
  104. }
  105. vSet6SummaryInfo(pFile, pPPS,
  106. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  107. break;
  108. case 8:
  109. vGet8LstInfo(pFile, pPPS,
  110. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  111. vGet8Stylesheet(pFile, pPPS,
  112. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  113. vGet8DopInfo(pFile, &pPPS->tTable,
  114. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  115. vGet8SepInfo(pFile, pPPS,
  116. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  117. vGet8PapInfo(pFile, pPPS,
  118. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  119. if (tOptions.eConversionType == conversion_ps ||
  120. tOptions.eConversionType == conversion_pdf) {
  121. vGet8HdrFtrInfo(pFile, &pPPS->tTable,
  122. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  123. }
  124. if (tOptions.eConversionType == conversion_draw ||
  125. tOptions.eConversionType == conversion_ps ||
  126. tOptions.eConversionType == conversion_xml ||
  127. tOptions.eConversionType == conversion_fmt_text ||
  128. tOptions.eConversionType == conversion_pdf) {
  129. vGet8ChrInfo(pFile, pPPS,
  130. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  131. }
  132. if (tOptions.eConversionType == conversion_draw ||
  133. tOptions.eConversionType == conversion_ps ||
  134. tOptions.eConversionType == conversion_pdf) {
  135. vCreate8FontTable(pFile, pPPS,
  136. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  137. }
  138. vSet8SummaryInfo(pFile, pPPS,
  139. aulBBD, tBBDLen, aulSBD, tSBDLen, aucHeader);
  140. break;
  141. default:
  142. DBG_DEC(iWordVersion);
  143. DBG_FIXME();
  144. werr(0, "Sorry, no property information");
  145. break;
  146. }
  147. /* Temporarily: Correct the font table */
  148. vCorrectFontTable(tOptions.eConversionType, tOptions.eEncoding);
  149. } /* end of vGetPropertyInfo */
  150. /*
  151. * ePropMod2RowInfo - Turn the Property Modifier into row information
  152. *
  153. * Returns: the row information
  154. */
  155. row_info_enum
  156. ePropMod2RowInfo(USHORT usPropMod, int iWordVersion)
  157. {
  158. row_block_type tRow;
  159. const UCHAR *aucPropMod;
  160. int iLen;
  161. TRACE_MSG("ePropMod2RowInfo");
  162. aucPropMod = aucReadPropModListItem(usPropMod);
  163. if (aucPropMod == NULL) {
  164. return found_nothing;
  165. }
  166. iLen = (int)usGetWord(0, aucPropMod);
  167. switch (iWordVersion) {
  168. case 0:
  169. return found_nothing;
  170. case 1:
  171. case 2:
  172. return eGet2RowInfo(0, aucPropMod + 2, iLen, &tRow);
  173. case 4:
  174. case 5:
  175. return found_nothing;
  176. case 6:
  177. case 7:
  178. return eGet6RowInfo(0, aucPropMod + 2, iLen, &tRow);
  179. case 8:
  180. return eGet8RowInfo(0, aucPropMod + 2, iLen, &tRow);
  181. default:
  182. DBG_DEC(iWordVersion);
  183. DBG_FIXME();
  184. return found_nothing;
  185. }
  186. } /* end of ePropMod2RowInfo */