Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/riched20/richole.c | 10 +++++++ dlls/riched20/tests/richole.c | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 447e7d4599..93003eb281 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -1391,6 +1391,16 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob, else reobj = cursor.pRun->member.run.reobj; } + else if (iob == REO_IOB_SELECTION) + { + ME_Cursor *from, *to; + + ME_GetSelection(This->editor, &from, &to); + if (!from->pRun->member.run.reobj) + return E_INVALIDARG; + else + reobj = from->pRun->member.run.reobj; + } else { if (iob > IRichEditOle_GetObjectCount(me)) diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 52399047ad..d9c7fa1670 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3328,6 +3328,61 @@ static void test_InsertObject(void) /* received_reo4 didn't be zeroed in E_INVALIDARG case */ CHECK_REOBJECT_STRUCT(received_reo4, NULL, NULL, reo2.polesite, 2);
+ 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); + + 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); + + 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); + + 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); + + 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); + + 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); + + 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); + + 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); + ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr); + release_interfaces(&hwnd, &reole, &doc, NULL); }