mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 11:01:56 +00:00
Added support for RTF special characters and extra paragraph attributes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6786 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
856468e13b
commit
21e0c1e7b2
6 changed files with 620 additions and 406 deletions
|
@ -57,7 +57,8 @@ readNSString(StringContext *ctxt)
|
||||||
{
|
{
|
||||||
@public
|
@public
|
||||||
BOOL changed;
|
BOOL changed;
|
||||||
NSParagraphStyle *paragraph;
|
BOOL tabChanged;
|
||||||
|
NSMutableParagraphStyle *paragraph;
|
||||||
NSColor *fgColour;
|
NSColor *fgColour;
|
||||||
NSColor *bgColour;
|
NSColor *bgColour;
|
||||||
NSString *fontName;
|
NSString *fontName;
|
||||||
|
@ -73,6 +74,7 @@ readNSString(StringContext *ctxt)
|
||||||
- (NSNumber*) underline;
|
- (NSNumber*) underline;
|
||||||
- (void) resetParagraphStyle;
|
- (void) resetParagraphStyle;
|
||||||
- (void) resetFont;
|
- (void) resetFont;
|
||||||
|
- (void) addTab: (float) location type: (NSTextTabType) type;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -97,16 +99,10 @@ readNSString(StringContext *ctxt)
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone*)zone
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
RTFAttribute *new = [isa allocWithZone: zone];
|
RTFAttribute *new = (RTFAttribute *)NSCopyObject (self, 0, zone);
|
||||||
|
|
||||||
new->paragraph = [paragraph copyWithZone: zone];
|
new->paragraph = [paragraph copyWithZone: zone];
|
||||||
new->fontName = [fontName copyWithZone: zone];
|
new->fontName = [fontName copyWithZone: zone];
|
||||||
new->fontSize = fontSize;
|
|
||||||
new->italic = italic;
|
|
||||||
new->bold = bold;
|
|
||||||
new->underline = underline;
|
|
||||||
new->script = script;
|
|
||||||
new->changed = NO;
|
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +120,7 @@ readNSString(StringContext *ctxt)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
weight = 6;
|
weight = 5;
|
||||||
traits |= NSUnboldFontMask;
|
traits |= NSUnboldFontMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +165,7 @@ readNSString(StringContext *ctxt)
|
||||||
{
|
{
|
||||||
ASSIGN(paragraph, [NSMutableParagraphStyle defaultParagraphStyle]);
|
ASSIGN(paragraph, [NSMutableParagraphStyle defaultParagraphStyle]);
|
||||||
|
|
||||||
|
tabChanged = NO;
|
||||||
changed = YES;
|
changed = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +186,24 @@ readNSString(StringContext *ctxt)
|
||||||
changed = YES;
|
changed = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) addTab: (float) location type: (NSTextTabType) type
|
||||||
|
{
|
||||||
|
NSTextTab *tab = [[NSTextTab alloc] initWithType: NSLeftTabStopType
|
||||||
|
location: location];
|
||||||
|
|
||||||
|
if (!tabChanged)
|
||||||
|
{
|
||||||
|
// remove all tab stops
|
||||||
|
[paragraph setTabStops: [NSArray arrayWithObject: tab]];
|
||||||
|
tabChanged = YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[paragraph addTabStop: tab];
|
||||||
|
|
||||||
|
changed = YES;
|
||||||
|
RELEASE(tab);
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RTFConsumer: NSObject
|
@interface RTFConsumer: NSObject
|
||||||
|
@ -268,6 +283,7 @@ readNSString(StringContext *ctxt)
|
||||||
- (void) pop
|
- (void) pop
|
||||||
{
|
{
|
||||||
[attrs removeLastObject];
|
[attrs removeLastObject];
|
||||||
|
((RTFAttribute*)[attrs lastObject])->changed = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSAttributedString*) result
|
- (NSAttributedString*) result
|
||||||
|
@ -284,7 +300,7 @@ readNSString(StringContext *ctxt)
|
||||||
StringContext stringCtxt;
|
StringContext stringCtxt;
|
||||||
NSString *rtfString = [[NSString alloc]
|
NSString *rtfString = [[NSString alloc]
|
||||||
initWithData: rtfData
|
initWithData: rtfData
|
||||||
encoding: NSASCIIStringEncoding];
|
encoding: NSISOLatin1StringEncoding];
|
||||||
|
|
||||||
// Reset this RFTConsumer, as it might already have been used!
|
// Reset this RFTConsumer, as it might already have been used!
|
||||||
[self reset];
|
[self reset];
|
||||||
|
@ -355,6 +371,7 @@ void GSRTFgenericRTFcommand(void *ctxt, RTFcmd cmd)
|
||||||
//Start: we're doing some initialization
|
//Start: we're doing some initialization
|
||||||
void GSRTFstart(void *ctxt)
|
void GSRTFstart(void *ctxt)
|
||||||
{
|
{
|
||||||
|
NSDebugLLog(@"RTFParser", @"Start RTF parsing");
|
||||||
[RESULT beginEditing];
|
[RESULT beginEditing];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +380,7 @@ void GSRTFstop(void *ctxt)
|
||||||
{
|
{
|
||||||
//<!> close all open bolds et al.
|
//<!> close all open bolds et al.
|
||||||
[RESULT endEditing];
|
[RESULT endEditing];
|
||||||
|
NSDebugLLog(@"RTFParser", @"End RTF parsing");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRTFopenBlock(void *ctxt, BOOL ignore)
|
void GSRTFopenBlock(void *ctxt, BOOL ignore)
|
||||||
|
@ -379,7 +397,9 @@ void GSRTFcloseBlock(void *ctxt, BOOL ignore)
|
||||||
if (ignore)
|
if (ignore)
|
||||||
IGNORE--;
|
IGNORE--;
|
||||||
if (!IGNORE)
|
if (!IGNORE)
|
||||||
[(RTFConsumer *)ctxt pop];
|
{
|
||||||
|
[(RTFConsumer *)ctxt pop];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRTFmangleText(void *ctxt, const char *text)
|
void GSRTFmangleText(void *ctxt, const char *text)
|
||||||
|
@ -544,6 +564,7 @@ void GSRTFfirstLineIndent(void *ctxt, int indent)
|
||||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||||
float findent = twips2points(indent);
|
float findent = twips2points(indent);
|
||||||
|
|
||||||
|
// FIXME: This should changed the left indent of the paragraph, if < 0
|
||||||
// for attributed strings only positiv indent is allowed
|
// for attributed strings only positiv indent is allowed
|
||||||
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
|
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
|
||||||
{
|
{
|
||||||
|
@ -580,16 +601,12 @@ void GSRTFrightIndent(void *ctxt, int indent)
|
||||||
|
|
||||||
void GSRTFtabstop(void *ctxt, int location)
|
void GSRTFtabstop(void *ctxt, int location)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
|
||||||
float flocation = twips2points(location);
|
float flocation = twips2points(location);
|
||||||
|
|
||||||
if (flocation >= 0.0))
|
if (flocation >= 0.0)
|
||||||
{
|
{
|
||||||
//[para addTab: flocation];
|
[CTXT addTab: flocation type: NSLeftTabStopType];
|
||||||
CHANGED = YES;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRTFalignCenter(void *ctxt)
|
void GSRTFalignCenter(void *ctxt)
|
||||||
|
@ -603,6 +620,17 @@ void GSRTFalignCenter(void *ctxt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSRTFalignJustified(void *ctxt)
|
||||||
|
{
|
||||||
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||||
|
|
||||||
|
if ([para alignment] != NSJustifiedTextAlignment)
|
||||||
|
{
|
||||||
|
[para setAlignment: NSJustifiedTextAlignment];
|
||||||
|
CHANGED = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GSRTFalignLeft(void *ctxt)
|
void GSRTFalignLeft(void *ctxt)
|
||||||
{
|
{
|
||||||
NSMutableParagraphStyle *para = PARAGRAPH;
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||||
|
@ -625,9 +653,39 @@ void GSRTFalignRight(void *ctxt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSRTFspaceAbove(void *ctxt, int space)
|
||||||
|
{
|
||||||
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||||
|
float fspace = twips2points(space);
|
||||||
|
|
||||||
|
if (fspace >= 0.0)
|
||||||
|
{
|
||||||
|
[para setParagraphSpacing: fspace];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSRTFlineSpace(void *ctxt, int space)
|
||||||
|
{
|
||||||
|
NSMutableParagraphStyle *para = PARAGRAPH;
|
||||||
|
float fspace = twips2points(space);
|
||||||
|
|
||||||
|
if (space == 1000)
|
||||||
|
{
|
||||||
|
[para setMinimumLineHeight: 0.0];
|
||||||
|
[para setMaximumLineHeight: 0.0];
|
||||||
|
}
|
||||||
|
else if (fspace < 0.0)
|
||||||
|
{
|
||||||
|
[para setMaximumLineHeight: -fspace];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[para setMinimumLineHeight: fspace];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GSRTFdefaultParagraph(void *ctxt)
|
void GSRTFdefaultParagraph(void *ctxt)
|
||||||
{
|
{
|
||||||
GSRTFmangleText(ctxt, "\n");
|
|
||||||
[CTXT resetParagraphStyle];
|
[CTXT resetParagraphStyle];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,6 +693,11 @@ void GSRTFstyle(void *ctxt, int style)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSRTFdefaultCharacterStyle(void *ctxt)
|
||||||
|
{
|
||||||
|
[CTXT resetFont];
|
||||||
|
}
|
||||||
|
|
||||||
void GSRTFaddColor(void *ctxt, int red, int green, int blue)
|
void GSRTFaddColor(void *ctxt, int red, int green, int blue)
|
||||||
{
|
{
|
||||||
NSColor *colour = [NSColor colorWithCalibratedRed: red/255.0
|
NSColor *colour = [NSColor colorWithCalibratedRed: red/255.0
|
||||||
|
@ -709,7 +772,11 @@ void GSRTFunderline(void *ctxt, BOOL state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSRTFparagraph(void *ctxt)
|
||||||
|
{
|
||||||
|
GSRTFmangleText(ctxt, "\n");
|
||||||
|
CTXT->tabChanged = NO;
|
||||||
|
}
|
||||||
|
|
||||||
NSAttributedString *parseRTFintoAttributedString(NSData *rtfData,
|
NSAttributedString *parseRTFintoAttributedString(NSData *rtfData,
|
||||||
NSDictionary **dict)
|
NSDictionary **dict)
|
||||||
|
|
|
@ -94,10 +94,16 @@ void GSRTFrightIndent(void *ctxt, int indent);
|
||||||
void GSRTFtabstop(void *ctxt, int location);
|
void GSRTFtabstop(void *ctxt, int location);
|
||||||
/* set center alignment */
|
/* set center alignment */
|
||||||
void GSRTFalignCenter(void *ctxt);
|
void GSRTFalignCenter(void *ctxt);
|
||||||
|
/* set justified alignment */
|
||||||
|
void GSRTFalignJustified(void *ctxt);
|
||||||
/* set left alignment */
|
/* set left alignment */
|
||||||
void GSRTFalignLeft(void *ctxt);
|
void GSRTFalignLeft(void *ctxt);
|
||||||
/* set right alignment */
|
/* set right alignment */
|
||||||
void GSRTFalignRight(void *ctxt);
|
void GSRTFalignRight(void *ctxt);
|
||||||
|
/* set space above */
|
||||||
|
void GSRTFspaceAbove(void *ctxt, int location);
|
||||||
|
/* set line space */
|
||||||
|
void GSRTFlineSpace(void *ctxt, int location);
|
||||||
/* set default paragraph style */
|
/* set default paragraph style */
|
||||||
void GSRTFdefaultParagraph(void *ctxt);
|
void GSRTFdefaultParagraph(void *ctxt);
|
||||||
/* set paragraph style */
|
/* set paragraph style */
|
||||||
|
@ -110,6 +116,8 @@ void GSRTFaddDefaultColor(void *ctxt);
|
||||||
void GSRTFcolorbg(void *ctxt, int color);
|
void GSRTFcolorbg(void *ctxt, int color);
|
||||||
/* set foreground colour */
|
/* set foreground colour */
|
||||||
void GSRTFcolorfg(void *ctxt, int color);
|
void GSRTFcolorfg(void *ctxt, int color);
|
||||||
|
/* set default character style */
|
||||||
|
void GSRTFdefaultCharacterStyle(void *ctxt);
|
||||||
/* set subscript in half points */
|
/* set subscript in half points */
|
||||||
void GSRTFsubscript(void *ctxt, int script);
|
void GSRTFsubscript(void *ctxt, int script);
|
||||||
/* set superscript in half points */
|
/* set superscript in half points */
|
||||||
|
@ -120,6 +128,8 @@ void GSRTFbold(void *ctxt, BOOL on);
|
||||||
void GSRTFitalic(void *ctxt, BOOL on);
|
void GSRTFitalic(void *ctxt, BOOL on);
|
||||||
/* Switch underline mode on or off */
|
/* Switch underline mode on or off */
|
||||||
void GSRTFunderline(void *ctxt, BOOL on);
|
void GSRTFunderline(void *ctxt, BOOL on);
|
||||||
|
/* new paragraph */
|
||||||
|
void GSRTFparagraph(void *ctxt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
typedef union {
|
typedef union {
|
||||||
int number;
|
int number;
|
||||||
const char *text;
|
const char *text;
|
||||||
RTFcmd cmd;
|
RTFcmd cmd;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
|
@ -33,47 +33,62 @@ typedef
|
||||||
#define RTFheader 268
|
#define RTFheader 268
|
||||||
#define RTFfooter 269
|
#define RTFfooter 269
|
||||||
#define RTFpict 270
|
#define RTFpict 270
|
||||||
#define RTFred 271
|
#define RTFplain 271
|
||||||
#define RTFgreen 272
|
#define RTFparagraph 272
|
||||||
#define RTFblue 273
|
#define RTFdefaultParagraph 273
|
||||||
#define RTFcolorbg 274
|
#define RTFrow 274
|
||||||
#define RTFcolorfg 275
|
#define RTFcell 275
|
||||||
#define RTFcolortable 276
|
#define RTFtabulator 276
|
||||||
#define RTFfont 277
|
#define RTFemdash 277
|
||||||
#define RTFfontSize 278
|
#define RTFendash 278
|
||||||
#define RTFpaperWidth 279
|
#define RTFemspace 279
|
||||||
#define RTFpaperHeight 280
|
#define RTFenspace 280
|
||||||
#define RTFmarginLeft 281
|
#define RTFbullet 281
|
||||||
#define RTFmarginRight 282
|
#define RTFlquote 282
|
||||||
#define RTFmarginTop 283
|
#define RTFrquote 283
|
||||||
#define RTFmarginButtom 284
|
#define RTFldblquote 284
|
||||||
#define RTFfirstLineIndent 285
|
#define RTFrdblquote 285
|
||||||
#define RTFleftIndent 286
|
#define RTFred 286
|
||||||
#define RTFrightIndent 287
|
#define RTFgreen 287
|
||||||
#define RTFalignCenter 288
|
#define RTFblue 288
|
||||||
#define RTFalignLeft 289
|
#define RTFcolorbg 289
|
||||||
#define RTFalignRight 290
|
#define RTFcolorfg 290
|
||||||
#define RTFstyle 291
|
#define RTFcolortable 291
|
||||||
#define RTFbold 292
|
#define RTFfont 292
|
||||||
#define RTFitalic 293
|
#define RTFfontSize 293
|
||||||
#define RTFunderline 294
|
#define RTFpaperWidth 294
|
||||||
#define RTFunderlineStop 295
|
#define RTFpaperHeight 295
|
||||||
#define RTFsubscript 296
|
#define RTFmarginLeft 296
|
||||||
#define RTFsuperscript 297
|
#define RTFmarginRight 297
|
||||||
#define RTFtabulator 298
|
#define RTFmarginTop 298
|
||||||
#define RTFtabstop 299
|
#define RTFmarginButtom 299
|
||||||
#define RTFparagraph 300
|
#define RTFfirstLineIndent 300
|
||||||
#define RTFdefaultParagraph 301
|
#define RTFleftIndent 301
|
||||||
#define RTFfcharset 302
|
#define RTFrightIndent 302
|
||||||
#define RTFfprq 303
|
#define RTFalignCenter 303
|
||||||
#define RTFcpg 304
|
#define RTFalignJustified 304
|
||||||
#define RTFOtherStatement 305
|
#define RTFalignLeft 305
|
||||||
#define RTFfontListStart 306
|
#define RTFalignRight 306
|
||||||
#define RTFfamilyNil 307
|
#define RTFlineSpace 307
|
||||||
#define RTFfamilyRoman 308
|
#define RTFspaceAbove 308
|
||||||
#define RTFfamilySwiss 309
|
#define RTFstyle 309
|
||||||
#define RTFfamilyModern 310
|
#define RTFbold 310
|
||||||
#define RTFfamilyScript 311
|
#define RTFitalic 311
|
||||||
#define RTFfamilyDecor 312
|
#define RTFunderline 312
|
||||||
#define RTFfamilyTech 313
|
#define RTFunderlineStop 313
|
||||||
|
#define RTFsubscript 314
|
||||||
|
#define RTFsuperscript 315
|
||||||
|
#define RTFtabstop 316
|
||||||
|
#define RTFfcharset 317
|
||||||
|
#define RTFfprq 318
|
||||||
|
#define RTFcpg 319
|
||||||
|
#define RTFOtherStatement 320
|
||||||
|
#define RTFfontListStart 321
|
||||||
|
#define RTFfamilyNil 322
|
||||||
|
#define RTFfamilyRoman 323
|
||||||
|
#define RTFfamilySwiss 324
|
||||||
|
#define RTFfamilyModern 325
|
||||||
|
#define RTFfamilyScript 326
|
||||||
|
#define RTFfamilyDecor 327
|
||||||
|
#define RTFfamilyTech 328
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ typedef void * GSRTFctxt;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
int number;
|
int number;
|
||||||
const char *text;
|
const char *text;
|
||||||
RTFcmd cmd;
|
RTFcmd cmd;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,21 @@ typedef void * GSRTFctxt;
|
||||||
%token RTFheader
|
%token RTFheader
|
||||||
%token RTFfooter
|
%token RTFfooter
|
||||||
%token RTFpict
|
%token RTFpict
|
||||||
|
%token RTFplain
|
||||||
|
%token RTFparagraph
|
||||||
|
%token RTFdefaultParagraph
|
||||||
|
%token RTFrow
|
||||||
|
%token RTFcell
|
||||||
|
%token RTFtabulator
|
||||||
|
%token RTFemdash
|
||||||
|
%token RTFendash
|
||||||
|
%token RTFemspace
|
||||||
|
%token RTFenspace
|
||||||
|
%token RTFbullet
|
||||||
|
%token RTFlquote
|
||||||
|
%token RTFrquote
|
||||||
|
%token RTFldblquote
|
||||||
|
%token RTFrdblquote
|
||||||
%token <cmd> RTFred
|
%token <cmd> RTFred
|
||||||
%token <cmd> RTFgreen
|
%token <cmd> RTFgreen
|
||||||
%token <cmd> RTFblue
|
%token <cmd> RTFblue
|
||||||
|
@ -105,8 +120,11 @@ typedef void * GSRTFctxt;
|
||||||
%token <cmd> RTFleftIndent
|
%token <cmd> RTFleftIndent
|
||||||
%token <cmd> RTFrightIndent
|
%token <cmd> RTFrightIndent
|
||||||
%token <cmd> RTFalignCenter
|
%token <cmd> RTFalignCenter
|
||||||
|
%token <cmd> RTFalignJustified
|
||||||
%token <cmd> RTFalignLeft
|
%token <cmd> RTFalignLeft
|
||||||
%token <cmd> RTFalignRight
|
%token <cmd> RTFalignRight
|
||||||
|
%token <cmd> RTFlineSpace
|
||||||
|
%token <cmd> RTFspaceAbove
|
||||||
%token <cmd> RTFstyle
|
%token <cmd> RTFstyle
|
||||||
%token <cmd> RTFbold
|
%token <cmd> RTFbold
|
||||||
%token <cmd> RTFitalic
|
%token <cmd> RTFitalic
|
||||||
|
@ -114,10 +132,7 @@ typedef void * GSRTFctxt;
|
||||||
%token <cmd> RTFunderlineStop
|
%token <cmd> RTFunderlineStop
|
||||||
%token <cmd> RTFsubscript
|
%token <cmd> RTFsubscript
|
||||||
%token <cmd> RTFsuperscript
|
%token <cmd> RTFsuperscript
|
||||||
%token <cmd> RTFtabulator
|
|
||||||
%token <cmd> RTFtabstop
|
%token <cmd> RTFtabstop
|
||||||
%token <cmd> RTFparagraph
|
|
||||||
%token <cmd> RTFdefaultParagraph
|
|
||||||
%token <cmd> RTFfcharset
|
%token <cmd> RTFfcharset
|
||||||
%token <cmd> RTFfprq
|
%token <cmd> RTFfprq
|
||||||
%token <cmd> RTFcpg
|
%token <cmd> RTFcpg
|
||||||
|
@ -259,8 +274,17 @@ rtfStatement: RTFfont { int font;
|
||||||
location = $1.parameter;
|
location = $1.parameter;
|
||||||
GSRTFtabstop(ctxt, location);}
|
GSRTFtabstop(ctxt, location);}
|
||||||
| RTFalignCenter { GSRTFalignCenter(ctxt); }
|
| RTFalignCenter { GSRTFalignCenter(ctxt); }
|
||||||
|
| RTFalignJustified { GSRTFalignJustified(ctxt); }
|
||||||
| RTFalignLeft { GSRTFalignLeft(ctxt); }
|
| RTFalignLeft { GSRTFalignLeft(ctxt); }
|
||||||
| RTFalignRight { GSRTFalignRight(ctxt); }
|
| RTFalignRight { GSRTFalignRight(ctxt); }
|
||||||
|
| RTFspaceAbove { int space;
|
||||||
|
|
||||||
|
if ($1.isEmpty)
|
||||||
|
space = 0;
|
||||||
|
else
|
||||||
|
space = $1.parameter;
|
||||||
|
GSRTFspaceAbove(ctxt, space); }
|
||||||
|
| RTFlineSpace { GSRTFlineSpace(ctxt, $1.parameter); }
|
||||||
| RTFdefaultParagraph { GSRTFdefaultParagraph(ctxt); }
|
| RTFdefaultParagraph { GSRTFdefaultParagraph(ctxt); }
|
||||||
| RTFstyle { GSRTFstyle(ctxt, $1.parameter); }
|
| RTFstyle { GSRTFstyle(ctxt, $1.parameter); }
|
||||||
| RTFcolorbg { int color;
|
| RTFcolorbg { int color;
|
||||||
|
@ -313,6 +337,9 @@ rtfStatement: RTFfont { int font;
|
||||||
on = NO;
|
on = NO;
|
||||||
GSRTFunderline(ctxt, on); }
|
GSRTFunderline(ctxt, on); }
|
||||||
| RTFunderlineStop { GSRTFunderline(ctxt, NO); }
|
| RTFunderlineStop { GSRTFunderline(ctxt, NO); }
|
||||||
|
| RTFplain { GSRTFdefaultCharacterStyle(ctxt); }
|
||||||
|
| RTFparagraph { GSRTFparagraph(ctxt); }
|
||||||
|
| RTFrow { GSRTFparagraph(ctxt); }
|
||||||
| RTFOtherStatement { GSRTFgenericRTFcommand(ctxt, $1); }
|
| RTFOtherStatement { GSRTFgenericRTFcommand(ctxt, $1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -355,7 +382,7 @@ rtfFontFamily:
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Font description end
|
Colour definition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rtfColorDef: '{' RTFcolortable rtfColors '}'
|
rtfColorDef: '{' RTFcolortable rtfColors '}'
|
||||||
|
|
|
@ -144,11 +144,17 @@ LexKeyword RTFcommands[]={
|
||||||
"ansi", token(RTFansi),
|
"ansi", token(RTFansi),
|
||||||
"b", token(RTFbold),
|
"b", token(RTFbold),
|
||||||
"blue", token(RTFblue),
|
"blue", token(RTFblue),
|
||||||
|
"bullet", token(RTFbullet),
|
||||||
"cb", token(RTFcolorbg),
|
"cb", token(RTFcolorbg),
|
||||||
|
"cell", token(RTFcell),
|
||||||
"cf", token(RTFcolorfg),
|
"cf", token(RTFcolorfg),
|
||||||
"colortbl", token(RTFcolortable),
|
"colortbl", token(RTFcolortable),
|
||||||
"cpg", token(RTFcpg),
|
"cpg", token(RTFcpg),
|
||||||
"dn", token(RTFsubscript),
|
"dn", token(RTFsubscript),
|
||||||
|
"emdash", token(RTFemdash),
|
||||||
|
"emspace", token(RTFemspace),
|
||||||
|
"endash", token(RTFendash),
|
||||||
|
"enspace", token(RTFenspace),
|
||||||
"f", token(RTFfont),
|
"f", token(RTFfont),
|
||||||
"fcharset", token(RTFfcharset),
|
"fcharset", token(RTFfcharset),
|
||||||
"fdecor", token(RTFfamilyDecor),
|
"fdecor", token(RTFfamilyDecor),
|
||||||
|
@ -156,7 +162,11 @@ LexKeyword RTFcommands[]={
|
||||||
"fmodern", token(RTFfamilyModern),
|
"fmodern", token(RTFfamilyModern),
|
||||||
"fnil", token(RTFfamilyNil),
|
"fnil", token(RTFfamilyNil),
|
||||||
"fonttbl", token(RTFfontListStart),
|
"fonttbl", token(RTFfontListStart),
|
||||||
|
/* All footers are mapped on one entry */
|
||||||
"footer", token(RTFfooter),
|
"footer", token(RTFfooter),
|
||||||
|
"footerf", token(RTFfooter),
|
||||||
|
"footerl", token(RTFfooter),
|
||||||
|
"footerr", token(RTFfooter),
|
||||||
"footnote", token(RTFfootnote),
|
"footnote", token(RTFfootnote),
|
||||||
"fprq", token(RTFfprq),
|
"fprq", token(RTFfprq),
|
||||||
"froman", token(RTFfamilyRoman),
|
"froman", token(RTFfamilyRoman),
|
||||||
|
@ -165,10 +175,16 @@ LexKeyword RTFcommands[]={
|
||||||
"fswiss", token(RTFfamilySwiss),
|
"fswiss", token(RTFfamilySwiss),
|
||||||
"ftech", token(RTFfamilyTech),
|
"ftech", token(RTFfamilyTech),
|
||||||
"green", token(RTFgreen),
|
"green", token(RTFgreen),
|
||||||
|
/* All headers are mapped on one entry */
|
||||||
"header", token(RTFheader),
|
"header", token(RTFheader),
|
||||||
|
"headerf", token(RTFheader),
|
||||||
|
"headerl", token(RTFheader),
|
||||||
|
"headerr", token(RTFheader),
|
||||||
"i", token(RTFitalic),
|
"i", token(RTFitalic),
|
||||||
"info", token(RTFinfo),
|
"info", token(RTFinfo),
|
||||||
|
"ldblquote", token(RTFldblquote),
|
||||||
"li", token(RTFleftIndent),
|
"li", token(RTFleftIndent),
|
||||||
|
"lquote", token(RTFlquote),
|
||||||
"mac", token(RTFmac),
|
"mac", token(RTFmac),
|
||||||
"margb", token(RTFmarginButtom),
|
"margb", token(RTFmarginButtom),
|
||||||
"margl", token(RTFmarginLeft),
|
"margl", token(RTFmarginLeft),
|
||||||
|
@ -181,18 +197,29 @@ LexKeyword RTFcommands[]={
|
||||||
"pc", token(RTFpc),
|
"pc", token(RTFpc),
|
||||||
"pca", token(RTFpca),
|
"pca", token(RTFpca),
|
||||||
"pict", token(RTFpict),
|
"pict", token(RTFpict),
|
||||||
|
"plain", token(RTFplain),
|
||||||
"qc", token(RTFalignCenter),
|
"qc", token(RTFalignCenter),
|
||||||
|
"qj", token(RTFalignJustified),
|
||||||
"ql", token(RTFalignLeft),
|
"ql", token(RTFalignLeft),
|
||||||
"qr", token(RTFalignRight),
|
"qr", token(RTFalignRight),
|
||||||
|
"rdblquote", token(RTFrdblquote),
|
||||||
"red", token(RTFred),
|
"red", token(RTFred),
|
||||||
"ri", token(RTFrightIndent),
|
"ri", token(RTFrightIndent),
|
||||||
|
"row", token(RTFrow),
|
||||||
|
"rquote", token(RTFrquote),
|
||||||
"rtf", token(RTFstart),
|
"rtf", token(RTFstart),
|
||||||
"s", token(RTFstyle),
|
"s", token(RTFstyle),
|
||||||
|
"sa", token(RTFspaceAbove),
|
||||||
|
"sl", token(RTFlineSpace),
|
||||||
"stylesheet", token(RTFstylesheet),
|
"stylesheet", token(RTFstylesheet),
|
||||||
"tab", token(RTFtabulator),
|
"tab", token(RTFtabulator),
|
||||||
"tx", token(RTFtabstop),
|
"tx", token(RTFtabstop),
|
||||||
|
/* All underline are mapped on one entry */
|
||||||
"ul", token(RTFunderline),
|
"ul", token(RTFunderline),
|
||||||
|
"uld", token(RTFunderline),
|
||||||
|
"uldb", token(RTFunderline),
|
||||||
"ulnone", token(RTFunderlineStop),
|
"ulnone", token(RTFunderlineStop),
|
||||||
|
"ulw", token(RTFunderline),
|
||||||
"up", token(RTFsuperscript)
|
"up", token(RTFsuperscript)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -341,20 +368,29 @@ int GSRTFlex(YYSTYPE *lvalp, YYLTYPE *llocp, RTFscannerCtxt *lctxt) /* provide v
|
||||||
if (probeCommand(lctxt) == YES)
|
if (probeCommand(lctxt) == YES)
|
||||||
{
|
{
|
||||||
readCommand(lctxt, lvalp, &token);
|
readCommand(lctxt, lvalp, &token);
|
||||||
if (token == RTFparagraph)
|
switch (token)
|
||||||
{
|
{
|
||||||
// release is up to the consumer
|
case RTFtabulator: c = '\t';
|
||||||
cv = calloc(1, 2);
|
break;
|
||||||
cv[0] = '\n';
|
case RTFcell: c = '\t';
|
||||||
cv[1] = '\0';
|
break;
|
||||||
lvalp->text = cv;
|
case RTFemdash: c = '-';
|
||||||
token = RTFtext;
|
break;
|
||||||
return token;
|
case RTFendash: c = '-';
|
||||||
}
|
break;
|
||||||
else if (token == RTFtabulator)
|
case RTFbullet: c = '*';
|
||||||
c = '\t';
|
break;
|
||||||
else
|
case RTFlquote: c = '`';
|
||||||
break;
|
break;
|
||||||
|
case RTFrquote: c = '\'';
|
||||||
|
break;
|
||||||
|
case RTFldblquote: c = '"';
|
||||||
|
break;
|
||||||
|
case RTFrdblquote: c = '"';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return token;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -380,33 +416,13 @@ int GSRTFlex(YYSTYPE *lvalp, YYLTYPE *llocp, RTFscannerCtxt *lctxt) /* provide v
|
||||||
break;
|
break;
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
// release is up to the consumer
|
return RTFparagraph;
|
||||||
cv = calloc(1, 2);
|
|
||||||
cv[0] = '\n';
|
|
||||||
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;
|
|
||||||
case '\\':
|
case '\\':
|
||||||
// release is up to the consumer
|
// release is up to the consumer
|
||||||
cv = calloc(1, 2);
|
cv = calloc(1, 2);
|
||||||
cv[0] = '\\';
|
cv[0] = c;
|
||||||
cv[1] = '\0';
|
cv[1] = '\0';
|
||||||
lvalp->text = cv;
|
lvalp->text = cv;
|
||||||
token = RTFtext;
|
token = RTFtext;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue