Add code to handle code page 10000 in RTF.

This commit is contained in:
fredkiefer 2020-05-29 15:18:37 +02:00
parent 385fb7d204
commit d9134d657f
5 changed files with 628 additions and 683 deletions

View file

@ -1,3 +1,10 @@
2020-05-29 Fred Kiefer <FredKiefer@gmx.de>
* TextConverters/RTF/rtfGrammar.y: Correct encoding handling.
* TextConverters/RTF/rtfGrammar.tab.h,
* TextConverters/RTF/rtfGrammar.tab.m: Regenerated.
* TextConverters/RTF/RTFConsumer.m: Add code to handle code page 10000.
2020-05-18 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSColor.h,

View file

@ -1393,16 +1393,20 @@ void GSRTFencoding(void *ctxt, int encoding)
{
switch (encoding)
{
// ansi
case 1:
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
break;
// mac
case 2:
[(RTFDConsumer *)ctxt setEncoding: NSMacOSRomanStringEncoding];
break;
// pc
case 3:
// FIXME: Code page 437 kCFStringEncodingDOSLatinUS
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
break;
// pca
case 4:
// FIXME: Code page 850 kCFStringEncodingDOSLatin1
[(RTFDConsumer *)ctxt setEncoding: NSISOLatin1StringEncoding];
@ -1422,6 +1426,9 @@ void GSRTFencoding(void *ctxt, int encoding)
case 1254:
[(RTFDConsumer *)ctxt setEncoding: NSWindowsCP1254StringEncoding];
break;
case 10000:
[(RTFDConsumer *)ctxt setEncoding: NSMacOSRomanStringEncoding];
break;
default:
NSLog(@"Setting unknown encoding %d", encoding);
break;

View file

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.5. */
/* A Bison parser, made by GNU Bison 3.6.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@ -31,8 +31,9 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_GSRTF_RTFGRAMMAR_TAB_H_INCLUDED
# define YY_GSRTF_RTFGRAMMAR_TAB_H_INCLUDED
@ -44,118 +45,123 @@
extern int GSRTFdebug;
#endif
/* Token type. */
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
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,
RTFfield = 282,
RTFfldinst = 283,
RTFfldalt = 284,
RTFfldrslt = 285,
RTFflddirty = 286,
RTFfldedit = 287,
RTFfldlock = 288,
RTFfldpriv = 289,
RTFfttruetype = 290,
RTFlquote = 291,
RTFrquote = 292,
RTFldblquote = 293,
RTFrdblquote = 294,
RTFred = 295,
RTFgreen = 296,
RTFblue = 297,
RTFcolorbg = 298,
RTFcolorfg = 299,
RTFunderlinecolor = 300,
RTFcolortable = 301,
RTFfont = 302,
RTFfontSize = 303,
RTFNeXTGraphic = 304,
RTFNeXTGraphicWidth = 305,
RTFNeXTGraphicHeight = 306,
RTFNeXTHelpLink = 307,
RTFNeXTHelpMarker = 308,
RTFNeXTfilename = 309,
RTFNeXTmarkername = 310,
RTFNeXTlinkFilename = 311,
RTFNeXTlinkMarkername = 312,
RTFpaperWidth = 313,
RTFpaperHeight = 314,
RTFmarginLeft = 315,
RTFmarginRight = 316,
RTFmarginTop = 317,
RTFmarginButtom = 318,
RTFfirstLineIndent = 319,
RTFleftIndent = 320,
RTFrightIndent = 321,
RTFalignCenter = 322,
RTFalignJustified = 323,
RTFalignLeft = 324,
RTFalignRight = 325,
RTFlineSpace = 326,
RTFspaceAbove = 327,
RTFstyle = 328,
RTFbold = 329,
RTFitalic = 330,
RTFunderline = 331,
RTFunderlineDot = 332,
RTFunderlineDash = 333,
RTFunderlineDashDot = 334,
RTFunderlineDashDotDot = 335,
RTFunderlineDouble = 336,
RTFunderlineStop = 337,
RTFunderlineThick = 338,
RTFunderlineThickDot = 339,
RTFunderlineThickDash = 340,
RTFunderlineThickDashDot = 341,
RTFunderlineThickDashDotDot = 342,
RTFunderlineWord = 343,
RTFstrikethrough = 344,
RTFstrikethroughDouble = 345,
RTFunichar = 346,
RTFsubscript = 347,
RTFsuperscript = 348,
RTFtabstop = 349,
RTFfcharset = 350,
RTFfprq = 351,
RTFcpg = 352,
RTFansicpg = 353,
RTFOtherStatement = 354,
RTFfontListStart = 355,
RTFfamilyNil = 356,
RTFfamilyRoman = 357,
RTFfamilySwiss = 358,
RTFfamilyModern = 359,
RTFfamilyScript = 360,
RTFfamilyDecor = 361,
RTFfamilyTech = 362,
RTFfamilyBiDi = 363
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
RTFtext = 258, /* RTFtext */
RTFstart = 259, /* RTFstart */
RTFansi = 260, /* RTFansi */
RTFmac = 261, /* RTFmac */
RTFpc = 262, /* RTFpc */
RTFpca = 263, /* RTFpca */
RTFignore = 264, /* RTFignore */
RTFinfo = 265, /* RTFinfo */
RTFstylesheet = 266, /* RTFstylesheet */
RTFfootnote = 267, /* RTFfootnote */
RTFheader = 268, /* RTFheader */
RTFfooter = 269, /* RTFfooter */
RTFpict = 270, /* RTFpict */
RTFplain = 271, /* RTFplain */
RTFparagraph = 272, /* RTFparagraph */
RTFdefaultParagraph = 273, /* RTFdefaultParagraph */
RTFrow = 274, /* RTFrow */
RTFcell = 275, /* RTFcell */
RTFtabulator = 276, /* RTFtabulator */
RTFemdash = 277, /* RTFemdash */
RTFendash = 278, /* RTFendash */
RTFemspace = 279, /* RTFemspace */
RTFenspace = 280, /* RTFenspace */
RTFbullet = 281, /* RTFbullet */
RTFfield = 282, /* RTFfield */
RTFfldinst = 283, /* RTFfldinst */
RTFfldalt = 284, /* RTFfldalt */
RTFfldrslt = 285, /* RTFfldrslt */
RTFflddirty = 286, /* RTFflddirty */
RTFfldedit = 287, /* RTFfldedit */
RTFfldlock = 288, /* RTFfldlock */
RTFfldpriv = 289, /* RTFfldpriv */
RTFfttruetype = 290, /* RTFfttruetype */
RTFlquote = 291, /* RTFlquote */
RTFrquote = 292, /* RTFrquote */
RTFldblquote = 293, /* RTFldblquote */
RTFrdblquote = 294, /* RTFrdblquote */
RTFred = 295, /* RTFred */
RTFgreen = 296, /* RTFgreen */
RTFblue = 297, /* RTFblue */
RTFcolorbg = 298, /* RTFcolorbg */
RTFcolorfg = 299, /* RTFcolorfg */
RTFunderlinecolor = 300, /* RTFunderlinecolor */
RTFcolortable = 301, /* RTFcolortable */
RTFfont = 302, /* RTFfont */
RTFfontSize = 303, /* RTFfontSize */
RTFNeXTGraphic = 304, /* RTFNeXTGraphic */
RTFNeXTGraphicWidth = 305, /* RTFNeXTGraphicWidth */
RTFNeXTGraphicHeight = 306, /* RTFNeXTGraphicHeight */
RTFNeXTHelpLink = 307, /* RTFNeXTHelpLink */
RTFNeXTHelpMarker = 308, /* RTFNeXTHelpMarker */
RTFNeXTfilename = 309, /* RTFNeXTfilename */
RTFNeXTmarkername = 310, /* RTFNeXTmarkername */
RTFNeXTlinkFilename = 311, /* RTFNeXTlinkFilename */
RTFNeXTlinkMarkername = 312, /* RTFNeXTlinkMarkername */
RTFpaperWidth = 313, /* RTFpaperWidth */
RTFpaperHeight = 314, /* RTFpaperHeight */
RTFmarginLeft = 315, /* RTFmarginLeft */
RTFmarginRight = 316, /* RTFmarginRight */
RTFmarginTop = 317, /* RTFmarginTop */
RTFmarginButtom = 318, /* RTFmarginButtom */
RTFfirstLineIndent = 319, /* RTFfirstLineIndent */
RTFleftIndent = 320, /* RTFleftIndent */
RTFrightIndent = 321, /* RTFrightIndent */
RTFalignCenter = 322, /* RTFalignCenter */
RTFalignJustified = 323, /* RTFalignJustified */
RTFalignLeft = 324, /* RTFalignLeft */
RTFalignRight = 325, /* RTFalignRight */
RTFlineSpace = 326, /* RTFlineSpace */
RTFspaceAbove = 327, /* RTFspaceAbove */
RTFstyle = 328, /* RTFstyle */
RTFbold = 329, /* RTFbold */
RTFitalic = 330, /* RTFitalic */
RTFunderline = 331, /* RTFunderline */
RTFunderlineDot = 332, /* RTFunderlineDot */
RTFunderlineDash = 333, /* RTFunderlineDash */
RTFunderlineDashDot = 334, /* RTFunderlineDashDot */
RTFunderlineDashDotDot = 335, /* RTFunderlineDashDotDot */
RTFunderlineDouble = 336, /* RTFunderlineDouble */
RTFunderlineStop = 337, /* RTFunderlineStop */
RTFunderlineThick = 338, /* RTFunderlineThick */
RTFunderlineThickDot = 339, /* RTFunderlineThickDot */
RTFunderlineThickDash = 340, /* RTFunderlineThickDash */
RTFunderlineThickDashDot = 341, /* RTFunderlineThickDashDot */
RTFunderlineThickDashDotDot = 342, /* RTFunderlineThickDashDotDot */
RTFunderlineWord = 343, /* RTFunderlineWord */
RTFstrikethrough = 344, /* RTFstrikethrough */
RTFstrikethroughDouble = 345, /* RTFstrikethroughDouble */
RTFunichar = 346, /* RTFunichar */
RTFsubscript = 347, /* RTFsubscript */
RTFsuperscript = 348, /* RTFsuperscript */
RTFtabstop = 349, /* RTFtabstop */
RTFfcharset = 350, /* RTFfcharset */
RTFfprq = 351, /* RTFfprq */
RTFcpg = 352, /* RTFcpg */
RTFansicpg = 353, /* RTFansicpg */
RTFOtherStatement = 354, /* RTFOtherStatement */
RTFfontListStart = 355, /* RTFfontListStart */
RTFfamilyNil = 356, /* RTFfamilyNil */
RTFfamilyRoman = 357, /* RTFfamilyRoman */
RTFfamilySwiss = 358, /* RTFfamilySwiss */
RTFfamilyModern = 359, /* RTFfamilyModern */
RTFfamilyScript = 360, /* RTFfamilyScript */
RTFfamilyDecor = 361, /* RTFfamilyDecor */
RTFfamilyTech = 362, /* RTFfamilyTech */
RTFfamilyBiDi = 363 /* RTFfamilyBiDi */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
@ -168,7 +174,7 @@ union YYSTYPE
const char *text;
RTFcmd cmd;
#line 172 "rtfGrammar.tab.h"
#line 178 "rtfGrammar.tab.h"
};
typedef union YYSTYPE YYSTYPE;

File diff suppressed because it is too large Load diff

View file

@ -209,7 +209,7 @@ rtfFile: '{' { GSRTFstart(CTXT); } RTFstart rtfIngredients { GSRTFstop(CTXT); }
rtfCharset: RTFansi { GSRTFencoding(CTXT, 1); }
| RTFmac { GSRTFencoding(CTXT, 2); }
| RTFpc { GSRTFencoding(CTXT, $$ = 3); }
| RTFpc { GSRTFencoding(CTXT, 3); }
| RTFpca { GSRTFencoding(CTXT, 4); }
| rtfCharset RTFansicpg { GSRTFencoding(CTXT, $2.parameter); }
;