1 #ifndef MSWORDVIEW_HEADER
2 #define MSWORDVIEW_HEADER
3 
4 #include <stdio.h>
5 #include <time.h>
6 
7 #include <gsf/gsf-input.h>
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /* The structure below is used to refer to a wvStream.  Usually,
14  * kind = GSF_STREAM,
15  * but if we can't open a file using LibGSF, we fall back to the old file-based
16  * routines, in which case kind == FILE_STREAM.
17  */
18     typedef enum {
19 	GSF_STREAM,
20 	FILE_STREAM,
21 	MEMORY_STREAM
22     } wvStreamKind;
23 
24     typedef struct {
25       char *mem;
26       unsigned long current;
27       unsigned long size;
28     } MemoryStream;
29 
30     typedef union {
31 	FILE *file_stream;
32 	GsfInput *gsf_stream;
33 	MemoryStream *memory_stream;
34     } wvInternalStream;
35 
36     typedef struct {
37 	wvStreamKind kind;
38 	wvInternalStream stream;
39     } wvStream;
40 
41 
42 #ifndef PATH_MAX
43 #define PATH_MAX 1024		/*seems a reasonable figure */
44 #endif
45 
46 /* these really should be worked out in the configure script to be 100% correct */
47 #ifndef U32
48 #define U32 unsigned int
49 #endif
50 
51 #ifndef S32
52 #define S32 int
53 #endif
54 
55 #ifndef U16
56 #define U16 unsigned short
57 #endif
58 
59 #ifndef S16
60 #define S16 signed short
61 #endif
62 
63 #ifndef U8
64 #define U8 unsigned char
65 #endif
66 
67 #ifndef S8
68 #define S8 char
69 #endif
70 
71 
72 #define DEFAULTINDENT 1800
73 #define TWIRPS_PER_BQ 1440
74 #define TWIRPS_PER_H_PIXEL 20
75 #define TWIRPS_PER_V_PIXEL 20
76 
77 #define SPACEPIXELS 6
78 
79 #ifndef isletter
80 #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
81 #endif
82 
83 #ifndef digit
84 #define digit(c)  ((c) >= '0' && (c) <= '9')
85 #endif
86 
87 #define legal_variable_char(c)  (isletter (c) || digit (c) || c == '_')
88 
89 #ifndef HAVE_WMF
90     typedef struct tagRECT {
91 	S32 left;
92 	S32 right;
93 	S32 top;
94 	S32 bottom;
95     } RECT;
96 
97     typedef struct tagPOINT {
98 	S32 x;
99 	S32 y;
100     } POINT;
101 #else
102 #	include /**/ <wmfapi.h>
103 #endif
104 
105 
106 
107 /*Wine Portions Begin*/
108 
109     typedef struct tagPANOSE {
110 	U8 bFamilyType;
111 	U8 bSerifStyle;
112 	U8 bWeight;
113 	U8 bProportion;
114 	U8 bContrast;
115 	U8 bStrokeVariation;
116 	U8 bArmStyle;
117 	U8 bLetterform;
118 	U8 bMidline;
119 	U8 bXHeight;
120     } PANOSE;
121 
122     void wvGetPANOSE (PANOSE * panose, wvStream * fd);
123     void wvInitPANOSE (PANOSE * item);
124 
125 
126 /*
127  * The FONTSIGNATURE tells which Unicode ranges and which code pages
128  * have glyphs in a font.
129  *
130  * fsUsb  128-bit bitmap. The most significant bits are 10 (magic number).
131  *        The remaining 126 bits map the Unicode ISO 10646 subranges
132  *        for which the font provides glyphs.
133  *
134  * fsCsb  64-bit bitmap. The low 32 bits map the Windows codepages for
135  *        which the font provides glyphs. The high 32 bits are for
136  *        non Windows codepages.
137  */
138     typedef struct {
139 	U32 fsUsb[4];
140 	U32 fsCsb[2];
141     } FONTSIGNATURE;
142 
143     void wvGetFONTSIGNATURE (FONTSIGNATURE * fs, wvStream * fd);
144     void wvInitFONTSIGNATURE (FONTSIGNATURE * fs);
145 
146 
147 #ifndef _FILETIME_
148 #define _FILETIME_
149 /* 64 bit number of 100 nanoseconds intervals since January 1, 1601 */
150     typedef struct {
151 	U32 dwLowDateTime;
152 	U32 dwHighDateTime;
153     } FILETIME;
154 #endif				/* _FILETIME_ */
155 
156     void wvGetFILETIME (FILETIME * ft, wvStream * fd);
157     void wvInitFILETIME (FILETIME * ft);
158 
159     time_t wvDOSFS_FileTimeToUnixTime (const FILETIME * filetime,
160 				       U32 * remainder);
161     int wvFileTimeToDosDateTime (const FILETIME * ft, U16 * fatdate,
162 				 U16 * fattime);
163 /*Wine Portions End*/
164 
165     char *wvFmtMsg (char *fmt, ...);
166 
167 /** beginning of clean interface **/
168     void wvRealError (char *file, int line, char *msg);
169     void wvRealTrace (char *file, int line, char *msg);
170 #define wvError( args ) wvRealError(__FILE__,__LINE__, wvFmtMsg args )
171     void wvWarning (char *fmt, ...);
172 
173 void _wvFree (void *ptr);
174 #define wvFree(P) do { if (P) { _wvFree((void *)(P)); (P)=NULL; } } while (0)
175 
176     char *wvWideStrToMB (U16 * str);
177     char *wvWideCharToMB (U16 char16);
178 
179     typedef enum {
180 	WORD1 = 0x0000,
181 	WORD2 = 0x0001,
182 	WORD3 = 0x0002,
183 	WORD4 = 0x0003,
184 	WORD5 = 0x0004,
185 	WORD6 = 0x0005,
186 	WORD7 = 0x0006,
187 	WORD8 = 0x0007
188     } wvVersion;
189 
190     typedef enum {
191 	Dmain,
192 	Dfootnote,
193 	Dheader,
194 	Dannotation,
195 	Dendnote,
196 	Dtextbox,
197 	Dheader_textbox
198     } subdocument;
199 
200 
201 
202     typedef struct _FIB {
203 	U16 wIdent;		/* 0x0000 */
204 	U16 nFib;		/* 0x0002 */
205 	U16 nProduct;		/* 0x0004 */
206 	U16 lid;		/* 0x0006 */
207 	S16 pnNext;		/* 0x0008 */
208 
209 	U32 fDot:1;		/* Bitfield 0x0001 0x000A */
210 	U32 fGlsy:1;		/* Bitfield 0x0002 */
211 	U32 fComplex:1;		/* Bitfield 0x0004 */
212 	U32 fHasPic:1;		/* Bitfield 0x0008 */
213 	U32 cQuickSaves:4;	/* Bitfield 0x00F0 */
214 	U32 fEncrypted:1;	/* Bitfield 0x0100 */
215 	U32 fWhichTblStm:1;	/* Bitfield 0x0200 */
216 	U32 fReadOnlyRecommended:1;	/* Bitfield 0x0400 */
217 	U32 fWriteReservation:1;	/* Bitfield 0x0800 */
218 	U32 fExtChar:1;		/* Bitfield 0x1000 */
219 	U32 fLoadOverride:1;	/* Bitfield 0x2000 */
220 	U32 fFarEast:1;		/* Bitfield 0x4000 */
221 	U32 fCrypto:1;		/* Bitfield 0x8000 */
222 	U32 nFibBack:16;	/* 0x000C */
223 	U32 lKey;		/* 0x000E */
224 	U32 envr:8;		/* 0x0012 */
225 	U32 fMac:1;		/* Bitfield 0x01 0x0013 */
226 	U32 fEmptySpecial:1;	/* Bitfield 0x02 */
227 	U32 fLoadOverridePage:1;	/* Bitfield 0x04 */
228 	U32 fFutureSavedUndo:1;	/* Bitfield 0x08 */
229 	U32 fWord97Saved:1;	/* Bitfield 0x10 */
230 	U32 fSpare0:3;		/* Bitfield 0xFE */
231 	U32 chse:16;		/* 0x0014 *//*was chs */
232 	U16 chsTables;		/* 0x0016 */
233 	U32 fcMin;		/* 0x0018 */
234 	U32 fcMac;		/* 0x001C */
235 	U16 csw;		/* 0x0020 */
236 	U16 wMagicCreated;	/* 0x0022 */
237 	U16 wMagicRevised;	/* 0x0024 */
238 	U16 wMagicCreatedPrivate;	/* 0x0026 */
239 	U16 wMagicRevisedPrivate;	/* 0x0028 */
240 	S16 pnFbpChpFirst_W6;	/* 0x002A */
241 	S16 pnChpFirst_W6;	/* 0x002C */
242 	S16 cpnBteChp_W6;	/* 0x002E */
243 	S16 pnFbpPapFirst_W6;	/* 0x0030 */
244 	S16 pnPapFirst_W6;	/* 0x0032 */
245 	S16 cpnBtePap_W6;	/* 0x0034 */
246 	S16 pnFbpLvcFirst_W6;	/* 0x0036 */
247 	S16 pnLvcFirst_W6;	/* 0x0038 */
248 	S16 cpnBteLvc_W6;	/* 0x003A */
249 	S16 lidFE;		/* 0x003C */
250 	U16 clw;		/* 0x003E */
251 	S32 cbMac;		/* 0x0040 */
252 	U32 lProductCreated;	/* 0x0044 */
253 	U32 lProductRevised;	/* 0x0048 */
254 	U32 ccpText;		/* 0x004C */
255 	S32 ccpFtn;		/* 0x0050 */
256 	S32 ccpHdr;		/* 0x0054 */
257 	S32 ccpMcr;		/* 0x0058 */
258 	S32 ccpAtn;		/* 0x005C */
259 	S32 ccpEdn;		/* 0x0060 */
260 	S32 ccpTxbx;		/* 0x0064 */
261 	S32 ccpHdrTxbx;		/* 0x0068 */
262 	S32 pnFbpChpFirst;	/* 0x006C */
263 	S32 pnChpFirst;		/* 0x0070 */
264 	S32 cpnBteChp;		/* 0x0074 */
265 	S32 pnFbpPapFirst;	/* 0x0078 */
266 	S32 pnPapFirst;		/* 0x007C */
267 	S32 cpnBtePap;		/* 0x0080 */
268 	S32 pnFbpLvcFirst;	/* 0x0084 */
269 	S32 pnLvcFirst;		/* 0x0088 */
270 	S32 cpnBteLvc;		/* 0x008C */
271 	S32 fcIslandFirst;	/* 0x0090 */
272 	S32 fcIslandLim;	/* 0x0094 */
273 	U16 cfclcb;		/* 0x0098 */
274 	S32 fcStshfOrig;	/* 0x009A */
275 	U32 lcbStshfOrig;	/* 0x009E */
276 	S32 fcStshf;		/* 0x00A2 */
277 	U32 lcbStshf;		/* 0x00A6 */
278 	S32 fcPlcffndRef;	/* 0x00AA */
279 	U32 lcbPlcffndRef;	/* 0x00AE */
280 	S32 fcPlcffndTxt;	/* 0x00B2 */
281 	U32 lcbPlcffndTxt;	/* 0x00B6 */
282 	S32 fcPlcfandRef;	/* 0x00BA */
283 	U32 lcbPlcfandRef;	/* 0x00BE */
284 	S32 fcPlcfandTxt;	/* 0x00C2 */
285 	U32 lcbPlcfandTxt;	/* 0x00C6 */
286 	S32 fcPlcfsed;		/* 0x00CA */
287 	U32 lcbPlcfsed;		/* 0x00CE */
288 	S32 fcPlcpad;		/* 0x00D2 */
289 	U32 lcbPlcpad;		/* 0x00D6 */
290 	S32 fcPlcfphe;		/* 0x00DA */
291 	U32 lcbPlcfphe;		/* 0x00DE */
292 	S32 fcSttbfglsy;	/* 0x00E2 */
293 	U32 lcbSttbfglsy;	/* 0x00E6 */
294 	S32 fcPlcfglsy;		/* 0x00EA */
295 	U32 lcbPlcfglsy;	/* 0x00EE */
296 	S32 fcPlcfhdd;		/* 0x00F2 */
297 	U32 lcbPlcfhdd;		/* 0x00F6 */
298 	S32 fcPlcfbteChpx;	/* 0x00FA */
299 	U32 lcbPlcfbteChpx;	/* 0x00FE */
300 	S32 fcPlcfbtePapx;	/* 0x0102 */
301 	U32 lcbPlcfbtePapx;	/* 0x0106 */
302 	S32 fcPlcfsea;		/* 0x010A */
303 	U32 lcbPlcfsea;		/* 0x010E */
304 	S32 fcSttbfffn;		/* 0x0112 */
305 	U32 lcbSttbfffn;	/* 0x0116 */
306 	S32 fcPlcffldMom;	/* 0x011A */
307 	U32 lcbPlcffldMom;	/* 0x011E */
308 	S32 fcPlcffldHdr;	/* 0x0122 */
309 	U32 lcbPlcffldHdr;	/* 0x0126 */
310 	S32 fcPlcffldFtn;	/* 0x012A */
311 	U32 lcbPlcffldFtn;	/* 0x012E */
312 	S32 fcPlcffldAtn;	/* 0x0132 */
313 	U32 lcbPlcffldAtn;	/* 0x0136 */
314 	S32 fcPlcffldMcr;	/* 0x013A */
315 	U32 lcbPlcffldMcr;	/* 0x013E */
316 	S32 fcSttbfbkmk;	/* 0x0142 */
317 	U32 lcbSttbfbkmk;	/* 0x0146 */
318 	S32 fcPlcfbkf;		/* 0x014A */
319 	U32 lcbPlcfbkf;		/* 0x014E */
320 	S32 fcPlcfbkl;		/* 0x0152 */
321 	U32 lcbPlcfbkl;		/* 0x0156 */
322 	S32 fcCmds;		/* 0x015A */
323 	U32 lcbCmds;		/* 0x015E */
324 	S32 fcPlcmcr;		/* 0x0162 */
325 	U32 lcbPlcmcr;		/* 0x0166 */
326 	S32 fcSttbfmcr;		/* 0x016A */
327 	U32 lcbSttbfmcr;	/* 0x016E */
328 	S32 fcPrDrvr;		/* 0x0172 */
329 	U32 lcbPrDrvr;		/* 0x0176 */
330 	S32 fcPrEnvPort;	/* 0x017A */
331 	U32 lcbPrEnvPort;	/* 0x017E */
332 	S32 fcPrEnvLand;	/* 0x0182 */
333 	U32 lcbPrEnvLand;	/* 0x0186 */
334 	S32 fcWss;		/* 0x018A */
335 	U32 lcbWss;		/* 0x018E */
336 	S32 fcDop;		/* 0x0192 */
337 	U32 lcbDop;		/* 0x0196 */
338 	S32 fcSttbfAssoc;	/* 0x019A */
339 	U32 lcbSttbfAssoc;	/* 0x019E */
340 	S32 fcClx;		/* 0x01A2 */
341 	U32 lcbClx;		/* 0x01A6 */
342 	S32 fcPlcfpgdFtn;	/* 0x01AA */
343 	U32 lcbPlcfpgdFtn;	/* 0x01AE */
344 	S32 fcAutosaveSource;	/* 0x01B2 */
345 	U32 lcbAutosaveSource;	/* 0x01B6 */
346 	S32 fcGrpXstAtnOwners;	/* 0x01BA */
347 	U32 lcbGrpXstAtnOwners;	/* 0x01BE */
348 	S32 fcSttbfAtnbkmk;	/* 0x01C2 */
349 	U32 lcbSttbfAtnbkmk;	/* 0x01C6 */
350 	S32 fcPlcdoaMom;	/* 0x01CA */
351 	U32 lcbPlcdoaMom;	/* 0x01CE */
352 	S32 fcPlcdoaHdr;	/* 0x01D2 */
353 	U32 lcbPlcdoaHdr;	/* 0x01D6 */
354 	S32 fcPlcspaMom;	/* 0x01DA */
355 	U32 lcbPlcspaMom;	/* 0x01DE */
356 	S32 fcPlcspaHdr;	/* 0x01E2 */
357 	U32 lcbPlcspaHdr;	/* 0x01E6 */
358 	S32 fcPlcfAtnbkf;	/* 0x01EA */
359 	U32 lcbPlcfAtnbkf;	/* 0x01EE */
360 	S32 fcPlcfAtnbkl;	/* 0x01F2 */
361 	U32 lcbPlcfAtnbkl;	/* 0x01F6 */
362 	S32 fcPms;		/* 0x01FA */
363 	U32 lcbPms;		/* 0x01FE */
364 	S32 fcFormFldSttbs;	/* 0x0202 */
365 	U32 lcbFormFldSttbs;	/* 0x0206 */
366 	S32 fcPlcfendRef;	/* 0x020A */
367 	U32 lcbPlcfendRef;	/* 0x020E */
368 	S32 fcPlcfendTxt;	/* 0x0212 */
369 	U32 lcbPlcfendTxt;	/* 0x0216 */
370 	S32 fcPlcffldEdn;	/* 0x021A */
371 	U32 lcbPlcffldEdn;	/* 0x021E */
372 	S32 fcPlcfpgdEdn;	/* 0x0222 */
373 	U32 lcbPlcfpgdEdn;	/* 0x0226 */
374 	S32 fcDggInfo;		/* 0x022A */
375 	U32 lcbDggInfo;		/* 0x022E */
376 	S32 fcSttbfRMark;	/* 0x0232 */
377 	U32 lcbSttbfRMark;	/* 0x0236 */
378 	S32 fcSttbCaption;	/* 0x023A */
379 	U32 lcbSttbCaption;	/* 0x023E */
380 	S32 fcSttbAutoCaption;	/* 0x0242 */
381 	U32 lcbSttbAutoCaption;	/* 0x0246 */
382 	S32 fcPlcfwkb;		/* 0x024A */
383 	U32 lcbPlcfwkb;		/* 0x024E */
384 	S32 fcPlcfspl;		/* 0x0252 */
385 	U32 lcbPlcfspl;		/* 0x0256 */
386 	S32 fcPlcftxbxTxt;	/* 0x025A */
387 	U32 lcbPlcftxbxTxt;	/* 0x025E */
388 	S32 fcPlcffldTxbx;	/* 0x0262 */
389 	U32 lcbPlcffldTxbx;	/* 0x0266 */
390 	S32 fcPlcfhdrtxbxTxt;	/* 0x026A */
391 	U32 lcbPlcfhdrtxbxTxt;	/* 0x026E */
392 	S32 fcPlcffldHdrTxbx;	/* 0x0272 */
393 	U32 lcbPlcffldHdrTxbx;	/* 0x0276 */
394 	S32 fcStwUser;		/* 0x027A */
395 	U32 lcbStwUser;		/* 0x027E */
396 	S32 fcSttbttmbd;	/* 0x0282 */
397 	U32 cbSttbttmbd;	/* 0x0286 */
398 	S32 fcUnused;		/* 0x028A */
399 	U32 lcbUnused;		/* 0x028E */
400 	S32 fcPgdMother;	/* 0x0292 */
401 	U32 lcbPgdMother;	/* 0x0296 */
402 	S32 fcBkdMother;	/* 0x029A */
403 	U32 lcbBkdMother;	/* 0x029E */
404 	S32 fcPgdFtn;		/* 0x02A2 */
405 	U32 lcbPgdFtn;		/* 0x02A6 */
406 	S32 fcBkdFtn;		/* 0x02AA */
407 	U32 lcbBkdFtn;		/* 0x02AE */
408 	S32 fcPgdEdn;		/* 0x02B2 */
409 	U32 lcbPgdEdn;		/* 0x02B6 */
410 	S32 fcBkdEdn;		/* 0x02BA */
411 	U32 lcbBkdEdn;		/* 0x02BE */
412 	S32 fcSttbfIntlFld;	/* 0x02C2 */
413 	U32 lcbSttbfIntlFld;	/* 0x02C6 */
414 	S32 fcRouteSlip;	/* 0x02CA */
415 	U32 lcbRouteSlip;	/* 0x02CE */
416 	S32 fcSttbSavedBy;	/* 0x02D2 */
417 	U32 lcbSttbSavedBy;	/* 0x02D6 */
418 	S32 fcSttbFnm;		/* 0x02DA */
419 	U32 lcbSttbFnm;		/* 0x02DE */
420 	S32 fcPlcfLst;		/* 0x02E2 */
421 	U32 lcbPlcfLst;		/* 0x02E6 */
422 	S32 fcPlfLfo;		/* 0x02EA */
423 	U32 lcbPlfLfo;		/* 0x02EE */
424 	S32 fcPlcftxbxBkd;	/* 0x02F2 */
425 	U32 lcbPlcftxbxBkd;	/* 0x02F6 */
426 	S32 fcPlcftxbxHdrBkd;	/* 0x02FA */
427 	U32 lcbPlcftxbxHdrBkd;	/* 0x02FE */
428 	S32 fcDocUndo;		/* 0x0302 */
429 	U32 lcbDocUndo;		/* 0x0306 */
430 	S32 fcRgbuse;		/* 0x030A */
431 	U32 lcbRgbuse;		/* 0x030E */
432 	S32 fcUsp;		/* 0x0312 */
433 	U32 lcbUsp;		/* 0x0316 */
434 	S32 fcUskf;		/* 0x031A */
435 	U32 lcbUskf;		/* 0x031E */
436 	S32 fcPlcupcRgbuse;	/* 0x0322 */
437 	U32 lcbPlcupcRgbuse;	/* 0x0326 */
438 	S32 fcPlcupcUsp;	/* 0x032A */
439 	U32 lcbPlcupcUsp;	/* 0x032E */
440 	S32 fcSttbGlsyStyle;	/* 0x0332 */
441 	U32 lcbSttbGlsyStyle;	/* 0x0336 */
442 	S32 fcPlgosl;		/* 0x033A */
443 	U32 lcbPlgosl;		/* 0x033E */
444 	S32 fcPlcocx;		/* 0x0342 */
445 	U32 lcbPlcocx;		/* 0x0346 */
446 	S32 fcPlcfbteLvc;	/* 0x034A */
447 	U32 lcbPlcfbteLvc;	/* 0x034E */
448 	FILETIME ftModified;	/* 0x0352 */
449 	S32 fcPlcflvc;		/* 0x035A */
450 	U32 lcbPlcflvc;		/* 0x035E */
451 	S32 fcPlcasumy;		/* 0x0362 */
452 	U32 lcbPlcasumy;	/* 0x0366 */
453 	S32 fcPlcfgram;		/* 0x036A */
454 	U32 lcbPlcfgram;	/* 0x036E */
455 	S32 fcSttbListNames;	/* 0x0372 */
456 	U32 lcbSttbListNames;	/* 0x0376 */
457 	S32 fcSttbfUssr;	/* 0x037A */
458 	U32 lcbSttbfUssr;	/* 0x037E */
459 
460 	/* Added for Word 2 */
461 
462 	U32 Spare;		/* 0x000E */
463 	U16 rgwSpare0[3];	/* 0x0012 */
464 	U32 fcSpare0;		/* 0x0024 */
465 	U32 fcSpare1;		/* 0x0028 */
466 	U32 fcSpare2;		/* 0x002C */
467 	U32 fcSpare3;		/* 0x0030 */
468 	U32 ccpSpare0;		/* 0x0048 */
469 	U32 ccpSpare1;		/* 0x004C */
470 	U32 ccpSpare2;		/* 0x0050 */
471 	U32 ccpSpare3;		/* 0x0054 */
472 
473 	U32 fcPlcfpgd;		/* 0x0082 */
474 	U16 cbPlcfpgd;		/* 0x0086 */
475 
476 	U32 fcSpare5;		/* 0x0130 */
477 	U16 cbSpare5;		/* 0x0136 */
478 	U32 fcSpare6;		/* 0x0130 */
479 	U16 cbSpare6;		/* 0x0136 */
480 	U16 wSpare4;		/* 0x013C */
481 
482     } FIB;
483 
484     void wvGetFIB (FIB * item, wvStream * fd);
485     void wvGetFIB2 (FIB * item, wvStream * fd);
486     void wvGetFIB6 (FIB * item, wvStream * fd);
487     void wvInitFIB (FIB * item);
488 
489 
490     int wvGetEmpty_PLCF (U32 ** cp, U32 * nocps, U32 offset, U32 len,
491 			 wvStream * fd);
492 
493     typedef struct _FRD {
494 	S16 frd;
495     } FRD;
496 
497     void wvGetFRD (FRD * item, wvStream * fd);
498     int wvGetFRD_PLCF (FRD ** frd, U32 ** pos, U32 * nofrd, U32 offset, U32 len,
499 		       wvStream * fd);
500 
501     typedef U16 XCHAR;
502 
503     typedef struct _ATRD {
504 	XCHAR xstUsrInitl[10];
505 	S16 ibst;
506 	U16 ak;			/*unused */
507 	U16 grfbmc;		/*unused */
508 	S32 lTagBkmk;
509     } ATRD;
510 
511     void wvGetATRD (ATRD * item, wvStream * fd);
512     int wvGetATRD_PLCF (ATRD ** atrd, U32 ** pos, U32 * noatrd, U32 offset,
513 			U32 len, wvStream * fd);
514 
515     typedef struct _SED {
516 	S16 fn;
517 	U32 fcSepx;
518 	S16 fnMpr;
519 	U32 fcMpr;
520     } SED;
521 
522     void wvGetSED (SED * item, wvStream * fd);
523     int wvGetSED_PLCF (SED ** item, U32 ** pos, U32 * noitem, U32 offset,
524 		       U32 len, wvStream * fd);
525 
526     typedef struct _FFN {
527 	U32 cbFfnM1:8;
528 	U32 prq:2;
529 	U32 fTrueType:1;
530 	U32 reserved1:1;
531 	U32 ff:3;
532 	U32 reserved2:1;
533 	S32 wWeight:16;
534 
535 	U8 chs;
536 	U8 ixchSzAlt;
537 	PANOSE panose;
538 	FONTSIGNATURE fs;
539 	XCHAR xszFfn[65];	/*max size */
540     } FFN;
541 
542     void wvGetFFN (FFN * item, wvStream * fd);
543     void wvGetFFN6 (FFN * item, wvStream * fd);
544 
545 
546     typedef struct _FFN_STTBF {
547 	U16 extendedflag;
548 	U16 nostrings;
549 	U16 extradatalen;
550 	FFN *ffn;
551     } FFN_STTBF;
552 
553     void wvGetFFN_STTBF (FFN_STTBF * item, U32 offset, U32 len, wvStream * fd);
554     void wvGetFFN_STTBF6 (FFN_STTBF * item, U32 offset, U32 len, wvStream * fd);
555     void wvReleaseFFN_STTBF (FFN_STTBF * item);
556     char *wvGetFontnameFromCode (FFN_STTBF * item, int fontcode);
557 
558 
559     typedef struct _STTBF {
560 	U16 extendedflag;
561 	U16 nostrings;
562 	U16 extradatalen;
563 	S8 **s8strings;
564 	U16 **u16strings;
565 	U8 **extradata;
566     } STTBF;
567 
568     void wvGetSTTBF (STTBF * anS, U32 offset, U32 len, wvStream * fd);
569     void wvGetSTTBF6 (STTBF * anS, U32 offset, U32 len, wvStream * fd);
570     void wvListSTTBF (STTBF * item);
571     void wvReleaseSTTBF (STTBF * item);
572     void wvGetGrpXst (STTBF * anS, U32 offset, U32 len, wvStream * fd);
573 
574 
575     U16 *UssrStrBegin (STTBF * sttbf, int no);
576 
577 
578     typedef enum {
579 	ibstAssocFileNext = 0,
580 	ibstAssocDot = 1,
581 	ibstAssocTitle = 2,
582 	ibstAssocSubject = 3,
583 	ibstAssocKeyWords = 4,
584 	ibstAssocComments = 5,
585 	ibstAssocAuthor = 6,
586 	ibstAssocLastRevBy = 7,
587 	ibstAssocDataDoc = 8,
588 	ibstAssocHeaderDoc = 9,
589 	ibstAssocCriteria1 = 10,
590 	ibstAssocCriteria2 = 11,
591 	ibstAssocCriteria3 = 12,
592 	ibstAssocCriteria4 = 13,
593 	ibstAssocCriteria5 = 14,
594 	ibstAssocCriteria6 = 15,
595 	ibstAssocCriteria7 = 16,
596 	ibstAssocMax = 17,
597 	ibstAssocMaxWord6 = 17	/* just in case */
598     } ibst;
599 
600 
601     typedef struct _wv_var1 {
602 	/* 16 bits for bitfields */
603 	U32 ch:5;
604 	U32 reserved:3;
605 	U32 flt:8;
606     } wv_var1;
607 
608     typedef struct _wv_var2 {
609 	/* 16 bits for bitfields */
610 	U32 ch:5;
611 	U32 reserved:3;
612 	U32 fDiffer:1;
613 	U32 fZombieEmbed:1;
614 	U32 fResultDirty:1;
615 	U32 fResultEdited:1;
616 	U32 fLocked:1;
617 	U32 fPrivateResult:1;
618 	U32 fNested:1;
619 	U32 fHasSep:1;
620     } wv_var2;
621 
622 
623 
624     typedef union _FLD {
625 	wv_var1 var1;
626 	wv_var2 var2;
627     } FLD;
628 
629     void wvGetFLD (FLD * item, wvStream * fd);
630     int wvGetFLD_PLCF (FLD ** fld, U32 ** pos, U32 * nofld, U32 offset, U32 len,
631 		       wvStream * fd);
632 
633     typedef struct _COPTS {
634 	/* 16 bits for bitfields */
635 	U32 fNoTabForInd:1;
636 	U32 fNoSpaceRaiseLower:1;
637 	U32 fSuppressSpbfAfterPageBreak:1;
638 	U32 fWrapTrailSpaces:1;
639 	U32 fMapPrintTextColor:1;
640 	U32 fNoColumnBalance:1;
641 	U32 fConvMailMergeEsc:1;
642 	U32 fSuppressTopSpacing:1;
643 	U32 fOrigWordTableRules:1;
644 	U32 fTransparentMetafiles:1;
645 	U32 fShowBreaksInFrames:1;
646 	U32 fSwapBordersFacingPgs:1;
647 	U32 reserved:4;
648     } COPTS;
649 
650     void wvGetCOPTS (COPTS * copts, wvStream * fd);
651 
652     typedef struct _DTTM {
653 	U32 mint:6;
654 	U32 hr:5;
655 	U32 dom:5;
656 	U32 mon:4;
657 	U32 yr:9;
658 	U32 wdy:3;
659     } DTTM;
660 
661     void wvGetDTTM (DTTM * item, wvStream * fd);
662     void wvGetDTTMFromBucket (DTTM * item, U8 * pointer);
663     void wvCreateDTTM (DTTM * dttm, U16 one, U16 two);
664     void wvCopyDTTM (DTTM * dest, DTTM * src);
665     void wvInitDTTM (DTTM * dttm);
666     char *wvDTTMtoUnix (DTTM * src);
667 
668 
669     typedef struct _DOPTYPOGRAPHY {
670 	U32 fKerningPunct:1;
671 	U32 iJustification:2;
672 	U32 iLevelOfKinsoku:2;
673 	U32 f2on1:1;
674 	U32 reserved:10;
675 	U32 cchFollowingPunct:16;
676 
677 	U16 cchLeadingPunct;
678 	U16 rgxchFPunct[101];
679 	U16 rgxchLPunct[51];
680     } DOPTYPOGRAPHY;
681 
682     void wvGetDOPTYPOGRAPHY (DOPTYPOGRAPHY * dopt, wvStream * fd);
683     void wvInitDOPTYPOGRAPHY (DOPTYPOGRAPHY * dopt);
684 
685 
686     typedef struct _DOGRID {
687 	U16 xaGrid;
688 	U16 yaGrid;
689 	U16 dxaGrid;
690 	U32 dyaGrid:16;
691 	U32 dyGridDisplay:7;
692 	U32 fTurnItOff:1;
693 	U32 dxGridDisplay:7;
694 	U32 fFollowMargins:1;
695     } DOGRID;
696 
697     typedef struct _ASUMY {
698 	S32 lLevel;
699     } ASUMY;
700 
701 
702     void wvGetDOGRID (DOGRID * dogrid, wvStream * fd);
703     void wvInitDOGRID (DOGRID * dog);
704 
705     typedef struct _ASUMYI {
706 	U32 fValid:1;
707 	U32 fView:1;
708 	U32 iViewBy:2;
709 	U32 fUpdateProps:1;
710 	U32 reserved:11;
711 	U32 wDlgLevel:16;
712 
713 	U32 lHighestLevel;
714 	U32 lCurrentLevel;
715     } ASUMYI;
716 
717     void wvGetASUMYI (ASUMYI * asumyi, wvStream * fd);
718     void wvInitASUMYI (ASUMYI * asu);
719 
720     typedef struct _DOP {
721 	U32 fFacingPages:1;
722 	U32 fWidowControl:1;
723 	U32 fPMHMainDoc:1;
724 	U32 grfSuppression:2;
725 	U32 fpc:2;		/*where footnotes are put */
726 	U32 reserved1:1;
727 	U32 grpfIhdt:8;
728 	U32 rncFtn:2;		/*how to restart footnotes */
729 	U32 fFtnRestart:1;	/* Word 2 */
730 
731 	U32 nFtn:15;		/*first footnote no. WORD 2: int :15 */
732 
733 	U8 irmBar;		/* W2 */
734 	U32 irmProps:7;		/* W2 */
735 
736 	U32 fOutlineDirtySave:1;
737 	U32 reserved2:7;
738 	U32 fOnlyMacPics:1;
739 	U32 fOnlyWinPics:1;
740 	U32 fLabelDoc:1;
741 	U32 fHyphCapitals:1;
742 	U32 fAutoHyphen:1;
743 	U32 fFormNoFields:1;
744 	U32 fLinkStyles:1;
745 
746 	U32 fRevMarking:1;
747 	U32 fBackup:1;
748 	U32 fExactCWords:1;
749 	U32 fPagHidden:1;
750 	U32 fPagResults:1;
751 	U32 fLockAtn:1;
752 	U32 fMirrorMargins:1;
753 
754 	U32 fKeepFileFormat:1;	/* W2 */
755 
756 	U32 reserved3:1;
757 
758 	U32 fDfltTrueType:1;
759 	U32 fPagSuppressTopSpacing:1;
760 
761 	U32 fRTLAlignment:1;	/* W2 */
762 	U32 reserved3a:6;	/* " */
763 	U32 reserved3b:7;	/* " */
764 
765 	U32 fSpares:16;		/* W2 */
766 
767 	U32 fProtEnabled:1;
768 	U32 fDispFormFldSel:1;
769 	U32 fRMView:1;
770 	U32 fRMPrint:1;
771 	U32 reserved4:1;
772 	U32 fLockRev:1;
773 	U32 fEmbedFonts:1;
774 
775 	COPTS copts;
776 
777 	U16 dxaTab;
778 
779 	U32 ftcDefaultBi;	/* W2 */
780 
781 	U16 wSpare;
782 	U16 dxaHotZ;
783 	U16 cConsecHypLim;
784 	U16 wSpare2;
785 
786 	U32 wSpare3;		/* W2 */
787 
788 	DTTM dttmCreated;
789 	DTTM dttmRevised;
790 	DTTM dttmLastPrint;
791 
792 	U16 nRevision;
793 	U32 tmEdited;
794 	U32 cWords;
795 	U32 cCh;
796 	U16 cPg;
797 	U32 cParas;
798 
799 	U16 rgwSpareDocSum[3];	/* W2 */
800 
801 	U32 rncEdn:2;		/*how endnotes are restarted */
802 	U32 nEdn:14;		/*beginning endnote no */
803 	U32 epc:2;		/*where endnotes go */
804 	U32 nfcFtnRef:4;	/*number format code for auto footnotes, i think use the new_* instead */
805 	U32 nfcEdnRef:4;	/*number format code for auto endnotes, i thing use the new_* instead */
806 	U32 fPrintFormData:1;
807 	U32 fSaveFormData:1;
808 	U32 fShadeFormData:1;
809 	U32 reserved6:2;
810 	U32 fWCFtnEdn:1;
811 
812 	U32 cLines;
813 	U32 cWordsFtnEnd;
814 	U32 cChFtnEdn;
815 	U16 cPgFtnEdn;
816 	U32 cParasFtnEdn;
817 	U32 cLinesFtnEdn;
818 	U32 lKeyProtDoc;	/*password protection key (! ?) */
819 
820 	U32 wvkSaved:3;
821 	U32 wScaleSaved:9;
822 	U32 zkSaved:2;
823 	U32 fRotateFontW6:1;
824 	U32 iGutterPos:1;
825 	U32 fNoTabForInd:1;
826 	U32 fNoSpaceRaiseLower:1;
827 	U32 fSuppressSpbfAfterPageBreak:1;
828 	U32 fWrapTrailSpaces:1;
829 	U32 fMapPrintTextColor:1;
830 	U32 fNoColumnBalance:1;
831 	U32 fConvMailMergeEsc:1;
832 	U32 fSuppressTopSpacing:1;
833 	U32 fOrigWordTableRules:1;
834 	U32 fTransparentMetafiles:1;
835 	U32 fShowBreaksInFrames:1;
836 	U32 fSwapBordersFacingPgs:1;
837 	U32 reserved7:4;
838 
839 	U32 fSuppressTopSpacingMac5:1;
840 	U32 fTruncDxaExpand:1;
841 	U32 fPrintBodyBeforeHdr:1;
842 	U32 fNoLeading:1;
843 	U32 reserved8:1;
844 	U32 fMWSmallCaps:1;
845 	U32 reserved9:10;
846 	U32 adt:16;
847 
848 	DOPTYPOGRAPHY doptypography;
849 	DOGRID dogrid;
850 
851 	U32 reserver11:1;
852 	U32 lvl:4;
853 	U32 fGramAllDone:1;
854 	U32 fGramAllClean:1;
855 	U32 fSubsetFonts:1;
856 	U32 fHideLastVersion:1;
857 	U32 fHtmlDoc:1;
858 	U32 reserved10:1;
859 	U32 fSnapBorder:1;
860 	U32 fIncludeHeader:1;
861 	U32 fIncludeFooter:1;
862 	U32 fForcePageSizePag:1;
863 	U32 fMinFontSizePag:1;
864 	U32 fHaveVersions:1;
865 	U32 fAutoVersion:1;
866 	U32 reserved11:14;
867 
868 	ASUMYI asumyi;
869 
870 	U32 cChWS;
871 	U32 cChWSFtnEdn;
872 	U32 grfDocEvents;
873 	U32 fVirusPrompted:1;
874 	U32 fVirusLoadSafe:1;
875 	U32 KeyVirusSession30:30;
876 
877 	U8 Spare[30];
878 	U32 reserved12;
879 	U32 reserved13;
880 
881 	U32 cDBC;
882 	U32 cDBCFtnEdn;
883 	U32 reserved14;
884 	U16 new_nfcFtnRef;	/*number format code for auto footnote references */
885 	U16 new_nfcEdnRef;	/*number format code for auto endnote references */
886 	U16 hpsZoonFontPag;
887 	U16 dywDispPag;
888     } DOP;
889 
890     void wvGetDOP (wvVersion ver, DOP * dop, U32 fcDop, U32 lcbDop,
891 		   wvStream * tablefd);
892     void wvInitDOP (DOP * dop);
893 
894     typedef struct _BKF {
895 	S32 ibkl:16;
896 	U32 itcFirst:7;
897 	U32 fPub:1;
898 	U32 itcLim:7;
899 	U32 fCol:1;
900     } BKF;
901 
902     void wvGetBKF (BKF * item, wvStream * fd);
903     int wvGetBKF_PLCF (BKF ** bkf, U32 ** pos, U32 * nobkf, U32 offset, U32 len,
904 		       wvStream * fd);
905     void wvInitBKF (BKF * item);
906 
907 
908 
909     typedef struct _Xst {
910 	U16 *u16string;
911 	struct _Xst *next;
912 	U32 noofstrings;
913     } Xst;
914 
915     void wvGetXst (Xst ** xst, U32 offset, U32 len, wvStream * fd);
916     void wvFreeXst (Xst ** xst);
917 
918     typedef struct _FSPA {
919 	U32 spid;
920 	S32 xaLeft;
921 	S32 yaTop;
922 	S32 xaRight;
923 	S32 yaBottom;
924 	/* 16 bits for bitfields */
925 	U32 fHdr:1;
926 	U32 bx:2;
927 	U32 by:2;
928 	U32 wr:4;
929 	U32 wrk:4;
930 	U32 fRcaSimple:1;
931 	U32 fBelowText:1;
932 	U32 fAnchorLock:1;
933 	S32 cTxbx;
934     } FSPA;
935 
936     void wvGetFSPA (FSPA * item, wvStream * fd);
937     int wvGetFSPA_PLCF (FSPA ** fspa, U32 ** pos, U32 * nofspa, U32 offset,
938 			U32 len, wvStream * fd);
939     FSPA *wvGetFSPAFromCP (U32 currentcp, FSPA * fspa, U32 * pos, U32 nofspa);
940     void wvInitFSPA (FSPA * item);
941 
942     typedef struct _LSTF {
943 	U32 lsid;
944 	U32 tplc;
945 	U16 rgistd[9];
946 	/* 16 bits for bitfields */
947 	U32 fSimpleList:1;
948 	U32 fRestartHdn:1;
949 	U32 reserved1:6;
950 	U32 reserved2:8;
951     } LSTF;
952 
953     void wvGetLSTF (LSTF * item, wvStream * fd);
954     void wvInitLSTF (LSTF * item);
955     int wvGetLSTF_PLCF (LSTF ** lstf, U32 ** pos, U32 * nolst, U32 offset,
956 			U32 len, wvStream * fd);
957 
958     typedef struct _LVLF {
959 	U32 iStartAt;
960 	/* 16 bits for bitfield */
961 	U32 nfc:8;
962 	U32 jc:2;
963 	U32 fLegal:1;
964 	U32 fNoRestart:1;
965 	U32 fPrev:1;
966 	U32 fPrevSpace:1;
967 	U32 fWord6:1;
968 	U32 reserved1:1;
969 	U8 rgbxchNums[9];
970 	U8 ixchFollow;
971 	U32 dxaSpace;
972 	U32 dxaIndent;
973 	U8 cbGrpprlChpx;
974 	U8 cbGrpprlPapx;
975 	U16 reserved2;
976     } LVLF;
977 
978     void wvGetLVLF (LVLF * item, wvStream * fd);
979     void wvInitLVLF (LVLF * item);
980     void wvCopyLVLF (LVLF * dest, LVLF * src);
981 
982 
983 /*
984 A LVL structure contains two parts to it:
985 
986 (1) an LVLF, which stores all static data such as the start-at value for the
987 list level, the numbering type (arabic or roman), the alignment (left, right or
988 centered) of the number, and several Word 6.0 compatibility options; and
989 
990 (2) a set of pointers to variable length data:
991 
992 (a) a grpprlChpx, which gives character formatting to the paragraph number text
993 itself
994 
995 (b) a grpprlPapx, which gives paragraph formatting to the paragraph containing
996 the number, such as indenting and tab information, and
997 
998 (c) the number text itself.
999 */
1000     typedef struct _LVL {
1001 	LVLF lvlf;
1002 	U8 *grpprlPapx;
1003 	U8 *grpprlChpx;
1004 	XCHAR *numbertext;
1005     } LVL;
1006 
1007     void wvGetLVL (LVL * lvl, wvStream * fd);
1008     void wvCopyLVL (LVL * dest, LVL * src);
1009     void wvReleaseLVL (LVL * lvl);
1010     void wvInitLVL (LVL * lvl);
1011 
1012 
1013 /*
1014 An LST consists of two main parts:
1015 
1016 (1) an LSTF, which is stored on disk and contains formatting properties which
1017 apply to the entire list, such as whether the list is simple or multilevel,
1018 the list's unique list index and template code, the istd's of the styles (if
1019 any) that each level in the list is linked to, and a number of Word 6
1020 compatilibity option;
1021 
1022 (2) an array of LVL structures, which describe the appearance of each
1023 individual level in the LST.
1024 */
1025 
1026 /*
1027 (3) I have added a list of values which i will use to determine what
1028 number to use for each list entry, Caolan
1029 */
1030 
1031     typedef struct _LST {
1032 	LSTF lstf;
1033 	LVL *lvl;
1034 	U32 *current_no;
1035     } LST;
1036 
1037     int wvGetLST (LST ** lst, U16 * noofLST, U32 offset, U32 len,
1038 		  wvStream * fd);
1039     void wvReleaseLST (LST ** lst, U16 noofLST);
1040     LST *wvSearchLST (U32 id, LST * lst, U16 noofLST);
1041     int wvInitLST (LST * lst);
1042 
1043     typedef struct _LFO {
1044 	U32 lsid;
1045 	U32 reserved1;
1046 	U32 reserved2;
1047 	U8 clfolvl;
1048 	U8 reserved3[3];
1049     } LFO;
1050 
1051     void wvGetLFO (LFO * item, wvStream * fd);
1052     void wvInitLFO (LFO * item);
1053     int wvGetLFO_PLF (LFO ** lfo, U32 * nolfo, U32 offset, U32 len,
1054 		      wvStream * fd);
1055 
1056     typedef struct _LFOLVL {
1057 	U32 iStartAt;
1058 	U32 ilvl:4;
1059 	U32 fStartAt:1;
1060 	U32 fFormatting:1;
1061 	U32 reserved1:2;
1062 	U32 reserved2:8;
1063 	U32 reserved3:8;
1064 	U32 reserved4:8;
1065     } LFOLVL;
1066 
1067     void wvGetLFOLVL (LFOLVL * item, wvStream * fd);
1068     void wvInitLFOLVL (LFOLVL * item);
1069     int wvInvalidLFOLVL (LFOLVL * item);
1070 
1071     int wvGetLFO_records (LFO ** lfo, LFOLVL ** lfolvl, LVL ** lvl, U32 * nolfo,
1072 			  U32 * nooflvl, U32 offset, U32 len, wvStream * fd);
1073     int wvReleaseLFO_records (LFO ** lfo, LFOLVL ** lfolvl, LVL ** lvl,
1074 			      U32 nooflvl);
1075 
1076     U16 *wvListString (int ilfo, int ilvl, LST * alst);
1077 
1078     typedef U16 LID;
1079 
1080     typedef struct _SHD {
1081 	/*16 bits in total */
1082 	U32 icoFore:5;
1083 	U32 icoBack:5;
1084 	U32 ipat:6;
1085     } SHD;
1086 
1087     void wvGetSHD (SHD * item, wvStream * fd);
1088     void wvGetSHDFromBucket (SHD * item, U8 * pointer);
1089     void wvInitSHD (SHD * item);
1090     void wvCopySHD (SHD * dest, SHD * src);
1091 
1092 
1093     typedef struct _DCS {
1094 	/* 16 bits for bitfields */
1095 	U32 fdct:3;
1096 	U32 count:5;
1097 	U32 reserved:8;
1098     } DCS;
1099 
1100     void wvGetDCS (DCS * item, wvStream * fd);
1101     void wvGetDCSFromBucket (DCS * item, U8 * pointer);
1102     void wvInitDCS (DCS * item);
1103     void wvCopyDCS (DCS * dest, DCS * src);
1104 
1105     typedef struct _BRC {
1106 	U32 dptLineWidth:8;
1107 	U32 brcType:8;
1108 	U32 ico:8;
1109 	U32 dptSpace:5;
1110 	U32 fShadow:1;
1111 	U32 fFrame:1;
1112 	U32 reserved:1;
1113     } BRC;
1114 
1115     void wvGetBRC (wvVersion ver, BRC * abrc, wvStream * fd);
1116     int wvGetBRCFromBucket (wvVersion ver, BRC * abrc, U8 * pointer);
1117     void wvInitBRC (BRC * abrc);
1118     void wvCopyBRC (BRC * dest, BRC * src);
1119     int wvEqualBRC (BRC * a, BRC * b);
1120 
1121 
1122     typedef struct _BRC10 {
1123 	/* 16 bits in total */
1124 	U32 dxpLine2Width:3;
1125 	U32 dxpSpaceBetween:3;
1126 	U32 dxpLine1Width:3;
1127 	U32 dxpSpace:5;
1128 	U32 fShadow:1;
1129 	U32 fSpare:1;
1130     } BRC10;
1131 
1132     int wvGetBRC10FromBucket (BRC10 * item, U8 * pointer);
1133     void wvInitBRC10 (BRC10 * item);
1134     void wvConvertBRC10ToBRC (BRC * item, BRC10 * in);
1135 
1136 
1137 /*
1138 The seven types of border lines that Windows Word 1.0 supports are coded
1139 with different sets of values for dxpLine1Width, dxpSpaceBetween, and
1140 dxpLine2 Width.
1141 
1142 The border lines and their brc10 settings follow:
1143 
1144  line type        dxpLine1Width               dxpSpaceBetween dxpLine2Width
1145  no border        0                           0               0
1146 
1147  single line      1                           0               0
1148  border
1149 
1150  two single line  1                           1               1
1151  border
1152 
1153  fat solid border 4                           0               0
1154 
1155  thick solid      2                           0               0
1156  border
1157 
1158  dotted border    6 (special value meaning    0               0
1159                   dotted line)
1160 
1161  hairline border  7(special value meaning     0               0
1162                   hairline)
1163 
1164 When the no border settings are stored in the BRC, brc.fShadow and
1165 brc.dxpSpace should be set to 0.
1166 */
1167 
1168     typedef struct _LSPD {
1169 	S16 dyaLine;
1170 	S16 fMultLinespace;
1171     } LSPD;
1172 
1173     void wvCopyLSPD (LSPD * dest, LSPD * src);
1174     void wvInitLSPD (LSPD * item);
1175     void wvGetLSPDFromBucket (LSPD * item, U8 * pointer);
1176 
1177     typedef union _PHE {
1178 	struct {
1179 	    U32 fSpare:1;
1180 	    U32 fUnk:1;
1181 	    U32 fDiffLines:1;
1182 	    U32 reserved1:5;
1183 	    U32 clMac:8;
1184 	    U32 reserved2:16;
1185 	    S32 dxaCol;
1186 	    S32 dymHeight;	/*also known as dymLine and dymTableHeight in docs */
1187 	} var1;
1188 	struct {
1189 	    U32 fSpare:1;
1190 	    U32 fUnk:1;
1191 	    U32 dcpTtpNext:30;
1192 	    S32 dxaCol;
1193 	    S32 dymHeight;	/*also known as dymLine and dymTableHeight in docs */
1194 	} var2;
1195     } PHE;
1196 
1197 
1198     void wvCopyPHE (PHE * dest, PHE * src, int which);
1199     void wvInitPHE (PHE * item, int which);
1200     void wvGetPHE (PHE * dest, int which, U8 * page, U16 * pos);
1201     void wvGetPHE6 (PHE * dest, U8 * page, U16 * pos);
1202 
1203     typedef struct _NUMRM {
1204 	U8 fNumRM;
1205 	U8 Spare1;
1206 	S16 ibstNumRM;
1207 	DTTM dttmNumRM;
1208 	U8 rgbxchNums[9];
1209 	U8 rgnfc[9];
1210 	S16 Spare2;
1211 	S32 PNBR[9];
1212 	XCHAR xst[32];
1213     } NUMRM;
1214 
1215     void wvGetNUMRM (NUMRM * item, wvStream * fd);
1216     void wvGetNUMRMFromBucket (NUMRM * item, U8 * pointer);
1217     void wvCopyNUMRM (NUMRM * dest, NUMRM * src);
1218     void wvInitNUMRM (NUMRM * item);
1219 
1220     typedef struct _ANLD {
1221 	U8 nfc;
1222 	U8 cxchTextBefore;
1223 
1224 	U32 cxchTextAfter:8;
1225 	U32 jc:2;
1226 	U32 fPrev:1;
1227 	U32 fHang:1;
1228 	U32 fSetBold:1;
1229 	U32 fSetItalic:1;
1230 	U32 fSetSmallCaps:1;
1231 	U32 fSetCaps:1;
1232 	U32 fSetStrike:1;
1233 	U32 fSetKul:1;
1234 	U32 fPrevSpace:1;
1235 	U32 fBold:1;
1236 	U32 fItalic:1;
1237 	U32 fSmallCaps:1;
1238 	U32 fCaps:1;
1239 	U32 fStrike:1;
1240 	U32 kul:3;
1241 	U32 ico:5;
1242 
1243 	S16 ftc;
1244 	U16 hps;
1245 	U16 iStartAt;
1246 	S16 dxaIndent;
1247 	U16 dxaSpace;
1248 	U8 fNumber1;
1249 	U8 fNumberAcross;
1250 	U8 fRestartHdn;
1251 	U8 fSpareX;
1252 	XCHAR rgxch[32];
1253     } ANLD;
1254 
1255     void wvGetANLD (wvVersion ver, ANLD * item, wvStream * fd);
1256     void wvGetANLD_FromBucket (wvVersion ver, ANLD * item, U8 * pointer8);
1257     void wvCopyANLD (ANLD * dest, ANLD * src);
1258     void wvInitANLD (ANLD * item);
1259     U32 wvCheckSumANLD (ANLD * item);
1260 
1261 #define istdNormalChar 10
1262 
1263     typedef struct _CHP {
1264 	U32 fBold:1;
1265 	U32 fItalic:1;
1266 	U32 fRMarkDel:1;
1267 	U32 fOutline:1;
1268 	U32 fFldVanish:1;
1269 	U32 fSmallCaps:1;
1270 	U32 fCaps:1;
1271 	U32 fVanish:1;
1272 	U32 fRMark:1;
1273 	U32 fSpec:1;
1274 	U32 fStrike:1;
1275 	U32 fObj:1;
1276 	U32 fShadow:1;
1277 	U32 fLowerCase:1;
1278 	U32 fData:1;
1279 	U32 fOle2:1;
1280 
1281 	U32 fEmboss:1;
1282 	U32 fImprint:1;
1283 	U32 fDStrike:1;
1284 	S32 fUsePgsuSettings:1;	/*? */
1285 	U32 reserved1:12;
1286 	U32 reserved2;
1287 
1288 	U16 reserved11;
1289 	U16 ftc;
1290 	U16 ftcAscii;
1291 	U16 ftcFE;
1292 	U16 ftcOther;
1293 	U16 hps;
1294 	S32 dxaSpace;
1295 
1296 	U32 iss:3;
1297 	U32 kul:4;
1298 	U32 fSpecSymbol:1;
1299 	U32 ico:5;
1300 	U32 reserved3:1;
1301 	U32 fSysVanish:1;
1302 	U32 hpsPos:1;
1303 	S32 super_sub:16;
1304 
1305 	LID lid;
1306 	LID lidDefault;
1307 	LID lidFE;
1308 	U8 idct;
1309 	U8 idctHint;
1310 	U8 wCharScale;
1311 	S32 fcPic_fcObj_lTagObj;
1312 	S16 ibstRMark;
1313 	S16 ibstRMarkDel;
1314 	DTTM dttmRMark;
1315 	DTTM dttmRMarkDel;
1316 	S16 reserved4;
1317 	U16 istd;
1318 	S16 ftcSym;
1319 	XCHAR xchSym;
1320 	S16 idslRMReason;
1321 	S16 idslReasonDel;
1322 	U8 ysr;
1323 	U8 chYsr;
1324 	U16 cpg;
1325 	U16 hpsKern;
1326 
1327 	U32 icoHighlight:5;
1328 	U32 fHighlight:1;
1329 	U32 kcd:3;
1330 	U32 fNavHighlight:1;
1331 	U32 fChsDiff:1;
1332 	U32 fMacChs:1;
1333 	U32 fFtcAsciSym:1;
1334 	U32 reserved5:3;
1335 	U32 fPropRMark:16;	/*was typo of fPropMark in documentation */
1336 
1337 	S16 ibstPropRMark;
1338 	DTTM dttmPropRMark;
1339 	U8 sfxtText;
1340 	U8 reserved6;
1341 	U8 reserved7;
1342 	U16 reserved8;
1343 	U16 reserved9;
1344 	DTTM reserved10;
1345 	U8 fDispFldRMark;
1346 	S16 ibstDispFldRMark;
1347 	DTTM dttmDispFldRMark;
1348 	XCHAR xstDispFldRMark[16];
1349 	SHD shd;
1350 	BRC brc;
1351 
1352       /* BiDi properties */
1353       U32  fBidi:1;
1354       U32  fBoldBidi:1;
1355       U32  fItalicBidi:1;
1356       U16 ftcBidi;
1357       U16 hpsBidi;
1358       U8  icoBidi;
1359       LID lidBidi;
1360 
1361 	  char stylename[100];
1362 
1363     } CHP;
1364 
1365     void wvInitCHP (CHP * item);
1366     void wvCopyCHP (CHP * dest, CHP * src);
1367 
1368 #define itcMax 64
1369 
1370     typedef struct _TC {
1371 	U32 fFirstMerged:1;
1372 	U32 fMerged:1;
1373 	U32 fVertical:1;
1374 	U32 fBackward:1;
1375 	U32 fRotateFont:1;
1376 	U32 fVertMerge:1;
1377 	U32 fVertRestart:1;
1378 	U32 vertAlign:2;
1379 	U32 fUnused:7;
1380 	U32 wUnused:16;
1381 	BRC brcTop;
1382 	BRC brcLeft;
1383 	BRC brcBottom;
1384 	BRC brcRight;
1385     } TC;
1386 
1387     void wvCopyTC (TC * dest, TC * src);
1388     int wvGetTCFromBucket (wvVersion ver, TC * abrc, U8 * pointer);
1389     void wvInitTC (TC * item);
1390 
1391     typedef struct _TLP {
1392 	S32 itl:16;
1393 	U32 fBorders:1;
1394 	U32 fShading:1;
1395 	U32 fFont:1;
1396 	U32 fColor:1;
1397 	U32 fBestFit:1;
1398 	U32 fHdrRows:1;
1399 	U32 fLastRow:1;
1400 	U32 fHdrCols:1;
1401 	U32 fLastCol:1;
1402 	U32 unused:7;
1403     } TLP;
1404 
1405     void wvCopyTLP (TLP * dest, TLP * src);
1406     void wvInitTLP (TLP * item);
1407     void wvGetTLP (TLP * item, wvStream * fd);
1408     void wvGetTLPFromBucket (TLP * item, U8 * pointer);
1409 
1410     typedef struct _TAP {
1411 	S16 jc;
1412 	S32 dxaGapHalf;
1413 	S32 dyaRowHeight;
1414 	U8 fCantSplit;
1415 	U8 fTableHeader;
1416 	TLP tlp;
1417 	S32 lwHTMLProps;
1418 
1419 	U32 fCaFull:1;
1420 	U32 fFirstRow:1;
1421 	U32 fLastRow:1;
1422 	U32 fOutline:1;
1423 	U32 reserved:12;
1424 	S32 itcMac:16;
1425 
1426 	S32 dxaAdjust;
1427 	S32 dxaScale;
1428 	S32 dxsInch;
1429 	S16 rgdxaCenter[itcMax + 1];
1430 	S16 rgdxaCenterPrint[itcMax + 1];
1431 	TC rgtc[itcMax];
1432 	SHD rgshd[itcMax];
1433 	BRC rgbrcTable[6];
1434     } TAP;
1435 
1436 #define itbdMax 64
1437 
1438     void wvCopyTAP (TAP * dest, TAP * src);
1439     void wvInitTAP (TAP * item);
1440 
1441     typedef struct _TBD		/* 8 bits */
1442     {
1443 	U32 jc:3;
1444 	U32 tlc:3;
1445 	U32 reserved:2;
1446     } TBD;
1447 
1448     void wvInitTBD (TBD * item);
1449     void wvCopyTBD (TBD * dest, TBD * src);
1450     void wvGetTBD (TBD * item, wvStream * fd);
1451     void wvGetTBDFromBucket (TBD * item, U8 * pointer);
1452 
1453 	/* list information: this is an wv extension to the PAP struct */
1454 	typedef struct
1455 	{
1456 		U32     id;
1457 		S32     start;
1458 		XCHAR * numberstr;
1459 		U32     numberstr_size;
1460 		U8      format;
1461 		U8      align;
1462 		U8      ixchFollow;
1463 		CHP     chp;
1464 	}wvListInfo;
1465 
1466 
1467     typedef struct _PAP {
1468 	U16 istd;
1469 	U8 jc;
1470 	U8 fKeep;
1471 	U8 fKeepFollow;
1472 
1473 	U32 fPageBreakBefore:8;
1474 	U32 fBrLnAbove:1;
1475 	U32 fBrLnBelow:1;
1476 	U32 fUnused:2;
1477 	U32 pcVert:2;
1478 	U32 pcHorz:2;
1479 	U32 brcp:8;
1480 	U32 brcl:8;
1481 
1482 	U8 reserved1;
1483 	U8 ilvl;
1484 	U8 fNoLnn;
1485 	S16 ilfo;
1486 	U8 nLvlAnm;
1487 	U8 reserved2;
1488 	U8 fSideBySide;
1489 	U8 reserved3;
1490 	U8 fNoAutoHyph;
1491 	U8 fWidowControl;
1492 	S32 dxaRight;
1493 	S32 dxaLeft;
1494 	S32 dxaLeft1;
1495 	LSPD lspd;
1496 	U32 dyaBefore;
1497 	U32 dyaAfter;
1498 	PHE phe;
1499 	U8 fCrLf;
1500 	U8 fUsePgsuSettings;
1501 	U8 fAdjustRight;
1502 	U8 reserved4;
1503 	U8 fKinsoku;
1504 	U8 fWordWrap;
1505 	U8 fOverflowPunct;
1506 	U8 fTopLinePunct;
1507 	U8 fAutoSpaceDE;
1508 	U8 fAtuoSpaceDN;
1509 	U16 wAlignFont;
1510 
1511 	U32 fVertical:1;
1512 	U32 fBackward:1;
1513 	U32 fRotateFont:1;
1514 	U32 reserved5:13;
1515 	U32 reserved6:16;
1516 
1517 	S8 fInTable;
1518 	S8 fTtp;
1519 	U8 wr;
1520 	U8 fLocked;
1521 	TAP ptap;
1522 	S32 dxaAbs;
1523 	S32 dyaAbs;
1524 	S32 dxaWidth;
1525 	BRC brcTop;
1526 	BRC brcLeft;
1527 	BRC brcBottom;
1528 	BRC brcRight;
1529 	BRC brcBetween;
1530 	BRC brcBar;
1531 	S32 dxaFromText;
1532 	S32 dyaFromText;
1533 	/*16 bits for the next two entries */
1534 	S32 dyaHeight:15;
1535 	S32 fMinHeight:1;
1536 	SHD shd;
1537 	DCS dcs;
1538 	S8 lvl;
1539 	S8 fNumRMIns;
1540 	ANLD anld;
1541 	S16 fPropRMark;
1542 	S16 ibstPropRMark;
1543 	DTTM dttmPropRMark;
1544 	NUMRM numrm;
1545 	S16 itbdMac;
1546 	S16 rgdxaTab[itbdMax];
1547 	TBD rgtbd[itbdMax];
1548 
1549   /* TODO: Enable Word 2002 extensions; Note this will break wv ABI
1550 	S8 fNoAllowOverlap;
1551 	S32 ipgb;
1552 	S32 rsid;
1553 	S16 istdList;
1554 	S8 fContextualSpacing;
1555 	S8 fHasOldProps;
1556 	S8 rpf;
1557 	S32 hplcnf;
1558 	S8 yfti[13];
1559   */
1560 
1561 /* >>------------------PATCH */
1562 	char stylename[100];
1563 /* -----------------------<< */
1564       /* BiDi */
1565       U32 fBidi:1;
1566 		wvListInfo linfo;
1567     } PAP;
1568 
1569 #define istdNil 4095
1570 
1571     void wvCopyPAP (PAP * dest, PAP * src);
1572     void wvCopyConformPAP (PAP * dest, PAP * src);
1573     void wvInitPAP (PAP * item);
1574     int wvIsListEntry (PAP * apap, wvVersion ver);
1575     int isPAPConform (PAP * current, PAP * previous);
1576 
1577 
1578     typedef U16 BF;
1579     typedef U16 FTC;
1580 
1581 /*
1582   STSHI: STyleSHeet Information, as stored in a file
1583   Note that new fields can be added to the STSHI without invalidating
1584   the file format, because it is stored preceded by it's length.
1585   When reading a STSHI from an older version, new fields will be zero.
1586 */
1587     typedef struct _STSHI {
1588 	U16 cstd;		/* Count of styles in stylesheet */
1589 	U16 cbSTDBaseInFile;	/* Length of STD Base as stored in a file */
1590 	U32 fStdStylenamesWritten:1;	/* Are built-in stylenames stored? */
1591 	U32 reserved:15;	/* Spare flags */
1592 	U32 stiMaxWhenSaved:16;	/* Max sti known when this file was written */
1593 	U16 istdMaxFixedWhenSaved;	/* How many fixed-index istds are there? */
1594 	U16 nVerBuiltInNamesWhenSaved;	/* Current version of built-in stylenames */
1595 	FTC rgftcStandardChpStsh[3];	/* ftc used by StandardChpStsh for this document */
1596     } STSHI;
1597 
1598     void wvGetSTSHI (STSHI * item, U16 cbSTSHI, wvStream * fd);
1599     void wvInitSTSHI (STSHI * item);
1600 
1601 
1602     typedef union _UPX {
1603 	struct {
1604 	    U8 *grpprl;
1605 	} chpx;
1606 	struct {
1607 	    U16 istd;
1608 	    U8 *grpprl;
1609 	} papx;
1610 	U8 *rgb;
1611     } UPX;
1612 
1613     typedef struct _UPXF {
1614 	U16 cbUPX;
1615 	UPX upx;
1616     } UPXF;
1617 
1618     typedef struct _CHPX {
1619 	U16 istd;
1620 	U8 cbGrpprl;
1621 	U8 *grpprl;
1622     } CHPX;
1623 
1624     void wvInitCHPX (CHPX * item);
1625     void wvCopyCHPX (CHPX * dest, CHPX * src);
1626     void wvReleaseCHPX (CHPX * item);
1627     void wvGetCHPX (wvVersion ver, CHPX * item, U8 * page, U16 * pos);
1628 
1629    typedef struct _CHPX_FKP {
1630 	U32 *rgfc;
1631 	U8 *rgb;
1632 	CHPX *grpchpx;
1633 	U8 crun;
1634     } CHPX_FKP;
1635 
1636     void wvGetCHPX_FKP (wvVersion ver, CHPX_FKP * fkp, U32 pn, wvStream * fd);
1637     void wvReleaseCHPX_FKP (CHPX_FKP * fkp);
1638     void wvInitCHPX_FKP (CHPX_FKP * fkp);
1639 
1640 
1641 
1642 
1643 
1644     typedef union _UPD {
1645 	PAP apap;
1646 	CHP achp;
1647 	CHPX chpx;
1648     } UPD;
1649 
1650 /*
1651 The UPE structure is the non-zero prefix of a UPD structure
1652 
1653 For my purposes we'll call them the same, and when we get around
1654 to writing word files, when we'll make a distinction.
1655 */
1656     typedef UPD UPE;
1657 
1658 
1659 
1660 /*
1661    STD: STyle Definition
1662    The STD contains the entire definition of a style.
1663    It has two parts, a fixed-length base (cbSTDBase bytes long)
1664    and a variable length remainder holding the name, and the upx and upe
1665    arrays (a upx and upe for each type stored in the style, std.cupx)
1666    Note that new fields can be added to the BASE of the STD without
1667    invalidating the file format, because the STSHI contains the length
1668    that is stored in the file.  When reading STDs from an older version,
1669    new fields will be zero.
1670 */
1671     typedef struct _wvSTD {
1672 	/* Base part of STD: */
1673 	U32 sti:12;		/* invariant style identifier */
1674 	U32 fScratch:1;		/* spare field for any temporary use,
1675 				   always reset back to zero! */
1676 	U32 fInvalHeight:1;	/* PHEs of all text with this style are wrong */
1677 	U32 fHasUpe:1;		/* UPEs have been generated */
1678 	U32 fMassCopy:1;	/* std has been mass-copied; if unused at
1679 				   save time, style should be deleted */
1680 	U32 sgc:4;		/* style type code */
1681 	U32 istdBase:12;	/* base style */
1682 
1683 	U32 cupx:4;		/* # of UPXs (and UPEs) */
1684 	U32 istdNext:12;	/* next style */
1685 	U32 bchUpe:16;		/* offset to end of upx's, start of upe's */
1686 
1687 	/* 16 bits in the following bitfields */
1688 	U32 fAutoRedef:1;	/* auto redefine style when appropriate */
1689 	U32 fHidden:1;		/* hidden from UI? */
1690 	U32 reserved:14;	/* unused bits */
1691 
1692 		/* Variable length part of STD: */
1693 		/*	XCHAR *xstzName;*/	/* sub-names are separated by chDelimStyle */
1694 		char *xstzName;
1695 
1696 
1697 
1698 		UPXF *grupxf;		/*was UPX *grupx in the spec, but for my
1699 							  purposes its different */
1700 
1701 	/* the UPEs are not stored on the file; they are a cache of the based-on
1702 	   chain */
1703 	UPE *grupe;
1704     } STD;
1705 
1706     typedef enum {
1707 	sgcPara = 1,
1708 	sgcChp,
1709 	sgcPic,
1710 	sgcSep,
1711 	sgcTap
1712     } sgcval;
1713 
1714     int wvGetSTD (STD * item, U16 baselen, U16 fixedlen, wvStream * fd);
1715     void wvInitSTD (STD * item);
1716     void wvReleaseSTD (STD * item);
1717 
1718 
1719 /*
1720 The style sheet (STSH) is stored in the file in two parts, a STSHI and then
1721 an array of STDs. The STSHI contains general information about the following
1722 stylesheet, including how many styles are in it. After the STSHI, each style
1723 is written as an STD. Both the STSHI and each STD are preceded by a U16
1724 that indicates their length.
1725 
1726  Field     Size        Comment
1727  cbStshi   2 bytes     size of the following STSHI structure
1728  STSHI     (cbStshi)   Stylesheet Information
1729  Then for each style in the stylesheet (stshi.cstd), the following is
1730  stored:
1731  cbStd     2 bytes     size of the following STD structure
1732  STD       (cbStd)     the style description
1733 */
1734 
1735     typedef struct _STSH {
1736 	STSHI Stshi;
1737 	STD *std;
1738     } STSH;
1739 
1740     void wvGetSTSH (STSH * item, U32 offset, U32 len, wvStream * fd);
1741     void wvReleaseSTSH (STSH * item);
1742     void wvGenerateStyle (STSH * item, U16 i, U16 type);
1743 
1744 
1745     void wvInitPAPFromIstd (PAP * apap, U16 istdBase, STSH * stsh);
1746     void wvAddPAPXFromBucket (PAP * apap, UPXF * upxf, STSH * stsh,
1747 			      wvStream * data);
1748     void wvAddPAPXFromBucket6 (PAP * apap, UPXF * upxf, STSH * stsh);
1749 
1750     void wvInitCHPFromIstd (CHP * achp, U16 istdBase, STSH * stsh);
1751     void wvAddCHPXFromBucket (CHP * achp, UPXF * upxf, STSH * stsh);
1752     void wvAddCHPXFromBucket6 (CHP * achp, UPXF * upxf, STSH * stsh);
1753 
1754     void wvInitCHPXFromIstd (CHPX * chpx, U16 istdBase, STSH * stsh);
1755     void wvMergeCHPXFromBucket (CHPX * dest, UPXF * upxf);
1756     void wvUpdateCHPXBucket (UPXF * src);
1757 
1758     void wvApplyCHPXFromBucket (CHP * achp, CHPX * chpx, STSH * stsh);
1759 
1760     typedef struct _ANLV {
1761 	U8 nfc;
1762 	U8 cxchTextBefore;
1763 
1764 	U32 cxchTextAfter:8;
1765 	U32 jc:2;
1766 	U32 fPrev:1;
1767 	U32 fHang:1;
1768 	U32 fSetBold:1;
1769 	U32 fSetItalic:1;
1770 	U32 fSetSmallCaps:1;
1771 	U32 fSetCaps:1;
1772 	U32 fSetStrike:1;
1773 	U32 fSetKul:1;
1774 	U32 fPrevSpace:1;
1775 	U32 fBold:1;
1776 	U32 fItalic:1;
1777 	U32 fSmallCaps:1;
1778 	U32 fCaps:1;
1779 	U32 fStrike:1;
1780 	U32 kul:3;
1781 	U32 ico:5;
1782 
1783 	S16 ftc;
1784 	U16 hps;
1785 	U16 iStartAt;
1786 	U16 dxaIndent;
1787 	U16 dxaSpace;
1788     } ANLV;
1789 
1790     void wvInitANLV (ANLV * item);
1791 
1792     void wvGetANLV (ANLV * item, wvStream * fd);
1793     void wvGetANLVFromBucket (ANLV * item, U8 * pointer);
1794 
1795 
1796 
1797     typedef struct _OLST {
1798 	ANLV rganlv[9];
1799 	U8 fRestartHdr;
1800 	U8 fSpareOlst2;
1801 	U8 fSpareOlst3;
1802 	U8 fSpareOlst4;
1803 	XCHAR rgxch[64];
1804     } OLST;
1805 
1806     void wvInitOLST (OLST *);
1807     void wvGetOLST (wvVersion ver, OLST * item, wvStream * fd);
1808     void wvGetOLSTFromBucket (wvVersion ver, OLST * item, U8 * pointer);
1809 
1810 
1811     typedef struct _SEP {
1812 	U8 bkc;
1813 	U8 fTitlePage;
1814 	S8 fAutoPgn;
1815 	U8 nfcPgn;
1816 	U8 fUnlocked;
1817 	U8 cnsPgn;
1818 	U8 fPgnRestart;
1819 	U8 fEndNote;
1820 	U8 lnc;
1821 	S8 grpfIhdt;
1822 	U16 nLnnMod;
1823 	S32 dxaLnn;
1824 	S16 dxaPgn;
1825 	S16 dyaPgn;
1826 	S8 fLBetween;
1827 	S8 vjc;
1828 	U16 dmBinFirst;
1829 	U16 dmBinOther;
1830 	U16 dmPaperReq;
1831 	BRC brcTop;
1832 	BRC brcLeft;
1833 	BRC brcBottom;
1834 	BRC brcRight;
1835 	S16 fPropRMark;
1836 	S16 ibstPropRMark;
1837 	DTTM dttmPropRMark;
1838 	S32 dxtCharSpace;
1839 	S32 dyaLinePitch;
1840 	U16 clm;
1841 	S16 reserved1;
1842 	U8 dmOrientPage;
1843 	U8 iHeadingPgn;
1844 	U16 pgnStart;
1845 	S16 lnnMin;
1846 	S16 wTextFlow;
1847 	S16 reserved2;
1848 
1849 	S32 pgbProp:16;
1850 	U32 pgbApplyTo:3;
1851 	U32 pgbPageDepth:2;
1852 	U32 pgbOffsetFrom:3;
1853 	U32 reserved:8;
1854 
1855 	U32 xaPage;
1856 	U32 yaPage;
1857 	U32 xaPageNUp;
1858 	U32 yaPageNUp;
1859 	U32 dxaLeft;
1860 	U32 dxaRight;
1861 	S32 dyaTop;
1862 	S32 dyaBottom;
1863 	U32 dzaGutter;
1864 	U32 dyaHdrTop;
1865 	U32 dyaHdrBottom;
1866 	S16 ccolM1;
1867 	S8 fEvenlySpaced;
1868 	S8 reserved3;
1869 	S32 dxaColumns;
1870 	S32 rgdxaColumnWidthSpacing[89];
1871 	S32 dxaColumnWidth;
1872 	U8 dmOrientFirst;
1873 	U8 fLayout;
1874 	S16 reserved4;
1875 	OLST olstAnm;
1876 	U8 fBidi;
1877     } SEP;
1878 
1879     void wvInitSEP (SEP * item);
1880 
1881     typedef struct _SEPX {
1882 	U16 cb;
1883 	U8 *grpprl;
1884     } SEPX;
1885 
1886     void wvGetSEPX (wvVersion ver, SEPX * item, wvStream * fd);
1887     void wvReleaseSEPX (SEPX * item);
1888     int wvAddSEPXFromBucket (SEP * asep, SEPX * item, STSH * stsh);
1889     int wvAddSEPXFromBucket6 (SEP * asep, SEPX * item, STSH * stsh);
1890 
1891     typedef struct _Sprm {
1892 	/*16 bits in total */
1893 	U32 ispmd:9;		/*ispmd unique identifier within sgc group */
1894 	U32 fSpec:1;		/*fSpec sprm requires special handling */
1895 	U32 sgc:3;		/*sgc   sprm group; type of sprm (PAP, CHP, etc) */
1896 	U32 spra:3;		/*spra  size of sprm argument */
1897     } Sprm;
1898 
1899 
1900 
1901     Sprm wvApplySprmFromBucket (wvVersion ver, U16 sprm, PAP * apap, CHP * achp,
1902 				SEP * asep, STSH * stsh, U8 * pointer,
1903 				U16 * pos, wvStream * data);
1904 
1905     int wvSprmLen (int spra);
1906     void wvGetSprmFromU16 (Sprm * Sprm, U16 sprm);
1907     U8 wvEatSprm (U16 sprm, U8 * pointer, U16 * pos);
1908 
1909     typedef enum _SprmName {
1910 	/*
1911 	   these ones are ones I made up entirely to match
1912 	   unnamed patterns in word 95 files, whose
1913 	   purpose is currently unknown
1914 	 */
1915 	sprmTUNKNOWN1 = 0xD400,
1916 	sprmPUNKNOWN2 = 0x2400,	/* word 7 0x39 */
1917 	sprmPUNKNOWN3 = 0x2401,	/* word 7 0x3a */
1918 	sprmPUNKNOWN4 = 0x4400,	/* word 7 0x3b */
1919 	sprmCUNKNOWN5 = 0x4800,	/* word 7 0x6f */
1920 	sprmCUNKNOWN6 = 0x4801,	/* word 7 0x70 */
1921 	sprmCUNKNOWN7 = 0x4802,	/* word 7 0x71 */
1922 
1923 
1924 	/*
1925 	   these ones showed up in rgsprmPrm and are mostly
1926 	   out of date i reckon
1927 	 */
1928 	sprmNoop = 0x0000,	/* this makes sense */
1929 	sprmPPnbrRMarkNot = 0x0000,	/* never seen this one */
1930 
1931 	/*
1932 	   this subset were not listed in word 8, but i recreated them
1933 	   from the word 8 guidelines and the original word 6, so
1934 	   basically they will blow things up when ms decides to reuse them
1935 	   in word 2000 or later versions, but what the hell...
1936 	 */
1937 	sprmCFStrikeRM = 0x0841,
1938 	sprmPNLvlAnm = 0x240D,
1939 	sprmCFtc = 0x483D,
1940 	/*end subset */
1941 
1942 	/*
1943 	   one of the sprm's that shows up in word 6 docs is "0", which
1944 	   appears to be either the pap.istd or just an index, seeing
1945 	   as the word 6 people didn't list it, lets just ignore it.
1946 	   as it only happens in word 6 docs, our code happens to
1947 	   function fine in the current setup, but at some stage
1948 	   im sure it will bite me hard
1949 	 */
1950 
1951 	sprmPIstd = 0x4600,
1952 	sprmPIstdPermute = 0xC601,
1953 	sprmPIncLvl = 0x2602,
1954 	sprmPJc = 0x2403,
1955 	sprmPFSideBySide = 0x2404,
1956 	sprmPFKeep = 0x2405,
1957 	sprmPFKeepFollow = 0x2406,
1958 	sprmPFPageBreakBefore = 0x2407,
1959 	sprmPBrcl = 0x2408,
1960 	sprmPBrcp = 0x2409,
1961 	sprmPIlvl = 0x260A,
1962 	sprmPIlfo = 0x460B,
1963 	sprmPFNoLineNumb = 0x240C,
1964 	sprmPChgTabsPapx = 0xC60D,
1965 	sprmPDxaRight = 0x840E,
1966 	sprmPDxaLeft = 0x840F,
1967 	sprmPNest = 0x4610,
1968 	sprmPDxaLeft1 = 0x8411,
1969 	sprmPDyaLine = 0x6412,
1970 	sprmPDyaBefore = 0xA413,
1971 	sprmPDyaAfter = 0xA414,
1972 	sprmPChgTabs = 0xC615,
1973 	sprmPFInTable = 0x2416,
1974 	sprmPFTtp = 0x2417,
1975 	sprmPDxaAbs = 0x8418,
1976 	sprmPDyaAbs = 0x8419,
1977 	sprmPDxaWidth = 0x841A,
1978 	sprmPPc = 0x261B,
1979 	sprmPBrcTop10 = 0x461C,
1980 	sprmPBrcLeft10 = 0x461D,
1981 	sprmPBrcBottom10 = 0x461E,
1982 	sprmPBrcRight10 = 0x461F,
1983 	sprmPBrcBetween10 = 0x4620,
1984 	sprmPBrcBar10 = 0x4621,
1985 	sprmPDxaFromText10 = 0x4622,
1986 	sprmPWr = 0x2423,
1987 	sprmPBrcTop = 0x6424,
1988 	sprmPBrcLeft = 0x6425,
1989 	sprmPBrcBottom = 0x6426,
1990 	sprmPBrcRight = 0x6427,
1991 	sprmPBrcBetween = 0x6428,
1992 	sprmPBrcBar = 0x6629,
1993 	sprmPFNoAutoHyph = 0x242A,
1994 	sprmPWHeightAbs = 0x442B,
1995 	sprmPDcs = 0x442C,
1996 	sprmPShd = 0x442D,
1997 	sprmPDyaFromText = 0x842E,
1998 	sprmPDxaFromText = 0x842F,
1999 	sprmPFLocked = 0x2430,
2000 	sprmPFWidowControl = 0x2431,
2001 	sprmPRuler = 0xC632,
2002 	sprmPFKinsoku = 0x2433,
2003 	sprmPFWordWrap = 0x2434,
2004 	sprmPFOverflowPunct = 0x2435,
2005 	sprmPFTopLinePunct = 0x2436,
2006 	sprmPFAutoSpaceDE = 0x2437,
2007 	sprmPFAutoSpaceDN = 0x2438,
2008 	sprmPWAlignFont = 0x4439,
2009 	sprmPFrameTextFlow = 0x443A,
2010 	sprmPISnapBaseLine = 0x243B,
2011 	sprmPAnld = 0xC63E,
2012 	sprmPPropRMark = 0xC63F,
2013 	sprmPOutLvl = 0x2640,
2014 	sprmPFBiDi = 0x2441,
2015 	sprmPFNumRMIns = 0x2443,
2016 	sprmPCrLf = 0x2444,
2017 	sprmPNumRM = 0xC645,
2018 	sprmPHugePapx = 0x6645,
2019 	sprmPHugePapx2 = 0x6646,	/* this is the one I have found in
2020 					   the wild, maybe the doc is incorrect
2021 					   in numbering it 6645 C. */
2022 	sprmPFUsePgsuSettings = 0x2447,
2023 	sprmPFAdjustRight = 0x2448,
2024 	sprmPItap = 0x6649,
2025 	sprmPRsid = 0x6467,
2026 	sprmCRsidText = 0x6816,
2027 
2028 	sprmCFRMarkDel = 0x0800,
2029 	sprmCFRMark = 0x0801,
2030 	sprmCFFldVanish = 0x0802,
2031 	sprmCPicLocation = 0x6A03,
2032 	sprmCIbstRMark = 0x4804,
2033 	sprmCDttmRMark = 0x6805,
2034 	sprmCFData = 0x0806,
2035 	sprmCIdslRMark = 0x4807,
2036 	sprmCChs = 0xEA08,
2037 	sprmCSymbol = 0x6A09,
2038 	sprmCFOle2 = 0x080A,
2039 	sprmCIdCharType = 0x480B,
2040 	sprmCHighlight = 0x2A0C,
2041 	sprmCObjLocation = 0x680E,
2042 	sprmCFFtcAsciSymb = 0x2A10,
2043 	sprmCIstd = 0x4A30,
2044 	sprmCIstdPermute = 0xCA31,
2045 	sprmCDefault = 0x2A32,
2046 	sprmCPlain = 0x2A33,
2047 	sprmCKcd = 0x2A34,
2048 	sprmCFBold = 0x0835,
2049 	sprmCFItalic = 0x0836,
2050 	sprmCFStrike = 0x0837,
2051 	sprmCFOutline = 0x0838,
2052 	sprmCFShadow = 0x0839,
2053 	sprmCFSmallCaps = 0x083A,
2054 	sprmCFCaps = 0x083B,
2055 	sprmCFVanish = 0x083C,
2056 	sprmCFtcDefault = 0x4A3D,
2057 	sprmCKul = 0x2A3E,
2058 	sprmCSizePos = 0xEA3F,
2059 	sprmCDxaSpace = 0x8840,
2060 	sprmCLid = 0x4A41,
2061 	sprmCIco = 0x2A42,
2062 	sprmCHps = 0x4A43,
2063 	sprmCHpsInc = 0x2A44,
2064 	sprmCHpsPos = 0x4845,
2065 	sprmCHpsPosAdj = 0x2A46,
2066 	sprmCMajority = 0xCA47,
2067 	sprmCIss = 0x2A48,
2068 	sprmCHpsNew50 = 0xCA49,
2069 	sprmCHpsInc1 = 0xCA4A,
2070 	sprmCHpsKern = 0x484B,
2071 	sprmCMajority50 = 0xCA4C,
2072 	sprmCHpsMul = 0x4A4D,
2073 	sprmCYsri = 0x484E,
2074 	sprmCRgFtc0 = 0x4A4F,
2075 	sprmCRgFtc1 = 0x4A50,
2076 	sprmCRgFtc2 = 0x4A51,
2077 	sprmCCharScale = 0x4852,
2078 	sprmCFDStrike = 0x2A53,
2079 	sprmCFImprint = 0x0854,
2080 	sprmCFSpec = 0x0855,
2081 	sprmCFObj = 0x0856,
2082 	sprmCPropRMark = 0xCA57,
2083 	sprmCFEmboss = 0x0858,
2084 	sprmCSfxText = 0x2859,
2085 	sprmCFBiDi = 0x085A,
2086 	sprmCFDiacColor = 0x085B,
2087 	sprmCFBoldBi = 0x085C,
2088 	sprmCFItalicBi = 0x085D,
2089 	sprmCFtcBi = 0x4A5E,
2090 	sprmCLidBi = 0x485F,
2091 	sprmCIcoBi = 0x4A60,
2092 	sprmCHpsBi = 0x4A61,
2093 	sprmCDispFldRMark = 0xCA62,
2094 	sprmCIbstRMarkDel = 0x4863,
2095 	sprmCDttmRMarkDel = 0x6864,
2096 	sprmCBrc = 0x6865,
2097 	sprmCShd = 0x4866,
2098 	sprmCIdslRMarkDel = 0x4867,
2099 	sprmCFUsePgsuSettings = 0x0868,
2100 	sprmCCpg = 0x486B,
2101 	sprmCRgLid0 = 0x486D,
2102 	sprmCRgLid1 = 0x486E,
2103 	sprmCIdctHint = 0x286F,
2104 
2105 	sprmPicBrcl = 0x2E00,
2106 	sprmPicScale = 0xCE01,
2107 	sprmPicBrcTop = 0x6C02,
2108 	sprmPicBrcLeft = 0x6C03,
2109 	sprmPicBrcBottom = 0x6C04,
2110 	sprmPicBrcRight = 0x6C05,
2111 
2112 	sprmScnsPgn = 0x3000,
2113 	sprmSiHeadingPgn = 0x3001,
2114 	sprmSOlstAnm = 0xD202,
2115 	sprmSDxaColWidth = 0xF203,
2116 	sprmSDxaColSpacing = 0xF204,
2117 	sprmSFEvenlySpaced = 0x3005,
2118 	sprmSFProtected = 0x3006,
2119 	sprmSDmBinFirst = 0x5007,
2120 	sprmSDmBinOther = 0x5008,
2121 	sprmSBkc = 0x3009,
2122 	sprmSFTitlePage = 0x300A,
2123 	sprmSCcolumns = 0x500B,
2124 	sprmSDxaColumns = 0x900C,
2125 	sprmSFAutoPgn = 0x300D,
2126 	sprmSNfcPgn = 0x300E,
2127 	sprmSDyaPgn = 0xB00F,
2128 	sprmSDxaPgn = 0xB010,
2129 	sprmSFPgnRestart = 0x3011,
2130 	sprmSFEndnote = 0x3012,
2131 	sprmSLnc = 0x3013,
2132 	sprmSGprfIhdt = 0x3014,
2133 	sprmSNLnnMod = 0x5015,
2134 	sprmSDxaLnn = 0x9016,
2135 	sprmSDyaHdrTop = 0xB017,
2136 	sprmSDyaHdrBottom = 0xB018,
2137 	sprmSLBetween = 0x3019,
2138 	sprmSVjc = 0x301A,
2139 	sprmSLnnMin = 0x501B,
2140 	sprmSPgnStart = 0x501C,
2141 	sprmSBOrientation = 0x301D,
2142 	sprmSBCustomize = 0x301E,
2143 	sprmSXaPage = 0xB01F,
2144 	sprmSYaPage = 0xB020,
2145 	sprmSDxaLeft = 0xB021,
2146 	sprmSDxaRight = 0xB022,
2147 	sprmSDyaTop = 0x9023,
2148 	sprmSDyaBottom = 0x9024,
2149 	sprmSDzaGutter = 0xB025,
2150 	sprmSDmPaperReq = 0x5026,
2151 	sprmSPropRMark = 0xD227,
2152 	sprmSFBiDi = 0x3228,
2153 	sprmSFFacingCol = 0x3229,
2154 	sprmSFRTLGutter = 0x322A,
2155 	sprmSBrcTop = 0x702B,
2156 	sprmSBrcLeft = 0x702C,
2157 	sprmSBrcBottom = 0x702D,
2158 	sprmSBrcRight = 0x702E,
2159 	sprmSPgbProp = 0x522F,
2160 	sprmSDxtCharSpace = 0x7030,
2161 	sprmSDyaLinePitch = 0x9031,
2162 	sprmSClm = 0x5032,
2163 	sprmSTextFlow = 0x5033,
2164 
2165 	sprmTJc = 0x5400,
2166 	sprmTDxaLeft = 0x9601,
2167 	sprmTDxaGapHalf = 0x9602,
2168 	sprmTFCantSplit = 0x3403,
2169 	sprmTTableHeader = 0x3404,
2170 	sprmTTableBorders = 0xD605,
2171 	sprmTDefTable10 = 0xD606,
2172 	sprmTDyaRowHeight = 0x9407,
2173 	sprmTDefTable = 0xD608,
2174 	sprmTDefTableShd = 0xD609,
2175 	sprmTTlp = 0x740A,
2176 	sprmTFBiDi = 0x560B,
2177 	sprmTHTMLProps = 0x740C,
2178 	sprmTSetBrc = 0xD620,
2179 	sprmTInsert = 0x7621,
2180 	sprmTDelete = 0x5622,
2181 	sprmTDxaCol = 0x7623,
2182 	sprmTMerge = 0x5624,
2183 	sprmTSplit = 0x5625,
2184 	sprmTSetBrc10 = 0xD626,
2185 	sprmTSetShd = 0x7627,
2186 	sprmTSetShdOdd = 0x7628,
2187 	sprmTTextFlow = 0x7629,
2188 	sprmTDiagLine = 0xD62A,
2189 	sprmTVertMerge = 0xD62B,
2190 	sprmTVertAlign = 0xD62C
2191     } SprmName;
2192 
2193     SprmName wvGetrgsprmWord6 (U8 in);
2194 
2195     void wvApplysprmPIstdPermute (PAP * apap, U8 * pointer, U16 * pos);
2196     void wvApplysprmPIncLvl (PAP * apap, U8 * pointer, U16 * pos);
2197     void wvApplysprmPChgTabsPapx (PAP * apap, U8 * pointer, U16 * pos);
2198     int wvApplysprmPChgTabs (PAP * apap, U8 * pointer, U16 * len);
2199     void wvApplysprmPPc (PAP * apap, U8 * pointer, U16 * len);
2200     void wvApplysprmPFrameTextFlow (PAP * apap, U8 * pointer, U16 * pos);
2201     void wvApplysprmPAnld (wvVersion ver, PAP * apap, U8 * pointer, U16 * pos);
2202     void wvApplysprmPPropRMark (PAP * apap, U8 * pointer, U16 * pos);
2203     void wvApplysprmPNumRM (PAP * apap, U8 * pointer, U16 * pos);
2204     void wvApplysprmPHugePapx (PAP * apap, U8 * pointer, U16 * pos,
2205 			       wvStream * data, STSH * stsh);
2206 
2207     void wvApplysprmCChs (CHP * achp, U8 * pointer, U16 * pos);	/*unfinished */
2208     void wvApplysprmCSymbol (wvVersion ver, CHP * achp, U8 * pointer,
2209 			     U16 * pos);
2210     void wvApplysprmCIstdPermute (CHP * achp, U8 * pointer, U16 * pos);	/*unfinished */
2211     void wvApplysprmCDefault (CHP * achp, U8 * pointer, U16 * pos);
2212     void wvApplysprmCPlain (CHP * achp, STSH * stsh);
2213     void wvApplysprmCHpsInc (CHP * achp, U8 * pointer, U16 * pos);	/*unfinished */
2214     void wvApplysprmCSizePos (CHP * achp, U8 * pointer, U16 * pos);	/*unfinished */
2215     void wvApplysprmCHpsPosAdj (CHP * achp, U8 * pointer, U16 * pos);	/*unfinished */
2216     void wvApplysprmCMajority (CHP * achp, STSH * stsh, U8 * pointer, U16 * pos);	/*possibly wrong */
2217     void wvApplysprmCMajority50 (CHP * achp, STSH * stsh, U8 * pointer, U16 * pos);	/*possibly wrong */
2218     void wvApplysprmCHpsInc1 (CHP * achp, U8 * pointer, U16 * pos);
2219     void wvApplysprmCPropRMark (CHP * achp, U8 * pointer, U16 * pos);
2220     void wvApplysprmCDispFldRMark (CHP * achp, U8 * pointer, U16 * pos);
2221 
2222     void wvApplysprmSOlstAnm (wvVersion ver, SEP * asep, U8 * pointer,
2223 			      U16 * pos);
2224     void wvApplysprmSPropRMark (SEP * asep, U8 * pointer, U16 * pos);
2225 
2226     void wvApplysprmTDxaLeft (TAP * tap, U8 * pointer, U16 * pos);
2227     void wvApplysprmTDxaGapHalf (TAP * tap, U8 * pointer, U16 * pos);
2228     void wvApplysprmTTableBorders (wvVersion ver, TAP * tap, U8 * pointer,
2229 				   U16 * pos);
2230     void wvApplysprmTDefTable (TAP * tap, U8 * pointer, U16 * pos);
2231     void wvApplysprmTDefTable10 (TAP * tap, U8 * pointer, U16 * pos);
2232     void wvApplysprmTDefTableShd (TAP * tap, U8 * pointer, U16 * pos);
2233     void wv2ApplysprmTDefTableShd (TAP * tap, U8 * pointer, U16 * pos);
2234     void wvApplysprmTSetBrc (wvVersion ver, TAP * tap, U8 * pointer, U16 * pos);
2235     void wvApplysprmTInsert (TAP * tap, U8 * pointer, U16 * pos);
2236     void wvApplysprmTDelete (TAP * tap, U8 * pointer, U16 * pos);
2237     void wvApplysprmTDxaCol (TAP * tap, U8 * pointer, U16 * pos);
2238     void wvApplysprmTMerge (TAP * tap, U8 * pointer, U16 * pos);
2239     void wvApplysprmTSplit (TAP * tap, U8 * pointer, U16 * pos);
2240     void wvApplysprmTSetBrc10 (TAP * tap, U8 * pointer, U16 * pos);
2241     void wvApplysprmTSetShd (TAP * tap, U8 * pointer, U16 * pos);
2242     void wvApplysprmTSetShdOdd (TAP * tap, U8 * pointer, U16 * pos);
2243     void wvApplysprmTTextFlow (TAP * tap, U8 * pointer, U16 * pos);
2244     void wvApplysprmTVertMerge (TAP * tap, U8 * pointer, U16 * pos);
2245     void wvApplysprmTVertAlign (TAP * tap, U8 * pointer, U16 * pos);
2246 
2247 
2248     U8 wvToggle (U8 in, U8 toggle);
2249 
2250     typedef enum {
2251 	UTF8,
2252 	ISO_8859_15,
2253 	KOI8,
2254 	TIS620,
2255 	/*add your own charset here */
2256 	CharsetTableSize	/* must be last entry on pain of death */
2257     } wvCharset;
2258 
2259 
2260     typedef enum _FIELDCODE {
2261 	FC_OTHER = 0,
2262 	FC_TIME,
2263 	FC_DateTimePicture,
2264 	FC_HYPERLINK,
2265 	FC_EDITTIME,
2266 	FC_TOC,
2267 	FC_TOC_FROM_RANGE,
2268 	FC_PAGEREF,
2269 	FC_EMBED,
2270 	FC_SPEICHERDAT,
2271 	FC_DATEINAME,
2272 	FieldCodeTableSize	/*must be last entry on pain of death */
2273     } FIELDCODE;
2274 
2275     typedef enum _TT {
2276 	TT_OTHER = 0,
2277 	TT_DOCUMENT,
2278 	TT_BEGIN,
2279 	TT_END,
2280 	TT_TITLE,
2281 	TT_PARA,
2282 	TT_CHARSET,
2283 	TT_VERSION,
2284 	TT_JUSTIFICATION,
2285 	TT_JUST,
2286 	TT_LEFT,
2287 	TT_RIGHT,
2288 	TT_CENTER,
2289 	TT_BLOCK,
2290 	TT_ASIAN,
2291 	TT_SECTION,
2292 	TT_BOLD,
2293 	TT_CHAR,
2294 	TT_BOLDB,
2295 	TT_BOLDE,
2296 	TT_ITALIC,
2297 	TT_ITALICB,
2298 	TT_ITALICE,
2299 	TT_STRIKE,
2300 	TT_STRIKEB,
2301 	TT_STRIKEE,
2302 	TT_RMarkDel,
2303 	TT_RMarkDelB,
2304 	TT_RMarkDelE,
2305 	TT_OUTLINE,
2306 	TT_OUTLINEB,
2307 	TT_OUTLINEE,
2308 	TT_SMALLCAPS,
2309 	TT_SMALLCAPSB,
2310 	TT_SMALLCAPSE,
2311 	TT_CAPS,
2312 	TT_CAPSB,
2313 	TT_CAPSE,
2314 	TT_VANISH,
2315 	TT_VANISHB,
2316 	TT_VANISHE,
2317 	TT_RMark,
2318 	TT_RMarkB,
2319 	TT_RMarkE,
2320 	TT_SHADOW,
2321 	TT_SHADOWB,
2322 	TT_SHADOWE,
2323 	TT_LOWERCASE,
2324 	TT_LOWERCASEB,
2325 	TT_LOWERCASEE,
2326 	TT_EMBOSS,
2327 	TT_EMBOSSB,
2328 	TT_EMBOSSE,
2329 	TT_IMPRINT,
2330 	TT_IMPRINTB,
2331 	TT_IMPRINTE,
2332 	TT_DSTRIKE,
2333 	TT_DSTRIKEB,
2334 	TT_DSTRIKEE,
2335 	TT_SUPER,
2336 	TT_SUPERB,
2337 	TT_SUPERE,
2338 	TT_SUB,
2339 	TT_SUBB,
2340 	TT_SUBE,
2341 	TT_SINGLEU,
2342 	TT_SINGLEUB,
2343 	TT_SINGLEUE,
2344 	TT_WORDU,
2345 	TT_WORDUB,
2346 	TT_WORDUE,
2347 	TT_DOUBLEU,
2348 	TT_DOUBLEUB,
2349 	TT_DOUBLEUE,
2350 	TT_DOTTEDU,
2351 	TT_DOTTEDUB,
2352 	TT_DOTTEDUE,
2353 	TT_HIDDENU,
2354 	TT_HIDDENUB,
2355 	TT_HIDDENUE,
2356 	TT_THICKU,
2357 	TT_THICKUB,
2358 	TT_THICKUE,
2359 	TT_DASHU,
2360 	TT_DASHUB,
2361 	TT_DASHUE,
2362 	TT_DOTU,
2363 	TT_DOTUB,
2364 	TT_DOTUE,
2365 	TT_DOTDASHU,
2366 	TT_DOTDASHUB,
2367 	TT_DOTDASHUE,
2368 	TT_DOTDOTDASHU,
2369 	TT_DOTDOTDASHUB,
2370 	TT_DOTDOTDASHUE,
2371 	TT_WAVEU,
2372 	TT_WAVEUB,
2373 	TT_WAVEUE,
2374 	TT_BLACK,
2375 	TT_BLACKB,
2376 	TT_BLACKE,
2377 	TT_BLUE,
2378 	TT_BLUEB,
2379 	TT_BLUEE,
2380 	TT_CYAN,
2381 	TT_CYANB,
2382 	TT_CYANE,
2383 	TT_GREEN,
2384 	TT_GREENB,
2385 	TT_GREENE,
2386 	TT_MAGENTA,
2387 	TT_MAGENTAB,
2388 	TT_MAGENTAE,
2389 	TT_RED,
2390 	TT_REDB,
2391 	TT_REDE,
2392 	TT_YELLOW,
2393 	TT_YELLOWB,
2394 	TT_YELLOWE,
2395 	TT_WHITE,
2396 	TT_WHITEB,
2397 	TT_WHITEE,
2398 	TT_DKBLUE,
2399 	TT_DKBLUEB,
2400 	TT_DKBLUEE,
2401 	TT_DKCYAN,
2402 	TT_DKCYANB,
2403 	TT_DKCYANE,
2404 	TT_DKGREEN,
2405 	TT_DKGREENB,
2406 	TT_DKGREENE,
2407 	TT_DKMAGENTA,
2408 	TT_DKMAGENTAB,
2409 	TT_DKMAGENTAE,
2410 	TT_DKRED,
2411 	TT_DKREDB,
2412 	TT_DKREDE,
2413 	TT_DKYELLOW,
2414 	TT_DKYELLOWB,
2415 	TT_DKYELLOWE,
2416 	TT_DKGRAY,
2417 	TT_DKGRAYB,
2418 	TT_DKGRAYE,
2419 	TT_LTGRAY,
2420 	TT_LTGRAYB,
2421 	TT_LTGRAYE,
2422 	TT_FONTSTR,
2423 	TT_FONTSTRB,
2424 	TT_FONTSTRE,
2425 	TT_COLOR,
2426 	TT_COLORB,
2427 	TT_COLORE,
2428 	TT_ibstRMark,
2429 	TT_ibstRMarkDel,
2430 	TT_dttmRMark,
2431 	TT_dttmRMarkDel,
2432 	TT_PropRMark,
2433 	TT_PropRMarkB,
2434 	TT_PropRMarkE,
2435 	TT_ibstPropRMark,
2436 	TT_dttmPropRMark,
2437 	TT_LasVegas,
2438 	TT_LasVegasB,
2439 	TT_LasVegasE,
2440 	TT_BackgroundBlink,
2441 	TT_BackgroundBlinkB,
2442 	TT_BackgroundBlinkE,
2443 	TT_SparkleText,
2444 	TT_SparkleTextB,
2445 	TT_SparkleTextE,
2446 	TT_MarchingAnts,
2447 	TT_MarchingAntsB,
2448 	TT_MarchingAntsE,
2449 	TT_MarchingRedAnts,
2450 	TT_MarchingRedAntsB,
2451 	TT_MarchingRedAntsE,
2452 	TT_Shimmer,
2453 	TT_ShimmerB,
2454 	TT_ShimmerE,
2455 	TT_ANIMATION,
2456 	TT_ANIMATIONB,
2457 	TT_ANIMATIONE,
2458 	TT_DispFldRMark,
2459 	TT_DispFldRMarkB,
2460 	TT_DispFldRMarkE,
2461 	TT_ibstDispFldRMark,
2462 	TT_dttmDispFldRMark,
2463 	TT_xstDispFldRMark,
2464 	TT_OLIST,
2465 	TT_OLISTB,
2466 	TT_OLISTE,
2467 	TT_ULIST,
2468 	TT_ULISTB,
2469 	TT_ULISTE,
2470 	TT_ENTRY,
2471 	TT_ENTRYB,
2472 	TT_ENTRYE,
2473 	TT_numbering,
2474 	TT_Arabic,
2475 	TT_UpperRoman,
2476 	TT_LowerRoman,
2477 	TT_UpperCaseN,
2478 	TT_LowerCaseN,
2479 	TT_nfc,
2480 	TT_START,
2481 	TT_TABLE,
2482 	TT_TABLEB,
2483 	TT_TABLEE,
2484 	TT_ROW,
2485 	TT_ROWB,
2486 	TT_ROWE,
2487 	TT_CELL,
2488 	TT_CELLB,
2489 	TT_CELLE,
2490 	TT_LASTCELL,
2491 	TT_LASTCELLB,
2492 	TT_LASTCELLE,
2493 	TT_COLSPAN,
2494 	TT_ROWSPAN,
2495 	TT_TEXT,
2496 	TT_TEXTB,
2497 	TT_TEXTE,
2498 	TT_CELLRELWIDTH,
2499 	TT_CELLRELPAGEWIDTH,
2500 	TT_CELLBGCOLOR,
2501 	TT_TABLERELWIDTH,
2502 	TT_STYLE,
2503 	TT_COMMENT,
2504 	TT_IBSTANNO,
2505 	TT_xstUsrInitl,
2506 	TT_mmParaBefore,
2507 	TT_mmParaAfter,
2508 	TT_mmParaLeft,
2509 	TT_mmParaRight,
2510 	TT_mmParaLeft1,
2511 
2512 	TT_BORDER,
2513 	TT_NONED,
2514 	TT_SINGLED,
2515 	TT_THICKD,
2516 	TT_DOUBLED,
2517 	TT_NUMBER4D,
2518 	TT_HAIRLINED,
2519 	TT_DOTD,
2520 	TT_DASHLARGEGAPD,
2521 	TT_DOTDASHD,
2522 	TT_DOTDOTDASHD,
2523 	TT_TRIPLED,
2524 	TT_thin_thicksmallgapD,
2525 	TT_thick_thinsmallgapD,
2526 	TT_thin_thick_thinsmallgapD,
2527 	TT_thin_thickmediumgapD,
2528 	TT_thick_thinmediumgapD,
2529 	TT_thin_thick_thinmediumgapD,
2530 	TT_thin_thicklargegapD,
2531 	TT_thick_thinlargegapD,
2532 	TT_thin_thick_thinlargegapD,
2533 	TT_WAVED,
2534 	TT_DOUBLEWAVED,
2535 	TT_DASHSMALLGAPD,
2536 	TT_DASHDOTSTROKEDD,
2537 	TT_EMBOSS3DD,
2538 	TT_ENGRAVE3DD,
2539 	TT_DEFAULTD,
2540 	TT_BORDERTopSTYLE,
2541 	TT_BORDERTopCOLOR,
2542 	TT_BORDERLeftSTYLE,
2543 	TT_BORDERLeftCOLOR,
2544 	TT_BORDERRightSTYLE,
2545 	TT_BORDERRightCOLOR,
2546 	TT_BORDERBottomSTYLE,
2547 	TT_BORDERBottomCOLOR,
2548 	TT_mmPadTop,
2549 	TT_mmPadRight,
2550 	TT_mmPadBottom,
2551 	TT_mmPadLeft,
2552 	TT_mmLineHeight,
2553 	TT_PARABGCOLOR,
2554 	TT_PARAFGCOLOR,
2555 	TT_PICTURE,
2556 	TT_pixPicWidth,
2557 	TT_pixPicHeight,
2558 	TT_htmlAlignGuess,
2559 	TT_htmlNextLineGuess,
2560 	TT_PMARGIN,
2561 	TT_PBORDER,
2562 	TT_PARAMARGIN,
2563 	TT_PARABORDER,
2564 	TT_TABLEOVERRIDES,
2565 	TT_ParaBefore,
2566 	TT_ParaAfter,
2567 	TT_ParaLeft,
2568 	TT_ParaRight,
2569 	TT_ParaLeft1,
2570 	TT_FILENAME,
2571 	TT_htmlgraphic,
2572 	TT_no_rows,
2573 	TT_no_cols,
2574 	TT_CHARENTITY,
2575 	TT_VertMergedCells,
2576 	TT_DIRECTION,
2577 	TT_DIR,
2578 /* >>---------- PATCH */
2579 	TT_stylename,
2580 /* << ---------------- */
2581 	TokenTableSize		/*must be last entry on pain of death */
2582     } TT;
2583 
2584 
2585 
2586     typedef struct _TokenTable {
2587 	const char *m_name;
2588 	int m_type;
2589     } TokenTable, CharsetTable, ReasonTable;
2590 
2591 /* support for ternary tree lookup of tokens */
2592     typedef struct tokennode *Tokenptr;
2593     typedef struct tokennode {
2594 	char splitchar;
2595 	Tokenptr lokid, eqkid, hikid;
2596 	int token;		/* indexes into the token table */
2597     } Tokennode;
2598 
2599     void tokenTreeFreeAll (void);
2600 
2601 
2602     typedef struct _wvEle {
2603 	int nostr;
2604 	char **str;
2605     } wvEle;
2606 
2607 
2608     const char *wvGetCharset (U16 charset);
2609     U16 wvLookupCharset (char *optarg);
2610 
2611     typedef struct _state_data {
2612 	wvEle elements[TokenTableSize];
2613 	U32 state;
2614 	wvEle *currentele;
2615 	char **current;
2616 	U32 currentlen;
2617 	FILE *fp;
2618 	const char *path;
2619     } state_data;
2620 
2621 
2622     typedef struct _PRM {
2623 	/*full total of bits should be 16 */
2624 	U32 fComplex:1;
2625 	union {
2626 	    struct {
2627 		U32 isprm:7;
2628 		U32 val:8;
2629 	    } var1;
2630 	    struct {
2631 		U32 igrpprl:15;
2632 	    } var2;
2633 	} para;
2634     } PRM;
2635 
2636     void wvGetPRM (PRM * item, wvStream * fd);
2637     void wvInitPRM (PRM * item);
2638 
2639     typedef struct _PCD {
2640 	/*this should be 16 bits for bitfields */
2641 	U32 fNoParaLast:1;
2642 	U32 fPaphNil:1;
2643 	U32 fCopied:1;
2644 	U32 reserved:5;
2645 	U32 fn:8;
2646 	U32 fc;
2647 	PRM prm;
2648     } PCD;
2649 
2650     void wvGetPCD (PCD * item, wvStream * fd);
2651     void wvInitPCD (PCD * item);
2652     int wvGetPCD_PLCF (PCD ** pcd, U32 ** pos, U32 * nopcd, U32 offset, U32 len,
2653 		       wvStream * fd);
2654     int wvReleasePCD_PLCF (PCD * pcd, U32 * pos);
2655     int wvGuess16bit (PCD * pcd, U32 * pos, U32 nopcd);
2656 
2657     typedef struct _CLX {
2658 	PCD *pcd;
2659 	U32 *pos;
2660 	U32 nopcd;
2661 
2662 	U16 grpprl_count;
2663 	U16 *cbGrpprl;
2664 	U8 **grpprl;
2665     } CLX;
2666 
2667 
2668 
2669     void wvInitCLX (CLX * item);
2670     void wvGetCLX (wvVersion ver, CLX * clx, U32 offset, U32 len, U8 fExtChar,
2671 		   wvStream * fd);
2672     void wvReleaseCLX (CLX * clx);
2673     void wvBuildCLXForSimple6 (CLX * clx, FIB * fib);
2674 
2675     typedef struct _FDOA {
2676 	S32 fc;
2677 	S16 ctxbx;
2678     } FDOA;
2679 
2680     void wvGetFDOA (FDOA * item, wvStream * fd);
2681     int wvGetFDOA_PLCF (FDOA ** fdoa, U32 ** pos, U32 * nofdoa, U32 offset,
2682 			U32 len, wvStream * fd);
2683     FDOA *wvGetFDOAFromCP (U32 currentcp, FDOA * fdoa, U32 * pos, U32 nofdoa);
2684 
2685     typedef enum {
2686 	DOCBEGIN,
2687 	DOCEND,
2688 	SECTIONBEGIN,
2689 	SECTIONEND,
2690 	PARABEGIN,
2691 	PARAEND,
2692 	CHARPROPBEGIN,
2693 	CHARPROPEND,
2694 	COMMENTBEGIN,
2695 	COMMENTEND
2696     } wvTag;
2697 
2698     typedef struct _wvParseStruct {
2699 	/*public */
2700 	void *userData;
2701 
2702 	/*protected */
2703         GsfInput *ole_file;
2704 	wvStream *mainfd;
2705 	wvStream *tablefd;
2706 	wvStream *data;
2707 	wvStream *summary;
2708 	FIB fib;
2709 	DOP dop;
2710 	STTBF anSttbfAssoc;
2711 	STTBF Sttbfbkmk;
2712 	LFO *lfo;
2713 	LFOLVL *lfolvl;
2714 	LVL *lvl;
2715 	U32 nolfo;
2716 	U32 nooflvl;
2717 	LST *lst;
2718 	U16 noofLST;
2719 	CLX clx;
2720 	FFN_STTBF fonts;
2721 	STSH stsh;
2722 
2723 	LVL *finallvl;
2724 	U32 *liststartnos;
2725 	U8 *listnfcs;
2726 
2727         int (*charhandler) (struct _wvParseStruct * ps, U16 eachchar,
2728 			    U8 chartype, U16 lid);
2729         int (*scharhandler) (struct _wvParseStruct * ps, U16 eachchar,
2730 			     CHP * achp);
2731         int (*elehandler) (struct _wvParseStruct * ps, wvTag tag, void *props,
2732 			   int dirty);
2733         int (*dochandler) (struct _wvParseStruct * ps, wvTag tag);
2734 
2735 	/*private */
2736 	wvStream *tablefd0;
2737 	wvStream *tablefd1;
2738 	U16 password[16];
2739 	U8 intable;
2740 	S16 *cellbounds;
2741 	int nocellbounds;
2742 	S16 **vmerges;
2743 	U16 norows;
2744 	U8 endcell;
2745 	U32 currentcp;
2746 	PAP nextpap;
2747 
2748 	FSPA *fspa;
2749 	U32 *fspapos;
2750 	U32 nooffspa;
2751 
2752 	FDOA *fdoa;
2753 	U32 *fdoapos;
2754 	U32 nooffdoa;
2755 
2756 	int fieldstate;
2757 	int fieldmiddle;
2758 	char *filename;
2759 	char *dir;
2760 
2761       /* see abiword bug 10247 */
2762         GsfInput *input;
2763     } wvParseStruct;
2764 
2765     void wvSetPassword (const char *password, wvParseStruct * ps);
2766     void wvSetTableInfo (wvParseStruct * ps, TAP * ptap, int no);
2767     int wvDecrypt95 (wvParseStruct * ps);
2768     int wvDecrypt97 (wvParseStruct * ps);
2769 
2770     void wvPrintTitle (wvParseStruct * ps, STTBF * item);
2771 
2772     wvStream *wvWhichTableStream (FIB * fib, wvParseStruct * ps);
2773 
2774     char *wvAutoCharset (wvParseStruct * ps);
2775 
2776     typedef struct _expand_data {
2777 	STTBF *anSttbfAssoc;	/* associated strings */
2778 	STSH *stsh;
2779 	LFO **lfo;		/* list tables */
2780 	LFOLVL *lfolvl;
2781 	LVL *lvl;
2782 	U32 *nolfo;
2783 	U32 *nooflvl;
2784 	LST **lst;
2785 	U16 *noofLST;
2786 	U8 *intable;
2787 	U8 *endcell;
2788 	S16 **cellbounds;
2789 	int *nocellbounds;
2790 	S16 ***vmerges;
2791 	int whichcell;
2792 	int whichrow;
2793 
2794 	U32 **liststartnos;
2795 	U8 **listnfcs;
2796 	LVL **finallvl;
2797 	U16 *norows;
2798 
2799 	FIB *fib;
2800 	DOP *dop;
2801 
2802 	void *props;		/* holds PAP/CHP/etc */
2803 	char *charset;
2804 
2805 	char *retstring;
2806 	U32 currentlen;
2807 	state_data *sd;
2808 	SEP *asep;
2809 	PAP *nextpap;
2810 	PAP lastpap;
2811 	char *filename;
2812 
2813 	wvParseStruct *ps;
2814     } expand_data;
2815 
2816     void wvInitExpandData (expand_data * data);
2817 /*
2818 returns the same as wvOLEDecode with the addition that
2819 4 means that it isnt a word document
2820 */
2821   int wvInitParser (wvParseStruct * ps, char *path);
2822   int wvInitParser_gsf (wvParseStruct * ps, GsfInput *path);
2823 
2824   wvParseStruct * wvCreateParser (void);
2825   void wvDeleteParser (wvParseStruct * ps);
2826 
2827   int wvInit (void);
2828   void wvShutdown (void);
2829 
2830     void wvDecodeSimple (wvParseStruct * ps, subdocument whichdoc);
2831     U32 wvGetBeginFC (wvParseStruct * ps, subdocument whichdoc);
2832 
2833     typedef enum {
2834 	cbATRD = 30,
2835 	cbANLD = 84,
2836 	cbANLV = 16,
2837 	cbASUMY = 4,
2838 	cbASUMYI = 12,
2839 	cbBTE = 4,
2840 	cbBKD = 6,
2841 	cbBKF = 4,
2842 	cbBKL = 2,
2843 	cbBRC = 4,
2844 	cbBRC10 = 2,
2845 	cbCHP = 136,
2846 	cbDTTM = 4,
2847 	cbDCS = 2,
2848 	cbDOGRID = 10,
2849 	cbDOPTYPOGRAPHY = 310,
2850 	cbFSPA = 26,
2851 	cbFIB = 898,
2852 	cbLSPD = 4,
2853 	cbOLST = 212,
2854 	cbNUMRM = 128,
2855 	cbPGD = 10,
2856 	cbPHE = 12,
2857 	cbPAP = 610,
2858 	cbPCD = 8,
2859 	/*
2860 	   cbPLC
2861 	 */
2862 	cbPRM = 2,
2863 	cbRS = 16,
2864 	cbRR = 4,
2865 	cbSED = 12,
2866 	cbSEP = 704,
2867 	cbSHD = 2,
2868 	cbTBD = 1,
2869 	cbTC = 20,
2870 	cbTLP = 4,
2871 	cbTAP = 1728,
2872 	cbWKB = 12,
2873 	cbLSTF = 28,
2874 	cbFDOA = 6,
2875 	cbFTXBXS = 22,
2876 
2877 	cb7DOP = 88,
2878 
2879 	cb6BTE = 2,
2880 	cb6FIB = 682,
2881 	cb6PHE = 6,
2882 	cb6ANLD = 52,
2883 	cb6BRC = 2,
2884 	cb6DOP = 84,
2885 	cb6PGD = 6,
2886 	cb6TC = 10,
2887 	cb6CHP = 42
2888     } cbStruct;
2889 
2890     U32 wvNormFC (U32 fc, int *flag);
2891     int wvGetPieceBoundsFC (U32 * begin, U32 * end, CLX * clx, U32 piececount);
2892     int wvGetPieceBoundsCP (U32 * begin, U32 * end, CLX * clx, U32 piececount);
2893     U16 wvGetChar (wvStream * fd, U8 chartype);
2894     void *wvMalloc (U32 size);
2895 
2896     typedef struct _BTE {
2897 	U32 pn:22;
2898 	U32 unused:10;
2899     } BTE;
2900 
2901     void wvGetBTE (BTE * bte, wvStream * fd);
2902     void wvInitBTE (BTE * bte);
2903     int wvGetBTE_PLCF (BTE ** bte, U32 ** pos, U32 * nobte, U32 offset, U32 len,
2904 		       wvStream * fd);
2905     int wvGetBTE_PLCF6 (BTE ** bte, U32 ** pos, U32 * nobte, U32 offset,
2906 			U32 len, wvStream * fd);
2907     void wvCopyBTE (BTE * dest, BTE * src);
2908     int wvGetBTE_FromFC (BTE * bte, U32 currentfc, BTE * list, U32 * fcs,
2909 			 int nobte);
2910     void wvListBTE_PLCF (BTE ** bte, U32 ** pos, U32 * nobte);
2911 
2912 #define WV_PAGESIZE 512
2913 
2914 
2915     typedef struct _BX {
2916 	U8 offset;
2917 	PHE phe;
2918     } BX;
2919 
2920     void wvGetBX (BX * item, U8 * page, U16 * pos);
2921     void wvGetBX6 (BX * item, U8 * page, U16 * pos);
2922 
2923 
2924     typedef struct _PAPX {
2925 	U16 cb;
2926 	U16 istd;
2927 	U8 *grpprl;
2928     } PAPX;
2929 
2930     void wvGetPAPX (wvVersion ver, PAPX * item, U8 * page, U16 * pos);
2931     void wvReleasePAPX (PAPX * item);
2932     void wvInitPAPX (PAPX * item);
2933 
2934     typedef struct _PAPX_FKP {
2935 	U32 *rgfc;
2936 	BX *rgbx;
2937 	PAPX *grppapx;
2938 	U8 crun;
2939     } PAPX_FKP;
2940 
2941     void wvGetPAPX_FKP (wvVersion ver, PAPX_FKP * fkp, U32 pn, wvStream * fd);
2942     void wvReleasePAPX_FKP (PAPX_FKP * fkp);
2943     void wvInitPAPX_FKP (PAPX_FKP * fkp);
2944 
2945     int wvGetIntervalBounds (U32 * fcFirst, U32 * fcLim, U32 currentfc,
2946 			     U32 * pos, U32 nopos);
2947     int wvIncFC (U8 chartype);
2948 
2949     int wvGetSimpleParaBounds (wvVersion ver, PAPX_FKP * fkp, U32 * fcFirst,
2950 			       U32 * fcLim, U32 currentfc,	/*CLX *clx, */
2951 			       BTE * bte, U32 * pos, int nobte, wvStream * fd);
2952 
2953     int wvOutputTextChar (U16 eachchar, U8 chartype, wvParseStruct * ps,
2954 			  CHP * achp);
2955     void wvOutputFromUnicode (U16 eachchar, char *outputtype);
2956 
2957     int wvConvertUnicodeToHtml (U16 char16);
2958     int wvConvertUnicodeToXml (U16 char16);
2959     char *wvConvertStylename(char *stylename, char *outputtype);
2960     int wvConvertUnicodeToLaTeX (U16 char16);
2961     U16 wvConvertSymbolToUnicode (U16 char16);
2962     U16 wvConvertMTExtraToUnicode (U16 char16);
2963 
2964     U16 wvHandleCodePage (U16 eachchar, U16 lid);
2965 
2966     void wvDecodeComplex (wvParseStruct * ps);
2967     int wvGetComplexParaBounds (wvVersion ver, PAPX_FKP * fkp, U32 * fcFirst,
2968 				U32 * fcLim, U32 currentfc, CLX * clx,
2969 				BTE * bte, U32 * pos, int nobte, U32 piece,
2970 				wvStream * fd);
2971     U32 wvSearchNextLargestFCPAPX_FKP (PAPX_FKP * fkp, U32 currentfc);
2972     U32 wvSearchNextLargestFCCHPX_FKP (CHPX_FKP * fkp, U32 currentfc);
2973     int wvQuerySamePiece (U32 fcTest, CLX * clx, U32 piece);
2974     int wvGetComplexParafcFirst (wvVersion ver, U32 * fcFirst, U32 currentfc,
2975 				 CLX * clx, BTE * bte, U32 * pos, int nobte,
2976 				 U32 piece, PAPX_FKP * fkp, wvStream * fd);
2977     U32 wvSearchNextSmallestFCPAPX_FKP (PAPX_FKP * fkp, U32 currentfc);
2978     U32 wvGetPieceFromCP (U32 cp, CLX * clx);
2979     int wvGetIndexFCInFKP_PAPX (PAPX_FKP * fkp, U32 currentfc);
2980 
2981     void wvOLEFree (wvParseStruct * ps);
2982 
2983 
2984 
2985     int wvText (wvParseStruct * ps);
2986     int wvHtml (wvParseStruct * ps);
2987 
2988 #ifdef DEBUG
2989 #define wvTrace( args ) wvRealTrace(__FILE__,__LINE__, wvFmtMsg args )
2990 #else
2991 #define wvTrace( args )
2992 #endif
2993 
2994     int wvAssembleSimplePAP (wvVersion ver, PAP * apap, U32 fc, PAPX_FKP * fkp, wvParseStruct * ps);
2995     int wvAssembleComplexCHP (wvVersion ver, CHP * achp, U32 cpiece,STSH * stsh, CLX * clx);
2996 
2997     void wvAppendStr (char **orig, const char *add);
2998     int wvParseConfig (state_data * myhandle);
2999 
3000     void wvBeginDocument (expand_data * data);
3001     void wvEndDocument (expand_data * data);
3002 
3003     void wvInitStateData (state_data * data);
3004     void wvListStateData (state_data * data);
3005 
3006     int wvExpand (expand_data * myhandle, char *buf, int len);
3007     int wvStrlen (const char *str);
3008     char *wvStrcat (char *dest, const char *src);
3009     void wvReleaseStateData (state_data * data);
3010 
3011     U32 wvConvertCPToFC (U32 currentcp, CLX * clx);
3012 
3013     int wvIsEmptyPara (PAP * apap, expand_data * data, int inc);
3014     void wvBeginPara (expand_data * data);
3015     void wvEndPara (expand_data * data);
3016 
3017     void wvBeginCharProp (expand_data * data, PAP * apap);
3018     void wvEndCharProp (expand_data * data);
3019 
3020     void wvBeginSection (expand_data * data);
3021     void wvEndSection (expand_data * data);
3022 
3023     void wvBeginComment (expand_data * data);
3024     void wvEndComment (expand_data * data);
3025 
3026     int wvGetComplexParafcLim (wvVersion ver, U32 * fcLim, U32 currentfc,
3027 			       CLX * clx, BTE * bte, U32 * pos, int nobte,
3028 			       U32 piece, PAPX_FKP * fkp, wvStream * fd);
3029 
3030     wvVersion wvQuerySupported (FIB * fib, int *reason);
3031 
3032     const char *wvReason (int reason);
3033 
3034     void
3035     wvSetCharHandler (wvParseStruct * ps,
3036 		      int (*proc) (wvParseStruct *, U16, U8, U16));
3037     void
3038     wvSetSpecialCharHandler (wvParseStruct * ps,
3039 			     int (*proc) (wvParseStruct *, U16, CHP *));
3040     void
3041     wvSetElementHandler (wvParseStruct * ps,
3042 			 int (*proc) (wvParseStruct *, wvTag, void *, int));
3043     void
3044     wvSetDocumentHandler (wvParseStruct * ps,
3045 			  int (*proc) (wvParseStruct *, wvTag));
3046 
3047     int wvHandleElement (wvParseStruct * ps, wvTag tag, void *props,
3048 			 int dirty);
3049     int wvHandleDocument (wvParseStruct * ps, wvTag tag);
3050 
3051     SprmName wvGetrgsprmPrm (U16 in);
3052     int wvAssembleComplexPAP (wvVersion ver, PAP * apap, U32 cpiece, wvParseStruct *ps);
3053     U32 wvGetEndFCPiece (U32 piece, CLX * clx);
3054     void wvInitSprm (Sprm * Sprm);
3055 
3056     void wvInitError (void);
3057 
3058     typedef struct _BKD {
3059 	S16 ipgd_itxbxs;
3060 	S32 dcpDepend:16;
3061 	U32 icol:8;
3062 	U32 fTableBreak:1;
3063 	U32 fColumnBreak:1;
3064 	U32 fMarked:1;
3065 	U32 fUnk:1;
3066 	U32 fTextOverflow:1;
3067 	U32 reserved1:3;
3068     } BKD;
3069 
3070     void wvGetBKD (BKD * item, wvStream * fd);
3071     int wvGetBKD_PLCF (BKD ** bkd, U32 ** pos, U32 * nobkd, U32 offset, U32 len,
3072 		       wvStream * fd);
3073 
3074 
3075 
3076     typedef struct _BKL {
3077 	S16 ibkf;
3078     } BKL;
3079 
3080     void wvGetBKL (BKL * item, wvStream * fd);
3081     int wvGetBKL_PLCF (BKL ** bkl, U32 ** pos, U32 * nobkl, U32 bkloffset, U32 bkllen,
3082                U32 bkfoffset, U32 bkflen, wvStream * fd);
3083 
3084 
3085     typedef struct _PGD {
3086 	U32 fContinue:1;
3087 	U32 fUnk:1;
3088 	U32 fRight:1;
3089 	U32 fPgnRestart:1;
3090 
3091 	/*
3092 	   U32 fGhost:2;   fGhost is fEmptyPage && fAllFtn, and is unioned (sort of with them
3093 	   in word 97) its existance serves no bloody purpose. The word 6
3094 	   spec has a different location for fGhost, but i reckon the word97
3095 	   is right for word 6 as well, but its not like i intend to use
3096 	   this anyway :-)
3097 	 */
3098 	U32 fEmptyPage:1;
3099 	U32 fAllFtn:1;
3100 
3101 	U32 fColOnly:1;		/* unused in word 97, but ive retained the name */
3102 	U32 fTableBreaks:1;
3103 	U32 fMarked:1;
3104 	U32 fColumnBreaks:1;
3105 	U32 fTableHeader:1;
3106 	U32 fNewPage:1;
3107 	U32 bkc:4;
3108 
3109 	U32 lnn:16;
3110 	U16 pgn;
3111 	S32 dym;
3112     } PGD;
3113 
3114 
3115     void wvGetPGD (wvVersion ver, PGD * item, wvStream * fd);
3116 
3117 
3118     typedef struct _RS {
3119 	S16 fRouted;
3120 	S16 fReturnOrig;
3121 	S16 fTrackStatus;
3122 	S16 fDirty;
3123 	S16 nProtect;
3124 	S16 iStage;
3125 	S16 delOption;
3126 	S16 cRecip;
3127     } RS;
3128 
3129     void wvGetRS (RS * item, wvStream * fd);
3130 
3131     typedef struct _RR {
3132 	S16 cb;
3133 	S16 cbSzRecip;
3134     } RR;
3135 
3136     void wvGetRR (RR * item, wvStream * fd);
3137 
3138     typedef struct _FTXBXS {
3139 	S32 cTxbx_iNextReuse;
3140 	S32 cReusable;
3141 	S16 fReusable;
3142 	S32 reserved;
3143 	S32 lid;
3144 	S32 txidUndo;
3145     } FTXBXS;
3146 
3147     void wvGetFTXBXS (FTXBXS * item, wvStream * fd);
3148     int wvGetFTXBXS_PLCF (FTXBXS ** ftxbxs, U32 ** pos, U32 * noftxbxs,
3149 			  U32 offset, U32 len, wvStream * fd);
3150 
3151 
3152     typedef struct _WKB {
3153 	S16 fn;
3154 	U16 grfwkb;
3155 	S32 lvl:16;
3156 	U32 fnpt:4;
3157 	U32 fnpd:12;
3158 	S32 doc;
3159     } WKB;
3160 
3161     void wvGetWKB (WKB * item, wvStream * fd);
3162 
3163     int wvGetSimpleSectionBounds (wvVersion ver, wvParseStruct * ps, SEP * sep,
3164 				  U32 * fcFirst, U32 * fcLim, U32 cp, CLX * clx,
3165 				  SED * sed, U32 * spiece, U32 * posSedx,
3166 				  U32 section_intervals, STSH * stsh,
3167 				  wvStream * fd);
3168     int wvGetComplexSEP (wvVersion ver, SEP * sep, U32 cpiece, STSH * stsh,
3169 			 CLX * clx);
3170 
3171     int wvGetSimpleCharBounds (wvVersion ver, CHPX_FKP * fkp, U32 * fcFirst,
3172 			       U32 * fcLim, U32 currentcp, CLX * clx, BTE * bte,
3173 			       U32 * pos, int nobte, wvStream * fd);
3174     int wvAssembleSimpleCHP (wvVersion ver, CHP * achp, const PAP * apap,
3175 							 U32 fc, CHPX_FKP * fkp, STSH * stsh);
3176     int wvGetComplexCharfcLim (wvVersion ver, U32 * fcLim, U32 currentfc,
3177 			       CLX * clx, BTE * bte, U32 * pos, int nobte,
3178 			       U32 piece, CHPX_FKP * fkp, wvStream * fd);
3179     int wvGetComplexCharfcFirst (wvVersion ver, U32 * fcFirst, U32 currentfc,
3180 				 CLX * clx, BTE * bte, U32 * pos, int nobte,
3181 				 U32 piece, CHPX_FKP * fkp, wvStream * fd);
3182 
3183     void wvOutputHtmlChar (U16 eachchar, U8 chartype, char *outputtype,
3184 			   U16 lid);
3185 
3186     int wvGetListEntryInfo (wvVersion ver, LVL ** rlvl, U32 ** nos, U8 ** nfcs,
3187 			    LVL * retlvl, LFO ** retlfo, PAP * apap, LFO ** lfo,
3188 			    LFOLVL * lfolvl, LVL * lvl, U32 * nolfo, LST ** lst,
3189 			    U16 * noofLST);
3190 
3191 
3192     void wvSetPixelsPerInch (S16 hpixels, S16 vpixels);
3193     float wvTwipsToHPixels (S16 twips);
3194     float wvTwipsToVPixels (S16 twips);
3195     float wvTwipsToMM (S16 twips);
3196     float wvPointsToMM (S16 points);
3197 
3198     int wvCellBgColor (int whichrow, int whichcell, int nocells, int norows,
3199 		       TLP * tlp);
3200 
3201 #define isodd(a)  ((a/2) != ((a+1)/2))
3202 
3203     float wvRelativeWidth (S16 width, SEP * asep);
3204 
3205     int fieldCharProc (wvParseStruct * ps, U16 eachchar, U8 chartype, U16 lid);
3206 
3207     ATRD *wvGetCommentBounds (U32 * comment_cpFirst, U32 * comment_cpLim,
3208 			      U32 currentcp, ATRD * atrd, U32 * pos, U32 noatrd,
3209 			      STTBF * bookmarks, BKF * bkf, U32 * posBKF,
3210 			      U32 bkf_intervals, BKL * bkl, U32 * posBKL,
3211 			      U32 bkl_intervals);
3212 
3213     int cellCompEQ (void *a, void *b);
3214     int cellCompLT (void *a, void *b);
3215 
3216     typedef size_t (*wvConvertToUnicode) (const char **, size_t *, char **,
3217 					  size_t *);
3218 
3219     const char *wvLIDToCodePageConverter (U16 lid);
3220     const char *wvLIDToLangConverter (U16 lid);
3221   U16 wvLangToLIDConverter ( const char * lang );
3222 
3223     typedef struct _MSOFBH {
3224 	U32 ver:4;
3225 	U32 inst:12;
3226 	U32 fbt:16;
3227 	U32 cbLength;
3228     } MSOFBH;
3229 
3230     U32 wvGetMSOFBH (MSOFBH * amsofbh, wvStream * fd);
3231     U32 wvEatmsofbt (MSOFBH * amsofbh, wvStream * fd);
3232 
3233 /* FDGG - File DGG */
3234     typedef struct _FDGG {
3235 	U32 spidMax;		/* The current maximum shape ID */
3236 	U32 cidcl;		/* The number of ID clusters (FIDCLs) */
3237 	U32 cspSaved;		/* The total number of shapes saved */
3238 	/* (including deleted shapes, if undo */
3239 	/* information was saved) */
3240 	U32 cdgSaved;		/* The total number of drawings saved */
3241     } FDGG;
3242 
3243 /* File ID Cluster - used to save IDCLs */
3244     typedef struct _FIDCL {
3245 	U32 dgid;		/* DG owning the SPIDs in this cluster */
3246 	U32 cspidCur;		/* number of SPIDs used so far */
3247     } FIDCL;
3248 
3249 /* FBSE - File Blip Store Entry */
3250     typedef struct _FBSE {
3251 	U8 btWin32;		/* Required type on Win32 */
3252 	U8 btMacOS;		/* Required type on Mac */
3253 	U8 rgbUid[16];		/* Identifier of blip */
3254 	U16 tag;		/* currently unused */
3255 	U32 size;		/* Blip size in stream */
3256 	U32 cRef;		/* Reference count on the blip */
3257 	U32 foDelay;		/* File offset in the delay stream */
3258 	U8 usage;		/* How this blip is used (MSOBLIPUSAGE) */
3259 	U8 cbName;		/* length of the blip name */
3260 	U8 unused2;		/* for the future */
3261 	U8 unused3;		/* for the future */
3262     } FBSE;
3263 
3264     U32 wvGetFBSE (FBSE * afbse, wvStream * fd);
3265     void wvCopyFBSE (FBSE * dest, FBSE * src);
3266 
3267 
3268     typedef enum {
3269 	msoblipusagedefault,	/* all non-texture fill blips get this. */
3270 	msoblipusagetexture,
3271 	msoblipusagemax = 255	/* since this is stored in a byte */
3272     } msoblipusage;
3273 
3274     typedef enum {		/* GEL provided types... */
3275 	msoblipERROR = 0,	/* An error occured during loading */
3276 	msoblipUNKNOWN,		/* An unknown blip type */
3277 	msoblipEMF,		/* Windows Enhanced Metafile */
3278 	msoblipWMF,		/* Windows Metafile */
3279 	msoblipPICT,		/* Macintosh PICT */
3280 	msoblipJPEG,		/* JFIF */
3281 	msoblipPNG,		/* PNG */
3282 	msoblipDIB,		/* Windows DIB */
3283 	msoblipFirstClient = 32,	/* First client defined blip type */
3284 	msoblipLastClient = 255	/* Last client defined blip type */
3285     } MSOBLIPTYPE;
3286 
3287     typedef enum {
3288 	msobiUNKNOWN = 0,
3289 	msobiWMF = 0x216,	/* Metafile header then compressed WMF */
3290 	msobiEMF = 0x3D4,	/* Metafile header then compressed EMF */
3291 	msobiPICT = 0x542,	/* Metafile header then compressed PICT */
3292 	msobiPNG = 0x6E0,	/* One byte tag then PNG data */
3293 	msobiJFIF = 0x46A,	/* One byte tag then JFIF data */
3294 	msobiJPEG = msobiJFIF,
3295 	msobiDIB = 0x7A8,	/* One byte tag then DIB data */
3296 	msobiClient = 0x800	/* Clients should set this bit */
3297     } MSOBI;			/* Blip signature as encoded in the MSOFBH.inst */
3298 
3299     typedef enum {
3300 	msofbtDggContainer = 0xF000,
3301 	msofbtBstoreContainer = 0xF001,
3302 	msofbtDgContainer = 0xF002,
3303 	msofbtSpgrContainer = 0xF003,
3304 	msofbtSpContainer = 0xF004,
3305 	msofbtDgg = 0xF006,
3306 	msofbtBSE = 0xF007,
3307 	msofbtDg = 0xF008,
3308 	msofbtSpgr = 0xF009,
3309 	msofbtSp = 0xF00A,
3310 	msofbtOPT = 0xF00B,
3311 	msofbtTextbox = 0xF00C,
3312 	msofbtClientTextbox = 0xF00D,
3313 	msofbtAnchor = 0xF00E,
3314 	msofbtChildAnchor = 0xF00F,
3315 	msofbtClientAnchor = 0xF010,
3316 	msofbtClientData = 0xF011,
3317 	msofbtBlipFirst = 0xF018,
3318 	msofbtDeletedPspl = 0xF11D,
3319 	msofbtSplitMenuColors = 0xF11E,
3320 	msofbtOleObject = 0xF11F,
3321 	msofbtUserDefined = 0xF122
3322     } MSOFBT;
3323 
3324     typedef enum {
3325 	msocompressionDeflate = 0,
3326 	msocompressionNone = 254,	/* Used only if compression fails */
3327 	msocompressionTest = 255	/* For testing only */
3328     } MSOBLIPCOMPRESSION;
3329 
3330     typedef enum {
3331 	msofilterAdaptive = 0,	/* PNG type - not used/supported for metafile */
3332 	msofilterNone = 254,
3333 	msofilterTest = 255	/* For testing only */
3334     } MSOBLIPFILTER;
3335 
3336     typedef struct _MetaFileBlip {
3337 	/* The secondary, or data, UID - should always be set. */
3338 	U8 m_rgbUid[16];
3339 	/* The primary UID - this defaults to 0, in which case the primary ID is
3340 	   that of the internal data. NOTE!: The primary UID is only saved to disk
3341 	   if (blip_instance ^ blip_signature == 1). Blip_instance is MSOFBH.inst and
3342 	   blip_signature is one of the values defined in MSOBI */
3343 	U8 m_rgbUidPrimary[16];	/* optional based on the above check */
3344 
3345 	/* Metafile Blip overhead = 34 bytes. m_cb gives the number of
3346 	   bytes required to store an uncompressed version of the file, m_cbSave
3347 	   is the compressed size.  m_mfBounds gives the boundary of all the
3348 	   drawing calls within the metafile (this may just be the bounding box
3349 	   or it may allow some whitespace, for a WMF this comes from the
3350 	   SetWindowOrg and SetWindowExt records of the metafile). */
3351 	U32 m_cb;		/* Cache of the metafile size */
3352 	RECT m_rcBounds;	/* Boundary of metafile drawing commands */
3353 	POINT m_ptSize;		/* Size of metafile in EMUs */
3354 	U32 m_cbSave;		/* Cache of saved size (size of m_pvBits) */
3355 	U8 m_fCompression;	/* MSOBLIPCOMPRESSION */
3356 	U8 m_fFilter;		/* always msofilterNone */
3357 	wvStream *m_pvBits;		/* Compressed bits of metafile. */
3358     } MetaFileBlip;
3359 
3360     typedef struct _BitmapBlip {
3361 	/* The secondary, or data, UID - should always be set. */
3362 	U8 m_rgbUid[16];
3363 	/* The primary UID - this defaults to 0, in which case the primary ID is
3364 	   that of the internal data. NOTE!: The primary UID is only saved to disk
3365 	   if (blip_instance ^ blip_signature == 1). Blip_instance is MSOFBH.finst and
3366 	   blip_signature is one of the values defined in MSOBI */
3367 	U8 m_rgbUidPrimary[16];	/* optional based on the above check */
3368 	U8 m_bTag;
3369 	wvStream *m_pvBits;		/* raster bits of the blip */
3370     } BitmapBlip;
3371 
3372 
3373     typedef struct _Blip {
3374 	FBSE fbse;
3375 	U16 type;
3376 	U16 *name;
3377 	union {
3378 	    MetaFileBlip metafile;
3379 	    BitmapBlip bitmap;
3380 	} blip;
3381     } Blip;
3382 
3383     void wvCopyBlip (Blip * dest, Blip * src);
3384     U32 wvGetBlip (Blip * blip, wvStream * fd, wvStream * delay);
3385     void wvReleaseBlip (Blip * blip);
3386 
3387     U32 wvGetMetafile (MetaFileBlip * amf, MSOFBH * amsofbh, wvStream * fd);
3388     void wvCopyMetafile (MetaFileBlip * dest, MetaFileBlip * src);
3389     U32 wvGetBitmap (BitmapBlip * abm, MSOFBH * amsofbh, wvStream * fd);
3390     void wvCopyBitmap (BitmapBlip * dest, BitmapBlip * src);
3391 
3392     typedef struct _FOPTE {
3393 	/* this should be 16 bits for bitfields, and then 32 bit op */
3394 	U32 pid:14;		/* Property ID */
3395 	U32 fBid:1;		/* value is a blip ID - only valid if fComplex is FALSE */
3396 	U32 fComplex:1;		/* complex property, value is length */
3397 	U32 op;
3398 	U8 *entry;
3399     } FOPTE;
3400 
3401     U32 wvGetFOPTE (FOPTE * afopte, wvStream * fd);
3402     void wvReleaseFOPTE (FOPTE * afopte);
3403     U32 wvGetFOPTEArray (FOPTE ** fopte, MSOFBH * msofbh, wvStream * fd);
3404     void wvReleaseFOPTEArray (FOPTE ** fopte);
3405     void wvInitFOPTEArray (FOPTE ** fopte);
3406 
3407     typedef struct _FSP {
3408 	U32 spid;		/* The shape id */
3409 	U32 grfPersistent;
3410     } FSP;
3411 
3412     U32 wvGetFSP (FSP * fsp, wvStream * fd);
3413 
3414 /* FDG - File DG */
3415     typedef struct _FDG {
3416 	U32 csp;		/* The number of shapes in this drawing */
3417 	U32 spidCur;		/* The last MSOSPID given to an SP in this DG */
3418     } FDG;
3419 
3420     typedef struct _FSPGR {
3421 	RECT rcgBounds;
3422     } FSPGR;
3423 
3424     typedef RECT FAnchor, FChildAnchor, FClientAnchor;
3425     U32 wvGetFAnchor (FAnchor * fanchor, wvStream * fd);
3426 
3427     typedef struct _ClientData {
3428 	U8 *data;
3429     } ClientData;
3430 
3431     typedef struct _ClientTextbox {
3432 	U32 *textid;
3433     } ClientTextbox;
3434 
3435     void wvInitClientTextbox (ClientTextbox * item);
3436     void wvReleaseClientTextbox (ClientTextbox * item);
3437     U32 wvGetClientTextbox (ClientTextbox * item, MSOFBH * amsofbh,
3438 			    wvStream * fd);
3439 
3440     typedef struct _FSPContainer {
3441 	FSPGR fspgr;		/*may not exist */
3442 	FSP fsp;		/*always will exist */
3443 	FOPTE *fopte;		/*always */
3444 	FAnchor fanchor;	/* one of these will be there */
3445 	ClientData clientdata;	/*always */
3446 	ClientTextbox clienttextbox;	/*maybe */
3447 
3448 #if 0
3449 	Textbox OleObject	/*maybe */
3450 	  DeletedPspl		/*maybe */
3451 #endif
3452     } FSPContainer;
3453 
3454     int wv0x01 (Blip * blip, wvStream * fd, U32 len);
3455     char *wvHtmlGraphic (wvParseStruct * ps, Blip * blip);
3456 
3457     U32 wvGetFSPContainer (FSPContainer * item, MSOFBH * msofbh, wvStream * fd);
3458     void wvReleaseFSPContainer (FSPContainer * item);
3459 
3460 /* begin temp */
3461     typedef struct _BITMAP {
3462 	U8 bm[14];
3463     } BITMAP;
3464 
3465     void wvGetBITMAP (BITMAP * bmp, wvStream * fd);
3466 
3467     typedef struct _rc {
3468 	U8 bm[14];
3469     } rc;
3470 
3471     void wvGetrc (rc * arc, wvStream * fd);
3472 /* end temp */
3473 
3474     typedef struct _PICF {
3475 	U32 lcb;
3476 	U16 cbHeader;
3477 	S16 mfp_mm;
3478 	S16 mfp_xExt;
3479 	S16 mfp_yExt;
3480 	S16 mfp_hMF;
3481 	union {
3482 	    BITMAP bitmap;
3483 	    rc arc;
3484 	} obj;
3485 	S16 dxaGoal;
3486 	S16 dyaGoal;
3487 	U16 mx;
3488 	U16 my;
3489 	S16 dxaCropLeft;
3490 	S16 dyaCropTop;
3491 	S16 dxaCropRight;
3492 
3493 	S32 dyaCropBottom:16;
3494 	U32 brcl:4;
3495 	U32 fFrameEmpty:1;
3496 	U32 fBitmap:1;
3497 	U32 fDrawHatch:1;
3498 	U32 fError:1;
3499 	U32 bpp:8;
3500 
3501 	BRC brcTop;
3502 	BRC brcLeft;
3503 	BRC brcBottom;
3504 	BRC brcRight;
3505 	S16 dxaOrigin;
3506 	S16 dyaOrigin;
3507 	S16 cProps;
3508 	wvStream *rgb;
3509     } PICF;
3510 
3511     int wvGetPICF (wvVersion ver, PICF * apicf, wvStream * fd);
3512 
3513     void remove_suffix (char *name, const char *suffix);
3514     char *base_name (char const *name);
3515 
3516     U32 wvEatOldGraphicHeader (wvStream * fd, U32 len);
3517     int bmptopng (char *prefix);
3518 
3519     int wv0x08 (Blip * blip, S32 spid, wvParseStruct * ps);
3520 
3521     typedef struct _SplitMenuColors {
3522 	U32 noofcolors;
3523 	U32 *colors;
3524     } SplitMenuColors;
3525 
3526     typedef struct _Dgg {
3527 	FDGG fdgg;
3528 	FIDCL *fidcl;
3529     } Dgg;
3530 
3531     typedef struct _BstoreContainer {
3532 	U32 no_fbse;
3533 	Blip *blip;
3534     } BstoreContainer;
3535 
3536     typedef struct _DggContainer {
3537 	SplitMenuColors splitmenucolors;
3538 	Dgg dgg;
3539 	BstoreContainer bstorecontainer;
3540     } DggContainer;
3541 
3542 
3543     U32 wvGetDggContainer (DggContainer * item, MSOFBH * msofbh, wvStream * fd,
3544 			   wvStream * delay);
3545     void wvReleaseDggContainer (DggContainer * item);
3546     void wvInitDggContainer (DggContainer * item);
3547     U32 wvGetBstoreContainer (BstoreContainer * item, MSOFBH * msofbh,
3548 			      wvStream * fd, wvStream * delay);
3549     void wvReleaseBstoreContainer (BstoreContainer * item);
3550     void wvInitBstoreContainer (BstoreContainer * item);
3551 
3552 
3553     U32 wvGetDgg (Dgg * dgg, MSOFBH * amsofbh, wvStream * fd);
3554     void wvReleaseDgg (Dgg * dgg);
3555     void wvInitDgg (Dgg * dgg);
3556 
3557     U32 wvGetFDGG (FDGG * afdgg, wvStream * fd);
3558     U32 wvGetFIDCL (FIDCL * afidcl, wvStream * fd);
3559 
3560 
3561     U32 wvGetSplitMenuColors (SplitMenuColors * splitmenucolors, MSOFBH
3562 			      * amsofbh, wvStream * fd);
3563     void wvReleaseSplitMenuColors (SplitMenuColors * splitmenucolors);
3564     void wvInitSplitMenuColors (SplitMenuColors * splitmenucolors);
3565 
3566     typedef struct _SpgrContainer {
3567 	U32 no_spcontainer;
3568 	FSPContainer *spcontainer;
3569 	U32 no_spgrcontainer;
3570 	struct _SpgrContainer *spgrcontainer;
3571     } SpgrContainer;
3572 
3573     typedef struct _DgContainer {
3574 	FDG fdg;
3575 	U32 no_spgrcontainer;
3576 	SpgrContainer *spgrcontainer;
3577 	U32 no_spcontainer;
3578 	FSPContainer *spcontainer;
3579 #if 0
3580 	SolverContainer solvercontainer;
3581 	ColorScheme colorscheme;
3582 	RegroupItems regroupitems;
3583 #endif
3584     } DgContainer;
3585 
3586     U32 wvGetDgContainer (DgContainer * item, MSOFBH * msofbh, wvStream * fd);
3587     void wvReleaseDgContainer (DgContainer * item);
3588     void wvInitDgContainer (DgContainer * item);
3589     U32 wvGetFDG (FDG * afdg, wvStream * fd);
3590     U32 wvGetSpgrContainer (SpgrContainer * item, MSOFBH * msofbh,
3591 			    wvStream * fd);
3592     void wvReleaseSpgrContainer (SpgrContainer * item);
3593     U32 wvGetFSPGR (FSPGR * item, wvStream * fd);
3594 
3595     U32 wvGetClientData (ClientData * item, MSOFBH * msofbh, wvStream * fd);
3596     void wvReleaseClientData (ClientData * item);
3597     void wvInitClientData (ClientData * item);
3598     FSPContainer *wvFindSPID (SpgrContainer * item, S32 spid);
3599 
3600     typedef struct _escherstruct {
3601 	DggContainer dggcontainer;
3602 	DgContainer dgcontainer;
3603     } escherstruct;
3604 
3605     void wvGetEscher (escherstruct * item, U32 offset, U32 len, wvStream * fd,
3606 		      wvStream * delay);
3607     void wvInitEscher (escherstruct * item);
3608     void wvReleaseEscher (escherstruct * item);
3609     void wvStrToUpper (char *str);
3610     int decompress (FILE * inputfile, FILE * outputfile, U32 inlen, U32 outlen);
3611 
3612 /*current insertion position*/
3613 
3614 /*
3615 Property       PID            Type            Default        Description
3616 */
3617     typedef enum _pid {
3618 	rotation = 4,		/*LONG            0              fixed point: */
3619 	fLockRotation = 119,	/*BOOL           FALSE           No rotation */
3620 	fLockAspectRatio = 120,	/*BOOL           FALSE           Don't allow */
3621 	fLockPosition = 121,	/*BOOL           FALSE           Don't allow */
3622 	fLockAgainstSelect = 122,	/*BOOL           FALSE           Shape may not */
3623 	fLockCropping = 123,	/*BOOL           FALSE           No cropping */
3624 	fLockVertices = 124,	/*BOOL           FALSE           Edit Points */
3625 	fLockText = 125,	/*BOOL           FALSE           Do not edit */
3626 	fLockAdjustHandles = 126,	/*BOOL           FALSE           Do not adjust */
3627 	fLockAgainstGrouping = 127,	/*BOOL           FALSE           Do not group */
3628 	lTxid = 128,		/*LONG           0               id for the text, */
3629 	dxTextLeft = 129,	/*LONG           1/10 inch       margins relative */
3630 	dyTextTop = 130,	/*LONG           1/20 inch */
3631 	dxTextRight = 131,	/*LONG           1/10 inch */
3632 	dyTextBottom = 132,	/*LONG           1/20 inch */
3633 	WrapText = 133,		/*MSOWRAPMODE    FALSE           Wrap text at */
3634 	scaleText = 134,	/*LONG           0               Text zoom/scale */
3635 	anchorText = 135,	/*MSOANCHOR      Top             How to anchor */
3636 	txflTextFlow = 136,	/*MSOTXFL        HorzN           Text flow */
3637 	cdirFont = 137,		/*MSOCDIR        msocdir0        Font rotation */
3638 	hspNext = 138,		/*MSOHSP         NULL            ID of the next */
3639 	txdir = 139,		/*MSOTXDIR       LTR             Bi-Di Text */
3640 	fSelectText = 187,	/*BOOL           TRUE            TRUE if single */
3641 	fAutoTextMargin = 188,	/*BOOL           FALSE           use host's */
3642 	fRotateText = 189,	/*BOOL           FALSE           Rotate text with */
3643 	fFitShapeToText = 190,	/*BOOL           FALSE           Size shape to */
3644 	fFitTextToShape = 191,	/*BOOL           FALSE           Size text to fit */
3645 	gtextUNICODE = 192,	/*WCHAR*           NULL           UNICODE text */
3646 	gtextRTF = 193,		/*char*            NULL           RTF text */
3647 	gtextAlign = 194,	/*MSOGEOTEXTALIGN  Center         alignment on */
3648 	gtextSize = 195,	/*LONG             36<<16         default point */
3649 	gtextSpacing = 196,	/*LONG             1<<16          fixed point */
3650 	gtextFont = 197,	/*WCHAR*           NULL           font family */
3651 	gtextFReverseRows = 240,	/*BOOL             FALSE          Reverse row */
3652 	fGtext = 241,		/*BOOL             FALSE          Has text */
3653 	gtextFVertical = 242,	/*BOOL             FALSE          Rotate */
3654 	gtextFKern = 243,	/*BOOL             FALSE          Kern */
3655 	gtextFTight = 244,	/*BOOL             FALSE          Tightening or */
3656 	gtextFStretch = 245,	/*BOOL             FALSE          Stretch to */
3657 	gtextFShrinkFit = 246,	/*BOOL             FALSE          Char bounding */
3658 	gtextFBestFit = 247,	/*BOOL             FALSE          Scale */
3659 	gtextFNormalize = 248,	/*BOOL             FALSE          Stretch char */
3660 	gtextFDxMeasure = 249,	/*BOOL             FALSE          Do not */
3661 	gtextFBold = 250,	/*BOOL             FALSE          Bold font */
3662 	gtextFItalic = 251,	/*BOOL             FALSE          Italic font */
3663 	gtextFUnderline = 252,	/*BOOL             FALSE          Underline */
3664 	gtextFShadow = 253,	/*BOOL             FALSE          Shadow font */
3665 	gtextFSmallcaps = 254,	/*BOOL             FALSE          Small caps */
3666 	gtextFStrikethrough = 255,	/*BOOL             FALSE          Strike */
3667 	cropFromTop = 256,	/*LONG          0                      16.16 fraction times total image */
3668 	cropFromBottom = 257,	/*LONG          0 */
3669 	cropFromLeft = 258,	/*LONG          0 */
3670 	cropFromRight = 259,	/*LONG          0 */
3671 	pib = 260,		/*IMsoBlip*     NULL                   Blip to display */
3672 	pibName = 261,		/*WCHAR*        NULL                   Blip file name */
3673 	pibFlags = 262,		/*MSOBLIPFLAGS  Comment                Blip flags */
3674 	pictureTransparent = 263,	/*LONG          ~0                     transparent color (none if ~0UL) */
3675 	pictureContrast = 264,	/*LONG          1<<16                  contrast setting */
3676 	pictureBrightness = 265,	/*LONG          0                      brightness setting */
3677 	pictureGamma = 266,	/*LONG          0                      16.16 gamma */
3678 	pictureId = 267,	/*LONG          0                      Host-defined ID for OLE objects */
3679 	pictureDblCrMod = 268,	/*MSOCLR        This                   Modification used if shape has */
3680 	pictureFillCrMod = 269,	/*MSOCLR        undefined */
3681 	pictureLineCrMod = 270,	/*MSOCLR        undefined */
3682 	pibPrint = 271,		/*IMsoBlip*     NULL                   Blip to display when printing */
3683 	pibPrintName = 272,	/*WCHAR*        NULL                   Blip file name */
3684 	pibPrintFlags = 273,	/*MSOBLIPFLAGS  Comment                Blip flags */
3685 	fNoHitTestPicture = 316,	/*BOOL          FALSE                  Do not hit test the picture */
3686 	pictureGray = 317,	/*BOOL          FALSE                  grayscale display */
3687 	pictureBiLevel = 318,	/*BOOL          FALSE                  bi-level display */
3688 	pictureActive = 319,	/*BOOL          FALSE                  Server is active (OLE objects */
3689 	geoLeft = 320,		/*LONG           0                   Defines the G */
3690 	geoTop = 321,		/*LONG           0 */
3691 	geoRight = 322,		/*LONG           21600 */
3692 	geoBottom = 323,	/*LONG           21600 */
3693 	shapePath = 324,	/*MSOSHAPEPATH   msoshapeLinesClosed */
3694 	pVertices = 325,	/*IMsoArray      NULL                An array of */
3695 	pSegmentInfo = 326,	/*IMsoArray      NULL */
3696 	adjustValue = 327,	/*LONG           0                   Adjustment */
3697 	adjust2Value = 328,	/*LONG           0 */
3698 	adjust3Value = 329,	/*LONG           0 */
3699 	adjust4Value = 330,	/*LONG           0 */
3700 	adjust5Value = 331,	/*LONG           0 */
3701 	adjust6Value = 332,	/*LONG           0 */
3702 	adjust7Value = 333,	/*LONG           0 */
3703 	adjust8Value = 334,	/*LONG           0 */
3704 	adjust9Value = 335,	/*LONG           0 */
3705 	adjust10Value = 336,	/*LONG           0 */
3706 	fShadowOK = 378,	/*BOOL           TRUE                Shadow may be */
3707 	f3DOK = 379,		/*BOOL           TRUE                3D may be set */
3708 	fLineOK = 380,		/*BOOL           TRUE                Line style may */
3709 	fGtextOK = 381,		/*BOOL           FALSE               Text effect */
3710 	fFillShadeShapeOK = 382,	/*BOOL           FALSE */
3711 	fFillOK = 383,		/*BOOL           TRUE                OK to fill the */
3712 	fillType = 384,		/*MSOFILLTYPE   Solid       Type of fill */
3713 	fillColor = 385,	/*MSOCLR        white       Foreground color */
3714 	fillOpacity = 386,	/*LONG          1<<16       Fixed 16.16 */
3715 	fillBackColor = 387,	/*MSOCLR        white       Background color */
3716 	fillBackOpacity = 388,	/*LONG          1<<16       Shades only */
3717 	fillCrMod = 389,	/*MSOCLR        undefined   Modification for BW */
3718 	fillBlip = 390,		/*IMsoBlip*     NULL        Pattern/texture */
3719 	fillBlipName = 391,	/*WCHAR*        NULL        Blip file name */
3720 	fillBlipFlags = 392,	/*MSOBLIPFLAGS  Comment     Blip flags */
3721 	fillWidth = 393,	/*LONG          0           How big (A units) to */
3722 	fillHeight = 394,	/*LONG          0 */
3723 	fillAngle = 395,	/*LONG          0           Fade angle - degrees in */
3724 	fillFocus = 396,	/*LONG          0           Linear shaded fill focus */
3725 	fillToLeft = 397,	/*LONG          0           Fraction 16.16 */
3726 	fillToTop = 398,	/*LONG          0           Fraction 16.16 */
3727 	fillToRight = 399,	/*LONG          0           Fraction 16.16 */
3728 	fillToBottom = 400,	/*LONG          0           Fraction 16.16 */
3729 	fillRectLeft = 401,	/*LONG          0           For shaded fills, use */
3730 	fillRectTop = 402,	/*LONG          0 */
3731 	fillRectRight = 403,	/*LONG          0 */
3732 	fillRectBottom = 404,	/*LONG          0 */
3733 	fillDztype = 405,	/*MSODZTYPE     Default */
3734 	fillShadePreset = 406,	/*LONG          0           Special shades */
3735 	fillShadeColors = 407,	/*IMsoArray     NULL        a preset array of colors */
3736 	fillOriginX = 408,	/*LONG          0 */
3737 	fillOriginY = 409,	/*LONG          0 */
3738 	fillShapeOriginX = 410,	/*LONG          0 */
3739 	fillShapeOriginY = 411,	/*LONG          0 */
3740 	fillShadeType = 412,	/*MSOSHADETYPE  Default    Type of */
3741 	fFilled = 443,		/*BOOL          TRUE        Is shape filled? */
3742 	fHitTestFill = 444,	/*BOOL          TRUE        Should we hit test fill? */
3743 	fillShape = 445,	/*BOOL          TRUE        Register pattern on */
3744 	fillUseRect = 446,	/*BOOL          FALSE       Use the large rect? */
3745 	fNoFillHitTest = 447,	/*BOOL          FALSE       Hit test a shape as */
3746 	lineColor = 448,	/*MSOCLR            black             Color of line */
3747 	lineOpacity = 449,	/*LONG              1<<16             Not implemented */
3748 	lineBackColor = 450,	/*MSOCLR            white             Background color */
3749 	lineCrMod = 451,	/*MSOCLR            undefined         Modification for */
3750 	lineType = 452,		/*MSOLINETYPE       Solid             Type of line */
3751 	lineFillBlip = 453,	/*IMsoBlip*         NULL              Pattern/texture */
3752 	lineFillBlipName = 454,	/*WCHAR*            NULL              Blip file name */
3753 	lineFillBlipFlags = 455,	/*MSOBLIPFLAGS      Comment           Blip flags */
3754 	lineFillWidth = 456,	/*LONG              0                 How big (A */
3755 	lineFillHeight = 457,	/*LONG              0 */
3756 	lineFillDztype = 458,	/*MSODZTYPE         Default           How to interpret */
3757 	lineWidth = 459,	/*LONG              9525              A units; 1pt == */
3758 	lineMiterLimit = 460,	/*LONG              8<<16             ratio (16.16) of */
3759 	lineStyle = 461,	/*MSOLINESTYLE      Simple            Draw parallel */
3760 	lineDashing = 462,	/*MSOLINEDASHING    Solid             Can be */
3761 	lineDashStyle = 463,	/*IMsoArray         NULL              As Win32 */
3762 	lineStartArrowhead = 464,	/*MSOLINEEND        NoEnd             Arrow at start */
3763 	lineEndArrowhead = 465,	/*MSOLINEEND        NoEnd             Arrow at end */
3764 	lineStartArrowWidth = 466,	/*MSOLINEENDWIDTH   MediumWidthArrow  Arrow at start */
3765 	lineStartArrowLength = 467,	/*MSOLINEENDLENGTH  MediumLenArrow    Arrow at end */
3766 	lineEndArrowWidth = 468,	/*MSOLINEENDWIDTH   MediumWidthArrow  Arrow at start */
3767 	lineEndArrowLength = 469,	/*MSOLINEENDLENGTH  MediumLenArrow    Arrow at end */
3768 	lineJoinStyle = 470,	/*MSOLINEJOIN       JoinRound         How to join */
3769 	lineEndCapStyle = 471,	/*MSOLINECAP        EndCapFlat        How to end lines */
3770 	fArrowheadsOK = 507,	/*BOOL              FALSE             Allow arrowheads */
3771 	fLine = 508,		/*BOOL              TRUE              Any line? */
3772 	fHitTestLine = 509,	/*BOOL              TRUE              Should we hit */
3773 	lineFillShape = 510,	/*BOOL              TRUE              Register pattern */
3774 	fNoLineDrawDash = 511,	/*BOOL              FALSE             Draw a dashed */
3775 	shadowType = 512,	/*MSOSHADOWTYPE  Offset          Type of */
3776 	shadowColor = 513,	/*MSOCLR         0x808080        Foreground */
3777 	shadowHighlight = 514,	/*MSOCLR         0xCBCBCB        Embossed */
3778 	shadowCrMod = 515,	/*MSOCLR         undefined       Modification */
3779 	shadowOpacity = 516,	/*LONG           1<<16           Fixed 16.16 */
3780 	shadowOffsetX = 517,	/*LONG           25400           Offset shadow */
3781 	shadowOffsetY = 518,	/*LONG           25400           Offset shadow */
3782 	shadowSecondOffsetX = 519,	/*LONG           0               Double offset */
3783 	shadowSecondOffsetY = 520,	/*LONG           0               Double offset */
3784 	shadowScaleXToX = 521,	/*LONG           1<<16           16.16 */
3785 	shadowScaleYToX = 522,	/*LONG           0               16.16 */
3786 	shadowScaleXToY = 523,	/*LONG           0               16.16 */
3787 	shadowScaleYToY = 524,	/*LONG           1<<16           16.16 */
3788 	shadowPerspectiveX = 525,	/*LONG           0               16.16 */
3789 	shadowPerspectiveY = 526,	/*LONG           0               16.16 */
3790 	shadowWeight = 527,	/*LONG           1<<8            scaling */
3791 	shadowOriginX = 528,	/*LONG           0 */
3792 	shadowOriginY = 529,	/*LONG           0 */
3793 	fShadow = 574,		/*BOOL           FALSE           Any shadow? */
3794 	fshadowObscured = 575,	/*BOOL           FALSE           Excel5-style */
3795 	perspectiveType = 576,	/*MSOXFORMTYPE   Shape           Where transform */
3796 	perspectiveOffsetX = 577,	/*LONG           0               The LONG values */
3797 	perspectiveOffsetY = 578,	/*LONG           0 */
3798 	perspectiveScaleXToX = 579,	/*LONG           1<<16 */
3799 	perspectiveScaleYToX = 580,	/*LONG           0 */
3800 	perspectiveScaleXToY = 581,	/*LONG           0 */
3801 	perspectiveScaleYToY = 582,	/*LONG           1<<16 */
3802 	perspectivePerspectiveX = 583,	/*LONG           0 */
3803 	perspectivePerspectiveY = 584,	/*LONG           0 */
3804 	perspectiveWeight = 585,	/*LONG           1<<8            Scaling factor */
3805 	perspectiveOriginX = 586,	/*LONG           1<<15 */
3806 	perspectiveOriginY = 587,	/*LONG           1<<15 */
3807 	fPerspective = 639,	/*BOOL           FALSE           On/off */
3808 	c3DSpecularAmt = 640,	/*LONG    0               Fixed-point 16.16 */
3809 	c3DDiffuseAmt = 641,	/*LONG    65536           Fixed-point 16.16 */
3810 	c3DShininess = 642,	/*LONG    5               Default gives OK */
3811 	c3DEdgeThickness = 643,	/*LONG    12700           Specular edge */
3812 	c3DExtrudeForward = 644,	/*LONG    0               Distance of extrusion */
3813 	c3DExtrudeBackward = 645,	/*LONG    457200 */
3814 	c3DExtrudePlane = 646,	/*LONG    0               Extrusion direction */
3815 	c3DExtrusionColor = 647,	/*MSOCLR  FillThenLine   Basic color */
3816 	c3DCrMod = 648,		/*MSOCLR  undefined       Modification for BW */
3817 	f3D = 700,		/*BOOL    FALSE           Does this shape have a */
3818 	fc3DMetallic = 701,	/*BOOL    0               Use metallic */
3819 	fc3DUseExtrusionColor = 702,	/*BOOL    FALSE */
3820 	fc3DLightFace = 703,	/*BOOL    TRUE */
3821 	c3DYRotationAngle = 704,	/*LONG             0              degrees (16.16) */
3822 	c3DXRotationAngle = 705,	/*LONG             0              degrees (16.16) */
3823 	c3DRotationAxisX = 706,	/*LONG             100            These specify */
3824 	c3DRotationAxisY = 707,	/*LONG             0 */
3825 	c3DRotationAxisZ = 708,	/*LONG             0 */
3826 	c3DRotationAngle = 709,	/*LONG             0              degrees (16.16) */
3827 	c3DRotationCenterX = 710,	/*LONG             0              rotation center */
3828 	c3DRotationCenterY = 711,	/*LONG             0              rotation center */
3829 	c3DRotationCenterZ = 712,	/*LONG             0              rotation center */
3830 	c3DRenderMode = 713,	/*MSO3DRENDERMODE  FullRender     Full,wireframe, */
3831 	c3DTolerance = 714,	/*LONG             30000          pixels (16.16) */
3832 	c3DXViewpoint = 715,	/*LONG             1250000        X view point */
3833 	c3DYViewpoint = 716,	/*LONG             -1250000       Y view point */
3834 	c3DZViewpoint = 717,	/*LONG             9000000        Z view distance */
3835 	c3DOriginX = 718,	/*LONG             32768 */
3836 	c3DOriginY = 719,	/*LONG             -32768 */
3837 	c3DSkewAngle = 720,	/*LONG             -8847360       degree (16.16) */
3838 	c3DSkewAmount = 721,	/*LONG             50             Percentage skew */
3839 	c3DAmbientIntensity = 722,	/*LONG             20000          Fixed point */
3840 	c3DKeyX = 723,		/*LONG             50000          Key light */
3841 	c3DKeyY = 724,		/*LONG             0              tion; only */
3842 	c3DKeyZ = 725,		/*LONG             10000          magnitudes */
3843 	c3DKeyIntensity = 726,	/*LONG             38000          Fixed point */
3844 	c3DFillX = 727,		/*LONG             -50000         Fill light */
3845 	c3DFillY = 728,		/*LONG             0              tion; only */
3846 	c3DFillZ = 729,		/*LONG             10000          magnitudes */
3847 	c3DFillIntensity = 730,	/*LONG             38000          Fixed point */
3848 	fc3DConstrainRotation = 763,	/*BOOL             TRUE */
3849 	fc3DRotationCenterAuto = 764,	/*BOOL             FALSE */
3850 	fc3DParallel = 765,	/*BOOL             1              Parallel */
3851 	fc3DKeyHarsh = 766,	/*BOOL             1              Is key lighting */
3852 	fc3DFillHarsh = 767,	/*BOOL             0              Is fill */
3853 	hspMaster = 769,	/*MSOHSP      NULL        master shape */
3854 	cxstyle = 771,		/*MSOCXSTYLE  None       Type of */
3855 	bWMode = 772,		/*MSOBWMODE   Automatic  Settings for */
3856 	bWModePureBW = 773,	/*MSOBWMODE   Automatic */
3857 	bWModeBW = 774,		/*MSOBWMODE   Automatic */
3858 	fOleIcon = 826,		/*BOOL        FALSE       For OLE objects, */
3859 	fPreferRelativeResize = 827,	/*BOOL        FALSE       For UI only. Prefer */
3860 	fLockShapeType = 828,	/*BOOL        FALSE       Lock the shape type */
3861 	fDeleteAttachedObject = 830,	/*BOOL        FALSE */
3862 	fBackground = 831,	/*BOOL        FALSE       If TRUE, this is the */
3863 	spcot = 832,		/*MSOSPCOT  TwoSegment  Callout type */
3864 	dxyCalloutGap = 833,	/*LONG      1/12 inch   Distance from box to */
3865 	spcoa = 834,		/*MSOSPCOA  Any         Callout angle */
3866 	spcod = 835,		/*MSOSPCOD  Specified   Callout drop type */
3867 	dxyCalloutDropSpecified = 836,	/*LONG      9 points    if msospcodSpecified, the */
3868 	dxyCalloutLengthSpecified = 837,	/*LONG      0           if */
3869 	fCallout = 889,		/*BOOL      FALSE       Is the shape a callout? */
3870 	fCalloutAccentBar = 890,	/*BOOL      FALSE       does callout have accent */
3871 	fCalloutTextBorder = 891,	/*BOOL      TRUE        does callout have a text */
3872 	fCalloutMinusX = 892,	/*BOOL      FALSE */
3873 	fCalloutMinusY = 893,	/*BOOL      FALSE */
3874 	fCalloutDropAuto = 894,	/*BOOL      FALSE       If true, then we */
3875 	fCalloutLengthSpecified = 895,	/*BOOL      FALSE       if true, we look at */
3876 	wzName = 896,		/*WCHAR*         NULL            Shape Name */
3877 	wzDescription = 897,	/*WCHAR*         NULL            alternate */
3878 	pihlShape = 898,	/*IHlink*        NULL            The hyperlink */
3879 	pWrapPolygonVertices = 899,	/*IMsoArray      NULL            The polygon */
3880 	dxWrapDistLeft = 900,	/*LONG           1/8 inch        Left wrapping */
3881 	dyWrapDistTop = 901,	/*LONG           0               Top wrapping */
3882 	dxWrapDistRight = 902,	/*LONG           1/8 inch        Right */
3883 	dyWrapDistBottom = 903,	/*LONG           0               Bottom */
3884 	lidRegroup = 904,	/*LONG           0               Regroup ID */
3885 	fEditedWrap = 953,	/*BOOL           FALSE           Has the wrap */
3886 	fBehindDocument = 954,	/*BOOL           FALSE           Word-only */
3887 	fOnDblClickNotify = 955,	/*BOOL           FALSE           Notify client */
3888 	fIsButton = 956,	/*BOOL           FALSE           A button */
3889 	fOneD = 957,		/*BOOL           FALSE           1D adjustment */
3890 	fHidden = 958,		/*BOOL           FALSE           Do not */
3891 	fPrint = 959		/*BOOL           TRUE            Print this */
3892     } pid;
3893 
3894 
3895     struct _fopte_list {
3896 	FOPTE afopte;
3897 	struct _fopte_list *next;
3898     };
3899 
3900     typedef struct _fopte_list fopte_list;
3901 
3902     struct _fsp_list {
3903 	FSP afsp;
3904 	fopte_list *afopte_list;
3905 	struct _fsp_list *next;
3906     };
3907 
3908     typedef struct _fsp_list fsp_list;
3909 
3910     struct _fbse_list {
3911 	FBSE afbse;
3912 	char filename[4096];
3913 	struct _fbse_list *next;
3914     };
3915 
3916     typedef struct _fbse_list fbse_list;
3917 
3918 
3919 
3920     fsp_list *wvParseEscher (fbse_list ** pic_list, U32 fcDggInfo,
3921 			     U32 lcbDggInfo, wvStream * escherstream,
3922 			     FILE * delaystream);
3923     fbse_list *wvGetSPID (U32 spid, fsp_list * afsp_list,
3924 			  fbse_list * afbse_list);
3925     U32 twvGetFBSE (FBSE * item, wvStream * fd);
3926 
3927 
3928 
3929 
3930 
3931 
3932 
3933 
3934 
3935 /*Summary Information Stream*/
3936 
3937     typedef struct _PropHeader {
3938 	U16 byteOrder;
3939 	U16 wFormat;
3940 	U16 osVersion1;
3941 	U16 osVersion2;
3942 	U8 classId[16];
3943 	U32 cSections;
3944     } PropHeader;
3945 
3946     void wvGetPropHeader (PropHeader * header, wvStream * file);
3947 
3948     typedef struct _FIDAndOffset {
3949 	U32 dwords[4];
3950 	U32 dwOffset;
3951     } FIDAndOffset;
3952 
3953     void wvGetFIDAndOffset (FIDAndOffset * fid, wvStream * file);
3954 
3955     typedef struct _aPro {
3956 	U32 propID;
3957 	U32 dwOffset;
3958     } aPro;
3959 
3960     typedef struct _SummaryInfo {
3961 	U32 cBytes;
3962 	U32 cProps;
3963 	aPro *aProps;
3964 	U8 *data;
3965     } SummaryInfo;
3966 
3967     int wvSumInfoOpenStream (SummaryInfo * si, wvStream * stream);
3968 
3969     void wvGetSummaryInfo (SummaryInfo * si, wvStream * file, U32 offset);
3970     void wvReleaseSummaryInfo (SummaryInfo * si);
3971 
3972     typedef struct _vtB {
3973 	U32 cBytes;
3974 	char *ch;
3975     } vtB;
3976 
3977 #define VT_I4           0x03
3978 #define VT_LPSTR        0x1E
3979 #define VT_FILETIME     0x40
3980 #define VT_WMF			0x47
3981 
3982     typedef struct _PropValue {
3983 	U32 vtType;
3984 	union {
3985 	    FILETIME vtTime;
3986 	    S32 vtLong;
3987 	    vtB vtBSTR;
3988 	} vtValue;
3989     } PropValue;
3990 
3991 /*String properties*/
3992 #define PID_TITLE          0x02
3993 #define PID_SUBJECT        0x03
3994 #define PID_AUTHOR         0x04
3995 #define PID_KEYWORDS       0x05
3996 #define PID_COMMENTS       0x06
3997 #define PID_TEMPLATE       0x07
3998 #define PID_LASTAUTHOR     0x08
3999 #define PID_REVNUMBER      0x09
4000 #define PID_APPNAME        0x12
4001 
4002 /*Time properties*/
4003 #define PID_TOTAL_EDITTIME 0x0A
4004 #define PID_LASTPRINTED    0x0B
4005 #define PID_CREATED        0x0C
4006 #define PID_LASTSAVED      0x0D
4007 
4008 /*Long integer properties*/
4009 #define PID_PAGECOUNT      0x0E
4010 #define PID_WORDCOUNT      0x0F
4011 #define PID_CHARCOUNT      0x10
4012 #define PID_SECURITY       0x13
4013 
4014 #define PID_THUMBNAIL	   0x11
4015 
4016 /*bit masks for security long integer*/
4017 #define AllSecurityFlagsEqNone         0x00
4018 #define fSecurityPassworded            0x01
4019 #define fSecurityRORecommended         0x02
4020 #define fSecurityRO                    0x04
4021 #define fSecurityLockedForAnnotations  0x08
4022 
4023     int wvGetProperty (PropValue * Prop, SummaryInfo * si, U32 pid);
4024     void wvReleaseProperty (PropValue * Prop);
4025 
4026     int wvSumInfoGetString (char *lpStr, U16 cbStr, U32 pid, SummaryInfo * si);
4027     int wvSumInfoGetLong (U32 * lpLong, U32 pid, SummaryInfo * si);
4028     int wvSumInfoGetTime (U16 * yr, U16 * mon, U16 * day, U16 * hr, U16 * min,
4029 			  U16 * sec, U32 pid, SummaryInfo * si);
4030     int wvSumInfoGetPreview (char *lpStr, U16 cbStr, U32 pid, SummaryInfo * si);
4031 
4032     void wvGetRowTap (wvParseStruct * ps, PAP * dpap, U32 para_intervals,
4033 		      BTE * btePapx, U32 * posPapx);
4034     void wvGetComplexRowTap (wvParseStruct * ps, PAP * dpap, U32 para_intervals,
4035 			     BTE * btePapx, U32 * posPapx, U32 piececount);
4036     void wvGetFullTableInit (wvParseStruct * ps, U32 para_intervals,
4037 			     BTE * btePapx, U32 * posPapx);
4038     void wvGetComplexFullTableInit (wvParseStruct * ps, U32 para_intervals,
4039 				    BTE * btePapx, U32 * posPapx, U32 piece);
4040 
4041 
4042 /*end of clean interface*/
4043 
4044 
4045 
4046 
4047 
4048 
4049 
4050 
4051 
4052 
4053 
4054 
4055 
4056 
4057 
4058 
4059     struct tTLP {
4060 	U16 itl;
4061 	U8 fShading;
4062 	U8 fColor;
4063 	U8 fHdrRows;
4064 	U8 fLastRow;
4065 	U8 fHdrCols;
4066 	U8 fLastCol;
4067     };
4068 
4069     typedef struct tTLP oTLP;
4070 
4071     struct ttablelook {
4072 	/* TOP BAR
4073 	   color for the top left entry
4074 	   color for the otherwise odd top entries
4075 	   color for the even top entries
4076 	 */
4077 
4078 	/* EVEN ROWS
4079 	   color for the left entry
4080 	   color for the otherwise odd row entries
4081 	   color for the even entries
4082 	 */
4083 
4084 	/* ODD ROWS
4085 	   color for the left entry
4086 	   color for the otherwise odd row entries
4087 	   color for the even entries
4088 	 */
4089 
4090 	char *color[9];
4091     };
4092 
4093     typedef struct ttablelook tablelook;
4094 
4095 
4096 
4097     struct tobj_by_spid {
4098 	U16 spid;
4099 	char *filename;
4100 	struct tobj_by_spid *next;
4101     };
4102 
4103     typedef struct tobj_by_spid obj_by_spid;
4104 
4105     struct node {
4106 	char streamname[255];
4107 	char filename[PATH_MAX];
4108 	struct node *next;
4109 	int level;
4110     };
4111 
4112     typedef struct node olestream;
4113 
4114     struct tsep {
4115 	U8 bkc;			/*break code */
4116 	U8 fTitlePage;		/*want title page */
4117 	U8 fAutoPgn;		/*unused */
4118 	U8 nfcPgn;		/*page no format */
4119 	U8 fUnlocked;		/*huh ? */
4120 	U8 cnsPgn;		/*huh ? */
4121 	U8 fPgnRestart;		/*restart pg numering */
4122 	U8 fEndNote;		/*footnotes at end of sec or page */
4123 	U8 lnc;			/*huh ? */
4124 	U8 grpfIhdt;		/*not used */
4125 	U8 nLnnMod;
4126 	U16 ccolM1;
4127 	U16 pgnStart;
4128 	U32 xaPage;
4129 	U32 yaPage;
4130 	U32 dxaLeft;
4131 	U32 dxaRight;
4132 	U32 dyaTop;
4133 	U32 dyaBottom;
4134 	U32 dzaGutter;
4135     };
4136 
4137     typedef struct tsep sep;
4138 
4139     struct tchp {
4140 	unsigned short istd;
4141 
4142 	U32 fBold:1;
4143 	U32 fItalic:1;
4144 	U32 fRMarkDel:1;
4145 	U32 fOutline:1;		/*not imp yet */
4146 	U32 fFldVanish:1;	/*not imp yet, internal to word */
4147 	U32 fSmallCaps:1;
4148 	U32 fCaps:1;
4149 	U32 fVanish:1;		/*not imp yet */
4150 	U32 fRMark:1;		/*not imp yet */
4151 	U32 fSpec:1;
4152 	U32 fStrike:1;
4153 	U32 fObj:1;		/*not imp yet */
4154 	U32 fShadow:1;		/*not imp yet */
4155 	U32 fLowerCase:1;	/*not imp yet */
4156 	U32 fData:1;
4157 	U32 fOle2:1;		/*not imp yet */
4158 	U32 fEmboss:1;		/*not imp yet */
4159 	U32 fImprint:1;		/*not imp yet */
4160 	U32 fDStrike:1;
4161 	U32 fUsePgsuSettings:1;	/*not imp yet, dont know what it means */
4162 	U32 Reserved1:12;	/*unused */
4163 
4164 	U32 Reserved2;		/*unused */
4165 
4166 	U16 ftc;		/*not used in word 8 */
4167 	U16 ftcAscii;
4168 	U16 ftcFE;
4169 	U16 ftcOther;
4170 
4171 	U16 fontsize;		/*half points */
4172 	U8 supersubscript;
4173 	S16 fontcode;
4174 	U16 fontspec;
4175 	char color[8];
4176 	U16 underline;
4177 	U8 idctHint;
4178 	U32 fcPic;
4179 
4180 	U16 ibstRMark;
4181 	U16 ibstRMarkDel;
4182 	DTTM dttmRMark;
4183 	DTTM dttmRMarkDel;
4184 
4185 	U16 fPropRMark;
4186 	U16 ibstPropRMark;
4187 	DTTM dttmPropRMark;
4188 	U8 sfxtText;
4189     };
4190 
4191     typedef struct tchp chp;
4192 
4193     struct tlist_def {
4194 	U16 *list_string;
4195 	int len;
4196 	S16 begin_no;
4197 	int no_type;
4198 	int fPrev;
4199 	U32 id;
4200 	chp achp;
4201 	struct tlist_def *sub_def_list;
4202     };
4203 
4204     typedef struct tlist_def list_def;
4205 
4206     struct ttap {
4207 	oTLP tlp;
4208 	int tablewidth;
4209 	S16 cellwidth[65];
4210 	int cell_no;
4211 	int shade_no;
4212 	int cell_backs[65];
4213 	int cell_fronts[65];
4214 	int cell_pattern[65];
4215 	int rowheight;
4216     };
4217 
4218     typedef struct ttap tap;
4219 
4220     struct tpap {
4221 	unsigned short istd;
4222 	U8 fInTable;
4223 	U8 fTtp;
4224 	U8 tableflag;
4225 	int justify;
4226 	int ilvl;		/*list level, 0 to 8 */
4227 	long ilfo;		/*list index */
4228 	/*link to list information */
4229 	list_def *list_data;
4230 	ANLD anld;
4231 	tap ourtap;
4232 	S16 leftmargin;
4233 	S16 rightmargin;
4234 	S16 firstline;
4235 	U32 brcBottom;
4236 	U32 brcLeft;
4237 	U32 brcRight;
4238 	U32 brcBetween;
4239 	U16 dxaWidth;
4240 	U32 dyaBefore;
4241 	U32 dyaAfter;
4242 	char *begin;
4243 	char *end;
4244 	char *prespace;
4245 	char *postspace;
4246     };
4247 
4248     typedef struct tpap pap;
4249 
4250 
4251     struct field_pro {
4252 	U32 *cps;
4253 	FLD *flds;
4254 	U32 no;
4255     };
4256 
4257     typedef struct field_pro field_info;
4258 
4259     struct tlist_info {
4260 	/*
4261 	   now this is very hairy, i not sure how this is supposed to work
4262 	   so lists are a bit tentitive, basically theres no many things you
4263 	   *can* do with lists, but hopefully this will sort out whether they
4264 	   are bulleted or enumerated, and ignore all sorts of shite like
4265 	   what kind of bullet were talking about, and whether some list
4266 	   items are numbered etc etc
4267 	 */
4268 	U8 *array;
4269 	int count;
4270 	int nooflsts;
4271 	U32 *o_lst_ids;
4272 	int **current_index_nos;
4273 	list_def *o_list_def;
4274 	U8 *level;
4275 
4276 	U8 *lstarray;
4277 	int lstcount;
4278 	U32 nooflfos;
4279 	U32 *lst_ids;
4280 	list_def *a_list_def;
4281 	int *overridecount;
4282 
4283 
4284 	/*
4285 	   temp placed here, will eventually replace the other rubbish
4286 	 */
4287 	LFO *lfo;
4288 	U32 nolfo;
4289 	LFOLVL *lfolvl;
4290 	U32 nooflvl;
4291 	LVL *lvl;
4292 
4293 	LST *lst;
4294 	U16 noofLST;
4295     };
4296 
4297     typedef struct tlist_info list_info;
4298 
4299     struct tsprm {
4300 	U8 *list;
4301 	struct tsprm *next;
4302 	int len;
4303     };
4304 
4305     typedef struct tsprm tSprm;
4306 
4307     struct tcstyle {
4308 	pap thepap;
4309 	chp thechp;
4310 	char *begin;
4311 	char *end;
4312 	char *name;
4313 	char *prespace;
4314 	char *postspace;
4315 	char *Default;
4316 	char *bold;
4317 	char *italic;
4318 	char *font;
4319 	struct tcstyle *next;
4320     };
4321 
4322     typedef struct tcstyle config_style;
4323 
4324     struct _document_style {
4325 	char *begin;
4326 	int htwips;
4327 	int vtwips;
4328 	char *end;
4329     };
4330 
4331     typedef struct _document_style document_style;
4332 
4333     struct _element_style {
4334 	char *begin;
4335 	char *end;
4336     };
4337 
4338     typedef struct _element_style element_style;
4339 
4340     typedef enum {
4341 	BOLD,
4342 	ITALIC,
4343 	FONT
4344     } ele_type;
4345 
4346     struct tstyle {
4347 	/*temp put in hooks for new stylesheet */
4348 	STSH stsh;
4349 	pap thepap;
4350 	chp thechp;
4351 	char *name;
4352 	char *begin;
4353 	char *end;
4354 	char *Default;
4355 	char *prespace;
4356 	char *postspace;
4357 	char *font;
4358 	char *bold;
4359 	char *italic;
4360     };
4361 
4362     typedef struct tstyle style;
4363 
4364     struct tbookmark_limits {
4365 	U32 bookmark_b_no;
4366 	U32 *bookmark_b_cps;
4367 	BKF *bookmark_b_bkfs;
4368 	U32 bookmark_e_no;
4369 	U32 *bookmark_e_cps;
4370     };
4371 
4372     typedef struct tbookmark_limits bookmark_limits;
4373 
4374 
4375     struct ttextportions {
4376 	U32 fcMin;
4377 	U32 fcMac;
4378 	U32 ccpText;
4379 	U32 ccpFtn;
4380 	U32 ccpHdr;
4381 	U32 ccpAtn;
4382 	U32 ccpEdn;
4383 	U32 fcPlcfhdd;
4384 	U32 lcbPlcfhdd;
4385 	U32 *headercplist;
4386 	U8 headercpno;
4387 
4388 	U32 fndref_no;
4389 	U32 fndtxt_no;
4390 	U32 *fndRef;
4391 	FRD *fndFRD;
4392 	U32 *fndTxt;
4393 	int list_footnotes[256];
4394 	int list_foot_no;
4395 	int auto_foot;
4396 	int last_foot;
4397 
4398 	U32 endref_no;
4399 	U32 endtxt_no;
4400 	U32 *endRef;
4401 	FRD *endFRD;
4402 	S16 *endTrueFRD;
4403 	U32 *endTxt;
4404 	int list_endnotes[256];
4405 	int list_end_no;
4406 	int auto_end;
4407 
4408 	U32 andref_no;
4409 	U32 *andRef;
4410 	U32 andtxt_no;
4411 	U32 *andTxt;
4412 	int list_annotations[256];
4413 	int list_anno_no;
4414 	Xst *authors;
4415 	STTBF annotations;
4416 	bookmark_limits a_bookmarks;
4417 	ATRD *the_atrd;
4418 	int last_anno;
4419 
4420 	bookmark_limits l_bookmarks;
4421 	STTBF bookmarks;
4422 
4423 	/*
4424 	   STTBF revisions;
4425 	 */
4426 
4427 	U32 *section_cps;
4428 	SED *section_fcs;
4429 	U32 section_nos;
4430 
4431 	U32 noofficedraw;
4432 	U32 *officedrawcps;
4433 	FSPA *fspas;		/*im ignoring the rest of the FSPA for now */
4434 
4435 	int noofblipdata;
4436 	obj_by_spid *ablipdata;
4437     };
4438 
4439     typedef struct ttextportions textportions;
4440 
4441 #define IGNORENUM 0
4442 #define DONTIGNORENUM 1
4443 #define IGNOREALL 2
4444 
4445     U32 read_32ubit (wvStream * in);
4446     U16 read_16ubit (wvStream * in);
4447     U8 read_8ubit (wvStream * in);
4448 
4449     U32 sread_32ubit (const U8 * in);
4450     U16 sread_16ubit (const U8 * in);
4451     U8 sread_8ubit (const U8 * in);
4452 
4453     U32 dread_32ubit (wvStream * in, U8 ** list);
4454     U16 dread_16ubit (wvStream * in, U8 ** list);
4455     U8 dread_8ubit (wvStream * in, U8 ** list);
4456 
4457     U32 bread_32ubit (U8 * in, U16 * pos);
4458     U16 bread_16ubit (U8 * in, U16 * pos);
4459     U8 bread_8ubit (U8 * in, U16 * pos);
4460 
4461 /* Perform file-I/O-like operations on wvStreams. */
4462     U32 wvStream_read (void *ptr, size_t size, size_t nmemb, wvStream * stream);
4463     void wvStream_rewind (wvStream * stream);
4464     U32 wvStream_goto (wvStream * stream, long position);
4465     U32 wvStream_offset (wvStream * stream, long offset);
4466     U32 wvStream_offset_from_end (wvStream * stream, long offset);
4467     U32 wvStream_size (wvStream * stream);
4468     U32 wvStream_tell (wvStream * stream);
4469 
4470 /* These functions take care of memory/file management for wvStreams */
4471     void wvStream_FILE_create (wvStream ** in, FILE * inner);
4472   wvStream * wvStream_TMP_create (size_t size);
4473     void wvStream_gsf_create (wvStream ** in, GsfInput * inner);
4474     void wvStream_memory_create (wvStream ** in, char *buf, size_t size);
4475     void wvStream_create (wvStream ** in, wvStreamKind kind,
4476 			  wvInternalStream inner);
4477     U32 wvStream_close (wvStream * stream);
4478 
4479 /* The above functions store all the streams we open in one of these, so that
4480  * we can clean up nicely.
4481  */
4482     struct twvStream_list {
4483 	wvStream *stream;
4484 	struct twvStream_list *next;
4485     };
4486     typedef struct twvStream_list wvStream_list;
4487 
4488     void external_wvReleasePAPX_FKP (void);
4489     void external_wvReleaseCHPX_FKP (void);
4490 
4491     void cleanupstreams (char *analyze, char *slashtmp);
4492     olestream *divide_streams (char *filename, char **analyze, char **slashtmp,
4493 			       char *argv0);
4494     int decode_word8 (wvParseStruct * ps, int core);
4495     void get_table_info (wvStream * tablefd, list_info * a_list_info,
4496 			 U32 fcSttbFnm, U32 lcbSttbFnm, U32 fcPlcfLst,
4497 			 U32 lcbPlcfLst, U32 fcPlfLfo, U32 lcbPlfLfo,
4498 			 style * sheet);
4499 
4500     pap *get_pap (U32 pageindex, wvStream * in, U32 charindex, U32 * nextfc,
4501 		  style * sheet, list_info * a_list_info);
4502     chp *get_chp (U32 pageindex, wvStream * in, FILE * data, U32 charindex,
4503 		  U32 * nextfc, style * sheet, U16 istd);
4504     sep *get_sep (U32 offset, wvStream * in);
4505 
4506     void decode_clx (U32 startpiece, U32 begincp, U32 endcp, wvStream * in,
4507 		     FILE * main, FILE * data, U32 fcClx, U32 lcbClx,
4508 		     U32 intervals, U32 chpintervals, U32 * plcfbtePapx,
4509 		     U32 * plcfbteChpx, field_info * all_fields[5],
4510 		     list_info * a_list_info, style * sheet,
4511 		     textportions * portions, FFN_STTBF * ffn_sttbf,
4512 		     int headfooterflag);
4513     void decode_clx_header (U32 * rgfc, sep * asep, int nopieces,
4514 			    U32 startpiece, U32 begincp, U32 endcp,
4515 			    wvStream * in, FILE * main, FILE * data, U32 fcClx,
4516 			    U32 lcbClx, U32 intervals, U32 chpintervals,
4517 			    U32 * plcfbtePapx, U32 * plcfbteChpx,
4518 			    field_info * all_fields[5], list_info * a_list_info,
4519 			    style * sheet, textportions * portions,
4520 			    FFN_STTBF * ffn_sttbf, int headerfooterflag);
4521     void decode_clx_footer (U32 * rgfc, sep * asep, int nopieces,
4522 			    U32 startpiece, U32 begincp, U32 endcp,
4523 			    wvStream * in, FILE * main, FILE * data, U32 fcClx,
4524 			    U32 lcbClx, U32 intervals, U32 chpintervals,
4525 			    U32 * plcfbtePapx, U32 * plcfbteChpx,
4526 			    field_info * all_fields[5], list_info * a_list_info,
4527 			    style * sheet, textportions * portions,
4528 			    FFN_STTBF * ffn_sttbf, int headerfooterflag);
4529     int decode_clx_endnote (U32 * rgfc, sep * asep, int nopieces,
4530 			    U32 startpiece, U32 begincp, U32 endcp,
4531 			    wvStream * in, FILE * main, FILE * data, U32 fcClx,
4532 			    U32 lcbClx, U32 intervals, U32 chpintervals,
4533 			    U32 * plcfbtePapx, U32 * plcfbteChpx,
4534 			    field_info * all_fields[5], list_info * a_list_info,
4535 			    style * sheet, textportions * portions,
4536 			    FFN_STTBF * ffn_sttbf, int headerfooterflag);
4537 
4538     void decode_simple (wvStream * mafd, FILE * tablefd, FILE * data, U32 fcClx,
4539 			U32 fcMin, U32 fcMac, U32 intervals, U32 chpintervals,
4540 			U32 * plcfbtePapx, U32 * plcfbteChpx,
4541 			field_info * all_fields[5], list_info * a_list_info,
4542 			style * sheet, textportions * portions,
4543 			FFN_STTBF * ffn_sttbf, int flag);
4544     int decode_simple_footer (wvStream * mafd, FILE * tablefd, FILE * data,
4545 			      sep * asep, U32 fcClx, U32 fcMin, U32 fcMac,
4546 			      U32 intervals, U32 chpintervals,
4547 			      U32 * plcfbtePapx, U32 * plcfbteChpx,
4548 			      field_info * all_fields[5],
4549 			      list_info * a_list_info, style * sheet,
4550 			      textportions * portions, FFN_STTBF * ffn_sttbf,
4551 			      int flag);
4552     int decode_simple_endnote (wvStream * mafd, FILE * tablefd, FILE * data,
4553 			       sep * asep, U32 fcClx, U32 fcMin, U32 fcMac,
4554 			       U32 intervals, U32 chpintervals,
4555 			       U32 * plcfbtePapx, U32 * plcfbteChpx,
4556 			       field_info * all_fields[5],
4557 			       list_info * a_list_info, style * sheet,
4558 			       textportions * portions, FFN_STTBF * ffn_sttbf,
4559 			       int flag);
4560     void decode_simple_header (wvStream * mafd, FILE * tablefd, FILE * data,
4561 			       sep * asep, U32 fcClx, U32 fcMin, U32 fcMac,
4562 			       U32 intervals, U32 chpintervals,
4563 			       U32 * plcfbtePapx, U32 * plcfbteChpx,
4564 			       field_info * all_fields[5],
4565 			       list_info * a_list_info, style * sheet,
4566 			       textportions * portions, FFN_STTBF * ffn_sttbf,
4567 			       int flag);
4568 
4569     int decode_letter (int letter, int flag, pap * apap, chp * achp,
4570 		       field_info * magic_fields, wvStream * main, FILE * data,
4571 		       FFN_STTBF * ffn_sttbf, list_info * a_list_info,
4572 		       textportions * portions, int *issection, style * sheet);
4573     void get_next_f_ref (textportions * portions, signed long *nextfootnote);
4574     void get_next_e_ref (textportions * portions, signed long *nextendnote);
4575 
4576     void decode_s_specials (pap * apap, chp * achp, list_info * a_list_info);
4577     int decode_s_table (pap * apap, chp * achp, list_info * a_list_info,
4578 			int silent);
4579     void decode_e_specials (pap * apap, chp * achp, list_info * a_list_info);
4580     int decode_e_table (pap * apap, chp * achp, list_info * a_list_info,
4581 			int silent);
4582 
4583     void decode_s_chp (chp * achp, FFN_STTBF *, style *);
4584     void decode_e_chp (chp * achp);
4585 
4586     void chpsoff (void);
4587     void chpson (void);
4588 
4589     void decode_list_nfc (int value, int no_type);
4590     void decode_list_level (pap * apap, int inalist, int num);
4591 
4592     int flushbreaks (int);
4593 
4594     void decode_s_anld (pap * apap, chp * achp, list_info * a_list_info,
4595 			FFN_STTBF * ffn_sttbf, style * sheet);
4596     void decode_s_list (pap * apap, chp * achp, list_info * a_list_info,
4597 			FFN_STTBF * ffn_sttbf, int num, style * sheet);
4598     void decode_e_list (pap * apap, chp * achp, list_info * a_list_info);
4599 
4600     void decode_field (wvStream * main, field_info * magic_fields, long *cp,
4601 		       U8 * fieldwas, unsigned long *swallowcp1,
4602 		       unsigned long *swallowcp2);
4603 
4604     int find_FKPno_papx (U32 fc, U32 * plcfbtePapx, U32 intervals);
4605     int find_FKPno_chpx (U32 fc, U32 * plcfbteChpx, U32 intervals);
4606     U32 find_FC_sepx (U32 cp, U32 * sepcp, textportions * portions);
4607     U32 find_next_smallest_fc (U32 charindex, U32 pageindex, wvStream * in,
4608 			       S16 * location, long *pos);
4609     U32 find_next_biggest_fc (U32 charindex, U32 pageindex, wvStream * in,
4610 			      U16 * location, long *pos);
4611     U32 find_next_biggest_orequal_fc (U32 charindex, U32 pageindex,
4612 				      wvStream * in, U16 * location, long *pos);
4613 
4614     pap *get_complex_pap (U32 fc, U32 * plcfbtePapx, U16 i, U16 nopieces,
4615 			  U32 intervals, U32 * rgfc, wvStream * main,
4616 			  U32 * avalrgfc, U32 * thenextone, U32 * paraendfc,
4617 			  int *paraendpiece, style * sheet,
4618 			  list_info * a_list_info);
4619     chp *get_complex_chp (U32 fc, U32 * plcfbteChpx, U16 i, U16 nopieces,
4620 			  U32 chpintervals, U32 * rgfc, wvStream * main,
4621 			  U32 * avalrgfc, U32 * thenextone, style * sheet,
4622 			  U16 istd);
4623 
4624 #if 0
4625     void decode_gpprls (pap * apap, chp * achp, sep * asep, U16 * gpprlindex,
4626 			int index, tSprm * sprmlists, style * sheet);
4627 #endif
4628 
4629     style *decode_stylesheet (wvStream * tablefd, U32 stsh, U32 stshlen,
4630 			      config_style * in_style);
4631     void fill_pap (style * stylelist, int m, int b);
4632 
4633     void decode_sprm (FILE * in, U16 clist, pap * retpap, chp * retchp,
4634 		      sep * retsep, U16 * pos, U8 ** list, style * sheet,
4635 		      U16 istd);
4636 
4637     void error (FILE * stream, char *fmt, ...);
4638     void oprintf (int silentflag, char *fmt, ...);
4639 
4640     int decode_symbol (U16 fontspec);
4641     char *symbolfontdir (void);
4642 
4643     int decode_wingding (U16 fontspec);
4644     char *wingdingfontdir (void);
4645 
4646     char *patterndir (void);
4647 
4648     void decode_header (U32 * begin, U32 * len, textportions * portions,
4649 			sep * asep);
4650     void decode_header2 (U32 * begin, U32 * len, textportions * portions);
4651     void decode_footer (U32 * begin, U32 * len, textportions * portions,
4652 			sep * asep);
4653     void decode_footnote (U32 * begin, U32 * len, textportions * portions,
4654 			  int i);
4655     void decode_endnote (U32 * begin, U32 * len, textportions * portions,
4656 			 int i);
4657     void decode_footanno (U32 * begin, U32 * len, textportions * portions,
4658 			  int i);
4659 
4660     int find_piece_cp (U32 sepcp, U32 * rgfc, int nopieces);
4661 
4662     obj_by_spid *get_blips (U32 fcDggInfo, U32 lcbDggInfo, wvStream * tablefd,
4663 			    FILE * mafd, int *noofblips, int streamtype,
4664 			    obj_by_spid ** realhead);
4665     void output_draw (U32 cp, textportions * portions);
4666 
4667     void do_indent (pap * apap);
4668 
4669     U32 get_fc_from_cp (U32 acp, U32 * rgfc, U32 * avalrgfc, int nopieces);
4670 
4671     void end_para (pap * apap, pap * newpap);
4672 
4673 /*
4674 returns slot to use in index array which keeps track of how far each list
4675 has got
4676 */
4677     int decode_ilfo (pap * retpap, chp * achp, list_info * a_list_info,
4678 		     style * sheet, FFN_STTBF * ffn_sttbf);
4679 
4680     void init_chp (chp * achp);
4681     void init_pap (pap * apap);
4682 
4683 /*result += modified - blank*/
4684     void merge_chps (chp * blank, chp * modified, chp * result);
4685 
4686     void init_chp_from_istd (U16 istd, style * sheet, chp * retchp);
4687     void init_pap_from_istd (U16 istd, style * sheet, pap * retpap);
4688 
4689     void get_para_bounds (int currentpiece, U32 fc, U32 * rgfc, U32 * avalrgfc,
4690 			  int nopieces, U32 * plcfbtePapx, U32 intervals,
4691 			  wvStream * main);
4692 
4693     char *ms_strlower (char *in);
4694 
4695 /* returns
4696 0 for no error
4697 1 for file doesn't exist
4698 2 if it isnt an ole file
4699 3 if its corrupt
4700 */
4701     int wvOLEDecode (wvParseStruct * ps,
4702 		     char *path, wvStream ** mafd, wvStream ** tablefd0,
4703 		     wvStream ** tablefd1, wvStream ** data,
4704 		     wvStream ** summary);
4705     int wvOLESummaryStream (char *filename, wvStream ** summary);
4706 
4707     long get_picture_header (U32 fcPic, wvStream * data, U32 * len,
4708 			     U16 * datatype);
4709 
4710     void cleanupglobals (void);
4711     char *ms_basename (char *filename);
4712     void outputimgsrc (char *filename, int width, int height);
4713 
4714 
4715     U32 decode_b_bookmark (bookmark_limits * l_bookmarks, STTBF * bookmarks);
4716     U32 decode_e_bookmark (bookmark_limits * l_bookmarks);
4717 
4718     void output_tablebg (pap * apap);
4719     int do_tablelooks (pap * apap);
4720 
4721     int setdecom (void);
4722 
4723     void pagebreak (void);
4724     void columnbreak (void);
4725     void sectionbreak (sep * asep);
4726     void copy_tap (tap * rettap, tap * intap);
4727     void check_auto_color (chp * achp);
4728 
4729     void extract_bookm_limits (bookmark_limits * l_bookmarks,
4730 			       wvStream * tablefd, U32 fcPlcfbkf,
4731 			       U32 lcbPlcfbkf, U32 fcPlcfbkl, U32 lcbPlcfbkl);
4732 
4733     int use_fontfacequery (chp * achp);
4734 
4735     char *notoday (int no);
4736 
4737     void convertwmf (char *filename);
4738 
4739     int Parse (wvStream * in, config_style ** in_style,
4740 	       document_style ** doc_style, element_style * ele_style);
4741     int do_output_start (U32 * avalrgfc, int nopieces,
4742 			 document_style * doc_style);
4743     void do_output_end (document_style * doc_style, int core, int tail);
4744     char *argument (void);
4745 
4746     void fill_table_info (pap * apap, U32 tapfc1, U32 * plcfbtePapx,
4747 			  U32 intervals, wvStream * mafd, style * sheet,
4748 			  list_info * a_list_info);
4749 
4750     char *expand_variables (char *in, pap * apap);
4751     char *expand_element (char *in, char *fontface, char *color, char *size);
4752     void init_sep (sep * asep);
4753     char *get_image_prefix (void);
4754 
4755     int add_t (int **vals, S16 * p, int plen);
4756     int gcf (int high, int low);
4757     int gcf_list (int *vals, int cno);
4758     int allowedfont (style * sheet, U16 istd);
4759 
4760 #define NOOFIDS 8
4761 
4762 /*interim*/
4763     U32 wvGetSPIDfromCP (U32 cp, textportions * portions);
4764     void oldwvGetPICF (PICF * apicf, wvStream * fd, U32 offset);
4765 
4766 /* have to have pap replaced with PAP, and change the text output code to the new ones, whenever they are ready*/
4767     void wvGetListInfo (pap * apap, chp * achp, LFO * lfo, LFOLVL * lfolvl,
4768 			LVL * lvl, U32 nolfo, LST * lst, U16 noofLST,
4769 			style * sheet, FFN_STTBF * ffn_sttbf);
4770 /* have to have pap replaced with PAP*/
4771     void wvAddPAP_FromBucket (pap * pap, U8 * pointer8, U16 len, style * sheet);
4772 
4773 /*we have to replace chp with CHP*/
4774     void wvAddCHP_FromBucket (chp * achp, U8 * pointer8, U16 len,
4775 			      style * sheet);
4776     void twvCopyCHP (chp * dest, chp * src);
4777 
4778     void wvSetEntityConverter (expand_data * data);
4779 
4780 	int wvIsBidiDocument(wvParseStruct * ps);
4781 
4782 	int wvGetPLCF (void ** plcf, U32 offset, U32 len, wvStream * fd);
4783 
4784 /* & finally */
4785     extern const char* wv_version;
4786 
4787 #ifdef __cplusplus
4788 }
4789 #endif
4790 #endif
4791