richedit: Properly restore style after end of rtf group.

Rich text files have groupings of text, where styles are pushed onto
the stack when encountering a start of the group, then popped at the
end of the group.  This was being handled improperly before, because a
single styleChanged flag was being stored to keep track of whether the
style needed to be restored at the end of a group. This fails to work
properly since the single flag isn't keeping track of all the levels
of the stack, so some styles are not restored properly.
This commit is contained in:
Dylan Smith 2009-07-17 13:24:13 -04:00 committed by Alexandre Julliard
parent 94c7ab72f5
commit c6cf567706
3 changed files with 13 additions and 12 deletions

View File

@ -1345,7 +1345,8 @@ static void ME_RTFReadHook(RTF_Info *info)
{ {
case rtfBeginGroup: case rtfBeginGroup:
if (info->stackTop < maxStack) { if (info->stackTop < maxStack) {
info->stack[info->stackTop].fmt = info->style->fmt; info->stack[info->stackTop].style = info->style;
ME_AddRefStyle(info->style);
info->stack[info->stackTop].codePage = info->codePage; info->stack[info->stackTop].codePage = info->codePage;
info->stack[info->stackTop].unicodeLength = info->unicodeLength; info->stack[info->stackTop].unicodeLength = info->unicodeLength;
} }
@ -1354,7 +1355,6 @@ static void ME_RTFReadHook(RTF_Info *info)
break; break;
case rtfEndGroup: case rtfEndGroup:
{ {
ME_Style *s;
RTFFlushOutputBuffer(info); RTFFlushOutputBuffer(info);
info->stackTop--; info->stackTop--;
if (info->stackTop<=0) { if (info->stackTop<=0) {
@ -1362,15 +1362,12 @@ static void ME_RTFReadHook(RTF_Info *info)
return; return;
} }
assert(info->stackTop >= 0); assert(info->stackTop >= 0);
if (info->styleChanged)
{
/* FIXME too slow ? how come ? */
s = ME_ApplyStyle(info->style, &info->stack[info->stackTop].fmt);
ME_ReleaseStyle(info->style); ME_ReleaseStyle(info->style);
info->style = s; info->style = info->stack[info->stackTop].style;
ME_AddRefStyle(info->style);
info->codePage = info->stack[info->stackTop].codePage; info->codePage = info->stack[info->stackTop].codePage;
info->unicodeLength = info->stack[info->stackTop].unicodeLength; info->unicodeLength = info->stack[info->stackTop].unicodeLength;
}
break; break;
} }
} }

View File

@ -442,7 +442,11 @@ static void RTFUngetToken(RTF_Info *info)
* increment the value to compensate for it being decremented * increment the value to compensate for it being decremented
* twice due to the RTFUngetToken. */ * twice due to the RTFUngetToken. */
if(RTFCheckCM (info, rtfGroup, rtfEndGroup)) if(RTFCheckCM (info, rtfGroup, rtfEndGroup))
{
info->stack[info->stackTop].style = info->style;
ME_AddRefStyle(info->style);
info->stackTop++; info->stackTop++;
}
} }

View File

@ -1095,7 +1095,7 @@ typedef void (*RTFFuncPtr) (RTF_Info *); /* generic function pointer */
/* RTF parser stack element */ /* RTF parser stack element */
struct tagRTFState { struct tagRTFState {
CHARFORMAT2W fmt; ME_Style *style;
int codePage; int codePage;
int unicodeLength; int unicodeLength;
}; };