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
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 IOleUndoManager IOleUndoManager_iface
;
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
;
60 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
64 IUnknown_AddRef((IUnknown
*)*ppv
);
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
);
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
);
91 static HRESULT WINAPI
OleUndoManager_Open(IOleUndoManager
*iface
, IOleParentUndoUnit
*pPUU
)
93 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
94 FIXME("(%p)->(%p)\n", This
, pPUU
);
98 static HRESULT WINAPI
OleUndoManager_Close(IOleUndoManager
*iface
, IOleParentUndoUnit
*pPUU
,
101 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
102 FIXME("(%p)->(%p %x)\n", This
, pPUU
, fCommit
);
106 static HRESULT WINAPI
OleUndoManager_Add(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
108 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
109 FIXME("(%p)->(%p)\n", This
, pUU
);
113 static HRESULT WINAPI
OleUndoManager_GetOpenParentState(IOleUndoManager
*iface
, DWORD
*pdwState
)
115 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
116 FIXME("(%p)->(%p)\n", This
, pdwState
);
120 static HRESULT WINAPI
OleUndoManager_DiscardFrom(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
122 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
123 FIXME("(%p)->(%p)\n", This
, pUU
);
127 static HRESULT WINAPI
OleUndoManager_UndoTo(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
129 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
130 FIXME("(%p)->(%p)\n", This
, pUU
);
134 static HRESULT WINAPI
OleUndoManager_RedoTo(IOleUndoManager
*iface
, IOleUndoUnit
*pUU
)
136 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
137 FIXME("(%p)->(%p)\n", This
, pUU
);
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
);
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
);
157 static HRESULT WINAPI
OleUndoManager_GetLastUndoDescription(IOleUndoManager
*iface
, BSTR
*pBstr
)
159 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
160 FIXME("(%p)->(%p)\n", This
, pBstr
);
164 static HRESULT WINAPI
OleUndoManager_GetLastRedoDescription(IOleUndoManager
*iface
, BSTR
*pBstr
)
166 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
167 FIXME("(%p)->(%p)\n", This
, pBstr
);
171 static HRESULT WINAPI
OleUndoManager_Enable(IOleUndoManager
*iface
, BOOL fEnable
)
173 UndoManager
*This
= impl_from_IOleUndoManager(iface
);
174 FIXME("(%p)->(%x)\n", This
, fEnable
);
178 static const IOleUndoManagerVtbl OleUndoManagerVtbl
= {
179 OleUndoManager_QueryInterface
,
180 OleUndoManager_AddRef
,
181 OleUndoManager_Release
,
183 OleUndoManager_Close
,
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 ret
->IOleUndoManager_iface
.lpVtbl
= &OleUndoManagerVtbl
;
203 return &ret
->IOleUndoManager_iface
;
206 /**********************************************************
207 * IServiceProvider implementation
210 static inline HTMLDocument
*impl_from_IServiceProvider(IServiceProvider
*iface
)
212 return CONTAINING_RECORD(iface
, HTMLDocument
, IServiceProvider_iface
);
215 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
217 HTMLDocument
*This
= impl_from_IServiceProvider(iface
);
218 return htmldoc_query_interface(This
, riid
, ppv
);
221 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
223 HTMLDocument
*This
= impl_from_IServiceProvider(iface
);
224 return htmldoc_addref(This
);
227 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
229 HTMLDocument
*This
= impl_from_IServiceProvider(iface
);
230 return htmldoc_release(This
);
233 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID guidService
,
234 REFIID riid
, void **ppv
)
236 HTMLDocument
*This
= impl_from_IServiceProvider(iface
);
238 if(IsEqualGUID(&CLSID_CMarkup
, guidService
)) {
239 FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This
, debugstr_guid(riid
), ppv
);
240 return E_NOINTERFACE
;
243 if(IsEqualGUID(&SID_SOleUndoManager
, guidService
)) {
244 TRACE("SID_SOleUndoManager\n");
246 if(!This
->doc_obj
->undomgr
)
247 This
->doc_obj
->undomgr
= create_undomgr();
249 return IOleUndoManager_QueryInterface(This
->doc_obj
->undomgr
, riid
, ppv
);
252 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
254 if(This
->doc_obj
->client
) {
255 IServiceProvider
*sp
;
258 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
,
259 &IID_IServiceProvider
, (void**)&sp
);
260 if(SUCCEEDED(hres
)) {
261 hres
= IServiceProvider_QueryService(sp
, guidService
, riid
, ppv
);
262 IServiceProvider_Release(sp
);
269 FIXME("unknown service %s\n", debugstr_guid(guidService
));
270 return E_NOINTERFACE
;
273 static const IServiceProviderVtbl ServiceProviderVtbl
= {
274 ServiceProvider_QueryInterface
,
275 ServiceProvider_AddRef
,
276 ServiceProvider_Release
,
277 ServiceProvider_QueryService
280 void HTMLDocument_Service_Init(HTMLDocument
*This
)
282 This
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;