Commit c4c11d25 authored by Krzysztof Foltman's avatar Krzysztof Foltman Committed by Alexandre Julliard

- Unknown destinations are now correctly skipped (so loading an RTF

file generated by, for example, OpenOffice doesn't produce lots of garbage anymore). - Format stack for RTF groups (so that RTF reader can correctly read what RTF writer wrote :) )
parent e8e1c656
......@@ -284,9 +284,11 @@ void ME_RTFCharAttrHook(RTF_Info *info)
switch(info->rtfMinor)
{
case rtfPlain:
FIXME("rtfPlain: how plain should it be ?\n");
fmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR | CFM_BACKCOLOR;
/* FIXME add more flags once they're implemented */
fmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR | CFM_BACKCOLOR | CFM_SIZE | CFM_WEIGHT;
fmt.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
fmt.yHeight = 12*20; /* 12pt */
fmt.wWeight = 400;
break;
case rtfBold:
fmt.dwMask = CFM_BOLD;
......@@ -385,6 +387,25 @@ void ME_RTFParAttrHook(RTF_Info *info)
void ME_RTFReadHook(RTF_Info *info) {
switch(info->rtfClass)
{
case rtfGroup:
switch(info->rtfMajor)
{
case rtfBeginGroup:
if (info->formatStackTop < maxCharFormatStack) {
info->formatStack[info->formatStackTop].cbSize = sizeof(info->formatStack[0]);
SendMessageW(info->hwndEdit, EM_GETCHARFORMAT, 1, (LPARAM)&info->formatStack[info->formatStackTop]);
}
info->formatStackTop++;
break;
case rtfEndGroup:
RTFFlushOutputBuffer(info);
info->formatStackTop--;
if (info->formatStackTop < maxCharFormatStack) {
SendMessageW(info->hwndEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&info->formatStack[info->formatStackTop]);
}
break;
}
break;
case rtfControl:
switch(info->rtfMajor)
{
......
......@@ -3685,7 +3685,7 @@ ControlClass (RTF_Info *info)
/*
* This function notices destinations that should be ignored
* This function notices destinations that aren't explicitly handled
* and skips to their ends. This keeps, for instance, picture
* data from being considered as plain text.
*/
......@@ -3694,26 +3694,8 @@ static void
Destination (RTF_Info *info)
{
TRACE("\n");
switch (info->rtfMinor)
{
case rtfGenerator:
case rtfPict:
case rtfFNContSep:
case rtfFNContNotice:
case rtfInfo:
case rtfIndexRange:
case rtfITitle:
case rtfISubject:
case rtfIAuthor:
case rtfIOperator:
case rtfIKeywords:
case rtfIComment:
case rtfIVersion:
case rtfIDoccomm:
RTFSkipGroup (info);
break;
}
if (!RTFGetDestinationCallback(info, info->rtfMinor))
RTFSkipGroup (info);
}
......@@ -3730,6 +3712,15 @@ void SpecialChar (RTF_Info *info)
switch (info->rtfMinor)
{
case rtfOptDest:
/* the next token determines destination, if it's unknown, skip the group */
/* this way we filter out the garbage coming from unknown destinations */
RTFGetToken(info);
if (info->rtfClass != rtfDestination)
RTFSkipGroup(info);
else
RTFRouteToken(info); /* "\*" is ignored with known destinations */
break;
case rtfPage:
case rtfSect:
case rtfRow:
......
......@@ -1390,6 +1390,9 @@ struct RTFStyleElt
# define maxCSStack 10
/* character format stack size */
# define maxCharFormatStack 32
struct _RTF_Info;
typedef struct _RTF_Info RTF_Info;
......@@ -1499,6 +1502,9 @@ struct _RTF_Info {
DWORD dwOutputCount;
char OutputBuffer[0x1000];
CHARFORMAT2W formatStack[maxCharFormatStack];
int formatStackTop;
};
......
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