Module: wine Branch: master Commit: b89c7c8fc2b1e1de06ddb49a8cc8326b45573961 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b89c7c8fc2b1e1de06ddb49a8c...
Author: Huw Davies huw@codeweavers.com Date: Thu May 29 15:47:42 2014 +0100
riched20: Don't skip the final carriage return in SFF_SELECTION mode.
---
dlls/riched20/editor.c | 2 +- dlls/riched20/tests/editor.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index bc5bc08..0127616 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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); diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index e14d7f6..2a85357 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -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;