Alex Villacís Lasso : riched20: Fix WM_GETTEXT to change \r to \r\n.

Alexandre Julliard julliard at winehq.org
Mon Sep 24 08:07:56 CDT 2007


Module: wine
Branch: master
Commit: 00e562735dd5e092b6149944ef09dd7f2ec97f1d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=00e562735dd5e092b6149944ef09dd7f2ec97f1d

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Sun Sep 23 16:40:28 2007 -0500

riched20: Fix WM_GETTEXT to change \r to \r\n.

---

 dlls/riched20/editor.c       |   13 ++++++++-----
 dlls/riched20/tests/editor.c |   13 +++----------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index dff0b5f..a10c954 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1983,11 +1983,14 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
     return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam);
   case WM_GETTEXT:
   {
-    TEXTRANGEW tr; /* W and A differ only by rng->lpstrText */
-    tr.chrg.cpMin = 0;
-    tr.chrg.cpMax = wParam ? (wParam - 1) : 0;
-    tr.lpstrText = (WCHAR *)lParam;
-    return RichEditWndProc_common(hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr, unicode);
+    GETTEXTEX ex;
+
+    ex.cb = wParam;
+    ex.flags = GT_USECRLF;
+    ex.codepage = unicode ? 1200 : CP_ACP;
+    ex.lpDefaultChar = NULL;
+    ex.lpUsedDefaultChar = NULL;
+    return RichEditWndProc_common(hWnd, EM_GETTEXTEX, (WPARAM)&ex, lParam, unicode);
   }
   case EM_GETTEXTEX:
   {
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index a0b04e0..1c564ec 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -943,10 +943,8 @@ static void test_WM_SETTEXT()
 	"WM_GETTEXT returned %ld instead of expected %u\n",
 	result, strlen(buf));
   result = strcmp(TestItem2_after, buf);
-  todo_wine {
   ok(result == 0,
         "WM_SETTEXT round trip: strcmp = %ld\n", result);
-  }
 
   result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem3);
   ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result);
@@ -955,10 +953,8 @@ static void test_WM_SETTEXT()
 	"WM_GETTEXT returned %ld instead of expected %u\n",
 	result, strlen(buf));
   result = strcmp(TestItem3_after, buf);
-  todo_wine {
   ok(result == 0,
         "WM_SETTEXT round trip: strcmp = %ld\n", result);
-  }
 
   result = SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) TestItem3_after);
   ok (result == 1, "WM_SETTEXT returned %ld instead of 1\n", result);
@@ -967,10 +963,8 @@ static void test_WM_SETTEXT()
 	"WM_GETTEXT returned %ld instead of expected %u\n",
 	result, strlen(buf));
   result = strcmp(TestItem3_after, buf);
-  todo_wine {
   ok(result == 0,
         "WM_SETTEXT round trip: strcmp = %ld\n", result);
-  }
 
   DestroyWindow(hwndRichEdit);
 }
@@ -1020,10 +1014,8 @@ static void test_EM_SETTEXTEX(void)
 
   /* However, WM_GETTEXT *does* see \r\n where EM_GETTEXTEX would see \r */
   SendMessage(hwndRichEdit, WM_GETTEXT, MAX_BUF_LEN, (LPARAM)buf);
-  todo_wine {
   ok(strcmp((const char *)buf, TestItem2_after) == 0,
       "WM_GETTEXT did *not* see \\r converted to \\r\\n pairs.\n");
-  }
 
   result = SendMessage(hwndRichEdit, EM_SETTEXTEX, 
                        (WPARAM)&setText, (LPARAM) NULL);
@@ -1616,8 +1608,9 @@ static void test_WM_PASTE(void)
     int result;
     char buffer[1024] = {0};
     const char* text1 = "testing paste\r";
+    const char* text1_after = "testing paste\r\n";
     const char* text2 = "testing paste\r\rtesting paste";
-    const char* text3 = "testing paste\rpaste\rtesting paste";
+    const char* text3 = "testing paste\r\npaste\r\ntesting paste";
     HWND hwndRichEdit = new_richedit(NULL);
 
     SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text1);
@@ -1627,7 +1620,7 @@ static void test_WM_PASTE(void)
     SendMessage(hwndRichEdit, WM_CHAR, 22, 0);  /* ctrl-v */
     SendMessage(hwndRichEdit, WM_CHAR, 26, 0);  /* ctrl-z */
     SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
-    result = strcmp(text1, buffer);
+    result = strcmp(text1_after, buffer);
     ok(result == 0,
         "test paste: strcmp = %i\n", result);
 




More information about the wine-cvs mailing list