atl80: Added AtlComModuleRegisterServer implementation (based on AtlModuleRegisterSer...
[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 #include <assert.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
29
30 #include "wine/debug.h"
31
32 #include "mshtml_private.h"
33 #include "pluginhost.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 typedef struct {
38     HTMLPluginContainer plugin_container;
39
40     IHTMLObjectElement IHTMLObjectElement_iface;
41     IHTMLObjectElement2 IHTMLObjectElement2_iface;
42
43     nsIDOMHTMLObjectElement *nsobject;
44 } HTMLObjectElement;
45
46 static inline HTMLObjectElement *impl_from_IHTMLObjectElement(IHTMLObjectElement *iface)
47 {
48     return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement_iface);
49 }
50
51 static HRESULT WINAPI HTMLObjectElement_QueryInterface(IHTMLObjectElement *iface,
52         REFIID riid, void **ppv)
53 {
54     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
55
56     return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
57             riid, ppv);
58 }
59
60 static ULONG WINAPI HTMLObjectElement_AddRef(IHTMLObjectElement *iface)
61 {
62     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
63
64     return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
65 }
66
67 static ULONG WINAPI HTMLObjectElement_Release(IHTMLObjectElement *iface)
68 {
69     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
70
71     return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
72 }
73
74 static HRESULT WINAPI HTMLObjectElement_GetTypeInfoCount(IHTMLObjectElement *iface, UINT *pctinfo)
75 {
76     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
77     return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
78             pctinfo);
79 }
80
81 static HRESULT WINAPI HTMLObjectElement_GetTypeInfo(IHTMLObjectElement *iface, UINT iTInfo,
82                                               LCID lcid, ITypeInfo **ppTInfo)
83 {
84     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
85     return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
86             iTInfo, lcid, ppTInfo);
87 }
88
89 static HRESULT WINAPI HTMLObjectElement_GetIDsOfNames(IHTMLObjectElement *iface, REFIID riid,
90                                                 LPOLESTR *rgszNames, UINT cNames,
91                                                 LCID lcid, DISPID *rgDispId)
92 {
93     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
94     return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
95             riid, rgszNames, cNames, lcid, rgDispId);
96 }
97
98 static HRESULT WINAPI HTMLObjectElement_Invoke(IHTMLObjectElement *iface, DISPID dispIdMember,
99                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
100                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
101 {
102     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
103     return IDispatchEx_Invoke(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
104             dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
105 }
106
107 static HRESULT WINAPI HTMLObjectElement_get_object(IHTMLObjectElement *iface, IDispatch **p)
108 {
109     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
110
111     TRACE("(%p)->(%p)\n", This, p);
112
113     return get_plugin_disp(&This->plugin_container, p);
114 }
115
116 static HRESULT WINAPI HTMLObjectElement_get_classid(IHTMLObjectElement *iface, BSTR *p)
117 {
118     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
119
120     TRACE("(%p)->(%p)\n", This, p);
121
122     return IHTMLObjectElement2_get_classid(&This->IHTMLObjectElement2_iface, p);
123 }
124
125 static HRESULT WINAPI HTMLObjectElement_get_data(IHTMLObjectElement *iface, BSTR *p)
126 {
127     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
128
129     TRACE("(%p)->(%p)\n", This, p);
130
131     return IHTMLObjectElement2_get_data(&This->IHTMLObjectElement2_iface, p);
132 }
133
134 static HRESULT WINAPI HTMLObjectElement_put_recordset(IHTMLObjectElement *iface, IDispatch *v)
135 {
136     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
137     FIXME("(%p)->(%p)\n", This, v);
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI HTMLObjectElement_get_recordset(IHTMLObjectElement *iface, IDispatch **p)
142 {
143     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
144     FIXME("(%p)->(%p)\n", This, p);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLObjectElement_put_align(IHTMLObjectElement *iface, BSTR v)
149 {
150     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
151     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI HTMLObjectElement_get_align(IHTMLObjectElement *iface, BSTR *p)
156 {
157     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
158     FIXME("(%p)->(%p)\n", This, p);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HTMLObjectElement_put_name(IHTMLObjectElement *iface, BSTR v)
163 {
164     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
165     nsAString nsstr;
166     nsresult nsres;
167
168     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
169
170     nsAString_InitDepend(&nsstr, v);
171     nsres = nsIDOMHTMLObjectElement_SetName(This->nsobject, &nsstr);
172     nsAString_Finish(&nsstr);
173     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
174 }
175
176 static HRESULT WINAPI HTMLObjectElement_get_name(IHTMLObjectElement *iface, BSTR *p)
177 {
178     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
179     nsAString nsstr;
180     nsresult nsres;
181
182     TRACE("(%p)->(%p)\n", This, p);
183
184     nsAString_Init(&nsstr, NULL);
185     nsres = nsIDOMHTMLObjectElement_GetName(This->nsobject, &nsstr);
186     return return_nsstr(nsres, &nsstr, p);
187 }
188
189 static HRESULT WINAPI HTMLObjectElement_put_codeBase(IHTMLObjectElement *iface, BSTR v)
190 {
191     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
192     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
193     return E_NOTIMPL;
194 }
195
196 static HRESULT WINAPI HTMLObjectElement_get_codeBase(IHTMLObjectElement *iface, BSTR *p)
197 {
198     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
199     FIXME("(%p)->(%p)\n", This, p);
200     return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI HTMLObjectElement_put_codeType(IHTMLObjectElement *iface, BSTR v)
204 {
205     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
206     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
207     return E_NOTIMPL;
208 }
209
210 static HRESULT WINAPI HTMLObjectElement_get_codeType(IHTMLObjectElement *iface, BSTR *p)
211 {
212     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
213     FIXME("(%p)->(%p)\n", This, p);
214     return E_NOTIMPL;
215 }
216
217 static HRESULT WINAPI HTMLObjectElement_put_code(IHTMLObjectElement *iface, BSTR v)
218 {
219     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
220     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
221     return E_NOTIMPL;
222 }
223
224 static HRESULT WINAPI HTMLObjectElement_get_code(IHTMLObjectElement *iface, BSTR *p)
225 {
226     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
227     FIXME("(%p)->(%p)\n", This, p);
228     return E_NOTIMPL;
229 }
230
231 static HRESULT WINAPI HTMLObjectElement_get_BaseHref(IHTMLObjectElement *iface, BSTR *p)
232 {
233     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
234     FIXME("(%p)->(%p)\n", This, p);
235     return E_NOTIMPL;
236 }
237
238 static HRESULT WINAPI HTMLObjectElement_put_type(IHTMLObjectElement *iface, BSTR v)
239 {
240     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
241     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI HTMLObjectElement_get_type(IHTMLObjectElement *iface, BSTR *p)
246 {
247     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
248     FIXME("(%p)->(%p)\n", This, p);
249     return E_NOTIMPL;
250 }
251
252 static HRESULT WINAPI HTMLObjectElement_get_form(IHTMLObjectElement *iface, IHTMLFormElement **p)
253 {
254     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
255     FIXME("(%p)->(%p)\n", This, p);
256     return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI HTMLObjectElement_put_width(IHTMLObjectElement *iface, VARIANT v)
260 {
261     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
262     nsAString width_str;
263     PRUnichar buf[12];
264     nsresult nsres;
265
266     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
267
268     switch(V_VT(&v)) {
269     case VT_I4: {
270         static const WCHAR formatW[] = {'%','d',0};
271         sprintfW(buf, formatW, V_I4(&v));
272         break;
273     }
274     default:
275         FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
276         return E_NOTIMPL;
277     }
278
279     nsAString_InitDepend(&width_str, buf);
280     nsres = nsIDOMHTMLObjectElement_SetWidth(This->nsobject, &width_str);
281     nsAString_Finish(&width_str);
282     if(NS_FAILED(nsres)) {
283         FIXME("SetWidth failed: %08x\n", nsres);
284         return E_FAIL;
285     }
286
287     notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
288     return S_OK;
289 }
290
291 static HRESULT WINAPI HTMLObjectElement_get_width(IHTMLObjectElement *iface, VARIANT *p)
292 {
293     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
294     nsAString width_str;
295     nsresult nsres;
296     HRESULT hres;
297
298     TRACE("(%p)->(%p)\n", This, p);
299
300     nsAString_Init(&width_str, NULL);
301     nsres = nsIDOMHTMLObjectElement_GetWidth(This->nsobject, &width_str);
302     if(NS_SUCCEEDED(nsres)) {
303         const PRUnichar *width;
304
305         nsAString_GetData(&width_str, &width);
306         V_VT(p) = VT_BSTR;
307         V_BSTR(p) = SysAllocString(width);
308         hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
309     }else {
310         ERR("GetWidth failed: %08x\n", nsres);
311         hres = E_FAIL;
312     }
313
314     nsAString_Finish(&width_str);
315     return hres;
316 }
317
318 static HRESULT WINAPI HTMLObjectElement_put_height(IHTMLObjectElement *iface, VARIANT v)
319 {
320     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
321     nsAString height_str;
322     PRUnichar buf[12];
323     nsresult nsres;
324
325     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
326
327     switch(V_VT(&v)) {
328     case VT_I4: {
329         static const WCHAR formatW[] = {'%','d',0};
330         sprintfW(buf, formatW, V_I4(&v));
331         break;
332     }
333     default:
334         FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
335         return E_NOTIMPL;
336     }
337
338     nsAString_InitDepend(&height_str, buf);
339     nsres = nsIDOMHTMLObjectElement_SetHeight(This->nsobject, &height_str);
340     nsAString_Finish(&height_str);
341     if(NS_FAILED(nsres)) {
342         FIXME("SetHeight failed: %08x\n", nsres);
343         return E_FAIL;
344     }
345
346     notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
347     return S_OK;
348 }
349
350 static HRESULT WINAPI HTMLObjectElement_get_height(IHTMLObjectElement *iface, VARIANT *p)
351 {
352     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
353     nsAString height_str;
354     nsresult nsres;
355     HRESULT hres;
356
357     TRACE("(%p)->(%p)\n", This, p);
358
359     nsAString_Init(&height_str, NULL);
360     nsres = nsIDOMHTMLObjectElement_GetHeight(This->nsobject, &height_str);
361     if(NS_SUCCEEDED(nsres)) {
362         const PRUnichar *height;
363
364         nsAString_GetData(&height_str, &height);
365         V_VT(p) = VT_BSTR;
366         V_BSTR(p) = SysAllocString(height);
367         hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
368     }else {
369         ERR("GetHeight failed: %08x\n", nsres);
370         hres = E_FAIL;
371     }
372
373     nsAString_Finish(&height_str);
374     return hres;
375 }
376
377 static HRESULT WINAPI HTMLObjectElement_get_readyState(IHTMLObjectElement *iface, LONG *p)
378 {
379     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
380     FIXME("(%p)->(%p)\n", This, p);
381     return E_NOTIMPL;
382 }
383
384 static HRESULT WINAPI HTMLObjectElement_put_onreadystatechange(IHTMLObjectElement *iface, VARIANT v)
385 {
386     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
387     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
388     return E_NOTIMPL;
389 }
390
391 static HRESULT WINAPI HTMLObjectElement_get_onreadystatechange(IHTMLObjectElement *iface, VARIANT *p)
392 {
393     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
394     FIXME("(%p)->(%p)\n", This, p);
395     return E_NOTIMPL;
396 }
397
398 static HRESULT WINAPI HTMLObjectElement_put_onerror(IHTMLObjectElement *iface, VARIANT v)
399 {
400     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
401     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
402     return E_NOTIMPL;
403 }
404
405 static HRESULT WINAPI HTMLObjectElement_get_onerror(IHTMLObjectElement *iface, VARIANT *p)
406 {
407     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
408     FIXME("(%p)->(%p)\n", This, p);
409     return E_NOTIMPL;
410 }
411
412 static HRESULT WINAPI HTMLObjectElement_put_altHtml(IHTMLObjectElement *iface, BSTR v)
413 {
414     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
415     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
416     return E_NOTIMPL;
417 }
418
419 static HRESULT WINAPI HTMLObjectElement_get_altHtml(IHTMLObjectElement *iface, BSTR *p)
420 {
421     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
422     FIXME("(%p)->(%p)\n", This, p);
423     return E_NOTIMPL;
424 }
425
426 static HRESULT WINAPI HTMLObjectElement_put_vspace(IHTMLObjectElement *iface, LONG v)
427 {
428     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
429     FIXME("(%p)->(%d)\n", This, v);
430     return E_NOTIMPL;
431 }
432
433 static HRESULT WINAPI HTMLObjectElement_get_vspace(IHTMLObjectElement *iface, LONG *p)
434 {
435     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
436     PRInt32 vspace;
437     nsresult nsres;
438
439     TRACE("(%p)->(%p)\n", This, p);
440
441     nsres = nsIDOMHTMLObjectElement_GetVspace(This->nsobject, &vspace);
442     if(NS_FAILED(nsres)) {
443         ERR("GetVspace failed: %08x\n", nsres);
444         return E_FAIL;
445     }
446
447     *p = vspace;
448     return S_OK;
449 }
450
451 static HRESULT WINAPI HTMLObjectElement_put_hspace(IHTMLObjectElement *iface, LONG v)
452 {
453     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
454     FIXME("(%p)->(%d)\n", This, v);
455     return E_NOTIMPL;
456 }
457
458 static HRESULT WINAPI HTMLObjectElement_get_hspace(IHTMLObjectElement *iface, LONG *p)
459 {
460     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
461     FIXME("(%p)->(%p)\n", This, p);
462     return E_NOTIMPL;
463 }
464
465 static const IHTMLObjectElementVtbl HTMLObjectElementVtbl = {
466     HTMLObjectElement_QueryInterface,
467     HTMLObjectElement_AddRef,
468     HTMLObjectElement_Release,
469     HTMLObjectElement_GetTypeInfoCount,
470     HTMLObjectElement_GetTypeInfo,
471     HTMLObjectElement_GetIDsOfNames,
472     HTMLObjectElement_Invoke,
473     HTMLObjectElement_get_object,
474     HTMLObjectElement_get_classid,
475     HTMLObjectElement_get_data,
476     HTMLObjectElement_put_recordset,
477     HTMLObjectElement_get_recordset,
478     HTMLObjectElement_put_align,
479     HTMLObjectElement_get_align,
480     HTMLObjectElement_put_name,
481     HTMLObjectElement_get_name,
482     HTMLObjectElement_put_codeBase,
483     HTMLObjectElement_get_codeBase,
484     HTMLObjectElement_put_codeType,
485     HTMLObjectElement_get_codeType,
486     HTMLObjectElement_put_code,
487     HTMLObjectElement_get_code,
488     HTMLObjectElement_get_BaseHref,
489     HTMLObjectElement_put_type,
490     HTMLObjectElement_get_type,
491     HTMLObjectElement_get_form,
492     HTMLObjectElement_put_width,
493     HTMLObjectElement_get_width,
494     HTMLObjectElement_put_height,
495     HTMLObjectElement_get_height,
496     HTMLObjectElement_get_readyState,
497     HTMLObjectElement_put_onreadystatechange,
498     HTMLObjectElement_get_onreadystatechange,
499     HTMLObjectElement_put_onerror,
500     HTMLObjectElement_get_onerror,
501     HTMLObjectElement_put_altHtml,
502     HTMLObjectElement_get_altHtml,
503     HTMLObjectElement_put_vspace,
504     HTMLObjectElement_get_vspace,
505     HTMLObjectElement_put_hspace,
506     HTMLObjectElement_get_hspace
507 };
508
509 static inline HTMLObjectElement *impl_from_IHTMLObjectElement2(IHTMLObjectElement2 *iface)
510 {
511     return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement2_iface);
512 }
513
514 static HRESULT WINAPI HTMLObjectElement2_QueryInterface(IHTMLObjectElement2 *iface,
515         REFIID riid, void **ppv)
516 {
517     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
518
519     return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
520             riid, ppv);
521 }
522
523 static ULONG WINAPI HTMLObjectElement2_AddRef(IHTMLObjectElement2 *iface)
524 {
525     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
526
527     return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
528 }
529
530 static ULONG WINAPI HTMLObjectElement2_Release(IHTMLObjectElement2 *iface)
531 {
532     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
533
534     return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
535 }
536
537 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfoCount(IHTMLObjectElement2 *iface, UINT *pctinfo)
538 {
539     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
540     return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
541             pctinfo);
542 }
543
544 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfo(IHTMLObjectElement2 *iface, UINT iTInfo,
545                                               LCID lcid, ITypeInfo **ppTInfo)
546 {
547     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
548     return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
549             iTInfo, lcid, ppTInfo);
550 }
551
552 static HRESULT WINAPI HTMLObjectElement2_GetIDsOfNames(IHTMLObjectElement2 *iface, REFIID riid,
553         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
554 {
555     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
556     return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
557             riid, rgszNames, cNames, lcid, rgDispId);
558 }
559
560 static HRESULT WINAPI HTMLObjectElement2_Invoke(IHTMLObjectElement2 *iface, DISPID dispIdMember,
561         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
562         EXCEPINFO *pExcepInfo, UINT *puArgErr)
563 {
564     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
565     return IDispatchEx_Invoke(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
566             dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
567 }
568
569 static HRESULT WINAPI HTMLObjectElement2_namedRecordset(IHTMLObjectElement2 *iface, BSTR dataMember,
570         VARIANT *hierarchy, IDispatch **ppRecordset)
571 {
572     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
573     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
574     return E_NOTIMPL;
575 }
576
577 static HRESULT WINAPI HTMLObjectElement2_put_classid(IHTMLObjectElement2 *iface, BSTR v)
578 {
579     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
580     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
581     return E_NOTIMPL;
582 }
583
584 static HRESULT WINAPI HTMLObjectElement2_get_classid(IHTMLObjectElement2 *iface, BSTR *p)
585 {
586     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
587     FIXME("(%p)->(%p)\n", This, p);
588     return E_NOTIMPL;
589 }
590
591 static HRESULT WINAPI HTMLObjectElement2_put_data(IHTMLObjectElement2 *iface, BSTR v)
592 {
593     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
594     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
595     return E_NOTIMPL;
596 }
597
598 static HRESULT WINAPI HTMLObjectElement2_get_data(IHTMLObjectElement2 *iface, BSTR *p)
599 {
600     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
601     FIXME("(%p)->(%p)\n", This, p);
602     return E_NOTIMPL;
603 }
604
605 static const IHTMLObjectElement2Vtbl HTMLObjectElement2Vtbl = {
606     HTMLObjectElement2_QueryInterface,
607     HTMLObjectElement2_AddRef,
608     HTMLObjectElement2_Release,
609     HTMLObjectElement2_GetTypeInfoCount,
610     HTMLObjectElement2_GetTypeInfo,
611     HTMLObjectElement2_GetIDsOfNames,
612     HTMLObjectElement2_Invoke,
613     HTMLObjectElement2_namedRecordset,
614     HTMLObjectElement2_put_classid,
615     HTMLObjectElement2_get_classid,
616     HTMLObjectElement2_put_data,
617     HTMLObjectElement2_get_data
618 };
619
620 static inline HTMLObjectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
621 {
622     return CONTAINING_RECORD(iface, HTMLObjectElement, plugin_container.element.node);
623 }
624
625 static HRESULT HTMLObjectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
626 {
627     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
628
629     if(IsEqualGUID(&IID_IUnknown, riid)) {
630         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
631         *ppv = &This->IHTMLObjectElement_iface;
632     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
633         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
634         *ppv = &This->IHTMLObjectElement_iface;
635     }else if(IsEqualGUID(&IID_IHTMLObjectElement, riid)) {
636         TRACE("(%p)->(IID_IHTMLObjectElement %p)\n", This, ppv);
637         *ppv = &This->IHTMLObjectElement_iface;
638     }else if(IsEqualGUID(&IID_IHTMLObjectElement2, riid)) {
639         TRACE("(%p)->(IID_IHTMLObjectElement2 %p)\n", This, ppv);
640         *ppv = &This->IHTMLObjectElement2_iface;
641     }else if(IsEqualGUID(&IID_HTMLPluginContainer, riid)) {
642         TRACE("(%p)->(IID_HTMLPluginContainer %p)\n", This, ppv);
643         *ppv = &This->plugin_container;
644         return S_OK;
645     }else {
646         HRESULT hres;
647
648         hres = HTMLElement_QI(&This->plugin_container.element.node, riid, ppv);
649         if(hres == E_NOINTERFACE && This->plugin_container.plugin_host && This->plugin_container.plugin_host->plugin_unk) {
650             IUnknown *plugin_iface, *ret;
651
652             hres = IUnknown_QueryInterface(This->plugin_container.plugin_host->plugin_unk, riid, (void**)&plugin_iface);
653             if(hres == S_OK) {
654                 hres = wrap_iface(plugin_iface, (IUnknown*)&This->IHTMLObjectElement_iface, &ret);
655                 IUnknown_Release(plugin_iface);
656                 if(FAILED(hres))
657                     return hres;
658
659                 TRACE("returning plugin iface %p wrapped to %p\n", plugin_iface, ret);
660                 *ppv = ret;
661                 return S_OK;
662             }
663         }
664
665         return hres;
666     }
667
668     IUnknown_AddRef((IUnknown*)*ppv);
669     return S_OK;
670 }
671
672 static void HTMLObjectElement_destructor(HTMLDOMNode *iface)
673 {
674     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
675
676     if(This->plugin_container.plugin_host)
677         detach_plugin_host(This->plugin_container.plugin_host);
678
679     HTMLElement_destructor(&This->plugin_container.element.node);
680 }
681
682 static HRESULT HTMLObjectElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
683 {
684     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
685     FIXME("(%p)->(%p)\n", This, p);
686     return E_NOTIMPL;
687 }
688
689 static HRESULT HTMLObjectElement_get_dispid(HTMLDOMNode *iface, BSTR name,
690         DWORD grfdex, DISPID *pid)
691 {
692     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
693
694     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), grfdex, pid);
695
696     return get_plugin_dispid(&This->plugin_container, name, pid);
697 }
698
699 static HRESULT HTMLObjectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
700         WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
701 {
702     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
703
704     TRACE("(%p)->(%d)\n", This, id);
705
706     return invoke_plugin_prop(&This->plugin_container, id, lcid, flags, params, res, ei);
707 }
708
709 static const NodeImplVtbl HTMLObjectElementImplVtbl = {
710     HTMLObjectElement_QI,
711     HTMLObjectElement_destructor,
712     HTMLElement_clone,
713     HTMLElement_handle_event,
714     HTMLElement_get_attr_col,
715     NULL,
716     NULL,
717     NULL,
718     NULL,
719     NULL,
720     HTMLObjectElement_get_readystate,
721     HTMLObjectElement_get_dispid,
722     HTMLObjectElement_invoke
723 };
724
725 static const tid_t HTMLObjectElement_iface_tids[] = {
726     HTMLELEMENT_TIDS,
727     IHTMLObjectElement_tid,
728     IHTMLObjectElement2_tid,
729     0
730 };
731 static dispex_static_data_t HTMLObjectElement_dispex = {
732     NULL,
733     DispHTMLObjectElement_tid,
734     NULL,
735     HTMLObjectElement_iface_tids
736 };
737
738 HRESULT HTMLObjectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
739 {
740     HTMLObjectElement *ret;
741     nsresult nsres;
742
743     ret = heap_alloc_zero(sizeof(*ret));
744     if(!ret)
745         return E_OUTOFMEMORY;
746
747     ret->IHTMLObjectElement_iface.lpVtbl = &HTMLObjectElementVtbl;
748     ret->IHTMLObjectElement2_iface.lpVtbl = &HTMLObjectElement2Vtbl;
749     ret->plugin_container.element.node.vtbl = &HTMLObjectElementImplVtbl;
750
751     HTMLElement_Init(&ret->plugin_container.element, doc, nselem, &HTMLObjectElement_dispex);
752
753     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLObjectElement, (void**)&ret->nsobject);
754
755     /* Share nsobject reference with nsnode */
756     assert(nsres == NS_OK && (nsIDOMNode*)ret->nsobject == ret->plugin_container.element.node.nsnode);
757     nsIDOMNode_Release(ret->plugin_container.element.node.nsnode);
758
759     *elem = &ret->plugin_container.element;
760     return S_OK;
761 }