https://git.reactos.org/?p=reactos.git;a=commitdiff;h=54c09f856c315c4266fff…
commit 54c09f856c315c4266fff190aa6ba4524a4e9943
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sun Jul 25 01:10:51 2021 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Mon Nov 15 20:02:14 2021 +0100
[FONTEXT] Simplify HIDA usage
---
dll/shellext/fontext/CFontExt.cpp | 14 ++++++-------
dll/shellext/fontext/CFontMenu.cpp | 42 +++++---------------------------------
dll/shellext/fontext/precomp.h | 2 --
3 files changed, 11 insertions(+), 47 deletions(-)
diff --git a/dll/shellext/fontext/CFontExt.cpp b/dll/shellext/fontext/CFontExt.cpp
index b2681055cd2..23b7e0b2721 100644
--- a/dll/shellext/fontext/CFontExt.cpp
+++ b/dll/shellext/fontext/CFontExt.cpp
@@ -505,10 +505,9 @@ STDMETHODIMP CFontExt::DragEnter(IDataObject* pDataObj, DWORD
grfKeyState, POINT
{
*pdwEffect = DROPEFFECT_NONE;
- CComHeapPtr<CIDA> cida;
- HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
+ CDataObjectHIDA cida(pDataObj);
+ if (FAILED_UNEXPECTEDLY(cida.hr()))
+ return cida.hr();
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
@@ -528,10 +527,9 @@ STDMETHODIMP CFontExt::Drop(IDataObject* pDataObj, DWORD grfKeyState,
POINTL pt,
{
*pdwEffect = DROPEFFECT_NONE;
- CComHeapPtr<CIDA> cida;
- HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
+ CDataObjectHIDA cida(pDataObj);
+ if (!cida)
+ return E_UNEXPECTED;
PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida);
if (!pidlParent)
diff --git a/dll/shellext/fontext/CFontMenu.cpp b/dll/shellext/fontext/CFontMenu.cpp
index 62464a099ee..fdd20bbd6ef 100644
--- a/dll/shellext/fontext/CFontMenu.cpp
+++ b/dll/shellext/fontext/CFontMenu.cpp
@@ -2,45 +2,13 @@
* PROJECT: ReactOS Font Shell Extension
* LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: CFontMenu implementation
- * COPYRIGHT: Copyright 2019,2020 Mark Jansen <mark.jansen(a)reactos.org>
+ * COPYRIGHT: Copyright 2019-2021 Mark Jansen <mark.jansen(a)reactos.org>
*/
#include "precomp.h"
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
-static CLIPFORMAT g_cfHIDA;
-
-HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida)
-{
- if (g_cfHIDA == NULL)
- {
- g_cfHIDA = (CLIPFORMAT)RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
- }
-
- FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- STGMEDIUM medium;
-
- HRESULT hr = pDataObject->GetData(&fmt, &medium);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
- LPVOID lpSrc = GlobalLock(medium.hGlobal);
- SIZE_T cbSize = GlobalSize(medium.hGlobal);
-
- *ppcida = (CIDA *)::CoTaskMemAlloc(cbSize);
- if (*ppcida)
- {
- memcpy(*ppcida, lpSrc, cbSize);
- hr = S_OK;
- }
- else
- {
- hr = E_FAIL;
- }
- ReleaseStgMedium(&medium);
- return hr;
-}
const char* DFM_TO_STR(UINT uMsg)
{
@@ -111,10 +79,10 @@ static HRESULT CALLBACK FontFolderMenuCallback(IShellFolder *psf,
HWND hwnd, IDa
// Preview is the only item we handle
if (wParam == 0)
{
- CComHeapPtr<CIDA> cida;
- HRESULT hr = _GetCidlFromDataObject(pdtobj, &cida);
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
+ CDataObjectHIDA cida(pdtobj);
+
+ if (FAILED_UNEXPECTEDLY(cida.hr()))
+ return cida.hr();
for (UINT n = 0; n < cida->cidl; ++n)
{
diff --git a/dll/shellext/fontext/precomp.h b/dll/shellext/fontext/precomp.h
index 8037e4cd064..2e46032986d 100644
--- a/dll/shellext/fontext/precomp.h
+++ b/dll/shellext/fontext/precomp.h
@@ -36,8 +36,6 @@ HRESULT _CFontMenu_CreateInstance(HWND hwnd, UINT cidl,
PCUITEMID_CHILD_ARRAY ap
HRESULT _CDataObject_CreateInstance(PCIDLIST_ABSOLUTE folder, UINT cidl,
PCUITEMID_CHILD_ARRAY apidl,
REFIID riid, LPVOID* ppvOut);
-HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida);
-
inline BOOL IsFontDotExt(LPCWSTR pchDotExt)
{
static const LPCWSTR array[] =