From dee64631ffeda2dffe4bb5d75405bbdf29873630 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 21 Feb 2017 13:19:24 +0100 Subject: [PATCH] ole32: Use generic class factory for item moniker. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/ole32/itemmoniker.c | 50 +++------------------------------------- dlls/ole32/moniker.h | 2 +- dlls/ole32/oleproxy.c | 13 ++++++++++- 3 files changed, 16 insertions(+), 49 deletions(-) diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index 67bef5f8b1d..14beadadee4 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -948,39 +948,16 @@ HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, IMoni hr = ItemMonikerImpl_Construct(newItemMoniker,lpszDelim,lpszItem); if (FAILED(hr)){ - HeapFree(GetProcessHeap(),0,newItemMoniker); - return hr; + return hr; } return ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface,&IID_IMoniker, (void**)ppmk); } -static HRESULT WINAPI ItemMonikerCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) -{ - *ppv = NULL; - if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IClassFactory)) - { - *ppv = iface; - IClassFactory_AddRef(iface); - return S_OK; - } - return E_NOINTERFACE; -} - -static ULONG WINAPI ItemMonikerCF_AddRef(LPCLASSFACTORY iface) -{ - return 2; /* non-heap based object */ -} - -static ULONG WINAPI ItemMonikerCF_Release(LPCLASSFACTORY iface) -{ - return 1; /* non-heap based object */ -} - -static HRESULT WINAPI ItemMonikerCF_CreateInstance(LPCLASSFACTORY iface, - LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv) +HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, + IUnknown *pUnk, REFIID riid, void **ppv) { ItemMonikerImpl* newItemMoniker; HRESULT hr; @@ -1006,24 +983,3 @@ static HRESULT WINAPI ItemMonikerCF_CreateInstance(LPCLASSFACTORY iface, return hr; } - -static HRESULT WINAPI ItemMonikerCF_LockServer(LPCLASSFACTORY iface, BOOL fLock) -{ - FIXME("(%d), stub!\n",fLock); - return S_OK; -} - -static const IClassFactoryVtbl ItemMonikerCFVtbl = -{ - ItemMonikerCF_QueryInterface, - ItemMonikerCF_AddRef, - ItemMonikerCF_Release, - ItemMonikerCF_CreateInstance, - ItemMonikerCF_LockServer -}; -static const IClassFactoryVtbl *ItemMonikerCF = &ItemMonikerCFVtbl; - -HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv) -{ - return IClassFactory_QueryInterface((IClassFactory *)&ItemMonikerCF, riid, ppv); -} diff --git a/dlls/ole32/moniker.h b/dlls/ole32/moniker.h index 2b08384c8f9..a8113668282 100644 --- a/dlls/ole32/moniker.h +++ b/dlls/ole32/moniker.h @@ -31,7 +31,7 @@ DEFINE_OLEGUID( CLSID_ClassMoniker, 0x31a, 0, 0 ); DEFINE_OLEGUID( CLSID_PointerMoniker, 0x306, 0, 0 ); HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk, REFIID riid, void **ppv); -HRESULT ItemMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; +HRESULT WINAPI ItemMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk, REFIID riid, void **ppv); HRESULT AntiMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; HRESULT CompositeMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; HRESULT ClassMonikerCF_Create(REFIID riid, LPVOID *ppv) DECLSPEC_HIDDEN; diff --git a/dlls/ole32/oleproxy.c b/dlls/ole32/oleproxy.c index ba0703d002d..b7a11a1da6d 100644 --- a/dlls/ole32/oleproxy.c +++ b/dlls/ole32/oleproxy.c @@ -84,6 +84,17 @@ static const IClassFactoryVtbl FileMonikerCFVtbl = static IClassFactory FileMonikerCF = { &FileMonikerCFVtbl }; +static const IClassFactoryVtbl ItemMonikerCFVtbl = +{ + ClassFactory_QueryInterface, + ClassFactory_AddRef, + ClassFactory_Release, + ItemMoniker_CreateInstance, + ClassFactory_LockServer +}; + +static IClassFactory ItemMonikerCF = { &ItemMonikerCFVtbl }; + /*********************************************************************** * DllGetClassObject [OLE32.@] */ @@ -103,7 +114,7 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) if (IsEqualCLSID(rclsid, &CLSID_FileMoniker)) return IClassFactory_QueryInterface(&FileMonikerCF, iid, ppv); if (IsEqualCLSID(rclsid, &CLSID_ItemMoniker)) - return ItemMonikerCF_Create(iid, ppv); + return IClassFactory_QueryInterface(&ItemMonikerCF, iid, ppv); if (IsEqualCLSID(rclsid, &CLSID_AntiMoniker)) return AntiMonikerCF_Create(iid, ppv); if (IsEqualCLSID(rclsid, &CLSID_CompositeMoniker))