wmp: Added IOleObject::GetExtent and SetExtent implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-05-31 16:05:58 +02:00 committed by Alexandre Julliard
parent 23e78c01af
commit a8d956b5b6
4 changed files with 79 additions and 5 deletions

View File

@ -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;

View File

@ -1,4 +1,4 @@
TESTDLL = wmp.dll
IMPORTS = ole32 oleaut32 user32
IMPORTS = ole32 oleaut32 user32 gdi32
C_SRCS = oleobj.c

View File

@ -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);

View File

@ -36,6 +36,7 @@ struct WindowsMediaPlayer {
IOleClientSite *client_site;
HWND hwnd;
SIZEL extent;
};
void init_player_ifaces(WindowsMediaPlayer*) DECLSPEC_HIDDEN;