wined3d: Remove dead code.
[wine.git] / dlls / mshtml / htmloption.c
blobefb983031c2ea68ecd022dbf4b306fd2e1dde61b
1 /*
2 * Copyright 2007 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 IHTMLOptionElementVtbl *lpHTMLOptionElementVtbl;
39 nsIDOMHTMLOptionElement *nsoption;
40 } HTMLOptionElement;
42 #define HTMLOPTION(x) ((IHTMLOptionElement*) &(x)->lpHTMLOptionElementVtbl)
44 #define HTMLOPTION_THIS(iface) DEFINE_THIS(HTMLOptionElement, HTMLOptionElement, iface)
46 static HRESULT WINAPI HTMLOptionElement_QueryInterface(IHTMLOptionElement *iface,
47 REFIID riid, void **ppv)
49 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 static ULONG WINAPI HTMLOptionElement_AddRef(IHTMLOptionElement *iface)
56 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 static ULONG WINAPI HTMLOptionElement_Release(IHTMLOptionElement *iface)
63 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 static HRESULT WINAPI HTMLOptionElement_GetTypeInfoCount(IHTMLOptionElement *iface, UINT *pctinfo)
70 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
71 FIXME("(%p)->(%p)\n", This, pctinfo);
72 return E_NOTIMPL;
75 static HRESULT WINAPI HTMLOptionElement_GetTypeInfo(IHTMLOptionElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
79 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
80 return E_NOTIMPL;
83 static HRESULT WINAPI HTMLOptionElement_GetIDsOfNames(IHTMLOptionElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
88 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
89 lcid, rgDispId);
90 return E_NOTIMPL;
93 static HRESULT WINAPI HTMLOptionElement_Invoke(IHTMLOptionElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLOptionElement *This = HTMLOPTION_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);
100 return E_NOTIMPL;
103 static HRESULT WINAPI HTMLOptionElement_put_selected(IHTMLOptionElement *iface, VARIANT_BOOL v)
105 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
106 FIXME("(%p)->(%x)\n", This, v);
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLOptionElement_get_selected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
112 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, p);
114 return E_NOTIMPL;
117 static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BSTR v)
119 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
120 nsAString value_str;
121 nsresult nsres;
123 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
125 nsAString_Init(&value_str, v);
126 nsres = nsIDOMHTMLOptionElement_SetValue(This->nsoption, &value_str);
127 nsAString_Finish(&value_str);
128 if(NS_FAILED(nsres))
129 ERR("SetValue failed: %08x\n", nsres);
131 return S_OK;
134 static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BSTR *p)
136 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
137 nsAString value_str;
138 const PRUnichar *value;
139 nsresult nsres;
141 TRACE("(%p)->(%p)\n", This, p);
143 nsAString_Init(&value_str, NULL);
144 nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str);
145 if(NS_SUCCEEDED(nsres)) {
146 nsAString_GetData(&value_str, &value);
147 *p = SysAllocString(value);
148 }else {
149 ERR("GetValue failed: %08x\n", nsres);
150 *p = NULL;
152 nsAString_Finish(&value_str);
154 return S_OK;
157 static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
159 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
160 FIXME("(%p)->(%x)\n", This, v);
161 return E_NOTIMPL;
164 static HRESULT WINAPI HTMLOptionElement_get_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
166 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
167 FIXME("(%p)->(%p)\n", This, p);
168 return E_NOTIMPL;
171 static HRESULT WINAPI HTMLOptionElement_put_index(IHTMLOptionElement *iface, LONG v)
173 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
174 FIXME("(%p)->(%d)\n", This, v);
175 return E_NOTIMPL;
178 static HRESULT WINAPI HTMLOptionElement_get_index(IHTMLOptionElement *iface, LONG *p)
180 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
181 FIXME("(%p)->(%p)\n", This, p);
182 return E_NOTIMPL;
185 static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR v)
187 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
188 nsIDOMDocument *nsdoc;
189 nsIDOMText *text_node;
190 nsAString text_str;
191 nsIDOMNode *tmp;
192 nsresult nsres;
194 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
196 while(1) {
197 nsIDOMNode *child;
199 nsres = nsIDOMHTMLOptionElement_GetFirstChild(This->nsoption, &child);
200 if(NS_FAILED(nsres) || !child)
201 break;
203 nsres = nsIDOMHTMLOptionElement_RemoveChild(This->nsoption, child, &tmp);
204 nsIDOMNode_Release(child);
205 if(NS_SUCCEEDED(nsres)) {
206 nsIDOMNode_Release(tmp);
207 }else {
208 ERR("RemoveChild failed: %08x\n", nsres);
209 break;
213 nsres = nsIWebNavigation_GetDocument(This->element.node.doc->nscontainer->navigation, &nsdoc);
214 if(NS_FAILED(nsres)) {
215 ERR("GetDocument failed: %08x\n", nsres);
216 return S_OK;
219 nsAString_Init(&text_str, v);
220 nsres = nsIDOMDocument_CreateTextNode(nsdoc, &text_str, &text_node);
221 nsIDOMDocument_Release(nsdoc);
222 nsAString_Finish(&text_str);
223 if(NS_FAILED(nsres)) {
224 ERR("CreateTextNode failed: %08x\n", nsres);
225 return S_OK;
228 nsres = nsIDOMHTMLOptionElement_AppendChild(This->nsoption, (nsIDOMNode*)text_node, &tmp);
229 if(NS_SUCCEEDED(nsres))
230 nsIDOMNode_Release(tmp);
231 else
232 ERR("AppendChild failed: %08x\n", nsres);
234 return S_OK;
237 static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR *p)
239 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
240 nsAString text_str;
241 const PRUnichar *text;
242 nsresult nsres;
244 TRACE("(%p)->(%p)\n", This, p);
246 nsAString_Init(&text_str, NULL);
247 nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str);
248 if(NS_SUCCEEDED(nsres)) {
249 nsAString_GetData(&text_str, &text);
250 *p = SysAllocString(text);
251 }else {
252 ERR("GetText failed: %08x\n", nsres);
253 *p = NULL;
255 nsAString_Finish(&text_str);
257 return S_OK;
260 static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)
262 HTMLOptionElement *This = HTMLOPTION_THIS(iface);
263 FIXME("(%p)->(%p)\n", This, p);
264 return E_NOTIMPL;
267 #undef HTMLOPTION_THIS
269 static const IHTMLOptionElementVtbl HTMLOptionElementVtbl = {
270 HTMLOptionElement_QueryInterface,
271 HTMLOptionElement_AddRef,
272 HTMLOptionElement_Release,
273 HTMLOptionElement_GetTypeInfoCount,
274 HTMLOptionElement_GetTypeInfo,
275 HTMLOptionElement_GetIDsOfNames,
276 HTMLOptionElement_Invoke,
277 HTMLOptionElement_put_selected,
278 HTMLOptionElement_get_selected,
279 HTMLOptionElement_put_value,
280 HTMLOptionElement_get_value,
281 HTMLOptionElement_put_defaultSelected,
282 HTMLOptionElement_get_defaultSelected,
283 HTMLOptionElement_put_index,
284 HTMLOptionElement_get_index,
285 HTMLOptionElement_put_text,
286 HTMLOptionElement_get_text,
287 HTMLOptionElement_get_form
290 #define HTMLOPTION_NODE_THIS(iface) DEFINE_THIS2(HTMLOptionElement, element.node, iface)
292 static HRESULT HTMLOptionElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
294 HTMLOptionElement *This = HTMLOPTION_NODE_THIS(iface);
296 *ppv = NULL;
298 if(IsEqualGUID(&IID_IUnknown, riid)) {
299 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
300 *ppv = HTMLOPTION(This);
301 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
302 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
303 *ppv = HTMLOPTION(This);
304 }else if(IsEqualGUID(&IID_IHTMLOptionElement, riid)) {
305 TRACE("(%p)->(IID_IHTMLOptionElement %p)\n", This, ppv);
306 *ppv = HTMLOPTION(This);
309 if(*ppv) {
310 IUnknown_AddRef((IUnknown*)*ppv);
311 return S_OK;
314 return HTMLElement_QI(&This->element.node, riid, ppv);
317 static void HTMLOptionElement_destructor(HTMLDOMNode *iface)
319 HTMLOptionElement *This = HTMLOPTION_NODE_THIS(iface);
321 if(This->nsoption)
322 nsIDOMHTMLOptionElement_Release(This->nsoption);
324 HTMLElement_destructor(&This->element.node);
327 #undef HTMLOPTION_NODE_THIS
329 static const NodeImplVtbl HTMLOptionElementImplVtbl = {
330 HTMLOptionElement_QI,
331 HTMLOptionElement_destructor
334 static const tid_t HTMLOptionElement_iface_tids[] = {
335 IHTMLDOMNode_tid,
336 IHTMLDOMNode2_tid,
337 IHTMLElement_tid,
338 IHTMLElement2_tid,
339 IHTMLOptionElement_tid,
342 static dispex_static_data_t HTMLOptionElement_dispex = {
343 NULL,
344 DispHTMLOptionElement_tid,
345 NULL,
346 HTMLOptionElement_iface_tids
349 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement *nselem)
351 HTMLOptionElement *ret = heap_alloc_zero(sizeof(HTMLOptionElement));
352 nsresult nsres;
354 ret->lpHTMLOptionElementVtbl = &HTMLOptionElementVtbl;
355 ret->element.node.vtbl = &HTMLOptionElementImplVtbl;
357 HTMLElement_Init(&ret->element);
358 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLOPTION(ret), &HTMLOptionElement_dispex);
360 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLOptionElement, (void**)&ret->nsoption);
361 if(NS_FAILED(nsres))
362 ERR("Could not get nsIDOMHTMLOptionElement interface: %08x\n", nsres);
364 return &ret->element;
367 #define HTMLOPTFACTORY_THIS(iface) DEFINE_THIS(HTMLOptionElementFactory, HTMLOptionElementFactory, iface)
369 static HRESULT WINAPI HTMLOptionElementFactory_QueryInterface(IHTMLOptionElementFactory *iface,
370 REFIID riid, void **ppv)
372 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
374 *ppv = NULL;
376 if(IsEqualGUID(&IID_IUnknown, riid)) {
377 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
378 *ppv = HTMLOPTFACTORY(This);
379 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
380 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
381 *ppv = HTMLOPTFACTORY(This);
382 }else if(IsEqualGUID(&IID_IHTMLOptionElementFactory, riid)) {
383 TRACE("(%p)->(IID_IHTMLOptionElementFactory %p)\n", This, ppv);
384 *ppv = HTMLOPTFACTORY(This);
387 if(*ppv) {
388 IUnknown_AddRef((IUnknown*)*ppv);
389 return S_OK;
392 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
393 return E_NOINTERFACE;
396 static ULONG WINAPI HTMLOptionElementFactory_AddRef(IHTMLOptionElementFactory *iface)
398 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
399 LONG ref = InterlockedIncrement(&This->ref);
401 TRACE("(%p) ref=%d\n", This, ref);
403 return ref;
406 static ULONG WINAPI HTMLOptionElementFactory_Release(IHTMLOptionElementFactory *iface)
408 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
409 LONG ref = InterlockedDecrement(&This->ref);
411 TRACE("(%p) ref=%d\n", This, ref);
413 if(!ref)
414 heap_free(This);
416 return ref;
419 static HRESULT WINAPI HTMLOptionElementFactory_GetTypeInfoCount(IHTMLOptionElementFactory *iface, UINT *pctinfo)
421 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
422 FIXME("(%p)->(%p)\n", This, pctinfo);
423 return E_NOTIMPL;
426 static HRESULT WINAPI HTMLOptionElementFactory_GetTypeInfo(IHTMLOptionElementFactory *iface, UINT iTInfo,
427 LCID lcid, ITypeInfo **ppTInfo)
429 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
430 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
431 return E_NOTIMPL;
434 static HRESULT WINAPI HTMLOptionElementFactory_GetIDsOfNames(IHTMLOptionElementFactory *iface, REFIID riid,
435 LPOLESTR *rgszNames, UINT cNames,
436 LCID lcid, DISPID *rgDispId)
438 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
439 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
440 lcid, rgDispId);
441 return E_NOTIMPL;
444 static HRESULT WINAPI HTMLOptionElementFactory_Invoke(IHTMLOptionElementFactory *iface, DISPID dispIdMember,
445 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
446 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
448 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
449 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
450 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
451 return E_NOTIMPL;
454 static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory *iface,
455 VARIANT text, VARIANT value, VARIANT defaultselected, VARIANT selected,
456 IHTMLOptionElement **optelem)
458 HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
459 nsIDOMDocument *nsdoc;
460 nsIDOMElement *nselem;
461 nsAString option_str;
462 nsresult nsres;
463 HRESULT hres;
465 static const PRUnichar optionW[] = {'O','P','T','I','O','N',0};
467 TRACE("(%p)->(v v v v %p)\n", This, optelem);
469 *optelem = NULL;
470 if(!This->doc->nscontainer)
471 return E_FAIL;
473 nsres = nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &nsdoc);
474 if(NS_FAILED(nsres)) {
475 ERR("GetDocument failed: %08x\n", nsres);
476 return E_FAIL;
479 nsAString_Init(&option_str, optionW);
480 nsres = nsIDOMDocument_CreateElement(nsdoc, &option_str, &nselem);
481 nsIDOMDocument_Release(nsdoc);
482 nsAString_Finish(&option_str);
483 if(NS_FAILED(nsres)) {
484 ERR("CreateElement failed: %08x\n", nsres);
485 return E_FAIL;
488 hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->doc, (nsIDOMNode*)nselem, TRUE)),
489 &IID_IHTMLOptionElement, (void**)optelem);
490 nsIDOMElement_Release(nselem);
492 if(V_VT(&text) == VT_BSTR)
493 IHTMLOptionElement_put_text(*optelem, V_BSTR(&text));
494 else if(V_VT(&text) != VT_EMPTY)
495 FIXME("Unsupported text vt=%d\n", V_VT(&text));
497 if(V_VT(&value) == VT_BSTR)
498 IHTMLOptionElement_put_value(*optelem, V_BSTR(&value));
499 else if(V_VT(&value) != VT_EMPTY)
500 FIXME("Unsupported value vt=%d\n", V_VT(&value));
502 if(V_VT(&defaultselected) != VT_EMPTY)
503 FIXME("Unsupported defaultselected vt=%d\n", V_VT(&defaultselected));
504 if(V_VT(&selected) != VT_EMPTY)
505 FIXME("Unsupported selected vt=%d\n", V_VT(&selected));
507 return S_OK;
510 #undef HTMLOPTFACTORY_THIS
512 static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
513 HTMLOptionElementFactory_QueryInterface,
514 HTMLOptionElementFactory_AddRef,
515 HTMLOptionElementFactory_Release,
516 HTMLOptionElementFactory_GetTypeInfoCount,
517 HTMLOptionElementFactory_GetTypeInfo,
518 HTMLOptionElementFactory_GetIDsOfNames,
519 HTMLOptionElementFactory_Invoke,
520 HTMLOptionElementFactory_create
523 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument *doc)
525 HTMLOptionElementFactory *ret;
527 ret = heap_alloc(sizeof(HTMLOptionElementFactory));
529 ret->lpHTMLOptionElementFactoryVtbl = &HTMLOptionElementFactoryVtbl;
530 ret->ref = 1;
531 ret->doc = doc;
533 return ret;