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