[PATCH 4/4 v3 resend] riched20: Partially implement ITextServices_TxGetNaturalSize().
Jactry Zeng
jzeng at codeweavers.com
Mon May 28 23:12:36 CDT 2018
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
---
dlls/riched20/tests/txtsrv.c | 65 ++++++++++++++++++++++++++++++++++++++++++--
dlls/riched20/txtsrv.c | 32 ++++++++++++++++++++--
2 files changed, 93 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c
index f97cd39d18..f9cdfc0945 100644
--- a/dlls/riched20/tests/txtsrv.c
+++ b/dlls/riched20/tests/txtsrv.c
@@ -424,9 +424,10 @@ static HRESULT WINAPI ITextHostImpl_TxGetPropertyBits(ITextHost *iface,
DWORD *pdwBits)
{
ITextHostTestImpl *This = impl_from_ITextHost(iface);
+ DWORD bits = TXTBIT_MULTILINE | TXTBIT_WORDWRAP;
TRACECALL("Call to TxGetPropertyBits(%p, dwMask=0x%08x, pdwBits=%p)\n",
This, dwMask, pdwBits);
- *pdwBits = 0;
+ *pdwBits = bits & dwMask;
return S_OK;
}
@@ -809,6 +810,13 @@ static void test_TxGetNaturalSize(void)
HRESULT result;
SIZEL psizelExtent = {-1,-1};
static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0};
+ static const WCHAR long_text[] = {'T','e','s','t','W','i','t','h','A','L','o','n','g',
+ 'L','i','n','e','S','t','r','i','n','g',0};
+ static const WCHAR long_text1[] = {'T','e','s','t','W','i','t','h','Y','e','t','A','n',
+ 'o','t','h','o','r','L', 'o','n','g','L','i','n','e',
+ 'S','t','r','i','n','g','W','h','i','c','h','H','a',
+ 's','M','o','r','e','T','h','a','n','T','w','o','L',
+ 'i','n','e','s',0};
LONG width, height, expected_width, expected_height, lines;
HDC hdcDraw;
HWND hwnd;
@@ -846,7 +854,60 @@ static void test_TxGetNaturalSize(void)
height = 0;
result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
TXTNS_FITTOCONTENT, &psizelExtent, &width, &height);
- todo_wine CHECK_TXGETNATURALSIZE(result, width, height, expected_width, expected_height);
+ CHECK_TXGETNATURALSIZE(result, width, height, expected_width, expected_height);
+
+ psizelExtent.cx = 1; psizelExtent.cy = 1;
+ width = rect.right - rect.left;
+ height = 0;
+ result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
+ TXTNS_FITTOCONTENT, &psizelExtent, &width, &height);
+ CHECK_TXGETNATURALSIZE(result, width, height, expected_width, expected_height);
+
+ psizelExtent.cx = 0; psizelExtent.cy = 0;
+ width = rect.right - rect.left;
+ height = 0;
+ result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
+ TXTNS_FITTOCONTENT, &psizelExtent, &width, &height);
+ CHECK_TXGETNATURALSIZE(result, width, height, 0, 0);
+
+ psizelExtent.cx = -1; psizelExtent.cy = -1;
+ result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
+ TXTNS_FITTOCONTENT, &psizelExtent, NULL, NULL);
+ ok(result == E_INVALIDARG, "ITextServices_TxGetNaturalSize should fail: 0x%08x.\n", result);
+
+ /* Test with a long line string */
+ result = ITextServices_TxSetText(txtserv, long_text);
+ ok(result == S_OK, "ITextServices_TxSetText failed result: 0x%08x.\n", result);
+
+ old_hf = SelectObject(hdcDraw, hf);
+ expected_width = get_max_width(hdcDraw, long_text, rect.right - rect.left, &lines);
+ GetTextMetricsA(hdcDraw, &tm);
+ expected_height = (tm.tmAscent + tm.tmDescent) * lines;
+ SelectObject(hdcDraw, old_hf);
+
+ psizelExtent.cx = -1; psizelExtent.cy = -1;
+ width = rect.right - rect.left;
+ height = 0;
+ result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
+ TXTNS_FITTOCONTENT, &psizelExtent, &width, &height);
+ CHECK_TXGETNATURALSIZE(result, width, height, expected_width, expected_height);
+
+ /* Test with string which has more than two lines */
+ result = ITextServices_TxSetText(txtserv, long_text1);
+ ok(result == S_OK, "ITextServices_TxSetText failed result: 0x%08x.\n", result);
+
+ old_hf = SelectObject(hdcDraw, hf);
+ expected_width = get_max_width(hdcDraw, long_text1, rect.right - rect.left, &lines);
+ GetTextMetricsA(hdcDraw, &tm);
+ expected_height = (tm.tmAscent + tm.tmDescent) * lines;
+ SelectObject(hdcDraw, old_hf);
+
+ psizelExtent.cx = -1; psizelExtent.cy = -1;
+ width = rect.right - rect.left;
+ height = 0;
+ result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
+ TXTNS_FITTOCONTENT, &psizelExtent, &width, &height);
+ CHECK_TXGETNATURALSIZE(result, width, height, expected_width, expected_height);
ReleaseDC(hwnd, hdcDraw);
DestroyWindow(hwnd);
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index eb61e4eff6..a621e7e6e9 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -319,9 +319,37 @@ DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetNaturalSize(ITextServices *iface,
const SIZEL *psizelExtent, LONG *pwidth, LONG *pheight)
{
ITextServicesImpl *This = impl_from_ITextServices(iface);
+ if (!pwidth || !pheight)
+ return E_INVALIDARG;
+
+ TRACE("(%p)->(%p, %x, %p, %p, %p, %x, %p, %p, %p\n)", This, iface, dwAspect, hdcDraw,
+ hicTargetDev, ptd, dwMode, psizelExtent, pwidth, pheight);
+
+ if (dwAspect != DVASPECT_CONTENT)
+ FIXME("Unsupported aspect: %x\n", dwAspect);
+ if (hicTargetDev)
+ FIXME("Unsupported hicTargetDev: %p\n", hicTargetDev);
+ if (ptd)
+ FIXME("Unsupported ptd: %p\n", ptd);
+ if (dwMode != TXTNS_FITTOCONTENT)
+ FIXME("Unsupported mode: %x\n", dwMode);
+
+ if (!psizelExtent->cy)
+ {
+ *pwidth = 0;
+ *pheight = 0;
+ return S_OK;
+ }
- FIXME("%p: STUB\n", This);
- return E_NOTIMPL;
+ SetRectEmpty(&This->editor->rcFormat);
+ This->editor->rcFormat.right = *pwidth;
+ This->editor->rcFormat.bottom = *pheight;
+ ME_MarkAllForWrapping(This->editor);
+ ME_WrapMarkedParagraphs(This->editor, hdcDraw);
+ *pwidth = This->editor->nTotalWidth;
+ *pheight = This->editor->nTotalLength;
+
+ return S_OK;
}
DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxGetDropTarget(ITextServices *iface, IDropTarget **ppDropTarget)
--
2.15.1 (Apple Git-101)
More information about the wine-devel
mailing list