richedit: Handle missing colours in rtf colour table.

When a colour table entry is empty, then the default colour is used.
For an incomplete colour table entry 0 is used for the missing colours.

Previously the -1 value used internally for missing colours was being
converted into white, where it should be using the default colour that
is normally black.

This bug could be seen by loading the following rich text into wordpad:
{\rtf{\colortbl;;}\cf1 text}
This commit is contained in:
Dylan Smith 2009-07-17 09:17:20 -04:00 committed by Alexandre Julliard
parent 1e5d72a630
commit dde41d5c13
2 changed files with 21 additions and 14 deletions

View file

@ -422,7 +422,10 @@ void ME_RTFCharAttrHook(RTF_Info *info)
else if (info->rtfParam != rtfNoParam)
{
RTFColor *c = RTFGetColor(info, info->rtfParam);
fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
if (c && c->rtfCBlue >= 0)
fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
else
fmt.dwEffects = CFE_AUTOBACKCOLOR;
}
break;
case rtfForeColor:
@ -433,10 +436,11 @@ void ME_RTFCharAttrHook(RTF_Info *info)
else if (info->rtfParam != rtfNoParam)
{
RTFColor *c = RTFGetColor(info, info->rtfParam);
if (c)
if (c && c->rtfCBlue >= 0)
fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
else
fmt.crTextColor = 0;
else {
fmt.dwEffects = CFE_AUTOCOLOR;
}
}
break;
case rtfFontNum:

View file

@ -990,18 +990,21 @@ static void ReadColorTbl(RTF_Info *info)
break;
}
cp->rtfCNum = cnum++;
cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
cp->rtfNextColor = info->colorList;
info->colorList = cp;
while (RTFCheckCM (info, rtfControl, rtfColorName))
{
switch (info->rtfMinor)
{
case rtfRed: cp->rtfCRed = info->rtfParam; break;
case rtfGreen: cp->rtfCGreen = info->rtfParam; break;
case rtfBlue: cp->rtfCBlue = info->rtfParam; break;
}
RTFGetToken (info);
if (!RTFCheckCM (info, rtfControl, rtfColorName))
cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
else {
cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = 0;
do {
switch (info->rtfMinor)
{
case rtfRed: cp->rtfCRed = info->rtfParam & 0xFF; break;
case rtfGreen: cp->rtfCGreen = info->rtfParam & 0xFF; break;
case rtfBlue: cp->rtfCBlue = info->rtfParam & 0xFF; break;
}
RTFGetToken (info);
} while (RTFCheckCM (info, rtfControl, rtfColorName));
}
if (info->rtfClass == rtfEOF)
break;