gphoto2.ds: Set supported groups.
[wine.git] / dlls / mshtml / service.c
blobd344293f6e372ae6c90e2c0bfdc87ec6b5a2fcfe
1 /*
2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 typedef struct {
38 IOleUndoManager IOleUndoManager_iface;
40 LONG ref;
41 } UndoManager;
43 static inline UndoManager *impl_from_IOleUndoManager(IOleUndoManager *iface)
45 return CONTAINING_RECORD(iface, UndoManager, IOleUndoManager_iface);
48 static HRESULT WINAPI OleUndoManager_QueryInterface(IOleUndoManager *iface, REFIID riid, void **ppv)
50 UndoManager *This = impl_from_IOleUndoManager(iface);
52 if(IsEqualGUID(riid, &IID_IUnknown)) {
53 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
54 *ppv = &This->IOleUndoManager_iface;
55 }else if(IsEqualGUID(riid, &IID_IOleUndoManager)) {
56 TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
57 *ppv = &This->IOleUndoManager_iface;
58 }else {
59 *ppv = NULL;
60 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
61 return E_NOINTERFACE;
64 IUnknown_AddRef((IUnknown*)*ppv);
65 return S_OK;
68 static ULONG WINAPI OleUndoManager_AddRef(IOleUndoManager *iface)
70 UndoManager *This = impl_from_IOleUndoManager(iface);
71 LONG ref = InterlockedIncrement(&This->ref);
73 TRACE("(%p) ref=%d\n", This, ref);
75 return ref;
78 static ULONG WINAPI OleUndoManager_Release(IOleUndoManager *iface)
80 UndoManager *This = impl_from_IOleUndoManager(iface);
81 LONG ref = InterlockedDecrement(&This->ref);
83 TRACE("(%p) ref=%d\n", This, ref);
85 if(!ref)
86 heap_free(This);
88 return ref;
91 static HRESULT WINAPI OleUndoManager_Open(IOleUndoManager *iface, IOleParentUndoUnit *pPUU)
93 UndoManager *This = impl_from_IOleUndoManager(iface);
94 FIXME("(%p)->(%p)\n", This, pPUU);
95 return E_NOTIMPL;
98 static HRESULT WINAPI OleUndoManager_Close(IOleUndoManager *iface, IOleParentUndoUnit *pPUU,
99 BOOL fCommit)
101 UndoManager *This = impl_from_IOleUndoManager(iface);
102 FIXME("(%p)->(%p %x)\n", This, pPUU, fCommit);
103 return E_NOTIMPL;
106 static HRESULT WINAPI OleUndoManager_Add(IOleUndoManager *iface, IOleUndoUnit *pUU)
108 UndoManager *This = impl_from_IOleUndoManager(iface);
109 FIXME("(%p)->(%p)\n", This, pUU);
110 return E_NOTIMPL;
113 static HRESULT WINAPI OleUndoManager_GetOpenParentState(IOleUndoManager *iface, DWORD *pdwState)
115 UndoManager *This = impl_from_IOleUndoManager(iface);
116 FIXME("(%p)->(%p)\n", This, pdwState);
117 return E_NOTIMPL;
120 static HRESULT WINAPI OleUndoManager_DiscardFrom(IOleUndoManager *iface, IOleUndoUnit *pUU)
122 UndoManager *This = impl_from_IOleUndoManager(iface);
123 FIXME("(%p)->(%p)\n", This, pUU);
124 return S_OK;
127 static HRESULT WINAPI OleUndoManager_UndoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
129 UndoManager *This = impl_from_IOleUndoManager(iface);
130 FIXME("(%p)->(%p)\n", This, pUU);
131 return E_NOTIMPL;
134 static HRESULT WINAPI OleUndoManager_RedoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
136 UndoManager *This = impl_from_IOleUndoManager(iface);
137 FIXME("(%p)->(%p)\n", This, pUU);
138 return E_NOTIMPL;
141 static HRESULT WINAPI OleUndoManager_EnumUndoable(IOleUndoManager *iface,
142 IEnumOleUndoUnits **ppEnum)
144 UndoManager *This = impl_from_IOleUndoManager(iface);
145 FIXME("(%p)->(%p)\n", This, ppEnum);
146 return E_NOTIMPL;
149 static HRESULT WINAPI OleUndoManager_EnumRedoable(IOleUndoManager *iface,
150 IEnumOleUndoUnits **ppEnum)
152 UndoManager *This = impl_from_IOleUndoManager(iface);
153 FIXME("(%p)->(%p)\n", This, ppEnum);
154 return E_NOTIMPL;
157 static HRESULT WINAPI OleUndoManager_GetLastUndoDescription(IOleUndoManager *iface, BSTR *pBstr)
159 UndoManager *This = impl_from_IOleUndoManager(iface);
160 FIXME("(%p)->(%p)\n", This, pBstr);
161 return E_NOTIMPL;
164 static HRESULT WINAPI OleUndoManager_GetLastRedoDescription(IOleUndoManager *iface, BSTR *pBstr)
166 UndoManager *This = impl_from_IOleUndoManager(iface);
167 FIXME("(%p)->(%p)\n", This, pBstr);
168 return E_NOTIMPL;
171 static HRESULT WINAPI OleUndoManager_Enable(IOleUndoManager *iface, BOOL fEnable)
173 UndoManager *This = impl_from_IOleUndoManager(iface);
174 FIXME("(%p)->(%x)\n", This, fEnable);
175 return E_NOTIMPL;
178 static const IOleUndoManagerVtbl OleUndoManagerVtbl = {
179 OleUndoManager_QueryInterface,
180 OleUndoManager_AddRef,
181 OleUndoManager_Release,
182 OleUndoManager_Open,
183 OleUndoManager_Close,
184 OleUndoManager_Add,
185 OleUndoManager_GetOpenParentState,
186 OleUndoManager_DiscardFrom,
187 OleUndoManager_UndoTo,
188 OleUndoManager_RedoTo,
189 OleUndoManager_EnumUndoable,
190 OleUndoManager_EnumRedoable,
191 OleUndoManager_GetLastUndoDescription,
192 OleUndoManager_GetLastRedoDescription,
193 OleUndoManager_Enable
196 static IOleUndoManager *create_undomgr(void)
198 UndoManager *ret = heap_alloc(sizeof(UndoManager));
200 if (!ret) return NULL;
202 ret->IOleUndoManager_iface.lpVtbl = &OleUndoManagerVtbl;
203 ret->ref = 1;
205 return &ret->IOleUndoManager_iface;
208 typedef struct {
209 IHTMLEditServices IHTMLEditServices_iface;
210 LONG ref;
211 } editsvcs;
213 static inline editsvcs *impl_from_IHTMLEditServices(IHTMLEditServices *iface)
215 return CONTAINING_RECORD(iface, editsvcs, IHTMLEditServices_iface);
218 static HRESULT WINAPI editsvcs_QueryInterface(IHTMLEditServices *iface, REFIID riid, void **ppv)
220 editsvcs *This = impl_from_IHTMLEditServices(iface);
222 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
224 if(IsEqualGUID(riid, &IID_IUnknown)) {
225 *ppv = &This->IHTMLEditServices_iface;
226 } else if(IsEqualGUID(riid, &IID_IHTMLEditServices)) {
227 *ppv = &This->IHTMLEditServices_iface;
228 } else {
229 *ppv = NULL;
230 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
231 return E_NOINTERFACE;
234 IUnknown_AddRef((IUnknown*)*ppv);
235 return S_OK;
238 static ULONG WINAPI editsvcs_AddRef(IHTMLEditServices *iface)
240 editsvcs *This = impl_from_IHTMLEditServices(iface);
241 LONG ref = InterlockedIncrement(&This->ref);
243 TRACE("(%p) ref=%d\n", This, ref);
244 return ref;
247 static ULONG WINAPI editsvcs_Release(IHTMLEditServices *iface)
249 editsvcs *This = impl_from_IHTMLEditServices(iface);
250 LONG ref = InterlockedDecrement(&This->ref);
252 TRACE("(%p) ref=%d\n", This, ref);
254 if(!ref)
255 heap_free(This);
257 return ref;
260 static HRESULT WINAPI editsvcs_AddDesigner(IHTMLEditServices *iface,
261 IHTMLEditDesigner *pIDesigner)
263 editsvcs *This = impl_from_IHTMLEditServices(iface);
264 FIXME("(%p)->(%p)\n", This, pIDesigner);
265 return E_NOTIMPL;
268 static HRESULT WINAPI editsvcs_RemoveDesigner(IHTMLEditServices *iface,
269 IHTMLEditDesigner *pIDesigner)
271 editsvcs *This = impl_from_IHTMLEditServices(iface);
272 FIXME("(%p)->(%p)\n", This, pIDesigner);
273 return E_NOTIMPL;
276 static HRESULT WINAPI editsvcs_GetSelectionServices(IHTMLEditServices *iface,
277 IMarkupContainer *pIContainer, ISelectionServices **ppSelSvc)
279 editsvcs *This = impl_from_IHTMLEditServices(iface);
280 FIXME("(%p)->(%p,%p)\n", This, pIContainer, ppSelSvc);
281 return E_NOTIMPL;
284 static HRESULT WINAPI editsvcs_MoveToSelectionAnchor(IHTMLEditServices *iface,
285 IMarkupPointer *pIStartAnchor)
287 editsvcs *This = impl_from_IHTMLEditServices(iface);
288 FIXME("(%p)->(%p)\n", This, pIStartAnchor);
289 return E_NOTIMPL;
292 static HRESULT WINAPI editsvcs_MoveToSelectionEnd(IHTMLEditServices *iface,
293 IMarkupPointer *pIEndAnchor)
295 editsvcs *This = impl_from_IHTMLEditServices(iface);
296 FIXME("(%p)->(%p)\n", This, pIEndAnchor);
297 return E_NOTIMPL;
300 static HRESULT WINAPI editsvcs_SelectRange(IHTMLEditServices *iface,
301 IMarkupPointer *pStart, IMarkupPointer *pEnd, SELECTION_TYPE eType)
303 editsvcs *This = impl_from_IHTMLEditServices(iface);
304 FIXME("(%p)->(%p,%p,%#x)\n", This, pStart, pEnd, eType);
305 return E_NOTIMPL;
308 static const IHTMLEditServicesVtbl editsvcsVtbl = {
309 editsvcs_QueryInterface,
310 editsvcs_AddRef,
311 editsvcs_Release,
312 editsvcs_AddDesigner,
313 editsvcs_RemoveDesigner,
314 editsvcs_GetSelectionServices,
315 editsvcs_MoveToSelectionAnchor,
316 editsvcs_MoveToSelectionEnd,
317 editsvcs_SelectRange,
320 static IHTMLEditServices *create_editsvcs(void)
322 editsvcs *ret = heap_alloc(sizeof(*ret));
324 if (ret) {
325 ret->IHTMLEditServices_iface.lpVtbl = &editsvcsVtbl;
326 ret->ref = 1;
327 return &ret->IHTMLEditServices_iface;
330 return NULL;
333 /**********************************************************
334 * IServiceProvider implementation
337 static inline HTMLDocument *impl_from_IServiceProvider(IServiceProvider *iface)
339 return CONTAINING_RECORD(iface, HTMLDocument, IServiceProvider_iface);
342 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
344 HTMLDocument *This = impl_from_IServiceProvider(iface);
345 return htmldoc_query_interface(This, riid, ppv);
348 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
350 HTMLDocument *This = impl_from_IServiceProvider(iface);
351 return htmldoc_addref(This);
354 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
356 HTMLDocument *This = impl_from_IServiceProvider(iface);
357 return htmldoc_release(This);
360 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
361 REFIID riid, void **ppv)
363 HTMLDocument *This = impl_from_IServiceProvider(iface);
365 if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
366 FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
367 return E_NOINTERFACE;
370 if(IsEqualGUID(&SID_SOleUndoManager, guidService)) {
371 TRACE("SID_SOleUndoManager\n");
373 if(!This->doc_obj->undomgr)
374 This->doc_obj->undomgr = create_undomgr();
376 if (!This->doc_obj->undomgr)
377 return E_OUTOFMEMORY;
379 return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
382 if(IsEqualGUID(&SID_SContainerDispatch, guidService)) {
383 TRACE("SID_SContainerDispatch\n");
384 return IHTMLDocument2_QueryInterface(&This->IHTMLDocument2_iface, riid, ppv);
387 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
388 TRACE("IID_IWindowForBindingUI\n");
389 return IWindowForBindingUI_QueryInterface(&This->doc_obj->IWindowForBindingUI_iface, riid, ppv);
392 if(IsEqualGUID(&SID_SHTMLEditServices, guidService)) {
393 TRACE("SID_SHTMLEditServices\n");
395 if(!This->doc_obj->editsvcs)
396 This->doc_obj->editsvcs = create_editsvcs();
398 if (!This->doc_obj->editsvcs)
399 return E_OUTOFMEMORY;
401 return IHTMLEditServices_QueryInterface(This->doc_obj->editsvcs, riid, ppv);
404 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
406 if(This->doc_obj->client) {
407 HRESULT hres;
409 hres = do_query_service((IUnknown*)This->doc_obj->client, guidService, riid, ppv);
410 if(SUCCEEDED(hres))
411 return hres;
414 FIXME("unknown service %s\n", debugstr_guid(guidService));
415 return E_NOINTERFACE;
418 static const IServiceProviderVtbl ServiceProviderVtbl = {
419 ServiceProvider_QueryInterface,
420 ServiceProvider_AddRef,
421 ServiceProvider_Release,
422 ServiceProvider_QueryService
425 void HTMLDocument_Service_Init(HTMLDocument *This)
427 This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;