richedit: GTL_PRECISE to GETTEXTLENGTHEX implies GTL_NUMBYTES.
David Hedberg
david.hedberg at gmail.com
Sat Feb 27 10:58:16 CST 2010
If GTL_PRECISE is passed without specifying either GTL_NUMCHARS or
GTL_NUMBYTES, behave as if GTL_NUMBYTES was passed.
Tested with winetestbot (#876), fixes bug #21857.
---
dlls/riched20/caret.c | 6 ++++--
dlls/riched20/tests/editor.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index abcc73e..a72a42b 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -91,8 +91,10 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
&& (how->flags & GTL_USECRLF)
&& !editor->bEmulateVersion10) /* Ignore GTL_USECRLF flag in 1.0 emulation */
length += editor->nParagraphs - 1;
-
- if (how->flags & GTL_NUMBYTES)
+
+ if (how->flags & GTL_NUMBYTES ||
+ (how->flags & GTL_PRECISE && /* GTL_PRECISE seems to imply GTL_NUMBYTES */
+ !(how->flags & GTL_NUMCHARS))) /* unless GTL_NUMCHARS is given */
{
CPINFO cpinfo;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 1fbdaa5..ee26683 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -5540,6 +5540,45 @@ static void test_EM_GETTEXTLENGTHEX(void)
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0);
ok(ret == 6, "ret %d\n",ret);
+ /* Unicode/NUMCHARS/NUMBYTES */
+ SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string_2);
+
+ gtl.flags = GTL_DEFAULT;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == lstrlen(test_string_2),
+ "GTL_DEFAULT gave %i, expected %i\n", ret, lstrlen(test_string_2));
+
+ gtl.flags = GTL_NUMCHARS;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == lstrlen(test_string_2),
+ "GTL_NUMCHARS gave %i, expected %i\n", ret, lstrlen(test_string_2));
+
+ gtl.flags = GTL_NUMBYTES;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == lstrlen(test_string_2)*2,
+ "GTL_NUMBYTES gave %i, expected %i\n", ret, lstrlen(test_string_2)*2);
+
+ gtl.flags = GTL_PRECISE;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == lstrlen(test_string_2)*2,
+ "GTL_PRECISE gave %i, expected %i\n", ret, lstrlen(test_string_2)*2);
+
+ gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == lstrlen(test_string_2),
+ "GTL_NUMCHAR | GTL_PRECISE gave %i, expected %i\n", ret, lstrlen(test_string_2));
+
+ gtl.flags = GTL_NUMCHARS | GTL_NUMBYTES;
+ gtl.codepage = 1200;
+ ret = SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM) >l, 0);
+ ok(ret == E_INVALIDARG,
+ "GTL_NUMCHARS | GTL_NUMBYTES gave %i, expected %i\n", ret, E_INVALIDARG);
+
DestroyWindow(hwnd);
}
--
1.7.0
More information about the wine-patches
mailing list