ReactOS  0.4.15-dev-2354-g9e947e2
CEnumFonts.cpp
Go to the documentation of this file.
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 
11 
12 
13 
14 class CEnumFonts :
15  public CComObjectRootEx<CComMultiThreadModelNoCS>,
16  public IEnumIDList
17 {
18 private:
21 
22 public:
24  :m_dwFlags(0)
25  ,m_Index(0)
26  {
27  }
28 
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  {
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  }
62  {
63  m_Index += celt;
64  return S_OK;
65  }
67  {
68  m_Index = 0;
69  return S_OK;
70  }
72  {
73  return E_NOTIMPL;
74  }
75 
76 
77 public:
80 
82  COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
83  END_COM_MAP()
84 };
85 
86 
88 {
89  return ShellObjectCreatorInit<CEnumFonts>(zip, flags, riid, ppvOut);
90 }
91 
#define REFIID
Definition: guiddef.h:118
Definition: fci.c:115
REFIID riid
Definition: precomp.h:44
HRESULT _CEnumFonts_CreateInstance(CFontExt *zip, DWORD flags, REFIID riid, LPVOID *ppvOut)
Definition: CEnumFonts.cpp:87
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:611
ULONG m_Index
Definition: CEnumFonts.cpp:20
#define STDMETHODIMP
Definition: basetyps.h:43
#define S_FALSE
Definition: winerror.h:2357
DWORD m_dwFlags
Definition: CEnumFonts.cpp:19
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
STDMETHODIMP Initialize(CFontExt *folder, DWORD flags)
Definition: CEnumFonts.cpp:29
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
STDMETHODIMP Reset()
Definition: CEnumFonts.cpp:66
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
#define S_OK
Definition: intsafe.h:51
CStringW Name(size_t Index)
Definition: CFontCache.cpp:85
STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched)
Definition: CEnumFonts.cpp:37
WINE_DEFAULT_DEBUG_CHANNEL(fontext)
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
#define E_NOTIMPL
Definition: ddrawi.h:99
STDMETHODIMP Clone(IEnumIDList **ppenum)
Definition: CEnumFonts.cpp:71
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:639
unsigned int ULONG
Definition: retypes.h:1
#define END_COM_MAP()
Definition: atlcom.h:552
#define E_POINTER
Definition: winerror.h:2365
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
STDMETHODIMP Skip(ULONG celt)
Definition: CEnumFonts.cpp:61
LPITEMIDLIST _ILCreate(LPCWSTR lpString, ULONG Index)
Definition: fontpidl.cpp:10