msxml4/tests: Copy namespaces as attributes tests.
[wine.git] / dlls / objsel / objsel.c
blobfce397cf557388319882a33fc44375b4e3e19c67
1 /*
2 * Object Picker Dialog
4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
6 * Copyright 2005 Thomas Weidenmueller <w3seek@reactos.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define COBJMACROS
24 #include "objidl.h"
25 #include "objsel.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(objsel);
31 typedef struct
33 IDsObjectPicker IDsObjectPicker_iface;
34 LONG ref;
35 } IDsObjectPickerImpl;
37 /**********************************************************************
38 * OBJSEL_IDsObjectPicker_Destroy (also IUnknown)
40 static VOID OBJSEL_IDsObjectPicker_Destroy(IDsObjectPickerImpl *This)
42 HeapFree(GetProcessHeap(),
44 This);
48 static inline IDsObjectPickerImpl *impl_from_IDsObjectPicker(IDsObjectPicker *iface)
50 return CONTAINING_RECORD(iface, IDsObjectPickerImpl, IDsObjectPicker_iface);
53 /**********************************************************************
54 * OBJSEL_IDsObjectPicker_AddRef (also IUnknown)
56 static ULONG WINAPI OBJSEL_IDsObjectPicker_AddRef(IDsObjectPicker * iface)
58 IDsObjectPickerImpl *This = impl_from_IDsObjectPicker(iface);
60 TRACE("\n");
62 return InterlockedIncrement(&This->ref);
66 /**********************************************************************
67 * OBJSEL_IDsObjectPicker_Release (also IUnknown)
69 static ULONG WINAPI OBJSEL_IDsObjectPicker_Release(IDsObjectPicker * iface)
71 IDsObjectPickerImpl *This = impl_from_IDsObjectPicker(iface);
72 ULONG ref;
74 TRACE("\n");
76 ref = InterlockedDecrement(&This->ref);
78 if (ref == 0)
79 OBJSEL_IDsObjectPicker_Destroy(This);
81 return ref;
85 /**********************************************************************
86 * OBJSEL_IDsObjectPicker_QueryInterface (also IUnknown)
88 static HRESULT WINAPI OBJSEL_IDsObjectPicker_QueryInterface(
89 IDsObjectPicker * iface,
90 REFIID riid,
91 LPVOID *ppvObj)
93 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
95 if (ppvObj == NULL) return E_POINTER;
97 if (IsEqualGUID(riid, &IID_IUnknown) ||
98 IsEqualGUID(riid, &IID_IDsObjectPicker))
100 *ppvObj = iface;
101 OBJSEL_IDsObjectPicker_AddRef(iface);
102 return S_OK;
105 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
106 return E_NOINTERFACE;
110 /**********************************************************************
111 * OBJSEL_IDsObjectPicker_Initialize
113 static HRESULT WINAPI OBJSEL_IDsObjectPicker_Initialize(
114 IDsObjectPicker * iface,
115 PDSOP_INIT_INFO pInitInfo)
117 FIXME("stub!\n");
118 return S_OK;
122 /**********************************************************************
123 * OBJSEL_IDsObjectPicker_InvokeDialog
125 static HRESULT WINAPI OBJSEL_IDsObjectPicker_InvokeDialog(
126 IDsObjectPicker * iface,
127 HWND hwndParent,
128 IDataObject** ppdoSelections)
130 FIXME("stub!\n");
131 return S_FALSE;
135 /**********************************************************************
136 * IDsObjectPicker_Vtbl
138 static IDsObjectPickerVtbl IDsObjectPicker_Vtbl =
140 OBJSEL_IDsObjectPicker_QueryInterface,
141 OBJSEL_IDsObjectPicker_AddRef,
142 OBJSEL_IDsObjectPicker_Release,
143 OBJSEL_IDsObjectPicker_Initialize,
144 OBJSEL_IDsObjectPicker_InvokeDialog
148 static HRESULT object_picker_create(void **ppvObj)
150 IDsObjectPickerImpl *Instance = HeapAlloc(GetProcessHeap(),
151 HEAP_ZERO_MEMORY,
152 sizeof(IDsObjectPickerImpl));
153 if (Instance != NULL)
155 Instance->IDsObjectPicker_iface.lpVtbl = &IDsObjectPicker_Vtbl;
156 OBJSEL_IDsObjectPicker_AddRef(&Instance->IDsObjectPicker_iface);
158 *ppvObj = Instance;
159 return S_OK;
161 else
162 return E_OUTOFMEMORY;
166 struct class_factory
168 IClassFactory IClassFactory_iface;
169 LONG ref;
173 static struct class_factory *impl_from_IClassFactory(IClassFactory *iface)
175 return CONTAINING_RECORD(iface, struct class_factory, IClassFactory_iface);
179 static HRESULT WINAPI class_factory_QueryInterface(IClassFactory *iface, REFIID iid, void **out)
181 TRACE("iid %s, out %p.\n", debugstr_guid(iid), out);
183 if (!out)
184 return E_POINTER;
186 if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IClassFactory))
188 *out = iface;
189 IClassFactory_AddRef(iface);
190 return S_OK;
193 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
194 return E_NOINTERFACE;
198 static ULONG WINAPI class_factory_AddRef(IClassFactory *iface)
200 struct class_factory *factory = impl_from_IClassFactory(iface);
202 TRACE("\n");
204 return InterlockedIncrement(&factory->ref);
208 static ULONG WINAPI class_factory_Release(IClassFactory *iface)
210 struct class_factory *factory = impl_from_IClassFactory(iface);
212 TRACE("\n");
214 return InterlockedDecrement(&factory->ref);
218 static HRESULT WINAPI class_factory_CreateInstance(IClassFactory *iface,
219 IUnknown *outer, REFIID iid, void **out)
221 TRACE("outer %p, iid %s, out %p.\n", outer, debugstr_guid(iid), out);
223 if (!out)
224 return E_POINTER;
226 if (outer)
227 return CLASS_E_NOAGGREGATION;
229 if (IsEqualGUID(&IID_IDsObjectPicker, iid))
230 return object_picker_create(out);
232 return CLASS_E_CLASSNOTAVAILABLE;
236 static HRESULT WINAPI class_factory_LockServer(IClassFactory *iface, BOOL lock)
238 TRACE("lock %d.\n", lock);
240 if (lock)
241 IClassFactory_AddRef(iface);
242 else
243 IClassFactory_Release(iface);
244 return S_OK;
248 static IClassFactoryVtbl class_factory_vtbl =
250 class_factory_QueryInterface,
251 class_factory_AddRef,
252 class_factory_Release,
253 class_factory_CreateInstance,
254 class_factory_LockServer
258 static struct class_factory class_factory = {{&class_factory_vtbl}, 0};
260 /***********************************************************************
261 * DllGetClassObject (OBJSEL.@)
263 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **out)
265 TRACE("clsid %s, iid %s, out %p.\n", debugstr_guid(clsid), debugstr_guid(iid), out);
267 *out = NULL;
269 if (IsEqualGUID(clsid, &CLSID_DsObjectPicker))
270 return IClassFactory_QueryInterface(&class_factory.IClassFactory_iface, iid, out);
272 FIXME("%s not available, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(clsid));
273 return CLASS_E_CLASSNOTAVAILABLE;