ReactOS 0.4.15-dev-5667-ged97270
CFontExt Class Reference

#include <CFontExt.hpp>

Inheritance diagram for CFontExt:
Collaboration diagram for CFontExt:

Public Member Functions

 CFontExt ()
 
 ~CFontExt ()
 
virtual STDMETHODIMP GetDefaultSearchGUID (GUID *lpguid)
 
virtual STDMETHODIMP EnumSearches (IEnumExtraSearch **ppenum)
 
virtual STDMETHODIMP GetDefaultColumn (DWORD dwReserved, ULONG *pSort, ULONG *pDisplay)
 
virtual STDMETHODIMP GetDefaultColumnState (UINT iColumn, SHCOLSTATEF *pcsFlags)
 
virtual STDMETHODIMP GetDetailsEx (PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
 
virtual STDMETHODIMP GetDetailsOf (PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd)
 
virtual STDMETHODIMP MapColumnToSCID (UINT iColumn, SHCOLUMNID *pscid)
 
virtual STDMETHODIMP ParseDisplayName (HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes)
 
virtual STDMETHODIMP EnumObjects (HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
 
virtual STDMETHODIMP BindToObject (PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
 
virtual STDMETHODIMP BindToStorage (PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
 
virtual STDMETHODIMP CompareIDs (LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
 
virtual STDMETHODIMP CreateViewObject (HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
 
virtual STDMETHODIMP GetAttributesOf (UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
 
virtual STDMETHODIMP GetUIObjectOf (HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
 
virtual STDMETHODIMP GetDisplayNameOf (PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
 
virtual STDMETHODIMP SetNameOf (HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
 
virtual STDMETHODIMP GetCurFolder (LPITEMIDLIST *ppidl)
 
virtual STDMETHODIMP Initialize (LPCITEMIDLIST pidl)
 
virtual STDMETHODIMP GetClassID (CLSID *lpClassId)
 
virtual STDMETHODIMP DragEnter (IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
 
virtual STDMETHODIMP DragOver (DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
 
virtual STDMETHODIMP DragLeave ()
 
virtual STDMETHODIMP Drop (IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
 
HRESULT DoInstallFontFile (LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HKEY hkeyFonts)
 
HRESULT DoGetFontTitle (IN LPCWSTR pszFontPath, OUT CStringW &strFontName)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
HRESULT GetDefaultSearchGUID ([out] GUID *lpguid)
 
HRESULT EnumSearches ([out] IEnumExtraSearch **ppenum)
 
HRESULT GetDefaultColumn ([in] DWORD dwReserved, [out] ULONG *pSort, [out] ULONG *pDisplay)
 
HRESULT GetDefaultColumnState ([in] UINT iColumn, [out] SHCOLSTATEF *pcsFlags)
 
HRESULT GetDetailsEx ([in] PCUITEMID_CHILD pidl, [in] const SHCOLUMNID *pscid, [out] VARIANT *pv)
 
HRESULT GetDetailsOf ([in] PCUITEMID_CHILD pidl, [in] UINT iColumn, [out] SHELLDETAILS *psd)
 
HRESULT MapColumnToSCID ([in] UINT iColumn, [in] SHCOLUMNID *pscid)
 
- Public Member Functions inherited from IShellFolder
HRESULT ParseDisplayName ([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
 
HRESULT EnumObjects ([in] HWND hwndOwner, [in] SHCONTF grfFlags, [out] IEnumIDList **ppenumIDList)
 
HRESULT BindToObject ([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
 
HRESULT BindToStorage ([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvObj)
 
HRESULT CompareIDs ([in] LPARAM lParam, [in] PCUIDLIST_RELATIVE pidl1, [in] PCUIDLIST_RELATIVE pidl2)
 
HRESULT CreateViewObject ([in] HWND hwndOwner, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
 
HRESULT GetAttributesOf ([in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in, out] SFGAOF *rgfInOut)
 
HRESULT GetUIObjectOf ([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)
 
HRESULT GetDisplayNameOf ([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
 
HRESULT SetNameOf ([in] HWND hwnd, [in] PCUITEMID_CHILD pidl, [in, string] LPCOLESTR lpszName, [in] SHGDNF uFlags, [out] PITEMID_CHILD *ppidlOut)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IPersistFolder2
HRESULT GetCurFolder ([out] PIDLIST_ABSOLUTE *ppidl)
 
- Public Member Functions inherited from IPersistFolder
HRESULT Initialize ([in] PCIDLIST_ABSOLUTE pidl)
 
HRESULT GetClassID ([out] CLSID *pClassID)
 
HRESULT DragEnter ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragOver ([in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragLeave ()
 
HRESULT Drop ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 

Private Attributes

CComHeapPtr< ITEMIDLISTm_Folder
 

Additional Inherited Members

- Public Types inherited from IShellFolder2
typedef struct IShellFolder2::SHCOLUMNIDLPSHCOLUMNID
 
typedef const SHCOLUMNIDLPCSHCOLUMNID
 
- Public Types inherited from IShellFolder
enum  tagSHGDN {
  SHGDN_NORMAL = 0 , SHGDN_INFOLDER = 1 , SHGDN_FOREDITING = 0x1000 , SHGDN_INCLUDE_NONFILESYS = 0x2000 ,
  SHGDN_FORADDRESSBAR = 0x4000 , SHGDN_FORPARSING = 0x8000
}
 
enum  tagSHCONTF {
  SHCONTF_FOLDERS = 32 , SHCONTF_NONFOLDERS = 64 , SHCONTF_INCLUDEHIDDEN = 128 , SHCONTF_INIT_ON_FIRST_NEXT = 256 ,
  SHCONTF_NETPRINTERSRCH = 512 , SHCONTF_SHAREABLE = 1024 , SHCONTF_STORAGE = 2048 , SHCONTF_NAVIGATION_ENUM = 0x01000 ,
  SHCONTF_FASTITEMS = 0x02000 , SHCONTF_FLATLIST = 0x04000 , SHCONTF_ENABLE_ASYNC = 0x08000 , SHCONTF_INCLUDESUPERHIDDEN = 0x10000
}
 
typedef IShellFolderLPSHELLFOLDER
 
typedef enum IShellFolder::tagSHGDN SHGNO
 
typedef DWORD SHGDNF
 
typedef DWORD SHCONTF
 
typedef ULONG SFGAOF
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IPersistFolder2
typedef IPersistFolder2LPPERSISTFOLDER2
 
- Public Types inherited from IPersistFolder
typedef IPersistFolderLPPERSISTFOLDER
 
- Public Types inherited from IPersist
typedef IPersistLPPERSIST
 
- Public Types inherited from IDropTarget
typedef IDropTargetLPDROPTARGET
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- Public Attributes inherited from IDropTarget
const DWORD MK_ALT = 0x20
 
const DWORD DROPEFFECT_NONE = 0
 
const DWORD DROPEFFECT_COPY = 1
 
const DWORD DROPEFFECT_MOVE = 2
 
const DWORD DROPEFFECT_LINK = 4
 
const DWORD DROPEFFECT_SCROLL = 0x80000000
 
const DWORD DD_DEFSCROLLINSET = 11
 
const DWORD DD_DEFSCROLLDELAY = 50
 
const DWORD DD_DEFSCROLLINTERVAL = 50
 
const DWORD DD_DEFDRAGDELAY = 200
 
const DWORD DD_DEFDRAGMINDIST = 2
 

Detailed Description

Definition at line 11 of file CFontExt.hpp.

Constructor & Destructor Documentation

◆ CFontExt()

CFontExt::CFontExt ( )

Definition at line 83 of file CFontExt.cpp.

84{
86}
LONG g_ModuleRefCnt
Definition: ACPPage.cpp:13
#define InterlockedIncrement
Definition: armddk.h:53

◆ ~CFontExt()

CFontExt::~CFontExt ( )

Definition at line 88 of file CFontExt.cpp.

89{
91}
#define InterlockedDecrement
Definition: armddk.h:52

Member Function Documentation

◆ BindToObject()

STDMETHODIMP CFontExt::BindToObject ( PCUIDLIST_RELATIVE  pidl,
LPBC  pbcReserved,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 240 of file CFontExt.cpp.

241{
242 ERR("%s(riid=%S) UNIMPLEMENTED\n", __FUNCTION__, g2s(riid));
243 return E_NOTIMPL;
244}
WCHAR * g2s(REFCLSID iid)
Definition: CFontExt.cpp:57
#define ERR(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
#define __FUNCTION__
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39

◆ BindToStorage()

STDMETHODIMP CFontExt::BindToStorage ( PCUIDLIST_RELATIVE  pidl,
LPBC  pbcReserved,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 246 of file CFontExt.cpp.

247{
248 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
249 return E_NOTIMPL;
250}

◆ CompareIDs()

STDMETHODIMP CFontExt::CompareIDs ( LPARAM  lParam,
PCUIDLIST_RELATIVE  pidl1,
PCUIDLIST_RELATIVE  pidl2 
)
virtual

Implements IShellFolder.

Definition at line 252 of file CFontExt.cpp.

253{
254 const FontPidlEntry* fontEntry1 = _FontFromIL(pidl1);
255 const FontPidlEntry* fontEntry2 = _FontFromIL(pidl2);
256
257 if (!fontEntry1 || !fontEntry2)
258 return E_INVALIDARG;
259
260 int result;
261 DWORD sortMode = lParam & 0xFFFF0000;
262 DWORD column = lParam & 0x0000FFFF;
263 if (sortMode == SHCIDS_ALLFIELDS)
264 {
266 result = (int)fontEntry1->Index - (int)fontEntry2->Index;
267 }
268 else
269 {
270 auto info1 = g_FontCache->Find(fontEntry1);
271 auto info2 = g_FontCache->Find(fontEntry2);
272
273 if (!info1 || !info2)
274 {
275 ERR("Unable to find font %S or %S in cache!\n", fontEntry1->Name, fontEntry2->Name);
276 return E_INVALIDARG;
277 }
278
279 switch (column)
280 {
281 case 0xffff:
282 /* ROS bug? */
283 case FONTEXT_COL_NAME:
284 // These items are already ordered by name
285 result = (int)fontEntry1->Index - (int)fontEntry2->Index;
286 break;
288 result = wcsicmp(PathFindFileNameW(info1->File()), PathFindFileNameW(info2->File()));
289 break;
290 case FONTEXT_COL_SIZE:
291 result = (int)info1->FileSize().HighPart - info2->FileSize().HighPart;
292 if (result == 0)
293 result = (int)info1->FileSize().LowPart - info2->FileSize().LowPart;
294 break;
296 result = CompareFileTime(&info1->FileWriteTime(), &info2->FileWriteTime());
297 break;
298 case FONTEXT_COL_ATTR:
299 // FIXME: how to compare attributes?
300 result = (int)info1->FileAttributes() - info2->FileAttributes();
301 break;
302 default:
303 ERR("Unimplemented column %u\n", column);
304 return E_INVALIDARG;
305 }
306 }
307
309}
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
#define SHCIDS_ALLFIELDS
Definition: CFontExt.cpp:15
@ FONTEXT_COL_NAME
Definition: CFontExt.cpp:28
@ FONTEXT_COL_SIZE
Definition: CFontExt.cpp:30
@ FONTEXT_COL_FILENAME
Definition: CFontExt.cpp:29
@ FONTEXT_COL_MODIFIED
Definition: CFontExt.cpp:31
@ FONTEXT_COL_ATTR
Definition: CFontExt.cpp:32
#define UNIMPLEMENTED
Definition: debug.h:115
CFontInfo * Find(const FontPidlEntry *fontEntry)
Definition: CFontCache.cpp:145
LPARAM lParam
Definition: combotst.c:139
#define E_INVALIDARG
Definition: ddrawi.h:101
#define wcsicmp
Definition: compat.h:15
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
const FontPidlEntry * _FontFromIL(LPCITEMIDLIST pidl)
Definition: fontpidl.cpp:32
GLuint64EXT * result
Definition: glext.h:11304
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:561
WCHAR Name[1]
Definition: fontpidl.hpp:17

◆ CreateViewObject()

STDMETHODIMP CFontExt::CreateViewObject ( HWND  hwndOwner,
REFIID  riid,
LPVOID ppvOut 
)
virtual

Definition at line 311 of file CFontExt.cpp.

312{
314
315 *ppvOut = NULL;
316
317 if (IsEqualIID(riid, IID_IDropTarget))
318 {
319 ERR("IDropTarget not implemented\n");
320 *ppvOut = static_cast<IDropTarget *>(this);
321 AddRef();
322 hr = S_OK;
323 }
324 else if (IsEqualIID(riid, IID_IContextMenu))
325 {
326 ERR("IContextMenu not implemented\n");
327 hr = E_NOTIMPL;
328 }
329 else if (IsEqualIID(riid, IID_IShellView))
330 {
331 // Just create a default shell folder view, and register ourself as folder
332 SFV_CREATE sfv = { sizeof(SFV_CREATE) };
333 sfv.pshf = this;
334 hr = SHCreateShellFolderView(&sfv, (IShellView**)ppvOut);
335 }
336
337 return hr;
338}
HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv)
Definition: CDefView.cpp:3931
#define NULL
Definition: types.h:112
ULONG AddRef()
#define S_OK
Definition: intsafe.h:52
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
HRESULT hr
Definition: shlfolder.c:183
struct _SFV_CREATE SFV_CREATE
IShellFolder * pshf
Definition: shlobj.h:1283
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ DoGetFontTitle()

HRESULT CFontExt::DoGetFontTitle ( IN LPCWSTR  pszFontPath,
OUT CStringW strFontName 
)

Definition at line 665 of file CFontExt.cpp.

666{
667 DWORD cbInfo = 0;
668 BOOL ret = GetFontResourceInfoW(pszFontPath, &cbInfo, NULL, 1);
669 if (!ret || !cbInfo)
670 {
671 ERR("GetFontResourceInfoW failed (err: %u)\n", GetLastError());
672 return E_FAIL;
673 }
674
675 LPWSTR pszBuffer = strFontName.GetBuffer(cbInfo / sizeof(WCHAR));
676 ret = GetFontResourceInfoW(pszFontPath, &cbInfo, pszBuffer, 1);
678 strFontName.ReleaseBuffer();
679 if (ret)
680 {
681 TRACE("pszFontName: %S\n", (LPCWSTR)strFontName);
682 return S_OK;
683 }
684
685 ERR("GetFontResourceInfoW failed (err: %u)\n", dwErr);
686 return E_FAIL;
687}
DWORD dwErr
Definition: service.c:36
#define E_FAIL
Definition: ddrawi.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI GetFontResourceInfoW(LPCWSTR lpFileName, DWORD *pdwBufSize, void *lpBuffer, DWORD dwType)
#define TRACE(s)
Definition: solgame.cpp:4
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by DoInstallFontFile().

◆ DoInstallFontFile()

HRESULT CFontExt::DoInstallFontFile ( LPCWSTR  pszFontPath,
LPCWSTR  pszFontsDir,
HKEY  hkeyFonts 
)

Definition at line 615 of file CFontExt.cpp.

616{
617 WCHAR szDestFile[MAX_PATH];
618
619 // Add this font to the font list, so we can query the name
620 if (!AddFontResourceW(pszFontPath))
621 {
622 ERR("AddFontResourceW('%S') failed\n", pszFontPath);
623 DeleteFileW(szDestFile);
624 return E_FAIL;
625 }
626
627 CStringW strFontName;
628 HRESULT hr = DoGetFontTitle(pszFontPath, strFontName);
629
630 // We got the name, remove it again
631 RemoveFontResourceW(pszFontPath);
632
633 if (!SUCCEEDED(hr))
634 {
635 ERR("DoGetFontTitle failed (err=0x%x)!\n", hr);
636 return hr;
637 }
638
639 StringCchCopyW(szDestFile, sizeof(szDestFile), pszFontsDir);
640
641 LPCWSTR pszFileTitle = PathFindFileName(pszFontPath);
642 PathAppendW(szDestFile, pszFileTitle);
643 if (!CopyFileW(pszFontPath, szDestFile, FALSE))
644 {
645 ERR("CopyFileW('%S', '%S') failed\n", pszFontPath, szDestFile);
646 return E_FAIL;
647 }
648
649 DWORD cbData = (wcslen(pszFileTitle) + 1) * sizeof(WCHAR);
650 LONG nError = RegSetValueExW(hkeyFonts, strFontName, 0, REG_SZ,
651 (const BYTE *)pszFileTitle, cbData);
652 if (nError)
653 {
654 ERR("RegSetValueExW failed with %ld\n", nError);
655 DeleteFileW(szDestFile);
656 return E_FAIL;
657 }
658
659 AddFontResourceW(szDestFile);
660
661 return S_OK;
662}
HRESULT DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW &strFontName)
Definition: CFontExt.cpp:665
#define FALSE
Definition: types.h:117
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define REG_SZ
Definition: layer.c:22
long LONG
Definition: pedump.c:60
#define PathFindFileName
Definition: shlwapi.h:911
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
int WINAPI AddFontResourceW(_In_ LPCWSTR pszFilename)
BOOL WINAPI RemoveFontResourceW(_In_ LPCWSTR)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by Drop().

◆ DragEnter()

STDMETHODIMP CFontExt::DragEnter ( IDataObject pDataObj,
DWORD  grfKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 499 of file CFontExt.cpp.

500{
501 *pdwEffect = DROPEFFECT_NONE;
502
503 CDataObjectHIDA cida(pDataObj);
504 if (FAILED_UNEXPECTEDLY(cida.hr()))
505 return cida.hr();
506
507 *pdwEffect = DROPEFFECT_COPY;
508 return S_OK;
509}
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82

◆ DragLeave()

STDMETHODIMP CFontExt::DragLeave ( void  )
virtual

Implements IDropTarget.

Definition at line 516 of file CFontExt.cpp.

517{
518 return S_OK;
519}

◆ DragOver()

STDMETHODIMP CFontExt::DragOver ( DWORD  grfKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 511 of file CFontExt.cpp.

512{
513 return S_OK;
514}

◆ Drop()

STDMETHODIMP CFontExt::Drop ( IDataObject pDataObj,
DWORD  grfKeyState,
POINTL  pt,
DWORD pdwEffect 
)
virtual

Implements IDropTarget.

Definition at line 521 of file CFontExt.cpp.

522{
523 *pdwEffect = DROPEFFECT_NONE;
524
525 CDataObjectHIDA cida(pDataObj);
526 if (!cida)
527 return E_UNEXPECTED;
528
529 PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida);
530 if (!pidlParent)
531 {
532 ERR("pidlParent is NULL\n");
533 return E_FAIL;
534 }
535
536 BOOL bOK = TRUE;
537 CAtlArray<CStringW> FontPaths;
538 for (UINT n = 0; n < cida->cidl; ++n)
539 {
540 PCUIDLIST_RELATIVE pidlRelative = HIDA_GetPIDLItem(cida, n);
541 if (!pidlRelative)
542 continue;
543
544 PIDLIST_ABSOLUTE pidl = ILCombine(pidlParent, pidlRelative);
545 if (!pidl)
546 {
547 ERR("ILCombine failed\n");
548 bOK = FALSE;
549 break;
550 }
551
554 ILFree(pidl);
555
556 if (!ret)
557 {
558 ERR("SHGetPathFromIDListW failed\n");
559 bOK = FALSE;
560 break;
561 }
562
564 {
565 ERR("PathIsDirectory\n");
566 bOK = FALSE;
567 break;
568 }
569
570 LPCWSTR pchDotExt = PathFindExtensionW(szPath);
571 if (!IsFontDotExt(pchDotExt))
572 {
573 ERR("'%S' is not supported\n", pchDotExt);
574 bOK = FALSE;
575 break;
576 }
577
578 FontPaths.Add(szPath);
579 }
580
581 if (!bOK)
582 return E_FAIL;
583
584 CRegKey keyFonts;
585 if (keyFonts.Open(FONT_HIVE, FONT_KEY, KEY_WRITE) != ERROR_SUCCESS)
586 {
587 ERR("keyFonts.Open failed\n");
588 return E_FAIL;
589 }
590
591 for (size_t iItem = 0; iItem < FontPaths.GetCount(); ++iItem)
592 {
593 HRESULT hr = DoInstallFontFile(FontPaths[iItem], g_FontCache->FontPath(), keyFonts.m_hKey);
595 {
596 bOK = FALSE;
597 break;
598 }
599 }
600
601 // Invalidate our cache
602 g_FontCache->Read();
603
604 // Notify the system that a font was added
606
607 // Notify the shell that the folder contents are changed
609
610 // TODO: Show message
611
612 return bOK ? S_OK : E_FAIL;
613}
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
size_t Add(INARGTYPE element)
Definition: atlcoll.h:295
size_t GetCount() const
Definition: atlcoll.h:373
HKEY m_hKey
Definition: atlbase.h:1014
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE)
Definition: atlbase.h:1072
PCXSTR GetString() const
Definition: atlsimpstr.h:361
void Read()
Definition: CFontCache.cpp:200
const CStringW & FontPath() const
Definition: CFontCache.hpp:53
HRESULT DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HKEY hkeyFonts)
Definition: CFontExt.cpp:615
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
BOOL IsFontDotExt(LPCWSTR pchDotExt)
Definition: precomp.h:39
#define FONT_HIVE
Definition: precomp.h:30
#define FONT_KEY
Definition: precomp.h:31
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1722
GLdouble n
Definition: glext.h:7729
LPCWSTR szPath
Definition: env.c:37
unsigned int UINT
Definition: ndis.h:50
#define KEY_WRITE
Definition: nt_native.h:1031
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:569
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:564
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1754
#define SHCNF_PATHW
Definition: shlobj.h:1777
const ITEMIDLIST_ABSOLUTE UNALIGNED * PCUIDLIST_ABSOLUTE
Definition: shtypes.idl:63
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
#define E_UNEXPECTED
Definition: winerror.h:2456
#define HWND_BROADCAST
Definition: winuser.h:1194
#define WM_FONTCHANGE
Definition: winuser.h:1623
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ EnumObjects()

STDMETHODIMP CFontExt::EnumObjects ( HWND  hwndOwner,
DWORD  dwFlags,
LPENUMIDLIST *  ppEnumIDList 
)
virtual

Definition at line 235 of file CFontExt.cpp.

236{
237 return _CEnumFonts_CreateInstance(this, dwFlags, IID_PPV_ARG(IEnumIDList, ppEnumIDList));
238}
HRESULT _CEnumFonts_CreateInstance(CFontExt *zip, DWORD flags, REFIID riid, LPVOID *ppvOut)
Definition: CEnumFonts.cpp:87
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define IID_PPV_ARG(Itype, ppType)

◆ EnumSearches()

STDMETHODIMP CFontExt::EnumSearches ( IEnumExtraSearch **  ppenum)
virtual

Implements IShellFolder2.

Definition at line 100 of file CFontExt.cpp.

101{
102 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
103 return E_NOTIMPL;
104}

◆ GetAttributesOf()

STDMETHODIMP CFontExt::GetAttributesOf ( UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
DWORD rgfInOut 
)
virtual

Definition at line 340 of file CFontExt.cpp.

341{
342 if (!rgfInOut || !cidl || !apidl)
343 return E_INVALIDARG;
344
345 DWORD rgf = 0;
346 while (cidl > 0 && *apidl)
347 {
348 const FontPidlEntry* fontEntry = _FontFromIL(*apidl);
349 if (fontEntry)
350 {
351 // We don't support delete yet
352 rgf |= (/*SFGAO_CANDELETE |*/ SFGAO_HASPROPSHEET | SFGAO_CANCOPY | SFGAO_FILESYSTEM);
353 }
354 else
355 {
356 rgf = 0;
357 break;
358 }
359
360 apidl++;
361 cidl--;
362 }
363
364 *rgfInOut = rgf;
365 return S_OK;
366}

◆ GetClassID()

STDMETHODIMP CFontExt::GetClassID ( CLSID lpClassId)
virtual

Implements IPersist.

Definition at line 492 of file CFontExt.cpp.

493{
494 *lpClassId = CLSID_CFontExt;
495 return S_OK;
496}
const GUID CLSID_CFontExt
Definition: fontext.cpp:12

◆ GetCurFolder()

STDMETHODIMP CFontExt::GetCurFolder ( LPITEMIDLIST ppidl)
virtual

Definition at line 448 of file CFontExt.cpp.

449{
450 if (ppidl && m_Folder)
451 {
452 *ppidl = ILClone(m_Folder);
453 return S_OK;
454 }
455
456 return E_POINTER;
457}
CComHeapPtr< ITEMIDLIST > m_Folder
Definition: CFontExt.hpp:18
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define E_POINTER
Definition: winerror.h:2365

◆ GetDefaultColumn()

STDMETHODIMP CFontExt::GetDefaultColumn ( DWORD  dwReserved,
ULONG pSort,
ULONG pDisplay 
)
virtual

Implements IShellFolder2.

Definition at line 106 of file CFontExt.cpp.

107{
108 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
109 return E_NOTIMPL;
110}

◆ GetDefaultColumnState()

STDMETHODIMP CFontExt::GetDefaultColumnState ( UINT  iColumn,
SHCOLSTATEF pcsFlags 
)
virtual

Implements IShellFolder2.

Definition at line 112 of file CFontExt.cpp.

113{
114 if (!pcsFlags || iColumn >= _countof(g_ColumnDefs))
115 return E_INVALIDARG;
116
117 *pcsFlags = g_ColumnDefs[iColumn].dwDefaultState;
118 return S_OK;
119}
static FolderViewColumns g_ColumnDefs[]
Definition: CFontExt.cpp:35
#define _countof(array)
Definition: sndvol32.h:68
DWORD dwDefaultState
Definition: CFontExt.cpp:21

◆ GetDefaultSearchGUID()

STDMETHODIMP CFontExt::GetDefaultSearchGUID ( GUID lpguid)
virtual

Implements IShellFolder2.

Definition at line 94 of file CFontExt.cpp.

95{
96 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
97 return E_NOTIMPL;
98}

◆ GetDetailsEx()

STDMETHODIMP CFontExt::GetDetailsEx ( PCUITEMID_CHILD  pidl,
const SHCOLUMNID pscid,
VARIANT pv 
)
virtual

Implements IShellFolder2.

Definition at line 121 of file CFontExt.cpp.

122{
123 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
124 return E_NOTIMPL;
125}

◆ GetDetailsOf()

STDMETHODIMP CFontExt::GetDetailsOf ( PCUITEMID_CHILD  pidl,
UINT  iColumn,
SHELLDETAILS psd 
)
virtual

Implements IShellFolder2.

Definition at line 127 of file CFontExt.cpp.

128{
129 if (iColumn >= _countof(g_ColumnDefs))
130 return E_FAIL;
131
132 psd->cxChar = g_ColumnDefs[iColumn].cxChar;
133 psd->fmt = g_ColumnDefs[iColumn].fmt;
134
135 // No item requested, so return the column name
136 if (pidl == NULL)
137 {
138 return SHSetStrRet(&psd->str, _AtlBaseModule.GetResourceInstance(), g_ColumnDefs[iColumn].iResource);
139 }
140
141 // Validate that this pidl is the last one
142 PCUIDLIST_RELATIVE curpidl = ILGetNext(pidl);
143 if (curpidl->mkid.cb != 0)
144 {
145 ERR("ERROR, unhandled PIDL!\n");
146 return E_FAIL;
147 }
148
149 // Name, ReactOS specific?
150 if (iColumn == FONTEXT_COL_NAME)
151 return GetDisplayNameOf(pidl, 0, &psd->str);
152
153 const FontPidlEntry* fontEntry = _FontFromIL(pidl);
154 if (!fontEntry)
155 {
156 ERR("ERROR, not a font PIDL!\n");
157 return E_FAIL;
158 }
159
160 // If we got here, we are in details view!
161 auto info = g_FontCache->Find(fontEntry);
162 if (info == nullptr)
163 {
164 ERR("Unable to query info about %S\n", fontEntry->Name);
166 }
167
168 int ret;
169 CStringA AttrLetters;
172 switch (iColumn)
173 {
175 return SHSetStrRet(&psd->str, PathFindFileNameW(info->File()));
176 case FONTEXT_COL_SIZE:
177 psd->str.uType = STRRET_CSTR;
178 StrFormatKBSizeA(info->FileSize().QuadPart, psd->str.cStr, MAX_PATH);
179 return S_OK;
181 psd->str.uType = STRRET_CSTR;
182 FileTimeToSystemTime(&info->FileWriteTime(), &time);
184 if (ret < 1)
185 {
186 ERR("GetDateFormatA failed\n");
187 return E_FAIL;
188 }
189 psd->str.cStr[ret-1] = ' ';
191 return S_OK;
192 case FONTEXT_COL_ATTR:
193 AttrLetters.LoadString(IDS_COL_ATTR_LETTERS);
194 if (AttrLetters.GetLength() != 5)
195 {
196 ERR("IDS_COL_ATTR_LETTERS does not contain 5 letters!\n");
197 return E_FAIL;
198 }
199 psd->str.uType = STRRET_CSTR;
200 dwAttributes = info->FileAttributes();
201 ret = 0;
203 psd->str.cStr[ret++] = AttrLetters[0];
205 psd->str.cStr[ret++] = AttrLetters[1];
207 psd->str.cStr[ret++] = AttrLetters[2];
209 psd->str.cStr[ret++] = AttrLetters[3];
211 psd->str.cStr[ret++] = AttrLetters[4];
212 psd->str.cStr[ret] = '\0';
213 return S_OK;
214 default:
215 break;
216 }
217
219 return E_NOTIMPL;
220}
int GetLength() const
Definition: atlsimpstr.h:356
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:591
virtual STDMETHODIMP GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: CFontExt.cpp:412
#define IDS_COL_ATTR_LETTERS
Definition: resource.h:11
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
LPSTR WINAPI StrFormatKBSizeA(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
Definition: string.c:1727
INT WINAPI GetTimeFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1030
INT WINAPI GetDateFormatA(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
Definition: lcformat.c:922
__u16 time
Definition: mkdosfs.c:8
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define LOCALE_USER_DEFAULT
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
@ STRRET_CSTR
Definition: shtypes.idl:87
STRRET str
Definition: shtypes.idl:108
char cStr[MAX_PATH]
Definition: shtypes.idl:98
UINT uType
Definition: shtypes.idl:93
DWORD dwAttributes
Definition: vdmdbg.h:34
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define TIME_NOSECONDS
Definition: winnls.h:278
#define DATE_SHORTDATE
Definition: winnls.h:196

◆ GetDisplayNameOf()

STDMETHODIMP CFontExt::GetDisplayNameOf ( PCUITEMID_CHILD  pidl,
DWORD  dwFlags,
LPSTRRET  strRet 
)
virtual

Definition at line 412 of file CFontExt.cpp.

413{
414 if (!pidl)
415 return E_NOTIMPL;
416
417 // Validate that this pidl is the last one
418 PCUIDLIST_RELATIVE curpidl = ILGetNext(pidl);
419 if (curpidl->mkid.cb != 0)
420 {
421 ERR("ERROR, unhandled PIDL!\n");
422 return E_FAIL;
423 }
424
425 const FontPidlEntry* fontEntry = _FontFromIL(pidl);
426 if (!fontEntry)
427 return E_FAIL;
428
430 {
431 CStringW File = g_FontCache->Filename(g_FontCache->Find(fontEntry), true);
432 if (!File.IsEmpty())
433 {
434 return SHSetStrRet(strRet, File);
435 }
436 }
437
438 return SHSetStrRet(strRet, fontEntry->Name);
439}
CStringW Filename(CFontInfo *info, bool alwaysFullPath=false)
Definition: CFontCache.cpp:164
Definition: File.h:16

Referenced by GetDetailsOf().

◆ GetUIObjectOf()

STDMETHODIMP CFontExt::GetUIObjectOf ( HWND  hwndOwner,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
REFIID  riid,
UINT prgfInOut,
LPVOID ppvOut 
)
virtual

Definition at line 369 of file CFontExt.cpp.

370{
371 if (riid == IID_IContextMenu ||
372 riid == IID_IContextMenu2 ||
373 riid == IID_IContextMenu3)
374 {
375 return _CFontMenu_CreateInstance(hwndOwner, cidl, apidl, this, riid, ppvOut);
376 }
377 else if (riid == IID_IExtractIconA || riid == IID_IExtractIconW)
378 {
379 if (cidl == 1)
380 {
381 const FontPidlEntry* fontEntry = _FontFromIL(*apidl);
382 if (fontEntry)
383 {
386 // Just create a default icon extractor based on the filename
387 // We might want to create a preview with the font to get really fancy one day.
389 }
390 }
391 else
392 {
393 ERR("IID_IExtractIcon with cidl != 1 UNIMPLEMENTED\n");
394 }
395 }
396 else if (riid == IID_IDataObject)
397 {
398 if (cidl >= 1)
399 {
400 return _CDataObject_CreateInstance(m_Folder, cidl, apidl, riid, ppvOut);
401 }
402 else
403 {
404 ERR("IID_IDataObject with cidl == 0 UNIMPLEMENTED\n");
405 }
406 }
407
408 //ERR("%s(riid=%S) UNIMPLEMENTED\n", __FUNCTION__, g2s(riid));
409 return E_NOTIMPL;
410}
HRESULT _CDataObject_CreateInstance(PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, LPVOID *ppvOut)
Definition: CDataObject.cpp:38
EXTERN_C HRESULT WINAPI SHCreateFileExtractIconW(_In_ LPCWSTR pszFile, _In_ DWORD dwFileAttributes, _In_ REFIID riid, _Outptr_ void **ppv)
HRESULT _CFontMenu_CreateInstance(HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, REFIID riid, LPVOID *ppvOut)
Definition: CFontMenu.cpp:114
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
const GUID IID_IDataObject

◆ Initialize()

STDMETHODIMP CFontExt::Initialize ( LPCITEMIDLIST  pidl)
virtual

Definition at line 461 of file CFontExt.cpp.

462{
463 WCHAR PidlPath[MAX_PATH + 1] = {0}, FontsDir[MAX_PATH + 1];
464 if (!SHGetPathFromIDListW(pidl, PidlPath))
465 {
466 ERR("Unable to extract path from pidl\n");
467 return E_FAIL;
468 }
469
472 {
473 ERR("Unable to get fonts path (0x%x)\n", hr);
474 return hr;
475 }
476
477 if (_wcsicmp(PidlPath, FontsDir))
478 {
479 ERR("CFontExt View initializing on unexpected folder: '%S'\n", PidlPath);
480 return E_FAIL;
481 }
482
483 m_Folder.Attach(ILClone(pidl));
484 StringCchCatW(FontsDir, _countof(FontsDir), L"\\");
485 g_FontCache->SetFontDir(FontsDir);
486
487 return S_OK;
488}
void SetFontDir(const LPCWSTR Path)
Definition: CFontCache.cpp:120
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define CSIDL_FONTS
Definition: shlobj.h:2044
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325

◆ MapColumnToSCID()

STDMETHODIMP CFontExt::MapColumnToSCID ( UINT  iColumn,
SHCOLUMNID pscid 
)
virtual

Implements IShellFolder2.

Definition at line 222 of file CFontExt.cpp.

223{
224 //ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
225 return E_NOTIMPL;
226}

◆ ParseDisplayName()

STDMETHODIMP CFontExt::ParseDisplayName ( HWND  hwndOwner,
LPBC  pbc,
LPOLESTR  lpszDisplayName,
DWORD pchEaten,
PIDLIST_RELATIVE ppidl,
DWORD pdwAttributes 
)
virtual

Definition at line 229 of file CFontExt.cpp.

230{
231 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
232 return E_NOTIMPL;
233}

◆ SetNameOf()

STDMETHODIMP CFontExt::SetNameOf ( HWND  hwndOwner,
PCUITEMID_CHILD  pidl,
LPCOLESTR  lpName,
DWORD  dwFlags,
PITEMID_CHILD pPidlOut 
)
virtual

Implements IShellFolder.

Definition at line 441 of file CFontExt.cpp.

442{
443 ERR("%s() UNIMPLEMENTED\n", __FUNCTION__);
444 return E_NOTIMPL;
445}

Member Data Documentation

◆ m_Folder

CComHeapPtr<ITEMIDLIST> CFontExt::m_Folder
private

Definition at line 18 of file CFontExt.hpp.

Referenced by GetCurFolder(), GetUIObjectOf(), and Initialize().


The documentation for this class was generated from the following files: