Misc. minor rtf-parsing fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15951 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-13 00:16:12 +00:00
parent 77950b1e66
commit e729e8815b
5 changed files with 1457 additions and 1072 deletions

View file

@ -1,3 +1,16 @@
2003-02-13 01:01 Alexander Malmberg <alexander@malmberg.org>
* TextConverters/RTF/rtfGrammer.y (rtfCharset): Treat unknown
character sets as ANSI.
TextConverters/RTF/rtfGrammer.tab.c,
TextConverters/RTF/rtfGrammer.tab.h: Regenerate.
* TextConverters/RTF/RTFConsumer.m: Fix handling of the indentation
control words: \fi, \li, and \ri.
(GSRTFmangleText): Set the paragraph style attribute to a copy of
the working NSMutableParagraphStyle so later changes won't affect
the attributes of this text.
2003-02-13 00:52 Alexander Malmberg <alexander@malmberg.org>
* Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:):

View file

@ -68,6 +68,8 @@ readNSString (StringContext *ctxt)
BOOL italic;
BOOL underline;
int script;
float real_fi, real_li;
}
- (NSFont*) currentFont;
@ -189,6 +191,7 @@ readNSString (StringContext *ctxt)
- (void) resetParagraphStyle
{
ASSIGN(paragraph, [NSMutableParagraphStyle defaultParagraphStyle]);
real_fi = real_li = 0.0;
tabChanged = NO;
changed = YES;
@ -583,7 +586,7 @@ void GSRTFmangleText (void *ctxt, const char *text)
attributes = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
[CTXT currentFont], NSFontAttributeName,
PARAGRAPH, NSParagraphStyleAttributeName,
[[PARAGRAPH copy] autorelease], NSParagraphStyleAttributeName,
nil];
if (UNDERLINE)
{
@ -749,7 +752,10 @@ void GSRTFfirstLineIndent (void *ctxt, int indent)
NSMutableParagraphStyle *para = PARAGRAPH;
float findent = twips2points(indent);
// FIXME: This should changed the left indent of the paragraph, if < 0
CTXT->real_fi = findent;
findent = CTXT->real_li + CTXT->real_fi;
// for attributed strings only positiv indent is allowed
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
{
@ -763,12 +769,21 @@ void GSRTFleftIndent (void *ctxt, int indent)
NSMutableParagraphStyle *para = PARAGRAPH;
float findent = twips2points(indent);
CTXT->real_li = findent;
// for attributed strings only positiv indent is allowed
if ((findent >= 0.0) && ([para headIndent] != findent))
{
[para setHeadIndent: findent];
CHANGED = YES;
}
findent = CTXT->real_li + CTXT->real_fi;
if ((findent >= 0.0) && ([para firstLineHeadIndent] != findent))
{
[para setFirstLineHeadIndent: findent];
CHANGED = YES;
}
}
void GSRTFrightIndent (void *ctxt, int indent)
@ -779,7 +794,7 @@ void GSRTFrightIndent (void *ctxt, int indent)
// for attributed strings only positiv indent is allowed
if ((findent >= 0.0) && ([para tailIndent] != findent))
{
[para setTailIndent: findent];
[para setTailIndent: -findent];
CHANGED = YES;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,86 +1,197 @@
#ifndef BISON_RTFGRAMMER_TAB_H
# define BISON_RTFGRAMMER_TAB_H
/* A Bison parser, made by GNU Bison 1.875. */
#ifndef YYSTYPE
typedef union {
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
RTFtext = 258,
RTFstart = 259,
RTFansi = 260,
RTFmac = 261,
RTFpc = 262,
RTFpca = 263,
RTFignore = 264,
RTFinfo = 265,
RTFstylesheet = 266,
RTFfootnote = 267,
RTFheader = 268,
RTFfooter = 269,
RTFpict = 270,
RTFplain = 271,
RTFparagraph = 272,
RTFdefaultParagraph = 273,
RTFrow = 274,
RTFcell = 275,
RTFtabulator = 276,
RTFemdash = 277,
RTFendash = 278,
RTFemspace = 279,
RTFenspace = 280,
RTFbullet = 281,
RTFlquote = 282,
RTFrquote = 283,
RTFldblquote = 284,
RTFrdblquote = 285,
RTFred = 286,
RTFgreen = 287,
RTFblue = 288,
RTFcolorbg = 289,
RTFcolorfg = 290,
RTFcolortable = 291,
RTFfont = 292,
RTFfontSize = 293,
RTFpaperWidth = 294,
RTFpaperHeight = 295,
RTFmarginLeft = 296,
RTFmarginRight = 297,
RTFmarginTop = 298,
RTFmarginButtom = 299,
RTFfirstLineIndent = 300,
RTFleftIndent = 301,
RTFrightIndent = 302,
RTFalignCenter = 303,
RTFalignJustified = 304,
RTFalignLeft = 305,
RTFalignRight = 306,
RTFlineSpace = 307,
RTFspaceAbove = 308,
RTFstyle = 309,
RTFbold = 310,
RTFitalic = 311,
RTFunderline = 312,
RTFunderlineStop = 313,
RTFsubscript = 314,
RTFsuperscript = 315,
RTFtabstop = 316,
RTFfcharset = 317,
RTFfprq = 318,
RTFcpg = 319,
RTFOtherStatement = 320,
RTFfontListStart = 321,
RTFfamilyNil = 322,
RTFfamilyRoman = 323,
RTFfamilySwiss = 324,
RTFfamilyModern = 325,
RTFfamilyScript = 326,
RTFfamilyDecor = 327,
RTFfamilyTech = 328
};
#endif
#define RTFtext 258
#define RTFstart 259
#define RTFansi 260
#define RTFmac 261
#define RTFpc 262
#define RTFpca 263
#define RTFignore 264
#define RTFinfo 265
#define RTFstylesheet 266
#define RTFfootnote 267
#define RTFheader 268
#define RTFfooter 269
#define RTFpict 270
#define RTFplain 271
#define RTFparagraph 272
#define RTFdefaultParagraph 273
#define RTFrow 274
#define RTFcell 275
#define RTFtabulator 276
#define RTFemdash 277
#define RTFendash 278
#define RTFemspace 279
#define RTFenspace 280
#define RTFbullet 281
#define RTFlquote 282
#define RTFrquote 283
#define RTFldblquote 284
#define RTFrdblquote 285
#define RTFred 286
#define RTFgreen 287
#define RTFblue 288
#define RTFcolorbg 289
#define RTFcolorfg 290
#define RTFcolortable 291
#define RTFfont 292
#define RTFfontSize 293
#define RTFpaperWidth 294
#define RTFpaperHeight 295
#define RTFmarginLeft 296
#define RTFmarginRight 297
#define RTFmarginTop 298
#define RTFmarginButtom 299
#define RTFfirstLineIndent 300
#define RTFleftIndent 301
#define RTFrightIndent 302
#define RTFalignCenter 303
#define RTFalignJustified 304
#define RTFalignLeft 305
#define RTFalignRight 306
#define RTFlineSpace 307
#define RTFspaceAbove 308
#define RTFstyle 309
#define RTFbold 310
#define RTFitalic 311
#define RTFunderline 312
#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
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 77 "rtfGrammer.y"
typedef union YYSTYPE {
int number;
const char *text;
RTFcmd cmd;
} yystype;
# define YYSTYPE yystype
} YYSTYPE;
/* Line 1248 of yacc.c. */
#line 188 "rtfGrammer.tab.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
# define RTFtext 257
# define RTFstart 258
# define RTFansi 259
# define RTFmac 260
# define RTFpc 261
# define RTFpca 262
# define RTFignore 263
# define RTFinfo 264
# define RTFstylesheet 265
# define RTFfootnote 266
# define RTFheader 267
# define RTFfooter 268
# define RTFpict 269
# define RTFplain 270
# define RTFparagraph 271
# define RTFdefaultParagraph 272
# define RTFrow 273
# define RTFcell 274
# define RTFtabulator 275
# define RTFemdash 276
# define RTFendash 277
# define RTFemspace 278
# define RTFenspace 279
# define RTFbullet 280
# define RTFlquote 281
# define RTFrquote 282
# define RTFldblquote 283
# define RTFrdblquote 284
# define RTFred 285
# define RTFgreen 286
# define RTFblue 287
# define RTFcolorbg 288
# define RTFcolorfg 289
# define RTFcolortable 290
# define RTFfont 291
# define RTFfontSize 292
# define RTFpaperWidth 293
# define RTFpaperHeight 294
# define RTFmarginLeft 295
# define RTFmarginRight 296
# define RTFmarginTop 297
# define RTFmarginButtom 298
# define RTFfirstLineIndent 299
# define RTFleftIndent 300
# define RTFrightIndent 301
# define RTFalignCenter 302
# define RTFalignJustified 303
# define RTFalignLeft 304
# define RTFalignRight 305
# define RTFlineSpace 306
# define RTFspaceAbove 307
# define RTFstyle 308
# define RTFbold 309
# define RTFitalic 310
# define RTFunderline 311
# define RTFunderlineStop 312
# define RTFsubscript 313
# define RTFsuperscript 314
# define RTFtabstop 315
# define RTFfcharset 316
# define RTFfprq 317
# define RTFcpg 318
# define RTFOtherStatement 319
# define RTFfontListStart 320
# define RTFfamilyNil 321
# define RTFfamilyRoman 322
# define RTFfamilySwiss 323
# define RTFfamilyModern 324
# define RTFfamilyScript 325
# define RTFfamilyDecor 326
# define RTFfamilyTech 327
#endif /* not BISON_RTFGRAMMER_TAB_H */

View file

@ -170,6 +170,8 @@ rtfCharset: RTFansi { $$ = 1; }
| RTFmac { $$ = 2; }
| RTFpc { $$ = 3; }
| RTFpca { $$ = 4; }
/* If it's an unknown character set, assume ansi. */
| RTFOtherStatement { $$ = 1; }
;
rtfIngredients: /* empty */