mshtml: Update Spanish translation.
[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     const IOleUndoManagerVtbl  *lpOleUndoManagerVtbl;
39
40     LONG ref;
41 } UndoManager;
42
43 #define UNDOMGR(x)  ((IOleUndoManager*)  &(x)->lpOleUndoManagerVtbl)
44
45 #define UNDOMGR_THIS(iface) DEFINE_THIS(UndoManager, OleUndoManager, iface)
46
47 static HRESULT WINAPI OleUndoManager_QueryInterface(IOleUndoManager *iface, REFIID riid, void **ppv)
48 {
49     UndoManager *This = UNDOMGR_THIS(iface);
50
51     *ppv = NULL;
52
53     if(IsEqualGUID(riid, &IID_IUnknown)) {
54         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
55         *ppv = UNDOMGR(This);
56     }else if(IsEqualGUID(riid, &IID_IOleUndoManager)) {
57         TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
58         *ppv = UNDOMGR(This);
59     }
60
61
62     FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
63     return E_NOINTERFACE;
64 }
65
66 static ULONG WINAPI OleUndoManager_AddRef(IOleUndoManager *iface)
67 {
68     UndoManager *This = UNDOMGR_THIS(iface);
69     LONG ref = InterlockedIncrement(&This->ref);
70
71     TRACE("(%p) ref=%d\n", This, ref);
72
73     return ref;
74 }
75
76 static ULONG WINAPI OleUndoManager_Release(IOleUndoManager *iface)
77 {
78     UndoManager *This = UNDOMGR_THIS(iface);
79     LONG ref = InterlockedDecrement(&This->ref);
80
81     TRACE("(%p) ref=%d\n", This, ref);
82
83     if(!ref)
84         heap_free(This);
85
86     return ref;
87 }
88
89 static HRESULT WINAPI OleUndoManager_Open(IOleUndoManager *iface, IOleParentUndoUnit *pPUU)
90 {
91     UndoManager *This = UNDOMGR_THIS(iface);
92     FIXME("(%p)->(%p)\n", This, pPUU);
93     return E_NOTIMPL;
94 }
95
96 static HRESULT WINAPI OleUndoManager_Close(IOleUndoManager *iface, IOleParentUndoUnit *pPUU,
97         BOOL fCommit)
98 {
99     UndoManager *This = UNDOMGR_THIS(iface);
100     FIXME("(%p)->(%p %x)\n", This, pPUU, fCommit);
101     return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI OleUndoManager_Add(IOleUndoManager *iface, IOleUndoUnit *pUU)
105 {
106     UndoManager *This = UNDOMGR_THIS(iface);
107     FIXME("(%p)->(%p)\n", This, pUU);
108     return E_NOTIMPL;
109 }
110
111 static HRESULT WINAPI OleUndoManager_GetOpenParentState(IOleUndoManager *iface, DWORD *pdwState)
112 {
113     UndoManager *This = UNDOMGR_THIS(iface);
114     FIXME("(%p)->(%p)\n", This, pdwState);
115     return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI OleUndoManager_DiscardFrom(IOleUndoManager *iface, IOleUndoUnit *pUU)
119 {
120     UndoManager *This = UNDOMGR_THIS(iface);
121     FIXME("(%p)->(%p)\n", This, pUU);
122     return S_OK;
123 }
124
125 static HRESULT WINAPI OleUndoManager_UndoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
126 {
127     UndoManager *This = UNDOMGR_THIS(iface);
128     FIXME("(%p)->(%p)\n", This, pUU);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI OleUndoManager_RedoTo(IOleUndoManager *iface, IOleUndoUnit *pUU)
133 {
134     UndoManager *This = UNDOMGR_THIS(iface);
135     FIXME("(%p)->(%p)\n", This, pUU);
136     return E_NOTIMPL;
137 }
138
139 static HRESULT WINAPI OleUndoManager_EnumUndoable(IOleUndoManager *iface,
140         IEnumOleUndoUnits **ppEnum)
141 {
142     UndoManager *This = UNDOMGR_THIS(iface);
143     FIXME("(%p)->(%p)\n", This, ppEnum);
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI OleUndoManager_EnumRedoable(IOleUndoManager *iface,
148         IEnumOleUndoUnits **ppEnum)
149 {
150     UndoManager *This = UNDOMGR_THIS(iface);
151     FIXME("(%p)->(%p)\n", This, ppEnum);
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI OleUndoManager_GetLastUndoDescription(IOleUndoManager *iface, BSTR *pBstr)
156 {
157     UndoManager *This = UNDOMGR_THIS(iface);
158     FIXME("(%p)->(%p)\n", This, pBstr);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI OleUndoManager_GetLastRedoDescription(IOleUndoManager *iface, BSTR *pBstr)
163 {
164     UndoManager *This = UNDOMGR_THIS(iface);
165     FIXME("(%p)->(%p)\n", This, pBstr);
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI OleUndoManager_Enable(IOleUndoManager *iface, BOOL fEnable)
170 {
171     UndoManager *This = UNDOMGR_THIS(iface);
172     FIXME("(%p)->(%x)\n", This, fEnable);
173     return E_NOTIMPL;
174 }
175
176 #undef UNDOMGR_THIS
177
178 static const IOleUndoManagerVtbl OleUndoManagerVtbl = {
179     OleUndoManager_QueryInterface,
180     OleUndoManager_AddRef,
181     OleUndoManager_Release,
182     OleUndoManager_Open,
183     OleUndoManager_Close,
184     OleUndoManager_Add,
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
194 };
195
196 static IOleUndoManager *create_undomgr(void)
197 {
198     UndoManager *ret = heap_alloc(sizeof(UndoManager));
199
200     ret->lpOleUndoManagerVtbl = &OleUndoManagerVtbl;
201     ret->ref = 1;
202
203     return UNDOMGR(ret);
204 }
205
206 /**********************************************************
207  * IServiceProvider implementation
208  */
209
210 #define SERVPROV_THIS(iface) DEFINE_THIS(HTMLDocument, ServiceProvider, iface)
211
212 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
213 {
214     HTMLDocument *This = SERVPROV_THIS(iface);
215     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
216 }
217
218 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
219 {
220     HTMLDocument *This = SERVPROV_THIS(iface);
221     return IHTMLDocument2_AddRef(HTMLDOC(This));
222 }
223
224 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
225 {
226     HTMLDocument *This = SERVPROV_THIS(iface);
227     return IHTMLDocument_Release(HTMLDOC(This));
228 }
229
230 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
231         REFIID riid, void **ppv)
232 {
233     HTMLDocument *This = SERVPROV_THIS(iface);
234     
235     if(IsEqualGUID(&CLSID_CMarkup, guidService)) {
236         FIXME("(%p)->(CLSID_CMarkup %s %p)\n", This, debugstr_guid(riid), ppv);
237         return E_NOINTERFACE;
238     }
239
240     if(IsEqualGUID(&IID_IOleUndoManager, riid)) {
241         TRACE("(%p)->(IID_IOleUndoManager %p)\n", This, ppv);
242
243         if(!This->doc_obj->undomgr)
244             This->doc_obj->undomgr = create_undomgr();
245
246         IOleUndoManager_AddRef(This->doc_obj->undomgr);
247         *ppv = This->doc_obj->undomgr;
248         return S_OK;
249     }
250
251     if(This->doc_obj->client) {
252         IServiceProvider *sp;
253         HRESULT hres;
254
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);
260
261             if(SUCCEEDED(hres))
262                 return hres;
263         }
264     }
265
266     FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
267     
268     return E_NOINTERFACE;
269 }
270
271 static const IServiceProviderVtbl ServiceProviderVtbl = {
272     ServiceProvider_QueryInterface,
273     ServiceProvider_AddRef,
274     ServiceProvider_Release,
275     ServiceProvider_QueryService
276 };
277
278 void HTMLDocument_Service_Init(HTMLDocument *This)
279 {
280     This->lpServiceProviderVtbl = &ServiceProviderVtbl;
281 }