2000-02-20 19:46:28 +01:00
|
|
|
/*
|
|
|
|
* clipboard helper functions
|
|
|
|
*
|
|
|
|
* Copyright 2000 Juergen Schmied <juergen.schmied@debitel.de>
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
*
|
2000-02-20 19:46:28 +01:00
|
|
|
* For copy & paste functions within contextmenus does the shell use
|
|
|
|
* the OLE clipboard functions in combination with dataobjects.
|
|
|
|
* The OLE32.DLL gets loaded with LoadLibrary
|
|
|
|
*
|
|
|
|
* - a right mousebutton-copy sets the following formats:
|
|
|
|
* classic:
|
|
|
|
* Shell IDList Array
|
2005-03-02 14:53:50 +01:00
|
|
|
* Preferred Drop Effect
|
2000-02-20 19:46:28 +01:00
|
|
|
* Shell Object Offsets
|
|
|
|
* HDROP
|
|
|
|
* FileName
|
|
|
|
* ole:
|
|
|
|
* OlePrivateData (ClipboardDataObjectInterface)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-20 19:46:28 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "winreg.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "wingdi.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "pidl.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
#include "shell32_main.h"
|
2001-12-11 01:30:17 +01:00
|
|
|
#include "shlwapi.h"
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2003-07-26 22:32:43 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* RenderHDROP
|
|
|
|
*
|
|
|
|
* creates a CF_HDROP structure
|
|
|
|
*/
|
|
|
|
HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
2002-12-13 01:36:52 +01:00
|
|
|
UINT i;
|
2000-02-20 19:46:28 +01:00
|
|
|
int rootsize = 0,size = 0;
|
|
|
|
char szRootPath[MAX_PATH];
|
|
|
|
char szFileName[MAX_PATH];
|
|
|
|
HGLOBAL hGlobal;
|
2000-09-26 01:56:41 +02:00
|
|
|
DROPFILES *pDropFiles;
|
2000-02-20 19:46:28 +01:00
|
|
|
int offset;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
|
|
|
|
|
|
|
/* get the size needed */
|
2000-09-26 01:56:41 +02:00
|
|
|
size = sizeof(DROPFILES);
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
SHGetPathFromIDListA(pidlRoot, szRootPath);
|
|
|
|
PathAddBackslashA(szRootPath);
|
|
|
|
rootsize = strlen(szRootPath);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
for (i=0; i<cidl;i++)
|
|
|
|
{
|
|
|
|
_ILSimpleGetText(apidl[i], szFileName, MAX_PATH);
|
|
|
|
size += rootsize + strlen(szFileName) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size++;
|
|
|
|
|
|
|
|
/* Fill the structure */
|
|
|
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
|
|
|
if(!hGlobal) return hGlobal;
|
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
pDropFiles = (DROPFILES *)GlobalLock(hGlobal);
|
|
|
|
pDropFiles->pFiles = sizeof(DROPFILES);
|
|
|
|
pDropFiles->fWide = FALSE;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
offset = pDropFiles->pFiles;
|
2000-02-20 19:46:28 +01:00
|
|
|
strcpy(szFileName, szRootPath);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
for (i=0; i<cidl;i++)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
_ILSimpleGetText(apidl[i], szFileName + rootsize, MAX_PATH - rootsize);
|
|
|
|
size = strlen(szFileName) + 1;
|
2000-08-14 16:41:19 +02:00
|
|
|
strcpy(((char*)pDropFiles)+offset, szFileName);
|
2000-02-20 19:46:28 +01:00
|
|
|
offset += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
((char*)pDropFiles)[offset] = 0;
|
|
|
|
GlobalUnlock(hGlobal);
|
|
|
|
|
|
|
|
return hGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
2002-12-13 01:36:52 +01:00
|
|
|
UINT i;
|
|
|
|
int offset = 0, sizePidl, size;
|
2000-02-20 19:46:28 +01:00
|
|
|
HGLOBAL hGlobal;
|
2002-11-12 02:05:00 +01:00
|
|
|
LPIDA pcida;
|
2000-02-20 19:46:28 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
|
|
|
|
|
|
|
/* get the size needed */
|
|
|
|
size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */
|
|
|
|
size += ILGetSize (pidlRoot); /* root pidl */
|
|
|
|
for(i=0; i<cidl; i++)
|
|
|
|
{
|
|
|
|
size += ILGetSize(apidl[i]); /* child pidls */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill the structure */
|
2002-06-01 01:06:46 +02:00
|
|
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
2000-02-20 19:46:28 +01:00
|
|
|
if(!hGlobal) return hGlobal;
|
|
|
|
pcida = GlobalLock (hGlobal);
|
|
|
|
pcida->cidl = cidl;
|
|
|
|
|
|
|
|
/* root pidl */
|
|
|
|
offset = sizeof(CIDA) + sizeof (UINT)*(cidl);
|
|
|
|
pcida->aoffset[0] = offset; /* first element */
|
|
|
|
sizePidl = ILGetSize (pidlRoot);
|
|
|
|
memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl);
|
|
|
|
offset += sizePidl;
|
|
|
|
|
|
|
|
for(i=0; i<cidl; i++) /* child pidls */
|
|
|
|
{
|
|
|
|
pcida->aoffset[i+1] = offset;
|
|
|
|
sizePidl = ILGetSize(apidl[i]);
|
|
|
|
memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl);
|
|
|
|
offset += sizePidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
GlobalUnlock(hGlobal);
|
|
|
|
return hGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-07-26 22:32:43 +02:00
|
|
|
HGLOBAL RenderFILENAMEA (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
2000-02-20 19:46:28 +01:00
|
|
|
{
|
2004-01-22 00:50:46 +01:00
|
|
|
int size = 0;
|
2000-02-20 19:46:28 +01:00
|
|
|
char szTemp[MAX_PATH], *szFileName;
|
2004-01-22 00:50:46 +01:00
|
|
|
LPITEMIDLIST pidl;
|
2000-02-20 19:46:28 +01:00
|
|
|
HGLOBAL hGlobal;
|
2005-06-14 21:17:41 +02:00
|
|
|
BOOL bSuccess;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
|
|
|
|
2004-01-22 00:50:46 +01:00
|
|
|
/* get path of combined pidl */
|
|
|
|
pidl = ILCombine(pidlRoot, apidl[0]);
|
|
|
|
if (!pidl)
|
|
|
|
return 0;
|
|
|
|
|
2005-06-14 21:17:41 +02:00
|
|
|
bSuccess = SHGetPathFromIDListA(pidl, szTemp);
|
2004-01-22 00:50:46 +01:00
|
|
|
SHFree(pidl);
|
2005-06-14 21:17:41 +02:00
|
|
|
if (!bSuccess)
|
2004-01-22 00:50:46 +01:00
|
|
|
return 0;
|
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
size = strlen(szTemp) + 1;
|
|
|
|
|
|
|
|
/* fill the structure */
|
|
|
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
|
|
|
if(!hGlobal) return hGlobal;
|
2003-07-26 22:32:43 +02:00
|
|
|
szFileName = (char *)GlobalLock(hGlobal);
|
|
|
|
memcpy(szFileName, szTemp, size);
|
|
|
|
GlobalUnlock(hGlobal);
|
2004-01-22 00:50:46 +01:00
|
|
|
|
2003-07-26 22:32:43 +02:00
|
|
|
return hGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderFILENAMEW (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
|
|
|
|
{
|
2004-01-22 00:50:46 +01:00
|
|
|
int size = 0;
|
2003-07-26 22:32:43 +02:00
|
|
|
WCHAR szTemp[MAX_PATH], *szFileName;
|
2004-01-22 00:50:46 +01:00
|
|
|
LPITEMIDLIST pidl;
|
2003-07-26 22:32:43 +02:00
|
|
|
HGLOBAL hGlobal;
|
2005-06-14 21:17:41 +02:00
|
|
|
BOOL bSuccess;
|
2003-07-26 22:32:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
|
|
|
|
|
2004-01-22 00:50:46 +01:00
|
|
|
/* get path of combined pidl */
|
|
|
|
pidl = ILCombine(pidlRoot, apidl[0]);
|
|
|
|
if (!pidl)
|
|
|
|
return 0;
|
|
|
|
|
2005-06-14 21:17:41 +02:00
|
|
|
bSuccess = SHGetPathFromIDListW(pidl, szTemp);
|
2004-01-22 00:50:46 +01:00
|
|
|
SHFree(pidl);
|
2005-06-14 21:17:41 +02:00
|
|
|
if (!bSuccess)
|
2004-01-22 00:50:46 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
size = (strlenW(szTemp)+1) * sizeof(WCHAR);
|
2003-07-26 22:32:43 +02:00
|
|
|
|
|
|
|
/* fill the structure */
|
|
|
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
|
|
|
|
if(!hGlobal) return hGlobal;
|
|
|
|
szFileName = (WCHAR *)GlobalLock(hGlobal);
|
|
|
|
memcpy(szFileName, szTemp, size);
|
2000-02-20 19:46:28 +01:00
|
|
|
GlobalUnlock(hGlobal);
|
2004-01-22 00:50:46 +01:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
return hGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags)
|
|
|
|
{
|
|
|
|
DWORD * pdwFlag;
|
|
|
|
HGLOBAL hGlobal;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
TRACE("(0x%08lx)\n", dwFlags);
|
|
|
|
|
|
|
|
hGlobal = GlobalAlloc(GHND|GMEM_SHARE, sizeof(DWORD));
|
|
|
|
if(!hGlobal) return hGlobal;
|
|
|
|
pdwFlag = (DWORD*)GlobalLock(hGlobal);
|
|
|
|
*pdwFlag = dwFlags;
|
|
|
|
GlobalUnlock(hGlobal);
|
|
|
|
return hGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IsDataInClipboard
|
|
|
|
*
|
|
|
|
* checks if there is something in the clipboard we can use
|
|
|
|
*/
|
|
|
|
BOOL IsDataInClipboard (HWND hwnd)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-02-20 19:46:28 +01:00
|
|
|
if (OpenClipboard(hwnd))
|
|
|
|
{
|
|
|
|
if (GetOpenClipboardWindow())
|
|
|
|
{
|
|
|
|
ret = IsClipboardFormatAvailable(CF_TEXT);
|
|
|
|
}
|
|
|
|
CloseClipboard();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|