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