Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
Superseded patch 206143, 206145, and 206146.
---
dlls/riched20/caret.c | 14 +++++++++++---
dlls/riched20/tests/richole.c | 16 ++++++++--------
2 files changed, 19 insertions(+), 11 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);
--
2.30.2