From: Vijay Kiran Kamuju Subject: [PATCH 2/2] dhtmled.ocx: Implement IOleObject::SetExtent and IOleObject::GetExtent functions Message-Id: Date: Fri, 19 Feb 2021 19:36:29 +0100 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50697 Signed-off-by: Vijay Kiran Kamuju
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50697
Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>
From 4b302c588d51af55122f7de8c8c4aab4c6e94cab Mon Sep 17 00:00:00 2001 From: Vijay Kiran Kamuju Date: Fri, 19 Feb 2021 19:26:40 +0100 Subject: [PATCH 2/2] dhtmled.ocx: Implement IOleObject::SetExtent and IOleObject::GetExtent functions Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50697 Signed-off-by: Vijay Kiran Kamuju --- dlls/dhtmled.ocx/Makefile.in | 2 +- dlls/dhtmled.ocx/edit.c | 30 ++++++++++++++++++--- dlls/dhtmled.ocx/tests/Makefile.in | 2 +- dlls/dhtmled.ocx/tests/oleobj.c | 42 +++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/dlls/dhtmled.ocx/Makefile.in b/dlls/dhtmled.ocx/Makefile.in index a6c053a2737..bbe397dc401 100644 --- a/dlls/dhtmled.ocx/Makefile.in +++ b/dlls/dhtmled.ocx/Makefile.in @@ -1,5 +1,5 @@ MODULE = dhtmled.ocx -IMPORTS = uuid ole32 +IMPORTS = uuid ole32 user32 gdi32 EXTRADLLFLAGS = -mno-cygwin diff --git a/dlls/dhtmled.ocx/edit.c b/dlls/dhtmled.ocx/edit.c index dfa300b9590..53dcdfc9ac6 100644 --- a/dlls/dhtmled.ocx/edit.c +++ b/dlls/dhtmled.ocx/edit.c @@ -1,5 +1,6 @@ /* * Copyright 2017 Alex Henrie + * Copyright 2021 Vijay Kiran Kamuju * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,6 +31,7 @@ typedef struct IOleObject IOleObject_iface; IPersistStreamInit IPersistStreamInit_iface; IOleClientSite *client_site; + SIZEL extent; LONG ref; } DHTMLEditImpl; @@ -700,15 +702,25 @@ static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD type_type, static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD aspect, SIZEL *size_limit) { DHTMLEditImpl *This = impl_from_IOleObject(iface); - FIXME("(%p)->(%u, %p) stub\n", This, aspect, size_limit); - return E_NOTIMPL; + TRACE("(%p)->(%u, %p)\n", This, aspect, size_limit); + + if(aspect != DVASPECT_CONTENT) + return DV_E_DVASPECT; + + This->extent = *size_limit; + return S_OK; } static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD aspect, SIZEL *size_limit) { DHTMLEditImpl *This = impl_from_IOleObject(iface); - FIXME("(%p)->(%u, %p) stub\n", This, aspect, size_limit); - return E_NOTIMPL; + TRACE("(%p)->(%u, %p)\n", This, aspect, size_limit); + + if(aspect != DVASPECT_CONTENT) + return E_FAIL; + + *size_limit = This->extent; + return S_OK; } static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *sink, DWORD *conn) @@ -849,6 +861,8 @@ static const IPersistStreamInitVtbl PersistStreamInitVtbl = { HRESULT dhtml_edit_create(REFIID iid, void **out) { DHTMLEditImpl *This; + DWORD dpi_x, dpi_y; + HDC hdc; HRESULT ret; TRACE("(%s, %p)\n", debugstr_guid(iid), out); @@ -863,6 +877,14 @@ HRESULT dhtml_edit_create(REFIID iid, void **out) This->client_site = NULL; This->ref = 1; + hdc = GetDC(0); + dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); + dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + + This->extent.cx = MulDiv(192, 2540, dpi_x); + This->extent.cy = MulDiv(192, 2540, dpi_y); + ret = IDHTMLEdit_QueryInterface(&This->IDHTMLEdit_iface, iid, out); IDHTMLEdit_Release(&This->IDHTMLEdit_iface); return ret; diff --git a/dlls/dhtmled.ocx/tests/Makefile.in b/dlls/dhtmled.ocx/tests/Makefile.in index bf29f658dd9..ec76d9b6bdc 100644 --- a/dlls/dhtmled.ocx/tests/Makefile.in +++ b/dlls/dhtmled.ocx/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = dhtmled.ocx -IMPORTS = ole32 +IMPORTS = user32 gdi32 ole32 C_SRCS = \ oleobj.c diff --git a/dlls/dhtmled.ocx/tests/oleobj.c b/dlls/dhtmled.ocx/tests/oleobj.c index ffddde1bc82..82529c2fbf3 100644 --- a/dlls/dhtmled.ocx/tests/oleobj.c +++ b/dlls/dhtmled.ocx/tests/oleobj.c @@ -118,7 +118,9 @@ static void test_dhtmledit(void) IOleObject *oleobj; IOleClientSite *site; HRESULT hr; - DWORD status; + DWORD status, dpi_x, dpi_y; + SIZEL extent, expected; + HDC hdc; hr = CoCreateInstance(&CLSID_DHTMLEdit, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER, &IID_IOleObject, (void**)&oleobj); @@ -142,6 +144,44 @@ static void test_dhtmledit(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok(site == &clientsite, "got %p, %p\n", site, &clientsite); + /* extents */ + hdc = GetDC(0); + dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); + dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + + memset(&extent, 0, sizeof(extent)); + hr = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(extent.cx == MulDiv(192, 2540, dpi_x), "got %d\n", extent.cx); + ok(extent.cy == MulDiv(192, 2540, dpi_y), "got %d\n", extent.cy); + + extent.cx = 800; + extent.cy = 700; + hr = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hr == S_OK, "SetExtent failed: %08x\n", hr); + + extent.cx = extent.cy = 0xdeadbeef; + hr = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hr == S_OK, "GetExtent failed: %08x\n", hr); + ok(extent.cx == 800, "got %d\n", extent.cx); + ok(extent.cy == 700, "got %d\n", extent.cy); + + hr = IOleObject_GetExtent(oleobj, 0, &extent); + ok(hr == E_FAIL, "GetExtent failed: %08x\n", hr); + hr = IOleObject_GetExtent(oleobj, 7, &extent); + ok(hr == E_FAIL, "GetExtent failed: %08x\n", hr); + + extent.cx = 900; + extent.cy = 800; + hr = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &expected); + ok(hr == S_OK, "SetExtent failed: %08x\n", hr); + + hr = IOleObject_SetExtent(oleobj, 0, &expected); + ok(hr == DV_E_DVASPECT, "SetExtent failed: %08x\n", hr); + hr = IOleObject_SetExtent(oleobj, 7, &expected); + ok(hr == DV_E_DVASPECT, "SetExtent failed: %08x\n", hr); + hr = IOleObject_Close(oleobj, OLECLOSE_NOSAVE); ok(hr == S_OK, "Close failed: %08x\n", hr); -- 2.30.1