ReactOS  0.4.15-dev-509-g96a357b
precomp.h File Reference
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <tchar.h>
#include <strsafe.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlcoll.h>
#include <atlstr.h>
#include <wine/debug.h>
#include <shellutils.h>
#include "resource.h"
#include "fontpidl.hpp"
#include "CFontCache.hpp"
#include "CFontExt.hpp"
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define COM_NO_WINDOWS_H
 
#define FONT_HIVE   HKEY_LOCAL_MACHINE
 
#define FONT_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"
 

Functions

HRESULT _CEnumFonts_CreateInstance (CFontExt *zip, DWORD flags, REFIID riid, LPVOID *ppvOut)
 
HRESULT _CFontMenu_CreateInstance (HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, REFIID riid, LPVOID *ppvOut)
 
HRESULT _CDataObject_CreateInstance (PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, LPVOID *ppvOut)
 
HRESULT _GetCidlFromDataObject (IDataObject *pDataObject, CIDA **ppcida)
 
BOOL IsFontDotExt (LPCWSTR pchDotExt)
 

Variables

const GUID CLSID_CFontExt
 
LONG g_ModuleRefCnt
 

Macro Definition Documentation

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 6 of file precomp.h.

◆ FONT_HIVE

#define FONT_HIVE   HKEY_LOCAL_MACHINE

Definition at line 30 of file precomp.h.

◆ FONT_KEY

#define FONT_KEY   L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"

Definition at line 31 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 5 of file precomp.h.

Function Documentation

◆ _CDataObject_CreateInstance()

