gdi32: Use get_object_type for GetObjectType implementation.
[wine.git] / dlls / mshtml / htmltextarea.c
blobfb8c3830862b37fd6a3c83391f7df34c5584f564
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 <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct HTMLTextAreaElement {
36 HTMLElement element;
38 IHTMLTextAreaElement IHTMLTextAreaElement_iface;
40 nsIDOMHTMLTextAreaElement *nstextarea;
43 static inline HTMLTextAreaElement *impl_from_IHTMLTextAreaElement(IHTMLTextAreaElement *iface)
45 return CONTAINING_RECORD(iface, HTMLTextAreaElement, IHTMLTextAreaElement_iface);
48 static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *iface,
49 REFIID riid, void **ppv)
51 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
58 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLTextAreaElement_Release(IHTMLTextAreaElement *iface)
65 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement *iface, UINT *pctinfo)
72 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfo(IHTMLTextAreaElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLTextAreaElement_Invoke(IHTMLTextAreaElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
98 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLTextAreaElement_get_type(IHTMLTextAreaElement *iface, BSTR *p)
104 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
106 TRACE("(%p)->(%p)\n", This, p);
108 *p = SysAllocString(L"textarea");
109 if(!*p)
110 return E_OUTOFMEMORY;
111 return S_OK;
114 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
116 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
117 nsAString value_str;
118 nsresult nsres;
120 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
122 nsAString_InitDepend(&value_str, v);
123 nsres = nsIDOMHTMLTextAreaElement_SetValue(This->nstextarea, &value_str);
124 nsAString_Finish(&value_str);
125 if(NS_FAILED(nsres)) {
126 ERR("SetValue failed: %08x\n", nsres);
127 return E_FAIL;
130 return S_OK;
133 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
135 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
136 nsAString value_str;
137 nsresult nsres;
139 TRACE("(%p)->(%p)\n", This, p);
141 nsAString_Init(&value_str, NULL);
142 nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
143 return return_nsstr(nsres, &value_str, p);
146 static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
148 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
149 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
150 return E_NOTIMPL;
153 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
155 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
156 nsAString name_str;
157 nsresult nsres;
159 TRACE("(%p)->(%p)\n", This, p);
161 nsAString_Init(&name_str, NULL);
162 nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
163 return return_nsstr(nsres, &name_str, p);
166 static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
168 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
169 FIXME("(%p)->()\n", This);
170 return E_NOTIMPL;
173 static HRESULT WINAPI HTMLTextAreaElement_get_status(IHTMLTextAreaElement *iface, VARIANT *p)
175 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
176 FIXME("(%p)->(%p)\n", This, p);
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
182 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
183 FIXME("(%p)->(%x)\n", This, v);
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
189 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
190 FIXME("(%p)->(%p)\n", This, p);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
196 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
197 nsIDOMHTMLFormElement *nsform;
198 nsresult nsres;
200 TRACE("(%p)->(%p)\n", This, p);
202 nsres = nsIDOMHTMLTextAreaElement_GetForm(This->nstextarea, &nsform);
203 return return_nsform(nsres, nsform, p);
206 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
208 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
209 nsAString nsstr;
210 nsresult nsres;
212 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
214 nsAString_InitDepend(&nsstr, v);
215 nsres = nsIDOMHTMLTextAreaElement_SetDefaultValue(This->nstextarea, &nsstr);
216 nsAString_Finish(&nsstr);
217 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
220 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
222 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
223 nsAString nsstr;
224 nsresult nsres;
226 TRACE("(%p)->(%p)\n", This, p);
228 nsAString_Init(&nsstr, NULL);
229 nsres = nsIDOMHTMLTextAreaElement_GetDefaultValue(This->nstextarea, &nsstr);
230 return return_nsstr(nsres, &nsstr, p);
233 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
235 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
236 FIXME("(%p)\n", This);
237 return E_NOTIMPL;
240 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
242 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
243 FIXME("(%p)->()\n", This);
244 return E_NOTIMPL;
247 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
249 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
250 FIXME("(%p)->(%p)\n", This, p);
251 return E_NOTIMPL;
254 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
256 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
257 FIXME("(%p)->()\n", This);
258 return E_NOTIMPL;
261 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
263 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
264 FIXME("(%p)->(%p)\n", This, p);
265 return E_NOTIMPL;
268 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
270 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
271 nsresult nsres;
273 TRACE("(%p)->(%x)\n", This, v);
275 nsres = nsIDOMHTMLTextAreaElement_SetReadOnly(This->nstextarea, v != VARIANT_FALSE);
276 if(NS_FAILED(nsres)) {
277 ERR("SetReadOnly failed: %08x\n", nsres);
278 return E_FAIL;
281 return S_OK;
284 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
286 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
287 cpp_bool b;
288 nsresult nsres;
290 TRACE("(%p)->(%p)\n", This, p);
292 nsres = nsIDOMHTMLTextAreaElement_GetReadOnly(This->nstextarea, &b);
293 if(NS_FAILED(nsres)) {
294 ERR("GetReadOnly failed: %08x\n", nsres);
295 return E_FAIL;
298 *p = variant_bool(b);
299 return S_OK;
302 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, LONG v)
304 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
305 FIXME("(%p)->(%d)\n", This, v);
306 return E_NOTIMPL;
309 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, LONG *p)
311 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
312 FIXME("(%p)->(%p)\n", This, p);
313 return E_NOTIMPL;
316 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, LONG v)
318 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
319 FIXME("(%p)->(%d)\n", This, v);
320 return E_NOTIMPL;
323 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, LONG *p)
325 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
326 FIXME("(%p)->(%p)\n", This, p);
327 return E_NOTIMPL;
330 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
332 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
333 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
334 return E_NOTIMPL;
337 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
339 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
340 FIXME("(%p)->(%p)\n", This, p);
341 return E_NOTIMPL;
344 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
345 IHTMLTxtRange **range)
347 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
348 FIXME("(%p)->(%p)\n", This, range);
349 return E_NOTIMPL;
352 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
353 HTMLTextAreaElement_QueryInterface,
354 HTMLTextAreaElement_AddRef,
355 HTMLTextAreaElement_Release,
356 HTMLTextAreaElement_GetTypeInfoCount,
357 HTMLTextAreaElement_GetTypeInfo,
358 HTMLTextAreaElement_GetIDsOfNames,
359 HTMLTextAreaElement_Invoke,
360 HTMLTextAreaElement_get_type,
361 HTMLTextAreaElement_put_value,
362 HTMLTextAreaElement_get_value,
363 HTMLTextAreaElement_put_name,
364 HTMLTextAreaElement_get_name,
365 HTMLTextAreaElement_put_status,
366 HTMLTextAreaElement_get_status,
367 HTMLTextAreaElement_put_disabled,
368 HTMLTextAreaElement_get_disabled,
369 HTMLTextAreaElement_get_form,
370 HTMLTextAreaElement_put_defaultValue,
371 HTMLTextAreaElement_get_defaultValue,
372 HTMLTextAreaElement_select,
373 HTMLTextAreaElement_put_onchange,
374 HTMLTextAreaElement_get_onchange,
375 HTMLTextAreaElement_put_onselect,
376 HTMLTextAreaElement_get_onselect,
377 HTMLTextAreaElement_put_readOnly,
378 HTMLTextAreaElement_get_readOnly,
379 HTMLTextAreaElement_put_rows,
380 HTMLTextAreaElement_get_rows,
381 HTMLTextAreaElement_put_cols,
382 HTMLTextAreaElement_get_cols,
383 HTMLTextAreaElement_put_wrap,
384 HTMLTextAreaElement_get_wrap,
385 HTMLTextAreaElement_createTextRange
388 static inline HTMLTextAreaElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
390 return CONTAINING_RECORD(iface, HTMLTextAreaElement, element.node);
393 static HRESULT HTMLTextAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
395 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
397 *ppv = NULL;
399 if(IsEqualGUID(&IID_IUnknown, riid)) {
400 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
401 *ppv = &This->IHTMLTextAreaElement_iface;
402 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
403 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
404 *ppv = &This->IHTMLTextAreaElement_iface;
405 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
406 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
407 *ppv = &This->IHTMLTextAreaElement_iface;
410 if(*ppv) {
411 IUnknown_AddRef((IUnknown*)*ppv);
412 return S_OK;
415 return HTMLElement_QI(&This->element.node, riid, ppv);
418 static HRESULT HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
420 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
421 return IHTMLTextAreaElement_put_disabled(&This->IHTMLTextAreaElement_iface, v);
424 static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
426 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
427 return IHTMLTextAreaElement_get_disabled(&This->IHTMLTextAreaElement_iface, p);
430 static BOOL HTMLTextAreaElement_is_text_edit(HTMLDOMNode *iface)
432 return TRUE;
435 static void HTMLTextAreaElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
437 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
439 if(This->nstextarea)
440 note_cc_edge((nsISupports*)This->nstextarea, "This->nstextarea", cb);
443 static void HTMLTextAreaElement_unlink(HTMLDOMNode *iface)
445 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
447 if(This->nstextarea) {
448 nsIDOMHTMLTextAreaElement *nstextarea = This->nstextarea;
450 This->nstextarea = NULL;
451 nsIDOMHTMLTextAreaElement_Release(nstextarea);
455 static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
456 &CLSID_HTMLTextAreaElement,
457 HTMLTextAreaElement_QI,
458 HTMLElement_destructor,
459 HTMLElement_cpc,
460 HTMLElement_clone,
461 HTMLElement_handle_event,
462 HTMLElement_get_attr_col,
463 NULL,
464 HTMLTextAreaElementImpl_put_disabled,
465 HTMLTextAreaElementImpl_get_disabled,
466 NULL,
467 NULL,
468 NULL,
469 NULL,
470 NULL,
471 HTMLTextAreaElement_traverse,
472 HTMLTextAreaElement_unlink,
473 HTMLTextAreaElement_is_text_edit
476 static const tid_t HTMLTextAreaElement_iface_tids[] = {
477 HTMLELEMENT_TIDS,
478 IHTMLTextAreaElement_tid,
482 static dispex_static_data_t HTMLTextAreaElement_dispex = {
483 NULL,
484 DispHTMLTextAreaElement_tid,
485 HTMLTextAreaElement_iface_tids,
486 HTMLElement_init_dispex_info
489 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
491 HTMLTextAreaElement *ret;
492 nsresult nsres;
494 ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
495 if(!ret)
496 return E_OUTOFMEMORY;
498 ret->IHTMLTextAreaElement_iface.lpVtbl = &HTMLTextAreaElementVtbl;
499 ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
501 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex);
503 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement, (void**)&ret->nstextarea);
504 assert(nsres == NS_OK);
506 *elem = &ret->element;
507 return S_OK;