Commit 372a16af authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Don't apply paragraph formatting until the end of paragraph.

Specifically this means that if the final paragraph does not end in a trailing \par, then new formatting is not applied to that paragraph. Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent aec411ed
......@@ -269,6 +269,9 @@ void RTFInit(RTF_Info *info)
info->nestingLevel = 0;
info->canInheritInTbl = FALSE;
info->borderType = 0;
memset(&info->fmt, 0, sizeof(info->fmt));
info->fmt.cbSize = sizeof(info->fmt);
}
/*
......@@ -2516,6 +2519,10 @@ static void SpecialChar (RTF_Info *info)
case rtfPage:
case rtfSect:
case rtfPar:
RTFFlushOutputBuffer(info);
ME_SetSelectionParaFormat(info->editor, &info->fmt);
memset(&info->fmt, 0, sizeof(info->fmt));
info->fmt.cbSize = sizeof(info->fmt);
RTFPutUnicodeChar (info, '\r');
if (info->editor->bEmulateVersion10) RTFPutUnicodeChar (info, '\n');
break;
......
......@@ -1181,6 +1181,8 @@ struct _RTF_Info {
int nestingLevel;
BOOL canInheritInTbl;
int borderType; /* value corresponds to the RTFBorder constants. */
PARAFORMAT2 fmt; /* Accumulated para fmt for current paragraph. */
};
......
......@@ -5404,9 +5404,10 @@ static void test_EM_STREAMIN(void)
EDITSTREAM es;
char buffer[1024] = {0}, tmp[16];
CHARRANGE range;
PARAFORMAT2 fmt;
const char * streamText0 = "{\\rtf1 TestSomeText}";
const char * streamText0a = "{\\rtf1 TestSomeText\\par}";
const char * streamText0 = "{\\rtf1\\fi100\\li200\\rtlpar\\qr TestSomeText}";
const char * streamText0a = "{\\rtf1\\fi100\\li200\\rtlpar\\qr TestSomeText\\par}";
const char * streamText0b = "{\\rtf1 TestSomeText\\par\\par}";
const char * ptr;
......@@ -5463,6 +5464,17 @@ static void test_EM_STREAMIN(void)
ok (result == 0,
"EM_STREAMIN: Test 0 set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es.dwError, 0);
/* Show that para fmts are ignored */
range.cpMin = 2;
range.cpMax = 2;
result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&range);
memset(&fmt, 0xcc, sizeof(fmt));
fmt.cbSize = sizeof(fmt);
result = SendMessageA(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt);
ok(fmt.dxStartIndent == 0, "got %d\n", fmt.dxStartIndent);
ok(fmt.dxOffset == 0, "got %d\n", fmt.dxOffset);
ok(fmt.wAlignment == PFA_LEFT, "got %d\n", fmt.wAlignment);
ok((fmt.wEffects & PFE_RTLPARA) == 0, "got %x\n", fmt.wEffects);
/* Native richedit 2.0 ignores last \par */
ptr = streamText0a;
......@@ -5479,6 +5491,17 @@ static void test_EM_STREAMIN(void)
ok (result == 0,
"EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %d, expected %d\n", es.dwError, 0);
/* This time para fmts are processed */
range.cpMin = 2;
range.cpMax = 2;
result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&range);
memset(&fmt, 0xcc, sizeof(fmt));
fmt.cbSize = sizeof(fmt);
result = SendMessageA(hwndRichEdit, EM_GETPARAFORMAT, 0, (LPARAM)&fmt);
ok(fmt.dxStartIndent == 300, "got %d\n", fmt.dxStartIndent);
ok(fmt.dxOffset == -100, "got %d\n", fmt.dxOffset);
ok(fmt.wAlignment == PFA_RIGHT, "got %d\n", fmt.wAlignment);
ok((fmt.wEffects & PFE_RTLPARA) == PFE_RTLPARA, "got %x\n", fmt.wEffects);
/* Native richedit 2.0 ignores last \par, next-to-last \par appears */
es.dwCookie = (DWORD_PTR)&streamText0b;
......
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