Damjan Jovanovic : shell32: Use the paste_pidls() helper function for the CFSTR_SHELLIDLISTW format too.
Alexandre Julliard
julliard at winehq.org
Wed May 26 15:46:27 CDT 2021
Module: wine
Branch: master
Commit: 9bc7d41080f5e6805154b9d52a765f2be5d37279
URL: https://source.winehq.org/git/wine.git/?a=commit;h=9bc7d41080f5e6805154b9d52a765f2be5d37279
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Tue May 25 07:53:46 2021 +0200
shell32: Use the paste_pidls() helper function for the CFSTR_SHELLIDLISTW format too.
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/shell32/shlview_cmenu.c | 76 ++++++++++----------------------------------
1 file changed, 17 insertions(+), 59 deletions(-)
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c
index dd03c64e654..ef11957e921 100644
--- a/dlls/shell32/shlview_cmenu.c
+++ b/dlls/shell32/shlview_cmenu.c
@@ -1182,15 +1182,15 @@ static HRESULT paste_pidls(ContextMenu *This, ITEMIDLIST **pidls, UINT count)
return hr;
}
-static BOOL DoPaste(ContextMenu *This)
+static HRESULT DoPaste(ContextMenu *This)
{
- BOOL bSuccess = TRUE;
IDataObject * pda;
HRESULT hr;
TRACE("\n");
- if(SUCCEEDED(OleGetClipboard(&pda)))
+ hr = OleGetClipboard(&pda);
+ if(SUCCEEDED(hr))
{
STGMEDIUM medium;
FORMATETC formatetc;
@@ -1204,68 +1204,29 @@ static BOOL DoPaste(ContextMenu *This)
/* Get the pidls from IDataObject */
format_hr = IDataObject_GetData(pda,&formatetc,&medium);
if(SUCCEEDED(format_hr))
- {
+ {
LPITEMIDLIST * apidl;
LPITEMIDLIST pidl;
- IShellFolder *psfFrom = NULL, *psfDesktop;
- int i;
LPIDA lpcida = GlobalLock(medium.u.hGlobal);
TRACE("cida=%p\n", lpcida);
-
- apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
-
- for (i = 0; bSuccess && i < lpcida->cidl; i++) {
- ITEMIDLIST *apidl_dir = NULL;
- ITEMIDLIST *apidl_item;
-
- psfFrom = NULL;
- /* bind to the source shellfolder */
- SHGetDesktopFolder(&psfDesktop);
- if(psfDesktop)
- {
- apidl_dir = ILClone(apidl[i]);
- ILRemoveLastID(apidl_dir);
- apidl_item = ILFindLastID(apidl[i]);
- IShellFolder_BindToObject(psfDesktop, apidl_dir, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
- IShellFolder_Release(psfDesktop);
- }
-
- if (psfFrom)
+ if(lpcida)
+ {
+ apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
+ if (apidl)
{
- /* get source and destination shellfolder */
- ISFHelper *psfhlpdst, *psfhlpsrc;
- IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&psfhlpdst);
- IShellFolder_QueryInterface(psfFrom, &IID_ISFHelper, (void**)&psfhlpsrc);
-
- /* do the copy/move */
- if (psfhlpdst && psfhlpsrc)
- {
- HRESULT hr = ISFHelper_CopyItems(psfhlpdst, psfFrom, 1, (LPCITEMIDLIST*)&apidl_item);
- if (FAILED(hr))
- bSuccess = FALSE;
- /* FIXME handle move
- ISFHelper_DeleteItems(psfhlpsrc, 1, &apidl_item);
- */
- }
- if(psfhlpdst) ISFHelper_Release(psfhlpdst);
- if(psfhlpsrc) ISFHelper_Release(psfhlpsrc);
- IShellFolder_Release(psfFrom);
+ hr = paste_pidls(This, apidl, lpcida->cidl);
+ _ILFreeaPidl(apidl, lpcida->cidl);
+ SHFree(pidl);
}
else
- bSuccess = FALSE;
- SHFree(apidl_dir);
+ hr = HRESULT_FROM_WIN32(GetLastError());
+ GlobalUnlock(medium.u.hGlobal);
}
-
- _ILFreeaPidl(apidl, lpcida->cidl);
- SHFree(pidl);
- GlobalUnlock(medium.u.hGlobal);
-
- /* release the medium*/
+ else
+ hr = HRESULT_FROM_WIN32(GetLastError());
ReleaseStgMedium(&medium);
}
- else
- bSuccess = FALSE;
if(FAILED(format_hr))
{
@@ -1298,20 +1259,17 @@ static BOOL DoPaste(ContextMenu *This)
else
hr = HRESULT_FROM_WIN32(GetLastError());
ReleaseStgMedium(&medium);
- bSuccess = SUCCEEDED(hr);
}
}
if (FAILED(format_hr))
{
ERR("there are no supported and retrievable clipboard formats\n");
- bSuccess = FALSE;
+ hr = format_hr;
}
IDataObject_Release(pda);
}
- else
- bSuccess = FALSE;
#if 0
HGLOBAL hMem;
@@ -1336,7 +1294,7 @@ static BOOL DoPaste(ContextMenu *This)
}
CloseClipboard();
#endif
- return bSuccess;
+ return hr;
}
static HRESULT WINAPI BackgroundMenu_InvokeCommand(
More information about the wine-cvs
mailing list