gdi32: Slightly simplify result handling in PolyDraw.
[wine.git] / dlls / mshtml / htmlselect.c
blob4a01ef16b4dd9d0dc5e9d81ff7f8043d7e543779
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 typedef struct {
39 const IHTMLSelectElementVtbl *lpHTMLSelectElementVtbl;
41 HTMLElement *element;
42 nsIDOMHTMLSelectElement *nsselect;
43 } HTMLSelectElement;
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);
53 HRESULT hres;
55 *ppv = NULL;
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);
68 if(*ppv) {
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
73 hres = HTMLElement_QI(This->element, riid, ppv);
74 if(FAILED(hres))
75 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
77 return hres;
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);
102 return E_NOTIMPL;
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);
110 return E_NOTIMPL;
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,
119 lcid, rgDispId);
120 return E_NOTIMPL;
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);
130 return E_NOTIMPL;
133 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, long v)
135 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
136 FIXME("(%p)->(%ld)\n", This, v);
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, long *p)
142 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
143 FIXME("(%p)->(%p)\n", This, p);
144 return E_NOTIMPL;
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);
151 return E_NOTIMPL;
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);
158 return E_NOTIMPL;
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));
165 return E_NOTIMPL;
168 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
170 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
171 nsAString name_str;
172 const PRUnichar *name = NULL;
173 nsresult nsres;
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);
190 }else {
191 ERR("GetName failed: %08x\n", nsres);
194 nsAString_Finish(&name_str);
196 TRACE("name=%s\n", debugstr_w(*p));
197 return S_OK;
200 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
202 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
203 FIXME("(%p)->(%p)\n", This, p);
204 return E_NOTIMPL;
207 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
209 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
210 FIXME("(%p)->()\n", This);
211 return E_NOTIMPL;
214 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
216 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
217 FIXME("(%p)->(%p)\n", This, p);
218 return E_NOTIMPL;
221 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, long v)
223 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
224 FIXME("(%p)->(%ld)\n", This, v);
225 return E_NOTIMPL;
228 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, long *p)
230 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
231 FIXME("(%p)->(%p)\n", This, p);
232 return E_NOTIMPL;
235 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
237 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
238 FIXME("(%p)->(%p)\n", This, p);
239 return E_NOTIMPL;
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));
246 return E_NOTIMPL;
249 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
251 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
252 nsAString value_str;
253 const PRUnichar *value = NULL;
254 nsresult nsres;
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);
264 }else {
265 ERR("GetValue failed: %08x\n", nsres);
268 nsAString_Finish(&value_str);
270 TRACE("value=%s\n", debugstr_w(*p));
271 return S_OK;
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);
278 return E_NOTIMPL;
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);
285 return E_NOTIMPL;
288 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
290 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
291 FIXME("(%p)->(%p)\n", This, p);
292 return E_NOTIMPL;
295 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
296 VARIANT before)
298 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
299 FIXME("(%p)->(%p v)\n", This, element);
300 return E_NOTIMPL;
303 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, long index)
305 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
306 FIXME("(%p)->(%ld)\n", This, index);
307 return E_NOTIMPL;
310 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, long v)
312 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
313 FIXME("(%p)->(%ld)\n", This, v);
314 return E_NOTIMPL;
317 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, long *p)
319 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
320 FIXME("(%p)->(%p)\n", This, p);
321 return E_NOTIMPL;
324 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
326 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
327 FIXME("(%p)->(%p)\n", This, p);
328 return E_NOTIMPL;
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);
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
340 IDispatch **pdisp)
342 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
343 FIXME("(%p)->(v %p)\n", This, pdisp);
344 return E_NOTIMPL;
347 static void HTMLSelectElement_destructor(IUnknown *iface)
349 HTMLSelectElement *This = HTMLSELECT_THIS(iface);
351 nsIDOMHTMLSelectElement_Release(This->nsselect);
352 mshtml_free(This);
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));
392 nsresult nsres;
394 ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
395 ret->element = element;
397 nsres = nsIDOMHTMLElement_QueryInterface(element->nselem, &IID_nsIDOMHTMLSelectElement,
398 (void**)&ret->nsselect);
399 if(NS_FAILED(nsres))
400 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
402 element->impl = (IUnknown*)HTMLSELECT(ret);
403 element->destructor = HTMLSelectElement_destructor;