[SHELLFIND] Add CFindFolder
[reactos.git] / dll / win32 / browseui / shellfind / CFindFolder.cpp
1 /*
2 * PROJECT: ReactOS Search Shell Extension
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Search results folder
5 * COPYRIGHT: Copyright 2019 Brock Mammen
6 */
7
8 #include "CFindFolder.h"
9
10 WINE_DEFAULT_DEBUG_CHANNEL(shellfind);
11
12 struct FolderViewColumns
13 {
14 LPCWSTR wzColumnName;
15 DWORD dwDefaultState;
16 int fmt;
17 int cxChar;
18 };
19
20 static FolderViewColumns g_ColumnDefs[] =
21 {
22 {L"Name", SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
23 {L"In Folder", SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 30},
24 {L"Relevance", SHCOLSTATE_TYPE_STR, LVCFMT_LEFT, 0}
25 };
26
27 // *** IShellFolder2 methods ***
28 STDMETHODIMP CFindFolder::GetDefaultSearchGUID(GUID *pguid)
29 {
30 UNIMPLEMENTED;
31 return E_NOTIMPL;
32 }
33
34 STDMETHODIMP CFindFolder::EnumSearches(IEnumExtraSearch **ppenum)
35 {
36 UNIMPLEMENTED;
37 return E_NOTIMPL;
38 }
39
40 STDMETHODIMP CFindFolder::GetDefaultColumn(DWORD, ULONG *pSort, ULONG *pDisplay)
41 {
42 if (pSort)
43 *pSort = 0;
44 if (pDisplay)
45 *pDisplay = 0;
46 return S_OK;
47 }
48
49 STDMETHODIMP CFindFolder::GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
50 {
51 if (!pcsFlags || iColumn >= _countof(g_ColumnDefs))
52 return E_INVALIDARG;
53 *pcsFlags = g_ColumnDefs[iColumn].dwDefaultState;
54 return S_OK;
55 }
56
57 STDMETHODIMP CFindFolder::GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
58 {
59 UNIMPLEMENTED;
60 return E_NOTIMPL;
61 }
62
63 STDMETHODIMP CFindFolder::GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *pDetails)
64 {
65 if (iColumn >= _countof(g_ColumnDefs))
66 return E_FAIL;
67
68 pDetails->cxChar = g_ColumnDefs[iColumn].cxChar;
69 pDetails->fmt = g_ColumnDefs[iColumn].fmt;
70
71 if (!pidl)
72 return SHSetStrRet(&pDetails->str, g_ColumnDefs[iColumn].wzColumnName);
73
74 return GetDisplayNameOf(pidl, SHGDN_NORMAL, &pDetails->str);
75 }
76
77 STDMETHODIMP CFindFolder::MapColumnToSCID(UINT iColumn, SHCOLUMNID *pscid)
78 {
79 UNIMPLEMENTED;
80 return E_NOTIMPL;
81 }
82
83 // *** IShellFolder methods ***
84 STDMETHODIMP CFindFolder::ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten,
85 PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
86 {
87 UNIMPLEMENTED;
88 return E_NOTIMPL;
89 }
90
91 STDMETHODIMP CFindFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
92 {
93 *ppEnumIDList = NULL;
94 return S_FALSE;
95 }
96
97 STDMETHODIMP CFindFolder::BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
98 {
99 UNIMPLEMENTED;
100 return E_NOTIMPL;
101 }
102
103 STDMETHODIMP CFindFolder::BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
104 {
105 UNIMPLEMENTED;
106 return E_NOTIMPL;
107 }
108
109 STDMETHODIMP CFindFolder::CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
110 {
111 UNIMPLEMENTED;
112 return E_NOTIMPL;
113 }
114
115 STDMETHODIMP CFindFolder::CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
116 {
117 if (riid == IID_IShellView)
118 {
119 SFV_CREATE sfvparams = {};
120 sfvparams.cbSize = sizeof(SFV_CREATE);
121 sfvparams.pshf = this;
122 HRESULT hr = SHCreateShellFolderView(&sfvparams, (IShellView **) ppvOut);
123 return hr;
124 }
125 return E_NOINTERFACE;
126 }
127
128 STDMETHODIMP CFindFolder::GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
129 {
130 *rgfInOut = SFGAO_NONENUMERATED;
131 return S_OK;
132 }
133
134 STDMETHODIMP CFindFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid,
135 UINT *prgfInOut, LPVOID *ppvOut)
136 {
137 return E_NOINTERFACE;
138 }
139
140 STDMETHODIMP CFindFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET pName)
141 {
142 return SHSetStrRet(pName, "search result");
143 }
144
145 STDMETHODIMP CFindFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags,
146 PITEMID_CHILD *pPidlOut)
147 {
148 UNIMPLEMENTED;
149 return E_NOTIMPL;
150 }
151 //// *** IPersistFolder2 methods ***
152 STDMETHODIMP CFindFolder::GetCurFolder(LPITEMIDLIST *pidl)
153 {
154 *pidl = ILClone(m_pidl);
155 return S_OK;
156 }
157
158 // *** IPersistFolder methods ***
159 STDMETHODIMP CFindFolder::Initialize(LPCITEMIDLIST pidl)
160 {
161 m_pidl = ILClone(pidl);
162 if (!m_pidl)
163 return E_OUTOFMEMORY;
164
165 return S_OK;
166 }
167
168 // *** IPersist methods ***
169 STDMETHODIMP CFindFolder::GetClassID(CLSID *pClassId)
170 {
171 if (pClassId == NULL)
172 return E_INVALIDARG;
173 memcpy(pClassId, &CLSID_FindFolder, sizeof(CLSID));
174 return S_OK;
175 }