[PATCH v4 1/2] riched20: Allow to insert OLE object at specified offset.
Jactry Zeng
jzeng at codeweavers.com
Tue Jun 8 00:45:49 CDT 2021
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
Superseded patch 206830.
v4:
- Discard nCursor parameter in ME_InsertOLEFromCursor().
- Rename ME_InsertOLEFromCursor() to editor_insert_oleobj().
---
dlls/riched20/caret.c | 16 ++++++++++++----
dlls/riched20/editor.c | 2 +-
dlls/riched20/editor.h | 2 +-
dlls/riched20/richole.c | 2 +-
dlls/riched20/tests/richole.c | 18 +++++++++---------
5 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 1f4c3903a38..beac8af50a1 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -455,15 +455,23 @@ static struct re_object* create_re_object(const REOBJECT *reo)
return reobj;
}
-void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor)
+void editor_insert_oleobj(ME_TextEditor *editor, const REOBJECT *reo)
{
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;
+ 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/editor.c b/dlls/riched20/editor.c
index d4aadc325f9..cc02604767e 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1172,7 +1172,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HB
reobject.dwFlags = 0; /* FIXME */
reobject.dwUser = 0;
- ME_InsertOLEFromCursor(editor, &reobject, 0);
+ editor_insert_oleobj(editor, &reobject);
hr = S_OK;
}
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 141e9034a6a..fdf3e068fe9 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -188,7 +188,7 @@ int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to) DEC
BOOL ME_IsSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_DeleteSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_SendSelChange(ME_TextEditor *editor) DECLSPEC_HIDDEN;
-void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor) DECLSPEC_HIDDEN;
+void editor_insert_oleobj( ME_TextEditor *editor, const REOBJECT *reo ) DECLSPEC_HIDDEN;
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce) DECLSPEC_HIDDEN;
int ME_GetTextLength(ME_TextEditor *editor) DECLSPEC_HIDDEN;
int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 72840a4cafa..03572511ff7 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -1367,7 +1367,7 @@ IRichEditOle_fnInsertObject(IRichEditOle *iface, REOBJECT *reo)
if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
- ME_InsertOLEFromCursor(services->editor, reo, 0);
+ editor_insert_oleobj(services->editor, reo);
ME_CommitUndo(services->editor);
ME_UpdateRepaint(services->editor, FALSE);
return S_OK;
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index a76f9fdaf2e..a8c48994613 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);
@@ -3467,7 +3467,7 @@ static void test_InsertObject(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
string = GlobalLock(stgmedium.hGlobal);
ok(lstrlenW(string) == lstrlenW(expected_string), "Got wrong length: %d.\n", lstrlenW(string));
- todo_wine ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string));
+ ok(!lstrcmpW(string, expected_string), "Got wrong content: %s.\n", debugstr_w(string));
GlobalUnlock(stgmedium.hGlobal);
expected_string = L"abc\xfffc""d\xfffc""efg";
@@ -3491,7 +3491,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;
@@ -3499,7 +3499,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
More information about the wine-devel
mailing list