Huw Davies : riched20: Implement TxGetNaturalSize().
Alexandre Julliard
julliard at winehq.org
Thu Mar 25 16:49:21 CDT 2021
Module: wine
Branch: master
Commit: e7b42deaf2a18e32313e2da02566905180986760
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e7b42deaf2a18e32313e2da02566905180986760
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Mar 25 09:10:28 2021 +0000
riched20: Implement TxGetNaturalSize().
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/riched20/tests/txtsrv.c | 6 +++---
dlls/riched20/txtsrv.c | 39 ++++++++++++++++++++++++++++++++++-----
2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/dlls/riched20/tests/txtsrv.c b/dlls/riched20/tests/txtsrv.c
index 7ca6074587d..3cfd5e63753 100644
--- a/dlls/riched20/tests/txtsrv.c
+++ b/dlls/riched20/tests/txtsrv.c
@@ -705,7 +705,7 @@ static void _check_txgetnaturalsize(HRESULT res, LONG width, LONG height, HDC hd
expected_width = expected_rect.right - expected_rect.left;
expected_height = expected_rect.bottom - expected_rect.top;
ok_(__FILE__,line)(res == S_OK, "ITextServices_TxGetNaturalSize failed: 0x%08x.\n", res);
- ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1,
+ todo_wine ok_(__FILE__,line)(width >= expected_width && width <= expected_width + 1,
"got wrong width: %d, expected: %d {+1}.\n", width, expected_width);
ok_(__FILE__,line)(height == expected_height, "got wrong height: %d, expected: %d.\n",
height, expected_height);
@@ -717,7 +717,7 @@ static void test_TxGetNaturalSize(void)
ITextHost *host;
HRESULT result;
SIZEL extent;
- static const WCHAR test_text[] = {'T','e','s','t','S','o','m','e','T','e','x','t',0};
+ static const WCHAR test_text[] = L"TestSomeText";
LONG width, height;
HDC hdcDraw;
HWND hwnd;
@@ -752,7 +752,7 @@ static void test_TxGetNaturalSize(void)
height = 0;
result = ITextServices_TxGetNaturalSize(txtserv, DVASPECT_CONTENT, hdcDraw, NULL, NULL,
TXTNS_FITTOCONTENT, &extent, &width, &height);
- todo_wine CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text);
+ CHECK_TXGETNATURALSIZE(result, width, height, hdcDraw, rect, test_text);
ReleaseDC(hwnd, hdcDraw);
DestroyWindow(hwnd);
diff --git a/dlls/riched20/txtsrv.c b/dlls/riched20/txtsrv.c
index 79ade0f6117..5736964c1b1 100644
--- a/dlls/riched20/txtsrv.c
+++ b/dlls/riched20/txtsrv.c
@@ -366,14 +366,43 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetBaseLinePos(ITextServices *ifa
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetNaturalSize,36)
-DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize(ITextServices *iface, DWORD dwAspect, HDC hdcDraw,
- HDC hicTargetDev, DVTARGETDEVICE *ptd, DWORD dwMode,
- const SIZEL *psizelExtent, LONG *pwidth, LONG *pheight)
+DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxGetNaturalSize( ITextServices *iface, DWORD aspect, HDC draw,
+ HDC target, DVTARGETDEVICE *td, DWORD mode,
+ const SIZEL *extent, LONG *width, LONG *height )
{
struct text_services *services = impl_from_ITextServices( iface );
+ RECT rect;
+ HDC dc = draw;
+ BOOL rewrap = FALSE;
+ HRESULT hr;
- FIXME( "%p: STUB\n", services );
- return E_NOTIMPL;
+ TRACE( "%p: aspect %d, draw %p, target %p, td %p, mode %08x, extent %s, *width %d, *height %d\n", services,
+ aspect, draw, target, td, mode, wine_dbgstr_point( (POINT *)extent ), *width, *height );
+
+ if (aspect != DVASPECT_CONTENT || target || td || mode != TXTNS_FITTOCONTENT )
+ FIXME( "Many arguments are ignored\n" );
+
+ SetRect( &rect, 0, 0, *width, *height );
+
+ hr = update_client_rect( services, &rect );
+ if (FAILED( hr )) return hr;
+ if (hr == S_OK) rewrap = TRUE;
+
+ if (!dc && services->editor->in_place_active)
+ dc = ITextHost_TxGetDC( services->host );
+ if (!dc) return E_FAIL;
+
+ if (rewrap)
+ {
+ editor_mark_rewrap_all( services->editor );
+ wrap_marked_paras_dc( services->editor, dc, FALSE );
+ }
+
+ *width = services->editor->nTotalWidth;
+ *height = services->editor->nTotalLength;
+
+ if (!draw) ITextHost_TxReleaseDC( services->host, dc );
+ return S_OK;
}
DEFINE_THISCALL_WRAPPER(fnTextSrv_TxGetDropTarget,8)
More information about the wine-cvs
mailing list