From a8d956b5b60759f144a863db6fb563ea8b0873b4 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 31 May 2017 16:05:58 +0200 Subject: [PATCH] wmp: Added IOleObject::GetExtent and SetExtent implementation. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/wmp/oleobj.c | 30 +++++++++++++++++++++++---- dlls/wmp/tests/Makefile.in | 2 +- dlls/wmp/tests/oleobj.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/wmp/wmp_private.h | 1 + 4 files changed, 79 insertions(+), 5 deletions(-) diff --git a/dlls/wmp/oleobj.c b/dlls/wmp/oleobj.c index 75957a44f70..8dcdfbdce21 100644 --- a/dlls/wmp/oleobj.c +++ b/dlls/wmp/oleobj.c @@ -457,15 +457,27 @@ static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfTyp static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel) { WindowsMediaPlayer *This = impl_from_IOleObject(iface); - FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel); - return E_NOTIMPL; + + TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel); + + if(dwDrawAspect != DVASPECT_CONTENT) + return DV_E_DVASPECT; + + This->extent = *psizel; + return S_OK; } static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel) { WindowsMediaPlayer *This = impl_from_IOleObject(iface); - FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel); - return E_NOTIMPL; + + TRACE("(%p)->(%d %p)\n", This, dwDrawAspect, psizel); + + if(dwDrawAspect != DVASPECT_CONTENT) + return E_FAIL; + + *psizel = This->extent; + return S_OK; } static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection) @@ -905,6 +917,8 @@ HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) { WindowsMediaPlayer *wmp; + DWORD dpi_x, dpi_y; + HDC hdc; HRESULT hres; TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv); @@ -924,6 +938,14 @@ HRESULT WINAPI WMPFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, init_player_ifaces(wmp); + hdc = GetDC(0); + dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); + dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + + wmp->extent.cx = MulDiv(192, 2540, dpi_x); + wmp->extent.cy = MulDiv(192, 2540, dpi_y); + hres = IOleObject_QueryInterface(&wmp->IOleObject_iface, riid, ppv); IOleObject_Release(&wmp->IOleObject_iface); return hres; diff --git a/dlls/wmp/tests/Makefile.in b/dlls/wmp/tests/Makefile.in index 465b8786cef..df770c78c67 100644 --- a/dlls/wmp/tests/Makefile.in +++ b/dlls/wmp/tests/Makefile.in @@ -1,4 +1,4 @@ TESTDLL = wmp.dll -IMPORTS = ole32 oleaut32 user32 +IMPORTS = ole32 oleaut32 user32 gdi32 C_SRCS = oleobj.c diff --git a/dlls/wmp/tests/oleobj.c b/dlls/wmp/tests/oleobj.c index 971a2fe93e0..b008af15890 100644 --- a/dlls/wmp/tests/oleobj.c +++ b/dlls/wmp/tests/oleobj.c @@ -857,6 +857,56 @@ static void test_QI(IUnknown *unk) IUnknown_Release(tmp); } +static void test_extent(IOleObject *oleobj) +{ + SIZE expected, extent; + DWORD dpi_x; + DWORD dpi_y; + HDC hdc; + HRESULT hres; + + /* default aspect ratio is 96dpi / 96dpi */ + hdc = GetDC(0); + dpi_x = GetDeviceCaps(hdc, LOGPIXELSX); + dpi_y = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(0, hdc); + if (dpi_x != 96 || dpi_y != 96) + trace("dpi: %d / %d\n", dpi_y, dpi_y); + + extent.cx = extent.cy = 0xdeadbeef; + hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hres == S_OK, "GetExtent failed: %08x\n", hres); + expected.cx = MulDiv(192, 2540, dpi_x); + expected.cy = MulDiv(192, 2540, dpi_y); + ok(extent.cx == expected.cx && extent.cy == expected.cy, "size = {%d %d} (expected %d %d)\n", + extent.cx, extent.cy, expected.cx, expected.cy ); + + extent.cx = 800; + extent.cy = 700; + hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hres == S_OK, "SetExtent failed: %08x\n", hres); + + extent.cx = extent.cy = 0xdeadbeef; + hres = IOleObject_GetExtent(oleobj, DVASPECT_CONTENT, &extent); + ok(hres == S_OK, "GetExtent failed: %08x\n", hres); + ok(extent.cx == 800 && extent.cy == 700, "size = {%d %d}\n", extent.cx, extent.cy); + + hres = IOleObject_GetExtent(oleobj, 0, &extent); + ok(hres == E_FAIL, "GetExtent failed: %08x\n", hres); + hres = IOleObject_GetExtent(oleobj, 7, &extent); + ok(hres == E_FAIL, "GetExtent failed: %08x\n", hres); + + extent.cx = 900; + extent.cy = 800; + hres = IOleObject_SetExtent(oleobj, DVASPECT_CONTENT, &expected); + ok(hres == S_OK, "SetExtent failed: %08x\n", hres); + + hres = IOleObject_SetExtent(oleobj, 0, &expected); + ok(hres == DV_E_DVASPECT, "SetExtent failed: %08x\n", hres); + hres = IOleObject_SetExtent(oleobj, 7, &expected); + ok(hres == DV_E_DVASPECT, "SetExtent failed: %08x\n", hres); +} + static void test_wmp(void) { IProvideClassInfo2 *class_info; @@ -902,6 +952,7 @@ static void test_wmp(void) IProvideClassInfo2_Release(class_info); test_QI((IUnknown*)oleobj); + test_extent(oleobj); hres = IOleObject_GetMiscStatus(oleobj, DVASPECT_CONTENT, &misc_status); ok(hres == S_OK, "GetMiscStatus failed: %08x\n", hres); diff --git a/dlls/wmp/wmp_private.h b/dlls/wmp/wmp_private.h index a44aa35a1ab..7b7f51cd633 100644 --- a/dlls/wmp/wmp_private.h +++ b/dlls/wmp/wmp_private.h @@ -36,6 +36,7 @@ struct WindowsMediaPlayer { IOleClientSite *client_site; HWND hwnd; + SIZEL extent; }; void init_player_ifaces(WindowsMediaPlayer*) DECLSPEC_HIDDEN; -- 2.11.4.GIT