Alex Villacís Lasso : richedit: Remove indication for bCRLF, now that ME_GetTextW() knows how to honor CR and LF counters.

Alexandre Julliard julliard at winehq.org
Tue Apr 29 08:54:46 CDT 2008


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

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Sat Apr 26 21:16:41 2008 -0500

richedit: Remove indication for bCRLF, now that ME_GetTextW() knows how to honor CR and LF counters.

EM_GETTEXTRANGE and EM_GETSELTEXT are affected by this, so include tests to ensure no behavior was broken.

---

 dlls/riched20/editor.c       |    4 +-
 dlls/riched20/tests/editor.c |   63 ++++++++++++++++++++++++++++++++++++++
 dlls/riched32/tests/editor.c |   69 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 2 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 4ba23a5..d0d6195 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2594,12 +2594,12 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
       rng->chrg.cpMin, rng->chrg.cpMax, unicode,
       editor->bEmulateVersion10, ME_GetTextLength(editor));
     if (unicode)
-      return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, editor->bEmulateVersion10);
+      return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, 0);
     else
     {
       int nLen = rng->chrg.cpMax-rng->chrg.cpMin;
       WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1);
-      int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, editor->bEmulateVersion10);
+      int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0);
       /* FIXME this is a potential security hole (buffer overrun) 
          if you know more about wchar->mbyte conversion please explain
       */
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 28b4ce5..b365965 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -753,6 +753,67 @@ static void test_WM_GETTEXT(void)
     DestroyWindow(hwndRichEdit);
 }
 
+static void test_EM_GETTEXTRANGE(void)
+{
+    HWND hwndRichEdit = new_richedit(NULL);
+    const char * text1 = "foo bar\r\nfoo bar";
+    const char * text2 = "foo bar\rfoo bar";
+    const char * expect = "bar\rfoo";
+    char buffer[1024] = {0};
+    LRESULT result;
+    TEXTRANGEA textRange;
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
+
+    textRange.lpstrText = buffer;
+    textRange.chrg.cpMin = 4;
+    textRange.chrg.cpMax = 11;
+    result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect));
+    ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2);
+
+    textRange.lpstrText = buffer;
+    textRange.chrg.cpMin = 4;
+    textRange.chrg.cpMax = 11;
+    result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect));
+    ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    DestroyWindow(hwndRichEdit);
+}
+
+static void test_EM_GETSELTEXT(void)
+{
+    HWND hwndRichEdit = new_richedit(NULL);
+    const char * text1 = "foo bar\r\nfoo bar";
+    const char * text2 = "foo bar\rfoo bar";
+    const char * expect = "bar\rfoo";
+    char buffer[1024] = {0};
+    LRESULT result;
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
+
+    SendMessage(hwndRichEdit, EM_SETSEL, 4, 11);
+    result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect));
+    ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2);
+
+    SendMessage(hwndRichEdit, EM_SETSEL, 4, 11);
+    result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect));
+    ok(!strcmp(expect, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    DestroyWindow(hwndRichEdit);
+}
+
 /* FIXME: need to test unimplemented options and robustly test wparam */
 static void test_EM_SETOPTIONS(void)
 {
@@ -3028,6 +3089,8 @@ START_TEST( editor )
   test_TM_PLAINTEXT();
   test_EM_SETOPTIONS();
   test_WM_GETTEXT();
+  test_EM_GETTEXTRANGE();
+  test_EM_GETSELTEXT();
   test_EM_AUTOURLDETECT();
   test_EM_SETUNDOLIMIT();
   test_ES_PASSWORD();
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 6fe027b..21972ab 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -464,6 +464,73 @@ static void test_EM_LINELENGTH(void)
   DestroyWindow(hwndRichEdit);
 }
 
+static void test_EM_GETTEXTRANGE(void)
+{
+    HWND hwndRichEdit = new_richedit(NULL);
+    const char * text1 = "foo bar\r\nfoo bar";
+    const char * text2 = "foo bar\rfoo bar";
+    const char * expect1 = "bar\r\nfoo";
+    const char * expect2 = "bar\rfoo";
+    char buffer[1024] = {0};
+    LRESULT result;
+    TEXTRANGEA textRange;
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
+
+    textRange.lpstrText = buffer;
+    textRange.chrg.cpMin = 4;
+    textRange.chrg.cpMax = 12;
+    result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+    ok(result == 8, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect1));
+    ok(!strcmp(expect1, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2);
+
+    textRange.lpstrText = buffer;
+    textRange.chrg.cpMin = 4;
+    textRange.chrg.cpMax = 11;
+    result = SendMessage(hwndRichEdit, EM_GETTEXTRANGE, 0, (LPARAM)&textRange);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect2));
+    todo_wine {
+    ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+    }
+
+    DestroyWindow(hwndRichEdit);
+}
+
+static void test_EM_GETSELTEXT(void)
+{
+    HWND hwndRichEdit = new_richedit(NULL);
+    const char * text1 = "foo bar\r\nfoo bar";
+    const char * text2 = "foo bar\rfoo bar";
+    const char * expect1 = "bar\r\nfoo";
+    const char * expect2 = "bar\rfoo";
+    char buffer[1024] = {0};
+    LRESULT result;
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
+
+    SendMessage(hwndRichEdit, EM_SETSEL, 4, 12);
+    result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
+    ok(result == 8, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect1));
+    ok(!strcmp(expect1, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+
+    SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text2);
+
+    SendMessage(hwndRichEdit, EM_SETSEL, 4, 11);
+    result = SendMessage(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffer);
+    ok(result == 7, "EM_GETTEXTRANGE returned %ld, expected %d\n",
+        result, strlen(expect2));
+    todo_wine {
+    ok(!strcmp(expect2, buffer), "EM_GETTEXTRANGE filled %s\n", buffer);
+    }
+
+    DestroyWindow(hwndRichEdit);
+}
+
 START_TEST( editor )
 {
   MSG msg;
@@ -475,6 +542,8 @@ START_TEST( editor )
   ok(hmoduleRichEdit != NULL, "error: %d\n", (int) GetLastError());
 
   test_WM_SETTEXT();
+  test_EM_GETTEXTRANGE();
+  test_EM_GETSELTEXT();
   test_WM_GETTEXTLENGTH();
   test_EM_STREAMIN();
   test_EM_STREAMOUT();




More information about the wine-cvs mailing list