Extended RTF support

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6699 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2000-06-16 17:03:56 +00:00
parent dd4b4e3bc9
commit 5f136b00d2
7 changed files with 537 additions and 264 deletions

View file

@ -27,13 +27,7 @@
#ifndef _rtfConsumer_h_INCLUDE #ifndef _rtfConsumer_h_INCLUDE
#define _rtfConsumer_h_INCLUDE #define _rtfConsumer_h_INCLUDE
#include "Parsers/rtfScanner.h" NSAttributedString *parseRTFintoAttributedString(NSData *rtfData,
NSDictionary **dict);
/* external symbols from the grammer */
int GSRTFparse(void *ctxt, RTFscannerCtxt *lctxt);
BOOL parseRTFintoAttributedString(NSString *rtfString,
NSMutableAttributedString *result,
NSDictionary **dict);
#endif #endif

View file

@ -34,6 +34,9 @@
measurement is usually in twips: one twentieth of a point (this is about 0.01764 mm) measurement is usually in twips: one twentieth of a point (this is about 0.01764 mm)
a tabstop of 540 twips (as it occurs on NeXT) is therefore about 0.95 cm a tabstop of 540 twips (as it occurs on NeXT) is therefore about 0.95 cm
*/ */
#define halfpoints2points(a) ((a)/2.0)
#define twips2points(a) ((a)/20.0)
#define twips2mm(a) ((a)*0.01764)
/* prepare the ctxt, or whatever you want */ /* prepare the ctxt, or whatever you want */
void GSRTFstart(void *ctxt); void GSRTFstart(void *ctxt);
@ -44,8 +47,8 @@ void GSRTFstop(void *ctxt);
/* those pairing functions enclose RTFBlocks. Use it to capture the hierarchical attribute changes of blocks. /* those pairing functions enclose RTFBlocks. Use it to capture the hierarchical attribute changes of blocks.
i.e. attributes of a block are forgotten once a block is closed i.e. attributes of a block are forgotten once a block is closed
*/ */
void GSRTFopenBlock(void *ctxt); void GSRTFopenBlock(void *ctxt, BOOL ignore);
void GSRTFcloseBlock(void *ctxt); void GSRTFcloseBlock(void *ctxt, BOOL ignore);
/* handle errors */ /* handle errors */
void GSRTFerror(const char *msg); void GSRTFerror(const char *msg);
@ -77,6 +80,10 @@ void GSRTFpaperHeight(void *ctxt, int height);
void GSRTFmarginLeft(void *ctxt, int margin); void GSRTFmarginLeft(void *ctxt, int margin);
/* set right margin in twips */ /* set right margin in twips */
void GSRTFmarginRight(void *ctxt, int margin); void GSRTFmarginRight(void *ctxt, int margin);
/* set top margin in twips */
void GSRTFmarginTop(void *ctxt, int margin);
/* set buttom margin in twips */
void GSRTFmarginButtom(void *ctxt, int margin);
/* set first line indent */ /* set first line indent */
void GSRTFfirstLineIndent(void *ctxt, int indent); void GSRTFfirstLineIndent(void *ctxt, int indent);
/* set left indent */ /* set left indent */
@ -89,6 +96,10 @@ void GSRTFalignLeft(void *ctxt);
void GSRTFalignRight(void *ctxt); void GSRTFalignRight(void *ctxt);
/* set paragraph style */ /* set paragraph style */
void GSRTFstyle(void *ctxt, int style); void GSRTFstyle(void *ctxt, int style);
/* Add a colour to the colour table*/
void GSRTFaddColor(void *ctxt, int red, int green, int blue);
/* Add the default colour to the colour table*/
void GSRTFaddDefaultColor(void *ctxt);
/* set background colour */ /* set background colour */
void GSRTFcolorbg(void *ctxt, int color); void GSRTFcolorbg(void *ctxt, int color);
/* set foreground colour */ /* set foreground colour */

View file

@ -21,42 +21,53 @@
#define RTFpc 262 #define RTFpc 262
#define RTFpca 263 #define RTFpca 263
#define RTFignore 264 #define RTFignore 264
#define RTFred 265 #define RTFinfo 265
#define RTFgreen 266 #define RTFstylesheet 266
#define RTFblue 267 #define RTFfootnote 267
#define RTFcolorbg 268 #define RTFheader 268
#define RTFcolorfg 269 #define RTFfooter 269
#define RTFcolortable 270 #define RTFpict 270
#define RTFfont 271 #define RTFred 271
#define RTFfontSize 272 #define RTFgreen 272
#define RTFpaperWidth 273 #define RTFblue 273
#define RTFpaperHeight 274 #define RTFcolorbg 274
#define RTFmarginLeft 275 #define RTFcolorfg 275
#define RTFmarginRight 276 #define RTFcolortable 276
#define RTFfirstLineIndent 277 #define RTFfont 277
#define RTFleftIndent 278 #define RTFfontSize 278
#define RTFalignCenter 279 #define RTFpaperWidth 279
#define RTFalignLeft 280 #define RTFpaperHeight 280
#define RTFalignRight 281 #define RTFmarginLeft 281
#define RTFstyle 282 #define RTFmarginRight 282
#define RTFbold 283 #define RTFmarginTop 283
#define RTFitalic 284 #define RTFmarginButtom 284
#define RTFunderline 285 #define RTFfirstLineIndent 285
#define RTFunderlineStop 286 #define RTFleftIndent 286
#define RTFsubscript 287 #define RTFalignCenter 287
#define RTFsuperscript 288 #define RTFalignLeft 288
#define RTFtabulator 289 #define RTFalignRight 289
#define RTFparagraph 290 #define RTFstyle 290
#define RTFdefaultParagraph 291 #define RTFbold 291
#define RTFOtherStatement 292 #define RTFitalic 292
#define RTFfontListStart 293 #define RTFunderline 293
#define RTFfamilyNil 294 #define RTFunderlineStop 294
#define RTFfamilyRoman 295 #define RTFsubscript 295
#define RTFfamilySwiss 296 #define RTFsuperscript 296
#define RTFfamilyModern 297 #define RTFtabulator 297
#define RTFfamilyScript 298 #define RTFparagraph 298
#define RTFfamilyDecor 299 #define RTFdefaultParagraph 299
#define RTFfamilyTech 300 #define RTFfcharset 300
#define RTFfprq 301
#define RTFcpg 302
#define RTFOtherStatement 303
#define RTFfontListStart 304
#define RTFfamilyNil 305
#define RTFfamilyRoman 306
#define RTFfamilySwiss 307
#define RTFfamilyModern 308
#define RTFfamilyScript 309
#define RTFfamilyDecor 310
#define RTFfamilyTech 311
#line 35 "Parsers/rtfGrammer.y" #line 35 "Parsers/rtfGrammer.y"
@ -126,11 +137,11 @@ typedef
#define YYFINAL 74 #define YYFINAL 107
#define YYFLAG -32768 #define YYFLAG -32768
#define YYNTBASE 49 #define YYNTBASE 60
#define YYTRANSLATE(x) ((unsigned)(x) <= 300 ? yytranslate[x] : 65) #define YYTRANSLATE(x) ((unsigned)(x) <= 311 ? yytranslate[x] : 83)
static const char yytranslate[] = { 0, static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@ -142,10 +153,10 @@ static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 48, 2, 2, 2, 2, 2, 2, 2, 2, 2, 59, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 46, 2, 47, 2, 2, 2, 2, 2, 2, 2, 57, 2, 58, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@ -162,46 +173,59 @@ static const char yytranslate[] = { 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43, 44, 45 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
56
}; };
#if YYDEBUG != 0 #if YYDEBUG != 0
static const short yyprhs[] = { 0, static const short yyprhs[] = { 0,
0, 1, 2, 10, 12, 14, 16, 18, 19, 22, 0, 1, 2, 10, 12, 14, 16, 18, 19, 22,
25, 28, 31, 34, 35, 40, 41, 47, 49, 51, 25, 28, 31, 34, 35, 40, 41, 47, 48, 54,
53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 55, 61, 62, 68, 69, 75, 76, 82, 83, 89,
73, 75, 77, 79, 81, 83, 85, 87, 89, 94, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
95, 98, 103, 107, 109, 111, 113, 115, 117, 119, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130,
121, 126, 127, 130, 135, 137 132, 134, 136, 138, 143, 144, 147, 152, 157, 158,
161, 164, 167, 170, 172, 174, 176, 178, 180, 182,
184, 189, 190, 193, 198, 200
}; };
static const short yyrhs[] = { -1, static const short yyrhs[] = { -1,
0, 46, 50, 4, 52, 53, 51, 47, 0, 5, 0, 57, 61, 4, 63, 64, 62, 58, 0, 5,
0, 6, 0, 7, 0, 8, 0, 0, 53, 58, 0, 6, 0, 7, 0, 8, 0, 0, 64, 75,
0, 53, 62, 0, 53, 57, 0, 53, 3, 0, 0, 64, 80, 0, 64, 74, 0, 64, 3, 0,
53, 54, 0, 0, 46, 55, 53, 47, 0, 0, 64, 65, 0, 0, 57, 66, 64, 58, 0, 0,
46, 56, 9, 53, 47, 0, 16, 0, 17, 0, 57, 67, 9, 64, 58, 0, 0, 57, 68, 10,
18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 64, 58, 0, 0, 57, 69, 11, 64, 58, 0,
23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 0, 57, 70, 12, 64, 58, 0, 0, 57, 71,
13, 0, 14, 0, 32, 0, 33, 0, 28, 0, 13, 64, 58, 0, 0, 57, 72, 14, 64, 58,
29, 0, 30, 0, 31, 0, 37, 0, 46, 38, 0, 0, 57, 73, 15, 64, 58, 0, 57, 58,
59, 47, 0, 0, 59, 60, 0, 59, 46, 60, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26,
47, 0, 16, 61, 3, 0, 39, 0, 40, 0, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31,
41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 0, 32, 0, 33, 0, 34, 0, 35, 0, 19,
46, 15, 63, 47, 0, 0, 63, 64, 0, 10, 0, 20, 0, 40, 0, 41, 0, 36, 0, 37,
11, 12, 3, 0, 3, 0, 48, 0 0, 38, 0, 39, 0, 48, 0, 57, 49, 76,
58, 0, 0, 76, 77, 0, 76, 57, 77, 58,
0, 22, 79, 78, 3, 0, 0, 78, 45, 0,
78, 46, 0, 78, 47, 0, 78, 65, 0, 50,
0, 51, 0, 52, 0, 53, 0, 54, 0, 55,
0, 56, 0, 57, 21, 81, 58, 0, 0, 81,
82, 0, 16, 17, 18, 3, 0, 3, 0, 59,
0
}; };
#endif #endif
#if YYDEBUG != 0 #if YYDEBUG != 0
static const short yyrline[] = { 0, static const short yyrline[] = { 0,
131, 131, 132, 134, 135, 136, 137, 140, 141, 142, 142, 142, 143, 145, 146, 147, 148, 151, 152, 153,
143, 144, 145, 148, 148, 149, 149, 157, 164, 171, 154, 155, 156, 159, 159, 160, 160, 161, 161, 162,
178, 185, 192, 199, 206, 213, 214, 215, 216, 217, 162, 163, 163, 164, 164, 165, 165, 166, 166, 167,
224, 231, 238, 245, 252, 259, 266, 267, 274, 277, 175, 182, 189, 196, 203, 210, 217, 224, 231, 238,
278, 279, 285, 289, 291, 292, 293, 294, 295, 296, 245, 246, 247, 248, 249, 256, 263, 270, 277, 284,
304, 307, 308, 312, 313, 319 291, 298, 299, 306, 309, 310, 311, 317, 321, 322,
323, 324, 325, 329, 331, 332, 333, 334, 335, 336,
344, 347, 348, 352, 357, 367
}; };
#endif #endif
@ -209,103 +233,176 @@ static const short yyrline[] = { 0,
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
static const char * const yytname[] = { "$","error","$undefined.","RTFtext", static const char * const yytname[] = { "$","error","$undefined.","RTFtext",
"RTFstart","RTFansi","RTFmac","RTFpc","RTFpca","RTFignore","RTFred","RTFgreen", "RTFstart","RTFansi","RTFmac","RTFpc","RTFpca","RTFignore","RTFinfo","RTFstylesheet",
"RTFblue","RTFcolorbg","RTFcolorfg","RTFcolortable","RTFfont","RTFfontSize", "RTFfootnote","RTFheader","RTFfooter","RTFpict","RTFred","RTFgreen","RTFblue",
"RTFpaperWidth","RTFpaperHeight","RTFmarginLeft","RTFmarginRight","RTFfirstLineIndent", "RTFcolorbg","RTFcolorfg","RTFcolortable","RTFfont","RTFfontSize","RTFpaperWidth",
"RTFleftIndent","RTFalignCenter","RTFalignLeft","RTFalignRight","RTFstyle","RTFbold", "RTFpaperHeight","RTFmarginLeft","RTFmarginRight","RTFmarginTop","RTFmarginButtom",
"RTFitalic","RTFunderline","RTFunderlineStop","RTFsubscript","RTFsuperscript", "RTFfirstLineIndent","RTFleftIndent","RTFalignCenter","RTFalignLeft","RTFalignRight",
"RTFtabulator","RTFparagraph","RTFdefaultParagraph","RTFOtherStatement","RTFfontListStart", "RTFstyle","RTFbold","RTFitalic","RTFunderline","RTFunderlineStop","RTFsubscript",
"RTFfamilyNil","RTFfamilyRoman","RTFfamilySwiss","RTFfamilyModern","RTFfamilyScript", "RTFsuperscript","RTFtabulator","RTFparagraph","RTFdefaultParagraph","RTFfcharset",
"RTFfamilyDecor","RTFfamilyTech","'{'","'}'","'\\'","rtfFile","@1","@2","rtfCharset", "RTFfprq","RTFcpg","RTFOtherStatement","RTFfontListStart","RTFfamilyNil","RTFfamilyRoman",
"rtfIngredients","rtfBlock","@3","@4","rtfStatement","rtfFontList","rtfFonts", "RTFfamilySwiss","RTFfamilyModern","RTFfamilyScript","RTFfamilyDecor","RTFfamilyTech",
"rtfFontStatement","rtfFontFamily","rtfColorDef","rtfColors","rtfColorStatement", NULL "'{'","'}'","'\\'","rtfFile","@1","@2","rtfCharset","rtfIngredients","rtfBlock",
"@3","@4","@5","@6","@7","@8","@9","@10","rtfStatement","rtfFontList","rtfFonts",
"rtfFontStatement","rtfFontAttrs","rtfFontFamily","rtfColorDef","rtfColors",
"rtfColorStatement", NULL
}; };
#endif #endif
static const short yyr1[] = { 0, static const short yyr1[] = { 0,
50, 51, 49, 52, 52, 52, 52, 53, 53, 53, 61, 62, 60, 63, 63, 63, 63, 64, 64, 64,
53, 53, 53, 55, 54, 56, 54, 57, 57, 57, 64, 64, 64, 66, 65, 67, 65, 68, 65, 69,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 65, 70, 65, 71, 65, 72, 65, 73, 65, 65,
57, 57, 57, 57, 57, 57, 57, 57, 58, 59, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
59, 59, 60, 61, 61, 61, 61, 61, 61, 61, 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
62, 63, 63, 64, 64, -1 74, 74, 74, 75, 76, 76, 76, 77, 78, 78,
78, 78, 78, 79, 79, 79, 79, 79, 79, 79,
80, 81, 81, 82, 82, -1
}; };
static const short yyr2[] = { 0, static const short yyr2[] = { 0,
0, 0, 7, 1, 1, 1, 1, 0, 2, 2, 0, 0, 7, 1, 1, 1, 1, 0, 2, 2,
2, 2, 2, 0, 4, 0, 5, 1, 1, 1, 2, 2, 2, 0, 4, 0, 5, 0, 5, 0,
5, 0, 5, 0, 5, 0, 5, 0, 5, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 2, 4, 4, 0, 2,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
4, 0, 2, 4, 1, 1 4, 0, 2, 4, 1, 1
}; };
static const short yydefact[] = { 0, static const short yydefact[] = { 0,
1, 0, 0, 4, 5, 6, 7, 8, 2, 12, 1, 0, 0, 4, 5, 6, 7, 8, 2, 12,
30, 31, 18, 19, 20, 21, 22, 23, 24, 25, 45, 46, 31, 32, 33, 34, 35, 36, 37, 38,
26, 27, 28, 29, 34, 35, 36, 37, 32, 33, 39, 40, 41, 42, 43, 44, 49, 50, 51, 52,
38, 14, 0, 13, 11, 9, 10, 52, 40, 8, 47, 48, 53, 14, 0, 13, 11, 9, 10, 72,
0, 3, 0, 0, 0, 8, 55, 0, 51, 53, 55, 30, 8, 0, 0, 0, 0, 0, 0, 0,
0, 0, 39, 41, 15, 0, 0, 44, 45, 46, 3, 0, 0, 0, 8, 8, 8, 8, 8, 8,
47, 48, 49, 50, 0, 0, 17, 0, 43, 42, 8, 75, 0, 71, 73, 0, 0, 54, 56, 15,
54, 0, 0, 0 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
66, 67, 68, 69, 70, 59, 0, 17, 19, 21,
23, 25, 27, 29, 0, 0, 57, 74, 58, 60,
61, 62, 14, 63, 0, 0, 0
}; };
static const short yydefgoto[] = { 72, static const short yydefgoto[] = { 105,
2, 33, 8, 9, 34, 40, 41, 35, 36, 44, 2, 35, 8, 9, 36, 43, 44, 45, 46, 47,
54, 65, 37, 43, 50 48, 49, 50, 37, 38, 53, 69, 96, 86, 39,
52, 65
}; };
static const short yypact[] = { -45, static const short yypact[] = { -56,
-32768, 8, 66,-32768,-32768,-32768,-32768,-32768, 67,-32768, -32768, -2, 44,-32768,-32768,-32768,-32768,-32768, 318,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
-32768, 92, -10,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768, 358, -55,-32768,-32768,-32768,-32768,-32768,
30,-32768, 28, -14, -3,-32768,-32768, 29,-32768,-32768, -32768,-32768,-32768, -4, 4, 7, 3, 26, 29, 38,
-36, 25,-32768,-32768,-32768, 32, 35,-32768,-32768,-32768, -32768, 316, -16, -3,-32768,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768, 63, 20,-32768, 65,-32768,-32768, -32768,-32768, 27,-32768,-32768, -43, 57,-32768,-32768,-32768,
-32768, 76, 77,-32768 37, 77, 117, 157, 197, 237, 277, 63,-32768,-32768,
-32768,-32768,-32768,-32768,-32768,-32768, 24,-32768,-32768,-32768,
-32768,-32768,-32768,-32768, 80, 1,-32768,-32768,-32768,-32768,
-32768,-32768, 278,-32768, 84, 86,-32768
}; };
static const short yypgoto[] = {-32768, static const short yypgoto[] = {-32768,
-32768,-32768,-32768, -4,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768, 333, -9,-32768,-32768,-32768,-32768,-32768,
50,-32768,-32768,-32768,-32768 -32768,-32768,-32768,-32768,-32768,-32768, 21,-32768,-32768,-32768,
-32768,-32768
}; };
#define YYLAST 130 #define YYLAST 416
static const short yytable[] = { 10, static const short yytable[] = { 10,
1, 51, 58, 59, 60, 61, 62, 63, 64, 11, 1, 3, 51, 99, 55, 66, 79, 80, 81, 82,
12, 3, 13, 14, 15, 16, 17, 18, 19, 20, 83, 84, 85, 56, 58, 11, 12, 57, 13, 14,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
47, 52, 53, 31, 10, 45, 42, 48, 46, 57, 25, 26, 27, 28, 29, 30, 31, 32, 59, 10,
51, 56, 32, 55, 11, 12, 68, 13, 14, 15, 67, 68, 60, 78, 33, 100, 101, 102, 4, 5,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 6, 7, 61, 34, 70, 11, 12, 103, 13, 14,
26, 27, 28, 29, 30, 69, 70, 71, 31, 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
4, 5, 6, 7, 49, 73, 74, 32, 67, 11, 25, 26, 27, 28, 29, 30, 31, 32, 66, 10,
12, 0, 13, 14, 15, 16, 17, 18, 19, 20, 95, 97, 98, 106, 33, 107, 104, 87, 0, 0,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 34, 88, 11, 12, 0, 13, 14,
-16, 66, 0, 31, 0, 0, 38, 0, 0, 0, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 0, 10,
0, 0, 0, 0, 0, 0, 0, 0, 0, 39 0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
0, 0, 0, 34, 89, 11, 12, 0, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 0, 10,
0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
0, 0, 0, 34, 90, 11, 12, 0, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 0, 10,
0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
0, 0, 0, 34, 91, 11, 12, 0, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 0, 10,
0, 0, 0, 0, 33, 0, 0, 0, 0, 0,
0, 0, 0, 34, 92, 11, 12, 0, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 0, 10,
0, 0, 0, 0, 33, 0, -16, -18, -20, -22,
-24, -26, -28, 34, 93, 11, 12, 0, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 62, 0,
10, 0, 0, 0, 33, 0, 0, 0, 0, 0,
0, 63, 0, 34, 94, 42, 11, 12, 0, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 0,
0, 0, 0, 0, 0, 33, -16, -18, -20, -22,
-24, -26, -28, 64, 34, 54, 0, 0, 40, 0,
0, 0, 0, 0, 0, 0, 0, 71, 72, 73,
74, 75, 76, 77, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 41, 0, 0, 0,
0, 0, 0, 0, 0, 42
}; };
static const short yycheck[] = { 3, static const short yycheck[] = { 3,
46, 16, 39, 40, 41, 42, 43, 44, 45, 13, 57, 4, 58, 3, 9, 22, 50, 51, 52, 53,
14, 4, 16, 17, 18, 19, 20, 21, 22, 23, 54, 55, 56, 10, 12, 19, 20, 11, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
3, 46, 47, 37, 3, 40, 47, 10, 9, 11, 34, 35, 36, 37, 38, 39, 40, 41, 13, 3,
16, 46, 46, 47, 13, 14, 12, 16, 17, 18, 57, 58, 14, 17, 48, 45, 46, 47, 5, 6,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 7, 8, 15, 57, 58, 19, 20, 57, 22, 23,
29, 30, 31, 32, 33, 3, 47, 3, 37, 3,
5, 6, 7, 8, 47, 0, 0, 46, 47, 13,
14, -1, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
9, 52, -1, 37, -1, -1, 15, -1, -1, -1, 34, 35, 36, 37, 38, 39, 40, 41, 22, 3,
-1, -1, 46, -1, -1, -1, -1, -1, -1, -1, 18, 58, 3, 0, 48, 0, 96, 67, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 38 -1, -1, -1, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, -1, 3,
-1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
-1, -1, -1, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, -1, 3,
-1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
-1, -1, -1, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, -1, 3,
-1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
-1, -1, -1, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, -1, 3,
-1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
-1, -1, -1, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, -1, 3,
-1, -1, -1, -1, 48, -1, 9, 10, 11, 12,
13, 14, 15, 57, 58, 19, 20, -1, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 3, -1,
3, -1, -1, -1, 48, -1, -1, -1, -1, -1,
-1, 16, -1, 57, 58, 58, 19, 20, -1, 22,
23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, -1,
-1, -1, -1, -1, -1, 48, 9, 10, 11, 12,
13, 14, 15, 58, 57, 43, -1, -1, 21, -1,
-1, -1, -1, -1, -1, -1, -1, 55, 56, 57,
58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 49, -1, -1, -1,
-1, -1, -1, -1, -1, 58
}; };
#define YYPURE 1 #define YYPURE 1
@ -809,51 +906,99 @@ yyreduce:
switch (yyn) { switch (yyn) {
case 1: case 1:
#line 131 "Parsers/rtfGrammer.y" #line 142 "Parsers/rtfGrammer.y"
{ GSRTFstart(ctxt); ; { GSRTFstart(ctxt); ;
break;} break;}
case 2: case 2:
#line 131 "Parsers/rtfGrammer.y" #line 142 "Parsers/rtfGrammer.y"
{ GSRTFstop(ctxt); ; { GSRTFstop(ctxt); ;
break;} break;}
case 4: case 4:
#line 134 "Parsers/rtfGrammer.y" #line 145 "Parsers/rtfGrammer.y"
{ yyval.number = 1; ; { yyval.number = 1; ;
break;} break;}
case 5: case 5:
#line 135 "Parsers/rtfGrammer.y" #line 146 "Parsers/rtfGrammer.y"
{ yyval.number = 2; ; { yyval.number = 2; ;
break;} break;}
case 6: case 6:
#line 136 "Parsers/rtfGrammer.y" #line 147 "Parsers/rtfGrammer.y"
{ yyval.number = 3; ; { yyval.number = 3; ;
break;} break;}
case 7: case 7:
#line 137 "Parsers/rtfGrammer.y" #line 148 "Parsers/rtfGrammer.y"
{ yyval.number = 4; ; { yyval.number = 4; ;
break;} break;}
case 12: case 12:
#line 144 "Parsers/rtfGrammer.y" #line 155 "Parsers/rtfGrammer.y"
{ GSRTFmangleText(ctxt, yyvsp[0].text); free((void *)yyvsp[0].text); ; { GSRTFmangleText(ctxt, yyvsp[0].text); free((void *)yyvsp[0].text); ;
break;} break;}
case 14: case 14:
#line 148 "Parsers/rtfGrammer.y" #line 159 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt); ; { GSRTFopenBlock(ctxt, NO); ;
break;} break;}
case 15: case 15:
#line 148 "Parsers/rtfGrammer.y" #line 159 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt); ; { GSRTFcloseBlock(ctxt, NO); ;
break;} break;}
case 16: case 16:
#line 149 "Parsers/rtfGrammer.y" #line 160 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt); ; { GSRTFopenBlock(ctxt, YES); ;
break;} break;}
case 17: case 17:
#line 149 "Parsers/rtfGrammer.y" #line 160 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt); ; { GSRTFcloseBlock(ctxt, YES); ;
break;} break;}
case 18: case 18:
#line 157 "Parsers/rtfGrammer.y" #line 161 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 19:
#line 161 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 20:
#line 162 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 21:
#line 162 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 22:
#line 163 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 23:
#line 163 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 24:
#line 164 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 25:
#line 164 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 26:
#line 165 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 27:
#line 165 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 28:
#line 166 "Parsers/rtfGrammer.y"
{ GSRTFopenBlock(ctxt, YES); ;
break;}
case 29:
#line 166 "Parsers/rtfGrammer.y"
{ GSRTFcloseBlock(ctxt, YES); ;
break;}
case 31:
#line 175 "Parsers/rtfGrammer.y"
{ int font; { int font;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -862,8 +1007,8 @@ case 18:
font = yyvsp[0].cmd.parameter; font = yyvsp[0].cmd.parameter;
GSRTFfontNumber(ctxt, font); ; GSRTFfontNumber(ctxt, font); ;
break;} break;}
case 19: case 32:
#line 164 "Parsers/rtfGrammer.y" #line 182 "Parsers/rtfGrammer.y"
{ int size; { int size;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -872,8 +1017,8 @@ case 19:
size = yyvsp[0].cmd.parameter; size = yyvsp[0].cmd.parameter;
GSRTFfontSize(ctxt, size); ; GSRTFfontSize(ctxt, size); ;
break;} break;}
case 20: case 33:
#line 171 "Parsers/rtfGrammer.y" #line 189 "Parsers/rtfGrammer.y"
{ int width; { int width;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -882,8 +1027,8 @@ case 20:
width = yyvsp[0].cmd.parameter; width = yyvsp[0].cmd.parameter;
GSRTFpaperWidth(ctxt, width);; GSRTFpaperWidth(ctxt, width);;
break;} break;}
case 21: case 34:
#line 178 "Parsers/rtfGrammer.y" #line 196 "Parsers/rtfGrammer.y"
{ int height; { int height;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -892,8 +1037,8 @@ case 21:
height = yyvsp[0].cmd.parameter; height = yyvsp[0].cmd.parameter;
GSRTFpaperHeight(ctxt, height);; GSRTFpaperHeight(ctxt, height);;
break;} break;}
case 22: case 35:
#line 185 "Parsers/rtfGrammer.y" #line 203 "Parsers/rtfGrammer.y"
{ int margin; { int margin;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -902,8 +1047,8 @@ case 22:
margin = yyvsp[0].cmd.parameter; margin = yyvsp[0].cmd.parameter;
GSRTFmarginLeft(ctxt, margin);; GSRTFmarginLeft(ctxt, margin);;
break;} break;}
case 23: case 36:
#line 192 "Parsers/rtfGrammer.y" #line 210 "Parsers/rtfGrammer.y"
{ int margin; { int margin;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -912,8 +1057,28 @@ case 23:
margin = yyvsp[0].cmd.parameter; margin = yyvsp[0].cmd.parameter;
GSRTFmarginRight(ctxt, margin); ; GSRTFmarginRight(ctxt, margin); ;
break;} break;}
case 24: case 37:
#line 199 "Parsers/rtfGrammer.y" #line 217 "Parsers/rtfGrammer.y"
{ int margin;
if (yyvsp[0].cmd.isEmpty)
margin = 1440;
else
margin = yyvsp[0].cmd.parameter;
GSRTFmarginTop(ctxt, margin); ;
break;}
case 38:
#line 224 "Parsers/rtfGrammer.y"
{ int margin;
if (yyvsp[0].cmd.isEmpty)
margin = 1440;
else
margin = yyvsp[0].cmd.parameter;
GSRTFmarginButtom(ctxt, margin); ;
break;}
case 39:
#line 231 "Parsers/rtfGrammer.y"
{ int indent; { int indent;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -922,8 +1087,8 @@ case 24:
indent = yyvsp[0].cmd.parameter; indent = yyvsp[0].cmd.parameter;
GSRTFfirstLineIndent(ctxt, indent); ; GSRTFfirstLineIndent(ctxt, indent); ;
break;} break;}
case 25: case 40:
#line 206 "Parsers/rtfGrammer.y" #line 238 "Parsers/rtfGrammer.y"
{ int indent; { int indent;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -932,24 +1097,24 @@ case 25:
indent = yyvsp[0].cmd.parameter; indent = yyvsp[0].cmd.parameter;
GSRTFleftIndent(ctxt, indent);; GSRTFleftIndent(ctxt, indent);;
break;} break;}
case 26: case 41:
#line 213 "Parsers/rtfGrammer.y" #line 245 "Parsers/rtfGrammer.y"
{ GSRTFalignCenter(ctxt); ; { GSRTFalignCenter(ctxt); ;
break;} break;}
case 27: case 42:
#line 214 "Parsers/rtfGrammer.y" #line 246 "Parsers/rtfGrammer.y"
{ GSRTFalignLeft(ctxt); ; { GSRTFalignLeft(ctxt); ;
break;} break;}
case 28: case 43:
#line 215 "Parsers/rtfGrammer.y" #line 247 "Parsers/rtfGrammer.y"
{ GSRTFalignRight(ctxt); ; { GSRTFalignRight(ctxt); ;
break;} break;}
case 29: case 44:
#line 216 "Parsers/rtfGrammer.y" #line 248 "Parsers/rtfGrammer.y"
{ GSRTFstyle(ctxt, yyvsp[0].cmd.parameter); ; { GSRTFstyle(ctxt, yyvsp[0].cmd.parameter); ;
break;} break;}
case 30: case 45:
#line 217 "Parsers/rtfGrammer.y" #line 249 "Parsers/rtfGrammer.y"
{ int color; { int color;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -958,8 +1123,8 @@ case 30:
color = yyvsp[0].cmd.parameter; color = yyvsp[0].cmd.parameter;
GSRTFcolorbg(ctxt, color); ; GSRTFcolorbg(ctxt, color); ;
break;} break;}
case 31: case 46:
#line 224 "Parsers/rtfGrammer.y" #line 256 "Parsers/rtfGrammer.y"
{ int color; { int color;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -968,8 +1133,8 @@ case 31:
color = yyvsp[0].cmd.parameter; color = yyvsp[0].cmd.parameter;
GSRTFcolorfg(ctxt, color); ; GSRTFcolorfg(ctxt, color); ;
break;} break;}
case 32: case 47:
#line 231 "Parsers/rtfGrammer.y" #line 263 "Parsers/rtfGrammer.y"
{ int script; { int script;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -978,8 +1143,8 @@ case 32:
script = yyvsp[0].cmd.parameter; script = yyvsp[0].cmd.parameter;
GSRTFsubscript(ctxt, script); ; GSRTFsubscript(ctxt, script); ;
break;} break;}
case 33: case 48:
#line 238 "Parsers/rtfGrammer.y" #line 270 "Parsers/rtfGrammer.y"
{ int script; { int script;
if (yyvsp[0].cmd.isEmpty) if (yyvsp[0].cmd.isEmpty)
@ -988,8 +1153,8 @@ case 33:
script = yyvsp[0].cmd.parameter; script = yyvsp[0].cmd.parameter;
GSRTFsuperscript(ctxt, script); ; GSRTFsuperscript(ctxt, script); ;
break;} break;}
case 34: case 49:
#line 245 "Parsers/rtfGrammer.y" #line 277 "Parsers/rtfGrammer.y"
{ BOOL on; { BOOL on;
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter) if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
@ -998,8 +1163,8 @@ case 34:
on = NO; on = NO;
GSRTFbold(ctxt, on); ; GSRTFbold(ctxt, on); ;
break;} break;}
case 35: case 50:
#line 252 "Parsers/rtfGrammer.y" #line 284 "Parsers/rtfGrammer.y"
{ BOOL on; { BOOL on;
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter) if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
@ -1008,8 +1173,8 @@ case 35:
on = NO; on = NO;
GSRTFitalic(ctxt, on); ; GSRTFitalic(ctxt, on); ;
break;} break;}
case 36: case 51:
#line 259 "Parsers/rtfGrammer.y" #line 291 "Parsers/rtfGrammer.y"
{ BOOL on; { BOOL on;
if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter) if (yyvsp[0].cmd.isEmpty || yyvsp[0].cmd.parameter)
@ -1018,57 +1183,63 @@ case 36:
on = NO; on = NO;
GSRTFunderline(ctxt, on); ; GSRTFunderline(ctxt, on); ;
break;} break;}
case 37: case 52:
#line 266 "Parsers/rtfGrammer.y" #line 298 "Parsers/rtfGrammer.y"
{ GSRTFunderline(ctxt, NO); ; { GSRTFunderline(ctxt, NO); ;
break;} break;}
case 38: case 53:
#line 267 "Parsers/rtfGrammer.y" #line 299 "Parsers/rtfGrammer.y"
{ GSRTFgenericRTFcommand(ctxt, yyvsp[0].cmd); ; { GSRTFgenericRTFcommand(ctxt, yyvsp[0].cmd); ;
break;} break;}
case 43: case 58:
#line 285 "Parsers/rtfGrammer.y" #line 317 "Parsers/rtfGrammer.y"
{ GSRTFregisterFont(ctxt, yyvsp[0].text, yyvsp[-1].number, yyvsp[-2].cmd.parameter); { GSRTFregisterFont(ctxt, yyvsp[0].text, yyvsp[-2].number, yyvsp[-3].cmd.parameter);
free((void *)yyvsp[0].text); ; free((void *)yyvsp[0].text); ;
break;} break;}
case 44: case 64:
#line 290 "Parsers/rtfGrammer.y" #line 330 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyNil - RTFfamilyNil; ; { yyval.number = RTFfamilyNil - RTFfamilyNil; ;
break;} break;}
case 45: case 65:
#line 291 "Parsers/rtfGrammer.y" #line 331 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyRoman - RTFfamilyNil; ; { yyval.number = RTFfamilyRoman - RTFfamilyNil; ;
break;} break;}
case 46: case 66:
#line 292 "Parsers/rtfGrammer.y" #line 332 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilySwiss - RTFfamilyNil; ; { yyval.number = RTFfamilySwiss - RTFfamilyNil; ;
break;} break;}
case 47: case 67:
#line 293 "Parsers/rtfGrammer.y" #line 333 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyModern - RTFfamilyNil; ; { yyval.number = RTFfamilyModern - RTFfamilyNil; ;
break;} break;}
case 48: case 68:
#line 294 "Parsers/rtfGrammer.y" #line 334 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyScript - RTFfamilyNil; ; { yyval.number = RTFfamilyScript - RTFfamilyNil; ;
break;} break;}
case 49: case 69:
#line 295 "Parsers/rtfGrammer.y" #line 335 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyDecor - RTFfamilyNil; ; { yyval.number = RTFfamilyDecor - RTFfamilyNil; ;
break;} break;}
case 50: case 70:
#line 296 "Parsers/rtfGrammer.y" #line 336 "Parsers/rtfGrammer.y"
{ yyval.number = RTFfamilyTech - RTFfamilyNil; ; { yyval.number = RTFfamilyTech - RTFfamilyNil; ;
break;} break;}
case 54: case 74:
#line 312 "Parsers/rtfGrammer.y" #line 353 "Parsers/rtfGrammer.y"
{ free((void *)yyvsp[0].text);; {
GSRTFaddColor(ctxt, yyvsp[-3].cmd.parameter, yyvsp[-2].cmd.parameter, yyvsp[-1].cmd.parameter);
free((void *)yyvsp[0].text);
;
break;} break;}
case 55: case 75:
#line 313 "Parsers/rtfGrammer.y" #line 358 "Parsers/rtfGrammer.y"
{ free((void *)yyvsp[0].text);; {
GSRTFaddDefaultColor(ctxt);
free((void *)yyvsp[0].text);
;
break;} break;}
case 56: case 76:
#line 319 "Parsers/rtfGrammer.y" #line 367 "Parsers/rtfGrammer.y"
{ yylsp[0].first_line; ; { yylsp[0].first_line; ;
break;} break;}
} }
@ -1269,7 +1440,7 @@ yyerrhandle:
yystate = yyn; yystate = yyn;
goto yynewstate; goto yynewstate;
} }
#line 322 "Parsers/rtfGrammer.y" #line 370 "Parsers/rtfGrammer.y"
/* some C code here */ /* some C code here */

View file

@ -27,40 +27,51 @@ typedef
#define RTFpc 262 #define RTFpc 262
#define RTFpca 263 #define RTFpca 263
#define RTFignore 264 #define RTFignore 264
#define RTFred 265 #define RTFinfo 265
#define RTFgreen 266 #define RTFstylesheet 266
#define RTFblue 267 #define RTFfootnote 267
#define RTFcolorbg 268 #define RTFheader 268
#define RTFcolorfg 269 #define RTFfooter 269
#define RTFcolortable 270 #define RTFpict 270
#define RTFfont 271 #define RTFred 271
#define RTFfontSize 272 #define RTFgreen 272
#define RTFpaperWidth 273 #define RTFblue 273
#define RTFpaperHeight 274 #define RTFcolorbg 274
#define RTFmarginLeft 275 #define RTFcolorfg 275
#define RTFmarginRight 276 #define RTFcolortable 276
#define RTFfirstLineIndent 277 #define RTFfont 277
#define RTFleftIndent 278 #define RTFfontSize 278
#define RTFalignCenter 279 #define RTFpaperWidth 279
#define RTFalignLeft 280 #define RTFpaperHeight 280
#define RTFalignRight 281 #define RTFmarginLeft 281
#define RTFstyle 282 #define RTFmarginRight 282
#define RTFbold 283 #define RTFmarginTop 283
#define RTFitalic 284 #define RTFmarginButtom 284
#define RTFunderline 285 #define RTFfirstLineIndent 285
#define RTFunderlineStop 286 #define RTFleftIndent 286
#define RTFsubscript 287 #define RTFalignCenter 287
#define RTFsuperscript 288 #define RTFalignLeft 288
#define RTFtabulator 289 #define RTFalignRight 289
#define RTFparagraph 290 #define RTFstyle 290
#define RTFdefaultParagraph 291 #define RTFbold 291
#define RTFOtherStatement 292 #define RTFitalic 292
#define RTFfontListStart 293 #define RTFunderline 293
#define RTFfamilyNil 294 #define RTFunderlineStop 294
#define RTFfamilyRoman 295 #define RTFsubscript 295
#define RTFfamilySwiss 296 #define RTFsuperscript 296
#define RTFfamilyModern 297 #define RTFtabulator 297
#define RTFfamilyScript 298 #define RTFparagraph 298
#define RTFfamilyDecor 299 #define RTFdefaultParagraph 299
#define RTFfamilyTech 300 #define RTFfcharset 300
#define RTFfprq 301
#define RTFcpg 302
#define RTFOtherStatement 303
#define RTFfontListStart 304
#define RTFfamilyNil 305
#define RTFfamilyRoman 306
#define RTFfamilySwiss 307
#define RTFfamilyModern 308
#define RTFfamilyScript 309
#define RTFfamilyDecor 310
#define RTFfamilyTech 311

