riched20: Appned a final \par when writing the whole buffer.
Huw Davies
huw at codeweavers.com
Mon Jun 8 08:29:17 CDT 2015
---
dlls/riched20/editor.c | 2 +-
dlls/riched20/tests/editor.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
dlls/riched20/writer.c | 5 ++++-
3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 38861fd..3ce6c91 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1708,7 +1708,7 @@ ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
data.pos = 0;
es.dwCookie = (DWORD_PTR)&data;
es.pfnCallback = ME_ReadFromRTFString;
- ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es, FALSE);
+ ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es, TRUE);
}
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 09437ef..c3470d4 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -3422,6 +3422,19 @@ static DWORD CALLBACK test_esCallback_written_1(DWORD_PTR dwCookie,
return 0;
}
+static int count_pars(const char *buf)
+{
+ const char *p = buf;
+ int count = 0;
+ while ((p = strstr( p, "\\par" )) != NULL)
+ {
+ if (!isalpha( p[4] ))
+ count++;
+ p++;
+ }
+ return count;
+}
+
static void test_EM_STREAMOUT(void)
{
HWND hwndRichEdit = new_richedit(NULL);
@@ -3446,6 +3459,19 @@ static void test_EM_STREAMOUT(void)
ok(strcmp(buf, TestItem1) == 0,
"streamed text different, got %s\n", buf);
+ /* RTF mode writes the final end of para \r if it's part of the selection */
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, 12);
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 0, "got %s\n", buf);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem2);
p = buf;
es.dwCookie = (DWORD_PTR)&p;
@@ -3458,6 +3484,20 @@ static void test_EM_STREAMOUT(void)
ok(r == 14, "streamed text length is %d, expecting 14\n", r);
ok(strcmp(buf, TestItem3) == 0,
"streamed text different from, got %s\n", buf);
+
+ /* And again RTF mode writes the final end of para \r if it's part of the selection */
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
+ ok (count_pars(buf) == 2, "got %s\n", buf);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, 13);
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
+ SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 2, "got %s\n", buf);
+
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem3);
p = buf;
es.dwCookie = (DWORD_PTR)&p;
@@ -4904,7 +4944,7 @@ static void test_WM_PASTE(void)
SendMessageA(hwndRichEdit, WM_PASTE, 0, 0);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n");
- todo_wine ok(result == 0,
+ ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer);
/* Simulates undo (Ctrl-Z) */
hold_key(VK_CONTROL);
@@ -4919,7 +4959,7 @@ static void test_WM_PASTE(void)
(MapVirtualKeyA('Y', MAPVK_VK_TO_VSC) << 16) | 1);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n");
- todo_wine ok(result == 0,
+ ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer);
release_key(VK_CONTROL);
diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index 26a64a7..2c7386a 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -788,8 +788,11 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
ME_Cursor cursor = *start;
ME_DisplayItem *prev_para = cursor.pPara;
ME_Cursor endCur = cursor;
+ int actual_chars;
- ME_MoveCursorChars(editor, &endCur, nChars);
+ actual_chars = ME_MoveCursorChars(editor, &endCur, nChars);
+ /* Include the final \r which MoveCursorChars will ignore. */
+ if (actual_chars != nChars) endCur.nOffset++;
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
return FALSE;
--
1.8.0
More information about the wine-patches
mailing list