1 /* wvWare
2 * Copyright (C) Caolan McNamara, Dom Lachowicz, and others
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include "wv.h"
27
28 /*
29 flt value live/dead field type
30
31 1 unknown keyword
32
33 2 live possible bookmark (syntax matches bookmark name)
34
35 3 live bookmark reference
36
37 4 dead index entry
38
39 5 live footnote reference
40
41 6 live Set command (for Print Merge)
42
43 7 live If command (for Print Merge)
44
45 8 live create index
46
47 9 dead table of contents entry
48
49 10 live Style reference
50
51 11 dead document reference
52
53 12 live sequence mark
54
55 13 live create table-of-contents
56
57 14 live quote Info variable
58
59 15 live quote Title variable
60
61 16 live quote Subject variable
62
63 17 live quote Author variable
64
65 18 live quote Keywords variable
66
67 19 live quote Comments variable
68
69 20 live quote Last Revised By variable
70
71 21 live quote Creation Date variable
72
73 22 live quote Revision Date variable
74
75 23 live quote Print Date variable
76
77 24 live quote Revision Number variable
78
79 25 live quote Edit Time variable
80
81 26 live quote Number of Pages variable
82
83 27 live quote Number of Words variable
84
85 28 live quote Number of Characters variable
86
87 29 live quote File Name variable
88
89 30 live quote Document Template Name variable
90
91 31 live quote Current Date variable
92
93 32 live quote Current Time variable
94
95 33 live quote Current Page variable
96
97 34 live evaluate expression
98
99 35 live insert literal text
100
101 36 live Include command (Print Merge)
102
103 37 live page reference
104
105 38 live Ask command (Print Merge)
106
107 39 live Fill-in command to display prompt (Print Merge)
108
109 40 live Data command (Print Merge)
110
111 41 live Next command (Print Merge)
112
113 42 live NextIf command (Print Merge)
114
115 43 live SkipIf (Print Merge)
116
117 44 live inserts number of current Print Merge record
118
119 45 live DDE reference
120
121 46 live DDE automatic reference
122
123 47 live Inserts Glossary Entry
124
125 48 live sends characters to printer without translation
126
127 49 live Formula definition
128
129 50 live Goto Button
130
131 51 live Macro Button
132
133 52 live insert auto numbering field in outline format
134
135 53 live insert auto numbering field in legal format
136
137 54 live insert auto numbering field in Arabic number format
138
139 55 live reads a TIFF file
140
141 56 live Link
142
143 57 live Symbol
144
145 58 live Embedded Object
146
147 59 live Merge fields
148
149 60 live User Name
150
151 61 live User Initial
152
153 62 live User Address
154
155 63 live Bar code
156
157 64 live Document variable
158
159 65 live Section
160
161 66 live Section pages
162
163 67 live Include Picture
164
165 68 live Include Text
166
167 69 live File Size
168
169 70 live Form Text Box
170
171 71 live Form Check Box
172
173 72 live Note Reference
174
175 73 live Create Table of Authorities
176
177 74 dead Mark Table of Authorities Entry
178
179 75 live Merge record sequence number
180
181 76 either Macro
182
183 77 dead Private
184
185 78 live Insert Database
186
187 79 live Autotext
188
189 80 live Compare two values
190
191 81 live Plug-in module private
192
193 82 live Subscriber
194
195 83 live Form List Box
196
197 84 live Advance
198
199 85 live Document property
200
201 86 live
202
203 87 live OCX
204
205 88 live Hyperlink
206
207 89 live AutoTextList
208
209 90 live List element
210
211 91 live HTML control
212
213 Since dead fields have no entry in the plcffld, the string in the field code
214 must be used to determine the field type. All versions of Word '97 use
215 English field code strings, except French, German, and Spanish versions of
216 Word. The strings for all languages for all possible dead fields are listed
217 below.
218
219 flt English French German Spanish field type
220 value string string string string
221
222 4 XE EX XE E index entry
223
224 9 TC TE INHALT TC table of contents
225 entry
226
227 11 RD RD RD RD document reference
228
229 74 TA TA TA TA Mark Table of
230 Authorities Entry
231
232 76 Macro
233
234 77 PRIVATE PRIVE PRIVATE PRIVATESPA Private
235 */
236
237
238 void
wvGetFLD(FLD * item,wvStream * fd)239 wvGetFLD (FLD * item, wvStream * fd)
240 {
241 U8 temp8;
242 U8 ch;
243
244 temp8 = read_8ubit (fd);
245 ch = temp8 & 0x1f;
246 if (ch == 19)
247 {
248 item->var1.ch = temp8 & 0x1f;
249 item->var1.reserved = (temp8 & 0xe0) >> 5;
250 item->var1.flt = read_8ubit (fd);
251 }
252 else
253 {
254 item->var2.ch = temp8 & 0x1f;
255 item->var2.reserved = (temp8 & 0xe0) >> 5;
256 temp8 = read_8ubit (fd);
257 item->var2.fDiffer = temp8 & 0x01;
258 item->var2.fZombieEmbed = (temp8 & 0x02) >> 1;
259 item->var2.fResultDirty = (temp8 & 0x04) >> 2;
260 item->var2.fResultEdited = (temp8 & 0x08) >> 3;
261 item->var2.fLocked = (temp8 & 0x10) >> 4;
262 item->var2.fPrivateResult = (temp8 & 0x20) >> 5;
263 item->var2.fNested = (temp8 & 0x40) >> 6;
264 item->var2.fHasSep = (temp8 & 0x80) >> 7;
265 }
266 }
267
268
269 int
wvGetFLD_PLCF(FLD ** fld,U32 ** pos,U32 * nofld,U32 offset,U32 len,wvStream * fd)270 wvGetFLD_PLCF (FLD ** fld, U32 ** pos, U32 * nofld, U32 offset, U32 len,
271 wvStream * fd)
272 {
273 U32 i;
274 if (len == 0)
275 {
276 *fld = NULL;
277 *pos = NULL;
278 *nofld = 0;
279 }
280 else
281 {
282 *nofld = (len - 4) / 6;
283 *pos = (U32 *) wvMalloc ((*nofld + 1) * sizeof (U32));
284 if (*pos == NULL)
285 {
286 wvError (
287 ("NO MEM 1, failed to alloc %d bytes\n",
288 (*nofld + 1) * sizeof (U32)));
289 return (1);
290 }
291
292 *fld = (FLD *) wvMalloc (*nofld * sizeof (FLD));
293 if (*fld == NULL)
294 {
295 wvError (
296 ("NO MEM 1, failed to alloc %d bytes\n",
297 *nofld * sizeof (FLD)));
298 wvFree (pos);
299 return (1);
300 }
301 wvStream_goto (fd, offset);
302 for (i = 0; i <= *nofld; i++)
303 (*pos)[i] = read_32ubit (fd);
304 for (i = 0; i < *nofld; i++)
305 wvGetFLD (&((*fld)[i]), fd);
306 }
307 return (0);
308 }
309