Jacek Caban : wmp: Added IOleObject:: GetExtent and SetExtent implementation.

Alexandre Julliard julliard at winehq.org
Fri Oct 20 07:19:57 CDT 2017


Module: wine
Branch: stable
Commit: c0a288b17c715cbb2d1e99d0d8a9a4369fd493e3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c0a288b17c715cbb2d1e99d0d8a9a4369fd493e3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed May 31 16:05:58 2017 +0200

wmp: Added IOleObject::GetExtent and SetExtent implementation.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit a8d956b5b60759f144a863db6fb563ea8b0873b4)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 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 75957a4..8dcdfbd 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 465b878..df770c7 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 971a2fe..b008af1 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 91e8465..c23f487 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;




More information about the wine-cvs mailing list