[PATCH] richedit: remove (now useless) 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.
Alex Villacís Lasso
alex at karlalex.palosanto.com
Sat Apr 26 21:16:41 CDT 2008
---
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 52715ac..fbd361e 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 fef94f0..56a23f6 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 8594548..33ad2af 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();
--
1.5.4.1
--------------040602090200030700040301--
More information about the wine-patches
mailing list