mshtml: Left-align Gecko download information message for better readability.
[wine] / dlls / mshtml / htmlbody.c
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
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 "winnls.h"
30 #include "ole2.h"
31
32 #include "wine/debug.h"
33
34 #include "mshtml_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
38 typedef struct {
39     const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
40
41     HTMLTextContainer text_container;
42
43     HTMLElement *element;
44     nsIDOMHTMLBodyElement *nsbody;
45 } HTMLBodyElement;
46
47 #define HTMLBODY(x)  ((IHTMLBodyElement*)  &(x)->lpHTMLBodyElementVtbl)
48
49 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
50
51 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
52                                                      REFIID riid, void **ppv)
53 {
54     HTMLBodyElement *This = HTMLBODY_THIS(iface);
55     HRESULT hres;
56
57     *ppv = NULL;
58
59     if(IsEqualGUID(&IID_IUnknown, riid)) {
60         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
61         *ppv = HTMLBODY(This);
62     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
63         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
64         *ppv = HTMLBODY(This);
65     }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
66         TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
67         *ppv = HTMLBODY(This);
68     }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
69         TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This, ppv);
70         *ppv = HTMLTEXTCONT(&This->text_container);
71     }
72
73     if(*ppv) {
74         IUnknown_AddRef((IUnknown*)*ppv);
75         return S_OK;
76     }
77
78     hres = HTMLElement_QI(This->element, riid, ppv);
79     if(FAILED(hres))
80         WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
81
82     return hres;
83 }
84
85 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
86 {
87     HTMLBodyElement *This = HTMLBODY_THIS(iface);
88
89     TRACE("(%p)\n", This);
90
91     return IHTMLDocument2_AddRef(HTMLDOC(This->element->node->doc));
92 }
93
94 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
95 {
96     HTMLBodyElement *This = HTMLBODY_THIS(iface);
97
98     TRACE("(%p)\n", This);
99
100     return IHTMLDocument2_Release(HTMLDOC(This->element->node->doc));
101 }
102
103 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
104 {
105     HTMLBodyElement *This = HTMLBODY_THIS(iface);
106     FIXME("(%p)->(%p)\n", This, pctinfo);
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
111                                               LCID lcid, ITypeInfo **ppTInfo)
112 {
113     HTMLBodyElement *This = HTMLBODY_THIS(iface);
114     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
115     return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
119                                                 LPOLESTR *rgszNames, UINT cNames,
120                                                 LCID lcid, DISPID *rgDispId)
121 {
122     HTMLBodyElement *This = HTMLBODY_THIS(iface);
123     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
124                                         lcid, rgDispId);
125     return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
129                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
130                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
131 {
132     HTMLBodyElement *This = HTMLBODY_THIS(iface);
133     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
134             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
135     return E_NOTIMPL;
136 }
137
138 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
139 {
140     HTMLBodyElement *This = HTMLBODY_THIS(iface);
141     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
146 {
147     HTMLBodyElement *This = HTMLBODY_THIS(iface);
148     TRACE("(%p)->(%p)\n", This, p);
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
153 {
154     HTMLBodyElement *This = HTMLBODY_THIS(iface);
155     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
156     return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
160 {
161     HTMLBodyElement *This = HTMLBODY_THIS(iface);
162     TRACE("(%p)->(%p)\n", This, p);
163     return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
167 {
168     HTMLBodyElement *This = HTMLBODY_THIS(iface);
169     TRACE("(%p)->()\n", This);
170     return E_NOTIMPL;
171 }
172
173 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
174 {
175     HTMLBodyElement *This = HTMLBODY_THIS(iface);
176     TRACE("(%p)->(%p)\n", This, p);
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
181 {
182     HTMLBodyElement *This = HTMLBODY_THIS(iface);
183     TRACE("(%p)->()\n", This);
184     return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
188 {
189     HTMLBodyElement *This = HTMLBODY_THIS(iface);
190     TRACE("(%p)->(%p)\n", This, p);
191     return E_NOTIMPL;
192 }
193
194 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
195 {
196     HTMLBodyElement *This = HTMLBODY_THIS(iface);
197     TRACE("(%p)->()\n", This);
198     return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
202 {
203     HTMLBodyElement *This = HTMLBODY_THIS(iface);
204     TRACE("(%p)->(%p)\n", This, p);
205     return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
209 {
210     HTMLBodyElement *This = HTMLBODY_THIS(iface);
211     TRACE("(%p)->()\n", This);
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
216 {
217     HTMLBodyElement *This = HTMLBODY_THIS(iface);
218     TRACE("(%p)->(%p)\n", This, p);
219     return E_NOTIMPL;
220 }
221
222 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
223 {
224     HTMLBodyElement *This = HTMLBODY_THIS(iface);
225     TRACE("(%p)->(%x)\n", This, v);
226     return E_NOTIMPL;
227 }
228
229 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
230 {
231     HTMLBodyElement *This = HTMLBODY_THIS(iface);
232     TRACE("(%p)->(%p)\n", This, p);
233     return E_NOTIMPL;
234 }
235
236 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
237 {
238     HTMLBodyElement *This = HTMLBODY_THIS(iface);
239     TRACE("(%p)->()\n", This);
240     return E_NOTIMPL;
241 }
242
243 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
244 {
245     HTMLBodyElement *This = HTMLBODY_THIS(iface);
246     TRACE("(%p)->(%p)\n", This, p);
247     return E_NOTIMPL;
248 }
249
250 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
251 {
252     HTMLBodyElement *This = HTMLBODY_THIS(iface);
253     TRACE("(%p)->()\n", This);
254     return E_NOTIMPL;
255 }
256
257 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
258 {
259     HTMLBodyElement *This = HTMLBODY_THIS(iface);
260     TRACE("(%p)->(%p)\n", This, p);
261     return E_NOTIMPL;
262 }
263
264 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
265 {
266     HTMLBodyElement *This = HTMLBODY_THIS(iface);
267     TRACE("(%p)->()\n", This);
268     return E_NOTIMPL;
269 }
270
271 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
272 {
273     HTMLBodyElement *This = HTMLBODY_THIS(iface);
274     TRACE("(%p)->(%p)\n", This, p);
275     return E_NOTIMPL;
276 }
277
278 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
279 {
280     HTMLBodyElement *This = HTMLBODY_THIS(iface);
281     TRACE("(%p)->()\n", This);
282     return E_NOTIMPL;
283 }
284
285 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
286 {
287     HTMLBodyElement *This = HTMLBODY_THIS(iface);
288     TRACE("(%p)->(%p)\n", This, p);
289     return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
293 {
294     HTMLBodyElement *This = HTMLBODY_THIS(iface);
295     TRACE("(%p)->()\n", This);
296     return E_NOTIMPL;
297 }
298
299 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
300 {
301     HTMLBodyElement *This = HTMLBODY_THIS(iface);
302     TRACE("(%p)->(%p)\n", This, p);
303     return E_NOTIMPL;
304 }
305
306 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
307 {
308     HTMLBodyElement *This = HTMLBODY_THIS(iface);
309     TRACE("(%p)->()\n", This);
310     return E_NOTIMPL;
311 }
312
313 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
314 {
315     HTMLBodyElement *This = HTMLBODY_THIS(iface);
316     TRACE("(%p)->(%p)\n", This, p);
317     return E_NOTIMPL;
318 }
319
320 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
321 {
322     HTMLBodyElement *This = HTMLBODY_THIS(iface);
323     TRACE("(%p)->()\n", This);
324     return E_NOTIMPL;
325 }
326
327 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
328 {
329     HTMLBodyElement *This = HTMLBODY_THIS(iface);
330     TRACE("(%p)->(%p)\n", This, p);
331     return E_NOTIMPL;
332 }
333
334 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
335 {
336     HTMLBodyElement *This = HTMLBODY_THIS(iface);
337     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
338     return E_NOTIMPL;
339 }
340
341 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
342 {
343     HTMLBodyElement *This = HTMLBODY_THIS(iface);
344     TRACE("(%p)->(%p)\n", This, p);
345     return E_NOTIMPL;
346 }
347
348 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
349 {
350     HTMLBodyElement *This = HTMLBODY_THIS(iface);
351     TRACE("(%p)->()\n", This);
352     return E_NOTIMPL;
353 }
354
355 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
356 {
357     HTMLBodyElement *This = HTMLBODY_THIS(iface);
358     TRACE("(%p)->(%p)\n", This, p);
359     return E_NOTIMPL;
360 }
361
362 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
363 {
364     HTMLBodyElement *This = HTMLBODY_THIS(iface);
365     TRACE("(%p)->()\n", This);
366     return E_NOTIMPL;
367 }
368
369 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
370 {
371     HTMLBodyElement *This = HTMLBODY_THIS(iface);
372     TRACE("(%p)->(%p)\n", This, p);
373     return E_NOTIMPL;
374 }
375
376 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
377 {
378     HTMLBodyElement *This = HTMLBODY_THIS(iface);
379     TRACE("(%p)->(%p)\n", This, range);
380     return E_NOTIMPL;
381 }
382
383 static void HTMLBodyElement_destructor(IUnknown *iface)
384 {
385     HTMLBodyElement *This = HTMLBODY_THIS(iface);
386
387     nsIDOMHTMLBodyElement_Release(This->nsbody);
388     mshtml_free(This);
389 }
390
391 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
392     HTMLBodyElement_QueryInterface,
393     HTMLBodyElement_AddRef,
394     HTMLBodyElement_Release,
395     HTMLBodyElement_GetTypeInfoCount,
396     HTMLBodyElement_GetTypeInfo,
397     HTMLBodyElement_GetIDsOfNames,
398     HTMLBodyElement_Invoke,
399     HTMLBodyElement_put_background,
400     HTMLBodyElement_get_background,
401     HTMLBodyElement_put_bgProperties,
402     HTMLBodyElement_get_bgProperties,
403     HTMLBodyElement_put_leftMargin,
404     HTMLBodyElement_get_leftMargin,
405     HTMLBodyElement_put_topMargin,
406     HTMLBodyElement_get_topMargin,
407     HTMLBodyElement_put_rightMargin,
408     HTMLBodyElement_get_rightMargin,
409     HTMLBodyElement_put_bottomMargin,
410     HTMLBodyElement_get_bottomMargin,
411     HTMLBodyElement_put_noWrap,
412     HTMLBodyElement_get_noWrap,
413     HTMLBodyElement_put_bgColor,
414     HTMLBodyElement_get_bgColor,
415     HTMLBodyElement_put_text,
416     HTMLBodyElement_get_text,
417     HTMLBodyElement_put_link,
418     HTMLBodyElement_get_link,
419     HTMLBodyElement_put_vLink,
420     HTMLBodyElement_get_vLink,
421     HTMLBodyElement_put_aLink,
422     HTMLBodyElement_get_aLink,
423     HTMLBodyElement_put_onload,
424     HTMLBodyElement_get_onload,
425     HTMLBodyElement_put_onunload,
426     HTMLBodyElement_get_onunload,
427     HTMLBodyElement_put_scroll,
428     HTMLBodyElement_get_scroll,
429     HTMLBodyElement_put_onselect,
430     HTMLBodyElement_get_onselect,
431     HTMLBodyElement_put_onbeforeunload,
432     HTMLBodyElement_get_onbeforeunload,
433     HTMLBodyElement_createTextRange
434 };
435
436 void HTMLBodyElement_Create(HTMLElement *element)
437 {
438     HTMLBodyElement *ret = mshtml_alloc(sizeof(HTMLBodyElement));
439     nsresult nsres;
440
441     ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
442     ret->element = element;
443
444     HTMLTextContainer_Init(&ret->text_container, element);
445
446     nsres = nsIDOMHTMLElement_QueryInterface(element->nselem, &IID_nsIDOMHTMLBodyElement,
447                                              (void**)&ret->nsbody);
448     if(NS_FAILED(nsres))
449         ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
450
451     element->impl = (IUnknown*)HTMLBODY(ret);
452     element->destructor = HTMLBodyElement_destructor;
453 }