HRESULT _CDataObject_CreateInstance ( PCIDLIST_ABSOLUTE  folder,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 38 of file CDataObject.cpp.

40 {
41  HRESULT hr = CIDLData_CreateFromIDArray(folder, cidl, apidl, (IDataObject**)ppvOut);
43  return hr;
44 
45  // Now that we have an IDataObject with the shell itemid list (CFSTR_SHELLIDLIST, aka HIDA) format
46  // we will augment this IDataObject with the CF_HDROP format. (Full filepaths)
47  // This enabled the objects for the 'copy' and drag to copy actions
48 
50 
51  // First we allocate room for the DROPFILES structure
52  data.AllocateBytes(sizeof(DROPFILES));
53  UINT offset = sizeof(DROPFILES);
54 
55  // Then we walk all files
56  for (UINT n = 0; n < cidl; ++n)
57  {
58  const FontPidlEntry* fontEntry = _FontFromIL(apidl[n]);
59  if (fontEntry)
60  {
61  CStringW File = g_FontCache->Filename(fontEntry, true);
62  if (!File.IsEmpty())
63  {
64  // Now append the path (+ nullterminator) to the buffer
65  UINT len = offset + (File.GetLength() + 1) * sizeof(WCHAR);
66  data.ReallocateBytes(len);
67  if (!data)
68  {
69  ERR("Unable to allocate memory for the CF_HDROP\n");
70  return hr;
71  }
72  BYTE* dataPtr = data;
74  offset = len;
75  }
76  else
77  {
78  ERR("No file found for %S\n", fontEntry->Name);
79  }
80  }
81  }
82 
83  // Append the final nullterminator (double null terminated list)
84  data.ReallocateBytes(offset + sizeof(UNICODE_NULL));
85  LPWSTR str = (LPWSTR)((BYTE*)data + offset);
86  *str = UNICODE_NULL;
87  offset += sizeof(UNICODE_NULL);
88 
89  // Fill in the required fields
90  DROPFILES* pDrop = (DROPFILES*)(BYTE*)data;
91  pDrop->fWide = 1;
92  pDrop->pFiles = sizeof(DROPFILES);
93  // Zero out the rest
94  pDrop->pt.x = pDrop->pt.y = 0;
95  pDrop-> fNC = NULL;
96 
97  // Prepare the format descriptors
98  STGMEDIUM medium = {0};
99  medium.tymed = TYMED_HGLOBAL;
100 
101  // Copy the data to an HGLOBAL
102  medium.hGlobal = GlobalAlloc(GHND, offset);
103  if (medium.hGlobal)
104  {
105  LPVOID blob = GlobalLock(medium.hGlobal);
106  if (blob)
107  {
109  GlobalUnlock(medium.hGlobal);
110 
111  CComPtr<IDataObject> spDataObject(*(IDataObject**)ppvOut);
112  if (spDataObject)
113  {
114  FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
115  hr = spDataObject->SetData(&etc, &medium, TRUE);
116  }
117  }
118  else
119  {
120  ERR("Unable to lock the hGlobal?!\n");
121  }
122  }
123  else
124  {
125  ERR("Unable to allocate %u bytes for the hGlobal\n", offset);
126  }
127 
128  return hr;
129 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
Definition: fci.c:115
long y
Definition: polytest.cpp:48
HRESULT hr
Definition: shlfolder.c:183
Definition: image.c:133
POINT pt
Definition: shlobj.h:2125
long x
Definition: polytest.cpp:48
GLintptr offset
Definition: glext.h:5920
GLdouble n
Definition: glext.h:7729
const FontPidlEntry * _FontFromIL(LPCITEMIDLIST pidl)
Definition: fontpidl.cpp:32
wchar_t * STRSAFE_LPWSTR
Definition: ntstrsafe.h:53
#define GHND
Definition: winbase.h:294
#define UNICODE_NULL
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define CF_HDROP
Definition: constants.h:410
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
BOOL fWide
Definition: shlobj.h:2127
#define CopyMemory
Definition: winbase.h:1646
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
GLenum GLsizei len
Definition: glext.h:6722
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
WCHAR Name[1]
Definition: fontpidl.hpp:17
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
CStringW Filename(const FontPidlEntry *fontEntry, bool alwaysFullPath=false)
Definition: CFontCache.cpp:96
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
Definition: File.h:15
HRESULT WINAPI CIDLData_CreateFromIDArray(PCIDLIST_ABSOLUTE pidlFolder, UINT cpidlFiles, PCUIDLIST_RELATIVE_ARRAY lppidlFiles, LPDATAOBJECT *ppdataObject)
Definition: shellord.c:2080
WCHAR * LPWSTR
Definition: xmlstorage.h:184
struct _DROPFILES DROPFILES
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
DWORD pFiles
Definition: shlobj.h:2124

Referenced by CFontExt::GetUIObjectOf().

◆ _CEnumFonts_CreateInstance()

HRESULT _CEnumFonts_CreateInstance ( CFontExt zip,
DWORD  flags,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 87 of file CEnumFonts.cpp.

88 {
89  return ShellObjectCreatorInit<CEnumFonts>(zip, flags, riid, ppvOut);
90 }
REFIID riid
Definition: precomp.h:44
GLbitfield flags
Definition: glext.h:7161

Referenced by CFontExt::EnumObjects().

◆ _CFontMenu_CreateInstance()

HRESULT _CFontMenu_CreateInstance ( HWND  hwnd,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
IShellFolder psf,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 137 of file CFontMenu.cpp.

139 {
140  if (cidl > 0)
141  {
142  HKEY keys[1] = {0};
143  int nkeys = 0;
144  CComPtr<IContextMenu> spMenu;
145 
146  // Use the default context menu handler, but augment it from the callbacks
147  HRESULT hr = CDefFolderMenu_Create2(NULL, hwnd, cidl, apidl, psf, FontFolderMenuCallback, nkeys, keys, &spMenu);
148 
149  if (FAILED_UNEXPECTEDLY(hr))
150  return hr;
151 
152  // See if the requested interface (e.g. IContextMenu3) is also available
153  return spMenu->QueryInterface(riid, ppvOut);
154  }
155 
156  // We can't create a background menu
157  return E_FAIL;
158 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
static HRESULT CALLBACK FontFolderMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CFontMenu.cpp:89
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
HRESULT WINAPI CDefFolderMenu_Create2(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)

Referenced by CFontExt::GetUIObjectOf().

◆ _GetCidlFromDataObject()

HRESULT _GetCidlFromDataObject ( IDataObject pDataObject,
CIDA **  ppcida 
)

Definition at line 14 of file CFontMenu.cpp.

15 {
16  if (g_cfHIDA == NULL)
17  {
19  }
20 
21  FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
22  STGMEDIUM medium;
23 
24  HRESULT hr = pDataObject->GetData(&fmt, &medium);
26  return hr;
27 
28  LPVOID lpSrc = GlobalLock(medium.hGlobal);
29  SIZE_T cbSize = GlobalSize(medium.hGlobal);
30 
31  *ppcida = (CIDA *)::CoTaskMemAlloc(cbSize);
32  if (*ppcida)
33  {
34  memcpy(*ppcida, lpSrc, cbSize);
35  hr = S_OK;
36  }
37  else
38  {
39  hr = E_FAIL;
40  }
41  ReleaseStgMedium(&medium);
42  return hr;
43 }
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:477
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
static CLIPFORMAT g_cfHIDA
Definition: CFontMenu.cpp:12
#define E_FAIL
Definition: ddrawi.h:102
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:78
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG_PTR SIZE_T
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:59
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
Definition: dsound.c:943
Definition: shlobj.h:498

Referenced by CFontExt::DragEnter(), CFontExt::Drop(), and FontFolderMenuCallback().

◆ IsFontDotExt()

BOOL IsFontDotExt ( LPCWSTR  pchDotExt)
inline

Definition at line 41 of file precomp.h.

42 {
43  static const LPCWSTR array[] =
44  {
45  L".ttf", L".ttc", L".otf", L".otc", L".fon", L".fnt", NULL
46  };
47  for (const LPCWSTR *pp = array; *pp; ++pp)
48  {
49  if (!_wcsicmp(*pp, pchDotExt))
50  return TRUE;
51  }
52  return FALSE;
53 }
#define TRUE
Definition: types.h:120
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define pp
Definition: hlsl.yy.c:1208
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by CFontExt::Drop().

Variable Documentation

◆ CLSID_CFontExt

const GUID CLSID_CFontExt

Definition at line 12 of file fontext.cpp.

Referenced by CFontExt::GetClassID().

◆ g_ModuleRefCnt

LONG g_ModuleRefCnt

Definition at line 13 of file ACPPage.cpp.