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 #define SERVPROV_THIS(iface) DEFINE_THIS(HTMLDocument, ServiceProvider, iface)
212 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
214 HTMLDocument *This = SERVPROV_THIS(iface);
215 return htmldoc_query_interface(This, riid, ppv);
218 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
220 HTMLDocument *This = SERVPROV_THIS(iface);
221 return htmldoc_addref(This);
224 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
226 HTMLDocument *This = SERVPROV_THIS(iface);
227 return htmldoc_release(This);
230 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
231 REFIID riid, void **ppv)
233 HTMLDocument *This = SERVPROV_THIS(iface);
235 if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
236 FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
237 return E_NOINTERFACE;
240 if(IsEqualGUID(&SID_SOleUndoManager, guidService)) {
241 TRACE("SID_SOleUndoManager\n");
243 if(!This->doc_obj->undomgr)
244 This->doc_obj->undomgr = create_undomgr();
246 return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
249 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
251 if(This->doc_obj->client) {
252 IServiceProvider *sp;
255 hres = IOleClientSite_QueryInterface(This->doc_obj->client,
256 &IID_IServiceProvider, (void**)&sp);
257 if(SUCCEEDED(hres)) {
258 hres = IServiceProvider_QueryService(sp, guidService, riid, ppv);
259 IServiceProvider_Release(sp);
266 FIXME("unknown service %s\n", debugstr_guid(guidService));
267 return E_NOINTERFACE;
270 static const IServiceProviderVtbl ServiceProviderVtbl = {
271 ServiceProvider_QueryInterface,
272 ServiceProvider_AddRef,
273 ServiceProvider_Release,
274 ServiceProvider_QueryService
277 void HTMLDocument_Service_Init(HTMLDocument *This)
279 This->lpServiceProviderVtbl = &ServiceProviderVtbl;