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
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
43 nsIDOMHTMLSelectElement *nsselect;
46 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
48 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
50 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
51 REFIID riid, void **ppv)
53 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
58 if(IsEqualGUID(&IID_IUnknown, riid)) {
59 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60 *ppv = HTMLSELECT(This);
61 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
62 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
63 *ppv = HTMLSELECT(This);
64 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
65 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
66 *ppv = HTMLSELECT(This);
70 IUnknown_AddRef((IUnknown*)*ppv);
74 hres = HTMLElement_QI(&This->element, riid, ppv);
76 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
81 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
83 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
85 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
88 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
90 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
92 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
95 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
97 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
98 FIXME("(%p)->(%p)\n", This, pctinfo);
102 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
103 LCID lcid, ITypeInfo **ppTInfo)
105 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
106 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
110 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
111 LPOLESTR *rgszNames, UINT cNames,
112 LCID lcid, DISPID *rgDispId)
114 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
115 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
120 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
121 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
122 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
124 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
125 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
126 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
130 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
132 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
133 FIXME("(%p)->(%ld)\n", This, v);
137 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
139 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
140 FIXME("(%p)->(%p)\n", This, p);
144 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
146 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
147 FIXME("(%p)->(%x)\n", This, v);
151 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
153 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
154 FIXME("(%p)->(%p)\n", This, p);
158 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
160 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
165 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
167 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
169 const PRUnichar *name = NULL;
172 TRACE("(%p)->(%p)\n", This, p);
174 nsAString_Init(&name_str, NULL);
176 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
177 if(NS_SUCCEEDED(nsres)) {
178 static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
180 nsAString_GetData(&name_str, &name, NULL);
183 * Native never returns empty string here. If an element has no name,
184 * name of previous element or ramdom data is returned.
186 *p = SysAllocString(*name ? name : wszGarbage);
188 ERR("GetName failed: %08x\n", nsres);
191 nsAString_Finish(&name_str);
193 TRACE("name=%s\n", debugstr_w(*p));
197 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
199 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
200 FIXME("(%p)->(%p)\n", This, p);
204 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
206 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
207 FIXME("(%p)->()\n", This);
211 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
213 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
214 FIXME("(%p)->(%p)\n", This, p);
218 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
220 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
221 FIXME("(%p)->(%ld)\n", This, v);
225 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
227 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
228 FIXME("(%p)->(%p)\n", This, p);
232 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
234 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
235 FIXME("(%p)->(%p)\n", This, p);
239 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
241 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
242 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
246 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
248 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
250 const PRUnichar *value = NULL;
253 TRACE("(%p)->(%p)\n", This, p);
255 nsAString_Init(&value_str, NULL);
257 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
258 if(NS_SUCCEEDED(nsres)) {
259 nsAString_GetData(&value_str, &value, NULL);
260 *p = SysAllocString(value);
262 ERR("GetValue failed: %08x\n", nsres);
265 nsAString_Finish(&value_str);
267 TRACE("value=%s\n", debugstr_w(*p));
271 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
273 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
274 FIXME("(%p)->(%x)\n", This, v);
278 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
280 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, p);
285 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
287 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
288 FIXME("(%p)->(%p)\n", This, p);
292 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
295 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
296 FIXME("(%p)->(%p v)\n", This, element);
300 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
302 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
303 FIXME("(%p)->(%ld)\n", This, index);
307 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
309 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
310 FIXME("(%p)->(%ld)\n", This, v);
314 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
316 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
317 FIXME("(%p)->(%p)\n", This, 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 static void HTMLSelectElement_destructor(IUnknown *iface)
346 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
348 nsIDOMHTMLSelectElement_Release(This->nsselect);
352 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
353 HTMLSelectElement_QueryInterface,
354 HTMLSelectElement_AddRef,
355 HTMLSelectElement_Release,
356 HTMLSelectElement_GetTypeInfoCount,
357 HTMLSelectElement_GetTypeInfo,
358 HTMLSelectElement_GetIDsOfNames,
359 HTMLSelectElement_Invoke,
360 HTMLSelectElement_put_size,
361 HTMLSelectElement_get_size,
362 HTMLSelectElement_put_multiple,
363 HTMLSelectElement_get_multiple,
364 HTMLSelectElement_put_name,
365 HTMLSelectElement_get_name,
366 HTMLSelectElement_get_options,
367 HTMLSelectElement_put_onchange,
368 HTMLSelectElement_get_onchange,
369 HTMLSelectElement_put_selectedIndex,
370 HTMLSelectElement_get_selectedIndex,
371 HTMLSelectElement_get_type,
372 HTMLSelectElement_put_value,
373 HTMLSelectElement_get_value,
374 HTMLSelectElement_put_disabled,
375 HTMLSelectElement_get_disabled,
376 HTMLSelectElement_get_form,
377 HTMLSelectElement_add,
378 HTMLSelectElement_remove,
379 HTMLSelectElement_put_length,
380 HTMLSelectElement_get_length,
381 HTMLSelectElement_get__newEnum,
382 HTMLSelectElement_item,
383 HTMLSelectElement_tags
386 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
388 HTMLSelectElement *ret = mshtml_alloc(sizeof(HTMLSelectElement));
391 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
393 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
394 (void**)&ret->nsselect);
396 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
398 ret->element.impl = (IUnknown*)HTMLSELECT(ret);
399 ret->element.destructor = HTMLSelectElement_destructor;
401 return &ret->element;