summaryrefslogtreecommitdiff
path: root/support/RTF-1_06a1/rtf.h
blob: 30e4cb4bb814024781d52e277f7721d876164cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
/*
	rtf.h - RTF document processing stuff.  Distribution 1.06.
*/


/*
	Twentieths of a point (twips) per inch (Many RTF measurements
	are in twips per inch (tpi) units).  Assumes 72 points/inch.
*/

# define	rtfTpi		1440

/*
	RTF buffer size (avoids BUFSIZ, which differs across systems)
*/

# define	rtfBufSiz	1024

/*
	Tokens are associated with up to three classification numbers:

	Class number: Broadest (least detailed) breakdown.  For programs
		that only care about gross token distinctions.
	Major/minor numbers: Within their class, tokens have a major
		number, and may also have a minor number to further
		distinquish tokens with the same major number.

	*** Class, major and minor token numbers are all >= 0 ***

	Tokens that can't be classified are put in the "unknown" class.
	For such, the major and minor numbers are meaningless, although
	rtfTextBuf may be of interest then.

	Text tokens are a single character, and the major number indicates
	the character value (note: can be non-ascii, i.e., greater than 127).
	There is no minor number.

	Control symbols may have a parameter value, which will be found in
	rtfParam.

	RTFToken() return value is the class number, but it sets all the
	global token vars.

	rtfEOF is a fake token used by the reader; the writer never sees
	it (except in the token reader hook, if it installs one).
*/


/*
	Information pertaining to last token read by RTFToken.  The
	text is exactly as it occurs in the input file, e.g., "\{"
	will be found in rtfTextBuf as "\{", even though it means "{".
	These variables are also set when styles are reprocessed.
*/

extern char	rtfTextBuf[rtfBufSiz];	/* text of token */
extern int	rtfTextLen;		/* length of token in rtfTextBuf */
extern int	rtfClass;		/* token class */
extern int	rtfMajor;		/* token major number */
extern int	rtfMinor;		/* token minor number */
extern int	rtfParam;		/* control symbol parameter */


/*
	Token classes (must be zero-based and sequential)
*/

# define	rtfUnknown	0
# define	rtfGroup	1
# define	rtfText		2
# define	rtfControl	3
# define	rtfEOF		4
# define	rtfMaxClass	5	/* highest class + 1 */

/*
	Brace class major numbers
*/

# define	rtfBeginGroup	0
# define	rtfEndGroup	1

/*
	Control class major and minor numbers.
*/

# define	rtfVersion	0

# define	rtfDefFont	1

# define	rtfCharSet	2
# define		rtfAnsiCharSet		0
# define		rtfMacCharSet		1
# define		rtfPcCharSet		2
# define		rtfPcaCharSet		3


/*	destination minor numbers should be zero-based, sequential */

# define	rtfDestination	3
# define		rtfPict			0
# define		rtfFootnote		1
# define		rtfHeader		2
# define		rtfHeaderLeft		3
# define		rtfHeaderRight		4
# define		rtfHeaderFirst		5
# define		rtfFooter		6
# define		rtfFooterLeft		7
# define		rtfFooterRight		8
# define		rtfFooterFirst		9
# define		rtfFNSep		10
# define		rtfFNContSep		11
# define		rtfFNContNotice		12
# define		rtfInfo			13
# define		rtfStyleSheet		14
# define		rtfFontTbl		15
# define		rtfColorTbl		16
# define		rtfField		17
# define		rtfFieldInst		18
# define		rtfFieldResult		19
# define		rtfIndex		20
# define		rtfIndexBold		21
# define		rtfIndexItalic		22
# define		rtfIndexText		23
# define		rtfIndexRange		24
# define		rtfTOC			25
# define		rtfBookmarkStart	26
# define		rtfBookmarkEnd		27
# define		rtfITitle		28
# define		rtfISubject		29
# define		rtfIAuthor		30
# define		rtfIOperator		31
# define		rtfIKeywords		32
# define		rtfIComment		33
# define		rtfIVersion		34
# define		rtfIDoccomm		35
# define		rtfMaxDestination	36	/* highest dest + 1 */

# define	rtfFontFamily	4
# define		rtfFFNil		0
# define		rtfFFRoman		1
# define		rtfFFSwiss		2
# define		rtfFFModern		3
# define		rtfFFScript		4
# define		rtfFFDecor		5
# define		rtfFFTech		6

# define	rtfColorName	5
# define		rtfRed			0
# define		rtfGreen		1
# define		rtfBlue			2

# define	rtfSpecialChar	6
# define		rtfCurHeadPage		0
# define		rtfCurFNote		1
# define		rtfCurHeadPict		2	/* valid? */
# define		rtfCurHeadDate		3
# define		rtfCurHeadTime		4
# define		rtfFormula		5
# define		rtfNoBrkSpace		6
# define		rtfNoReqHyphen		7
# define		rtfNoBrkHyphen		8
# define		rtfPage			9
# define		rtfLine			10
# define		rtfPar			11
# define		rtfSect			12
# define		rtfTab			13
# define		rtfCell			14
# define		rtfRow			15
# define		rtfCurAnnot		16
# define		rtfAnnotation		17
# define		rtfAnnotID		18
# define		rtfCurAnnotRef		19
# define		rtfFNoteSep		20
# define		rtfFNoteCont		21
# define		rtfColumn		22
# define		rtfOptDest		23
# define		rtfIIntVersion		24
# define		rtfICreateTime		25
# define		rtfIRevisionTime	26
# define		rtfIPrintTime		27
# define		rtfIBackupTime		28
# define		rtfIEditTime		29
# define		rtfIYear		30
# define		rtfIMonth		31
# define		rtfIDay			32
# define		rtfIHour		33
# define		rtfIMinute		34
# define		rtfINPages		35
# define		rtfINWords		36
# define		rtfINChars		37
# define		rtfIIntID		38

# define	rtfStyleAttr	7
# define		rtfBasedOn		0
# define		rtfNext			1

# define	rtfDocAttr	8
# define		rtfPaperWidth		0
# define		rtfPaperHeight		1
# define		rtfLeftMargin		2
# define		rtfRightMargin		3
# define		rtfTopMargin		4
# define		rtfBottomMargin		5
# define		rtfFacingPage		6
# define		rtfGutterWid		7
# define		rtfDefTab		8
# define		rtfWidowCtrl		9
# define		rtfHyphHotZone		10
# define		rtfFNoteEndSect		11
# define		rtfFNoteEndDoc		12
# define		rtfFNoteText		13
# define		rtfFNoteBottom		14
# define		rtfFNoteStart		15
# define		rtfFNoteRestart		16
# define		rtfPageStart		17
# define		rtfLineStart		18
# define		rtfLandscape		19
# define		rtfFracWidth		20
# define		rtfNextFile		21
# define		rtfTemplate		22
# define		rtfMakeBackup		23
# define		rtfRTFDefault		24
# define		rtfRevisions		25
# define		rtfMirrorMargin		26
# define		rtfRevDisplay		27
# define		rtfRevBar		28

# define	rtfSectAttr	9
# define		rtfSectDef		0
# define		rtfNoBreak		1
# define		rtfColBreak		2
# define		rtfPageBreak		3
# define		rtfEvenBreak		4
# define		rtfOddBreak		5
# define		rtfPageStarts		6
# define		rtfPageCont		7
# define		rtfPageRestart		8
# define		rtfPageDecimal		9
# define		rtfPageURoman		10
# define		rtfPageLRoman		11
# define		rtfPageULetter		12
# define		rtfPageLLetter		13
# define		rtfPageNumLeft		14
# define		rtfPageNumTop		15
# define		rtfHeaderY		16
# define		rtfFooterY		17
# define		rtfLineModulus		18
# define		rtfLineDist		19
# define		rtfLineStarts		20
# define		rtfLineRestart		21
# define		rtfLineRestartPg	22
# define		rtfLineCont		23
# define		rtfTopVAlign		24
# define		rtfBottomVAlign		25
# define		rtfCenterVAlign		26
# define		rtfJustVAlign		27
# define		rtfColumns		28
# define		rtfColumnSpace		29
# define		rtfColumnLine		30
# define		rtfENoteHere		31
# define		rtfTitleSpecial		32

