mshtml: Better QueryInterface implementation.
[wine/hacks.git] / dlls / mshtml / htmlbody.c
blobe55c06c2fd5d3858706a3fd057140c96f7f27255
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 typedef struct {
39 const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
41 HTMLElement *element;
42 nsIDOMHTMLBodyElement *nsbody;
43 } HTMLBodyElement;
45 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
47 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
49 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
50 REFIID riid, void **ppv)
52 HTMLBodyElement *This = HTMLBODY_THIS(iface);
53 HRESULT hres;
55 *ppv = NULL;
57 if(IsEqualGUID(&IID_IUnknown, riid)) {
58 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
59 *ppv = HTMLBODY(This);
60 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
61 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
62 *ppv = HTMLBODY(This);
63 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
64 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
65 *ppv = HTMLBODY(This);
68 if(*ppv) {
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
73 hres = HTMLElement_QI(This->element, riid, ppv);
74 if(FAILED(hres))
75 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
77 return hres;
80 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
82 HTMLBodyElement *This = HTMLBODY_THIS(iface);
84 TRACE("(%p)\n", This);
86 return IHTMLDocument2_AddRef(HTMLDOC(This->element->node->doc));
89 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
91 HTMLBodyElement *This = HTMLBODY_THIS(iface);
93 TRACE("(%p)\n", This);
95 return IHTMLDocument2_Release(HTMLDOC(This->element->node->doc));
98 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
100 HTMLBodyElement *This = HTMLBODY_THIS(iface);
101 FIXME("(%p)->(%p)\n", This, pctinfo);
102 return E_NOTIMPL;
105 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
106 LCID lcid, ITypeInfo **ppTInfo)
108 HTMLBodyElement *This = HTMLBODY_THIS(iface);
109 FIXME("(%p)->(%u %lu %p)\n", This, iTInfo, lcid, ppTInfo);
110 return E_NOTIMPL;
113 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
114 LPOLESTR *rgszNames, UINT cNames,
115 LCID lcid, DISPID *rgDispId)
117 HTMLBodyElement *This = HTMLBODY_THIS(iface);
118 FIXME("(%p)->(%s %p %u %lu %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
119 lcid, rgDispId);
120 return E_NOTIMPL;
123 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
124 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
125 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
127 HTMLBodyElement *This = HTMLBODY_THIS(iface);
128 FIXME("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
129 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
130 return E_NOTIMPL;
133 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
135 HTMLBodyElement *This = HTMLBODY_THIS(iface);
136 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
142 HTMLBodyElement *This = HTMLBODY_THIS(iface);
143 TRACE("(%p)->(%p)\n", This, p);
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
149 HTMLBodyElement *This = HTMLBODY_THIS(iface);
150 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
156 HTMLBodyElement *This = HTMLBODY_THIS(iface);
157 TRACE("(%p)->(%p)\n", This, p);
158 return E_NOTIMPL;
161 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
163 HTMLBodyElement *This = HTMLBODY_THIS(iface);
164 TRACE("(%p)->()\n", This);
165 return E_NOTIMPL;
168 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
170 HTMLBodyElement *This = HTMLBODY_THIS(iface);
171 TRACE("(%p)->(%p)\n", This, p);
172 return E_NOTIMPL;
175 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
177 HTMLBodyElement *This = HTMLBODY_THIS(iface);
178 TRACE("(%p)->()\n", This);
179 return E_NOTIMPL;
182 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
184 HTMLBodyElement *This = HTMLBODY_THIS(iface);
185 TRACE("(%p)->(%p)\n", This, p);
186 return E_NOTIMPL;
189 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
191 HTMLBodyElement *This = HTMLBODY_THIS(iface);
192 TRACE("(%p)->()\n", This);
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
198 HTMLBodyElement *This = HTMLBODY_THIS(iface);
199 TRACE("(%p)->(%p)\n", This, p);
200 return E_NOTIMPL;
203 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
205 HTMLBodyElement *This = HTMLBODY_THIS(iface);
206 TRACE("(%p)->()\n", This);
207 return E_NOTIMPL;
210 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
212 HTMLBodyElement *This = HTMLBODY_THIS(iface);
213 TRACE("(%p)->(%p)\n", This, p);
214 return E_NOTIMPL;
217 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
219 HTMLBodyElement *This = HTMLBODY_THIS(iface);
220 TRACE("(%p)->(%x)\n", This, v);
221 return E_NOTIMPL;
224 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
226 HTMLBodyElement *This = HTMLBODY_THIS(iface);
227 TRACE("(%p)->(%p)\n", This, p);
228 return E_NOTIMPL;
231 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
233 HTMLBodyElement *This = HTMLBODY_THIS(iface);
234 TRACE("(%p)->()\n", This);
235 return E_NOTIMPL;
238 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
240 HTMLBodyElement *This = HTMLBODY_THIS(iface);
241 TRACE("(%p)->(%p)\n", This, p);
242 return E_NOTIMPL;
245 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
247 HTMLBodyElement *This = HTMLBODY_THIS(iface);
248 TRACE("(%p)->()\n", This);
249 return E_NOTIMPL;
252 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
254 HTMLBodyElement *This = HTMLBODY_THIS(iface);
255 TRACE("(%p)->(%p)\n", This, p);
256 return E_NOTIMPL;
259 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
261 HTMLBodyElement *This = HTMLBODY_THIS(iface);
262 TRACE("(%p)->()\n", This);
263 return E_NOTIMPL;
266 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
268 HTMLBodyElement *This = HTMLBODY_THIS(iface);
269 TRACE("(%p)->(%p)\n", This, p);
270 return E_NOTIMPL;
273 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
275 HTMLBodyElement *This = HTMLBODY_THIS(iface);
276 TRACE("(%p)->()\n", This);
277 return E_NOTIMPL;
280 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
282 HTMLBodyElement *This = HTMLBODY_THIS(iface);
283 TRACE("(%p)->(%p)\n", This, p);
284 return E_NOTIMPL;
287 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
289 HTMLBodyElement *This = HTMLBODY_THIS(iface);
290 TRACE("(%p)->()\n", This);
291 return E_NOTIMPL;
294 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
296 HTMLBodyElement *This = HTMLBODY_THIS(iface);
297 TRACE("(%p)->(%p)\n", This, p);
298 return E_NOTIMPL;
301 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
303 HTMLBodyElement *This = HTMLBODY_THIS(iface);
304 TRACE("(%p)->()\n", This);
305 return E_NOTIMPL;
308 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
310 HTMLBodyElement *This = HTMLBODY_THIS(iface);
311 TRACE("(%p)->(%p)\n", This, p);
312 return E_NOTIMPL;
315 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
317 HTMLBodyElement *This = HTMLBODY_THIS(iface);
318 TRACE("(%p)->()\n", This);
319 return E_NOTIMPL;
322 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
324 HTMLBodyElement *This = HTMLBODY_THIS(iface);
325 TRACE("(%p)->(%p)\n", This, p);
326 return E_NOTIMPL;
329 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
331 HTMLBodyElement *This = HTMLBODY_THIS(iface);
332 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
333 return E_NOTIMPL;
336 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
338 HTMLBodyElement *This = HTMLBODY_THIS(iface);
339 TRACE("(%p)->(%p)\n", This, p);
340 return E_NOTIMPL;
343 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
345 HTMLBodyElement *This = HTMLBODY_THIS(iface);
346 TRACE("(%p)->()\n", This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
352 HTMLBodyElement *This = HTMLBODY_THIS(iface);
353 TRACE("(%p)->(%p)\n", This, p);
354 return E_NOTIMPL;
357 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
359 HTMLBodyElement *This = HTMLBODY_THIS(iface);
360 TRACE("(%p)->()\n", This);
361 return E_NOTIMPL;
364 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
366 HTMLBodyElement *This = HTMLBODY_THIS(iface);
367 TRACE("(%p)->(%p)\n", This, p);
368 return E_NOTIMPL;
371 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
373 HTMLBodyElement *This = HTMLBODY_THIS(iface);
374 TRACE("(%p)->(%p)\n", This, range);
375 return E_NOTIMPL;
378 static void HTMLBodyElement_destructor(IUnknown *iface)
380 HTMLBodyElement *This = HTMLBODY_THIS(iface);
382 nsIDOMHTMLBodyElement_Release(This->nsbody);
383 HeapFree(GetProcessHeap(), 0, This);
386 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
387 HTMLBodyElement_QueryInterface,
388 HTMLBodyElement_AddRef,
389 HTMLBodyElement_Release,
390 HTMLBodyElement_GetTypeInfoCount,
391 HTMLBodyElement_GetTypeInfo,
392 HTMLBodyElement_GetIDsOfNames,
393 HTMLBodyElement_Invoke,
394 HTMLBodyElement_put_background,
395 HTMLBodyElement_get_background,
396 HTMLBodyElement_put_bgProperties,
397 HTMLBodyElement_get_bgProperties,
398 HTMLBodyElement_put_leftMargin,
399 HTMLBodyElement_get_leftMargin,
400 HTMLBodyElement_put_topMargin,
401 HTMLBodyElement_get_topMargin,
402 HTMLBodyElement_put_rightMargin,
403 HTMLBodyElement_get_rightMargin,
404 HTMLBodyElement_put_bottomMargin,
405 HTMLBodyElement_get_bottomMargin,
406 HTMLBodyElement_put_noWrap,
407 HTMLBodyElement_get_noWrap,
408 HTMLBodyElement_put_bgColor,
409 HTMLBodyElement_get_bgColor,
410 HTMLBodyElement_put_text,
411 HTMLBodyElement_get_text,
412 HTMLBodyElement_put_link,
413 HTMLBodyElement_get_link,
414 HTMLBodyElement_put_vLink,
415 HTMLBodyElement_get_vLink,
416 HTMLBodyElement_put_aLink,
417 HTMLBodyElement_get_aLink,
418 HTMLBodyElement_put_onload,
419 HTMLBodyElement_get_onload,
420 HTMLBodyElement_put_onunload,
421 HTMLBodyElement_get_onunload,
422 HTMLBodyElement_put_scroll,
423 HTMLBodyElement_get_scroll,
424 HTMLBodyElement_put_onselect,
425 HTMLBodyElement_get_onselect,
426 HTMLBodyElement_put_onbeforeunload,
427 HTMLBodyElement_get_onbeforeunload,
428 HTMLBodyElement_createTextRange
431 void HTMLBodyElement_Create(HTMLElement *element)
433 HTMLBodyElement *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HTMLBodyElement));
434 nsresult nsres;
436 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
437 ret->element = element;
439 nsres = nsIDOMHTMLElement_QueryInterface(element->nselem, &IID_nsIDOMHTMLBodyElement,
440 (void**)&ret->nsbody);
441 if(NS_FAILED(nsres))
442 ERR("Could not get nsDOMHTMLBodyElement: %08lx\n", nsres);
444 element->impl = (IUnknown*)HTMLBODY(ret);
445 element->destructor = HTMLBodyElement_destructor;