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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 HTMLTextContainer textcont;
41 const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
43 ConnectionPointContainer cp_container;
44 ConnectionPoint cp_propnotif;
45 ConnectionPoint cp_txtcontevents;
47 nsIDOMHTMLBodyElement *nsbody;
50 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
52 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
54 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
55 REFIID riid, void **ppv)
57 HTMLBodyElement *This = HTMLBODY_THIS(iface);
62 if(IsEqualGUID(&IID_IUnknown, riid)) {
63 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
64 *ppv = HTMLBODY(This);
65 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
66 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
67 *ppv = HTMLBODY(This);
68 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
69 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
70 *ppv = HTMLBODY(This);
71 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
72 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
73 *ppv = HTMLTEXTCONT(&This->textcont);
74 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
75 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
76 *ppv = CONPTCONT(&This->cp_container);
80 IUnknown_AddRef((IUnknown*)*ppv);
84 hres = HTMLElement_QI(&This->textcont.element, riid, ppv);
86 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
91 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
93 HTMLBodyElement *This = HTMLBODY_THIS(iface);
95 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->textcont.element.node));
98 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
100 HTMLBodyElement *This = HTMLBODY_THIS(iface);
102 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->textcont.element.node));
105 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
107 HTMLBodyElement *This = HTMLBODY_THIS(iface);
108 FIXME("(%p)->(%p)\n", This, pctinfo);
112 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
113 LCID lcid, ITypeInfo **ppTInfo)
115 HTMLBodyElement *This = HTMLBODY_THIS(iface);
116 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
120 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
121 LPOLESTR *rgszNames, UINT cNames,
122 LCID lcid, DISPID *rgDispId)
124 HTMLBodyElement *This = HTMLBODY_THIS(iface);
125 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
130 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
131 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
132 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
134 HTMLBodyElement *This = HTMLBODY_THIS(iface);
135 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
136 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
142 HTMLBodyElement *This = HTMLBODY_THIS(iface);
143 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
147 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
149 HTMLBodyElement *This = HTMLBODY_THIS(iface);
150 nsAString background_str;
153 TRACE("(%p)->(%p)\n", This, p);
155 nsAString_Init(&background_str, NULL);
157 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
158 if(NS_SUCCEEDED(nsres)) {
159 const PRUnichar *background;
160 nsAString_GetData(&background_str, &background, NULL);
161 *p = SysAllocString(background);
163 ERR("GetBackground failed: %08x\n", nsres);
167 nsAString_Finish(&background_str);
169 TRACE("*p = %s\n", debugstr_w(*p));
173 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
175 HTMLBodyElement *This = HTMLBODY_THIS(iface);
176 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
180 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
182 HTMLBodyElement *This = HTMLBODY_THIS(iface);
183 FIXME("(%p)->(%p)\n", This, p);
187 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
189 HTMLBodyElement *This = HTMLBODY_THIS(iface);
190 FIXME("(%p)->()\n", This);
194 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
196 HTMLBodyElement *This = HTMLBODY_THIS(iface);
197 FIXME("(%p)->(%p)\n", This, p);
201 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
203 HTMLBodyElement *This = HTMLBODY_THIS(iface);
204 FIXME("(%p)->()\n", This);
208 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
210 HTMLBodyElement *This = HTMLBODY_THIS(iface);
211 FIXME("(%p)->(%p)\n", This, p);
215 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
217 HTMLBodyElement *This = HTMLBODY_THIS(iface);
218 FIXME("(%p)->()\n", This);
222 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
224 HTMLBodyElement *This = HTMLBODY_THIS(iface);
225 FIXME("(%p)->(%p)\n", This, p);
229 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
231 HTMLBodyElement *This = HTMLBODY_THIS(iface);
232 FIXME("(%p)->()\n", This);
236 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
238 HTMLBodyElement *This = HTMLBODY_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, p);
243 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
245 HTMLBodyElement *This = HTMLBODY_THIS(iface);
246 FIXME("(%p)->(%x)\n", This, v);
250 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
252 HTMLBodyElement *This = HTMLBODY_THIS(iface);
253 FIXME("(%p)->(%p)\n", This, p);
257 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
259 HTMLBodyElement *This = HTMLBODY_THIS(iface);
260 FIXME("(%p)->()\n", This);
264 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
266 HTMLBodyElement *This = HTMLBODY_THIS(iface);
267 FIXME("(%p)->(%p)\n", This, p);
271 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
273 HTMLBodyElement *This = HTMLBODY_THIS(iface);
274 FIXME("(%p)->()\n", This);
278 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
280 HTMLBodyElement *This = HTMLBODY_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, p);
285 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
287 HTMLBodyElement *This = HTMLBODY_THIS(iface);
288 FIXME("(%p)->()\n", This);
292 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
294 HTMLBodyElement *This = HTMLBODY_THIS(iface);
295 FIXME("(%p)->(%p)\n", This, p);
299 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
301 HTMLBodyElement *This = HTMLBODY_THIS(iface);
302 FIXME("(%p)->()\n", This);
306 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
308 HTMLBodyElement *This = HTMLBODY_THIS(iface);
309 FIXME("(%p)->(%p)\n", This, p);
313 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
315 HTMLBodyElement *This = HTMLBODY_THIS(iface);
316 FIXME("(%p)->()\n", This);
320 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
322 HTMLBodyElement *This = HTMLBODY_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, p);
327 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
329 HTMLBodyElement *This = HTMLBODY_THIS(iface);
330 FIXME("(%p)->()\n", This);
334 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
336 HTMLBodyElement *This = HTMLBODY_THIS(iface);
337 FIXME("(%p)->(%p)\n", This, p);
341 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
343 HTMLBodyElement *This = HTMLBODY_THIS(iface);
344 FIXME("(%p)->()\n", This);
348 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
350 HTMLBodyElement *This = HTMLBODY_THIS(iface);
351 FIXME("(%p)->(%p)\n", This, p);
355 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
357 HTMLBodyElement *This = HTMLBODY_THIS(iface);
358 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
362 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
364 HTMLBodyElement *This = HTMLBODY_THIS(iface);
365 FIXME("(%p)->(%p)\n", This, p);
369 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
371 HTMLBodyElement *This = HTMLBODY_THIS(iface);
372 FIXME("(%p)->()\n", This);
376 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
378 HTMLBodyElement *This = HTMLBODY_THIS(iface);
379 FIXME("(%p)->(%p)\n", This, p);
383 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
385 HTMLBodyElement *This = HTMLBODY_THIS(iface);
386 FIXME("(%p)->()\n", This);
390 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
392 HTMLBodyElement *This = HTMLBODY_THIS(iface);
393 FIXME("(%p)->(%p)\n", This, p);
397 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
399 HTMLBodyElement *This = HTMLBODY_THIS(iface);
400 nsIDOMRange *nsrange = NULL;
402 TRACE("(%p)->(%p)\n", This, range);
404 if(This->textcont.element.node.doc->nscontainer) {
405 nsIDOMDocument *nsdoc;
406 nsIDOMDocumentRange *nsdocrange;
409 nsIWebNavigation_GetDocument(This->textcont.element.node.doc->nscontainer->navigation, &nsdoc);
410 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
411 nsIDOMDocument_Release(nsdoc);
413 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
414 if(NS_SUCCEEDED(nsres)) {
415 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
417 ERR("SelectNodeContents failed: %08x\n", nsres);
419 ERR("CreateRange failed: %08x\n", nsres);
422 nsIDOMDocumentRange_Release(nsdocrange);
425 *range = HTMLTxtRange_Create(This->textcont.element.node.doc, nsrange);
429 static void HTMLBodyElement_destructor(IUnknown *iface)
431 HTMLBodyElement *This = HTMLBODY_THIS(iface);
433 ConnectionPointContainer_Destroy(&This->cp_container);
434 nsIDOMHTMLBodyElement_Release(This->nsbody);
438 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
439 HTMLBodyElement_QueryInterface,
440 HTMLBodyElement_AddRef,
441 HTMLBodyElement_Release,
442 HTMLBodyElement_GetTypeInfoCount,
443 HTMLBodyElement_GetTypeInfo,
444 HTMLBodyElement_GetIDsOfNames,
445 HTMLBodyElement_Invoke,
446 HTMLBodyElement_put_background,
447 HTMLBodyElement_get_background,
448 HTMLBodyElement_put_bgProperties,
449 HTMLBodyElement_get_bgProperties,
450 HTMLBodyElement_put_leftMargin,
451 HTMLBodyElement_get_leftMargin,
452 HTMLBodyElement_put_topMargin,
453 HTMLBodyElement_get_topMargin,
454 HTMLBodyElement_put_rightMargin,
455 HTMLBodyElement_get_rightMargin,
456 HTMLBodyElement_put_bottomMargin,
457 HTMLBodyElement_get_bottomMargin,
458 HTMLBodyElement_put_noWrap,
459 HTMLBodyElement_get_noWrap,
460 HTMLBodyElement_put_bgColor,
461 HTMLBodyElement_get_bgColor,
462 HTMLBodyElement_put_text,
463 HTMLBodyElement_get_text,
464 HTMLBodyElement_put_link,
465 HTMLBodyElement_get_link,
466 HTMLBodyElement_put_vLink,
467 HTMLBodyElement_get_vLink,
468 HTMLBodyElement_put_aLink,
469 HTMLBodyElement_get_aLink,
470 HTMLBodyElement_put_onload,
471 HTMLBodyElement_get_onload,
472 HTMLBodyElement_put_onunload,
473 HTMLBodyElement_get_onunload,
474 HTMLBodyElement_put_scroll,
475 HTMLBodyElement_get_scroll,
476 HTMLBodyElement_put_onselect,
477 HTMLBodyElement_get_onselect,
478 HTMLBodyElement_put_onbeforeunload,
479 HTMLBodyElement_get_onbeforeunload,
480 HTMLBodyElement_createTextRange
483 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
485 HTMLBodyElement *ret = mshtml_alloc(sizeof(HTMLBodyElement));
488 TRACE("(%p)->(%p)\n", ret, nselem);
490 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
492 HTMLTextContainer_Init(&ret->textcont);
494 ConnectionPoint_Init(&ret->cp_propnotif, CONPTCONT(&ret->cp_container),
495 &IID_IPropertyNotifySink, NULL);
496 ConnectionPoint_Init(&ret->cp_txtcontevents, CONPTCONT(&ret->cp_container),
497 &DIID_HTMLTextContainerEvents, &ret->cp_propnotif);
498 ConnectionPointContainer_Init(&ret->cp_container, &ret->cp_propnotif, (IUnknown*)HTMLBODY(ret));
500 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
501 (void**)&ret->nsbody);
503 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
505 ret->textcont.element.impl = (IUnknown*)HTMLBODY(ret);
506 ret->textcont.element.destructor = HTMLBodyElement_destructor;
508 return &ret->textcont.element;