[PATCH] riched20: Allow to insert OLE object at specified character position.

Jactry Zeng jzeng at codeweavers.com
Wed May 5 07:26:39 CDT 2021


Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
Superseded patch 205181.
Sorry for bothering, forgot to sign it.
---
 dlls/riched20/caret.c         | 14 +++++++++++---
 dlls/riched20/tests/richole.c |  3 +--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 04ac3eaa66f..702e367fadc 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -461,10 +461,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 e6329c5b1b6..2a35be74621 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -3252,10 +3252,9 @@ static void test_InsertObject(void)
   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);
+  fill_reobject_struct(&reo2, 2, 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);
   count = IRichEditOle_GetObjectCount(reole);
-- 
2.30.2




More information about the wine-devel mailing list