shell32: Avoid casts when creating item menu.

This commit is contained in:
Nikolay Sivov 2012-01-11 05:02:03 +03:00 committed by Alexandre Julliard
parent 3efda60ef6
commit 72a7c34109
9 changed files with 23 additions and 26 deletions

View File

@ -600,8 +600,7 @@ static HRESULT WINAPI ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 *iface, HWN
*ppvOut = NULL;
if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
pObj = (LPUNKNOWN) ItemMenu_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
hr = S_OK;
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
hr = S_OK;

View File

@ -78,7 +78,7 @@ LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST myPidl, LPCIT
LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT, const FORMATETC []) DECLSPEC_HIDDEN;
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID) DECLSPEC_HIDDEN;
IContextMenu2 * ItemMenu_Constructor(IShellFolder*, LPCITEMIDLIST, const LPCITEMIDLIST*, UINT) DECLSPEC_HIDDEN;
HRESULT ItemMenu_Constructor(IShellFolder*, LPCITEMIDLIST, const LPCITEMIDLIST*, UINT, REFIID, void**) DECLSPEC_HIDDEN;
HRESULT BackgroundMenu_Constructor(IShellFolder*, BOOL, REFIID, void**) DECLSPEC_HIDDEN;
LPSHELLVIEW IShellView_Constructor(LPSHELLFOLDER) DECLSPEC_HIDDEN;

View File

@ -530,10 +530,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
if (IsEqualIID (riid, &IID_IContextMenu))
{
if (cidl > 0)
{
pObj = (LPUNKNOWN) ItemMenu_Constructor( (IShellFolder *) iface, This->pidlRoot, apidl, cidl);
hr = S_OK;
}
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
else
return BackgroundMenu_Constructor((IShellFolder*)iface, TRUE, riid, ppvOut);
}

View File

@ -744,9 +744,7 @@ IShellFolder_fnGetUIObjectOf (IShellFolder2 * iface,
}
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
pObj = (LPUNKNOWN) ItemMenu_Constructor ((IShellFolder *) iface,
This->pidlRoot, apidl, cidl);
hr = S_OK;
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
} else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner,
This->pidlRoot, apidl, cidl);

View File

@ -532,9 +532,7 @@ static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
{
pObj = (LPUNKNOWN) ItemMenu_Constructor ((IShellFolder *) iface,
This->pidlRoot, apidl, cidl);
hr = S_OK;
return ItemMenu_Constructor((IShellFolder*) iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
}
else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
{

View File

@ -426,8 +426,7 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetUIObjectOf (IShellFolder2 * iface,
if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
{
pObj = (LPUNKNOWN) ItemMenu_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
hr = S_OK;
return ItemMenu_Constructor((IShellFolder*)iface, This->pidlRoot, apidl, cidl, riid, ppvOut);
}
else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
{

View File

@ -1165,10 +1165,9 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetUIObjectOf(IShellFolder2* ifac
if(hr != S_FALSE)
return hr;
}
if (IsEqualIID(&IID_IContextMenu, riid)) {
*ppvOut = ItemMenu_Constructor((IShellFolder*)iface, This->m_pidlLocation, apidl, cidl);
return S_OK;
return ItemMenu_Constructor((IShellFolder*)iface, This->m_pidlLocation, apidl, cidl, riid, ppvOut);
} else if (IsEqualIID(&IID_IDataObject, riid)) {
*ppvOut = IDataObject_Constructor(hwndOwner, This->m_pidlLocation, apidl, cidl);
return S_OK;

View File

@ -1275,7 +1275,8 @@ HRESULT WINAPI CDefFolderMenu_Create2(LPCITEMIDLIST pidlFolder, HWND hwnd, UINT
}
else
folder_pidl=ILClone(pidlFolder);
system_menu = (IContextMenu*)ItemMenu_Constructor(psf,folder_pidl,(const LPCITEMIDLIST*)apidl,cidl);
ItemMenu_Constructor(psf, folder_pidl, (const LPCITEMIDLIST*)apidl, cidl, &IID_IContextMenu, (void**)&system_menu);
hres= SHELL_CreateContextMenu(hwnd,system_menu,psf,folder_pidl,apidl,cidl,ahkeys,nKeys,&IID_IContextMenu,(void**)ppcm);
IContextMenu_Release(system_menu);
ILFree(folder_pidl);
@ -1300,7 +1301,8 @@ HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID rii
folder_pidl=ILClone(pdcm->pidlFolder);
if(pdcm->cKeys==0)
FIXME("Loading shell extensions using IQueryAssociations not yet supported\n");
system_menu = (IContextMenu*)ItemMenu_Constructor(folder,folder_pidl,(const LPCITEMIDLIST*)pdcm->apidl,pdcm->cidl);
ItemMenu_Constructor(folder, folder_pidl, (const LPCITEMIDLIST*)pdcm->apidl, pdcm->cidl, &IID_IContextMenu, (void**)&system_menu);
ret = SHELL_CreateContextMenu(pdcm->hwnd,system_menu,folder,folder_pidl,(LPCITEMIDLIST*)pdcm->apidl,pdcm->cidl,pdcm->aKeys,pdcm->cKeys,riid,ppv);
IContextMenu_Release(system_menu);
ILFree(folder_pidl);

View File

@ -569,12 +569,16 @@ static const IContextMenu3Vtbl ItemContextMenuVtbl =
ContextMenu_HandleMenuMsg2
};
IContextMenu2 *ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl)
HRESULT ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, const LPCITEMIDLIST *apidl, UINT cidl,
REFIID riid, void **pObj)
{
ContextMenu* This;
UINT u;
HRESULT hr;
int i;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IContextMenu3_iface.lpVtbl = &ItemContextMenuVtbl;
This->ref = 1;
This->verb_offset = 0;
@ -588,12 +592,13 @@ IContextMenu2 *ItemMenu_Constructor(IShellFolder *parent, LPCITEMIDLIST pidl, co
This->desktop = FALSE;
for(u = 0; u < cidl; u++)
This->allvalues &= (_ILIsValue(apidl[u]) ? 1 : 0);
for (i = 0; i < cidl; i++)
This->allvalues &= (_ILIsValue(apidl[i]) ? 1 : 0);
TRACE("(%p)\n", This);
hr = IContextMenu3_QueryInterface(&This->IContextMenu3_iface, riid, pObj);
IContextMenu3_Release(&This->IContextMenu3_iface);
return (IContextMenu2*)&This->IContextMenu3_iface;
return hr;
}
/* Background menu implementation */