From 07e9d33f39730ff50646bda53ca2d510140e118d Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 18 Jun 2014 14:57:13 -0500 Subject: [PATCH] packager: Implement IOleObject::SetClientSite. --- dlls/packager/packager_main.c | 18 +++++++- dlls/packager/tests/oleobj.c | 78 +++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/dlls/packager/packager_main.c b/dlls/packager/packager_main.c index 47353834c6b..942ae7208e4 100644 --- a/dlls/packager/packager_main.c +++ b/dlls/packager/packager_main.c @@ -44,6 +44,8 @@ struct Package { LONG ref; WCHAR filename[MAX_PATH]; + + IOleClientSite *clientsite; }; static inline struct Package *impl_from_IOleObject(IOleObject *iface) @@ -95,6 +97,9 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface) TRACE("(%p) ref=%d\n", This, ref); if(!ref){ + if(This->clientsite) + IOleClientSite_Release(This->clientsite); + if(*This->filename) DeleteFileW(This->filename); @@ -107,8 +112,17 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface) static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite) { struct Package *This = impl_from_IOleObject(iface); - FIXME("(%p)->(%p)\n", This, pClientSite); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, pClientSite); + + if(This->clientsite) + IOleClientSite_Release(This->clientsite); + + This->clientsite = pClientSite; + if(pClientSite) + IOleClientSite_AddRef(pClientSite); + + return S_OK; } static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite) diff --git a/dlls/packager/tests/oleobj.c b/dlls/packager/tests/oleobj.c index 5ff536a9078..912dda97742 100644 --- a/dlls/packager/tests/oleobj.c +++ b/dlls/packager/tests/oleobj.c @@ -334,6 +334,78 @@ static IStorage stg = { &stg_vtbl }; +static HRESULT WINAPI clientsite_QueryInterface(IOleClientSite* This, + REFIID riid, void **ppvObject) +{ + ok(0, "query interface\n"); + return E_NOINTERFACE; +} + +static ULONG WINAPI clientsite_AddRef(IOleClientSite* This) +{ + return 2; +} + +static ULONG WINAPI clientsite_Release(IOleClientSite* This) +{ + return 1; +} + +static HRESULT WINAPI clientsite_SaveObject(IOleClientSite* This) +{ + ok(0, "saveobject\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI clientsite_GetMoniker(IOleClientSite* This, + DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) +{ + ok(0, "getmoniker\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI clientsite_GetContainer(IOleClientSite* This, + IOleContainer **ppContainer) +{ + ok(0, "getcontainer\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI clientsite_ShowObject(IOleClientSite* This) +{ + ok(0, "showobject\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI clientsite_OnShowWindow(IOleClientSite* This, + BOOL fShow) +{ + ok(0, "onshowwindow\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI clientsite_RequestNewObjectLayout(IOleClientSite* This) +{ + ok(0, "requestnewobjectlayout\n"); + return E_NOTIMPL; +} + +static IOleClientSiteVtbl clientsite_vtbl = { + clientsite_QueryInterface, + clientsite_AddRef, + clientsite_Release, + clientsite_SaveObject, + clientsite_GetMoniker, + clientsite_GetContainer, + clientsite_ShowObject, + clientsite_OnShowWindow, + clientsite_RequestNewObjectLayout +}; + +static IOleClientSite clientsite = { + &clientsite_vtbl +}; + static void test_packager(void) { IOleObject *oleobj; @@ -363,6 +435,12 @@ static void test_packager(void) &IID_IOleObject, (void**)&oleobj); ok(hr == S_OK, "CoCreateInstance(CLSID_Package_Alt) failed: %08x\n", hr); + hr = IOleObject_SetClientSite(oleobj, NULL); + ok(hr == S_OK, "SetClientSite failed: %08x\n", hr); + + hr = IOleObject_SetClientSite(oleobj, &clientsite); + ok(hr == S_OK, "SetClientSite failed: %08x\n", hr); + hr = IOleObject_QueryInterface(oleobj, &IID_IPersistStorage, (void**)&persist); ok(hr == S_OK, "QueryInterface(IPersistStorage) failed: %08x\n", hr);