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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
39 nsIDOMHTMLSelectElement *nsselect;
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);
71 FIXME("(%p)->(%p)\n", This, pctinfo);
75 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
79 FIXME("(%p)->(%u %u %p)\n", This, 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);
88 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
93 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
98 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
103 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
105 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
106 FIXME("(%p)->(%ld)\n", This, v);
110 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
112 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, p);
117 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
119 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
120 FIXME("(%p)->(%x)\n", This, v);
124 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
126 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
127 FIXME("(%p)->(%p)\n", This, p);
131 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
133 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
134 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
138 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
140 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
142 const PRUnichar *name = NULL;
145 TRACE("(%p)->(%p)\n", This, p);
147 nsAString_Init(&name_str, NULL);
149 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
150 if(NS_SUCCEEDED(nsres)) {
151 static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
153 nsAString_GetData(&name_str, &name);
156 * Native never returns empty string here. If an element has no name,
157 * name of previous element or ramdom data is returned.
159 *p = SysAllocString(*name ? name : wszGarbage);
161 ERR("GetName failed: %08x\n", nsres);
164 nsAString_Finish(&name_str);
166 TRACE("name=%s\n", debugstr_w(*p));
170 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
172 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
177 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
179 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
180 FIXME("(%p)->()\n", This);
184 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
186 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
187 FIXME("(%p)->(%p)\n", This, p);
191 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
193 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
196 TRACE("(%p)->(%ld)\n", This, v);
198 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
200 ERR("SetSelectedIndex failed: %08x\n", nsres);
205 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
207 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
211 TRACE("(%p)->(%p)\n", This, p);
213 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, &idx);
215 ERR("GetSelectedIndex failed: %08x\n", nsres);
221 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
223 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
224 FIXME("(%p)->(%p)\n", This, p);
228 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
230 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
231 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
235 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
237 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
239 const PRUnichar *value = NULL;
242 TRACE("(%p)->(%p)\n", This, p);
244 nsAString_Init(&value_str, NULL);
246 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
247 if(NS_SUCCEEDED(nsres)) {
248 nsAString_GetData(&value_str, &value);
249 *p = SysAllocString(value);
251 ERR("GetValue failed: %08x\n", nsres);
254 nsAString_Finish(&value_str);
256 TRACE("value=%s\n", debugstr_w(*p));
260 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
262 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
263 FIXME("(%p)->(%x)\n", This, v);
267 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
269 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
270 FIXME("(%p)->(%p)\n", This, p);
274 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
276 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
277 FIXME("(%p)->(%p)\n", This, p);
281 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
284 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
285 FIXME("(%p)->(%p v)\n", This, element);
289 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
291 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
292 FIXME("(%p)->(%ld)\n", This, index);
296 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
298 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
299 FIXME("(%p)->(%ld)\n", This, v);
303 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
305 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
309 TRACE("(%p)->(%p)\n", This, p);
311 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
313 ERR("GetLength failed: %08x\n", nsres);
317 TRACE("ret %ld\n", *p);
321 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
323 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
324 FIXME("(%p)->(%p)\n", This, p);
328 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
329 VARIANT index, IDispatch **pdisp)
331 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
332 FIXME("(%p)->(v v %p)\n", This, pdisp);
336 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
339 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
340 FIXME("(%p)->(v %p)\n", This, pdisp);
344 #undef HTMLSELECT_THIS
346 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
347 HTMLSelectElement_QueryInterface,
348 HTMLSelectElement_AddRef,
349 HTMLSelectElement_Release,
350 HTMLSelectElement_GetTypeInfoCount,
351 HTMLSelectElement_GetTypeInfo,
352 HTMLSelectElement_GetIDsOfNames,
353 HTMLSelectElement_Invoke,
354 HTMLSelectElement_put_size,
355 HTMLSelectElement_get_size,
356 HTMLSelectElement_put_multiple,
357 HTMLSelectElement_get_multiple,
358 HTMLSelectElement_put_name,
359 HTMLSelectElement_get_name,
360 HTMLSelectElement_get_options,
361 HTMLSelectElement_put_onchange,
362 HTMLSelectElement_get_onchange,
363 HTMLSelectElement_put_selectedIndex,
364 HTMLSelectElement_get_selectedIndex,
365 HTMLSelectElement_get_type,
366 HTMLSelectElement_put_value,
367 HTMLSelectElement_get_value,
368 HTMLSelectElement_put_disabled,
369 HTMLSelectElement_get_disabled,
370 HTMLSelectElement_get_form,
371 HTMLSelectElement_add,
372 HTMLSelectElement_remove,
373 HTMLSelectElement_put_length,
374 HTMLSelectElement_get_length,
375 HTMLSelectElement_get__newEnum,
376 HTMLSelectElement_item,
377 HTMLSelectElement_tags
380 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
382 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
384 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
388 if(IsEqualGUID(&IID_IUnknown, riid)) {
389 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
390 *ppv = HTMLSELECT(This);
391 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
392 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
393 *ppv = HTMLSELECT(This);
394 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
395 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
396 *ppv = HTMLSELECT(This);
400 IUnknown_AddRef((IUnknown*)*ppv);
404 return HTMLElement_QI(&This->element.node, riid, ppv);
407 static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
409 HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
411 nsIDOMHTMLSelectElement_Release(This->nsselect);
413 HTMLElement_destructor(&This->element.node);
416 #undef HTMLSELECT_NODE_THIS
418 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
419 HTMLSelectElement_QI,
420 HTMLSelectElement_destructor
423 static const tid_t HTMLSelectElement_tids[] = {
428 IHTMLSelectElement_tid,
432 static dispex_static_data_t HTMLSelectElement_dispex = {
434 DispHTMLSelectElement_tid,
436 HTMLSelectElement_tids
439 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
441 HTMLSelectElement *ret = heap_alloc_zero(sizeof(HTMLSelectElement));
444 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
445 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
447 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLSELECT(ret), &HTMLSelectElement_dispex);
448 HTMLElement_Init(&ret->element);
450 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
451 (void**)&ret->nsselect);
453 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
455 return &ret->element;