View file

@ -81,6 +81,12 @@ typedef void * GSRTFctxt;
%token RTFpc %token RTFpc
%token RTFpca %token RTFpca
%token RTFignore %token RTFignore
%token RTFinfo
%token RTFstylesheet
%token RTFfootnote
%token RTFheader
%token RTFfooter
%token RTFpict
%token <cmd> RTFred %token <cmd> RTFred
%token <cmd> RTFgreen %token <cmd> RTFgreen
%token <cmd> RTFblue %token <cmd> RTFblue
@ -93,6 +99,8 @@ typedef void * GSRTFctxt;
%token <cmd> RTFpaperHeight %token <cmd> RTFpaperHeight
%token <cmd> RTFmarginLeft %token <cmd> RTFmarginLeft
%token <cmd> RTFmarginRight %token <cmd> RTFmarginRight
%token <cmd> RTFmarginTop
%token <cmd> RTFmarginButtom
%token <cmd> RTFfirstLineIndent %token <cmd> RTFfirstLineIndent
%token <cmd> RTFleftIndent %token <cmd> RTFleftIndent
%token <cmd> RTFalignCenter %token <cmd> RTFalignCenter
@ -108,6 +116,9 @@ typedef void * GSRTFctxt;
%token <cmd> RTFtabulator %token <cmd> RTFtabulator
%token <cmd> RTFparagraph %token <cmd> RTFparagraph
%token <cmd> RTFdefaultParagraph %token <cmd> RTFdefaultParagraph
%token <cmd> RTFfcharset
%token <cmd> RTFfprq
%token <cmd> RTFcpg
%token <cmd> RTFOtherStatement %token <cmd> RTFOtherStatement
%token RTFfontListStart %token RTFfontListStart
@ -145,8 +156,15 @@ rtfIngredients: /* empty */
| rtfIngredients rtfBlock | rtfIngredients rtfBlock
; ;
rtfBlock: '{' { GSRTFopenBlock(ctxt); } rtfIngredients '}' { GSRTFcloseBlock(ctxt); } rtfBlock: '{' { GSRTFopenBlock(ctxt, NO); } rtfIngredients '}' { GSRTFcloseBlock(ctxt, NO); }
| '{' { GSRTFopenBlock(ctxt); } RTFignore rtfIngredients '}' { GSRTFcloseBlock(ctxt); } | '{' { GSRTFopenBlock(ctxt, YES); } RTFignore rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFinfo rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFstylesheet rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFfootnote rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFheader rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFfooter rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' { GSRTFopenBlock(ctxt, YES); } RTFpict rtfIngredients '}' { GSRTFcloseBlock(ctxt, YES); }
| '{' '}' /* empty */
; ;
@ -196,6 +214,20 @@ rtfStatement: RTFfont { int font;
else else
margin = $1.parameter; margin = $1.parameter;
GSRTFmarginRight(ctxt, margin); } GSRTFmarginRight(ctxt, margin); }
| RTFmarginTop { int margin;
if ($1.isEmpty)
margin = 1440;
else
margin = $1.parameter;
GSRTFmarginTop(ctxt, margin); }
| RTFmarginButtom { int margin;
if ($1.isEmpty)
margin = 1440;
else
margin = $1.parameter;
GSRTFmarginButtom(ctxt, margin); }
| RTFfirstLineIndent { int indent; | RTFfirstLineIndent { int indent;
if ($1.isEmpty) if ($1.isEmpty)
@ -282,10 +314,18 @@ rtfFonts:
/* the first RTFfont tags the font with a number */ /* the first RTFfont tags the font with a number */
/* RTFtext introduces the fontName */ /* RTFtext introduces the fontName */
rtfFontStatement: RTFfont rtfFontFamily RTFtext { GSRTFregisterFont(ctxt, $3, $2, $1.parameter); rtfFontStatement: RTFfont rtfFontFamily rtfFontAttrs RTFtext { GSRTFregisterFont(ctxt, $4, $2, $1.parameter);
free((void *)$3); } free((void *)$4); }
; ;
rtfFontAttrs: /* empty */
| rtfFontAttrs RTFfcharset
| rtfFontAttrs RTFfprq
| rtfFontAttrs RTFcpg
| rtfFontAttrs rtfBlock
;
rtfFontFamily: rtfFontFamily:
RTFfamilyNil { $$ = RTFfamilyNil - RTFfamilyNil; } RTFfamilyNil { $$ = RTFfamilyNil - RTFfamilyNil; }
| RTFfamilyRoman { $$ = RTFfamilyRoman - RTFfamilyNil; } | RTFfamilyRoman { $$ = RTFfamilyRoman - RTFfamilyNil; }
@ -309,8 +349,16 @@ rtfColors: /* empty */
; ;
/* We get the ';' as RTFText */ /* We get the ';' as RTFText */
rtfColorStatement: RTFred RTFgreen RTFblue RTFtext { free((void *)$4);} rtfColorStatement: RTFred RTFgreen RTFblue RTFtext
| RTFtext { free((void *)$1);} {
GSRTFaddColor(ctxt, $1.parameter, $2.parameter, $3.parameter);
free((void *)$4);
}
| RTFtext
{
GSRTFaddDefaultColor(ctxt);
free((void *)$1);
}
; ;
/* /*

View file

@ -147,36 +147,47 @@ LexKeyword RTFcommands[]={
"cb", token(RTFcolorbg), "cb", token(RTFcolorbg),
"cf", token(RTFcolorfg), "cf", token(RTFcolorfg),
"colortbl", token(RTFcolortable), "colortbl", token(RTFcolortable),
"cpg", token(RTFcpg),
"dn", token(RTFsubscript), "dn", token(RTFsubscript),
"f", token(RTFfont), "f", token(RTFfont),
"fcharset", token(RTFfcharset),
"fdecor", token(RTFfamilyDecor), "fdecor", token(RTFfamilyDecor),
"fi", token(RTFfirstLineIndent), "fi", token(RTFfirstLineIndent),
"fmodern", token(RTFfamilyModern), "fmodern", token(RTFfamilyModern),
"fnil", token(RTFfamilyNil), "fnil", token(RTFfamilyNil),
"fonttbl", token(RTFfontListStart), "fonttbl", token(RTFfontListStart),
"footer", token(RTFfooter),
"footnote", token(RTFfootnote),
"fprq", token(RTFfprq),
"froman", token(RTFfamilyRoman), "froman", token(RTFfamilyRoman),
"fs", token(RTFfontSize), "fs", token(RTFfontSize),
"fscript", token(RTFfamilyScript), "fscript", token(RTFfamilyScript),
"fswiss", token(RTFfamilySwiss), "fswiss", token(RTFfamilySwiss),
"ftech", token(RTFfamilyTech), "ftech", token(RTFfamilyTech),
"green", token(RTFgreen), "green", token(RTFgreen),
"header", token(RTFheader),
"i", token(RTFitalic), "i", token(RTFitalic),
"info", token(RTFinfo),
"li", token(RTFleftIndent), "li", token(RTFleftIndent),
"mac", token(RTFmac), "mac", token(RTFmac),
"margb", token(RTFmarginButtom),
"margl", token(RTFmarginLeft), "margl", token(RTFmarginLeft),
"margr", token(RTFmarginRight), "margr", token(RTFmarginRight),
"margt", token(RTFmarginTop),
"paperh", token(RTFpaperHeight), "paperh", token(RTFpaperHeight),
"paperw", token(RTFpaperWidth), "paperw", token(RTFpaperWidth),
"par", token(RTFparagraph), "par", token(RTFparagraph),
"pard", token(RTFdefaultParagraph), "pard", token(RTFdefaultParagraph),
"pc", token(RTFpc), "pc", token(RTFpc),
"pca", token(RTFpca), "pca", token(RTFpca),
"pict", token(RTFpict),
"qc", token(RTFalignCenter), "qc", token(RTFalignCenter),
"ql", token(RTFalignLeft), "ql", token(RTFalignLeft),
"qr", token(RTFalignRight), "qr", token(RTFalignRight),
"red", token(RTFred), "red", token(RTFred),
"rtf", token(RTFstart), "rtf", token(RTFstart),
"s", token(RTFstyle), "s", token(RTFstyle),
"stylesheet", token(RTFstylesheet),
"tab", token(RTFtabulator), "tab", token(RTFtabulator),
"ul", token(RTFunderline), "ul", token(RTFunderline),
"ulnone", token(RTFunderlineStop), "ulnone", token(RTFunderlineStop),
@ -366,6 +377,7 @@ int GSRTFlex(YYSTYPE *lvalp, YYLTYPE *llocp, RTFscannerCtxt *lctxt) /* provide v
case '~': c = ' '; case '~': c = ' ';
break; break;
case '\n': case '\n':
case '\r':
// release is up to the consumer // release is up to the consumer
cv = calloc(1, 2); cv = calloc(1, 2);
cv[0] = '\n'; cv[0] = '\n';
@ -374,8 +386,29 @@ int GSRTFlex(YYSTYPE *lvalp, YYLTYPE *llocp, RTFscannerCtxt *lctxt) /* provide v
token = RTFtext; token = RTFtext;
return token; return token;
case '{': case '{':
// release is up to the consumer
cv = calloc(1, 2);
cv[0] = '{';
cv[1] = '\0';
lvalp->text = cv;
token = RTFtext;
return token;
case '}': case '}':
// release is up to the consumer
cv = calloc(1, 2);
cv[0] = '}';
cv[1] = '\0';
lvalp->text = cv;
token = RTFtext;
return token;
case '\\': case '\\':
// release is up to the consumer
cv = calloc(1, 2);
cv[0] = '\\';
cv[1] = '\0';
lvalp->text = cv;
token = RTFtext;
return token;
default: default:
// fall through // fall through
} }

View file

@ -60,4 +60,9 @@ typedef enum {
void lexInitContext(RTFscannerCtxt *lctxt, void *customContext, int (*getcharFunction)()); void lexInitContext(RTFscannerCtxt *lctxt, void *customContext, int (*getcharFunction)());
/* external symbols from the grammer */
/*int GSRTFparse(void *ctxt, RTFscannerCtxt *lctxt);*/
int GSRTFparse(void *ctxt, void *lctxt);
#endif #endif