push b5232b2081a0e20e4bf07d6ded424d0101e4a589
[wine/hacks.git] / dlls / mshtml / htmlbody.c
blobb8c153a76b8b05cc1f1e529772e4778745657e94
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 HTMLTextContainer textcont;
41 const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
43 HTMLTextContainer text_container;
45 ConnectionPointContainer cp_container;
46 ConnectionPoint cp_propnotif;
47 ConnectionPoint cp_txtcontevents;
49 nsIDOMHTMLBodyElement *nsbody;
50 } HTMLBodyElement;
52 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
54 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
56 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
57 REFIID riid, void **ppv)
59 HTMLBodyElement *This = HTMLBODY_THIS(iface);
60 HRESULT hres;
62 *ppv = NULL;
64 if(IsEqualGUID(&IID_IUnknown, riid)) {
65 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
66 *ppv = HTMLBODY(This);
67 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
68 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
69 *ppv = HTMLBODY(This);
70 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
71 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
72 *ppv = HTMLBODY(This);
73 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
74 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This, ppv);
75 *ppv = HTMLTEXTCONT(&This->text_container);
76 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
77 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
78 *ppv = CONPTCONT(&This->cp_container);
81 if(*ppv) {
82 IUnknown_AddRef((IUnknown*)*ppv);
83 return S_OK;
86 hres = HTMLElement_QI(&This->textcont.element, riid, ppv);
87 if(FAILED(hres))
88 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
90 return hres;
93 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
95 HTMLBodyElement *This = HTMLBODY_THIS(iface);
97 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->textcont.element.node));
100 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
102 HTMLBodyElement *This = HTMLBODY_THIS(iface);
104 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->textcont.element.node));
107 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
109 HTMLBodyElement *This = HTMLBODY_THIS(iface);
110 FIXME("(%p)->(%p)\n", This, pctinfo);
111 return E_NOTIMPL;
114 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
115 LCID lcid, ITypeInfo **ppTInfo)
117 HTMLBodyElement *This = HTMLBODY_THIS(iface);
118 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
119 return E_NOTIMPL;
122 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
123 LPOLESTR *rgszNames, UINT cNames,
124 LCID lcid, DISPID *rgDispId)
126 HTMLBodyElement *This = HTMLBODY_THIS(iface);
127 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
128 lcid, rgDispId);
129 return E_NOTIMPL;
132 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
133 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
134 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
136 HTMLBodyElement *This = HTMLBODY_THIS(iface);
137 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
138 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
139 return E_NOTIMPL;
142 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
144 HTMLBodyElement *This = HTMLBODY_THIS(iface);
145 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
146 return E_NOTIMPL;
149 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
151 HTMLBodyElement *This = HTMLBODY_THIS(iface);
152 nsAString background_str;
153 nsresult nsres;
155 TRACE("(%p)->(%p)\n", This, p);
157 nsAString_Init(&background_str, NULL);
159 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
160 if(NS_SUCCEEDED(nsres)) {
161 const PRUnichar *background;
162 nsAString_GetData(&background_str, &background, NULL);
163 *p = SysAllocString(background);
164 }else {
165 ERR("GetBackground failed: %08x\n", nsres);
166 *p = NULL;
169 nsAString_Finish(&background_str);
171 TRACE("*p = %s\n", debugstr_w(*p));
172 return S_OK;
175 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
177 HTMLBodyElement *This = HTMLBODY_THIS(iface);
178 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
179 return E_NOTIMPL;
182 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
184 HTMLBodyElement *This = HTMLBODY_THIS(iface);
185 FIXME("(%p)->(%p)\n", This, p);
186 return E_NOTIMPL;
189 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
191 HTMLBodyElement *This = HTMLBODY_THIS(iface);
192 FIXME("(%p)->()\n", This);
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
198 HTMLBodyElement *This = HTMLBODY_THIS(iface);
199 FIXME("(%p)->(%p)\n", This, p);
200 return E_NOTIMPL;
203 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
205 HTMLBodyElement *This = HTMLBODY_THIS(iface);
206 FIXME("(%p)->()\n", This);
207 return E_NOTIMPL;
210 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
212 HTMLBodyElement *This = HTMLBODY_THIS(iface);
213 FIXME("(%p)->(%p)\n", This, p);
214 return E_NOTIMPL;
217 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
219 HTMLBodyElement *This = HTMLBODY_THIS(iface);
220 FIXME("(%p)->()\n", This);
221 return E_NOTIMPL;
224 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
226 HTMLBodyElement *This = HTMLBODY_THIS(iface);
227 FIXME("(%p)->(%p)\n", This, p);
228 return E_NOTIMPL;
231 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
233 HTMLBodyElement *This = HTMLBODY_THIS(iface);
234 FIXME("(%p)->()\n", This);
235 return E_NOTIMPL;
238 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
240 HTMLBodyElement *This = HTMLBODY_THIS(iface);
241 FIXME("(%p)->(%p)\n", This, p);
242 return E_NOTIMPL;
245 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
247 HTMLBodyElement *This = HTMLBODY_THIS(iface);
248 FIXME("(%p)->(%x)\n", This, v);
249 return E_NOTIMPL;
252 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
254 HTMLBodyElement *This = HTMLBODY_THIS(iface);
255 FIXME("(%p)->(%p)\n", This, p);
256 return E_NOTIMPL;
259 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
261 HTMLBodyElement *This = HTMLBODY_THIS(iface);
262 FIXME("(%p)->()\n", This);
263 return E_NOTIMPL;
266 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
268 HTMLBodyElement *This = HTMLBODY_THIS(iface);
269 FIXME("(%p)->(%p)\n", This, p);
270 return E_NOTIMPL;
273 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
275 HTMLBodyElement *This = HTMLBODY_THIS(iface);
276 FIXME("(%p)->()\n", This);
277 return E_NOTIMPL;
280 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
282 HTMLBodyElement *This = HTMLBODY_THIS(iface);
283 FIXME("(%p)->(%p)\n", This, p);
284 return E_NOTIMPL;
287 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
289 HTMLBodyElement *This = HTMLBODY_THIS(iface);
290 FIXME("(%p)->()\n", This);
291 return E_NOTIMPL;
294 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
296 HTMLBodyElement *This = HTMLBODY_THIS(iface);
297 FIXME("(%p)->(%p)\n", This, p);
298 return E_NOTIMPL;
301 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
303 HTMLBodyElement *This = HTMLBODY_THIS(iface);
304 FIXME("(%p)->()\n", This);
305 return E_NOTIMPL;
308 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
310 HTMLBodyElement *This = HTMLBODY_THIS(iface);
311 FIXME("(%p)->(%p)\n", This, p);
312 return E_NOTIMPL;
315 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
317 HTMLBodyElement *This = HTMLBODY_THIS(iface);
318 FIXME("(%p)->()\n", This);
319 return E_NOTIMPL;
322 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
324 HTMLBodyElement *This = HTMLBODY_THIS(iface);
325 FIXME("(%p)->(%p)\n", This, p);
326 return E_NOTIMPL;
329 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
331 HTMLBodyElement *This = HTMLBODY_THIS(iface);
332 FIXME("(%p)->()\n", This);
333 return E_NOTIMPL;
336 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
338 HTMLBodyElement *This = HTMLBODY_THIS(iface);
339 FIXME("(%p)->(%p)\n", This, p);
340 return E_NOTIMPL;
343 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
345 HTMLBodyElement *This = HTMLBODY_THIS(iface);
346 FIXME("(%p)->()\n", This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
352 HTMLBodyElement *This = HTMLBODY_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
354 return E_NOTIMPL;
357 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
359 HTMLBodyElement *This = HTMLBODY_THIS(iface);
360 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
361 return E_NOTIMPL;
364 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
366 HTMLBodyElement *This = HTMLBODY_THIS(iface);
367 FIXME("(%p)->(%p)\n", This, p);
368 return E_NOTIMPL;
371 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
373 HTMLBodyElement *This = HTMLBODY_THIS(iface);
374 FIXME("(%p)->()\n", This);
375 return E_NOTIMPL;
378 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
380 HTMLBodyElement *This = HTMLBODY_THIS(iface);
381 FIXME("(%p)->(%p)\n", This, p);
382 return E_NOTIMPL;
385 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
387 HTMLBodyElement *This = HTMLBODY_THIS(iface);
388 FIXME("(%p)->()\n", This);
389 return E_NOTIMPL;
392 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
394 HTMLBodyElement *This = HTMLBODY_THIS(iface);
395 FIXME("(%p)->(%p)\n", This, p);
396 return E_NOTIMPL;
399 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
401 HTMLBodyElement *This = HTMLBODY_THIS(iface);
402 nsIDOMRange *nsrange = NULL;
404 TRACE("(%p)->(%p)\n", This, range);
406 if(This->textcont.element.node.doc->nscontainer) {
407 nsIDOMDocument *nsdoc;
408 nsIDOMDocumentRange *nsdocrange;
409 nsresult nsres;
411 nsIWebNavigation_GetDocument(This->textcont.element.node.doc->nscontainer->navigation, &nsdoc);
412 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
413 nsIDOMDocument_Release(nsdoc);
415 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
416 if(NS_SUCCEEDED(nsres)) {
417 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
418 if(NS_FAILED(nsres))
419 ERR("SelectNodeContents failed: %08x\n", nsres);
420 }else {
421 ERR("CreateRange failed: %08x\n", nsres);
424 nsIDOMDocumentRange_Release(nsdocrange);
427 *range = HTMLTxtRange_Create(This->textcont.element.node.doc, nsrange);
428 return S_OK;
431 static void HTMLBodyElement_destructor(IUnknown *iface)
433 HTMLBodyElement *This = HTMLBODY_THIS(iface);
435 ConnectionPointContainer_Destroy(&This->cp_container);
436 nsIDOMHTMLBodyElement_Release(This->nsbody);
437 mshtml_free(This);
440 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
441 HTMLBodyElement_QueryInterface,
442 HTMLBodyElement_AddRef,
443 HTMLBodyElement_Release,
444 HTMLBodyElement_GetTypeInfoCount,
445 HTMLBodyElement_GetTypeInfo,
446 HTMLBodyElement_GetIDsOfNames,
447 HTMLBodyElement_Invoke,
448 HTMLBodyElement_put_background,
449 HTMLBodyElement_get_background,
450 HTMLBodyElement_put_bgProperties,
451 HTMLBodyElement_get_bgProperties,
452 HTMLBodyElement_put_leftMargin,
453 HTMLBodyElement_get_leftMargin,
454 HTMLBodyElement_put_topMargin,
455 HTMLBodyElement_get_topMargin,
456 HTMLBodyElement_put_rightMargin,
457 HTMLBodyElement_get_rightMargin,
458 HTMLBodyElement_put_bottomMargin,
459 HTMLBodyElement_get_bottomMargin,
460 HTMLBodyElement_put_noWrap,
461 HTMLBodyElement_get_noWrap,
462 HTMLBodyElement_put_bgColor,
463 HTMLBodyElement_get_bgColor,
464 HTMLBodyElement_put_text,
465 HTMLBodyElement_get_text,
466 HTMLBodyElement_put_link,
467 HTMLBodyElement_get_link,
468 HTMLBodyElement_put_vLink,
469 HTMLBodyElement_get_vLink,
470 HTMLBodyElement_put_aLink,
471 HTMLBodyElement_get_aLink,
472 HTMLBodyElement_put_onload,
473 HTMLBodyElement_get_onload,
474 HTMLBodyElement_put_onunload,
475 HTMLBodyElement_get_onunload,
476 HTMLBodyElement_put_scroll,
477 HTMLBodyElement_get_scroll,
478 HTMLBodyElement_put_onselect,
479 HTMLBodyElement_get_onselect,
480 HTMLBodyElement_put_onbeforeunload,
481 HTMLBodyElement_get_onbeforeunload,
482 HTMLBodyElement_createTextRange
485 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
487 HTMLBodyElement *ret = mshtml_alloc(sizeof(HTMLBodyElement));
488 nsresult nsres;
490 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
492 HTMLTextContainer_Init(&ret->text_container);
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);
502 if(NS_FAILED(nsres))
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;