riched20: EM_SETTEXTTEX obeys ST_SELECTION with RTF inputs.
This commit is contained in:
parent
12a6140280
commit
3a805d289e
|
@ -2308,7 +2308,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
|
||||||
style = ME_GetSelectionInsertStyle(editor);
|
style = ME_GetSelectionInsertStyle(editor);
|
||||||
ME_InternalDeleteText(editor, from, to - from);
|
ME_InternalDeleteText(editor, from, to - from);
|
||||||
if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5))
|
if (pStruct->codepage != 1200 && lParam && !strncmp((char *)lParam, "{\\rtf", 5))
|
||||||
ME_StreamInRTFString(editor, 0, (char *)lParam);
|
ME_StreamInRTFString(editor, 1, (char *)lParam);
|
||||||
else ME_InsertTextFromCursor(editor, 0, wszText, len, style);
|
else ME_InsertTextFromCursor(editor, 0, wszText, len, style);
|
||||||
ME_ReleaseStyle(style);
|
ME_ReleaseStyle(style);
|
||||||
|
|
||||||
|
|
|
@ -3180,6 +3180,12 @@ static void test_EM_SETTEXTEX(void)
|
||||||
WCHAR TestItem1[] = {'T', 'e', 's', 't',
|
WCHAR TestItem1[] = {'T', 'e', 's', 't',
|
||||||
'S', 'o', 'm', 'e',
|
'S', 'o', 'm', 'e',
|
||||||
'T', 'e', 'x', 't', 0};
|
'T', 'e', 'x', 't', 0};
|
||||||
|
WCHAR TestItem1alt[] = {'T', 'T', 'e', 's',
|
||||||
|
't', 'S', 'o', 'm',
|
||||||
|
'e', 'T', 'e', 'x',
|
||||||
|
't', 't', 'S', 'o',
|
||||||
|
'm', 'e', 'T', 'e',
|
||||||
|
'x', 't', 0};
|
||||||
WCHAR TestItem2[] = {'T', 'e', 's', 't',
|
WCHAR TestItem2[] = {'T', 'e', 's', 't',
|
||||||
'S', 'o', 'm', 'e',
|
'S', 'o', 'm', 'e',
|
||||||
'T', 'e', 'x', 't',
|
'T', 'e', 'x', 't',
|
||||||
|
@ -3208,6 +3214,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
' ','\r', 0};
|
' ','\r', 0};
|
||||||
#define MAX_BUF_LEN 1024
|
#define MAX_BUF_LEN 1024
|
||||||
WCHAR buf[MAX_BUF_LEN];
|
WCHAR buf[MAX_BUF_LEN];
|
||||||
|
char bufACP[MAX_BUF_LEN];
|
||||||
char * p;
|
char * p;
|
||||||
int result;
|
int result;
|
||||||
CHARRANGE cr;
|
CHARRANGE cr;
|
||||||
|
@ -3227,7 +3234,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
||||||
|
|
||||||
/* Unlike WM_SETTEXT/WM_GETTEXT pair, EM_SETTEXTEX/EM_GETTEXTEX does not
|
/* Unlike WM_SETTEXT/WM_GETTEXT pair, EM_SETTEXTEX/EM_GETTEXTEX does not
|
||||||
convert \r to \r\n on return
|
convert \r to \r\n on return: !ST_SELECTION && Unicode && !\rtf
|
||||||
*/
|
*/
|
||||||
setText.codepage = 1200; /* no constant for unicode */
|
setText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.codepage = 1200; /* no constant for unicode */
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
|
@ -3273,7 +3280,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
||||||
|
|
||||||
|
|
||||||
/* \r\n pairs get changed into \r */
|
/* \r\n pairs get changed into \r: !ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.codepage = 1200; /* no constant for unicode */
|
setText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.codepage = 1200; /* no constant for unicode */
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.cb = MAX_BUF_LEN;
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
@ -3286,7 +3293,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
ok(lstrcmpW(buf, TestItem3_after) == 0,
|
ok(lstrcmpW(buf, TestItem3_after) == 0,
|
||||||
"EM_SETTEXTEX did not convert properly\n");
|
"EM_SETTEXTEX did not convert properly\n");
|
||||||
|
|
||||||
/* \n also gets changed to \r */
|
/* \n also gets changed to \r: !ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.codepage = 1200; /* no constant for unicode */
|
setText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.codepage = 1200; /* no constant for unicode */
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.cb = MAX_BUF_LEN;
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
@ -3299,7 +3306,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
ok(lstrcmpW(buf, TestItem3_after) == 0,
|
ok(lstrcmpW(buf, TestItem3_after) == 0,
|
||||||
"EM_SETTEXTEX did not convert properly\n");
|
"EM_SETTEXTEX did not convert properly\n");
|
||||||
|
|
||||||
/* \r\r\n gets changed into single space */
|
/* \r\r\n gets changed into single space: !ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.codepage = 1200; /* no constant for unicode */
|
setText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.codepage = 1200; /* no constant for unicode */
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.cb = MAX_BUF_LEN;
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
@ -3312,6 +3319,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
ok(lstrcmpW(buf, TestItem4_after) == 0,
|
ok(lstrcmpW(buf, TestItem4_after) == 0,
|
||||||
"EM_SETTEXTEX did not convert properly\n");
|
"EM_SETTEXTEX did not convert properly\n");
|
||||||
|
|
||||||
|
/* !ST_SELECTION && Unicode && !\rtf */
|
||||||
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
||||||
(WPARAM)&setText, (LPARAM) NULL);
|
(WPARAM)&setText, (LPARAM) NULL);
|
||||||
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
|
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
|
||||||
|
@ -3321,14 +3329,14 @@ static void test_EM_SETTEXTEX(void)
|
||||||
ok(lstrlenW(buf) == 0,
|
ok(lstrlenW(buf) == 0,
|
||||||
"EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
|
"EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
|
||||||
|
|
||||||
/* put some text back */
|
/* put some text back: !ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.flags = 0;
|
setText.flags = 0;
|
||||||
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) TestItem1);
|
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) TestItem1);
|
||||||
/* select some text */
|
/* select some text */
|
||||||
cr.cpMax = 1;
|
cr.cpMax = 1;
|
||||||
cr.cpMin = 3;
|
cr.cpMin = 3;
|
||||||
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
||||||
/* replace current selection */
|
/* replace current selection: ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.flags = ST_SELECTION;
|
setText.flags = ST_SELECTION;
|
||||||
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
||||||
(WPARAM)&setText, (LPARAM) NULL);
|
(WPARAM)&setText, (LPARAM) NULL);
|
||||||
|
@ -3337,14 +3345,14 @@ static void test_EM_SETTEXTEX(void)
|
||||||
" with no text should return 0. Got %i\n",
|
" with no text should return 0. Got %i\n",
|
||||||
result);
|
result);
|
||||||
|
|
||||||
/* put some text back */
|
/* put some text back: !ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.flags = 0;
|
setText.flags = 0;
|
||||||
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) TestItem1);
|
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) TestItem1);
|
||||||
/* select some text */
|
/* select some text */
|
||||||
cr.cpMax = 1;
|
cr.cpMax = 1;
|
||||||
cr.cpMin = 3;
|
cr.cpMin = 3;
|
||||||
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
||||||
/* replace current selection */
|
/* replace current selection: ST_SELECTION && Unicode && !\rtf */
|
||||||
setText.flags = ST_SELECTION;
|
setText.flags = ST_SELECTION;
|
||||||
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
result = SendMessage(hwndRichEdit, EM_SETTEXTEX,
|
||||||
(WPARAM)&setText, (LPARAM) TestItem1);
|
(WPARAM)&setText, (LPARAM) TestItem1);
|
||||||
|
@ -3369,6 +3377,7 @@ static void test_EM_SETTEXTEX(void)
|
||||||
(WPARAM)(SF_RTF), (LPARAM)&es);
|
(WPARAM)(SF_RTF), (LPARAM)&es);
|
||||||
trace("EM_STREAMOUT produced: \n%s\n", (char *)buf);
|
trace("EM_STREAMOUT produced: \n%s\n", (char *)buf);
|
||||||
|
|
||||||
|
/* !ST_SELECTION && !Unicode && \rtf */
|
||||||
setText.codepage = CP_ACP;/* EM_STREAMOUT saved as ANSI string */
|
setText.codepage = CP_ACP;/* EM_STREAMOUT saved as ANSI string */
|
||||||
getText.codepage = 1200; /* no constant for unicode */
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
getText.cb = MAX_BUF_LEN;
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
@ -3382,6 +3391,66 @@ static void test_EM_SETTEXTEX(void)
|
||||||
ok(lstrcmpW(buf, TestItem1) == 0,
|
ok(lstrcmpW(buf, TestItem1) == 0,
|
||||||
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
|
||||||
|
|
||||||
|
/* The following test demonstrates that EM_SETTEXTEX supports RTF strings with a selection */
|
||||||
|
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) "TestSomeText"); /* TestItem1 */
|
||||||
|
p = (char *)buf;
|
||||||
|
es.dwCookie = (DWORD_PTR)&p;
|
||||||
|
es.dwError = 0;
|
||||||
|
es.pfnCallback = test_WM_SETTEXT_esCallback;
|
||||||
|
memset(buf, 0, sizeof(buf));
|
||||||
|
SendMessage(hwndRichEdit, EM_STREAMOUT,
|
||||||
|
(WPARAM)(SF_RTF), (LPARAM)&es);
|
||||||
|
trace("EM_STREAMOUT produced: \n%s\n", (char *)buf);
|
||||||
|
|
||||||
|
/* select some text */
|
||||||
|
cr.cpMax = 1;
|
||||||
|
cr.cpMin = 3;
|
||||||
|
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
||||||
|
|
||||||
|
/* ST_SELECTION && !Unicode && \rtf */
|
||||||
|
setText.codepage = CP_ACP;/* EM_STREAMOUT saved as ANSI string */
|
||||||
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
getText.flags = GT_DEFAULT;
|
||||||
|
getText.lpDefaultChar = NULL;
|
||||||
|
getText.lpUsedDefChar = NULL;
|
||||||
|
|
||||||
|
setText.flags = ST_SELECTION;
|
||||||
|
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) buf);
|
||||||
|
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
|
||||||
|
ok(lstrcmpW(buf, TestItem1alt) == 0,
|
||||||
|
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX when"
|
||||||
|
" using ST_SELECTION on an RTF string and non-Unicode\n");
|
||||||
|
|
||||||
|
/* The following test demonstrates that EM_SETTEXTEX replacing a selection */
|
||||||
|
setText.codepage = 1200; /* no constant for unicode */
|
||||||
|
getText.codepage = CP_ACP;
|
||||||
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
|
||||||
|
setText.flags = 0;
|
||||||
|
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) TestItem1); /* TestItem1 */
|
||||||
|
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) bufACP);
|
||||||
|
|
||||||
|
/* select some text */
|
||||||
|
cr.cpMax = 1;
|
||||||
|
cr.cpMin = 3;
|
||||||
|
SendMessage(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM) &cr);
|
||||||
|
|
||||||
|
/* ST_SELECTION && !Unicode && !\rtf */
|
||||||
|
setText.codepage = CP_ACP;
|
||||||
|
getText.codepage = 1200; /* no constant for unicode */
|
||||||
|
getText.cb = MAX_BUF_LEN;
|
||||||
|
getText.flags = GT_DEFAULT;
|
||||||
|
getText.lpDefaultChar = NULL;
|
||||||
|
getText.lpUsedDefChar = NULL;
|
||||||
|
|
||||||
|
setText.flags = ST_SELECTION;
|
||||||
|
SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM) bufACP);
|
||||||
|
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
|
||||||
|
ok(lstrcmpW(buf, TestItem1alt) == 0,
|
||||||
|
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX when"
|
||||||
|
" using ST_SELECTION and non-Unicode\n");
|
||||||
|
|
||||||
|
|
||||||
DestroyWindow(hwndRichEdit);
|
DestroyWindow(hwndRichEdit);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue