Commit 4c9f013f authored by Phil Krylov's avatar Phil Krylov Committed by Alexandre Julliard

Added handling of deff RTF control word.

parent 2cc40bac
......@@ -393,6 +393,7 @@ static void ME_RTFCharAttrHook(RTF_Info *info)
style2 = ME_ApplyStyle(info->style, &fmt);
ME_ReleaseStyle(info->style);
info->style = style2;
info->styleChanged = TRUE;
}
}
......@@ -476,18 +477,22 @@ static void ME_RTFReadHook(RTF_Info *info) {
info->stack[info->stackTop].unicodeLength = info->unicodeLength;
}
info->stackTop++;
info->styleChanged = FALSE;
break;
case rtfEndGroup:
{
ME_Style *s;
RTFFlushOutputBuffer(info);
info->stackTop--;
/* FIXME too slow ? how come ? */
s = ME_ApplyStyle(info->style, &info->stack[info->stackTop].fmt);
ME_ReleaseStyle(info->style);
info->style = s;
info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength;
if (info->styleChanged)
{
/* FIXME too slow ? how come ? */
s = ME_ApplyStyle(info->style, &info->stack[info->stackTop].fmt);
ME_ReleaseStyle(info->style);
info->style = s;
info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength;
}
break;
}
}
......
......@@ -257,6 +257,7 @@ void RTFInit(RTF_Info *info)
info->ansiCodePage = 1252; /* Latin-1; actually unused */
info->unicodeLength = 1; /* \uc1 is the default */
info->codePage = info->ansiCodePage;
info->defFont = 0;
info->rtfClass = -1;
info->pushedClass = -1;
......@@ -1005,6 +1006,14 @@ static void ReadFontTbl(RTF_Info *info)
if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
RTFPanic (info, "%s: missing \"}\"", fn);
}
/* Apply the real properties of the default font */
if (fp->rtfFNum == info->defFont)
{
if (info->ansiCodePage != CP_UTF8)
info->codePage = fp->rtfFCodePage;
TRACE("default font codepage %d\n", info->codePage);
}
}
if (fp->rtfFNum == -1)
RTFPanic (info,"%s: missing font number", fn);
......@@ -2467,6 +2476,7 @@ void RTFPanic(RTF_Info *info, const char *fmt, ...)
static void TextClass (RTF_Info *info);
static void ControlClass (RTF_Info *info);
static void DefFont(RTF_Info *info);
static void Destination (RTF_Info *info);
static void SpecialChar (RTF_Info *info);
static void RTFPutUnicodeChar (RTF_Info *info, int c);
......@@ -2516,6 +2526,9 @@ ControlClass (RTF_Info *info)
case rtfCharSet:
CharSet(info);
break;
case rtfDefFont:
DefFont(info);
break;
case rtfDestination:
Destination (info);
break;
......@@ -2542,6 +2555,7 @@ CharAttr(RTF_Info *info)
{
if (info->ansiCodePage != CP_UTF8)
info->codePage = font->rtfFCodePage;
TRACE("font %d codepage %d\n", info->rtfParam, info->codePage);
}
else
RTFMsg(info, "unknown font %d\n", info->rtfParam);
......@@ -2592,8 +2606,18 @@ Destination (RTF_Info *info)
static void
DefFont(RTF_Info *info)
{
TRACE("%d\n", info->rtfParam);
info->defFont = info->rtfParam;
}
static void
DocAttr(RTF_Info *info)
{
TRACE("minor %d, param %d\n", info->rtfMinor, info->rtfParam);
switch (info->rtfMinor)
{
case rtfAnsiCodePage:
......
......@@ -1070,6 +1070,7 @@ struct _RTF_Info {
RTFColor *colorList; /* initialized to NULL */
RTFStyle *styleList;
int ansiCodePage; /* ANSI codepage used in conversion to Unicode */
int defFont;
/* Character attributes */
int unicodeLength; /* The length of ANSI representation of Unicode characters */
......@@ -1103,6 +1104,7 @@ struct _RTF_Info {
RTFState stack[maxStack];
int stackTop;
BOOL styleChanged;
};
......
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