shell32: Use the paste_pidls() helper function for the CFSTR_SHELLIDLISTW format too.

Signed-off-by: Damjan Jovanovic <damjan.jov@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Damjan Jovanovic 2021-05-25 07:53:46 +02:00 committed by Alexandre Julliard
parent 91b0340170
commit 9bc7d41080
1 changed files with 17 additions and 59 deletions

View File

@ -1182,15 +1182,15 @@ static HRESULT paste_pidls(ContextMenu *This, ITEMIDLIST **pidls, UINT count)
return hr; return hr;
} }
static BOOL DoPaste(ContextMenu *This) static HRESULT DoPaste(ContextMenu *This)
{ {
BOOL bSuccess = TRUE;
IDataObject * pda; IDataObject * pda;
HRESULT hr; HRESULT hr;
TRACE("\n"); TRACE("\n");
if(SUCCEEDED(OleGetClipboard(&pda))) hr = OleGetClipboard(&pda);
if(SUCCEEDED(hr))
{ {
STGMEDIUM medium; STGMEDIUM medium;
FORMATETC formatetc; FORMATETC formatetc;
@ -1204,68 +1204,29 @@ static BOOL DoPaste(ContextMenu *This)
/* Get the pidls from IDataObject */ /* Get the pidls from IDataObject */
format_hr = IDataObject_GetData(pda,&formatetc,&medium); format_hr = IDataObject_GetData(pda,&formatetc,&medium);
if(SUCCEEDED(format_hr)) if(SUCCEEDED(format_hr))
{ {
LPITEMIDLIST * apidl; LPITEMIDLIST * apidl;
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
IShellFolder *psfFrom = NULL, *psfDesktop;
int i;
LPIDA lpcida = GlobalLock(medium.u.hGlobal); LPIDA lpcida = GlobalLock(medium.u.hGlobal);
TRACE("cida=%p\n", lpcida); TRACE("cida=%p\n", lpcida);
if(lpcida)
apidl = _ILCopyCidaToaPidl(&pidl, lpcida); {
apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
for (i = 0; bSuccess && i < lpcida->cidl; i++) { if (apidl)
ITEMIDLIST *apidl_dir = NULL;
ITEMIDLIST *apidl_item;
psfFrom = NULL;
/* bind to the source shellfolder */
SHGetDesktopFolder(&psfDesktop);
if(psfDesktop)
{ {
apidl_dir = ILClone(apidl[i]); hr = paste_pidls(This, apidl, lpcida->cidl);
ILRemoveLastID(apidl_dir); _ILFreeaPidl(apidl, lpcida->cidl);
apidl_item = ILFindLastID(apidl[i]); SHFree(pidl);
IShellFolder_BindToObject(psfDesktop, apidl_dir, NULL, &IID_IShellFolder, (LPVOID*)&psfFrom);
IShellFolder_Release(psfDesktop);
}
if (psfFrom)
{
/* 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);
} }
else else
bSuccess = FALSE; hr = HRESULT_FROM_WIN32(GetLastError());
SHFree(apidl_dir); GlobalUnlock(medium.u.hGlobal);
} }
else
_ILFreeaPidl(apidl, lpcida->cidl); hr = HRESULT_FROM_WIN32(GetLastError());
SHFree(pidl);
GlobalUnlock(medium.u.hGlobal);
/* release the medium*/
ReleaseStgMedium(&medium); ReleaseStgMedium(&medium);
} }
else
bSuccess = FALSE;
if(FAILED(format_hr)) if(FAILED(format_hr))
{ {
@ -1298,20 +1259,17 @@ static BOOL DoPaste(ContextMenu *This)
else else
hr = HRESULT_FROM_WIN32(GetLastError()); hr = HRESULT_FROM_WIN32(GetLastError());
ReleaseStgMedium(&medium); ReleaseStgMedium(&medium);
bSuccess = SUCCEEDED(hr);
} }
} }
if (FAILED(format_hr)) if (FAILED(format_hr))
{ {
ERR("there are no supported and retrievable clipboard formats\n"); ERR("there are no supported and retrievable clipboard formats\n");
bSuccess = FALSE; hr = format_hr;
} }
IDataObject_Release(pda); IDataObject_Release(pda);
} }
else
bSuccess = FALSE;
#if 0 #if 0
HGLOBAL hMem; HGLOBAL hMem;
@ -1336,7 +1294,7 @@ static BOOL DoPaste(ContextMenu *This)
} }
CloseClipboard(); CloseClipboard();
#endif #endif
return bSuccess; return hr;
} }
static HRESULT WINAPI BackgroundMenu_InvokeCommand( static HRESULT WINAPI BackgroundMenu_InvokeCommand(