include: Define more wuapi interfaces to avoid undefined forward declarations.
[wine] / dlls / mshtml / htmlobject.c
1 /*
2  * Copyright 2010 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 <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 typedef struct {
36     HTMLElement element;
37
38     IHTMLObjectElement IHTMLObjectElement_iface;
39
40     nsIDOMHTMLObjectElement *nsobject;
41 } HTMLObjectElement;
42
43 static inline HTMLObjectElement *impl_from_IHTMLObjectElement(IHTMLObjectElement *iface)
44 {
45     return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement_iface);
46 }
47
48 static HRESULT WINAPI HTMLObjectElement_QueryInterface(IHTMLObjectElement *iface,
49         REFIID riid, void **ppv)
50 {
51     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
52
53     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 }
55
56 static ULONG WINAPI HTMLObjectElement_AddRef(IHTMLObjectElement *iface)
57 {
58     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
59
60     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 }
62
63 static ULONG WINAPI HTMLObjectElement_Release(IHTMLObjectElement *iface)
64 {
65     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
66
67     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 }
69
70 static HRESULT WINAPI HTMLObjectElement_GetTypeInfoCount(IHTMLObjectElement *iface, UINT *pctinfo)
71 {
72     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
73     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
74 }
75
76 static HRESULT WINAPI HTMLObjectElement_GetTypeInfo(IHTMLObjectElement *iface, UINT iTInfo,
77                                               LCID lcid, ITypeInfo **ppTInfo)
78 {
79     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
80     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
81 }
82
83 static HRESULT WINAPI HTMLObjectElement_GetIDsOfNames(IHTMLObjectElement *iface, REFIID riid,
84                                                 LPOLESTR *rgszNames, UINT cNames,
85                                                 LCID lcid, DISPID *rgDispId)
86 {
87     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
88     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
89 }
90
91 static HRESULT WINAPI HTMLObjectElement_Invoke(IHTMLObjectElement *iface, DISPID dispIdMember,
92                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
93                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
94 {
95     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
96     return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
97             pVarResult, pExcepInfo, puArgErr);
98 }
99
100 static HRESULT WINAPI HTMLObjectElement_get_object(IHTMLObjectElement *iface, IDispatch **p)
101 {
102     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
103     FIXME("(%p)->(%p)\n", This, p);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI HTMLObjectElement_get_classid(IHTMLObjectElement *iface, BSTR *p)
108 {
109     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
110     FIXME("(%p)->(%p)\n", This, p);
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI HTMLObjectElement_get_data(IHTMLObjectElement *iface, BSTR *p)
115 {
116     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
117     FIXME("(%p)->(%p)\n", This, p);
118     return E_NOTIMPL;
119 }
120
121 static HRESULT WINAPI HTMLObjectElement_put_recordset(IHTMLObjectElement *iface, IDispatch *v)
122 {
123     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
124     FIXME("(%p)->(%p)\n", This, v);
125     return E_NOTIMPL;
126 }
127
128 static HRESULT WINAPI HTMLObjectElement_get_recordset(IHTMLObjectElement *iface, IDispatch **p)
129 {
130     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
131     FIXME("(%p)->(%p)\n", This, p);
132     return E_NOTIMPL;
133 }
134
135 static HRESULT WINAPI HTMLObjectElement_put_align(IHTMLObjectElement *iface, BSTR v)
136 {
137     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
138     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
139     return E_NOTIMPL;
140 }
141
142 static HRESULT WINAPI HTMLObjectElement_get_align(IHTMLObjectElement *iface, BSTR *p)
143 {
144     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
145     FIXME("(%p)->(%p)\n", This, p);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI HTMLObjectElement_put_name(IHTMLObjectElement *iface, BSTR v)
150 {
151     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
152     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
153     return E_NOTIMPL;
154 }
155
156 static HRESULT WINAPI HTMLObjectElement_get_name(IHTMLObjectElement *iface, BSTR *p)
157 {
158     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
159     FIXME("(%p)->(%p)\n", This, p);
160     return E_NOTIMPL;
161 }
162
163 static HRESULT WINAPI HTMLObjectElement_put_codeBase(IHTMLObjectElement *iface, BSTR v)
164 {
165     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
166     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI HTMLObjectElement_get_codeBase(IHTMLObjectElement *iface, BSTR *p)
171 {
172     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
173     FIXME("(%p)->(%p)\n", This, p);
174     return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI HTMLObjectElement_put_codeType(IHTMLObjectElement *iface, BSTR v)
178 {
179     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
180     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
181     return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI HTMLObjectElement_get_codeType(IHTMLObjectElement *iface, BSTR *p)
185 {
186     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
187     FIXME("(%p)->(%p)\n", This, p);
188     return E_NOTIMPL;
189 }
190
191 static HRESULT WINAPI HTMLObjectElement_put_code(IHTMLObjectElement *iface, BSTR v)
192 {
193     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
194     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
195     return E_NOTIMPL;
196 }
197
198 static HRESULT WINAPI HTMLObjectElement_get_code(IHTMLObjectElement *iface, BSTR *p)
199 {
200     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
201     FIXME("(%p)->(%p)\n", This, p);
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI HTMLObjectElement_get_BaseHref(IHTMLObjectElement *iface, BSTR *p)
206 {
207     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
208     FIXME("(%p)->(%p)\n", This, p);
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI HTMLObjectElement_put_type(IHTMLObjectElement *iface, BSTR v)
213 {
214     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
215     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI HTMLObjectElement_get_type(IHTMLObjectElement *iface, BSTR *p)
220 {
221     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
222     FIXME("(%p)->(%p)\n", This, p);
223     return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI HTMLObjectElement_get_form(IHTMLObjectElement *iface, IHTMLFormElement **p)
227 {
228     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
229     FIXME("(%p)->(%p)\n", This, p);
230     return E_NOTIMPL;
231 }
232
233 static HRESULT WINAPI HTMLObjectElement_put_width(IHTMLObjectElement *iface, VARIANT v)
234 {
235     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
236     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
237     return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI HTMLObjectElement_get_width(IHTMLObjectElement *iface, VARIANT *p)
241 {
242     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
243     FIXME("(%p)->(%p)\n", This, p);
244     return E_NOTIMPL;
245 }
246
247 static HRESULT WINAPI HTMLObjectElement_put_height(IHTMLObjectElement *iface, VARIANT v)
248 {
249     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
250     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
251     return E_NOTIMPL;
252 }
253
254 static HRESULT WINAPI HTMLObjectElement_get_height(IHTMLObjectElement *iface, VARIANT *p)
255 {
256     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
257     FIXME("(%p)->(%p)\n", This, p);
258     return E_NOTIMPL;
259 }
260
261 static HRESULT WINAPI HTMLObjectElement_get_readyState(IHTMLObjectElement *iface, LONG *p)
262 {
263     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
264     FIXME("(%p)->(%p)\n", This, p);
265     return E_NOTIMPL;
266 }
267
268 static HRESULT WINAPI HTMLObjectElement_put_onreadystatechange(IHTMLObjectElement *iface, VARIANT v)
269 {
270     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
271     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
272     return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI HTMLObjectElement_get_onreadystatechange(IHTMLObjectElement *iface, VARIANT *p)
276 {
277     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
278     FIXME("(%p)->(%p)\n", This, p);
279     return E_NOTIMPL;
280 }
281
282 static HRESULT WINAPI HTMLObjectElement_put_onerror(IHTMLObjectElement *iface, VARIANT v)
283 {
284     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
285     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
286     return E_NOTIMPL;
287 }
288
289 static HRESULT WINAPI HTMLObjectElement_get_onerror(IHTMLObjectElement *iface, VARIANT *p)
290 {
291     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
292     FIXME("(%p)->(%p)\n", This, p);
293     return E_NOTIMPL;
294 }
295
296 static HRESULT WINAPI HTMLObjectElement_put_altHtml(IHTMLObjectElement *iface, BSTR v)
297 {
298     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
299     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
300     return E_NOTIMPL;
301 }
302
303 static HRESULT WINAPI HTMLObjectElement_get_altHtml(IHTMLObjectElement *iface, BSTR *p)
304 {
305     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
306     FIXME("(%p)->(%p)\n", This, p);
307     return E_NOTIMPL;
308 }
309
310 static HRESULT WINAPI HTMLObjectElement_put_vspace(IHTMLObjectElement *iface, LONG v)
311 {
312     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
313     FIXME("(%p)->(%d)\n", This, v);
314     return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI HTMLObjectElement_get_vspace(IHTMLObjectElement *iface, LONG *p)
318 {
319     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
320     PRInt32 vspace;
321     nsresult nsres;
322
323     TRACE("(%p)->(%p)\n", This, p);
324
325     nsres = nsIDOMHTMLObjectElement_GetVspace(This->nsobject, &vspace);
326     if(NS_FAILED(nsres)) {
327         ERR("GetVspace failed: %08x\n", nsres);
328         return E_FAIL;
329     }
330
331     *p = vspace;
332     return S_OK;
333 }
334
335 static HRESULT WINAPI HTMLObjectElement_put_hspace(IHTMLObjectElement *iface, LONG v)
336 {
337     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
338     FIXME("(%p)->(%d)\n", This, v);
339     return E_NOTIMPL;
340 }
341
342 static HRESULT WINAPI HTMLObjectElement_get_hspace(IHTMLObjectElement *iface, LONG *p)
343 {
344     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
345     FIXME("(%p)->(%p)\n", This, p);
346     return E_NOTIMPL;
347 }
348
349 static const IHTMLObjectElementVtbl HTMLObjectElementVtbl = {
350     HTMLObjectElement_QueryInterface,
351     HTMLObjectElement_AddRef,
352     HTMLObjectElement_Release,
353     HTMLObjectElement_GetTypeInfoCount,
354     HTMLObjectElement_GetTypeInfo,
355     HTMLObjectElement_GetIDsOfNames,
356     HTMLObjectElement_Invoke,
357     HTMLObjectElement_get_object,
358     HTMLObjectElement_get_classid,
359     HTMLObjectElement_get_data,
360     HTMLObjectElement_put_recordset,
361     HTMLObjectElement_get_recordset,
362     HTMLObjectElement_put_align,
363     HTMLObjectElement_get_align,
364     HTMLObjectElement_put_name,
365     HTMLObjectElement_get_name,
366     HTMLObjectElement_put_codeBase,
367     HTMLObjectElement_get_codeBase,
368     HTMLObjectElement_put_codeType,
369     HTMLObjectElement_get_codeType,
370     HTMLObjectElement_put_code,
371     HTMLObjectElement_get_code,
372     HTMLObjectElement_get_BaseHref,
373     HTMLObjectElement_put_type,
374     HTMLObjectElement_get_type,
375     HTMLObjectElement_get_form,
376     HTMLObjectElement_put_width,
377     HTMLObjectElement_get_width,
378     HTMLObjectElement_put_height,
379     HTMLObjectElement_get_height,
380     HTMLObjectElement_get_readyState,
381     HTMLObjectElement_put_onreadystatechange,
382     HTMLObjectElement_get_onreadystatechange,
383     HTMLObjectElement_put_onerror,
384     HTMLObjectElement_get_onerror,
385     HTMLObjectElement_put_altHtml,
386     HTMLObjectElement_get_altHtml,
387     HTMLObjectElement_put_vspace,
388     HTMLObjectElement_get_vspace,
389     HTMLObjectElement_put_hspace,
390     HTMLObjectElement_get_hspace
391 };
392
393 #define HTMLOBJECT_NODE_THIS(iface) DEFINE_THIS2(HTMLObjectElement, element.node, iface)
394
395 static HRESULT HTMLObjectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
396 {
397     HTMLObjectElement *This = HTMLOBJECT_NODE_THIS(iface);
398
399     if(IsEqualGUID(&IID_IUnknown, riid)) {
400         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
401         *ppv = &This->IHTMLObjectElement_iface;
402     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
403         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
404         *ppv = &This->IHTMLObjectElement_iface;
405     }else if(IsEqualGUID(&IID_IHTMLObjectElement, riid)) {
406         TRACE("(%p)->(IID_IHTMLObjectElement %p)\n", This, ppv);
407         *ppv = &This->IHTMLObjectElement_iface;
408     }else {
409         return HTMLElement_QI(&This->element.node, riid, ppv);
410     }
411
412     IUnknown_AddRef((IUnknown*)*ppv);
413     return S_OK;
414 }
415
416 static void HTMLObjectElement_destructor(HTMLDOMNode *iface)
417 {
418     HTMLObjectElement *This = HTMLOBJECT_NODE_THIS(iface);
419
420     if(This->nsobject)
421         nsIDOMHTMLObjectElement_Release(This->nsobject);
422
423     HTMLElement_destructor(&This->element.node);
424 }
425
426 static HRESULT HTMLObjectElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
427 {
428     HTMLObjectElement *This = HTMLOBJECT_NODE_THIS(iface);
429     FIXME("(%p)->(%p)\n", This, p);
430     return E_NOTIMPL;
431 }
432
433 #undef HTMLOBJECT_NODE_THIS
434
435 static const NodeImplVtbl HTMLObjectElementImplVtbl = {
436     HTMLObjectElement_QI,
437     HTMLObjectElement_destructor,
438     HTMLElement_clone,
439     NULL,
440     NULL,
441     NULL,
442     NULL,
443     NULL,
444     HTMLObjectElement_get_readystate
445 };
446
447 static const tid_t HTMLObjectElement_iface_tids[] = {
448     HTMLELEMENT_TIDS,
449     IHTMLObjectElement_tid,
450     0
451 };
452 static dispex_static_data_t HTMLObjectElement_dispex = {
453     NULL,
454     DispHTMLObjectElement_tid,
455     NULL,
456     HTMLObjectElement_iface_tids
457 };
458
459 HRESULT HTMLObjectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
460 {
461     HTMLObjectElement *ret;
462     nsresult nsres;
463
464     ret = heap_alloc_zero(sizeof(*ret));
465     if(!ret)
466         return E_OUTOFMEMORY;
467
468     ret->IHTMLObjectElement_iface.lpVtbl = &HTMLObjectElementVtbl;
469     ret->element.node.vtbl = &HTMLObjectElementImplVtbl;
470
471     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLObjectElement, (void**)&ret->nsobject);
472     if(NS_FAILED(nsres)) {
473         ERR("Could not get nsIDOMHTMLObjectElement iface: %08x\n", nsres);
474         heap_free(ret);
475         return E_FAIL;
476     }
477
478     HTMLElement_Init(&ret->element, doc, nselem, &HTMLObjectElement_dispex);
479
480     *elem = &ret->element;
481     return S_OK;
482 }