Replaced slow and outdated character set handling in RTF reader by

Unicode/codepages support. Added charset->codepage conversion.
This commit is contained in:
Phil Krylov 2005-03-17 13:57:27 +00:00 committed by Alexandre Julliard
parent d9ef0a4ba4
commit 0284930129
3 changed files with 176 additions and 1736 deletions

View File

@ -399,6 +399,7 @@ void ME_RTFReadHook(RTF_Info *info) {
if (info->formatStackTop < maxCharFormatStack) {
info->formatStack[info->formatStackTop].cbSize = sizeof(info->formatStack[0]);
memcpy(&info->formatStack[info->formatStackTop], &info->style->fmt, sizeof(CHARFORMAT2W));
info->codePageStack[info->formatStackTop] = info->codePage;
}
info->formatStackTop++;
break;
@ -411,6 +412,7 @@ void ME_RTFReadHook(RTF_Info *info) {
s = ME_ApplyStyle(info->style, &info->formatStack[info->formatStackTop]);
ME_ReleaseStyle(info->style);
info->style = s;
info->codePage = info->codePageStack[info->formatStackTop];
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -11,365 +11,6 @@
#include "richedit.h"
/* The following defines are automatically generated. Do not edit. */
/* These must be sequential beginning from zero */
#define rtfSC_nothing 0
#define rtfSC_space 1
#define rtfSC_exclam 2
#define rtfSC_quotedbl 3
#define rtfSC_numbersign 4
#define rtfSC_dollar 5
#define rtfSC_percent 6
#define rtfSC_ampersand 7
#define rtfSC_quoteright 8
#define rtfSC_parenleft 9
#define rtfSC_parenright 10
#define rtfSC_asterisk 11
#define rtfSC_plus 12
#define rtfSC_comma 13
#define rtfSC_hyphen 14
#define rtfSC_period 15
#define rtfSC_slash 16
#define rtfSC_zero 17
#define rtfSC_one 18
#define rtfSC_two 19
#define rtfSC_three 20
#define rtfSC_four 21
#define rtfSC_five 22
#define rtfSC_six 23
#define rtfSC_seven 24
#define rtfSC_eight 25
#define rtfSC_nine 26
#define rtfSC_colon 27
#define rtfSC_semicolon 28
#define rtfSC_less 29
#define rtfSC_equal 30
#define rtfSC_greater 31
#define rtfSC_question 32
#define rtfSC_at 33
#define rtfSC_A 34
#define rtfSC_B 35
#define rtfSC_C 36
#define rtfSC_D 37
#define rtfSC_E 38
#define rtfSC_F 39
#define rtfSC_G 40
#define rtfSC_H 41
#define rtfSC_I 42
#define rtfSC_J 43
#define rtfSC_K 44
#define rtfSC_L 45
#define rtfSC_M 46
#define rtfSC_N 47
#define rtfSC_O 48
#define rtfSC_P 49
#define rtfSC_Q 50
#define rtfSC_R 51
#define rtfSC_S 52
#define rtfSC_T 53
#define rtfSC_U 54
#define rtfSC_V 55
#define rtfSC_W 56
#define rtfSC_X 57
#define rtfSC_Y 58
#define rtfSC_Z 59
#define rtfSC_bracketleft 60
#define rtfSC_backslash 61
#define rtfSC_bracketright 62
#define rtfSC_asciicircum 63
#define rtfSC_underscore 64
#define rtfSC_quoteleft 65
#define rtfSC_a 66
#define rtfSC_b 67
#define rtfSC_c 68
#define rtfSC_d 69
#define rtfSC_e 70
#define rtfSC_f 71
#define rtfSC_g 72
#define rtfSC_h 73
#define rtfSC_i 74
#define rtfSC_j 75
#define rtfSC_k 76
#define rtfSC_l 77
#define rtfSC_m 78
#define rtfSC_n 79
#define rtfSC_o 80
#define rtfSC_p 81
#define rtfSC_q 82
#define rtfSC_r 83
#define rtfSC_s 84
#define rtfSC_t 85
#define rtfSC_u 86
#define rtfSC_v 87
#define rtfSC_w 88
#define rtfSC_x 89
#define rtfSC_y 90
#define rtfSC_z 91
#define rtfSC_braceleft 92
#define rtfSC_bar 93
#define rtfSC_braceright 94
#define rtfSC_asciitilde 95
#define rtfSC_exclamdown 96
#define rtfSC_cent 97
#define rtfSC_sterling 98
#define rtfSC_fraction 99
#define rtfSC_yen 100
#define rtfSC_florin 101
#define rtfSC_section 102
#define rtfSC_currency 103
#define rtfSC_quotedblleft 104
#define rtfSC_guillemotleft 105
#define rtfSC_guilsinglleft 106
#define rtfSC_guilsinglright 107
#define rtfSC_fi 108
#define rtfSC_fl 109
#define rtfSC_endash 110
#define rtfSC_dagger 111
#define rtfSC_daggerdbl 112
#define rtfSC_periodcentered 113
#define rtfSC_paragraph 114
#define rtfSC_bullet 115
#define rtfSC_quotesinglbase 116
#define rtfSC_quotedblbase 117
#define rtfSC_quotedblright 118
#define rtfSC_guillemotright 119
#define rtfSC_ellipsis 120
#define rtfSC_perthousand 121
#define rtfSC_questiondown 122
#define rtfSC_grave 123
#define rtfSC_acute 124
#define rtfSC_circumflex 125
#define rtfSC_tilde 126
#define rtfSC_macron 127
#define rtfSC_breve 128
#define rtfSC_dotaccent 129
#define rtfSC_dieresis 130
#define rtfSC_ring 131
#define rtfSC_cedilla 132
#define rtfSC_hungarumlaut 133
#define rtfSC_ogonek 134
#define rtfSC_caron 135
#define rtfSC_emdash 136
#define rtfSC_AE 137
#define rtfSC_ordfeminine 138
#define rtfSC_Lslash 139
#define rtfSC_Oslash 140
#define rtfSC_OE 141
#define rtfSC_ordmasculine 142
#define rtfSC_ae 143
#define rtfSC_dotlessi 144
#define rtfSC_lslash 145
#define rtfSC_oslash 146
#define rtfSC_oe 147
#define rtfSC_germandbls 148
#define rtfSC_Aacute 149
#define rtfSC_Acircumflex 150
#define rtfSC_Adieresis 151
#define rtfSC_Agrave 152
#define rtfSC_Aring 153
#define rtfSC_Atilde 154
#define rtfSC_Ccedilla 155
#define rtfSC_Eacute 156
#define rtfSC_Ecircumflex 157
#define rtfSC_Edieresis 158
#define rtfSC_Egrave 159
#define rtfSC_Eth 160
#define rtfSC_Iacute 161
#define rtfSC_Icircumflex 162
#define rtfSC_Idieresis 163
#define rtfSC_Igrave 164
#define rtfSC_Ntilde 165
#define rtfSC_Oacute 166
#define rtfSC_Ocircumflex 167
#define rtfSC_Odieresis 168
#define rtfSC_Ograve 169
#define rtfSC_Otilde 170
#define rtfSC_Scaron 171
#define rtfSC_Thorn 172
#define rtfSC_Uacute 173
#define rtfSC_Ucircumflex 174
#define rtfSC_Udieresis 175
#define rtfSC_Ugrave 176
#define rtfSC_Yacute 177
#define rtfSC_Ydieresis 178
#define rtfSC_aacute 179
#define rtfSC_acircumflex 180
#define rtfSC_adieresis 181
#define rtfSC_agrave 182
#define rtfSC_aring 183
#define rtfSC_atilde 184
#define rtfSC_brokenbar 185
#define rtfSC_ccedilla 186
#define rtfSC_copyright 187
#define rtfSC_degree 188
#define rtfSC_divide 189
#define rtfSC_eacute 190
#define rtfSC_ecircumflex 191
#define rtfSC_edieresis 192
#define rtfSC_egrave 193
#define rtfSC_eth 194
#define rtfSC_iacute 195
#define rtfSC_icircumflex 196
#define rtfSC_idieresis 197
#define rtfSC_igrave 198
#define rtfSC_logicalnot 199
#define rtfSC_minus 200
#define rtfSC_multiply 201
#define rtfSC_ntilde 202
#define rtfSC_oacute 203
#define rtfSC_ocircumflex 204
#define rtfSC_odieresis 205
#define rtfSC_ograve 206
#define rtfSC_onehalf 207
#define rtfSC_onequarter 208
#define rtfSC_onesuperior 209
#define rtfSC_otilde 210
#define rtfSC_plusminus 211
#define rtfSC_registered 212
#define rtfSC_thorn 213
#define rtfSC_threequarters 214
#define rtfSC_threesuperior 215
#define rtfSC_trademark 216
#define rtfSC_twosuperior 217
#define rtfSC_uacute 218
#define rtfSC_ucircumflex 219
#define rtfSC_udieresis 220
#define rtfSC_ugrave 221
#define rtfSC_yacute 222
#define rtfSC_ydieresis 223
#define rtfSC_Alpha 224
#define rtfSC_Beta 225
#define rtfSC_Chi 226
#define rtfSC_Delta 227
#define rtfSC_Epsilon 228
#define rtfSC_Phi 229
#define rtfSC_Gamma 230
#define rtfSC_Eta 231
#define rtfSC_Iota 232
#define rtfSC_Kappa 233
#define rtfSC_Lambda 234
#define rtfSC_Mu 235
#define rtfSC_Nu 236
#define rtfSC_Omicron 237
#define rtfSC_Pi 238
#define rtfSC_Theta 239
#define rtfSC_Rho 240
#define rtfSC_Sigma 241
#define rtfSC_Tau 242
#define rtfSC_Upsilon 243
#define rtfSC_varUpsilon 244
#define rtfSC_Omega 245
#define rtfSC_Xi 246
#define rtfSC_Psi 247
#define rtfSC_Zeta 248
#define rtfSC_alpha 249
#define rtfSC_beta 250
#define rtfSC_chi 251
#define rtfSC_delta 252
#define rtfSC_epsilon 253
#define rtfSC_phi 254
#define rtfSC_varphi 255
#define rtfSC_gamma 256
#define rtfSC_eta 257
#define rtfSC_iota 258
#define rtfSC_kappa 259
#define rtfSC_lambda 260
#define rtfSC_mu 261
#define rtfSC_nu 262
#define rtfSC_omicron 263
#define rtfSC_pi 264
#define rtfSC_varpi 265
#define rtfSC_theta 266
#define rtfSC_vartheta 267
#define rtfSC_rho 268
#define rtfSC_sigma 269
#define rtfSC_varsigma 270
#define rtfSC_tau 271
#define rtfSC_upsilon 272
#define rtfSC_omega 273
#define rtfSC_xi 274
#define rtfSC_psi 275
#define rtfSC_zeta 276
#define rtfSC_nobrkspace 277
#define rtfSC_nobrkhyphen 278
#define rtfSC_lessequal 279
#define rtfSC_greaterequal 280
#define rtfSC_infinity 281
#define rtfSC_integral 282
#define rtfSC_notequal 283
#define rtfSC_radical 284
#define rtfSC_radicalex 285
#define rtfSC_approxequal 286
#define rtfSC_apple 287
#define rtfSC_partialdiff 288
#define rtfSC_opthyphen 289
#define rtfSC_formula 290
#define rtfSC_lozenge 291
#define rtfSC_universal 292
#define rtfSC_existential 293
#define rtfSC_suchthat 294
#define rtfSC_congruent 295
#define rtfSC_therefore 296
#define rtfSC_perpendicular 297
#define rtfSC_minute 298
#define rtfSC_club 299
#define rtfSC_diamond 300
#define rtfSC_heart 301
#define rtfSC_spade 302
#define rtfSC_arrowboth 303
#define rtfSC_arrowleft 304
#define rtfSC_arrowup 305
#define rtfSC_arrowright 306
#define rtfSC_arrowdown 307
#define rtfSC_second 308
#define rtfSC_proportional 309
#define rtfSC_equivalence 310
#define rtfSC_arrowvertex 311
#define rtfSC_arrowhorizex 312
#define rtfSC_carriagereturn 313
#define rtfSC_aleph 314
#define rtfSC_Ifraktur 315
#define rtfSC_Rfraktur 316
#define rtfSC_weierstrass 317
#define rtfSC_circlemultiply 318
#define rtfSC_circleplus 319
#define rtfSC_emptyset 320
#define rtfSC_intersection 321
#define rtfSC_union 322
#define rtfSC_propersuperset 323
#define rtfSC_reflexsuperset 324
#define rtfSC_notsubset 325
#define rtfSC_propersubset 326
#define rtfSC_reflexsubset 327
#define rtfSC_element 328
#define rtfSC_notelement 329
#define rtfSC_angle 330
#define rtfSC_gradient 331
#define rtfSC_product 332
#define rtfSC_logicaland 333
#define rtfSC_logicalor 334
#define rtfSC_arrowdblboth 335
#define rtfSC_arrowdblleft 336
#define rtfSC_arrowdblup 337
#define rtfSC_arrowdblright 338
#define rtfSC_arrowdbldown 339
#define rtfSC_angleleft 340
#define rtfSC_registersans 341
#define rtfSC_copyrightsans 342
#define rtfSC_trademarksans 343
#define rtfSC_angleright 344
#define rtfSC_mathplus 345
#define rtfSC_mathminus 346
#define rtfSC_mathasterisk 347
#define rtfSC_mathnumbersign 348
#define rtfSC_dotmath 349
#define rtfSC_mathequal 350
#define rtfSC_mathtilde 351
#define rtfSC_MaxChar 352
/*
* rtf.h - RTF document processing stuff. Release 1.10.
*/
@ -711,6 +352,8 @@
# define rtfAnnotProtected 75 /* new in 1.10 */
# define rtfRTLDoc 76 /* new in 1.10 */
# define rtfLTRDoc 77 /* new in 1.10 */
# define rtfAnsiCodePage 78
# define rtfUnicodeLength 79
# define rtfSectAttr 9
# define rtfSectDef 0
@ -1439,9 +1082,14 @@ struct _RTF_Info {
int prevChar;
int bumpLine;
/* Document-wide attributes */
RTFFont *fontList; /* these lists MUST be */
RTFColor *colorList; /* initialized to NULL */
RTFStyle *styleList;
int ansiCodePage; /* ANSI codepage used in conversion to Unicode */
int unicodeLength; /* The length of ANSI representation of Unicode characters */
int codePage; /* Current codepage for text conversion */
char *inputName;
char *outputName;
@ -1457,41 +1105,6 @@ struct _RTF_Info {
ME_TextEditor *editor;
ME_Style *style;
/*
* These arrays are used to map RTF input character values onto the standard
* character names represented by the values. Input character values are
* used as indices into the arrays to produce standard character codes.
*/
char *genCharSetFile ;
int genCharCode[charSetSize]; /* general */
int haveGenCharSet;
char *symCharSetFile;
int symCharCode[charSetSize]; /* symbol */
int haveSymCharSet;
int curCharSet;
int *curCharCode;
/*
* By default, the reader is configured to handle charset mapping invisibly,
* including reading the charset files and switching charset maps as necessary
* for Symbol font.
*/
int autoCharSetFlags;
/*
* Stack for keeping track of charset map on group begin/end. This is
* necessary because group termination reverts the font to the previous
* value, which may implicitly change it.
*/
int csStack[maxCSStack];
int csTop;
RTFFuncPtr ccb[rtfMaxClass]; /* class callbacks */
RTFFuncPtr dcb[rtfMaxDestination]; /* destination callbacks */
@ -1502,12 +1115,11 @@ struct _RTF_Info {
FILE *(*libFileOpen) ();
char *outMap[rtfSC_MaxChar];
DWORD dwOutputCount;
char OutputBuffer[0x1000];
WCHAR OutputBuffer[0x1000];
CHARFORMAT2W formatStack[maxCharFormatStack];
int codePageStack[maxCharFormatStack];
int formatStackTop;
};
@ -1561,15 +1173,6 @@ void RTFSetPanicProc ( RTF_Info *, RTFFuncPtr);
void RTFMsg (RTF_Info *, const char *fmt, ...);
void RTFPanic (RTF_Info *, const char *fmt, ...);
int RTFReadOutputMap ( RTF_Info *, char *[], int);
int RTFReadCharSetMap ( RTF_Info *, int);
void RTFSetCharSetMap ( RTF_Info *, char *, int);
int RTFStdCharCode ( RTF_Info *, const char *);
const char *RTFStdCharName ( RTF_Info *, int);
int RTFMapChar ( RTF_Info *, int);
int RTFGetCharSet( RTF_Info * );
void RTFSetCharSet( RTF_Info *, int);
void RTFSetOpenLibFileProc ( RTF_Info *, FILE *(*)());
FILE *RTFOpenLibFile ( RTF_Info *, char *, char *);