Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52752 Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/riched20/richole.c | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c index a23f4c82730..3cbd2ddf4af 100644 --- a/dlls/riched20/richole.c +++ b/dlls/riched20/richole.c @@ -5652,6 +5652,7 @@ static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz) void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) { IDataObject* ido; + IViewObject* ivo; FORMATETC fmt; STGMEDIUM stgm; DIBSECTION dibsect; @@ -5677,6 +5678,29 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) return; }
+ if (SUCCEEDED(IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IViewObject, (void**)&ivo))) + { + HRESULT hr; + SIZEL sizel; + + hr = IOleObject_GetExtent(run->reobj->obj.poleobj, DVASPECT_CONTENT, &sizel); + if (FAILED(hr)) + { + WARN("failed to get extent: %#08lx\n", hr); + sizel.cx = sizel.cy = 0; + } + + convert_sizel(c, &sizel, pSize); + if (c->editor->nZoomNumerator != 0) + { + pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + } + + IViewObject_Release(ivo); + return; + } + if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK) { FIXME("Query Interface IID_IDataObject failed!\n"); @@ -5729,6 +5753,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected ) { IDataObject* ido; + IViewObject* ivo; FORMATETC fmt; STGMEDIUM stgm; DIBSECTION dibsect; @@ -5741,6 +5766,45 @@ void draw_ole( ME_Context *c, int x, int y, ME_Run *run, BOOL selected )
assert(run->nFlags & MERF_GRAPHICS); assert(run->reobj); + + if (SUCCEEDED(IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IViewObject, (void**)&ivo))) + { + HRESULT hr; + SIZEL sizel = run->reobj->obj.sizel; + + if (sizel.cx == 0 && sizel.cy == 0) + { + hr = IOleObject_GetExtent(run->reobj->obj.poleobj, DVASPECT_CONTENT, &sizel); + if (FAILED(hr)) + { + WARN("failed to get extent: %#08lx\n", hr); + IViewObject_Release(ivo); + return; + } + } + + convert_sizel(c, &sizel, &sz); + if (c->editor->nZoomNumerator != 0) + { + sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator); + } + + rc.left = x; + rc.top = y - sz.cy; + rc.right = x + sz.cx; + rc.bottom = y; + + hr = IViewObject_Draw(ivo, DVASPECT_CONTENT, -1, 0, 0, 0, c->hDC, (RECTL*)&rc, NULL, NULL, 0); + if (FAILED(hr)) + { + WARN("failed to draw object: %#08lx\n", hr); + } + + IViewObject_Release(ivo); + return; + } + if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK) { FIXME("Couldn't get interface\n");