Commit dde41d5c authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

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}
parent 1e5d72a6
...@@ -422,7 +422,10 @@ void ME_RTFCharAttrHook(RTF_Info *info) ...@@ -422,7 +422,10 @@ void ME_RTFCharAttrHook(RTF_Info *info)
else if (info->rtfParam != rtfNoParam) else if (info->rtfParam != rtfNoParam)
{ {
RTFColor *c = RTFGetColor(info, info->rtfParam); 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; break;
case rtfForeColor: case rtfForeColor:
...@@ -433,10 +436,11 @@ void ME_RTFCharAttrHook(RTF_Info *info) ...@@ -433,10 +436,11 @@ void ME_RTFCharAttrHook(RTF_Info *info)
else if (info->rtfParam != rtfNoParam) else if (info->rtfParam != rtfNoParam)
{ {
RTFColor *c = RTFGetColor(info, info->rtfParam); RTFColor *c = RTFGetColor(info, info->rtfParam);
if (c) if (c && c->rtfCBlue >= 0)
fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed); fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
else else {
fmt.crTextColor = 0; fmt.dwEffects = CFE_AUTOCOLOR;
}
} }
break; break;
case rtfFontNum: case rtfFontNum:
......
...@@ -990,18 +990,21 @@ static void ReadColorTbl(RTF_Info *info) ...@@ -990,18 +990,21 @@ static void ReadColorTbl(RTF_Info *info)
break; break;
} }
cp->rtfCNum = cnum++; cp->rtfCNum = cnum++;
cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
cp->rtfNextColor = info->colorList; cp->rtfNextColor = info->colorList;
info->colorList = cp; info->colorList = cp;
while (RTFCheckCM (info, rtfControl, rtfColorName)) if (!RTFCheckCM (info, rtfControl, rtfColorName))
{ cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = -1;
switch (info->rtfMinor) else {
{ cp->rtfCRed = cp->rtfCGreen = cp->rtfCBlue = 0;
case rtfRed: cp->rtfCRed = info->rtfParam; break; do {
case rtfGreen: cp->rtfCGreen = info->rtfParam; break; switch (info->rtfMinor)
case rtfBlue: cp->rtfCBlue = info->rtfParam; break; {
} case rtfRed: cp->rtfCRed = info->rtfParam & 0xFF; break;
RTFGetToken (info); 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) if (info->rtfClass == rtfEOF)
break; break;
......
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