2019-08-03 13:14:20 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Font Shell Extension
|
|
|
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
|
|
|
* PURPOSE: CEnumFonts implementation
|
2021-07-15 20:45:19 +00:00
|
|
|
* COPYRIGHT: Copyright 2019 Mark Jansen <mark.jansen@reactos.org>
|
2019-08-03 13:14:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CEnumFonts :
|
|
|
|
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
|
|
|
public IEnumIDList
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
DWORD m_dwFlags;
|
|
|
|
ULONG m_Index;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CEnumFonts()
|
|
|
|
:m_dwFlags(0)
|
|
|
|
,m_Index(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
STDMETHODIMP Initialize(CFontExt* folder, DWORD flags)
|
|
|
|
{
|
|
|
|
m_dwFlags = flags;
|
|
|
|
m_Index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// *** IEnumIDList methods ***
|
|
|
|
STDMETHODIMP Next(ULONG celt, LPITEMIDLIST *rgelt, ULONG *pceltFetched)
|
|
|
|
{
|
2023-11-13 15:31:37 +00:00
|
|
|
if (!rgelt || (!pceltFetched && celt != 1))
|
2019-08-03 13:14:20 +00:00
|
|
|
return E_POINTER;
|
|
|
|
|
2023-11-13 15:31:37 +00:00
|
|
|
HRESULT hr = S_OK;
|
2019-08-03 13:14:20 +00:00
|
|
|
ULONG Fetched = 0;
|
|
|
|
|
|
|
|
while (celt)
|
|
|
|
{
|
|
|
|
celt--;
|
|
|
|
|
|
|
|
if (m_Index < g_FontCache->Size())
|
|
|
|
{
|
|
|
|
CStringW Name = g_FontCache->Name(m_Index);
|
2023-11-13 15:31:37 +00:00
|
|
|
LPITEMIDLIST item = _ILCreate(Name, m_Index);
|
|
|
|
if (!item)
|
|
|
|
{
|
|
|
|
hr = Fetched ? S_FALSE : E_OUTOFMEMORY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rgelt[Fetched] = item;
|
2019-08-03 13:14:20 +00:00
|
|
|
m_Index++;
|
|
|
|
Fetched++;
|
|
|
|
}
|
2023-11-13 15:31:37 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
2019-08-03 13:14:20 +00:00
|
|
|
}
|
|
|
|
|
2023-11-13 15:31:37 +00:00
|
|
|
if (pceltFetched)
|
|
|
|
*pceltFetched = Fetched;
|
|
|
|
return hr;
|
2019-08-03 13:14:20 +00:00
|
|
|
}
|
|
|
|
STDMETHODIMP Skip(ULONG celt)
|
|
|
|
{
|
|
|
|
m_Index += celt;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
STDMETHODIMP Reset()
|
|
|
|
{
|
|
|
|
m_Index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
STDMETHODIMP Clone(IEnumIDList **ppenum)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
DECLARE_NOT_AGGREGATABLE(CEnumFonts)
|
|
|
|
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
2021-09-13 01:33:14 +00:00
|
|
|
|
2019-08-03 13:14:20 +00:00
|
|
|
BEGIN_COM_MAP(CEnumFonts)
|
|
|
|
COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
|
|
|
|
END_COM_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
HRESULT _CEnumFonts_CreateInstance(CFontExt* zip, DWORD flags, REFIID riid, LPVOID * ppvOut)
|
|
|
|
{
|
|
|
|
return ShellObjectCreatorInit<CEnumFonts>(zip, flags, riid, ppvOut);
|
|
|
|
}
|
|
|
|
|