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