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: CEnumFonts implementation 5 * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org) 6 */ 7 8 #include "precomp.h" 9 10 WINE_DEFAULT_DEBUG_CHANNEL(fontext); 11 12 13 14 class CEnumFonts : 15 public CComObjectRootEx<CComMultiThreadModelNoCS>, 16 public IEnumIDList 17 { 18 private: 19 DWORD m_dwFlags; 20 ULONG m_Index; 21 22 public: 23 CEnumFonts() 24 :m_dwFlags(0) 25 ,m_Index(0) 26 { 27 } 28 29 STDMETHODIMP Initialize(CFontExt* folder, DWORD flags) 30 { 31 m_dwFlags = flags; 32 m_Index = 0; 33 return S_OK; 34 } 35 36 // *** IEnumIDList methods *** 37 STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched) 38 { 39 if (!pceltFetched || !rgelt) 40 return E_POINTER; 41 42 ULONG Fetched = 0; 43 44 while (celt) 45 { 46 celt--; 47 48 if (m_Index < g_FontCache->Size()) 49 { 50 CStringW Name = g_FontCache->Name(m_Index); 51 rgelt[Fetched] = _ILCreate(Name, m_Index); 52 53 m_Index++; 54 Fetched++; 55 } 56 } 57 58 *pceltFetched = Fetched; 59 return Fetched ? S_OK : S_FALSE; 60 } 61 STDMETHODIMP Skip(ULONG celt) 62 { 63 m_Index += celt; 64 return S_OK; 65 } 66 STDMETHODIMP Reset() 67 { 68 m_Index = 0; 69 return S_OK; 70 } 71 STDMETHODIMP Clone(IEnumIDList **ppenum) 72 { 73 return E_NOTIMPL; 74 } 75 76 77 public: 78 DECLARE_NOT_AGGREGATABLE(CEnumFonts) 79 DECLARE_PROTECT_FINAL_CONSTRUCT() 80 81 BEGIN_COM_MAP(CEnumFonts) 82 COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList) 83 END_COM_MAP() 84 }; 85 86 87 HRESULT _CEnumFonts_CreateInstance(CFontExt* zip, DWORD flags, REFIID riid, LPVOID * ppvOut) 88 { 89 return ShellObjectCreatorInit<CEnumFonts>(zip, flags, riid, ppvOut); 90 } 91 92