When OLE object provides IViewObject::Draw, Richedit can draw it even though the OLE object does not support CF_BITMAP nor CF_ENHMETAFILE.
Signed-off-by: Dongwan Kim kdw6485@gmail.com --- dlls/riched20/richole.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index 03572511ff7..1a62f0b9f36 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -5653,6 +5653,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) STGMEDIUM stgm; DIBSECTION dibsect; ENHMETAHEADER emh; + int pixs;
assert(run->nFlags & MERF_GRAPHICS); assert(run->reobj); @@ -5691,8 +5692,13 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) fmt.tymed = TYMED_ENHMF; if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK) { - FIXME("unsupported format\n"); - pSize->cx = pSize->cy = 0; + if( IOleObject_GetExtent(run->reobj->obj.poleobj, DVASPECT_CONTENT, pSize) != S_OK){ + FIXME("unsupported format\n"); + pSize->cx = pSize->cy = 0; + } + pixs = GetDeviceCaps(c->hDC, LOGPIXELSX); + pSize->cx = MulDiv(pSize->cx, pixs , 2540); + pSize->cy = MulDiv(pSize->cy, pixs , 2540); IDataObject_Release(ido); return; } @@ -5735,6 +5741,8 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) BOOL has_size; HBITMAP old_bm; RECT rc; + HRESULT hr; + int pixs;
assert(run->nFlags & MERF_GRAPHICS); assert(run->reobj); @@ -5755,7 +5763,17 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) fmt.tymed = TYMED_ENHMF; if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK) { - FIXME("Couldn't get storage medium\n"); + IOleObject_GetExtent(run->reobj->obj.poleobj, DVASPECT_CONTENT, &sz); + pixs = GetDeviceCaps(c->hDC, LOGPIXELSX); + rc.left = x; + rc.top = y - MulDiv(sz.cy, pixs, 2540); + rc.right = x + MulDiv(sz.cx, pixs, 2540); + rc.bottom = y ; + hr = OleDraw(run->reobj->obj.poleobj, DVASPECT_CONTENT, c->hDC, &rc); + if (FAILED(hr)) + { + FIXME("Couldn't draw ole object\n"); + } IDataObject_Release(ido); return; }
The character position should be filled in REOBJECT which IRichEditOle::GetObject returns.
Signed-off-by: Dongwan Kim kdw6485@gmail.com --- dlls/riched20/caret.c | 2 ++ dlls/riched20/run.c | 1 + 2 files changed, 3 insertions(+)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index ebc137ebf85..50bb320c982 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -488,6 +488,8 @@ void editor_insert_oleobj(ME_TextEditor *editor, const REOBJECT *reo) break; } } + if(run->reobj->obj.cp == REO_CP_SELECTION) + run->reobj->obj.cp = run->nCharOfs; if (reobj_prev) list_add_after(&reobj_prev->entry, &run->reobj->entry); else diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 51e768f8441..0cd0773b6b0 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -154,6 +154,7 @@ void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift ) do { run->nCharOfs += shift; + if(run->reobj) run->reobj->obj.cp = run->nCharOfs; run = run_next( run ); } while (run); }
Signed-off-by: Dongwan Kim kdw6485@gmail.com --- dlls/riched20/tests/richole.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c index 9449c6b58cc..d68bf1149ae 100644 --- a/dlls/riched20/tests/richole.c +++ b/dlls/riched20/tests/richole.c @@ -3296,6 +3296,11 @@ static void test_InsertObject(void) CHECK_REOBJECT_STRUCT(reole, 1, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo3.polesite, 3); CHECK_REOBJECT_STRUCT(reole, 2, REO_GETOBJ_ALL_INTERFACES, 0, NULL, NULL, reo2.polesite, 2);
+ received_reo.cbStruct = sizeof(received_reo); + hr = IRichEditOle_GetObject(reole, 1, &received_reo, REO_GETOBJ_ALL_INTERFACES); + ok( received_reo.cp == 1 , "IRichEditOle_GetObject should fill the cp of structure REOBJ."); + + hr = IRichEditOle_GetObject(reole, 2, NULL, REO_GETOBJ_ALL_INTERFACES); ok(hr == E_INVALIDARG, "IRichEditOle_GetObject should fail: 0x%08x\n", hr);