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
);
39 const IHTMLSelectElementVtbl
*lpHTMLSelectElementVtbl
;
42 nsIDOMHTMLSelectElement
*nsselect
;
45 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
47 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
49 static HRESULT WINAPI
HTMLSelectElement_QueryInterface(IHTMLSelectElement
*iface
,
50 REFIID riid
, void **ppv
)
52 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
57 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
58 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
59 *ppv
= HTMLSELECT(This
);
60 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
61 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
62 *ppv
= HTMLSELECT(This
);
63 }else if(IsEqualGUID(&IID_IHTMLSelectElement
, riid
)) {
64 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This
, ppv
);
65 *ppv
= HTMLSELECT(This
);
69 IUnknown_AddRef((IUnknown
*)*ppv
);
73 hres
= HTMLElement_QI(This
->element
, riid
, ppv
);
75 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
80 static ULONG WINAPI
HTMLSelectElement_AddRef(IHTMLSelectElement
*iface
)
82 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
84 TRACE("(%p)\n", This
);
86 return IHTMLDocument2_AddRef(HTMLDOC(This
->element
->node
->doc
));
89 static ULONG WINAPI
HTMLSelectElement_Release(IHTMLSelectElement
*iface
)
91 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
93 TRACE("(%p)\n", This
);
95 return IHTMLDocument2_Release(HTMLDOC(This
->element
->node
->doc
));
98 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement
*iface
, UINT
*pctinfo
)
100 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
101 FIXME("(%p)->(%p)\n", This
, pctinfo
);
105 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfo(IHTMLSelectElement
*iface
, UINT iTInfo
,
106 LCID lcid
, ITypeInfo
**ppTInfo
)
108 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
109 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
113 static HRESULT WINAPI
HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement
*iface
, REFIID riid
,
114 LPOLESTR
*rgszNames
, UINT cNames
,
115 LCID lcid
, DISPID
*rgDispId
)
117 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
118 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
123 static HRESULT WINAPI
HTMLSelectElement_Invoke(IHTMLSelectElement
*iface
, DISPID dispIdMember
,
124 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
125 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
127 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
128 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
129 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
133 static HRESULT WINAPI
HTMLSelectElement_put_size(IHTMLSelectElement
*iface
, long v
)
135 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
136 FIXME("(%p)->(%ld)\n", This
, v
);
140 static HRESULT WINAPI
HTMLSelectElement_get_size(IHTMLSelectElement
*iface
, long *p
)
142 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
143 FIXME("(%p)->(%p)\n", This
, p
);
147 static HRESULT WINAPI
HTMLSelectElement_put_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
149 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
150 FIXME("(%p)->(%x)\n", This
, v
);
154 static HRESULT WINAPI
HTMLSelectElement_get_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
156 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
157 FIXME("(%p)->(%p)\n", This
, p
);
161 static HRESULT WINAPI
HTMLSelectElement_put_name(IHTMLSelectElement
*iface
, BSTR v
)
163 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
164 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
168 static HRESULT WINAPI
HTMLSelectElement_get_name(IHTMLSelectElement
*iface
, BSTR
*p
)
170 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
172 const PRUnichar
*name
= NULL
;
175 TRACE("(%p)->(%p)\n", This
, p
);
177 nsAString_Init(&name_str
, NULL
);
179 nsres
= nsIDOMHTMLSelectElement_GetName(This
->nsselect
, &name_str
);
180 if(NS_SUCCEEDED(nsres
)) {
181 static const WCHAR wszGarbage
[] = {'g','a','r','b','a','g','e',0};
183 nsAString_GetData(&name_str
, &name
, NULL
);
186 * Native never returns empty string here. If an element has no name,
187 * name of previous element or ramdom data is returned.
189 *p
= SysAllocString(*name
? name
: wszGarbage
);
191 ERR("GetName failed: %08x\n", nsres
);
194 nsAString_Finish(&name_str
);
196 TRACE("name=%s\n", debugstr_w(*p
));
200 static HRESULT WINAPI
HTMLSelectElement_get_options(IHTMLSelectElement
*iface
, IDispatch
**p
)
202 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
203 FIXME("(%p)->(%p)\n", This
, p
);
207 static HRESULT WINAPI
HTMLSelectElement_put_onchange(IHTMLSelectElement
*iface
, VARIANT v
)
209 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
210 FIXME("(%p)->()\n", This
);
214 static HRESULT WINAPI
HTMLSelectElement_get_onchange(IHTMLSelectElement
*iface
, VARIANT
*p
)
216 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
217 FIXME("(%p)->(%p)\n", This
, p
);
221 static HRESULT WINAPI
HTMLSelectElement_put_selectedIndex(IHTMLSelectElement
*iface
, long v
)
223 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
224 FIXME("(%p)->(%ld)\n", This
, v
);
228 static HRESULT WINAPI
HTMLSelectElement_get_selectedIndex(IHTMLSelectElement
*iface
, long *p
)
230 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
231 FIXME("(%p)->(%p)\n", This
, p
);
235 static HRESULT WINAPI
HTMLSelectElement_get_type(IHTMLSelectElement
*iface
, BSTR
*p
)
237 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
238 FIXME("(%p)->(%p)\n", This
, p
);
242 static HRESULT WINAPI
HTMLSelectElement_put_value(IHTMLSelectElement
*iface
, BSTR v
)
244 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
245 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
249 static HRESULT WINAPI
HTMLSelectElement_get_value(IHTMLSelectElement
*iface
, BSTR
*p
)
251 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
253 const PRUnichar
*value
= NULL
;
256 TRACE("(%p)->(%p)\n", This
, p
);
258 nsAString_Init(&value_str
, NULL
);
260 nsres
= nsIDOMHTMLSelectElement_GetValue(This
->nsselect
, &value_str
);
261 if(NS_SUCCEEDED(nsres
)) {
262 nsAString_GetData(&value_str
, &value
, NULL
);
263 *p
= SysAllocString(value
);
265 ERR("GetValue failed: %08x\n", nsres
);
268 nsAString_Finish(&value_str
);
270 TRACE("value=%s\n", debugstr_w(*p
));
274 static HRESULT WINAPI
HTMLSelectElement_put_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
276 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
277 FIXME("(%p)->(%x)\n", This
, v
);
281 static HRESULT WINAPI
HTMLSelectElement_get_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
283 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
284 FIXME("(%p)->(%p)\n", This
, p
);
288 static HRESULT WINAPI
HTMLSelectElement_get_form(IHTMLSelectElement
*iface
, IHTMLFormElement
**p
)
290 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
291 FIXME("(%p)->(%p)\n", This
, p
);
295 static HRESULT WINAPI
HTMLSelectElement_add(IHTMLSelectElement
*iface
, IHTMLElement
*element
,
298 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
299 FIXME("(%p)->(%p v)\n", This
, element
);
303 static HRESULT WINAPI
HTMLSelectElement_remove(IHTMLSelectElement
*iface
, long index
)
305 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
306 FIXME("(%p)->(%ld)\n", This
, index
);
310 static HRESULT WINAPI
HTMLSelectElement_put_length(IHTMLSelectElement
*iface
, long v
)
312 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
313 FIXME("(%p)->(%ld)\n", This
, v
);
317 static HRESULT WINAPI
HTMLSelectElement_get_length(IHTMLSelectElement
*iface
, long *p
)
319 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
320 FIXME("(%p)->(%p)\n", This
, p
);
324 static HRESULT WINAPI
HTMLSelectElement_get__newEnum(IHTMLSelectElement
*iface
, IUnknown
**p
)
326 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
327 FIXME("(%p)->(%p)\n", This
, p
);
331 static HRESULT WINAPI
HTMLSelectElement_item(IHTMLSelectElement
*iface
, VARIANT name
,
332 VARIANT index
, IDispatch
**pdisp
)
334 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
335 FIXME("(%p)->(v v %p)\n", This
, pdisp
);
339 static HRESULT WINAPI
HTMLSelectElement_tags(IHTMLSelectElement
*iface
, VARIANT tagName
,
342 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
343 FIXME("(%p)->(v %p)\n", This
, pdisp
);
347 static void HTMLSelectElement_destructor(IUnknown
*iface
)
349 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
351 nsIDOMHTMLSelectElement_Release(This
->nsselect
);
355 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl
= {
356 HTMLSelectElement_QueryInterface
,
357 HTMLSelectElement_AddRef
,
358 HTMLSelectElement_Release
,
359 HTMLSelectElement_GetTypeInfoCount
,
360 HTMLSelectElement_GetTypeInfo
,
361 HTMLSelectElement_GetIDsOfNames
,
362 HTMLSelectElement_Invoke
,
363 HTMLSelectElement_put_size
,
364 HTMLSelectElement_get_size
,
365 HTMLSelectElement_put_multiple
,
366 HTMLSelectElement_get_multiple
,
367 HTMLSelectElement_put_name
,
368 HTMLSelectElement_get_name
,
369 HTMLSelectElement_get_options
,
370 HTMLSelectElement_put_onchange
,
371 HTMLSelectElement_get_onchange
,
372 HTMLSelectElement_put_selectedIndex
,
373 HTMLSelectElement_get_selectedIndex
,
374 HTMLSelectElement_get_type
,
375 HTMLSelectElement_put_value
,
376 HTMLSelectElement_get_value
,
377 HTMLSelectElement_put_disabled
,
378 HTMLSelectElement_get_disabled
,
379 HTMLSelectElement_get_form
,
380 HTMLSelectElement_add
,
381 HTMLSelectElement_remove
,
382 HTMLSelectElement_put_length
,
383 HTMLSelectElement_get_length
,
384 HTMLSelectElement_get__newEnum
,
385 HTMLSelectElement_item
,
386 HTMLSelectElement_tags
389 void HTMLSelectElement_Create(HTMLElement
*element
)
391 HTMLSelectElement
*ret
= mshtml_alloc(sizeof(HTMLSelectElement
));
394 ret
->lpHTMLSelectElementVtbl
= &HTMLSelectElementVtbl
;
395 ret
->element
= element
;
397 nsres
= nsIDOMHTMLElement_QueryInterface(element
->nselem
, &IID_nsIDOMHTMLSelectElement
,
398 (void**)&ret
->nsselect
);
400 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres
);
402 element
->impl
= (IUnknown
*)HTMLSELECT(ret
);
403 element
->destructor
= HTMLSelectElement_destructor
;