1 /* 2 * Fonts folder 3 * 4 * Copyright 2008 Johannes Anderwald <johannes.anderwald@reactos.org> 5 * Copyright 2009 Andrew Hill 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 */ 21 22 #include <precomp.h> 23 24 WINE_DEFAULT_DEBUG_CHANNEL (shell); 25 26 /* 27 This folder should not exist. It is just a file system folder... The \windows\fonts 28 directory contains a hidden desktop.ini with a UIHandler entry that specifies a class 29 that lives in fontext.dll. The UI handler creates a custom view for the folder, which 30 is what we normally see. However, the folder is a perfectly normal CFSFolder. 31 */ 32 33 /*********************************************************************** 34 * IShellFolder implementation 35 */ 36 37 CFontsFolder::CFontsFolder() 38 { 39 m_pisfInner = NULL; 40 m_pisf2Inner = NULL; 41 42 pidlRoot = NULL; 43 apidl = NULL; 44 } 45 46 CFontsFolder::~CFontsFolder() 47 { 48 TRACE("-- destroying IShellFolder(%p)\n", this); 49 SHFree(pidlRoot); 50 } 51 52 HRESULT WINAPI CFontsFolder::FinalConstruct() 53 { 54 HRESULT hr; 55 CComPtr<IPersistFolder3> ppf3; 56 hr = SHCoCreateInstance(NULL, &CLSID_ShellFSFolder, NULL, IID_PPV_ARG(IShellFolder, &m_pisfInner)); 57 if (FAILED(hr)) 58 return hr; 59 60 hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IShellFolder2, &m_pisf2Inner)); 61 if (FAILED(hr)) 62 return hr; 63 64 hr = m_pisfInner->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3)); 65 if (FAILED(hr)) 66 return hr; 67 68 PERSIST_FOLDER_TARGET_INFO info; 69 ZeroMemory(&info, sizeof(PERSIST_FOLDER_TARGET_INFO)); 70 info.csidl = CSIDL_FONTS; 71 hr = ppf3->InitializeEx(NULL, _ILCreateFont(), &info); 72 73 return hr; 74 } 75 76 77 HRESULT WINAPI CFontsFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, 78 ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes) 79 { 80 return m_pisfInner->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes); 81 } 82 83 HRESULT WINAPI CFontsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) 84 { 85 return m_pisfInner->EnumObjects(hwndOwner, dwFlags, ppEnumIDList); 86 } 87 88 HRESULT WINAPI CFontsFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 89 { 90 return m_pisfInner->BindToObject(pidl, pbcReserved, riid, ppvOut); 91 } 92 93 HRESULT WINAPI CFontsFolder::BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) 94 { 95 return m_pisfInner->BindToStorage(pidl, pbcReserved, riid, ppvOut); 96 } 97 98 HRESULT WINAPI CFontsFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) 99 { 100 return m_pisfInner->CompareIDs(lParam, pidl1, pidl2); 101 } 102 103 HRESULT WINAPI CFontsFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) 104 { 105 return m_pisfInner->CreateViewObject(hwndOwner, riid, ppvOut); 106 } 107 108 HRESULT WINAPI CFontsFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) 109 { 110 return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut); 111 } 112 113 HRESULT WINAPI CFontsFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, 114 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) 115 { 116 return m_pisfInner->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut); 117 } 118 119 HRESULT WINAPI CFontsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) 120 { 121 if (!_ILIsSpecialFolder(pidl)) 122 return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet); 123 124 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl, dwFlags, strRet); 125 pdump (pidl); 126 127 if (!strRet) 128 return E_INVALIDARG; 129 130 if (!pidl->mkid.cb) 131 { 132 WCHAR wszPath[MAX_PATH]; 133 134 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && 135 (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)) 136 { 137 if (!SHGetSpecialFolderPathW(NULL, wszPath, CSIDL_FONTS, FALSE)) 138 return E_FAIL; 139 } 140 else if (!HCR_GetClassNameW(CLSID_FontsFolderShortcut, wszPath, MAX_PATH)) 141 return E_FAIL; 142 143 strRet->pOleStr = (LPWSTR)CoTaskMemAlloc((wcslen(wszPath) + 1) * sizeof(WCHAR)); 144 if (!strRet->pOleStr) 145 return E_OUTOFMEMORY; 146 147 wcscpy(strRet->pOleStr, wszPath); 148 strRet->uType = STRRET_WSTR; 149 150 return S_OK; 151 } 152 else 153 return E_INVALIDARG; 154 } 155 156 HRESULT WINAPI CFontsFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /* simple pidl */ 157 LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) 158 { 159 return m_pisfInner->SetNameOf(hwndOwner, pidl, lpName, dwFlags, pPidlOut); 160 } 161 162 HRESULT WINAPI CFontsFolder::GetDefaultSearchGUID(GUID *pguid) 163 { 164 return m_pisf2Inner->GetDefaultSearchGUID(pguid); 165 } 166 167 HRESULT WINAPI CFontsFolder::EnumSearches(IEnumExtraSearch ** ppenum) 168 { 169 return m_pisf2Inner->EnumSearches(ppenum); 170 } 171 172 HRESULT WINAPI CFontsFolder::GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) 173 { 174 return m_pisf2Inner->GetDefaultColumn(dwRes, pSort, pDisplay); 175 } 176 177 HRESULT WINAPI CFontsFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) 178 { 179 return m_pisf2Inner->GetDefaultColumnState(iColumn, pcsFlags); 180 } 181 182 HRESULT WINAPI CFontsFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) 183 { 184 return m_pisf2Inner->GetDetailsEx(pidl, pscid, pv); 185 } 186 187 HRESULT WINAPI CFontsFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) 188 { 189 return m_pisf2Inner->GetDetailsOf(pidl, iColumn, psd); 190 } 191 192 HRESULT WINAPI CFontsFolder::MapColumnToSCID(UINT column, SHCOLUMNID *pscid) 193 { 194 return m_pisf2Inner->MapColumnToSCID(column, pscid); 195 } 196 197 /************************************************************************ 198 * CFontsFolder::GetClassID 199 */ 200 HRESULT WINAPI CFontsFolder::GetClassID(CLSID *lpClassId) 201 { 202 TRACE ("(%p)\n", this); 203 204 if (!lpClassId) 205 return E_POINTER; 206 207 *lpClassId = CLSID_FontsFolderShortcut; 208 209 return S_OK; 210 } 211 212 /************************************************************************ 213 * CFontsFolder::Initialize 214 * 215 * NOTES: it makes no sense to change the pidl 216 */ 217 HRESULT WINAPI CFontsFolder::Initialize(LPCITEMIDLIST pidl) 218 { 219 TRACE ("(%p)->(%p)\n", this, pidl); 220 221 return E_NOTIMPL; 222 } 223 224 /************************************************************************** 225 * CFontsFolder::GetCurFolder 226 */ 227 HRESULT WINAPI CFontsFolder::GetCurFolder(LPITEMIDLIST *pidl) 228 { 229 TRACE ("(%p)->(%p)\n", this, pidl); 230 231 if (!pidl) 232 return E_POINTER; 233 234 *pidl = ILClone(pidlRoot); 235 236 return S_OK; 237 } 238