mshtml: Use wide-char string literals.
[wine.git] / dlls / mshtml / service.c
blobd90af3e658c58b1912461f2445b67c5f47f9a04e
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 <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 IOleUndoManager IOleUndoManager_iface;
38 LONG ref;
39 } UndoManager;
41 static inline UndoManager *impl_from_IOleUndoManager(IOleUndoManager *iface)
43 return CONTAINING_RECORD(iface, UndoManager, IOleUndoManager_iface);
46 static HRESULT WINAPI OleUndoManager_QueryInterface(IOleUndoManager *iface, REFIID riid, void **ppv)
48 UndoManager *This = impl_from_IOleUndoManager(iface);
50 if(IsEqualGUID(riid, &IID_IUnknown)) {
51 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
52 *ppv = &This->IOleUndoManager_iface;
53 }else if(IsEqualGUID(riid, &IID_IOleUndoManager)) {
54 TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
55 *ppv = &This->IOleUndoManager_iface;
56 }else {
57 *ppv = NULL;
58 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
59 return E_NOINTERFACE;
62 IUnknown_AddRef((IUnknown*)*ppv);
63 return S_OK;
66 static ULONG WINAPI OleUndoManager_AddRef(IOleUndoManager *iface)
68 UndoManager *This = impl_from_IOleUndoManager(iface);
69 LONG ref = InterlockedIncrement(&This->ref);
71 TRACE("(%p) ref=%d\n", This, ref);
73 return ref;
76 static ULONG WINAPI OleUndoManager_Release(IOleUndoManager *iface)
78 UndoManager *This = impl_from_IOleUndoManager(iface);
79 LONG ref = InterlockedDecrement(&This->ref);
81 TRACE("(%p) ref=%d\n", This, ref);
83 if(!ref)
84 heap_free(This);
86 return ref;
89 static HRESULT WINAPI OleUndoManager_Open(IOleUndoManager *iface, IOleParentUndoUnit *pPUU)
91 UndoManager *This = impl_from_IOleUndoManager(iface);
92 FIXME("(%p)->(%p)\n", This, pPUU);
93 return E_NOTIMPL;
96 static HRESULT WINAPI OleUndoManager_Close(IOleUndoManager *iface, IOleParentUndoUnit *pPUU,
97 BOOL fCommit)
99 UndoManager *This = impl_from_IOleUndoManager(iface);
100 FIXME("(%p)->(%p %x)\n", This, pPUU, fCommit);
101 return E_NOTIMPL;
104 static HRESULT WINAPI OleUndoManager_Add(IOleUndoManager *iface, IOleUndoUnit *pUU)
106 UndoManager *This = impl_from_IOleUndoManager(iface);
107 FIXME("(%p)->(%p)\n", This, pUU);
108 return E_NOTIMPL;
111 static HRESULT WINAPI OleUndoManager_GetOpenParentState(IOleUndoManager *iface, DWORD *pdwState)
113 UndoManager *This = impl_from_IOleUndoManager(iface);
114 FIXME("(%p)->(%p)\n", This, pdwState);
115 return E_NOTIMPL;
118 static HRESULT WINAPI OleUndoManager_DiscardFrom(IOleUndoManager *iface, IOleUndoUnit *pUU)
120 UndoManager *This = impl_from_IOleUndoManager(iface);
121 FIXME("(%p)->(%p)\n", This, pUU);
122 return S_OK;
125 static HRESULT WINAPI OleUndoManager_UndoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
127 UndoManager *This = impl_from_IOleUndoManager(iface);
128 FIXME("(%p)->(%p)\n", This, pUU);
129 return E_NOTIMPL;
132 static HRESULT WINAPI OleUndoManager_RedoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
134 UndoManager *This = impl_from_IOleUndoManager(iface);
135 FIXME("(%p)->(%p)\n", This, pUU);
136 return E_NOTIMPL;
139 static HRESULT WINAPI OleUndoManager_EnumUndoable(IOleUndoManager *iface,
140 IEnumOleUndoUnits **ppEnum)
142 UndoManager *This = impl_from_IOleUndoManager(iface);
143 FIXME("(%p)->(%p)\n", This, ppEnum);
144 return E_NOTIMPL;
147 static HRESULT WINAPI OleUndoManager_EnumRedoable(IOleUndoManager *iface,
148 IEnumOleUndoUnits **ppEnum)
150 UndoManager *This = impl_from_IOleUndoManager(iface);
151 FIXME("(%p)->(%p)\n", This, ppEnum);
152 return E_NOTIMPL;
155 static HRESULT WINAPI OleUndoManager_GetLastUndoDescription(IOleUndoManager *iface, BSTR *pBstr)
157 UndoManager *This = impl_from_IOleUndoManager(iface);
158 FIXME("(%p)->(%p)\n", This, pBstr);
159 return E_NOTIMPL;
162 static HRESULT WINAPI OleUndoManager_GetLastRedoDescription(IOleUndoManager *iface, BSTR *pBstr)
164 UndoManager *This = impl_from_IOleUndoManager(iface);
165 FIXME("(%p)->(%p)\n", This, pBstr);
166 return E_NOTIMPL;
169 static HRESULT WINAPI OleUndoManager_Enable(IOleUndoManager *iface, BOOL fEnable)
171 UndoManager *This = impl_from_IOleUndoManager(iface);
172 FIXME("(%p)->(%x)\n", This, fEnable);
173 return E_NOTIMPL;
176 static const IOleUndoManagerVtbl OleUndoManagerVtbl = {
177 OleUndoManager_QueryInterface,
178 OleUndoManager_AddRef,
179 OleUndoManager_Release,
180 OleUndoManager_Open,
181 OleUndoManager_Close,
182 OleUndoManager_Add,
183 OleUndoManager_GetOpenParentState,
184 OleUndoManager_DiscardFrom,
185 OleUndoManager_UndoTo,
186 OleUndoManager_RedoTo,
187 OleUndoManager_EnumUndoable,
188 OleUndoManager_EnumRedoable,
189 OleUndoManager_GetLastUndoDescription,
190 OleUndoManager_GetLastRedoDescription,
191 OleUndoManager_Enable
194 static IOleUndoManager *create_undomgr(void)
196 UndoManager *ret = heap_alloc(sizeof(UndoManager));
198 if (!ret) return NULL;
200 ret->IOleUndoManager_iface.lpVtbl = &OleUndoManagerVtbl;
201 ret->ref = 1;
203 return &ret->IOleUndoManager_iface;
206 typedef struct {
207 IHTMLEditServices IHTMLEditServices_iface;
208 LONG ref;
209 } editsvcs;
211 static inline editsvcs *impl_from_IHTMLEditServices(IHTMLEditServices *iface)
213 return CONTAINING_RECORD(iface, editsvcs, IHTMLEditServices_iface);
216 static HRESULT WINAPI editsvcs_QueryInterface(IHTMLEditServices *iface, REFIID riid, void **ppv)
218 editsvcs *This = impl_from_IHTMLEditServices(iface);
220 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
222 if(IsEqualGUID(riid, &IID_IUnknown)) {
223 *ppv = &This->IHTMLEditServices_iface;
224 } else if(IsEqualGUID(riid, &IID_IHTMLEditServices)) {
225 *ppv = &This->IHTMLEditServices_iface;
226 } else {
227 *ppv = NULL;
228 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
229 return E_NOINTERFACE;
232 IUnknown_AddRef((IUnknown*)*ppv);
233 return S_OK;
236 static ULONG WINAPI editsvcs_AddRef(IHTMLEditServices *iface)
238 editsvcs *This = impl_from_IHTMLEditServices(iface);
239 LONG ref = InterlockedIncrement(&This->ref);
241 TRACE("(%p) ref=%d\n", This, ref);
242 return ref;
245 static ULONG WINAPI editsvcs_Release(IHTMLEditServices *iface)
247 editsvcs *This = impl_from_IHTMLEditServices(iface);
248 LONG ref = InterlockedDecrement(&This->ref);
250 TRACE("(%p) ref=%d\n", This, ref);
252 if(!ref)
253 heap_free(This);
255 return ref;
258 static HRESULT WINAPI editsvcs_AddDesigner(IHTMLEditServices *iface,
259 IHTMLEditDesigner *pIDesigner)
261 editsvcs *This = impl_from_IHTMLEditServices(iface);
262 FIXME("(%p)->(%p)\n", This, pIDesigner);
263 return E_NOTIMPL;
266 static HRESULT WINAPI editsvcs_RemoveDesigner(IHTMLEditServices *iface,
267 IHTMLEditDesigner *pIDesigner)
269 editsvcs *This = impl_from_IHTMLEditServices(iface);
270 FIXME("(%p)->(%p)\n", This, pIDesigner);
271 return E_NOTIMPL;
274 static HRESULT WINAPI editsvcs_GetSelectionServices(IHTMLEditServices *iface,
275 IMarkupContainer *pIContainer, ISelectionServices **ppSelSvc)
277 editsvcs *This = impl_from_IHTMLEditServices(iface);
278 FIXME("(%p)->(%p,%p)\n", This, pIContainer, ppSelSvc);
279 return E_NOTIMPL;
282 static HRESULT WINAPI editsvcs_MoveToSelectionAnchor(IHTMLEditServices *iface,
283 IMarkupPointer *pIStartAnchor)
285 editsvcs *This = impl_from_IHTMLEditServices(iface);
286 FIXME("(%p)->(%p)\n", This, pIStartAnchor);
287 return E_NOTIMPL;
290 static HRESULT WINAPI editsvcs_MoveToSelectionEnd(IHTMLEditServices *iface,
291 IMarkupPointer *pIEndAnchor)
293 editsvcs *This = impl_from_IHTMLEditServices(iface);
294 FIXME("(%p)->(%p)\n", This, pIEndAnchor);
295 return E_NOTIMPL;
298 static HRESULT WINAPI editsvcs_SelectRange(IHTMLEditServices *iface,
299 IMarkupPointer *pStart, IMarkupPointer *pEnd, SELECTION_TYPE eType)
301 editsvcs *This = impl_from_IHTMLEditServices(iface);
302 FIXME("(%p)->(%p,%p,%#x)\n", This, pStart, pEnd, eType);
303 return E_NOTIMPL;
306 static const IHTMLEditServicesVtbl editsvcsVtbl = {
307 editsvcs_QueryInterface,
308 editsvcs_AddRef,
309 editsvcs_Release,
310 editsvcs_AddDesigner,
311 editsvcs_RemoveDesigner,
312 editsvcs_GetSelectionServices,
313 editsvcs_MoveToSelectionAnchor,
314 editsvcs_MoveToSelectionEnd,
315 editsvcs_SelectRange,
318 static IHTMLEditServices *create_editsvcs(void)
320 editsvcs *ret = heap_alloc(sizeof(*ret));
322 if (ret) {
323 ret->IHTMLEditServices_iface.lpVtbl = &editsvcsVtbl;
324 ret->ref = 1;
325 return &ret->IHTMLEditServices_iface;
328 return NULL;
331 /**********************************************************
332 * IServiceProvider implementation
335 static inline HTMLDocument *impl_from_IServiceProvider(IServiceProvider *iface)
337 return CONTAINING_RECORD(iface, HTMLDocument, IServiceProvider_iface);
340 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
342 HTMLDocument *This = impl_from_IServiceProvider(iface);
343 return htmldoc_query_interface(This, riid, ppv);
346 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
348 HTMLDocument *This = impl_from_IServiceProvider(iface);
349 return htmldoc_addref(This);
352 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
354 HTMLDocument *This = impl_from_IServiceProvider(iface);
355 return htmldoc_release(This);
358 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
359 REFIID riid, void **ppv)
361 HTMLDocument *This = impl_from_IServiceProvider(iface);
363 if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
364 FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
365 return E_NOINTERFACE;
368 if(IsEqualGUID(&SID_SOleUndoManager, guidService)) {
369 TRACE("SID_SOleUndoManager\n");
371 if(!This->doc_obj->undomgr)
372 This->doc_obj->undomgr = create_undomgr();
374 if (!This->doc_obj->undomgr)
375 return E_OUTOFMEMORY;
377 return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
380 if(IsEqualGUID(&SID_SContainerDispatch, guidService)) {
381 TRACE("SID_SContainerDispatch\n");
382 return IHTMLDocument2_QueryInterface(&This->IHTMLDocument2_iface, riid, ppv);
385 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
386 TRACE("IID_IWindowForBindingUI\n");
387 return IWindowForBindingUI_QueryInterface(&This->doc_obj->IWindowForBindingUI_iface, riid, ppv);
390 if(IsEqualGUID(&SID_SHTMLEditServices, guidService)) {
391 TRACE("SID_SHTMLEditServices\n");
393 if(!This->doc_obj->editsvcs)
394 This->doc_obj->editsvcs = create_editsvcs();
396 if (!This->doc_obj->editsvcs)
397 return E_OUTOFMEMORY;
399 return IHTMLEditServices_QueryInterface(This->doc_obj->editsvcs, riid, ppv);
402 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
404 if(This->doc_obj->client) {
405 HRESULT hres;
407 hres = do_query_service((IUnknown*)This->doc_obj->client, guidService, riid, ppv);
408 if(SUCCEEDED(hres))
409 return hres;
412 FIXME("unknown service %s\n", debugstr_guid(guidService));
413 return E_NOINTERFACE;
416 static const IServiceProviderVtbl ServiceProviderVtbl = {
417 ServiceProvider_QueryInterface,
418 ServiceProvider_AddRef,
419 ServiceProvider_Release,
420 ServiceProvider_QueryService
423 void HTMLDocument_Service_Init(HTMLDocument *This)
425 This->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;