3 * Copyright (C) 1998-2004 A.J. van Os; Released under GNU GPL
6 * Constants and macros for the interpretation of MS Word files
9 #if !defined(__wordconst_h)
10 #define __wordconst_h 1
13 * A bit odd definition of the type Boolean, but RISC OS insists
14 * on this and Linux/Unix doesn't mind.
23 #define HEADER_SIZE 768
24 #define BIG_BLOCK_SIZE 512
25 #define PROPERTY_SET_STORAGE_SIZE 128
26 #define SMALL_BLOCK_SIZE 64
27 /* Switch size of Depot use */
28 #define MIN_SIZE_FOR_BBD_USE 0x1000
30 #define TABLE_COLUMN_MAX 31
31 /* Maximum number of tabs positions in a paragraph */
32 #define NUMBER_OF_TABS_MAX 64
33 /* Font sizes (in half-points) */
34 #define MIN_FONT_SIZE 8
35 #define DEFAULT_FONT_SIZE 20
36 #define MAX_FONT_SIZE 240
37 #define MIN_TABLEFONT_SIZE 16
38 #define MAX_TABLEFONT_SIZE 20
40 #define FONT_REGULAR 0x0000
41 #define FONT_BOLD 0x0001
42 #define FONT_ITALIC 0x0002
43 #define FONT_UNDERLINE 0x0004
44 #define FONT_CAPITALS 0x0008
45 #define FONT_SMALL_CAPITALS 0x0010
46 #define FONT_STRIKE 0x0020
47 #define FONT_HIDDEN 0x0040
48 #define FONT_MARKDEL 0x0080
49 #define FONT_SUPERSCRIPT 0x0100
50 #define FONT_SUBSCRIPT 0x0200
52 #define FONT_COLOR_DEFAULT 0
53 #define FONT_COLOR_BLACK 1
54 #define FONT_COLOR_BLUE 2
55 #define FONT_COLOR_CYAN 3
56 #define FONT_COLOR_GREEN 4
57 #define FONT_COLOR_MAGENTA 5
58 #define FONT_COLOR_RED 6
59 #define FONT_COLOR_YELLOW 7
60 #define FONT_COLOR_WHITE 8
61 /* Special block numbers */
62 #define END_OF_CHAIN 0xfffffffeUL
63 #define UNUSED_BLOCK 0xffffffffUL
64 /* Blocksize (512 bytes) and maximum filesize (4 GB) gives 0..7fffff */
65 #define MAX_BLOCKNUMBER 0x007fffffUL
66 /* Invalid character position */
67 #define CP_INVALID 0xffffffffUL
68 /* Invalid file offset */
69 #define FC_INVALID 0xffffffffUL
70 /* Special istd values */
71 #define ISTD_INVALID USHRT_MAX
73 /* Properties modifier without value */
74 #define IGNORE_PROPMOD 0
76 #define LIST_ARABIC_NUM 0x00
77 #define LIST_UPPER_ROMAN 0x01
78 #define LIST_LOWER_ROMAN 0x02
79 #define LIST_UPPER_ALPHA 0x03
80 #define LIST_LOWER_ALPHA 0x04
81 #define LIST_ORDINAL_NUM 0x05
82 #define LIST_NUMBER_TXT 0x06
83 #define LIST_ORDINAL_TXT 0x07
84 #define LIST_OUTLINE_NUM 0x16
85 #define LIST_SPECIAL 0x17
86 #define LIST_SPECIAL2 0x19
87 #define LIST_BULLETS 0xff
88 /* Types of paragraph alignment */
89 #define ALIGNMENT_LEFT 0x00
90 #define ALIGNMENT_CENTER 0x01
91 #define ALIGNMENT_RIGHT 0x02
92 #define ALIGNMENT_JUSTIFY 0x03
93 /* Minimum vertical space before and after a heading line */
94 #define HEADING_GAP 120 /* twips */
95 /* Style identifier */
96 #define STI_USER 0xffe
98 /* Table border style codes */
99 #define TABLE_BORDER_TOP 0x01
100 #define TABLE_BORDER_LEFT 0x02
101 #define TABLE_BORDER_BOTTOM 0x04
102 #define TABLE_BORDER_RIGHT 0x08
106 #define ucGetByte(i,a) ((unsigned char)(a[i]))
107 #define usGetWord(i,a) ((unsigned short)\
108 ((unsigned int)(a[(i)+1])<<8|\
109 (unsigned int)(a[i])))
110 #define ulGetLong(i,a) ((unsigned long)(a[i])|\
111 (unsigned long)(a[(i)+1])<<8|\
112 (unsigned long)(a[(i)+2])<<16|\
113 (unsigned long)(a[(i)+3])<<24)
114 #define usGetWordBE(i,a) ((unsigned short)\
115 ((unsigned int)(a[i])<<8|\
116 (unsigned int)(a[(i)+1])))
117 #define ulGetLongBE(i,a) ((unsigned long)(a[(i)+3])|\
118 (unsigned long)(a[(i)+2])<<8|\
119 (unsigned long)(a[(i)+1])<<16|\
120 (unsigned long)(a[i])<<24)
121 /* Font style macros */
122 #define bIsBold(x) (((x) & FONT_BOLD) == FONT_BOLD)
123 #define bIsItalic(x) (((x) & FONT_ITALIC) == FONT_ITALIC)
124 #define bIsUnderline(x) (((x) & FONT_UNDERLINE) == FONT_UNDERLINE)
125 #define bIsCapitals(x) (((x) & FONT_CAPITALS) == FONT_CAPITALS)
126 #define bIsSmallCapitals(x) (((x) & FONT_SMALL_CAPITALS) == FONT_SMALL_CAPITALS)
127 #define bIsStrike(x) (((x) & FONT_STRIKE) == FONT_STRIKE)
128 #define bIsHidden(x) (((x) & FONT_HIDDEN) == FONT_HIDDEN)
129 #define bIsMarkDel(x) (((x) & FONT_MARKDEL) == FONT_MARKDEL)
130 #define bIsSuperscript(x) (((x) & FONT_SUPERSCRIPT) == FONT_SUPERSCRIPT)
131 #define bIsSubscript(x) (((x) & FONT_SUBSCRIPT) == FONT_SUBSCRIPT)
132 /* Table border style code macros */
133 #define bIsTableBorderTop(x) (((x) & TABLE_BORDER_TOP) == TABLE_BORDER_TOP)
134 #define bIsTableBorderLeft(x) (((x) & TABLE_BORDER_LEFT) == TABLE_BORDER_LEFT)
135 #define bIsTableBorderBottom(x) (((x) & TABLE_BORDER_BOTTOM) == TABLE_BORDER_BOTTOM)
136 #define bIsTableBorderRight(x) (((x) & TABLE_BORDER_RIGHT) == TABLE_BORDER_RIGHT)
137 /* Computation macros */
138 #if defined(__riscos)
139 /* From Words half-points to draw units (plus a percentage) */
140 #define lWord2DrawUnits00(x) ((long)(x) * 320)
141 #define lWord2DrawUnits20(x) ((long)(x) * 384)
142 #define lToBaseLine(x) ((long)(x) * 45)
143 #endif /* __riscos */
144 /* From twips (1/20 of a point) to millipoints */
145 #define lTwips2MilliPoints(x) ((long)(x) * 50)
146 /* From twips (1/20 of a point) to points */
147 #define dTwips2Points(x) ((double)(x) / 20.0)
148 /* From default characters (16 OS units wide) to millipoints */
149 #define lChar2MilliPoints(x) ((long)(x) * 6400)
150 #define iMilliPoints2Char(x) (int)(((long)(x) + 3200) / 6400)
151 #define iDrawUnits2Char(x) (int)(((long)(x) + 2048) / 4096)
152 /* From draw units (1/180*256 inch) to millipoints (1/72*1000 inch) */
153 #define lDrawUnits2MilliPoints(x) (((long)(x) * 25 + 8) / 16)
154 #define lMilliPoints2DrawUnits(x) (((long)(x) * 16 + 12) / 25)
155 #define lPoints2DrawUnits(x) ((long)(x) * 640)
156 #define dDrawUnits2Points(x) ((double)(x) / 640.0)
158 /* Special characters */
159 #define IGNORE_CHARACTER 0x00 /* ^@ */
160 #define PICTURE 0x01 /* ^A */
161 #define FOOTNOTE_OR_ENDNOTE 0x02 /* ^B */
162 #define FOOTNOTE_SEPARATOR 0x03 /* ^C */
163 #define FOOTNOTE_CONTINUATION 0x04 /* ^D */
164 #define ANNOTATION 0x05 /* ^E */
165 #define TABLE_SEPARATOR 0x07 /* ^G */
166 #define FRAME 0x08 /* ^H */
167 #define TAB 0x09 /* ^I */
168 /* End of line characters */
169 #define LINE_FEED 0x0a /* ^J */
170 #define HARD_RETURN 0x0b /* ^K */
171 #define PAGE_BREAK 0x0c /* ^L */
172 #define PAR_END 0x0d /* ^M */
173 #define COLUMN_FEED 0x0e /* ^N */
175 #define START_EMBEDDED 0x13 /* ^S */
176 #define END_IGNORE 0x14 /* ^T */
177 #define END_EMBEDDED 0x15 /* ^U */
178 /* Special characters */
180 #define FILLER_CHAR '~'
182 #define FILLER_CHAR ' '
184 #define TABLE_SEPARATOR_CHAR '|'
185 /* Pseudo characters. These must be outside the Unicode range */
186 #define FOOTNOTE_CHAR ((unsigned long)0xffff + 1)
187 #define ENDNOTE_CHAR ((unsigned long)0xffff + 2)
188 #define UNKNOWN_NOTE_CHAR ((unsigned long)0xffff + 3)
190 /* Charactercodes as used by Word */
191 #define WORD_UNBREAKABLE_JOIN 0x1e
192 #define WORD_SOFT_HYPHEN 0x1f
194 /* Unicode characters */
195 #define UNICODE_DOUBLE_LEFT_ANGLE_QMARK 0x00ab
196 #define UNICODE_MIDDLE_DOT 0x00b7
197 #define UNICODE_DOUBLE_RIGHT_ANGLE_QMARK 0x00bb
198 #define UNICODE_CAPITAL_D_WITH_STROKE 0x0110
199 #define UNICODE_SMALL_D_WITH_STROKE 0x0111
200 #define UNICODE_CAPITAL_LIGATURE_OE 0x0152
201 #define UNICODE_SMALL_LIGATURE_OE 0x0153
202 #define UNICODE_SMALL_F_HOOK 0x0192
203 #define UNICODE_GREEK_CAPITAL_CHI 0x03a7
204 #define UNICODE_GREEK_SMALL_UPSILON 0x03c5
205 #define UNICODE_MODIFIER_CIRCUMFLEX 0x02c6
206 #define UNICODE_SMALL_TILDE 0x02dc
207 #define UNICODE_SMALL_LETTER_OMEGA 0x03c9
208 #define UNICODE_EN_QUAD 0x2000
209 #define UNICODE_EM_QUAD 0x2001
210 #define UNICODE_EN_SPACE 0x2002
211 #define UNICODE_EM_SPACE 0x2003
212 #define UNICODE_THREE_PER_EM_SPACE 0x2004
213 #define UNICODE_FOUR_PER_EM_SPACE 0x2005
214 #define UNICODE_SIX_PER_EM_SPACE 0x2006
215 #define UNICODE_FIGURE_SPACE 0x2007
216 #define UNICODE_PUNCTUATION_SPACE 0x2008
217 #define UNICODE_THIN_SPACE 0x2009
218 #define UNICODE_HAIR_SPACE 0x200a
219 #define UNICODE_ZERO_WIDTH_SPACE 0x200b
220 #define UNICODE_ZERO_WIDTH_NON_JOINER 0x200c
221 #define UNICODE_ZERO_WIDTH_JOINER 0x200d
222 #define UNICODE_LEFT_TO_RIGHT_MARK 0x200e
223 #define UNICODE_RIGHT_TO_LEFT_MARK 0x200f
224 #define UNICODE_HYPHEN 0x2010
225 #define UNICODE_NON_BREAKING_HYPHEN 0x2011
226 #define UNICODE_FIGURE_DASH 0x2012
227 #define UNICODE_EN_DASH 0x2013
228 #define UNICODE_EM_DASH 0x2014
229 #define UNICODE_HORIZONTAL_BAR 0x2015
230 #define UNICODE_DOUBLE_VERTICAL_LINE 0x2016
231 #define UNICODE_DOUBLE_LOW_LINE 0x2017
232 #define UNICODE_LEFT_SINGLE_QMARK 0x2018
233 #define UNICODE_RIGHT_SINGLE_QMARK 0x2019
234 #define UNICODE_SINGLE_LOW_9_QMARK 0x201a
235 #define UNICODE_SINGLE_HIGH_REV_9_QMARK 0x201b
236 #define UNICODE_LEFT_DOUBLE_QMARK 0x201c
237 #define UNICODE_RIGHT_DOUBLE_QMARK 0x201d
238 #define UNICODE_DOUBLE_LOW_9_QMARK 0x201e
239 #define UNICODE_DOUBLE_HIGH_REV_9_QMARK 0x201f
240 #define UNICODE_DAGGER 0x2020
241 #define UNICODE_DOUBLE_DAGGER 0x2021
242 #define UNICODE_BULLET 0x2022
243 #define UNICODE_TRIANGULAR_BULLET 0x2023
244 #define UNICODE_ONE_DOT_LEADER 0x2024
245 #define UNICODE_TWO_DOT_LEADER 0x2025
246 #define UNICODE_ELLIPSIS 0x2026
247 #define UNICODE_HYPHENATION_POINT 0x2027
248 #define UNICODE_LEFT_TO_RIGHT_EMBEDDING 0x202a
249 #define UNICODE_RIGHT_TO_LEFT_EMBEDDING 0x202b
250 #define UNICODE_POP_DIRECTIONAL_FORMATTING 0x202c
251 #define UNICODE_LEFT_TO_RIGHT_OVERRIDE 0x202d
252 #define UNICODE_RIGHT_TO_LEFT_OVERRIDE 0x202e
253 #define UNICODE_NARROW_NO_BREAK_SPACE 0x202f
254 #define UNICODE_PER_MILLE_SIGN 0x2030
255 #define UNICODE_PRIME 0x2032
256 #define UNICODE_DOUBLE_PRIME 0x2033
257 #define UNICODE_SINGLE_LEFT_ANGLE_QMARK 0x2039
258 #define UNICODE_SINGLE_RIGHT_ANGLE_QMARK 0x203a
259 #define UNICODE_UNDERTIE 0x203f
260 #define UNICODE_FRACTION_SLASH 0x2044
261 #define UNICODE_EURO_SIGN 0x20ac
262 #define UNICODE_CIRCLE 0x20dd
263 #define UNICODE_SQUARE 0x20de
264 #define UNICODE_DIAMOND 0x20df
265 #define UNICODE_NUMERO_SIGN 0x2116
266 #define UNICODE_TRADEMARK_SIGN 0x2122
267 #define UNICODE_KELVIN_SIGN 0x212a
268 #define UNICODE_LEFTWARDS_ARROW 0x2190
269 #define UNICODE_UPWARDS_ARROW 0x2191
270 #define UNICODE_RIGHTWARDS_ARROW 0x2192
271 #define UNICODE_DOWNWARDS_ARROW 0x2193
272 #define UNICODE_N_ARY_SUMMATION 0x2211
273 #define UNICODE_MINUS_SIGN 0x2212
274 #define UNICODE_DIVISION_SLASH 0x2215
275 #define UNICODE_ASTERISK_OPERATOR 0x2217
276 #define UNICODE_BULLET_OPERATOR 0x2219
277 #define UNICODE_RATIO 0x2236
278 #define UNICODE_TILDE_OPERATOR 0x223c
279 #define UNICODE_BD_LIGHT_HORIZONTAL 0x2500
280 #define UNICODE_BD_LIGHT_VERTICAL 0x2502
281 #define UNICODE_BD_LIGHT_DOWN_RIGHT 0x250c
282 #define UNICODE_BD_LIGHT_DOWN_AND_LEFT 0x2510
283 #define UNICODE_BD_LIGHT_UP_AND_RIGHT 0x2514
284 #define UNICODE_BD_LIGHT_UP_AND_LEFT 0x2518
285 #define UNICODE_BD_LIGHT_VERTICAL_AND_RIGHT 0x251c
286 #define UNICODE_BD_LIGHT_VERTICAL_AND_LEFT 0x2524
287 #define UNICODE_BD_LIGHT_DOWN_AND_HORIZONTAL 0x252c
288 #define UNICODE_BD_LIGHT_UP_AND_HORIZONTAL 0x2534
289 #define UNICODE_BD_LIGHT_VERTICAL_AND_HORIZONTAL 0x253c
290 #define UNICODE_BD_DOUBLE_HORIZONTAL 0x2550
291 #define UNICODE_BD_DOUBLE_VERTICAL 0x2551
292 #define UNICODE_BD_DOUBLE_DOWN_AND_RIGHT 0x2554
293 #define UNICODE_BD_DOUBLE_DOWN_AND_LEFT 0x2557
294 #define UNICODE_BD_DOUBLE_UP_AND_RIGHT 0x255a
295 #define UNICODE_BD_DOUBLE_UP_AND_LEFT 0x255d
296 #define UNICODE_BD_DOUBLE_VERTICAL_AND_RIGHT 0x2560
297 #define UNICODE_BD_DOUBLE_VERTICAL_AND_LEFT 0x2563
298 #define UNICODE_BD_DOUBLE_DOWN_AND_HORIZONTAL 0x2566
299 #define UNICODE_BD_DOUBLE_UP_AND_HORIZONTAL 0x2569
300 #define UNICODE_BD_DOUBLE_VERTICAL_AND_HORIZONTAL 0x256c
301 #define UNICODE_LIGHT_SHADE 0x2591
302 #define UNICODE_MEDIUM_SHADE 0x2592
303 #define UNICODE_DARK_SHADE 0x2593
304 #define UNICODE_BLACK_SQUARE 0x25a0
305 #define UNICODE_BLACK_CLUB_SUIT 0x2663
306 #define UNICODE_SMALL_LIGATURE_FI 0xfb01
307 #define UNICODE_SMALL_LIGATURE_FL 0xfb02
308 #define UNICODE_ZERO_WIDTH_NO_BREAK_SPACE 0xfeff
310 #if defined(__riscos)
311 #define OUR_ELLIPSIS 0x8c
312 #define OUR_EM_DASH 0x98
313 #define OUR_UNBREAKABLE_JOIN 0x99
315 #define OUR_ELLIPSIS '.'
316 #define OUR_EM_DASH '-'
317 #define OUR_UNBREAKABLE_JOIN '-'
318 #endif /* __riscos */
319 #define OUR_DIAMOND '-'
321 #endif /* __wordconst_h */