mshtml: Forward HTMLSelectElement's IDispatch functions to IDispatchEx implementation.
[wine/gsoc_dplay.git] / dlls / mshtml / htmlselect.c
blob9c7cf71dcea5ca629ed36fd45a9a29b5807edb37
1 /*
2 * Copyright 2006 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 HTMLElement element;
37 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
39 nsIDOMHTMLSelectElement *nsselect;
40 } HTMLSelectElement;
42 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
44 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
46 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
47 REFIID riid, void **ppv)
49 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
56 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
63 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
70 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
75 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
80 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
83 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
89 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
92 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
93 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
96 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
98 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid,
99 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
104 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
105 FIXME("(%p)->(%ld)\n", This, v);
106 return E_NOTIMPL;
109 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
111 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
112 FIXME("(%p)->(%p)\n", This, p);
113 return E_NOTIMPL;
116 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
118 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
119 FIXME("(%p)->(%x)\n", This, v);
120 return E_NOTIMPL;
123 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
125 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
126 FIXME("(%p)->(%p)\n", This, p);
127 return E_NOTIMPL;
130 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
132 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
133 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
134 return E_NOTIMPL;
137 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
139 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
140 nsAString name_str;
141 const PRUnichar *name = NULL;
142 nsresult nsres;
144 TRACE("(%p)->(%p)\n", This, p);
146 nsAString_Init(&name_str, NULL);
148 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
149 if(NS_SUCCEEDED(nsres)) {
150 static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
152 nsAString_GetData(&name_str, &name);
155 * Native never returns empty string here. If an element has no name,
156 * name of previous element or ramdom data is returned.
158 *p = SysAllocString(*name ? name : wszGarbage);
159 }else {
160 ERR("GetName failed: %08x\n", nsres);
163 nsAString_Finish(&name_str);
165 TRACE("name=%s\n", debugstr_w(*p));
166 return S_OK;
169 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
171 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
172 FIXME("(%p)->(%p)\n", This, p);
173 return E_NOTIMPL;
176 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
178 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
180 TRACE("(%p)->()\n", This);
182 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
185 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
187 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
188 FIXME("(%p)->(%p)\n", This, p);
189 return E_NOTIMPL;
192 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
194 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
195 nsresult nsres;
197 TRACE("(%p)->(%ld)\n", This, v);
199 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
200 if(NS_FAILED(nsres))
201 ERR("SetSelectedIndex failed: %08x\n", nsres);
203 return S_OK;
206 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
208 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
209 PRInt32 idx = 0;
210 nsresult nsres;
212 TRACE("(%p)->(%p)\n", This, p);
214 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, &idx);
215 if(NS_FAILED(nsres))
216 ERR("GetSelectedIndex failed: %08x\n", nsres);
218 *p = idx;
219 return S_OK;
222 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
224 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
225 const PRUnichar *type;
226 nsAString type_str;
227 nsresult nsres;
228 HRESULT hres = S_OK;
230 TRACE("(%p)->(%p)\n", This, p);
232 nsAString_Init(&type_str, NULL);
233 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
234 if(NS_SUCCEEDED(nsres)) {
235 nsAString_GetData(&type_str, &type);
236 *p = *type ? SysAllocString(type) : NULL;
237 }else {
238 ERR("GetType failed: %08x\n", nsres);
239 hres = E_FAIL;
242 nsAString_Finish(&type_str);
244 return hres;
247 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
249 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
250 nsAString value_str;
251 nsresult nsres;
253 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
255 nsAString_Init(&value_str, v);
256 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
257 nsAString_Finish(&value_str);
258 if(NS_FAILED(nsres))
259 ERR("SetValue failed: %08x\n", nsres);
261 return S_OK;
264 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
266 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
267 nsAString value_str;
268 const PRUnichar *value = NULL;
269 nsresult nsres;
271 TRACE("(%p)->(%p)\n", This, p);
273 nsAString_Init(&value_str, NULL);
275 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
276 if(NS_SUCCEEDED(nsres)) {
277 nsAString_GetData(&value_str, &value);
278 *p = *value ? SysAllocString(value) : NULL;
279 }else {
280 ERR("GetValue failed: %08x\n", nsres);
283 nsAString_Finish(&value_str);
285 TRACE("value=%s\n", debugstr_w(*p));
286 return S_OK;
289 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
291 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
292 FIXME("(%p)->(%x)\n", This, v);
293 return E_NOTIMPL;
296 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
298 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
299 FIXME("(%p)->(%p)\n", This, p);
300 return E_NOTIMPL;
303 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
305 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
306 FIXME("(%p)->(%p)\n", This, p);
307 return E_NOTIMPL;
310 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
311 VARIANT before)
313 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
314 FIXME("(%p)->(%p v)\n", This, element);
315 return E_NOTIMPL;
318 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
320 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
321 FIXME("(%p)->(%ld)\n", This, index);
322 return E_NOTIMPL;
325 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
327 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
328 FIXME("(%p)->(%ld)\n", This, v);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
334 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
335 PRUint32 length = 0;
336 nsresult nsres;
338 TRACE("(%p)->(%p)\n", This, p);
340 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
341 if(NS_FAILED(nsres))
342 ERR("GetLength failed: %08x\n", nsres);
344 *p = length;
346 TRACE("ret %ld\n", *p);
347 return S_OK;
350 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
352 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
354 return E_NOTIMPL;
357 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
358 VARIANT index, IDispatch **pdisp)
360 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
361 FIXME("(%p)->(v v %p)\n", This, pdisp);
362 return E_NOTIMPL;
365 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
366 IDispatch **pdisp)
368 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
369 FIXME("(%p)->(v %p)\n", This, pdisp);
370 return E_NOTIMPL;
373 #undef HTMLSELECT_THIS
375 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
376 HTMLSelectElement_QueryInterface,
377 HTMLSelectElement_AddRef,
378 HTMLSelectElement_Release,
379 HTMLSelectElement_GetTypeInfoCount,
380 HTMLSelectElement_GetTypeInfo,
381 HTMLSelectElement_GetIDsOfNames,
382 HTMLSelectElement_Invoke,
383 HTMLSelectElement_put_size,
384 HTMLSelectElement_get_size,
385 HTMLSelectElement_put_multiple,
386 HTMLSelectElement_get_multiple,
387 HTMLSelectElement_put_name,
388 HTMLSelectElement_get_name,
389 HTMLSelectElement_get_options,
390 HTMLSelectElement_put_onchange,
391 HTMLSelectElement_get_onchange,
392 HTMLSelectElement_put_selectedIndex,
393 HTMLSelectElement_get_selectedIndex,
394 HTMLSelectElement_get_type,
395 HTMLSelectElement_put_value,
396 HTMLSelectElement_get_value,
397 HTMLSelectElement_put_disabled,
398 HTMLSelectElement_get_disabled,
399 HTMLSelectElement_get_form,
400 HTMLSelectElement_add,
401 HTMLSelectElement_remove,
402 HTMLSelectElement_put_length,
403 HTMLSelectElement_get_length,
404 HTMLSelectElement_get__newEnum,
405 HTMLSelectElement_item,
406 HTMLSelectElement_tags
409 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
411 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
413 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
415 *ppv = NULL;
417 if(IsEqualGUID(&IID_IUnknown, riid)) {
418 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
419 *ppv = HTMLSELECT(This);
420 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
421 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
422 *ppv = HTMLSELECT(This);
423 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
424 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
425 *ppv = HTMLSELECT(This);
428 if(*ppv) {
429 IUnknown_AddRef((IUnknown*)*ppv);
430 return S_OK;
433 return HTMLElement_QI(&This->element.node, riid, ppv);
436 static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
438 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
440 nsIDOMHTMLSelectElement_Release(This->nsselect);
442 HTMLElement_destructor(&This->element.node);
445 #undef HTMLSELECT_NODE_THIS
447 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
448 HTMLSelectElement_QI,
449 HTMLSelectElement_destructor
452 static const tid_t HTMLSelectElement_tids[] = {
453 IHTMLDOMNode_tid,
454 IHTMLDOMNode2_tid,
455 IHTMLElement_tid,
456 IHTMLElement2_tid,
457 IHTMLSelectElement_tid,
461 static dispex_static_data_t HTMLSelectElement_dispex = {
462 NULL,
463 DispHTMLSelectElement_tid,
464 NULL,
465 HTMLSelectElement_tids
468 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
470 HTMLSelectElement *ret = heap_alloc_zero(sizeof(HTMLSelectElement));
471 nsresult nsres;
473 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
474 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
476 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLSELECT(ret), &HTMLSelectElement_dispex);
477 HTMLElement_Init(&ret->element);
479 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
480 (void**)&ret->nsselect);
481 if(NS_FAILED(nsres))
482 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
484 return &ret->element;