https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c31327114b40aa0acbca0…
commit c31327114b40aa0acbca014aaf896d919a56985c
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Oct 20 00:44:03 2019 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Oct 20 17:10:12 2019 +0200
[SDK][SHELL32] Augment the internally used IDataObject with some extra formats
This is needed because our code seems to use CF_HDROP a lot, instead of HIDA...
---
dll/win32/shell32/CIDLDataObj.cpp | 35 ++++++++++++++++++-----
dll/win32/shell32/folders/CControlPanelFolder.cpp | 2 +-
dll/win32/shell32/folders/CDesktopFolder.cpp | 2 +-
dll/win32/shell32/folders/CDrivesFolder.cpp | 2 +-
dll/win32/shell32/folders/CFSFolder.cpp | 2 +-
dll/win32/shell32/folders/CNetFolder.cpp | 2 +-
dll/win32/shell32/folders/CRegFolder.cpp | 2 +-
dll/win32/shell32/wine/shell32_main.h | 2 +-
dll/win32/shell32/wine/shellord.c | 2 +-
sdk/include/reactos/shellutils.h | 22 ++++++++++++++
10 files changed, 58 insertions(+), 15 deletions(-)
diff --git a/dll/win32/shell32/CIDLDataObj.cpp b/dll/win32/shell32/CIDLDataObj.cpp
index b1704ff9b5a..8e1993e2a66 100644
--- a/dll/win32/shell32/CIDLDataObj.cpp
+++ b/dll/win32/shell32/CIDLDataObj.cpp
@@ -143,7 +143,7 @@ private:
public:
CIDLDataObj();
~CIDLDataObj();
- HRESULT WINAPI Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx);
+ HRESULT WINAPI Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats);
// *** IDataObject methods ***
virtual HRESULT WINAPI GetData(LPFORMATETC pformatetcIn, STGMEDIUM *pmedium);
@@ -187,7 +187,7 @@ CIDLDataObj::~CIDLDataObj()
m_Storage.RemoveAll();
}
-HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx)
+HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats)
{
HGLOBAL hida = RenderSHELLIDLIST((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx,
cidlx);
if (!hida)
@@ -198,12 +198,33 @@ HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner,
PCIDLIST_ABSOLUTE pMyPidl
m_cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
- FORMATETC HIDAFormat = { (CLIPFORMAT)m_cfShellIDList, NULL, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL };
+ FORMATETC Format = { (CLIPFORMAT)m_cfShellIDList, NULL, DVASPECT_CONTENT, -1,
TYMED_HGLOBAL };
STGMEDIUM medium = {0};
medium.tymed = TYMED_HGLOBAL;
medium.hGlobal = hida;
+ HRESULT hr = SetData(&Format, &medium, TRUE);
+ if (!FAILED_UNEXPECTEDLY(hr) && bAddAdditionalFormats)
+ {
+ Format.cfFormat = CF_HDROP;
+ medium.hGlobal = RenderHDROP((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx,
cidlx);
+ hr = SetData(&Format, &medium, TRUE);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ Format.cfFormat = RegisterClipboardFormatA(CFSTR_FILENAMEA);
+ medium.hGlobal = RenderFILENAMEA((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx,
cidlx);
+ hr = SetData(&Format, &medium, TRUE);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ Format.cfFormat = RegisterClipboardFormatW(CFSTR_FILENAMEW);
+ medium.hGlobal = RenderFILENAMEW((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx,
cidlx);
+ hr = SetData(&Format, &medium, TRUE);
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+ }
- return SetData(&HIDAFormat, &medium, TRUE);
+ return hr;
}
@@ -355,11 +376,11 @@ HRESULT WINAPI CIDLDataObj::EndOperation(HRESULT hResult, IBindCtx
*pbcReserved,
/**************************************************************************
* IDataObject_Constructor
*/
-HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, IDataObject **dataObject)
+HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl,
PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject
**dataObject)
{
if (!dataObject)
return E_INVALIDARG;
- return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl,
IID_PPV_ARG(IDataObject, dataObject));
+ return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl,
bExtendedObject, IID_PPV_ARG(IDataObject, dataObject));
}
/*************************************************************************
@@ -373,7 +394,7 @@ HRESULT WINAPI SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT
cidl, PCUIT
{
if (pdtInner)
UNIMPLEMENTED;
- return CIDLData_CreateFromIDArray(pidlFolder, cidl, apidl, (IDataObject **)ppv);
+ return IDataObject_Constructor(NULL, pidlFolder, apidl, cidl, TRUE, (IDataObject
**)ppv);
}
return E_FAIL;
}
diff --git a/dll/win32/shell32/folders/CControlPanelFolder.cpp
b/dll/win32/shell32/folders/CControlPanelFolder.cpp
index 53bd9cb6313..84e2abe69f7 100644
--- a/dll/win32/shell32/folders/CControlPanelFolder.cpp
+++ b/dll/win32/shell32/folders/CControlPanelFolder.cpp
@@ -459,7 +459,7 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
else
hr = m_regFolder->GetUIObjectOf(hwndOwner, cidl, apidl, riid,
prgfInOut, &pObj);
} else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1)) {
- hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
+ hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, TRUE,
(IDataObject **)&pObj);
} else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid,
IID_IExtractIconW)) && (cidl == 1)) {
if (_ILGetCPanelPointer(apidl[0]))
hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
diff --git a/dll/win32/shell32/folders/CDesktopFolder.cpp
b/dll/win32/shell32/folders/CDesktopFolder.cpp
index 20c5f667f63..f2d6c32e09c 100644
--- a/dll/win32/shell32/folders/CDesktopFolder.cpp
+++ b/dll/win32/shell32/folders/CDesktopFolder.cpp
@@ -636,7 +636,7 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
}
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
{
- hr = IDataObject_Constructor( hwndOwner, pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
+ hr = IDataObject_Constructor( hwndOwner, pidlRoot, apidl, cidl, TRUE,
(IDataObject **)&pObj);
}
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
{
diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp
b/dll/win32/shell32/folders/CDrivesFolder.cpp
index d8c35a79150..35f6a7d735a 100644
--- a/dll/win32/shell32/folders/CDrivesFolder.cpp
+++ b/dll/win32/shell32/folders/CDrivesFolder.cpp
@@ -784,7 +784,7 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner,
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
{
hr = IDataObject_Constructor (hwndOwner,
- pidlRoot, apidl, cidl, (IDataObject **)&pObj);
+ pidlRoot, apidl, cidl, TRUE, (IDataObject
**)&pObj);
}
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid,
IID_IExtractIconW)) && (cidl == 1))
{
diff --git a/dll/win32/shell32/folders/CFSFolder.cpp
b/dll/win32/shell32/folders/CFSFolder.cpp
index f3c758d93fc..a356bb927a3 100644
--- a/dll/win32/shell32/folders/CFSFolder.cpp
+++ b/dll/win32/shell32/folders/CFSFolder.cpp
@@ -1064,7 +1064,7 @@ HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
{
if (cidl >= 1)
{
- hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl,
(IDataObject **)&pObj);
+ hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, TRUE,
(IDataObject **)&pObj);
}
else
{
diff --git a/dll/win32/shell32/folders/CNetFolder.cpp
b/dll/win32/shell32/folders/CNetFolder.cpp
index 93d91ab6dbb..5479deddb1a 100644
--- a/dll/win32/shell32/folders/CNetFolder.cpp
+++ b/dll/win32/shell32/folders/CNetFolder.cpp
@@ -427,7 +427,7 @@ HRESULT WINAPI CNetFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CH
else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1))
{
IDataObject * pDo = NULL;
- hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, &pDo);
+ hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, TRUE, &pDo);
pObj = pDo;
}
else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW))
&& (cidl == 1))
diff --git a/dll/win32/shell32/folders/CRegFolder.cpp
b/dll/win32/shell32/folders/CRegFolder.cpp
index 33539816b11..6398109247d 100644
--- a/dll/win32/shell32/folders/CRegFolder.cpp
+++ b/dll/win32/shell32/folders/CRegFolder.cpp
@@ -533,7 +533,7 @@ HRESULT WINAPI CRegFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl,
PCUITEMID_CH
}
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
{
- hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, (IDataObject
**)&pObj);
+ hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, TRUE,
(IDataObject **)&pObj);
}
else
{
diff --git a/dll/win32/shell32/wine/shell32_main.h
b/dll/win32/shell32/wine/shell32_main.h
index 16536975384..1585f60aedd 100644
--- a/dll/win32/shell32/wine/shell32_main.h
+++ b/dll/win32/shell32/wine/shell32_main.h
@@ -63,7 +63,7 @@ DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD
len) DECLS
/****************************************************************************
* Class constructors
*/
-HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl,
PCUITEMID_CHILD_ARRAY apidl, UINT cidl, IDataObject **dataObject);
+HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl,
PCUITEMID_CHILD_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject);
HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC
**enumerator);
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
diff --git a/dll/win32/shell32/wine/shellord.c b/dll/win32/shell32/wine/shellord.c
index fac2d20dea3..71f35e4d866 100644
--- a/dll/win32/shell32/wine/shellord.c
+++ b/dll/win32/shell32/wine/shellord.c
@@ -1791,7 +1791,7 @@ HRESULT WINAPI CIDLData_CreateFromIDArray(
pdump (pidlFolder);
for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
}
- hResult = IDataObject_Constructor(hwnd, pidlFolder, lppidlFiles, cpidlFiles,
ppdataObject);
+ hResult = IDataObject_Constructor(hwnd, pidlFolder, lppidlFiles, cpidlFiles, FALSE,
ppdataObject);
return hResult;
}
diff --git a/sdk/include/reactos/shellutils.h b/sdk/include/reactos/shellutils.h
index 2f5d72ece0f..467f142c4ae 100644
--- a/sdk/include/reactos/shellutils.h
+++ b/sdk/include/reactos/shellutils.h
@@ -378,6 +378,28 @@ HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3
initArg3, T4
return hResult;
}
+template<class T, class T1, class T2, class T3, class T4, class T5>
+HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4 initArg4,
T5 initArg5, REFIID riid, void ** ppv)
+{
+ _CComObject<T> *pobj;
+ HRESULT hResult;
+
+ hResult = _CComObject<T>::CreateInstance(&pobj);
+ if (FAILED(hResult))
+ return hResult;
+
+ pobj->AddRef(); /* CreateInstance returns object with 0 ref count */
+
+ hResult = pobj->Initialize(initArg1, initArg2, initArg3, initArg4, initArg5);
+
+ if (SUCCEEDED(hResult))
+ hResult = pobj->QueryInterface(riid, reinterpret_cast<void **>(ppv));
+
+ pobj->Release(); /* In case of failure the object will be released */
+
+ return hResult;
+}
+
HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCSTR pstrValue)
{
pStrRet->uType = STRRET_CSTR;