Eric Pouech : riched20: Make use of the size info in REOBJECT if present.
Alexandre Julliard
julliard at winehq.org
Tue Feb 5 06:33:28 CST 2008
Module: wine
Branch: master
Commit: 9c20cdfea8c4db041066363424f6fde018374dfc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c20cdfea8c4db041066363424f6fde018374dfc
Author: Eric Pouech <eric.pouech at orange.fr>
Date: Sun Jan 27 19:02:34 2008 +0100
riched20: Make use of the size info in REOBJECT if present.
---
dlls/riched20/editor.h | 2 +-
dlls/riched20/richole.c | 54 ++++++++++++++++++++++++++++++++++++----------
dlls/riched20/run.c | 22 ++++++++++--------
3 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index dde2efc..8b97a55 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -260,7 +260,7 @@ int ME_GetParaLineSpace(ME_Context *c, ME_Paragraph*);
/* richole.c */
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_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_DeleteReObject(REOBJECT* reo);
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index c7fc2c8..1509d4e 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -550,12 +550,19 @@ LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
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
*
* 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;
FORMATETC fmt;
@@ -565,6 +572,13 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
assert(run->nFlags & MERF_GRAPHICS);
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);
fmt.cfFormat = CF_BITMAP;
fmt.ptd = NULL;
@@ -603,10 +617,10 @@ void ME_GetOLEObjectSize(ME_TextEditor *editor, ME_Run *run, SIZE *pSize)
break;
}
IDataObject_Release(ido);
- if (editor->nZoomNumerator != 0)
+ if (c->editor->nZoomNumerator != 0)
{
- pSize->cx = MulDiv(pSize->cx, editor->nZoomNumerator, editor->nZoomDenominator);
- pSize->cy = MulDiv(pSize->cy, editor->nZoomNumerator, editor->nZoomDenominator);
+ pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->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,
ENHMETAHEADER emh;
HDC hMemDC;
SIZE sz;
+ BOOL has_size;
assert(run->nFlags & MERF_GRAPHICS);
assert(run->ole_obj);
@@ -628,6 +643,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
FIXME("Couldn't get interface\n");
return;
}
+ has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
fmt.cfFormat = CF_BITMAP;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
@@ -650,7 +666,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
hMemDC = CreateCompatibleDC(c->hDC);
SelectObject(hMemDC, stgm.u.hBitmap);
- if (c->editor->nZoomNumerator == 0)
+ if (!has_size && c->editor->nZoomNumerator == 0)
{
sz.cx = dibsect.dsBm.bmWidth;
sz.cy = dibsect.dsBm.bmHeight;
@@ -660,10 +676,17 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
}
else
{
- sz.cy = MulDiv(dibsect.dsBm.bmWidth,
- c->editor->nZoomNumerator, c->editor->nZoomDenominator);
- sz.cx = MulDiv(dibsect.dsBm.bmHeight,
- c->editor->nZoomNumerator, c->editor->nZoomDenominator);
+ if (has_size)
+ {
+ convert_sizel(c, &run->ole_obj->sizel, &sz);
+ }
+ else
+ {
+ sz.cy = MulDiv(dibsect.dsBm.bmWidth,
+ c->editor->nZoomNumerator, c->editor->nZoomDenominator);
+ sz.cx = MulDiv(dibsect.dsBm.bmHeight,
+ c->editor->nZoomNumerator, c->editor->nZoomDenominator);
+ }
StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
}
@@ -671,17 +694,24 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
break;
case TYMED_ENHMF:
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.cx = emh.rclBounds.right - emh.rclBounds.left;
+ sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
+ sz.cx = emh.rclBounds.right - emh.rclBounds.left;
}
else
{
+ if (has_size)
+ {
+ convert_sizel(c, &run->ole_obj->sizel, &sz);
+ }
+ else
+ {
sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top,
c->editor->nZoomNumerator, c->editor->nZoomDenominator);
sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left,
c->editor->nZoomNumerator, c->editor->nZoomDenominator);
+ }
}
{
RECT rc;
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 9928640..9ed14d3 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -492,7 +492,7 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
if (run->nFlags & MERF_GRAPHICS)
{
SIZE sz;
- ME_GetOLEObjectSize(c->editor, run, &sz);
+ ME_GetOLEObjectSize(c, run, &sz);
if (cx < sz.cx)
return 0;
return 1;
@@ -546,21 +546,22 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
return 0;
return 1;
}
+ ME_InitContext(&c, editor, GetDC(editor->hWnd));
if (run->nFlags & MERF_GRAPHICS)
{
SIZE sz;
- ME_GetOLEObjectSize(editor, run, &sz);
+ ME_GetOLEObjectSize(&c, run, &sz);
+ ReleaseDC(editor->hWnd, c.hDC);
if (cx < sz.cx/2)
return 0;
return 1;
}
-
+
if (editor->cPasswordMask)
strRunText = ME_MakeStringR(editor->cPasswordMask,ME_StrVLen(run->strText));
else
strRunText = run->strText;
- ME_InitContext(&c, editor, GetDC(editor->hWnd));
hOldFont = ME_SelectStyleFont(&c, run->style);
GetTextExtentExPointW(c.hDC, strRunText->szData, strRunText->nLen,
cx, &fit, NULL, &sz);
@@ -609,19 +610,20 @@ int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
ME_String *strRunText;
/* 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 (!nOffset) return 0;
- ME_GetOLEObjectSize(editor, pRun, &size);
- return 1;
+ if (nOffset)
+ ME_GetOLEObjectSize(&c, pRun, &size);
+ ReleaseDC(editor->hWnd, c.hDC);
+ return nOffset != 0;
}
if (editor->cPasswordMask)
strRunText = ME_MakeStringR(editor->cPasswordMask,ME_StrVLen(pRun->strText));
else
strRunText = pRun->strText;
-
- ME_InitContext(&c, editor, GetDC(editor->hWnd));
+
ME_GetTextExtent(&c, strRunText->szData, nOffset, pRun->style, &size);
ReleaseDC(editor->hWnd, c.hDC);
if (editor->cPasswordMask)
@@ -689,7 +691,7 @@ static SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run
}
if (run->nFlags & MERF_GRAPHICS)
{
- ME_GetOLEObjectSize(c->editor, run, &size);
+ ME_GetOLEObjectSize(c, run, &size);
if (size.cy > *pAscent)
*pAscent = size.cy;
/* descent is unchanged */
More information about the wine-cvs
mailing list