Commit 534398a5 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

richedit: GTL_PRECISE to GETTEXTLENGTHEX implies GTL_NUMBYTES.

If GTL_PRECISE is passed without specifying either GTL_NUMCHARS or GTL_NUMBYTES, behave as if GTL_NUMBYTES was passed.
parent 7ed13120
......@@ -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;
......
......@@ -5540,6 +5540,45 @@ static void test_EM_GETTEXTLENGTHEX(void)
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 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) &gtl, 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) &gtl, 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) &gtl, 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) &gtl, 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) &gtl, 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) &gtl, 0);
ok(ret == E_INVALIDARG,
"GTL_NUMCHARS | GTL_NUMBYTES gave %i, expected %i\n", ret, E_INVALIDARG);
DestroyWindow(hwnd);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment