Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- This series includes a patch superseded patch 205182. --- dlls/riched20/tests/richole.c | 144 ++++++++++++---------------------- 1 file changed, 48 insertions(+), 96 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index e6329c5b1b6..0fab1106a29 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3212,11 +3212,18 @@ static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, reobj->dwUser = user; }
-#define CHECK_REOBJECT_STRUCT(reobj,poleobj,pstg,polesite,user) \ - _check_reobject_struct(reobj, poleobj, pstg, polesite, user, __LINE__) -static void _check_reobject_struct(REOBJECT reobj, LPOLEOBJECT poleobj, LPSTORAGE pstg, - LPOLECLIENTSITE polesite, DWORD user, int line) +#define CHECK_REOBJECT_STRUCT(reole,index,flags,cp,poleobj,pstg,polesite,user) \ + _check_reobject_struct(reole, index, flags, cp, poleobj, pstg, polesite, user, __LINE__) +static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, LONG cp, + LPOLEOBJECT poleobj, LPSTORAGE pstg, LPOLECLIENTSITE polesite, DWORD user, int line) { + REOBJECT reobj; + HRESULT hr; + + reobj.cbStruct = sizeof(reobj); + reobj.cp = cp; + hr = IRichEditOle_GetObject(reole, index, &reobj, flags); + ok(hr == S_OK, "IRichEditOle_GetObject failed: %#x.\n", hr); ok_(__FILE__,line)(reobj.poleobj == poleobj, "got wrong object interface.\n"); ok_(__FILE__,line)(reobj.pstg == pstg, "got wrong storage interface.\n"); ok_(__FILE__,line)(reobj.polesite == polesite, "got wrong site interface.\n"); @@ -3229,7 +3236,7 @@ static void test_InsertObject(void) IRichEditOle *reole = NULL; ITextDocument *doc = NULL; IOleClientSite *clientsite; - REOBJECT reo1, reo2, reo3, received_reo1, received_reo2, received_reo3, received_reo4; + REOBJECT reo1, reo2, reo3, received_reo; HRESULT hr; HWND hwnd; LONG count; @@ -3274,132 +3281,77 @@ static void test_InsertObject(void) IOleClientSite_Release(clientsite);
/* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */ - received_reo1.cbStruct = sizeof(received_reo1); - hr = IRichEditOle_GetObject(reole, 0, &received_reo1, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo1, NULL, NULL, reo1.polesite, 1); - - received_reo2.cbStruct = sizeof(received_reo2); - hr = IRichEditOle_GetObject(reole, 1, &received_reo2, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo2, NULL, NULL, reo3.polesite, 3); - - received_reo3.cbStruct = sizeof(received_reo3); - hr = IRichEditOle_GetObject(reole, 2, &received_reo3, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo3, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, 0, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, 1, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2);
hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- received_reo4.cbStruct = 0; - hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + received_reo.cbStruct = 0; + hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- received_reo4.cbStruct = sizeof(received_reo4); - hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_PSTG); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_PSTG, 0, NULL, NULL, NULL, 2); + CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_POLESITE, 0, NULL, NULL, reo2.polesite, 2);
- hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_POLESITE); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); - - hr = IRichEditOle_GetObject(reole, 3, &received_reo4, REO_GETOBJ_POLESITE); + hr = IRichEditOle_GetObject(reole, 3, &received_reo, REO_GETOBJ_POLESITE); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- hr = IRichEditOle_GetObject(reole, 4, &received_reo4, REO_GETOBJ_POLESITE); + hr = IRichEditOle_GetObject(reole, 4, &received_reo, REO_GETOBJ_POLESITE); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- hr = IRichEditOle_GetObject(reole, 1024, &received_reo4, REO_GETOBJ_POLESITE); + hr = IRichEditOle_GetObject(reole, 1024, &received_reo, REO_GETOBJ_POLESITE); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- hr = IRichEditOle_GetObject(reole, -10, &received_reo4, REO_GETOBJ_POLESITE); + hr = IRichEditOle_GetObject(reole, -10, &received_reo, REO_GETOBJ_POLESITE); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- /* received_reo4 will be zeroed before be used */ - hr = IRichEditOle_GetObject(reole, 2, &received_reo4, REO_GETOBJ_NO_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, NULL, 2); - - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); - - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 1; - hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + /* received_reo will be zeroed before be used */ + received_reo.cbStruct = sizeof(received_reo); + received_reo.polesite = (IOleClientSite *)0xdeadbeef; + hr = IRichEditOle_GetObject(reole, 2, &received_reo, REO_GETOBJ_NO_INTERFACES); ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3); + ok(received_reo.polesite == (IOleClientSite *)NULL, "Got wrong site interface.\n");
- received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 2; - hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_USE_CP, REO_GETOBJ_ALL_INTERFACES, 2, NULL, NULL, reo2.polesite, 2);
- received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 4; - hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + received_reo.cbStruct = sizeof(received_reo); + received_reo.polesite = (IOleClientSite *)0xdeadbeef; + received_reo.dwUser = 4; + received_reo.cp = 4; + hr = IRichEditOle_GetObject(reole, REO_IOB_USE_CP, &received_reo, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); - /* received_reo4 didn't be zeroed in E_INVALIDARG case */ - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); + ok(received_reo.polesite == (IOleClientSite *)0xdeadbeef, "Got wrong site interface.\n"); + ok(received_reo.dwUser == 4, "Got wrong user-defined value: %d.\n", received_reo.dwUser);
SendMessageA(hwnd, EM_SETSEL, 0, 1); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 1; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
SendMessageA(hwnd, EM_SETSEL, 1, 2); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3);
SendMessageA(hwnd, EM_SETSEL, 2, 3); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2);
SendMessageA(hwnd, EM_SETSEL, 0, 2); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
SendMessageA(hwnd, EM_SETSEL, 1, 3); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo3.polesite, 3); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3);
SendMessageA(hwnd, EM_SETSEL, 2, 0); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
SendMessageA(hwnd, EM_SETSEL, 0, 6); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); - ok(hr == S_OK, "IRichEditOle_GetObject failed: 0x%08x\n", hr); - CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo1.polesite, 1); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
SendMessageA(hwnd, EM_SETSEL, 4, 5); - received_reo4.cbStruct = sizeof(received_reo4); - received_reo4.cp = 0; - hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo4, REO_GETOBJ_ALL_INTERFACES); + received_reo.cbStruct = sizeof(received_reo); + received_reo.cp = 0; + hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
release_interfaces(&hwnd, &reole, &doc, NULL);
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/richole.c | 36 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 0fab1106a29..9f463fd69e0 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3230,12 +3230,25 @@ static void _check_reobject_struct(IRichEditOle *reole, LONG index, DWORD flags, ok_(__FILE__,line)(reobj.dwUser == user, "got wrong user-defined value.\n"); }
+#define INSERT_REOBJECT(reole,reobj,cp,user) \ + _insert_reobject(reole, reobj, cp, user, __LINE__) +static void _insert_reobject(IRichEditOle *reole, REOBJECT *reobj, LONG cp, DWORD user, int line) +{ + IOleClientSite *clientsite; + HRESULT hr; + hr = IRichEditOle_GetClientSite(reole, &clientsite); + ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_GetClientSite got hr %#x.\n", hr); + fill_reobject_struct(reobj, cp, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, user); + hr = IRichEditOle_InsertObject(reole, reobj); + ok_(__FILE__,line)(hr == S_OK, "IRichEditOle_InsertObject got hr %#x.\n", hr); + IOleClientSite_Release(clientsite); +} + static void test_InsertObject(void) { static CHAR test_text1[] = "abcdefg"; IRichEditOle *reole = NULL; ITextDocument *doc = NULL; - IOleClientSite *clientsite; REOBJECT reo1, reo2, reo3, received_reo; HRESULT hr; HWND hwnd; @@ -3249,36 +3262,21 @@ static void test_InsertObject(void)
/* insert object1 in (0, 1)*/ SendMessageA(hwnd, EM_SETSEL, 0, 1); - hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr); - fill_reobject_struct(&reo1, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); - hr = IRichEditOle_InsertObject(reole, &reo1); - ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr); + INSERT_REOBJECT(reole, &reo1, REO_CP_SELECTION, 1); count = IRichEditOle_GetObjectCount(reole); ok(count == 1, "got wrong object count: %d\n", count); - IOleClientSite_Release(clientsite);
/* insert object2 in (2, 3)*/ SendMessageA(hwnd, EM_SETSEL, 2, 3); - hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr); - fill_reobject_struct(&reo2, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 2); - hr = IRichEditOle_InsertObject(reole, &reo2); - ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr); + INSERT_REOBJECT(reole, &reo2, REO_CP_SELECTION, 2); count = IRichEditOle_GetObjectCount(reole); ok(count == 2, "got wrong object count: %d\n", count); - IOleClientSite_Release(clientsite);
/* insert object3 in (1, 2)*/ SendMessageA(hwnd, EM_SETSEL, 1, 2); - hr = IRichEditOle_GetClientSite(reole, &clientsite); - ok(hr == S_OK, "IRichEditOle_GetClientSite failed: 0x%08x\n", hr); - fill_reobject_struct(&reo3, REO_CP_SELECTION, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 3); - hr = IRichEditOle_InsertObject(reole, &reo3); - ok(hr == S_OK, "IRichEditOle_InsertObject failed: 0x%08x\n", hr); + INSERT_REOBJECT(reole, &reo3, REO_CP_SELECTION, 3); count = IRichEditOle_GetObjectCount(reole); ok(count == 3, "got wrong object count: %d\n", count); - IOleClientSite_Release(clientsite);
/* tests below show that order of rebject (from 0 to 2) is: reo1,reo3,reo2 */ CHECK_REOBJECT_STRUCT(reole, 0, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo1.polesite, 1);
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/richole.c | 180 +++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 9f463fd69e0..c2457ae5146 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3252,9 +3252,22 @@ static void test_InsertObject(void) REOBJECT reo1, reo2, reo3, received_reo; HRESULT hr; HWND hwnd; - LONG count; + const WCHAR *expected_string; + const CHAR *expected_stringA; + ITextSelection *selection; + IDataObject *dataobject; + TEXTRANGEA textrange; + FORMATETC formatetc; + CHARRANGE charrange; + GETTEXTEX gettextex; + STGMEDIUM stgmedium; + WCHAR buffer[1024]; + CHAR bufferA[1024]; + LONG count, result; + ITextRange *range; + BSTR bstr;
- create_interfaces(&hwnd, &reole, &doc, NULL); + create_interfaces(&hwnd, &reole, &doc, &selection); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1);
hr = IRichEditOle_InsertObject(reole, NULL); @@ -3352,7 +3365,168 @@ static void test_InsertObject(void) hr = IRichEditOle_GetObject(reole, REO_IOB_SELECTION, &received_reo, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);
- release_interfaces(&hwnd, &reole, &doc, NULL); + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); + + /* "abc|d|efg" */ + INSERT_REOBJECT(reole, &reo1, 3, 1); + INSERT_REOBJECT(reole, &reo2, 5, 2); + + SendMessageW(hwnd, EM_SETSEL, 2, 3); + result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); + ok(result == SEL_TEXT, "Got selection type: %x.\n", result); + + SendMessageW(hwnd, EM_SETSEL, 3, 4); + result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); + todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); + todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1); + + SendMessageW(hwnd, EM_SETSEL, 2, 4); + result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); + todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result); + + SendMessageW(hwnd, EM_SETSEL, 5, 6); + todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2); + + expected_string = L"abc\xfffc""d\xfffc""efg"; + gettextex.cb = sizeof(buffer); + gettextex.flags = GT_DEFAULT; + gettextex.codepage = 1200; + gettextex.lpDefaultChar = NULL; + gettextex.lpUsedDefChar = NULL; + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + gettextex.flags = GT_RAWTEXT; + memset(buffer, 0, sizeof(buffer)); + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + expected_stringA = "abc d efg"; + memset(bufferA, 0, sizeof(bufferA)); + SendMessageA(hwnd, EM_SETSEL, 0, -1); + result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); + ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); + todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + + memset(bufferA, 0, sizeof(bufferA)); + textrange.lpstrText = bufferA; + textrange.chrg.cpMin = 0; + textrange.chrg.cpMax = 11; + result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); + ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); + todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + + expected_string = L"abc\xfffc""d\xfffc""efg\r"; + hr = ITextDocument_Range(doc, 0, 11, &range); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITextRange_GetText(range, &bstr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); + todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + hr = ITextRange_SetRange(range, 3, 4); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITextRange_GetChar(range, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ITextRange_Release(range); + + SendMessageW(hwnd, EM_SETSEL, 0, -1); + hr = ITextSelection_GetText(selection, &bstr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); + todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + SendMessageW(hwnd, EM_SETSEL, 3, 4); + result = 0; + hr = ITextSelection_GetChar(selection, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); + result = SendMessageW(hwnd, EM_SETTEXTMODE, (WPARAM)TM_PLAINTEXT, 0); + ok(!result, "Got result %x.\n", result); + /* "abc|d|efg" */ + SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)test_text1); + INSERT_REOBJECT(reole, &reo1, 3, 1); + INSERT_REOBJECT(reole, &reo2, 5, 2); + + expected_string = L"abc d efg"; + charrange.cpMin = 0; + charrange.cpMax = 11; + hr = IRichEditOle_GetClipboardData(reole, &charrange, 1, &dataobject); + ok(hr == S_OK, "Got hr %#x.\n", hr); + formatetc.cfFormat = CF_UNICODETEXT; + formatetc.dwAspect = DVASPECT_CONTENT; + formatetc.ptd = NULL; + formatetc.tymed = TYMED_HGLOBAL; + formatetc.lindex = -1; + hr = IDataObject_GetData(dataobject, &formatetc, &stgmedium); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(lstrlenW(stgmedium.hGlobal) == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + todo_wine ok(!lstrcmpW(stgmedium.hGlobal, expected_string), "Got wrong content: %s.\n", debugstr_w(stgmedium.hGlobal)); + + expected_string = L"abc\xfffc""d\xfffc""efg"; + gettextex.cb = sizeof(buffer); + gettextex.flags = GT_DEFAULT; + gettextex.codepage = 1200; + gettextex.lpDefaultChar = NULL; + gettextex.lpUsedDefChar = NULL; + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + gettextex.flags = GT_RAWTEXT; + memset(buffer, 0, sizeof(buffer)); + result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); + ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); + todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + + expected_stringA = "abc d efg"; + memset(bufferA, 0, sizeof(bufferA)); + SendMessageA(hwnd, EM_SETSEL, 0, -1); + result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); + ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); + todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + + memset(bufferA, 0, sizeof(bufferA)); + textrange.lpstrText = bufferA; + textrange.chrg.cpMin = 0; + textrange.chrg.cpMax = 11; + result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); + ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); + todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + + expected_string = L"abc\xfffc""d\xfffc""efg"; + hr = ITextDocument_Range(doc, 0, 11, &range); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITextRange_GetText(range, &bstr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); + todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + hr = ITextRange_SetRange(range, 3, 4); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = ITextRange_GetChar(range, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ITextRange_Release(range); + + SendMessageW(hwnd, EM_SETSEL, 0, -1); + hr = ITextSelection_GetText(selection, &bstr); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); + todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + SysFreeString(bstr); + SendMessageW(hwnd, EM_SETSEL, 3, 4); + result = 0; + hr = ITextSelection_GetChar(selection, &result); + ok(hr == S_OK, "Got hr %#x.\n", hr); + todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + + release_interfaces(&hwnd, &reole, &doc, &selection); }
static void test_GetStoryLength(void)
It would be good to also adding test of result from IRichEditOle_GetClipboardData() in TM_RICHTEXT mode, but unfortunately Wine's TM_RICHTEXT has some other issues which cause a crash in TM_RICHTEXT mode. Let's add it after we get the issue fixed. I have tested it on Windows, it returned the same result as from plain text mode: https://testbot.winehq.org/JobDetails.pl?Key=90900
On 5/20/21 3:56 PM, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/riched20/tests/richole.c | 180 +++++++++++++++++++++++++++++++++- 1 file changed, 177 insertions(+), 3 deletions(-)
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/txtsrv.c | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index fe27be26edb..1f789da8a37 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -650,9 +650,30 @@ static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret) return TRUE; }
+static void fill_reobject_struct(REOBJECT *reobj, LONG cp, LPOLEOBJECT poleobj, + LPSTORAGE pstg, LPOLECLIENTSITE polesite, LONG sizel_cx, + LONG sizel_cy, DWORD aspect, DWORD flags, DWORD user) +{ + reobj->cbStruct = sizeof(*reobj); + reobj->clsid = CLSID_NULL; + reobj->cp = cp; + reobj->poleobj = poleobj; + reobj->pstg = pstg; + reobj->polesite = polesite; + reobj->sizel.cx = sizel_cx; + reobj->sizel.cy = sizel_cy; + reobj->dvaspect = aspect; + reobj->dwFlags = flags; + reobj->dwUser = user; +} + static void test_TxGetText(void) { + const WCHAR *expected_string; + IOleClientSite *clientsite; ITextServices *txtserv; + IRichEditOle *reole; + REOBJECT reobject; ITextHost *host; HRESULT hres; BSTR rettext; @@ -664,6 +685,24 @@ static void test_TxGetText(void) ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); SysFreeString(rettext);
+ hres = ITextServices_TxSetText(txtserv, L"abcdefg"); + ok(hres == S_OK, "Got hres: %#x.\n", hres); + hres = ITextServices_QueryInterface(txtserv, &IID_IRichEditOle, (void **)&reole); + ok(hres == S_OK, "Got hres: %#x.\n", hres); + hres = IRichEditOle_GetClientSite(reole, &clientsite); + ok(hres == S_OK, "Got hres: %#x.\n", hres); + expected_string = L"abc\xfffc""defg"; + fill_reobject_struct(&reobject, 3, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1); + hres = IRichEditOle_InsertObject(reole, &reobject); + ok(hres == S_OK, "Got hres: %#x.\n", hres); + hres = ITextServices_TxGetText(txtserv, &rettext); + ok(hres == S_OK, "Got hres: %#x.\n", hres); + ok(lstrlenW(rettext) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(rettext)); + todo_wine ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); + SysFreeString(rettext); + IOleClientSite_Release(clientsite); + IRichEditOle_Release(reole); + ITextServices_Release(txtserv); ITextHost_Release(host); }
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/tests/txtsrv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 1f789da8a37..741e3d0baf2 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1169,6 +1169,11 @@ static void test_notifications( void ) HRESULT hr; RECT client = { 0, 0, 100, 100 }; ITextHostTestImpl *host_impl; + const WCHAR *expected_string; + IOleClientSite *clientsite; + IRichEditOle *reole; + WCHAR buffer[1024]; + REOBJECT reobject;
init_texthost( &txtserv, &host ); host_impl = impl_from_ITextHost( host ); @@ -1212,6 +1217,23 @@ static void test_notifications( void ) ok( hr == S_OK, "got %08x\n", hr ); ok( en_update_sent == 1, "got %d\n", en_update_sent );
+ expected_string = L"abc defg"; + hr = ITextServices_TxSetText( txtserv, L"abcdefg" ); + ok( hr == S_OK, "Got hr: %#x.\n", hr ); + hr = ITextServices_QueryInterface( txtserv, &IID_IRichEditOle, (void **)&reole ); + ok( hr == S_OK, "Got hr: %#x.\n", hr ); + hr = IRichEditOle_GetClientSite( reole, &clientsite ); + ok( hr == S_OK, "Got hr: %#x.\n", hr ); + fill_reobject_struct( &reobject, 3, NULL, NULL, clientsite, 10, 10, DVASPECT_CONTENT, 0, 1 ); + hr = IRichEditOle_InsertObject( reole, &reobject ); + ok( hr == S_OK, "Got hr: %#x.\n", hr ); + hr = ITextServices_TxSendMessage( txtserv, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer, &res ); + ok( hr == S_OK, "Got hr %#x.\n", hr ); + ok( lstrlenW( buffer ) == lstrlenW( expected_string ), "Got wrong length: %d.\n", lstrlenW( buffer ) ); + todo_wine ok( !lstrcmpW( buffer, expected_string ), "Got wrong content: %s.\n", debugstr_w( buffer ) ); + IOleClientSite_Release( clientsite ); + IRichEditOle_Release( reole ); + DestroyWindow( host_impl->window ); ITextServices_Release( txtserv ); ITextHost_Release( host );
On Thu, May 20, 2021 at 03:56:13PM +0800, Jactry Zeng wrote:
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
dlls/riched20/tests/txtsrv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 1f789da8a37..741e3d0baf2 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1169,6 +1169,11 @@ static void test_notifications( void ) HRESULT hr; RECT client = { 0, 0, 100, 100 }; ITextHostTestImpl *host_impl;
- const WCHAR *expected_string;
- IOleClientSite *clientsite;
- IRichEditOle *reole;
- WCHAR buffer[1024];
- REOBJECT reobject;
This should be moved to a new function since it has nothing to do with notifications. Something like test_TxSendMessage_gettext(). You might as well also test sending EM_GETTEXTEX while you're at it (in the same function).
Huw.
--- dlls/riched20/caret.c | 14 +++++++++++--- dlls/riched20/tests/richole.c | 16 ++++++++-------- dlls/riched20/tests/txtsrv.c | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 1f4c3903a38..3104178082a 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -460,10 +460,18 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur ME_Run *run, *prev; const WCHAR space = ' '; struct re_object *reobj_prev = NULL; - ME_Cursor *cursor = editor->pCursors + nCursor; - ME_Style *style = style_get_insert_style( editor, cursor ); + ME_Cursor *cursor, cursor_from_ofs; + ME_Style *style; + + if (reo->cp == REO_CP_SELECTION) + cursor = editor->pCursors + nCursor; + else + { + cursor_from_char_ofs( editor, reo->cp, &cursor_from_ofs ); + cursor = &cursor_from_ofs; + } + style = style_get_insert_style( editor, cursor );
- /* FIXME no no no */ if (ME_IsSelection(editor)) ME_DeleteSelection(editor);
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index c2457ae5146..a50a4aff26b 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3377,15 +3377,15 @@ static void test_InsertObject(void)
SendMessageW(hwnd, EM_SETSEL, 3, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1); + ok(result == SEL_OBJECT, "Got selection type: %x.\n", result); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1);
SendMessageW(hwnd, EM_SETSEL, 2, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0); - todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result); + ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result);
SendMessageW(hwnd, EM_SETSEL, 5, 6); - todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2); + CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2);
expected_string = L"abc\xfffc""d\xfffc""efg"; gettextex.cb = sizeof(buffer); @@ -3408,7 +3408,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; @@ -3416,7 +3416,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg\r"; hr = ITextDocument_Range(doc, 0, 11, &range); @@ -3489,7 +3489,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA; @@ -3497,7 +3497,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result); - todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA); + ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg"; hr = ITextDocument_Range(doc, 0, 11, &range); diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 741e3d0baf2..08db02517f5 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1230,7 +1230,7 @@ static void test_notifications( void ) hr = ITextServices_TxSendMessage( txtserv, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer, &res ); ok( hr == S_OK, "Got hr %#x.\n", hr ); ok( lstrlenW( buffer ) == lstrlenW( expected_string ), "Got wrong length: %d.\n", lstrlenW( buffer ) ); - todo_wine ok( !lstrcmpW( buffer, expected_string ), "Got wrong content: %s.\n", debugstr_w( buffer ) ); + ok( !lstrcmpW( buffer, expected_string ), "Got wrong content: %s.\n", debugstr_w( buffer ) ); IOleClientSite_Release( clientsite ); IRichEditOle_Release( reole );
Signed-off-by: Jactry Zeng jzeng@codeweavers.com
On 5/20/21 3:56 PM, Jactry Zeng wrote:
dlls/riched20/caret.c | 14 +++++++++++--- dlls/riched20/tests/richole.c | 16 ++++++++-------- dlls/riched20/tests/txtsrv.c | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 1f4c3903a38..3104178082a 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -460,10 +460,18 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur ME_Run *run, *prev; const WCHAR space = ' '; struct re_object *reobj_prev = NULL;
- ME_Cursor *cursor = editor->pCursors + nCursor;
- ME_Style *style = style_get_insert_style( editor, cursor );
- ME_Cursor *cursor, cursor_from_ofs;
- ME_Style *style;
- if (reo->cp == REO_CP_SELECTION)
- cursor = editor->pCursors + nCursor;
- else
- {
- cursor_from_char_ofs( editor, reo->cp, &cursor_from_ofs );
- cursor = &cursor_from_ofs;
- }
- style = style_get_insert_style( editor, cursor );
- /* FIXME no no no */ if (ME_IsSelection(editor)) ME_DeleteSelection(editor);
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index c2457ae5146..a50a4aff26b 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3377,15 +3377,15 @@ static void test_InsertObject(void)
SendMessageW(hwnd, EM_SETSEL, 3, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0);
- todo_wine ok(result == SEL_OBJECT, "Got selection type: %x.\n", result);
- todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1);
ok(result == SEL_OBJECT, "Got selection type: %x.\n", result);
CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo1.polesite, 1);
SendMessageW(hwnd, EM_SETSEL, 2, 4); result = SendMessageW(hwnd, EM_SELECTIONTYPE, 0, 0);
- todo_wine ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result);
ok(result == (SEL_TEXT | SEL_OBJECT), "Got selection type: %x.\n", result);
SendMessageW(hwnd, EM_SETSEL, 5, 6);
- todo_wine CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2);
CHECK_REOBJECT_STRUCT(reole, REO_IOB_SELECTION, REO_GETOBJ_ALL_INTERFACES, 1, NULL, NULL, reo2.polesite, 2);
expected_string = L"abc\xfffc""d\xfffc""efg"; gettextex.cb = sizeof(buffer);
@@ -3408,7 +3408,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
- todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content:
%s.\n", bufferA);
ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA;
@@ -3416,7 +3416,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
- todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content:
%s.\n", bufferA);
ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg\r"; hr = ITextDocument_Range(doc, 0, 11, &range);
@@ -3489,7 +3489,7 @@ static void test_InsertObject(void) SendMessageA(hwnd, EM_SETSEL, 0, -1); result = SendMessageA(hwnd, EM_GETSELTEXT, (WPARAM)sizeof(bufferA), (LPARAM)bufferA); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
- todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content:
%s.\n", bufferA);
ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
memset(bufferA, 0, sizeof(bufferA)); textrange.lpstrText = bufferA;
@@ -3497,7 +3497,7 @@ static void test_InsertObject(void) textrange.chrg.cpMax = 11; result = SendMessageA(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&textrange); ok(result == strlen(expected_stringA), "Got wrong length: %d.\n", result);
- todo_wine ok(!strcmp(bufferA, expected_stringA), "Got wrong content:
%s.\n", bufferA);
ok(!strcmp(bufferA, expected_stringA), "Got wrong content: %s.\n", bufferA);
expected_string = L"abc\xfffc""d\xfffc""efg"; hr = ITextDocument_Range(doc, 0, 11, &range);
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 741e3d0baf2..08db02517f5 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -1230,7 +1230,7 @@ static void test_notifications( void ) hr = ITextServices_TxSendMessage( txtserv, WM_GETTEXT, sizeof(buffer), (LPARAM)buffer, &res ); ok( hr == S_OK, "Got hr %#x.\n", hr ); ok( lstrlenW( buffer ) == lstrlenW( expected_string ), "Got wrong length: %d.\n", lstrlenW( buffer ) );
- todo_wine ok( !lstrcmpW( buffer, expected_string ), "Got wrong content: %s.\n", debugstr_w( buffer ) );
- ok( !lstrcmpW( buffer, expected_string ), "Got wrong content: %s.\n", debugstr_w( buffer ) ); IOleClientSite_Release( clientsite ); IRichEditOle_Release( reole );
Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/clipboard.c | 2 +- dlls/riched20/editor.c | 23 ++++++++++++++--------- dlls/riched20/editor.h | 2 +- dlls/riched20/richole.c | 6 +++--- dlls/riched20/tests/richole.c | 20 ++++++++++---------- dlls/riched20/tests/txtsrv.c | 2 +- dlls/riched20/txtsrv.c | 2 +- 7 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/dlls/riched20/clipboard.c b/dlls/riched20/clipboard.c index 10a814214be..c7abdeba6a3 100644 --- a/dlls/riched20/clipboard.c +++ b/dlls/riched20/clipboard.c @@ -354,7 +354,7 @@ static HGLOBAL get_unicode_text(ME_TextEditor *editor, const ME_Cursor *start, i
ret = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * (nChars + pars + 1)); data = GlobalLock(ret); - ME_GetTextW(editor, data, nChars + pars, start, nChars, TRUE, FALSE); + ME_GetTextW(editor, data, nChars + pars, start, nChars, TRUE, FALSE, FALSE); GlobalUnlock(ret); return ret; } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index d4aadc325f9..c267832fa58 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -1750,7 +1750,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre set_selection_cursors(editor, newto, newto);
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE); - ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE); + ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE, FALSE); if (lastchar[0] == '\r' && (lastchar[1] == '\n' || lastchar[1] == '\0')) { ME_InternalDeleteText(editor, &linebreakCursor, linebreakSize, FALSE); } @@ -2076,7 +2076,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH return -1; }
-static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) +static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText, BOOL object) { int nChars; ME_Cursor start; @@ -2101,7 +2101,7 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) if (ex->codepage == CP_UNICODE) { return ME_GetTextW(editor, (LPWSTR)pText, ex->cb / sizeof(WCHAR) - 1, - &start, nChars, ex->flags & GT_USECRLF, FALSE); + &start, nChars, ex->flags & GT_USECRLF, FALSE, object); } else { @@ -2118,7 +2118,7 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText) buflen = min(crlfmul * nChars, ex->cb - 1); buffer = heap_alloc((buflen + 1) * sizeof(WCHAR));
- nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE); + nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE, object); rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1, (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar); if (rc) rc--; /* do not count 0 terminator */ @@ -2132,7 +2132,7 @@ static int get_text_range( ME_TextEditor *editor, WCHAR *buffer, const ME_Cursor *start, int len ) { if (!buffer) return 0; - return ME_GetTextW( editor, buffer, INT_MAX, start, len, FALSE, FALSE ); + return ME_GetTextW( editor, buffer, INT_MAX, start, len, FALSE, FALSE, FALSE ); }
int set_selection( ME_TextEditor *editor, int to, int from ) @@ -3662,10 +3662,10 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, ex.codepage = CP_UNICODE; ex.lpDefaultChar = NULL; ex.lpUsedDefChar = NULL; - return ME_GetTextEx(editor, &ex, lParam); + return ME_GetTextEx(editor, &ex, lParam, FALSE); } case EM_GETTEXTEX: - return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam); + return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam, TRUE); case EM_GETSELTEXT: { int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo); @@ -4247,7 +4247,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, */ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF, - BOOL bEOP) + BOOL bEOP, BOOL object) { ME_Run *run, *next_run; const WCHAR *pStart = buffer; @@ -4275,6 +4275,11 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, nLen = 2; str = L"\r\n"; } + else if (object && run->nFlags & MERF_GRAPHICS) + { + srcChars--; + str = L"\xfffc"; + } else { nLen = min(nLen, srcChars); @@ -4454,7 +4459,7 @@ static BOOL ME_IsCandidateAnURL(ME_TextEditor *editor, const ME_Cursor *start, i WCHAR bufferW[MAX_PREFIX_LEN + 1]; unsigned int i;
- ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE); + ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE, FALSE); for (i = 0; i < ARRAY_SIZE(prefixes); i++) { if (nChars < prefixes[i].length) continue; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 141e9034a6a..3f956a3d27b 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -277,7 +277,7 @@ void ME_DestroyEditor(ME_TextEditor *editor) DECLSPEC_HIDDEN; LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, HRESULT* phresult ) DECLSPEC_HIDDEN; int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, - const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP) DECLSPEC_HIDDEN; + const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP, BOOL object) DECLSPEC_HIDDEN; void ME_RTFCharAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_RTFParAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_RTFTblAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 72840a4cafa..7049526f577 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1563,7 +1563,7 @@ static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str) return E_OUTOFMEMORY;
bEOP = (!para_next( para_next( end.para )) && This->end > ME_GetTextLength(editor)); - ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP); + ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP, TRUE); return S_OK; }
@@ -1617,7 +1617,7 @@ static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch { WCHAR wch[2];
- ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, !para_next( para_next( cursor->para ) )); + ME_GetTextW(editor, wch, 1, cursor, 1, FALSE, !para_next( para_next( cursor->para ) ), TRUE); *pch = wch[0];
return S_OK; @@ -4651,7 +4651,7 @@ static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr) return E_OUTOFMEMORY;
bEOP = (!para_next( para_next( end->para ) ) && endOfs > ME_GetTextLength(This->services->editor)); - ME_GetTextW(This->services->editor, *pbstr, nChars, start, nChars, FALSE, bEOP); + ME_GetTextW(This->services->editor, *pbstr, nChars, start, nChars, FALSE, bEOP, TRUE); TRACE("%s\n", wine_dbgstr_w(*pbstr));
return S_OK; diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index a50a4aff26b..702190c8259 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3395,13 +3395,13 @@ static void test_InsertObject(void) gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
gettextex.flags = GT_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); @@ -3424,26 +3424,26 @@ static void test_InsertObject(void) hr = ITextRange_GetText(range, &bstr); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); - todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); hr = ITextRange_SetRange(range, 3, 4); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = ITextRange_GetChar(range, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result); ITextRange_Release(range);
SendMessageW(hwnd, EM_SETSEL, 0, -1); hr = ITextSelection_GetText(selection, &bstr); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(lstrlenW(bstr) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(bstr)); - todo_wine ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); + ok(!lstrcmpW(bstr, expected_string), "Got text: %s.\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); SendMessageW(hwnd, EM_SETSEL, 3, 4); result = 0; hr = ITextSelection_GetChar(selection, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result);
SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)""); result = SendMessageW(hwnd, EM_SETTEXTMODE, (WPARAM)TM_PLAINTEXT, 0); @@ -3476,13 +3476,13 @@ static void test_InsertObject(void) gettextex.lpUsedDefChar = NULL; result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
gettextex.flags = GT_RAWTEXT; memset(buffer, 0, sizeof(buffer)); result = SendMessageW(hwnd, EM_GETTEXTEX, (WPARAM)&gettextex, (LPARAM)buffer); ok(result == lstrlenW(expected_string), "Got wrong length: %d.\n", result); - todo_wine ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer)); + ok(!lstrcmpW(buffer, expected_string), "Got wrong content: %s.\n", debugstr_w(buffer));
expected_stringA = "abc d efg"; memset(bufferA, 0, sizeof(bufferA)); @@ -3511,7 +3511,7 @@ static void test_InsertObject(void) ok(hr == S_OK, "Got hr %#x.\n", hr); hr = ITextRange_GetChar(range, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result); ITextRange_Release(range);
SendMessageW(hwnd, EM_SETSEL, 0, -1); @@ -3524,7 +3524,7 @@ static void test_InsertObject(void) result = 0; hr = ITextSelection_GetChar(selection, &result); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(result == 0xfffc, "Got char: %c\n", result); + ok(result == 0xfffc, "Got char: %c\n", result);
release_interfaces(&hwnd, &reole, &doc, &selection); } diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c index 08db02517f5..8f9ccf35717 100644 --- a/dlls/riched20/tests/txtsrv.c +++ b/dlls/riched20/tests/txtsrv.c @@ -698,7 +698,7 @@ static void test_TxGetText(void) hres = ITextServices_TxGetText(txtserv, &rettext); ok(hres == S_OK, "Got hres: %#x.\n", hres); ok(lstrlenW(rettext) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(rettext)); - todo_wine ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); + ok(!lstrcmpW(rettext, expected_string), "Got wrong content: %s.\n", debugstr_w(rettext)); SysFreeString(rettext); IOleClientSite_Release(clientsite); IRichEditOle_Release(reole); diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c index 73b8d3ea7e9..9ea8b64b4ac 100644 --- a/dlls/riched20/txtsrv.c +++ b/dlls/riched20/txtsrv.c @@ -312,7 +312,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetText( ITextServices *iface, BS if (bstr == NULL) return E_OUTOFMEMORY;
cursor_from_char_ofs( services->editor, 0, &start ); - ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, FALSE, FALSE ); + ME_GetTextW( services->editor, bstr, length, &start, INT_MAX, FALSE, FALSE, TRUE ); *text = bstr; } else *text = NULL;
On Thu, May 20, 2021 at 03:56:15PM +0800, Jactry Zeng wrote:
@@ -4247,7 +4247,7 @@ LRESULT editor_handle_message( ME_TextEditor *editor, UINT msg, WPARAM wParam, */ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF,
BOOL bEOP)
BOOL bEOP, BOOL object)
{
Let's combine the last three params into a DWORD flags.
ME_Run *run, *next_run; const WCHAR *pStart = buffer; @@ -4275,6 +4275,11 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, nLen = 2; str = L"\r\n"; }
- else if (object && run->nFlags & MERF_GRAPHICS)
- {
srcChars--;
str = L"\xfffc";
- }
I think it would be cleaner to do the opposite. So have ME_InsertOLEFromCursor() insert a '\xfffc' and then return a space here if we explicitly don't want it (and similarly invert the meaning of the "object" flag so that it's set if we want to return a space).
Huw.