Commit 9c20cdfe authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

riched20: Make use of the size info in REOBJECT if present.

parent bcbf9eeb
...@@ -260,7 +260,7 @@ int ME_GetParaLineSpace(ME_Context *c, ME_Paragraph*); ...@@ -260,7 +260,7 @@ int ME_GetParaLineSpace(ME_Context *c, ME_Paragraph*);
/* richole.c */ /* richole.c */
LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *); LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *);
void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, ME_Paragraph *para, BOOL selected); void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, ME_Paragraph *para, BOOL selected);
void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize); void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize);
void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src); void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src);
void ME_DeleteReObject(REOBJECT* reo); void ME_DeleteReObject(REOBJECT* reo);
......
...@@ -550,12 +550,19 @@ LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj) ...@@ -550,12 +550,19 @@ LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
return 1; return 1;
} }
static void convert_sizel(ME_Context *c, const SIZEL* szl, SIZE* sz)
{
/* sizel is in .01 millimeters, sz in pixels */
sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
}
/****************************************************************************** /******************************************************************************
* ME_GetOLEObjectSize * ME_GetOLEObjectSize
* *
* Sets run extent for OLE objects. * Sets run extent for OLE objects.
*/ */
void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize) void ME_GetOLEObjectSize(ME_Context *c, ME_Run *run, SIZE *pSize)
{ {
IDataObject* ido; IDataObject* ido;
FORMATETC fmt; FORMATETC fmt;
...@@ -565,6 +572,13 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize) ...@@ -565,6 +572,13 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
assert(run->nFlags & MERF_GRAPHICS); assert(run->nFlags & MERF_GRAPHICS);
assert(run->ole_obj); assert(run->ole_obj);
if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
{
convert_sizel(c, &run->ole_obj->sizel, pSize);
return;
}
IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido); IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
fmt.cfFormat = CF_BITMAP; fmt.cfFormat = CF_BITMAP;
fmt.ptd = NULL; fmt.ptd = NULL;
...@@ -603,10 +617,10 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize) ...@@ -603,10 +617,10 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
break; break;
} }
IDataObject_Release(ido); IDataObject_Release(ido);
if (editor->nZoomNumerator != 0) if (c->editor->nZoomNumerator != 0)
{ {
pSize->cx = MulDiv(pSize->cx, editor->nZoomNumerator, editor->nZoomDenominator); pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
pSize->cy = MulDiv(pSize->cy, editor->nZoomNumerator, editor->nZoomDenominator); pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
} }
} }
...@@ -620,6 +634,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, ...@@ -620,6 +634,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
ENHMETAHEADER emh; ENHMETAHEADER emh;
HDC hMemDC; HDC hMemDC;
SIZE sz; SIZE sz;
BOOL has_size;
assert(run->nFlags & MERF_GRAPHICS); assert(run->nFlags & MERF_GRAPHICS);
assert(run->ole_obj); assert(run->ole_obj);
...@@ -628,6 +643,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, ...@@ -628,6 +643,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
FIXME("Couldn't get interface\n"); FIXME("Couldn't get interface\n");
return; return;
} }
has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
fmt.cfFormat = CF_BITMAP; fmt.cfFormat = CF_BITMAP;
fmt.ptd = NULL; fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT; fmt.dwAspect = DVASPECT_CONTENT;
...@@ -650,7 +666,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, ...@@ -650,7 +666,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect); GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
hMemDC = CreateCompatibleDC(c->hDC); hMemDC = CreateCompatibleDC(c->hDC);
SelectObject(hMemDC, stgm.u.hBitmap); SelectObject(hMemDC, stgm.u.hBitmap);
if (c->editor->nZoomNumerator == 0) if (!has_size && c->editor->nZoomNumerator == 0)
{ {
sz.cx = dibsect.dsBm.bmWidth; sz.cx = dibsect.dsBm.bmWidth;
sz.cy = dibsect.dsBm.bmHeight; sz.cy = dibsect.dsBm.bmHeight;
...@@ -660,10 +676,17 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, ...@@ -660,10 +676,17 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
} }
else else
{ {
if (has_size)
{
convert_sizel(c, &run->ole_obj->sizel, &sz);
}
else
{
sz.cy = MulDiv(dibsect.dsBm.bmWidth, sz.cy = MulDiv(dibsect.dsBm.bmWidth,
c->editor->nZoomNumerator, c->editor->nZoomDenominator); c->editor->nZoomNumerator, c->editor->nZoomDenominator);
sz.cx = MulDiv(dibsect.dsBm.bmHeight, sz.cx = MulDiv(dibsect.dsBm.bmHeight,
c->editor->nZoomNumerator, c->editor->nZoomDenominator); c->editor->nZoomNumerator, c->editor->nZoomDenominator);
}
StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY); hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
} }
...@@ -671,18 +694,25 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, ...@@ -671,18 +694,25 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
break; break;
case TYMED_ENHMF: case TYMED_ENHMF:
GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh); GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
if (c->editor->nZoomNumerator == 0) if (!has_size && c->editor->nZoomNumerator == 0)
{ {
sz.cy = emh.rclBounds.bottom - emh.rclBounds.top; sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
sz.cx = emh.rclBounds.right - emh.rclBounds.left; sz.cx = emh.rclBounds.right - emh.rclBounds.left;
} }
else else
{ {
if (has_size)
{
convert_sizel(c, &run->ole_obj->sizel, &sz);
}
else
{
sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
c->editor->nZoomNumerator, c->editor->nZoomDenominator); c->editor->nZoomNumerator, c->editor->nZoomDenominator);
sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
c->editor->nZoomNumerator, c->editor->nZoomDenominator); c->editor->nZoomNumerator, c->editor->nZoomDenominator);
} }
}
{ {
RECT rc; RECT rc;
......
...@@ -492,7 +492,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run) ...@@ -492,7 +492,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
if (run->nFlags & MERF_GRAPHICS) if (run->nFlags & MERF_GRAPHICS)
{ {
SIZE sz; SIZE sz;
ME_GetOLEObjectSize(c->editor, run, &sz); ME_GetOLEObjectSize(c, run, &sz);
if (cx < sz.cx) if (cx < sz.cx)
return 0; return 0;
return 1; return 1;
...@@ -546,10 +546,12 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run) ...@@ -546,10 +546,12 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
return 0; return 0;
return 1; return 1;
} }
ME_InitContext(&c, editor, GetDC(editor->hWnd));
if (run->nFlags & MERF_GRAPHICS) if (run->nFlags & MERF_GRAPHICS)
{ {
SIZE sz; SIZE sz;
ME_GetOLEObjectSize(editor, run, &sz); ME_GetOLEObjectSize(&c, run, &sz);
ReleaseDC(editor->hWnd, c.hDC);
if (cx < sz.cx/2) if (cx < sz.cx/2)
return 0; return 0;
return 1; return 1;
...@@ -560,7 +562,6 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run) ...@@ -560,7 +562,6 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
else else
strRunText = run->strText; strRunText = run->strText;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
hOldFont = ME_SelectStyleFont(&c, run->style); hOldFont = ME_SelectStyleFont(&c, run->style);
GetTextExtentExPointW(c.hDC, strRunText->szData, strRunText->nLen, GetTextExtentExPointW(c.hDC, strRunText->szData, strRunText->nLen,
cx, &fit, NULL, &sz); cx, &fit, NULL, &sz);
...@@ -609,11 +610,13 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) ...@@ -609,11 +610,13 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
ME_String *strRunText; ME_String *strRunText;
/* This could point to either the run's real text, or it's masked form in a password control */ /* This could point to either the run's real text, or it's masked form in a password control */
ME_InitContext(&c, editor, GetDC(editor->hWnd));
if (pRun->nFlags & MERF_GRAPHICS) if (pRun->nFlags & MERF_GRAPHICS)
{ {
if (!nOffset) return 0; if (nOffset)
ME_GetOLEObjectSize(editor, pRun, &size); ME_GetOLEObjectSize(&c, pRun, &size);
return 1; ReleaseDC(editor->hWnd, c.hDC);
return nOffset != 0;
} }
if (editor->cPasswordMask) if (editor->cPasswordMask)
...@@ -621,7 +624,6 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) ...@@ -621,7 +624,6 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
else else
strRunText = pRun->strText; strRunText = pRun->strText;
ME_InitContext(&c, editor, GetDC(editor->hWnd));
ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size); ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size);
ReleaseDC(editor->hWnd, c.hDC); ReleaseDC(editor->hWnd, c.hDC);
if (editor->cPasswordMask) if (editor->cPasswordMask)
...@@ -689,7 +691,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run ...@@ -689,7 +691,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
} }
if (run->nFlags & MERF_GRAPHICS) if (run->nFlags & MERF_GRAPHICS)
{ {
ME_GetOLEObjectSize(c->editor, run, &size); ME_GetOLEObjectSize(c, run, &size);
if (size.cy > *pAscent) if (size.cy > *pAscent)
*pAscent = size.cy; *pAscent = size.cy;
/* descent is unchanged */ /* descent is unchanged */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment