include: Define more wuapi interfaces to avoid undefined forward declarations.
[wine] / dlls / mshtml / service.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 typedef struct {
38     IOleUndoManager IOleUndoManager_iface;
39
40     LONG ref;
41 } UndoManager;
42
43 static inline UndoManager *impl_from_IOleUndoManager(IOleUndoManager *iface)
44 {
45     return CONTAINING_RECORD(iface, UndoManager, IOleUndoManager_iface);
46 }
47
48 static HRESULT WINAPI OleUndoManager_QueryInterface(IOleUndoManager *iface, REFIID riid, void **ppv)
49 {
50     UndoManager *This = impl_from_IOleUndoManager(iface);
51
52     *ppv = NULL;
53
54     if(IsEqualGUID(riid, &IID_IUnknown)) {
55         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
56         *ppv = &This->IOleUndoManager_iface;
57     }else if(IsEqualGUID(riid, &IID_IOleUndoManager)) {
58         TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
59         *ppv = &This->IOleUndoManager_iface;
60     }
61
62
63     FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
64     return E_NOINTERFACE;
65 }
66
67 static ULONG WINAPI OleUndoManager_AddRef(IOleUndoManager *iface)
68 {
69     UndoManager *This = impl_from_IOleUndoManager(iface);
70     LONG ref = InterlockedIncrement(&This->ref);
71
72     TRACE("(%p) ref=%d\n", This, ref);
73
74     return ref;
75 }
76
77 static ULONG WINAPI OleUndoManager_Release(IOleUndoManager *iface)
78 {
79     UndoManager *This = impl_from_IOleUndoManager(iface);
80     LONG ref = InterlockedDecrement(&This->ref);
81
82     TRACE("(%p) ref=%d\n", This, ref);
83
84     if(!ref)
85         heap_free(This);
86
87     return ref;
88 }
89
90 static HRESULT WINAPI OleUndoManager_Open(IOleUndoManager *iface, IOleParentUndoUnit *pPUU)
91 {
92     UndoManager *This = impl_from_IOleUndoManager(iface);
93     FIXME("(%p)->(%p)\n", This, pPUU);
94     return E_NOTIMPL;
95 }
96
97 static HRESULT WINAPI OleUndoManager_Close(IOleUndoManager *iface, IOleParentUndoUnit *pPUU,
98         BOOL fCommit)
99 {
100     UndoManager *This = impl_from_IOleUndoManager(iface);
101     FIXME("(%p)->(%p %x)\n", This, pPUU, fCommit);
102     return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI OleUndoManager_Add(IOleUndoManager *iface, IOleUndoUnit *pUU)
106 {
107     UndoManager *This = impl_from_IOleUndoManager(iface);
108     FIXME("(%p)->(%p)\n", This, pUU);
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI OleUndoManager_GetOpenParentState(IOleUndoManager *iface, DWORD *pdwState)
113 {
114     UndoManager *This = impl_from_IOleUndoManager(iface);
115     FIXME("(%p)->(%p)\n", This, pdwState);
116     return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI OleUndoManager_DiscardFrom(IOleUndoManager *iface, IOleUndoUnit *pUU)
120 {
121     UndoManager *This = impl_from_IOleUndoManager(iface);
122     FIXME("(%p)->(%p)\n", This, pUU);
123     return S_OK;
124 }
125
126 static HRESULT WINAPI OleUndoManager_UndoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
127 {
128     UndoManager *This = impl_from_IOleUndoManager(iface);
129     FIXME("(%p)->(%p)\n", This, pUU);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI OleUndoManager_RedoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
134 {
135     UndoManager *This = impl_from_IOleUndoManager(iface);
136     FIXME("(%p)->(%p)\n", This, pUU);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI OleUndoManager_EnumUndoable(IOleUndoManager *iface,
141         IEnumOleUndoUnits **ppEnum)
142 {
143     UndoManager *This = impl_from_IOleUndoManager(iface);
144     FIXME("(%p)->(%p)\n", This, ppEnum);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI OleUndoManager_EnumRedoable(IOleUndoManager *iface,
149         IEnumOleUndoUnits **ppEnum)
150 {
151     UndoManager *This = impl_from_IOleUndoManager(iface);
152     FIXME("(%p)->(%p)\n", This, ppEnum);
153     return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI OleUndoManager_GetLastUndoDescription(IOleUndoManager *iface, BSTR *pBstr)
157 {
158     UndoManager *This = impl_from_IOleUndoManager(iface);
159     FIXME("(%p)->(%p)\n", This, pBstr);
160     return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI OleUndoManager_GetLastRedoDescription(IOleUndoManager *iface, BSTR *pBstr)
164 {
165     UndoManager *This = impl_from_IOleUndoManager(iface);
166     FIXME("(%p)->(%p)\n", This, pBstr);
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI OleUndoManager_Enable(IOleUndoManager *iface, BOOL fEnable)
171 {
172     UndoManager *This = impl_from_IOleUndoManager(iface);
173     FIXME("(%p)->(%x)\n", This, fEnable);
174     return E_NOTIMPL;
175 }
176
177 static const IOleUndoManagerVtbl OleUndoManagerVtbl = {
178     OleUndoManager_QueryInterface,
179     OleUndoManager_AddRef,
180     OleUndoManager_Release,
181     OleUndoManager_Open,
182     OleUndoManager_Close,
183     OleUndoManager_Add,
184     OleUndoManager_GetOpenParentState,
185     OleUndoManager_DiscardFrom,
186     OleUndoManager_UndoTo,
187     OleUndoManager_RedoTo,
188     OleUndoManager_EnumUndoable,
189     OleUndoManager_EnumRedoable,
190     OleUndoManager_GetLastUndoDescription,
191     OleUndoManager_GetLastRedoDescription,
192     OleUndoManager_Enable
193 };
194
195 static IOleUndoManager *create_undomgr(void)
196 {
197     UndoManager *ret = heap_alloc(sizeof(UndoManager));
198
199     ret->IOleUndoManager_iface.lpVtbl = &OleUndoManagerVtbl;
200     ret->ref = 1;
201
202     return &ret->IOleUndoManager_iface;
203 }
204
205 /**********************************************************
206  * IServiceProvider implementation
207  */
208
209 #define SERVPROV_THIS(iface) DEFINE_THIS(HTMLDocument, ServiceProvider, iface)
210
211 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
212 {
213     HTMLDocument *This = SERVPROV_THIS(iface);
214     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
215 }
216
217 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
218 {
219     HTMLDocument *This = SERVPROV_THIS(iface);
220     return IHTMLDocument2_AddRef(HTMLDOC(This));
221 }
222
223 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
224 {
225     HTMLDocument *This = SERVPROV_THIS(iface);
226     return IHTMLDocument_Release(HTMLDOC(This));
227 }
228
229 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
230         REFIID riid, void **ppv)
231 {
232     HTMLDocument *This = SERVPROV_THIS(iface);
233     
234     if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
235         FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
236         return E_NOINTERFACE;
237     }
238
239     if(IsEqualGUID(&SID_SOleUndoManager, guidService)) {
240         TRACE("SID_SOleUndoManager\n");
241
242         if(!This->doc_obj->undomgr)
243             This->doc_obj->undomgr = create_undomgr();
244
245         return IOleUndoManager_QueryInterface(This->doc_obj->undomgr, riid, ppv);
246     }
247
248     if(This->doc_obj->client) {
249         IServiceProvider *sp;
250         HRESULT hres;
251
252         hres = IOleClientSite_QueryInterface(This->doc_obj->client,
253                 &IID_IServiceProvider, (void**)&sp);
254         if(SUCCEEDED(hres)) {
255             hres = IServiceProvider_QueryService(sp, guidService, riid, ppv);
256             IServiceProvider_Release(sp);
257
258             if(SUCCEEDED(hres))
259                 return hres;
260         }
261     }
262
263     FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
264     
265     return E_NOINTERFACE;
266 }
267
268 static const IServiceProviderVtbl ServiceProviderVtbl = {
269     ServiceProvider_QueryInterface,
270     ServiceProvider_AddRef,
271     ServiceProvider_Release,
272     ServiceProvider_QueryService
273 };
274
275 void HTMLDocument_Service_Init(HTMLDocument *This)
276 {
277     This->lpServiceProviderVtbl = &ServiceProviderVtbl;
278 }