xref: /reactos/dll/shellext/fontext/CFontExt.hpp (revision 2aca4b27)
1 /*
2  * PROJECT:     ReactOS Font Shell Extension
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     CFontExt definition
5  * COPYRIGHT:   Copyright 2019,2020 Mark Jansen (mark.jansen@reactos.org)
6  *              Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
7  */
8 
9 #pragma once
10 
11 class CFontExt :
12     public CComCoClass<CFontExt, &CLSID_CFontExt>,
13     public CComObjectRootEx<CComMultiThreadModelNoCS>,
14     public IShellFolder2,
15     public IPersistFolder2,
16     public IDropTarget
17 {
18     CComHeapPtr<ITEMIDLIST> m_Folder;
19     CStringW m_LastDetailsFontName;
20     WIN32_FIND_DATAW m_LastDetailsFileData;
21 
22 public:
23 
24     CFontExt();
25     ~CFontExt();
26 
27     // *** IShellFolder2 methods ***
28     virtual STDMETHODIMP GetDefaultSearchGUID(GUID *lpguid);
29     virtual STDMETHODIMP EnumSearches(IEnumExtraSearch **ppenum);
30     virtual STDMETHODIMP GetDefaultColumn(DWORD dwReserved, ULONG *pSort, ULONG *pDisplay);
31     virtual STDMETHODIMP GetDefaultColumnState(UINT iColumn, SHCOLSTATEF *pcsFlags);
32     virtual STDMETHODIMP GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv);
33     virtual STDMETHODIMP GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd);
34     virtual STDMETHODIMP MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid);
35 
36     // *** IShellFolder methods ***
37     virtual STDMETHODIMP ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes);
38     virtual STDMETHODIMP EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList);
39     virtual STDMETHODIMP BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut);
40     virtual STDMETHODIMP BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut);
41     virtual STDMETHODIMP CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2);
42     virtual STDMETHODIMP CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut);
43     virtual STDMETHODIMP GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut);
44     virtual STDMETHODIMP GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut);
45     virtual STDMETHODIMP GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet);
46     virtual STDMETHODIMP SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut);
47 
48 
49     // *** IPersistFolder2 methods ***
50     virtual STDMETHODIMP GetCurFolder(LPITEMIDLIST *ppidl);
51 
52     // *** IPersistFolder methods ***
53     virtual STDMETHODIMP Initialize(LPCITEMIDLIST pidl);
54 
55     // *** IPersist methods ***
56     virtual STDMETHODIMP GetClassID(CLSID *lpClassId);
57 
58     // *** IDropTarget methods ***
59     virtual STDMETHODIMP DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
60     virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
61     virtual STDMETHODIMP DragLeave();
62     virtual STDMETHODIMP Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
63 
64 #if 0
65     static HRESULT WINAPI log_stuff(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw)
66     {
67         WCHAR* g2s(REFCLSID iid);
68 
69         WCHAR buffer[MAX_PATH];
70         StringCchPrintfW(buffer, _countof(buffer), L"CFontExt::QueryInterface(%s)\n", g2s(riid));
71         OutputDebugStringW(buffer);
72 
73         return E_NOINTERFACE;
74     }
75 #endif
76 
77 protected:
78 
79 public:
80 
81     DECLARE_REGISTRY_RESOURCEID(IDR_FONTEXT)
82     DECLARE_NOT_AGGREGATABLE(CFontExt)
83 
84     DECLARE_PROTECT_FINAL_CONSTRUCT()
85 
86     BEGIN_COM_MAP(CFontExt)
87         COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
88         COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder)
89         COM_INTERFACE_ENTRY_IID(IID_IPersistFolder2, IPersistFolder2)
90         COM_INTERFACE_ENTRY_IID(IID_IPersistFolder, IPersistFolder)
91         COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
92         //COM_INTERFACE_ENTRY_FUNC_BLIND(0, log_stuff)
93     END_COM_MAP()
94 
95     HRESULT DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HKEY hkeyFonts);
96     HRESULT DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName);
97 };
98