blob: 7ed6b1e1bf1789db69def440b81e0b3cbef6fede (
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
|
/*
rtf2troff.h - rtf2troff defines, structures, externs
*/
/* troff versions understood */
# define TROFF 0 /* generic troff */
# define XROFF 1 /* Image Network xroff */
# define PSTROFF 2 /* ditroff + public domain tpscript backend */
/* macro packages understood */
# define noMacros 0
# define meMacros 1
# define mmMacros 2
# define msMacros 3
/*
macro/register names
*/
# define mHeader "He"
# define mHeaderAll "Ha"
# define mHeaderFirst "Hf"
# define mHeaderLeft "Hl"
# define mHeaderRight "Hr"
# define mFooter "Fo"
# define mFooterAll "Fa"
# define mFooterFirst "Ff"
# define mFooterLeft "Fl"
# define mFooterRight "Fr"
/* normally Hp > Tm > Bm > Fp */
# define rTitlePageSpecial "Tp"
# define rTopMargin "Tm"
# define rHeaderPos "Hp"
# define rBottomMargin "Bm" /* from *top* of page! */
# define rFooterPos "Fp" /* from *top* of page! */
# define rHeaderAll "Ha"
# define rHeaderFirst "Hf"
# define rHeaderLeft "Hl"
# define rHeaderRight "Hr"
# define rFooterAll "Fa"
# define rFooterFirst "Ff"
# define rFooterLeft "Fl"
# define rFooterRight "Fr"
/*
rtfTabLeft is used to indicate the default tab type (left tab).
RTF assumes that if some other type is not specified, a tab is
a left tab and never indicates that explicitly. It's given a
number here so the writer can refer to it by a constant known
to be different from the other tab types. (All "real" token
numbers are non-negative.)
rtfLeaderMotion is used to indicate default tab char (motion only),
which likewise is undefined in RTF.
rtfNoDestination is used to indicate that a state has had no
destination specified yet.
rtfNoBorderType indicates that a paragraph has no borders.
*/
# define rtfTabLeft (-1)
# define rtfLeaderMotion (-1)
# define rtfNoDestination (-1)
# define rtfNoBorderType (-1)
# define styleBold 0x0001
# define styleItalic 0x0002
# define styleStrikeThru 0x0004
# define styleOutline 0x0008
# define styleShadow 0x0010
# define styleSmallCaps 0x0020
# define styleAllCaps 0x0040
# define styleInvisible 0x0080
# define styleUnderline 0x0100
# define styleWUnderline 0x0200
# define StyleFontBits(s) (s & (styleBold | styleItalic))
/*
Values for operations that map border positions onto bits
in flag word.
*/
# define borderTop 0x0001
# define borderBottom 0x0002
# define borderLeft 0x0004
# define borderRight 0x0008
/*
Values for operations that map border positions to array indices.
Must be zero-based and sequential.
*/
# define topIndex 0
# define leftIndex 1
# define bottomIndex 2
# define rightIndex 3
# define lineBreakLen 60 /* break lines after 60 columns */
# define maxIStack 10 /* internal state stack depth */
# define maxWStack 3 /* written state stack depth */
# define maxTab 20
# define maxCell 20
typedef struct State State;
typedef struct DocState DocState;
typedef struct SectState SectState;
typedef struct ParState ParState;
typedef struct CharState CharState;
typedef struct TblState TblState; /* this is separate */
/* document properties */
struct DocState
{
int landscape; /* non-zero if landscape */
double pageWidth; /* paper width */
double pageHeight; /* paper height */
double leftMargin; /* left margin */
double rightMargin; /* right margin */
double topMargin; /* top margin */
double bottomMargin; /* bottom margin */
double tabWidth; /* default tab width */
};
/* section properties */
struct SectState
{
int breakType; /* section break type */
int pageStart; /* section starting page number */
int pageRestart; /* restart page numbering each sect. */
double headerPos; /* from top of page */
double footerPos; /* from bottom of page */
int titleSpecial; /* first page special */
};
/* paragraph properties */
struct ParState
{
double firstIndent; /* first indent */
double leftIndent; /* left indent */
double rightIndent; /* right indent */
double spaceBefore; /* space before lines */
double spaceAfter; /* space after lines */
double spaceBetween; /* space between lines */
int tabFlag; /* any tabs set yet? (0 = no) */
int nTabs; /* number of tabs (0 = defaults) */
double tab[maxTab]; /* tab positions */
int tabType[maxTab]; /* tab types */
int tabChar; /* tab (leader) character */
int justification; /* justification */
int borderType; /* type of border */
int borderFlags; /* where to draw borders */
};
/* character properties */
struct CharState
{
int fontSize; /* font (point) size */
u_long charStyle; /* character style */
double superScript; /* superscript */
double subScript; /* subscript */
};
struct State
{
int destination; /* state destination */
DocState docState;
SectState sectState;
ParState parState;
CharState charState;
};
/* table properties */
struct TblState
{
int tableHeader; /* non-zero if table header written */
int nCells; /* number of cells */
int curCell; /* current cell (0-based) */
double cellPos[maxCell]; /* cell positions (right edge) */
double tableLeft; /* table left edge position */
double cellGap; /* horiz. gap between cells */
int border[maxCell][4]; /* cell borders */
};
extern int tvers; /* troff version */
extern int mvers; /* macro package version */
extern TblState *its;
extern int inTable;
extern FILE *f;
extern State *is; /* current internal state */
extern DocState *ids; /* internal document state */
extern SectState *iss; /* internal section state */
extern ParState *ips; /* internal paragraph state */
extern CharState *ics; /* internal character state */
extern State *ws; /* written state */
extern DocState *wds; /* written document state */
extern SectState *wss; /* written section state */
extern ParState *wps; /* written paragraph state */
extern CharState *wcs; /* written character state */
extern int docStateChanged; /* document properties have changed */
extern int sectStateChanged; /* section properties have changed */
extern int parStateChanged; /* paragraph properties have changed */
extern int charStateChanged; /* character properties have changed */
# define stateChanged \
(docStateChanged||sectStateChanged||parStateChanged||charStateChanged)
extern int indirectionLevel;
extern void InitState ();
extern void CheckFinalState ();
extern void PushIState ();
extern void PopIState ();
extern void PushWState ();
extern void PopWState ();
extern void BeginDiversion ();
extern void EndDiversion ();
extern void RestoreSectDefaults ();
extern void RestoreParDefaults ();
extern void RestoreCharDefaults ();
extern void InitTabSet ();
extern int MapBorderLocation ();
extern void SelectFormatterMaps ();
extern void SelectMacPackMaps ();
extern void SelectCharSetMaps ();
extern char *CharMapping ();
extern void TblAttr ();
extern void BeginTbl ();
extern void EndTbl ();
extern void BeginCell ();
extern void EndCell ();
extern void FlushState ();
extern void FlushInitialState ();
extern void FlushSectState ();
extern void Flush ();
extern void SaveTblFPV ();
extern void FlushTblFPV ();
extern double EnWidth ();
extern void ResetPar ();
extern void ResetParLine ();
extern void Sect ();
extern void Par ();
extern void PutString ();
extern void Comment ();
|