[PATCH 6/7] riched20: Allow to insert OLE object at specified offset.

Jactry Zeng jzeng at codeweavers.com
Thu May 20 02:56:14 CDT 2021


---
 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 );
 
-- 
2.30.2




More information about the wine-devel mailing list