# define	rtfTblAttr	10
# define		rtfCellBordBottom	0
# define		rtfCellBordTop		1
# define		rtfCellBordLeft		2
# define		rtfCellBordRight	3
# define		rtfRowDef		4
# define		rtfRowLeft		5
# define		rtfRowRight		6
# define		rtfRowCenter		7
# define		rtfRowGapH		8
# define		rtfRowHt		9
# define		rtfRowLeftEdge		10
# define		rtfCellPos		11
# define		rtfMergeRngFirst	12
# define		rtfMergePrevious	13

# define	rtfParAttr	11
# define		rtfParDef		0
# define		rtfStyleNum		1
# define		rtfQuadLeft		2
# define		rtfQuadRight		3
# define		rtfQuadJust		4
# define		rtfQuadCenter		5
# define		rtfFirstIndent		6
# define		rtfLeftIndent		7
# define		rtfRightIndent		8
# define		rtfSpaceBefore		9
# define		rtfSpaceAfter		10
# define		rtfSpaceBetween		11
# define		rtfInTable		12
# define		rtfKeep			13
# define		rtfKeepNext		14
# define		rtfSideBySide		15
# define		rtfPBBefore		16
# define		rtfNoLineNum		17
# define		rtfTabPos		18
# define		rtfTabRight		19
# define		rtfTabCenter		20
# define		rtfTabDecimal		21
# define		rtfTabBar		22
# define		rtfBorderTop		23
# define		rtfBorderBottom		24
# define		rtfBorderLeft		25
# define		rtfBorderRight		26
# define		rtfBorderBox		27
# define		rtfBorderBar		28
# define		rtfBorderBetween	29
# define		rtfBorderSingle		30
# define		rtfBorderThick		31
# define		rtfBorderShadow		32
# define		rtfBorderDouble		33
# define		rtfBorderDot		34
# define		rtfBorderHair		35
# define		rtfBorderSpace		36
# define		rtfLeaderDot		37
# define		rtfLeaderHyphen		38
# define		rtfLeaderUnder		39
# define		rtfLeaderThick		40

# define	rtfCharAttr	12
# define		rtfPlain		0
# define		rtfBold			1
# define		rtfItalic		2
# define		rtfStrikeThru		3
# define		rtfOutline		4
# define		rtfShadow		5
# define		rtfSmallCaps		6
# define		rtfAllCaps		7
# define		rtfInvisible		8
# define		rtfFontNum		9
# define		rtfFontSize		10
# define		rtfExpand		11
# define		rtfUnderline		12
# define		rtfWUnderline		13
# define		rtfDUnderline		14
# define		rtfDbUnderline		15
# define		rtfNoUnderline		16
# define		rtfSuperScript		17
# define		rtfSubScript		18
# define		rtfRevised		19
# define		rtfForeColor		20
# define		rtfBackColor		21

# define	rtfPictAttr	13
# define		rtfMacQD		0
# define		rtfWinMetafile		1
# define		rtfWinBitmap		2
# define		rtfPicWid		3
# define		rtfPicHt		4
# define		rtfPicGoalWid		5
# define		rtfPicGoalHt		6
# define		rtfPicScaleX		7
# define		rtfPicScaleY		8
# define		rtfPicScaled		9
# define		rtfPicCropTop		10
# define		rtfPicCropBottom	11
# define		rtfPicCropLeft		12
# define		rtfPicCropRight		13
# define		rtfPixelBits		14
# define		rtfBitmapPlanes		15
# define		rtfBitmapWid		16
# define		rtfPicBinary		17

# define	rtfFieldAttr	14
# define		rtfFieldDirty		0
# define		rtfFieldEdited		1
# define		rtfFieldLocked		2
# define		rtfFieldPrivate		3

# define	rtfTOCAttr	15
# define		rtfTOCType		0
# define		rtfTOCLevel		1

# define	rtfPosAttr	16
# define		rtfPosX			0
# define		rtfPosXCenter		1
# define		rtfPosXInside		2
# define		rtfPosXLeft		3
# define		rtfPosXOutSide		4
# define		rtfPosXRight		5
# define		rtfPosY			6
# define		rtfPosYInline		7
# define		rtfPosYTop		8
# define		rtfPosYCenter		9
# define		rtfPosYBottom		10
# define		rtfAbsWid		11
# define		rtfTextDist		12
# define		rtfRPosMargV		13
# define		rtfRPosPageV		14
# define		rtfRPosMargH		15
# define		rtfRPosPageH		16
# define		rtfRPosColH		17



/*
	RTF font, color and style structures.  Used for font table,
	color table, and stylesheet processing.
*/

typedef struct RTFFont		RTFFont;
typedef struct RTFColor		RTFColor;
typedef struct RTFStyle		RTFStyle;
typedef struct RTFStyleElt	RTFStyleElt;


struct RTFFont
{
	char	*rtfFName;		/* font name */
	int	rtfFNum;		/* font number */
	int	rtfFFamily;		/* font family */
	RTFFont	*rtfNextFont;		/* next font in list */
};


/*
	Color values are -1 if the default color for the the color
	number should be used.  The default color is writer-dependent.
*/

struct RTFColor
{
	int		rtfCNum;	/* color number */
	int		rtfCRed;	/* red value */
	int		rtfCGreen;	/* green value */
	int		rtfCBlue;	/* blue value */
	RTFColor	*rtfNextColor;	/* next color in list */
};


struct RTFStyle
{
	char		*rtfSName;	/* style name */
	int		rtfSNum;	/* style number */
	int		rtfSBasedOn;	/* style this one's based on */
	int		rtfSNextPar;	/* style next paragraph style */
	RTFStyleElt	*rtfSSEList;	/* list of style words */
	int		rtfExpanding;	/* non-zero = being expanded */
	RTFStyle	*rtfNextStyle;	/* next style in style list */
};

# define	rtfBasedOnNone	222	/* "no based-on style" */


struct RTFStyleElt
{
	int		rtfSEClass;	/* token class */
	int		rtfSEMajor;	/* token major number */
	int		rtfSEMinor;	/* token minor number */
	int		rtfSEParam;	/* control symbol parameter */
	char		*rtfSEText;	/* text of symbol */
	RTFStyleElt	*rtfNextSE;	/* next element in style */
};


/*
	Public RTF reader routines
*/

extern void	RTFInit ();
extern void	RTFSetStream ();
extern void	RTFSetClassCallback ();
extern void	(*RTFGetClassCallback ()) ();
extern void	RTFSetDestinationCallback ();
extern void	(*RTFGetDestinationCallback ()) ();
extern void	RTFRead ();
extern int	RTFGetToken ();	/* writer should rarely need this */
extern void	RTFSetToken ();
extern void	RTFSetReadHook ();
extern void	(*RTFGetReadHook ()) ();
extern void	RTFRouteToken ();
extern void	RTFSkipGroup ();
extern void	RTFExpandStyle ();
extern int	RTFCheckCM ();
extern int	RTFCheckCMM ();
extern int	RTFCheckMM ();
extern RTFFont	*RTFGetFont ();
extern RTFColor	*RTFGetColor ();
extern RTFStyle	*RTFGetStyle ();
extern char	*RTFAlloc ();
extern char	*RTFStrSave ();
extern void	RTFFree ();