mirror of
https://github.com/reactos/reactos.git
synced 2024-07-12 23:55:07 +00:00
[SHELL32]
* Partial sync of clipboard.c with Wine 1.7.27. CORE-8540 svn path=/branches/shell-experiments/; revision=65293
This commit is contained in:
parent
4a6b43ac42
commit
98ab989c82
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* clipboard helper functions
|
* clipboard helper functions
|
||||||
*
|
*
|
||||||
* Copyright 2000 Juergen Schmied <juergen.schmied@debitel.de>
|
* Copyright 2000 Juergen Schmied <juergen.schmied@debitel.de>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -25,13 +25,13 @@
|
||||||
*
|
*
|
||||||
* - a right mousebutton-copy sets the following formats:
|
* - a right mousebutton-copy sets the following formats:
|
||||||
* classic:
|
* classic:
|
||||||
* Shell IDList Array
|
* Shell IDList Array
|
||||||
* Preferred Drop Effect
|
* Preferred Drop Effect
|
||||||
* Shell Object Offsets
|
* Shell Object Offsets
|
||||||
* HDROP
|
* HDROP
|
||||||
* FileName
|
* FileName
|
||||||
* ole:
|
* ole:
|
||||||
* OlePrivateData (ClipboardDataObjectInterface)
|
* OlePrivateData (ClipboardDataObjectInterface)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
|
#include <wine/unicode.h>
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
|
|
||||||
|
@ -52,100 +53,101 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
*/
|
*/
|
||||||
HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
{
|
{
|
||||||
UINT i;
|
UINT i;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
WCHAR wszFileName[MAX_PATH];
|
WCHAR wszFileName[MAX_PATH];
|
||||||
HGLOBAL hGlobal = NULL;
|
HGLOBAL hGlobal = NULL;
|
||||||
DROPFILES *pDropFiles;
|
DROPFILES *pDropFiles;
|
||||||
int offset;
|
int offset;
|
||||||
LPITEMIDLIST *pidls;
|
LPITEMIDLIST *pidls;
|
||||||
|
|
||||||
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
||||||
|
|
||||||
pidls = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls));
|
pidls = (LPITEMIDLIST *)HeapAlloc(GetProcessHeap(), 0, cidl * sizeof(*pidls));
|
||||||
if (!pidls)
|
if (!pidls)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* get the size needed */
|
/* get the size needed */
|
||||||
size = sizeof(DROPFILES);
|
size = sizeof(DROPFILES);
|
||||||
|
|
||||||
for (i=0; i<cidl;i++)
|
for (i=0; i<cidl;i++)
|
||||||
{
|
{
|
||||||
pidls[i] = ILCombine(pidlRoot, apidl[i]);
|
pidls[i] = ILCombine(pidlRoot, apidl[i]);
|
||||||
SHGetPathFromIDListW(pidls[i], wszFileName);
|
SHGetPathFromIDListW(pidls[i], wszFileName);
|
||||||
size += (wcslen(wszFileName) + 1) * sizeof(WCHAR);
|
size += (wcslen(wszFileName) + 1) * sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
size += sizeof(WCHAR);
|
size += sizeof(WCHAR);
|
||||||
|
|
||||||
/* Fill the structure */
|
/* Fill the structure */
|
||||||
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
||||||
if(!hGlobal)
|
if(!hGlobal)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
pDropFiles = (DROPFILES *)GlobalLock(hGlobal);
|
pDropFiles = (DROPFILES *)GlobalLock(hGlobal);
|
||||||
offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR);
|
offset = (sizeof(DROPFILES) + sizeof(WCHAR) - 1) / sizeof(WCHAR);
|
||||||
pDropFiles->pFiles = offset * sizeof(WCHAR);
|
pDropFiles->pFiles = offset * sizeof(WCHAR);
|
||||||
pDropFiles->fWide = TRUE;
|
pDropFiles->fWide = TRUE;
|
||||||
|
|
||||||
for (i=0; i<cidl;i++)
|
for (i=0; i<cidl;i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
SHGetPathFromIDListW(pidls[i], wszFileName);
|
SHGetPathFromIDListW(pidls[i], wszFileName);
|
||||||
wcscpy(((WCHAR*)pDropFiles)+offset, wszFileName);
|
wcscpy(((WCHAR*)pDropFiles)+offset, wszFileName);
|
||||||
offset += wcslen(wszFileName) + 1;
|
offset += wcslen(wszFileName) + 1;
|
||||||
ILFree(pidls[i]);
|
ILFree(pidls[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
((WCHAR*)pDropFiles)[offset] = 0;
|
((WCHAR*)pDropFiles)[offset] = 0;
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if(pidls)
|
if(pidls)
|
||||||
HeapFree(GetProcessHeap(), 0, pidls);
|
HeapFree(GetProcessHeap(), 0, pidls);
|
||||||
|
|
||||||
return hGlobal;
|
return hGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
{
|
{
|
||||||
UINT i;
|
UINT i;
|
||||||
int offset = 0, sizePidl, size;
|
int offset = 0, sizePidl, size;
|
||||||
HGLOBAL hGlobal;
|
HGLOBAL hGlobal;
|
||||||
LPIDA pcida;
|
LPIDA pcida;
|
||||||
|
|
||||||
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
||||||
|
|
||||||
/* get the size needed */
|
/* get the size needed */
|
||||||
size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */
|
size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */
|
||||||
size += ILGetSize (pidlRoot); /* root pidl */
|
size += ILGetSize (pidlRoot); /* root pidl */
|
||||||
for(i=0; i<cidl; i++)
|
for(i=0; i<cidl; i++)
|
||||||
{
|
{
|
||||||
size += ILGetSize(apidl[i]); /* child pidls */
|
size += ILGetSize(apidl[i]); /* child pidls */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill the structure */
|
/* fill the structure */
|
||||||
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
||||||
if(!hGlobal) return hGlobal;
|
if(!hGlobal) return hGlobal;
|
||||||
pcida = (LPIDA)GlobalLock (hGlobal);
|
pcida = GlobalLock (hGlobal);
|
||||||
pcida->cidl = cidl;
|
pcida->cidl = cidl;
|
||||||
|
|
||||||
/* root pidl */
|
/* root pidl */
|
||||||
offset = sizeof(CIDA) + sizeof (UINT)*(cidl);
|
offset = sizeof(CIDA) + sizeof (UINT)*(cidl);
|
||||||
pcida->aoffset[0] = offset; /* first element */
|
pcida->aoffset[0] = offset; /* first element */
|
||||||
sizePidl = ILGetSize (pidlRoot);
|
sizePidl = ILGetSize (pidlRoot);
|
||||||
memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl);
|
memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl);
|
||||||
offset += sizePidl;
|
offset += sizePidl;
|
||||||
|
|
||||||
for(i=0; i<cidl; i++) /* child pidls */
|
for(i=0; i<cidl; i++) /* child pidls */
|
||||||
{
|
{
|
||||||
pcida->aoffset[i+1] = offset;
|
pcida->aoffset[i+1] = offset;
|
||||||
sizePidl = ILGetSize(apidl[i]);
|
sizePidl = ILGetSize(apidl[i]);
|
||||||
memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl);
|
memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl);
|
||||||
offset += sizePidl;
|
offset += sizePidl;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
return hGlobal;
|
return hGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
|
@ -168,66 +170,66 @@ HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT
|
||||||
|
|
||||||
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char szTemp[MAX_PATH], *szFileName;
|
char szTemp[MAX_PATH], *szFileName;
|
||||||
LPITEMIDLIST pidl;
|
LPITEMIDLIST pidl;
|
||||||
HGLOBAL hGlobal;
|
HGLOBAL hGlobal;
|
||||||
BOOL bSuccess;
|
BOOL bSuccess;
|
||||||
|
|
||||||
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
||||||
|
|
||||||
/* get path of combined pidl */
|
/* get path of combined pidl */
|
||||||
pidl = ILCombine(pidlRoot, apidl[0]);
|
pidl = ILCombine(pidlRoot, apidl[0]);
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bSuccess = SHGetPathFromIDListA(pidl, szTemp);
|
bSuccess = SHGetPathFromIDListA(pidl, szTemp);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
if (!bSuccess)
|
if (!bSuccess)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size = strlen(szTemp) + 1;
|
size = strlen(szTemp) + 1;
|
||||||
|
|
||||||
/* fill the structure */
|
/* fill the structure */
|
||||||
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
||||||
if(!hGlobal) return hGlobal;
|
if(!hGlobal) return hGlobal;
|
||||||
szFileName = (char *)GlobalLock(hGlobal);
|
szFileName = GlobalLock(hGlobal);
|
||||||
memcpy(szFileName, szTemp, size);
|
memcpy(szFileName, szTemp, size);
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
|
|
||||||
return hGlobal;
|
return hGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
WCHAR szTemp[MAX_PATH], *szFileName;
|
WCHAR szTemp[MAX_PATH], *szFileName;
|
||||||
LPITEMIDLIST pidl;
|
LPITEMIDLIST pidl;
|
||||||
HGLOBAL hGlobal;
|
HGLOBAL hGlobal;
|
||||||
BOOL bSuccess;
|
BOOL bSuccess;
|
||||||
|
|
||||||
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
||||||
|
|
||||||
/* get path of combined pidl */
|
/* get path of combined pidl */
|
||||||
pidl = ILCombine(pidlRoot, apidl[0]);
|
pidl = ILCombine(pidlRoot, apidl[0]);
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bSuccess = SHGetPathFromIDListW(pidl, szTemp);
|
bSuccess = SHGetPathFromIDListW(pidl, szTemp);
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
if (!bSuccess)
|
if (!bSuccess)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size = (wcslen(szTemp)+1) * sizeof(WCHAR);
|
size = (strlenW(szTemp)+1) * sizeof(WCHAR);
|
||||||
|
|
||||||
/* fill the structure */
|
/* fill the structure */
|
||||||
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
||||||
if(!hGlobal) return hGlobal;
|
if(!hGlobal) return hGlobal;
|
||||||
szFileName = (WCHAR *)GlobalLock(hGlobal);
|
szFileName = GlobalLock(hGlobal);
|
||||||
memcpy(szFileName, szTemp, size);
|
memcpy(szFileName, szTemp, size);
|
||||||
GlobalUnlock(hGlobal);
|
GlobalUnlock(hGlobal);
|
||||||
|
|
||||||
return hGlobal;
|
return hGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags)
|
HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags)
|
||||||
|
|
Loading…
Reference in a new issue