riched20: Don't skip the final carriage return in SFF_SELECTION mode.

This commit is contained in:
Huw Davies 2014-05-29 15:47:42 +01:00 committed by Alexandre Julliard
parent d32abd7726
commit b89c7c8fc2
2 changed files with 42 additions and 2 deletions

View File

@ -1620,7 +1620,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
CR/LF counters, since RTF streaming presents only \para tokens, which
are converted according to the standard rules: \r for 2.0, \r\n for 1.0
*/
if (stripLastCR) {
if (stripLastCR && !(format & SFF_SELECTION)) {
int newto;
ME_GetSelection(editor, &selStart, &selEnd);
newto = ME_GetCursorOfs(selEnd);

View File

@ -5072,10 +5072,12 @@ static void test_EM_STREAMIN(void)
LRESULT result;
EDITSTREAM es;
char buffer[1024] = {0}, tmp[16];
CHARRANGE range;
const char * streamText0 = "{\\rtf1 TestSomeText}";
const char * streamText0a = "{\\rtf1 TestSomeText\\par}";
const char * streamText0b = "{\\rtf1 TestSomeText\\par\\par}";
const char * ptr;
const char * streamText1 =
"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang12298{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 System;}}\r\n"
@ -5132,7 +5134,8 @@ static void test_EM_STREAMIN(void)
ok(es.dwError == 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es.dwError, 0);
/* Native richedit 2.0 ignores last \par */
es.dwCookie = (DWORD_PTR)&streamText0a;
ptr = streamText0a;
es.dwCookie = (DWORD_PTR)&ptr;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;
result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es);
@ -5161,6 +5164,43 @@ static void test_EM_STREAMIN(void)
"EM_STREAMIN: Test 0-b set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test 0-b set error %d, expected %d\n", es.dwError, 0);
/* Show that when using SFF_SELECTION the last \par is not ignored. */
ptr = streamText0a;
es.dwCookie = (DWORD_PTR)&ptr;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;
result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es);
ok(result == 12, "got %ld, expected %d\n", result, 12);
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 12,
"EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result);
result = strcmp (buffer,"TestSomeText");
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);
range.cpMin = 0;
range.cpMax = -1;
result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&range);
ok (result == 13, "got %ld\n", result);
ptr = streamText0a;
es.dwCookie = (DWORD_PTR)&ptr;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;
result = SendMessageA(hwndRichEdit, EM_STREAMIN, SFF_SELECTION | SF_RTF, (LPARAM)&es);
ok(result == 13, "got %ld, expected 13\n", result);
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 14,
"EM_STREAMIN: Test SFF_SELECTION 0-a returned %ld, expected 14\n", result);
result = strcmp (buffer,"TestSomeText\r\n");
ok (result == 0,
"EM_STREAMIN: Test SFF_SELECTION 0-a set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test SFF_SELECTION 0-a set error %d, expected %d\n", es.dwError, 0);
es.dwCookie = (DWORD_PTR)&streamText1;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;