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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
36 IOleUndoManager IOleUndoManager_iface
;
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
;
58 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
62 IUnknown_AddRef((IUnknown
*)*ppv
);
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=%ld\n", This
, 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=%ld\n", This
, 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
);
96 static HRESULT WINAPI
OleUndoManager_Close(IOleUndoManager
*iface
, IOleParentUndoUnit
*pPUU
,
99 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
100 FIXME("(%p)->(%p %x)\n", This
, pPUU
, fCommit
);
104 static HRESULT WINAPI
OleUndoManager_Add(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
106 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
107 FIXME("(%p)->(%p)\n", This
, pUU
);
111 static HRESULT WINAPI
OleUndoManager_GetOpenParentState(IOleUndoManager
*iface
, DWORD
*pdwState
)
113 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
114 FIXME("(%p)->(%p)\n", This
, pdwState
);
118 static HRESULT WINAPI
OleUndoManager_DiscardFrom(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
120 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
121 FIXME("(%p)->(%p)\n", This
, pUU
);
125 static HRESULT WINAPI
OleUndoManager_UndoTo(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
127 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
128 FIXME("(%p)->(%p)\n", This
, pUU
);
132 static HRESULT WINAPI
OleUndoManager_RedoTo(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
134 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
135 FIXME("(%p)->(%p)\n", This
, pUU
);
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
);
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
);
155 static HRESULT WINAPI
OleUndoManager_GetLastUndoDescription(IOleUndoManager
*iface
, BSTR
*pBstr
)
157 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
158 FIXME("(%p)->(%p)\n", This
, pBstr
);
162 static HRESULT WINAPI
OleUndoManager_GetLastRedoDescription(IOleUndoManager
*iface
, BSTR
*pBstr
)
164 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
165 FIXME("(%p)->(%p)\n", This
, pBstr
);
169 static HRESULT WINAPI
OleUndoManager_Enable(IOleUndoManager
*iface
, BOOL fEnable
)
171 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
172 FIXME("(%p)->(%x)\n", This
, fEnable
);
176 static const IOleUndoManagerVtbl OleUndoManagerVtbl
= {
177 OleUndoManager_QueryInterface
,
178 OleUndoManager_AddRef
,
179 OleUndoManager_Release
,
181 OleUndoManager_Close
,
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
;
203 return &ret
->IOleUndoManager_iface
;
207 IHTMLEditServices IHTMLEditServices_iface
;
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
;
228 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
229 return E_NOINTERFACE
;
232 IUnknown_AddRef((IUnknown
*)*ppv
);
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=%ld\n", This
, 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=%ld\n", This
, 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
);
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
);
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
);
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
);
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
);
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
);
306 static const IHTMLEditServicesVtbl editsvcsVtbl
= {
307 editsvcs_QueryInterface
,
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
));
323 ret
->IHTMLEditServices_iface
.lpVtbl
= &editsvcsVtbl
;
325 return &ret
->IHTMLEditServices_iface
;
331 /**********************************************************
332 * IServiceProvider implementation
335 static inline HTMLDocumentNode
*HTMLDocumentNode_from_IServiceProvider(IServiceProvider
*iface
)
337 return CONTAINING_RECORD(iface
, HTMLDocumentNode
, IServiceProvider_iface
);
340 static HRESULT WINAPI
DocNodeServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
342 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IServiceProvider(iface
);
343 return IHTMLDOMNode_QueryInterface(&This
->node
.IHTMLDOMNode_iface
, riid
, ppv
);
346 static ULONG WINAPI
DocNodeServiceProvider_AddRef(IServiceProvider
*iface
)
348 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IServiceProvider(iface
);
349 return IHTMLDOMNode_AddRef(&This
->node
.IHTMLDOMNode_iface
);
352 static ULONG WINAPI
DocNodeServiceProvider_Release(IServiceProvider
*iface
)
354 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IServiceProvider(iface
);
355 return IHTMLDOMNode_Release(&This
->node
.IHTMLDOMNode_iface
);
358 static HRESULT WINAPI
DocNodeServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
359 REFIID riid
, void **ppv
)
361 HTMLDocumentNode
*This
= HTMLDocumentNode_from_IServiceProvider(iface
);
363 if(IsEqualGUID(&SID_SContainerDispatch
, guidService
)) {
364 TRACE("SID_SContainerDispatch\n");
365 return IHTMLDocument2_QueryInterface(&This
->IHTMLDocument2_iface
, riid
, ppv
);
368 return IServiceProvider_QueryService(&This
->doc_obj
->IServiceProvider_iface
, guidService
, riid
, ppv
);
371 static const IServiceProviderVtbl DocNodeServiceProviderVtbl
= {
372 DocNodeServiceProvider_QueryInterface
,
373 DocNodeServiceProvider_AddRef
,
374 DocNodeServiceProvider_Release
,
375 DocNodeServiceProvider_QueryService
378 static inline HTMLDocumentObj
*HTMLDocumentObj_from_IServiceProvider(IServiceProvider
*iface
)
380 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IServiceProvider_iface
);
383 static HRESULT WINAPI
DocObjServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
385 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IServiceProvider(iface
);
386 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
389 static ULONG WINAPI
DocObjServiceProvider_AddRef(IServiceProvider
*iface
)
391 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IServiceProvider(iface
);
392 return IUnknown_AddRef(This
->outer_unk
);
395 static ULONG WINAPI
DocObjServiceProvider_Release(IServiceProvider
*iface
)
397 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IServiceProvider(iface
);
398 return IUnknown_Release(This
->outer_unk
);
401 static HRESULT WINAPI
DocObjServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
402 REFIID riid
, void **ppv
)
404 HTMLDocumentObj
*This
= HTMLDocumentObj_from_IServiceProvider(iface
);
406 if(IsEqualGUID(&CLSID_CMarkup
, guidService
)) {
407 FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This
, debugstr_guid(riid
), ppv
);
408 return E_NOINTERFACE
;
411 if(IsEqualGUID(&SID_SOleUndoManager
, guidService
)) {
412 TRACE("SID_SOleUndoManager\n");
415 This
->undomgr
= create_undomgr();
418 return E_OUTOFMEMORY
;
420 return IOleUndoManager_QueryInterface(This
->undomgr
, riid
, ppv
);
423 if(IsEqualGUID(&SID_SContainerDispatch
, guidService
)) {
424 TRACE("SID_SContainerDispatch\n");
425 return IHTMLDocument2_QueryInterface(&This
->IHTMLDocument2_iface
, riid
, ppv
);
428 if(IsEqualGUID(&IID_IWindowForBindingUI
, guidService
)) {
429 TRACE("IID_IWindowForBindingUI\n");
430 return IWindowForBindingUI_QueryInterface(&This
->IWindowForBindingUI_iface
, riid
, ppv
);
433 if(IsEqualGUID(&SID_SHTMLEditServices
, guidService
)) {
434 TRACE("SID_SHTMLEditServices\n");
437 This
->editsvcs
= create_editsvcs();
440 return E_OUTOFMEMORY
;
442 return IHTMLEditServices_QueryInterface(This
->editsvcs
, riid
, ppv
);
445 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
450 hres
= do_query_service((IUnknown
*)This
->client
, guidService
, riid
, ppv
);
455 FIXME("unknown service %s\n", debugstr_guid(guidService
));
456 return E_NOINTERFACE
;
459 static const IServiceProviderVtbl DocObjServiceProviderVtbl
= {
460 DocObjServiceProvider_QueryInterface
,
461 DocObjServiceProvider_AddRef
,
462 DocObjServiceProvider_Release
,
463 DocObjServiceProvider_QueryService
466 void HTMLDocumentNode_Service_Init(HTMLDocumentNode
*This
)
468 This
->IServiceProvider_iface
.lpVtbl
= &DocNodeServiceProviderVtbl
;
471 void HTMLDocumentObj_Service_Init(HTMLDocumentObj
*This
)
473 This
->IServiceProvider_iface
.lpVtbl
= &DocObjServiceProviderVtbl
;