Commit 297cd99c authored by Phil Krylov's avatar Phil Krylov Committed by Alexandre Julliard

Fixed support for RTF documents using ANSI charset and added support

for multibyte charsets, so that BIG5 and UTF-8 RTF documents are working now.
parent dbf222f3
......@@ -396,23 +396,24 @@ void ME_RTFReadHook(RTF_Info *info) {
switch(info->rtfMajor)
{
case rtfBeginGroup:
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;
if (info->stackTop < maxStack) {
memcpy(&info->stack[info->stackTop].fmt, &info->style->fmt, sizeof(CHARFORMAT2W));
info->stack[info->stackTop].codePage = info->codePage;
info->stack[info->stackTop].unicodeLength = info->unicodeLength;
}
info->formatStackTop++;
info->stackTop++;
break;
case rtfEndGroup:
{
ME_Style *s;
RTFFlushOutputBuffer(info);
info->formatStackTop--;
info->stackTop--;
/* FIXME too slow ? how come ? */
s = ME_ApplyStyle(info->style, &info->formatStack[info->formatStackTop]);
s = ME_ApplyStyle(info->style, &info->stack[info->stackTop].fmt);
ME_ReleaseStyle(info->style);
info->style = s;
info->codePage = info->codePageStack[info->formatStackTop];
info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength;
break;
}
}
......@@ -476,6 +477,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
/* do the parsing */
RTFRead(&parser);
RTFFlushOutputBuffer(&parser);
RTFDestroy(&parser);
style = parser.style;
}
......
......@@ -353,7 +353,7 @@
# define rtfRTLDoc 76 /* new in 1.10 */
# define rtfLTRDoc 77 /* new in 1.10 */
# define rtfAnsiCodePage 78
# define rtfUnicodeLength 79
# define rtfUTF8RTF 79
# define rtfSectAttr 9
# define rtfSectDef 0
......@@ -595,6 +595,7 @@
# define rtfCharCharSet 33 /* new in 1.10 */
# define rtfLanguage 34
# define rtfGray 35
# define rtfUnicodeLength 36
# define rtfPictAttr 13
# define rtfMacQD 0
......@@ -933,20 +934,6 @@
# define rtfLangUrdu 0x0420
/*
* CharSet indices
*/
# define rtfCSGeneral 0 /* general (default) charset */
# define rtfCSSymbol 1 /* symbol charset */
/*
* Flags for auto-charset-processing. Both are on by default.
*/
# define rtfReadCharSet 0x01 /* auto-read charset files */
# define rtfSwitchCharSet 0x02 /* auto-switch charset maps */
/*
* Style types
*/
......@@ -1026,23 +1013,25 @@ struct RTFStyleElt
# define New(t) ((t *) RTFAlloc ((int) sizeof (t)))
/* maximum number of character values representable in a byte */
# define charSetSize 256
/* charset stack size */
/* Parser stack size */
# define maxCSStack 10
/* character format stack size */
# define maxCharFormatStack 32
# define maxStack 32
struct _RTF_Info;
typedef struct _RTF_Info RTF_Info;
typedef void (*RTFFuncPtr) (RTF_Info *); /* generic function pointer */
/* RTF parser stack element */
struct tagRTFState {
CHARFORMAT2W fmt;
int codePage;
int unicodeLength;
};
typedef struct tagRTFState RTFState;
struct _RTF_Info {
/*
* Public variables (listed in rtf.h)
......@@ -1087,8 +1076,9 @@ struct _RTF_Info {
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 */
/* Character attributes */
int unicodeLength; /* The length of ANSI representation of Unicode characters */
int codePage; /* Current codepage for text conversion */
char *inputName;
......@@ -1118,9 +1108,12 @@ struct _RTF_Info {
DWORD dwOutputCount;
WCHAR OutputBuffer[0x1000];
CHARFORMAT2W formatStack[maxCharFormatStack];
int codePageStack[maxCharFormatStack];
int formatStackTop;
DWORD dwCPOutputCount;
DWORD dwMaxCPOutputCount;
char *cpOutputBuffer;
RTFState stack[maxStack];
int stackTop;
};
......@@ -1129,6 +1122,7 @@ struct _RTF_Info {
*/
void RTFInit (RTF_Info *);
void RTFDestroy(RTF_Info *info);
void RTFSetInputName (RTF_Info *, char *);
char *RTFGetInputName (RTF_Info *);
void RTFSetOutputName (RTF_Info *, char *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment