ole32: COM cleanup in itemmoniker.c.
This commit is contained in:
parent
bf7df85169
commit
d3c934adcd
|
@ -40,26 +40,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||||
|
|
||||||
/* ItemMoniker data structure */
|
/* ItemMoniker data structure */
|
||||||
typedef struct ItemMonikerImpl{
|
typedef struct ItemMonikerImpl{
|
||||||
|
IMoniker IMoniker_iface; /* VTable relative to the IMoniker interface.*/
|
||||||
const IMonikerVtbl* lpvtbl1; /* VTable relative to the IMoniker interface.*/
|
IROTData IROTData_iface; /* VTable relative to the IROTData interface.*/
|
||||||
|
LONG ref;
|
||||||
/* The ROT (RunningObjectTable implementation) uses the IROTData interface to test whether
|
|
||||||
* two monikers are equal. That's whay IROTData interface is implemented by monikers.
|
|
||||||
*/
|
|
||||||
const IROTDataVtbl* lpvtbl2; /* VTable relative to the IROTData interface.*/
|
|
||||||
|
|
||||||
LONG ref; /* reference counter for this object */
|
|
||||||
|
|
||||||
LPOLESTR itemName; /* item name identified by this ItemMoniker */
|
LPOLESTR itemName; /* item name identified by this ItemMoniker */
|
||||||
|
|
||||||
LPOLESTR itemDelimiter; /* Delimiter string */
|
LPOLESTR itemDelimiter; /* Delimiter string */
|
||||||
|
|
||||||
IUnknown *pMarshal; /* custom marshaler */
|
IUnknown *pMarshal; /* custom marshaler */
|
||||||
} ItemMonikerImpl;
|
} ItemMonikerImpl;
|
||||||
|
|
||||||
static inline IMoniker *impl_from_IROTData( IROTData *iface )
|
static inline ItemMonikerImpl *impl_from_IMoniker(IMoniker *iface)
|
||||||
{
|
{
|
||||||
return (IMoniker *)((char*)iface - FIELD_OFFSET(ItemMonikerImpl, lpvtbl2));
|
return CONTAINING_RECORD(iface, ItemMonikerImpl, IMoniker_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ItemMonikerImpl *impl_from_IROTData(IROTData *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, ItemMonikerImpl, IROTData_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
|
static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
|
||||||
|
@ -69,7 +65,7 @@ static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* iface);
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
|
static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
|
||||||
|
|
||||||
|
@ -89,7 +85,7 @@ static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid
|
||||||
*ppvObject = iface;
|
*ppvObject = iface;
|
||||||
|
|
||||||
else if (IsEqualIID(&IID_IROTData, riid))
|
else if (IsEqualIID(&IID_IROTData, riid))
|
||||||
*ppvObject = &This->lpvtbl2;
|
*ppvObject = &This->IROTData_iface;
|
||||||
else if (IsEqualIID(&IID_IMarshal, riid))
|
else if (IsEqualIID(&IID_IMarshal, riid))
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
@ -115,7 +111,7 @@ static HRESULT WINAPI ItemMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
|
static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
TRACE("(%p)\n",This);
|
TRACE("(%p)\n",This);
|
||||||
|
|
||||||
|
@ -127,7 +123,7 @@ static ULONG WINAPI ItemMonikerImpl_AddRef(IMoniker* iface)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
|
static ULONG WINAPI ItemMonikerImpl_Release(IMoniker* iface)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
ULONG ref;
|
ULONG ref;
|
||||||
|
|
||||||
TRACE("(%p)\n",This);
|
TRACE("(%p)\n",This);
|
||||||
|
@ -174,8 +170,7 @@ static HRESULT WINAPI ItemMonikerImpl_IsDirty(IMoniker* iface)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
||||||
{
|
{
|
||||||
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
DWORD delimiterLength,nameLength,lenW;
|
DWORD delimiterLength,nameLength,lenW;
|
||||||
CHAR *itemNameA,*itemDelimiterA;
|
CHAR *itemNameA,*itemDelimiterA;
|
||||||
|
@ -241,11 +236,9 @@ static HRESULT WINAPI ItemMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ItemMoniker_Save
|
* ItemMoniker_Save
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface,
|
static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
|
||||||
IStream* pStm,/* pointer to the stream where the object is to be saved */
|
|
||||||
BOOL fClearDirty)/* Specifies whether to clear the dirty flag */
|
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
CHAR *itemNameA,*itemDelimiterA;
|
CHAR *itemNameA,*itemDelimiterA;
|
||||||
|
|
||||||
|
@ -277,10 +270,9 @@ static HRESULT WINAPI ItemMonikerImpl_Save(IMoniker* iface,
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ItemMoniker_GetSizeMax
|
* ItemMoniker_GetSizeMax
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
|
static HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ULARGE_INTEGER* pcbSize)
|
||||||
ULARGE_INTEGER* pcbSize)/* Pointer to size of stream needed to save object */
|
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1;
|
DWORD delimiterLength=lstrlenW(This->itemDelimiter)+1;
|
||||||
DWORD nameLength=lstrlenW(This->itemName)+1;
|
DWORD nameLength=lstrlenW(This->itemName)+1;
|
||||||
|
|
||||||
|
@ -310,8 +302,7 @@ static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface,
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
VOID** ppvResult)
|
VOID** ppvResult)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
IID refid=IID_IOleItemContainer;
|
IID refid=IID_IOleItemContainer;
|
||||||
IOleItemContainer *poic=0;
|
IOleItemContainer *poic=0;
|
||||||
|
@ -347,8 +338,7 @@ static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface,
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
VOID** ppvResult)
|
VOID** ppvResult)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
IOleItemContainer *poic=0;
|
IOleItemContainer *poic=0;
|
||||||
|
|
||||||
|
@ -519,7 +509,7 @@ static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOther
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
static HRESULT WINAPI ItemMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
DWORD h = 0;
|
DWORD h = 0;
|
||||||
int i,len;
|
int i,len;
|
||||||
int off = 0;
|
int off = 0;
|
||||||
|
@ -547,10 +537,10 @@ static HRESULT WINAPI ItemMonikerImpl_IsRunning(IMoniker* iface,
|
||||||
IMoniker* pmkToLeft,
|
IMoniker* pmkToLeft,
|
||||||
IMoniker* pmkNewlyRunning)
|
IMoniker* pmkNewlyRunning)
|
||||||
{
|
{
|
||||||
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
IRunningObjectTable* rot;
|
IRunningObjectTable* rot;
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
IOleItemContainer *poic=0;
|
IOleItemContainer *poic=0;
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
|
||||||
|
|
||||||
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
|
||||||
|
|
||||||
|
@ -695,7 +685,7 @@ static HRESULT WINAPI ItemMonikerImpl_GetDisplayName(IMoniker* iface,
|
||||||
IMoniker* pmkToLeft,
|
IMoniker* pmkToLeft,
|
||||||
LPOLESTR *ppszDisplayName)
|
LPOLESTR *ppszDisplayName)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
|
|
||||||
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
|
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
|
||||||
|
|
||||||
|
@ -729,11 +719,11 @@ static HRESULT WINAPI ItemMonikerImpl_ParseDisplayName(IMoniker* iface,
|
||||||
ULONG* pchEaten,
|
ULONG* pchEaten,
|
||||||
IMoniker** ppmkOut)
|
IMoniker** ppmkOut)
|
||||||
{
|
{
|
||||||
|
ItemMonikerImpl *This = impl_from_IMoniker(iface);
|
||||||
IOleItemContainer* poic=0;
|
IOleItemContainer* poic=0;
|
||||||
IParseDisplayName* ppdn=0;
|
IParseDisplayName* ppdn=0;
|
||||||
LPOLESTR displayName;
|
LPOLESTR displayName;
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
ItemMonikerImpl *This = (ItemMonikerImpl *)iface;
|
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(pszDisplayName));
|
TRACE("%s\n", debugstr_w(pszDisplayName));
|
||||||
|
|
||||||
|
@ -781,14 +771,15 @@ static HRESULT WINAPI ItemMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwd
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* ItemMonikerIROTData_QueryInterface
|
* ItemMonikerIROTData_QueryInterface
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
|
static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,
|
||||||
|
void **ppvObject)
|
||||||
{
|
{
|
||||||
|
|
||||||
IMoniker *This = impl_from_IROTData(iface);
|
ItemMonikerImpl *This = impl_from_IROTData(iface);
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
|
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
|
||||||
|
|
||||||
return ItemMonikerImpl_QueryInterface(This, riid, ppvObject);
|
return ItemMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -796,11 +787,11 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFI
|
||||||
*/
|
*/
|
||||||
static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
|
static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
|
||||||
{
|
{
|
||||||
IMoniker *This = impl_from_IROTData(iface);
|
ItemMonikerImpl *This = impl_from_IROTData(iface);
|
||||||
|
|
||||||
TRACE("(%p)\n",iface);
|
TRACE("(%p)\n",iface);
|
||||||
|
|
||||||
return ItemMonikerImpl_AddRef(This);
|
return ItemMonikerImpl_AddRef(&This->IMoniker_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -808,11 +799,11 @@ static ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
|
||||||
*/
|
*/
|
||||||
static ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface)
|
static ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface)
|
||||||
{
|
{
|
||||||
IMoniker *This = impl_from_IROTData(iface);
|
ItemMonikerImpl *This = impl_from_IROTData(iface);
|
||||||
|
|
||||||
TRACE("(%p)\n",iface);
|
TRACE("(%p)\n",iface);
|
||||||
|
|
||||||
return ItemMonikerImpl_Release(This);
|
return ItemMonikerImpl_Release(&This->IMoniker_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -823,9 +814,8 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,
|
||||||
ULONG cbMax,
|
ULONG cbMax,
|
||||||
ULONG* pcbData)
|
ULONG* pcbData)
|
||||||
{
|
{
|
||||||
IMoniker *This = impl_from_IROTData(iface);
|
ItemMonikerImpl *This = impl_from_IROTData(iface);
|
||||||
ItemMonikerImpl *This1 = (ItemMonikerImpl *)This;
|
int len = (strlenW(This->itemName)+1);
|
||||||
int len = (strlenW(This1->itemName)+1);
|
|
||||||
int i;
|
int i;
|
||||||
LPWSTR pszItemName;
|
LPWSTR pszItemName;
|
||||||
LPWSTR pszItemDelimiter;
|
LPWSTR pszItemDelimiter;
|
||||||
|
@ -840,11 +830,11 @@ static HRESULT WINAPI ItemMonikerROTDataImpl_GetComparisonData(IROTData* iface,
|
||||||
memcpy(pbData, &CLSID_ItemMoniker, sizeof(CLSID));
|
memcpy(pbData, &CLSID_ItemMoniker, sizeof(CLSID));
|
||||||
/* write delimiter */
|
/* write delimiter */
|
||||||
pszItemDelimiter = (LPWSTR)(pbData+sizeof(CLSID));
|
pszItemDelimiter = (LPWSTR)(pbData+sizeof(CLSID));
|
||||||
*pszItemDelimiter = *This1->itemDelimiter;
|
*pszItemDelimiter = *This->itemDelimiter;
|
||||||
/* write name */
|
/* write name */
|
||||||
pszItemName = pszItemDelimiter + 1;
|
pszItemName = pszItemDelimiter + 1;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
pszItemName[i] = toupperW(This1->itemName[i]);
|
pszItemName[i] = toupperW(This->itemName[i]);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -902,8 +892,8 @@ static HRESULT ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDe
|
||||||
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszDelim),debugstr_w(lpszItem));
|
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszDelim),debugstr_w(lpszItem));
|
||||||
|
|
||||||
/* Initialize the virtual function table. */
|
/* Initialize the virtual function table. */
|
||||||
This->lpvtbl1 = &VT_ItemMonikerImpl;
|
This->IMoniker_iface.lpVtbl = &VT_ItemMonikerImpl;
|
||||||
This->lpvtbl2 = &VT_ROTDataImpl;
|
This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
|
||||||
This->ref = 0;
|
This->ref = 0;
|
||||||
This->pMarshal = NULL;
|
This->pMarshal = NULL;
|
||||||
|
|
||||||
|
@ -945,7 +935,7 @@ static HRESULT ItemMonikerImpl_Destroy(ItemMonikerImpl* This)
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* CreateItemMoniker [OLE32.@]
|
* CreateItemMoniker [OLE32.@]
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONIKER * ppmk)
|
HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim, LPCOLESTR lpszItem, IMoniker **ppmk)
|
||||||
{
|
{
|
||||||
ItemMonikerImpl* newItemMoniker;
|
ItemMonikerImpl* newItemMoniker;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -965,7 +955,8 @@ HRESULT WINAPI CreateItemMoniker(LPCOLESTR lpszDelim,LPCOLESTR lpszItem, LPMONI
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker,&IID_IMoniker,(void**)ppmk);
|
return ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface,&IID_IMoniker,
|
||||||
|
(void**)ppmk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI ItemMonikerCF_QueryInterface(LPCLASSFACTORY iface,
|
static HRESULT WINAPI ItemMonikerCF_QueryInterface(LPCLASSFACTORY iface,
|
||||||
|
@ -1012,7 +1003,7 @@ static HRESULT WINAPI ItemMonikerCF_CreateInstance(LPCLASSFACTORY iface,
|
||||||
hr = ItemMonikerImpl_Construct(newItemMoniker, wszEmpty, wszEmpty);
|
hr = ItemMonikerImpl_Construct(newItemMoniker, wszEmpty, wszEmpty);
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
hr = ItemMonikerImpl_QueryInterface((IMoniker*)newItemMoniker, riid, ppv);
|
hr = ItemMonikerImpl_QueryInterface(&newItemMoniker->IMoniker_iface, riid, ppv);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
HeapFree(GetProcessHeap(),0,newItemMoniker);
|
HeapFree(GetProcessHeap(),0,newItemMoniker);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue