- Remove redunant braces.

- Compact multi-line comments that fit into one line.
- Remove comments that state the obvious.
- Remove extra brackets that are redundant because the -> operator
  binds tighter than &.
- Change "this" to "This" to make code more like other interface
  implementations.
- Remove redundant comparisons with NULL for pointers.
This commit is contained in:
Robert Shearman 2005-09-19 14:42:53 +00:00 committed by Alexandre Julliard
parent 8c2ba6f93c
commit 83f3b370b1
1 changed files with 172 additions and 274 deletions

View File

@ -67,37 +67,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
*/
struct DefaultHandler
{
/*
* List all interface VTables here
*/
const IOleObjectVtbl* lpVtbl;
const IUnknownVtbl* lpvtblIUnknown;
const IDataObjectVtbl* lpvtblIDataObject;
const IRunnableObjectVtbl* lpvtblIRunnableObject;
/*
* Reference count of this object
*/
/* Reference count of this object */
LONG ref;
/*
* IUnknown implementation of the outer object.
p */
/* IUnknown implementation of the outer object. */
IUnknown* outerUnknown;
/*
* Class Id that this handler object represents.
*/
/* Class Id that this handler object represents. */
CLSID clsid;
/*
* IUnknown implementation of the datacache.
*/
/* IUnknown implementation of the datacache. */
IUnknown* dataCache;
/*
* Client site for the embedded object.
*/
/* Client site for the embedded object. */
IOleClientSite* clientSite;
/*
@ -112,9 +99,7 @@ p */
*/
IDataAdviseHolder* dataAdviseHolder;
/*
* Name of the container and object contained
*/
/* Name of the container and object contained */
LPWSTR containerApp;
LPWSTR containerObj;
@ -124,7 +109,7 @@ typedef struct DefaultHandler DefaultHandler;
/*
* Here, I define utility functions to help with the casting of the
* "this" parameter.
* "This" parameter.
* There is a version to accommodate all of the VTables implemented
* by this object.
*/
@ -148,11 +133,7 @@ static inline DefaultHandler *impl_from_IRunnableObject( IRunnableObject *iface
return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIRunnableObject));
}
/*
* Prototypes for the methods of the DefaultHandler class.
*/
static void DefaultHandler_Destroy(DefaultHandler* ptrToDestroy);
static void DefaultHandler_Destroy(DefaultHandler* This);
/*********************************************************
@ -173,51 +154,33 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
REFIID riid,
void** ppvObject)
{
DefaultHandler *this = impl_from_NDIUnknown(iface);
DefaultHandler *This = impl_from_NDIUnknown(iface);
/*
* Perform a sanity check on the parameters.
*/
if ( (this==0) || (ppvObject==0) )
/* Perform a sanity check on the parameters. */
if (!ppvObject)
return E_INVALIDARG;
/*
* Initialize the return parameter.
*/
*ppvObject = 0;
*ppvObject = NULL;
/*
* Compare the riid with the interface IDs implemented by this object.
*/
if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
{
if (IsEqualIID(&IID_IUnknown, riid))
*ppvObject = iface;
}
else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
{
*ppvObject = (IOleObject*)&(this->lpVtbl);
}
else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
{
*ppvObject = (IDataObject*)&(this->lpvtblIDataObject);
}
else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
{
*ppvObject = (IRunnableObject*)&(this->lpvtblIRunnableObject);
}
else if (IsEqualIID(&IID_IOleObject, riid))
*ppvObject = (IOleObject*)&This->lpVtbl;
else if (IsEqualIID(&IID_IDataObject, riid))
*ppvObject = (IDataObject*)&This->lpvtblIDataObject;
else if (IsEqualIID(&IID_IRunnableObject, riid))
*ppvObject = (IRunnableObject*)&This->lpvtblIRunnableObject;
else
{
/*
* Blind aggregate the data cache to "inherit" it's interfaces.
*/
if (IUnknown_QueryInterface(this->dataCache, riid, ppvObject) == S_OK)
if (IUnknown_QueryInterface(This->dataCache, riid, ppvObject) == S_OK)
return S_OK;
}
/*
* Check that we obtained an interface.
*/
if ((*ppvObject)==0)
/* Check that we obtained an interface. */
if (*ppvObject == NULL)
{
WARN( "() : asking for un supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
@ -243,8 +206,8 @@ static HRESULT WINAPI DefaultHandler_NDIUnknown_QueryInterface(
static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
IUnknown* iface)
{
DefaultHandler *this = impl_from_NDIUnknown(iface);
return InterlockedIncrement(&this->ref);
DefaultHandler *This = impl_from_NDIUnknown(iface);
return InterlockedIncrement(&This->ref);
}
/************************************************************************
@ -258,18 +221,13 @@ static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
IUnknown* iface)
{
DefaultHandler *this = impl_from_NDIUnknown(iface);
DefaultHandler *This = impl_from_NDIUnknown(iface);
ULONG ref;
/*
* Decrease the reference count on this object.
*/
ref = InterlockedDecrement(&this->ref);
/* Decrease the reference count on this object. */
ref = InterlockedDecrement(&This->ref);
/*
* If the reference count goes down to 0, perform suicide.
*/
if (ref == 0) DefaultHandler_Destroy(this);
if (!ref) DefaultHandler_Destroy(This);
return ref;
}
@ -289,9 +247,9 @@ static HRESULT WINAPI DefaultHandler_QueryInterface(
REFIID riid,
void** ppvObject)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
}
/************************************************************************
@ -302,9 +260,9 @@ static HRESULT WINAPI DefaultHandler_QueryInterface(
static ULONG WINAPI DefaultHandler_AddRef(
IOleObject* iface)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
return IUnknown_AddRef(this->outerUnknown);
return IUnknown_AddRef(This->outerUnknown);
}
/************************************************************************
@ -315,9 +273,9 @@ static ULONG WINAPI DefaultHandler_AddRef(
static ULONG WINAPI DefaultHandler_Release(
IOleObject* iface)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
return IUnknown_Release(this->outerUnknown);
return IUnknown_Release(This->outerUnknown);
}
/************************************************************************
@ -332,7 +290,7 @@ static HRESULT WINAPI DefaultHandler_SetClientSite(
IOleObject* iface,
IOleClientSite* pClientSite)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, pClientSite);
@ -340,17 +298,13 @@ static HRESULT WINAPI DefaultHandler_SetClientSite(
* Make sure we release the previous client site if there
* was one.
*/
if (this->clientSite!=NULL)
{
IOleClientSite_Release(this->clientSite);
}
if (This->clientSite)
IOleClientSite_Release(This->clientSite);
this->clientSite = pClientSite;
This->clientSite = pClientSite;
if (this->clientSite!=NULL)
{
IOleClientSite_AddRef(this->clientSite);
}
if (This->clientSite)
IOleClientSite_AddRef(This->clientSite);
return S_OK;
}
@ -367,20 +321,16 @@ static HRESULT WINAPI DefaultHandler_GetClientSite(
IOleObject* iface,
IOleClientSite** ppClientSite)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
/*
* Sanity check.
*/
if (ppClientSite == NULL)
/* Sanity check. */
if (!ppClientSite)
return E_POINTER;
*ppClientSite = this->clientSite;
*ppClientSite = This->clientSite;
if (this->clientSite != NULL)
{
IOleClientSite_AddRef(this->clientSite);
}
if (This->clientSite)
IOleClientSite_AddRef(This->clientSite);
return S_OK;
}
@ -398,36 +348,32 @@ static HRESULT WINAPI DefaultHandler_SetHostNames(
LPCOLESTR szContainerApp,
LPCOLESTR szContainerObj)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %s, %s)\n",
iface,
debugstr_w(szContainerApp),
debugstr_w(szContainerObj));
/*
* Be sure to cleanup before re-assinging the strings.
*/
HeapFree( GetProcessHeap(), 0, this->containerApp );
this->containerApp = NULL;
HeapFree( GetProcessHeap(), 0, this->containerObj );
this->containerObj = NULL;
/* Be sure to cleanup before re-assinging the strings. */
HeapFree( GetProcessHeap(), 0, This->containerApp );
This->containerApp = NULL;
HeapFree( GetProcessHeap(), 0, This->containerObj );
This->containerObj = NULL;
/*
* Copy the string supplied.
*/
if (szContainerApp != NULL)
/* Copy the string supplied. */
if (szContainerApp)
{
if ((this->containerApp = HeapAlloc( GetProcessHeap(), 0,
if ((This->containerApp = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW(szContainerApp) + 1) * sizeof(WCHAR) )))
strcpyW( this->containerApp, szContainerApp );
strcpyW( This->containerApp, szContainerApp );
}
if (szContainerObj != NULL)
if (szContainerObj)
{
if ((this->containerObj = HeapAlloc( GetProcessHeap(), 0,
if ((This->containerObj = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW(szContainerObj) + 1) * sizeof(WCHAR) )))
strcpyW( this->containerObj, szContainerObj );
strcpyW( This->containerObj, szContainerObj );
}
return S_OK;
}
@ -481,14 +427,14 @@ static HRESULT WINAPI DefaultHandler_GetMoniker(
DWORD dwWhichMoniker,
IMoniker** ppmk)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %ld, %ld, %p)\n",
iface, dwAssign, dwWhichMoniker, ppmk);
if (this->clientSite)
if (This->clientSite)
{
return IOleClientSite_GetMoniker(this->clientSite,
return IOleClientSite_GetMoniker(This->clientSite,
dwAssign,
dwWhichMoniker,
ppmk);
@ -560,11 +506,11 @@ static HRESULT WINAPI DefaultHandler_EnumVerbs(
IOleObject* iface,
IEnumOLEVERB** ppEnumOleVerb)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
return OleRegEnumVerbs(&this->clsid, ppEnumOleVerb);
return OleRegEnumVerbs(&This->clsid, ppEnumOleVerb);
}
static HRESULT WINAPI DefaultHandler_Update(
@ -600,17 +546,15 @@ static HRESULT WINAPI DefaultHandler_GetUserClassID(
IOleObject* iface,
CLSID* pClsid)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, pClsid);
/*
* Sanity check.
*/
if (pClsid==NULL)
/* Sanity check. */
if (!pClsid)
return E_POINTER;
memcpy(pClsid, &this->clsid, sizeof(CLSID));
memcpy(pClsid, &This->clsid, sizeof(CLSID));
return S_OK;
}
@ -628,11 +572,11 @@ static HRESULT WINAPI DefaultHandler_GetUserType(
DWORD dwFormOfType,
LPOLESTR* pszUserType)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
return OleRegGetUserType(&this->clsid, dwFormOfType, pszUserType);
return OleRegGetUserType(&This->clsid, dwFormOfType, pszUserType);
}
/************************************************************************
@ -669,11 +613,11 @@ static HRESULT WINAPI DefaultHandler_GetExtent(
IViewObject2* cacheView = NULL;
HRESULT hres;
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
hres = IUnknown_QueryInterface(this->dataCache, &IID_IViewObject2, (void**)&cacheView);
hres = IUnknown_QueryInterface(This->dataCache, &IID_IViewObject2, (void**)&cacheView);
if (FAILED(hres))
return E_UNEXPECTED;
@ -716,24 +660,18 @@ static HRESULT WINAPI DefaultHandler_Advise(
DWORD* pdwConnection)
{
HRESULT hres = S_OK;
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
/*
* Make sure we have an advise holder before we start.
*/
if (this->oleAdviseHolder==NULL)
{
hres = CreateOleAdviseHolder(&this->oleAdviseHolder);
}
/* Make sure we have an advise holder before we start. */
if (!This->oleAdviseHolder)
hres = CreateOleAdviseHolder(&This->oleAdviseHolder);
if (SUCCEEDED(hres))
{
hres = IOleAdviseHolder_Advise(this->oleAdviseHolder,
hres = IOleAdviseHolder_Advise(This->oleAdviseHolder,
pAdvSink,
pdwConnection);
}
return hres;
}
@ -750,7 +688,7 @@ static HRESULT WINAPI DefaultHandler_Unadvise(
IOleObject* iface,
DWORD dwConnection)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %ld)\n", iface, dwConnection);
@ -758,10 +696,10 @@ static HRESULT WINAPI DefaultHandler_Unadvise(
* If we don't have an advise holder yet, it means we don't have
* a connection.
*/
if (this->oleAdviseHolder==NULL)
if (!This->oleAdviseHolder)
return OLE_E_NOCONNECTION;
return IOleAdviseHolder_Unadvise(this->oleAdviseHolder,
return IOleAdviseHolder_Unadvise(This->oleAdviseHolder,
dwConnection);
}
@ -777,23 +715,18 @@ static HRESULT WINAPI DefaultHandler_EnumAdvise(
IOleObject* iface,
IEnumSTATDATA** ppenumAdvise)
{
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, ppenumAdvise);
/*
* Sanity check
*/
if (ppenumAdvise==NULL)
/* Sanity check */
if (!ppenumAdvise)
return E_POINTER;
/*
* Initialize the out parameter.
*/
*ppenumAdvise = NULL;
if (this->oleAdviseHolder==NULL)
return IOleAdviseHolder_EnumAdvise(this->oleAdviseHolder,
if (!This->oleAdviseHolder)
return IOleAdviseHolder_EnumAdvise(This->oleAdviseHolder,
ppenumAdvise);
return S_OK;
@ -813,11 +746,11 @@ static HRESULT WINAPI DefaultHandler_GetMiscStatus(
DWORD* pdwStatus)
{
HRESULT hres;
DefaultHandler *this = impl_from_IOleObject(iface);
DefaultHandler *This = impl_from_IOleObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
hres = OleRegGetMiscStatus(&(this->clsid), dwAspect, pdwStatus);
hres = OleRegGetMiscStatus(&This->clsid, dwAspect, pdwStatus);
if (FAILED(hres))
*pdwStatus = 0;
@ -855,9 +788,9 @@ static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
REFIID riid,
void** ppvObject)
{
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
}
/************************************************************************
@ -868,9 +801,9 @@ static HRESULT WINAPI DefaultHandler_IDataObject_QueryInterface(
static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
IDataObject* iface)
{
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
return IUnknown_AddRef(this->outerUnknown);
return IUnknown_AddRef(This->outerUnknown);
}
/************************************************************************
@ -881,9 +814,9 @@ static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
static ULONG WINAPI DefaultHandler_IDataObject_Release(
IDataObject* iface)
{
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
return IUnknown_Release(this->outerUnknown);
return IUnknown_Release(This->outerUnknown);
}
/************************************************************************
@ -901,11 +834,11 @@ static HRESULT WINAPI DefaultHandler_GetData(
IDataObject* cacheDataObject = NULL;
HRESULT hres;
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
hres = IUnknown_QueryInterface(this->dataCache,
hres = IUnknown_QueryInterface(This->dataCache,
&IID_IDataObject,
(void**)&cacheDataObject);
@ -945,11 +878,11 @@ static HRESULT WINAPI DefaultHandler_QueryGetData(
IDataObject* cacheDataObject = NULL;
HRESULT hres;
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %p)\n", iface, pformatetc);
hres = IUnknown_QueryInterface(this->dataCache,
hres = IUnknown_QueryInterface(This->dataCache,
&IID_IDataObject,
(void**)&cacheDataObject);
@ -998,11 +931,11 @@ static HRESULT WINAPI DefaultHandler_SetData(
IDataObject* cacheDataObject = NULL;
HRESULT hres;
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
hres = IUnknown_QueryInterface(this->dataCache,
hres = IUnknown_QueryInterface(This->dataCache,
&IID_IDataObject,
(void**)&cacheDataObject);
@ -1022,7 +955,7 @@ static HRESULT WINAPI DefaultHandler_SetData(
/************************************************************************
* DefaultHandler_EnumFormatEtc (IDataObject)
*
* The default handler's implementation of this method simply delegates
* The default handler's implementation of This method simply delegates
* to OleRegEnumFormatEtc.
*
* See Windows documentation for more details on IDataObject methods.
@ -1033,11 +966,11 @@ static HRESULT WINAPI DefaultHandler_EnumFormatEtc(
IEnumFORMATETC** ppenumFormatEtc)
{
HRESULT hres;
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
hres = OleRegEnumFormatEtc(&(this->clsid), dwDirection, ppenumFormatEtc);
hres = OleRegEnumFormatEtc(&This->clsid, dwDirection, ppenumFormatEtc);
return hres;
}
@ -1058,28 +991,22 @@ static HRESULT WINAPI DefaultHandler_DAdvise(
DWORD* pdwConnection)
{
HRESULT hres = S_OK;
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %p, %ld, %p, %p)\n",
iface, pformatetc, advf, pAdvSink, pdwConnection);
/*
* Make sure we have a data advise holder before we start.
*/
if (this->dataAdviseHolder==NULL)
{
hres = CreateDataAdviseHolder(&this->dataAdviseHolder);
}
/* Make sure we have a data advise holder before we start. */
if (!This->dataAdviseHolder)
hres = CreateDataAdviseHolder(&This->dataAdviseHolder);
if (SUCCEEDED(hres))
{
hres = IDataAdviseHolder_Advise(this->dataAdviseHolder,
hres = IDataAdviseHolder_Advise(This->dataAdviseHolder,
iface,
pformatetc,
advf,
pAdvSink,
pdwConnection);
}
return hres;
}
@ -1096,7 +1023,7 @@ static HRESULT WINAPI DefaultHandler_DUnadvise(
IDataObject* iface,
DWORD dwConnection)
{
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %ld)\n", iface, dwConnection);
@ -1104,12 +1031,10 @@ static HRESULT WINAPI DefaultHandler_DUnadvise(
* If we don't have a data advise holder yet, it means that
* we don't have any connections..
*/
if (this->dataAdviseHolder==NULL)
{
if (!This->dataAdviseHolder)
return OLE_E_NOCONNECTION;
}
return IDataAdviseHolder_Unadvise(this->dataAdviseHolder,
return IDataAdviseHolder_Unadvise(This->dataAdviseHolder,
dwConnection);
}
@ -1125,29 +1050,20 @@ static HRESULT WINAPI DefaultHandler_EnumDAdvise(
IDataObject* iface,
IEnumSTATDATA** ppenumAdvise)
{
DefaultHandler *this = impl_from_IDataObject(iface);
DefaultHandler *This = impl_from_IDataObject(iface);
TRACE("(%p, %p)\n", iface, ppenumAdvise);
/*
* Sanity check
*/
if (ppenumAdvise == NULL)
/* Sanity check */
if (!ppenumAdvise)
return E_POINTER;
/*
* Initialize the out parameter.
*/
*ppenumAdvise = NULL;
/*
* If we have a data advise holder object, delegate.
*/
if (this->dataAdviseHolder!=NULL)
{
return IDataAdviseHolder_EnumAdvise(this->dataAdviseHolder,
/* If we have a data advise holder object, delegate. */
if (This->dataAdviseHolder)
return IDataAdviseHolder_EnumAdvise(This->dataAdviseHolder,
ppenumAdvise);
}
return S_OK;
}
@ -1167,9 +1083,9 @@ static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
REFIID riid,
void** ppvObject)
{
DefaultHandler *this = impl_from_IRunnableObject(iface);
DefaultHandler *This = impl_from_IRunnableObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
}
/************************************************************************
@ -1180,9 +1096,9 @@ static HRESULT WINAPI DefaultHandler_IRunnableObject_QueryInterface(
static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
IRunnableObject* iface)
{
DefaultHandler *this = impl_from_IRunnableObject(iface);
DefaultHandler *This = impl_from_IRunnableObject(iface);
return IUnknown_AddRef(this->outerUnknown);
return IUnknown_AddRef(This->outerUnknown);
}
/************************************************************************
@ -1193,9 +1109,9 @@ static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
IRunnableObject* iface)
{
DefaultHandler *this = impl_from_IRunnableObject(iface);
DefaultHandler *This = impl_from_IRunnableObject(iface);
return IUnknown_Release(this->outerUnknown);
return IUnknown_Release(This->outerUnknown);
}
/************************************************************************
@ -1347,29 +1263,26 @@ static DefaultHandler* DefaultHandler_Construct(
REFCLSID clsid,
LPUNKNOWN pUnkOuter)
{
DefaultHandler* newObject = 0;
DefaultHandler* This = NULL;
/*
* Allocate space for the object.
*/
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
This = HeapAlloc(GetProcessHeap(), 0, sizeof(DefaultHandler));
if (newObject==0)
return newObject;
if (!This)
return This;
/*
* Initialize the virtual function table.
*/
newObject->lpVtbl = &DefaultHandler_IOleObject_VTable;
newObject->lpvtblIUnknown = &DefaultHandler_NDIUnknown_VTable;
newObject->lpvtblIDataObject = &DefaultHandler_IDataObject_VTable;
newObject->lpvtblIRunnableObject = &DefaultHandler_IRunnableObject_VTable;
This->lpVtbl = &DefaultHandler_IOleObject_VTable;
This->lpvtblIUnknown = &DefaultHandler_NDIUnknown_VTable;
This->lpvtblIDataObject = &DefaultHandler_IDataObject_VTable;
This->lpvtblIRunnableObject = &DefaultHandler_IRunnableObject_VTable;
/*
* Start with one reference count. The caller of this function
* must release the interface pointer when it is done.
*/
newObject->ref = 1;
This->ref = 1;
/*
* Initialize the outer unknown
@ -1377,86 +1290,73 @@ static DefaultHandler* DefaultHandler_Construct(
* aggregation works, our lifetime is at least as large as it's
* lifetime.
*/
if (pUnkOuter==NULL)
pUnkOuter = (IUnknown*)&(newObject->lpvtblIUnknown);
if (!pUnkOuter)
pUnkOuter = (IUnknown*)&This->lpvtblIUnknown;
newObject->outerUnknown = pUnkOuter;
This->outerUnknown = pUnkOuter;
/*
* Create a datacache object.
* We aggregate with the datacache. Make sure we pass our outer
* unknown as the datacache's outer unknown.
*/
CreateDataCache(newObject->outerUnknown,
CreateDataCache(This->outerUnknown,
clsid,
&IID_IUnknown,
(void**)&newObject->dataCache);
(void**)&This->dataCache);
/*
* Initialize the other data members of the class.
*/
memcpy(&(newObject->clsid), clsid, sizeof(CLSID));
newObject->clientSite = NULL;
newObject->oleAdviseHolder = NULL;
newObject->dataAdviseHolder = NULL;
newObject->containerApp = NULL;
newObject->containerObj = NULL;
memcpy(&This->clsid, clsid, sizeof(CLSID));
This->clientSite = NULL;
This->oleAdviseHolder = NULL;
This->dataAdviseHolder = NULL;
This->containerApp = NULL;
This->containerObj = NULL;
return newObject;
return This;
}
static void DefaultHandler_Destroy(
DefaultHandler* ptrToDestroy)
DefaultHandler* This)
{
/*
* Free the strings idenfitying the object
*/
HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerApp );
ptrToDestroy->containerApp = NULL;
HeapFree( GetProcessHeap(), 0, ptrToDestroy->containerObj );
ptrToDestroy->containerObj = NULL;
/* Free the strings idenfitying the object */
HeapFree( GetProcessHeap(), 0, This->containerApp );
This->containerApp = NULL;
HeapFree( GetProcessHeap(), 0, This->containerObj );
This->containerObj = NULL;
/*
* Release our reference to the data cache.
*/
if (ptrToDestroy->dataCache!=NULL)
/* Release our reference to the data cache. */
if (This->dataCache)
{
IUnknown_Release(ptrToDestroy->dataCache);
ptrToDestroy->dataCache = NULL;
IUnknown_Release(This->dataCache);
This->dataCache = NULL;
}
/*
* Same thing for the client site.
*/
if (ptrToDestroy->clientSite!=NULL)
/* Same thing for the client site. */
if (This->clientSite)
{
IOleClientSite_Release(ptrToDestroy->clientSite);
ptrToDestroy->clientSite = NULL;
IOleClientSite_Release(This->clientSite);
This->clientSite = NULL;
}
/*
* And the advise holder.
*/
if (ptrToDestroy->oleAdviseHolder!=NULL)
/* And the advise holder. */
if (This->oleAdviseHolder)
{
IOleAdviseHolder_Release(ptrToDestroy->oleAdviseHolder);
ptrToDestroy->oleAdviseHolder = NULL;
IOleAdviseHolder_Release(This->oleAdviseHolder);
This->oleAdviseHolder = NULL;
}
/*
* And the data advise holder.
*/
if (ptrToDestroy->dataAdviseHolder!=NULL)
/* And the data advise holder. */
if (This->dataAdviseHolder)
{
IDataAdviseHolder_Release(ptrToDestroy->dataAdviseHolder);
ptrToDestroy->dataAdviseHolder = NULL;
IDataAdviseHolder_Release(This->dataAdviseHolder);
This->dataAdviseHolder = NULL;
}
/*
* Free the actual default handler structure.
*/
HeapFree(GetProcessHeap(), 0, ptrToDestroy);
/* Free the actual default handler structure. */
HeapFree(GetProcessHeap(), 0, This);
}
/******************************************************************************
@ -1482,20 +1382,18 @@ HRESULT WINAPI OleCreateDefaultHandler(
*ppvObj = NULL;
/*
* If this handler is constructed for aggregation, make sure
* If This handler is constructed for aggregation, make sure
* the caller is requesting the IUnknown interface.
* This is necessary because it's the only time the non-delegating
* IUnknown pointer can be returned to the outside.
*/
if ( (pUnkOuter!=NULL) &&
(IsEqualIID(&IID_IUnknown, riid)) )
if (pUnkOuter && IsEqualIID(&IID_IUnknown, riid))
return CLASS_E_NOAGGREGATION;
/*
* Try to construct a new instance of the class.
*/
newHandler = DefaultHandler_Construct(clsid,
pUnkOuter);
newHandler = DefaultHandler_Construct(clsid, pUnkOuter);
if (!newHandler)
return E_OUTOFMEMORY;
@ -1503,13 +1401,13 @@ HRESULT WINAPI OleCreateDefaultHandler(
/*
* Make sure it supports the interface required by the caller.
*/
hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtblIUnknown), riid, ppvObj);
hr = IUnknown_QueryInterface((IUnknown*)&newHandler->lpvtblIUnknown, riid, ppvObj);
/*
* Release the reference obtained in the constructor. If
* the QueryInterface was unsuccessful, it will free the class.
*/
IUnknown_Release((IUnknown*)&(newHandler->lpvtblIUnknown));
IUnknown_Release((IUnknown*)&newHandler->lpvtblIUnknown);
return hr;
}