comctl32: We can now store binary files in the repository.
[wine] / dlls / mshtml / htmltextarea.c
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
31
32 #include "wine/debug.h"
33
34 #include "mshtml_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37
38 typedef struct {
39     HTMLElement element;
40
41     const IHTMLTextAreaElementVtbl *lpHTMLTextAreaElementVtbl;
42
43     nsIDOMHTMLTextAreaElement *nstextarea;
44 } HTMLTextAreaElement;
45
46 #define HTMLTXTAREA(x)  ((IHTMLTextAreaElement*)  &(x)->lpHTMLTextAreaElementVtbl)
47
48 #define HTMLTXTAREA_THIS(iface) DEFINE_THIS(HTMLTextAreaElement, HTMLTextAreaElement, iface)
49
50 static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *iface,
51                                                          REFIID riid, void **ppv)
52 {
53     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
54     HRESULT hres;
55
56     *ppv = NULL;
57
58     if(IsEqualGUID(&IID_IUnknown, riid)) {
59         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60         *ppv = HTMLTXTAREA(This);
61     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
62         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
63         *ppv = HTMLTXTAREA(This);
64     }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
65         TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
66         *ppv = HTMLTXTAREA(This);
67     }
68
69     if(*ppv) {
70         IUnknown_AddRef((IUnknown*)*ppv);
71         return S_OK;
72     }
73
74     hres = HTMLElement_QI(&This->element, riid, ppv);
75     if(FAILED(hres))
76         WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
77
78     return hres;
79 }
80
81 static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
82 {
83     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
84
85     TRACE("(%p)\n", This);
86
87     return IHTMLDocument2_AddRef(HTMLDOC(This->element.node.doc));
88 }
89
90 static ULONG WINAPI HTMLTextAreaElement_Release(IHTMLTextAreaElement *iface)
91 {
92     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
93
94     TRACE("(%p)\n", This);
95
96     return IHTMLDocument2_Release(HTMLDOC(This->element.node.doc));
97 }
98
99 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement *iface, UINT *pctinfo)
100 {
101     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
102     FIXME("(%p)->(%p)\n", This, pctinfo);
103     return E_NOTIMPL;
104 }
105
106 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfo(IHTMLTextAreaElement *iface, UINT iTInfo,
107                                               LCID lcid, ITypeInfo **ppTInfo)
108 {
109     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
110     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement *iface, REFIID riid,
115                                                 LPOLESTR *rgszNames, UINT cNames,
116                                                 LCID lcid, DISPID *rgDispId)
117 {
118     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
119     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
120                                         lcid, rgDispId);
121     return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI HTMLTextAreaElement_Invoke(IHTMLTextAreaElement *iface, DISPID dispIdMember,
125                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
126                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
127 {
128     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
129     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
130             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
131     return E_NOTIMPL;
132 }
133
134 static HRESULT WINAPI HTMLTextAreaElement_get_type(IHTMLTextAreaElement *iface, BSTR *p)
135 {
136     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
137     FIXME("(%p)->(%p)\n", This, p);
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
142 {
143     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
144     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
149 {
150     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
151     nsAString value_str;
152     const PRUnichar *value;
153     nsresult nsres;
154
155     TRACE("(%p)->(%p)\n", This, p);
156
157     nsAString_Init(&value_str, NULL);
158
159     nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
160     if(NS_SUCCEEDED(nsres)) {
161         nsAString_GetData(&value_str, &value, NULL);
162         *p = SysAllocString(value);
163     }else {
164         ERR("GetValue failed: %08x\n", nsres);
165     }
166
167     nsAString_Finish(&value_str);
168
169     TRACE("%s\n", debugstr_w(*p));
170     return S_OK;
171 }
172
173 static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
174 {
175     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
176     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
181 {
182     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
183     nsAString name_str;
184     const PRUnichar *name;
185     nsresult nsres;
186
187     TRACE("(%p)->(%p)\n", This, p);
188
189     nsAString_Init(&name_str, NULL);
190
191     nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
192     if(NS_SUCCEEDED(nsres)) {
193         nsAString_GetData(&name_str, &name, NULL);
194         *p = SysAllocString(name);
195     }else {
196         ERR("GetName failed: %08x\n", nsres);
197     }
198
199     nsAString_Finish(&name_str);
200
201     TRACE("%s\n", debugstr_w(*p));
202     return S_OK;
203 }
204
205 static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
206 {
207     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
208     FIXME("(%p)->()\n", This);
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI HTMLTextAreaElement_get_status(IHTMLTextAreaElement *iface, VARIANT *p)
213 {
214     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
215     FIXME("(%p)->(%p)\n", This, p);
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
220 {
221     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
222     FIXME("(%p)->(%x)\n", This, v);
223     return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
227 {
228     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
229     FIXME("(%p)->(%p)\n", This, p);
230     return E_NOTIMPL;
231 }
232
233 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
234 {
235     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
236     FIXME("(%p)->(%p)\n", This, p);
237     return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
241 {
242     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
243     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
244     return E_NOTIMPL;
245 }
246
247 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
248 {
249     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
250     FIXME("(%p)->(%p)\n", This, p);
251     return E_NOTIMPL;
252 }
253
254 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
255 {
256     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
257     FIXME("(%p)\n", This);
258     return E_NOTIMPL;
259 }
260
261 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
262 {
263     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
264     FIXME("(%p)->()\n", This);
265     return E_NOTIMPL;
266 }
267
268 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
269 {
270     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
271     FIXME("(%p)->(%p)\n", This, p);
272     return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
276 {
277     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
278     FIXME("(%p)->()\n", This);
279     return E_NOTIMPL;
280 }
281
282 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
283 {
284     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
285     FIXME("(%p)->(%p)\n", This, p);
286     return E_NOTIMPL;
287 }
288
289 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
290 {
291     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
292     FIXME("(%p)->(%x)\n", This, v);
293     return E_NOTIMPL;
294 }
295
296 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
297 {
298     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
299     FIXME("(%p)->(%p)\n", This, p);
300     return E_NOTIMPL;
301 }
302
303 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, long v)
304 {
305     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
306     FIXME("(%p)->(%ld)\n", This, v);
307     return E_NOTIMPL;
308 }
309
310 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, long *p)
311 {
312     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
313     FIXME("(%p)->(%p)\n", This, p);
314     return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, long v)
318 {
319     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
320     FIXME("(%p)->(%ld)\n", This, v);
321     return E_NOTIMPL;
322 }
323
324 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, long *p)
325 {
326     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
327     FIXME("(%p)->(%p)\n", This, p);
328     return E_NOTIMPL;
329 }
330
331 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
332 {
333     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
334     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
335     return E_NOTIMPL;
336 }
337
338 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
339 {
340     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
341     FIXME("(%p)->(%p)\n", This, p);
342     return E_NOTIMPL;
343 }
344
345 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
346                                                           IHTMLTxtRange **range)
347 {
348     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
349     FIXME("(%p)->(%p)\n", This, range);
350     return E_NOTIMPL;
351 }
352
353 static void HTMLTextAreaElement_destructor(IUnknown *iface)
354 {
355     HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
356
357     nsIDOMHTMLTextAreaElement_Release(This->nstextarea);
358     mshtml_free(This);
359 }
360
361 #undef HTMLTXTAREA_THIS
362
363 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
364     HTMLTextAreaElement_QueryInterface,
365     HTMLTextAreaElement_AddRef,
366     HTMLTextAreaElement_Release,
367     HTMLTextAreaElement_GetTypeInfoCount,
368     HTMLTextAreaElement_GetTypeInfo,
369     HTMLTextAreaElement_GetIDsOfNames,
370     HTMLTextAreaElement_Invoke,
371     HTMLTextAreaElement_get_type,
372     HTMLTextAreaElement_put_value,
373     HTMLTextAreaElement_get_value,
374     HTMLTextAreaElement_put_name,
375     HTMLTextAreaElement_get_name,
376     HTMLTextAreaElement_put_status,
377     HTMLTextAreaElement_get_status,
378     HTMLTextAreaElement_put_disabled,
379     HTMLTextAreaElement_get_disabled,
380     HTMLTextAreaElement_get_form,
381     HTMLTextAreaElement_put_defaultValue,
382     HTMLTextAreaElement_get_defaultValue,
383     HTMLTextAreaElement_select,
384     HTMLTextAreaElement_put_onchange,
385     HTMLTextAreaElement_get_onchange,
386     HTMLTextAreaElement_put_onselect,
387     HTMLTextAreaElement_get_onselect,
388     HTMLTextAreaElement_put_readOnly,
389     HTMLTextAreaElement_get_readOnly,
390     HTMLTextAreaElement_put_rows,
391     HTMLTextAreaElement_get_rows,
392     HTMLTextAreaElement_put_cols,
393     HTMLTextAreaElement_get_cols,
394     HTMLTextAreaElement_put_wrap,
395     HTMLTextAreaElement_get_wrap,
396     HTMLTextAreaElement_createTextRange
397 };
398
399 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement *nselem)
400 {
401     HTMLTextAreaElement *ret = mshtml_alloc(sizeof(HTMLTextAreaElement));
402     nsresult nsres;
403
404     ret->lpHTMLTextAreaElementVtbl = &HTMLTextAreaElementVtbl;
405
406     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement,
407                                              (void**)&ret->nstextarea);
408     if(NS_FAILED(nsres))
409         ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres);
410
411     ret->element.impl = (IUnknown*)HTMLTXTAREA(ret);
412     ret->element.destructor = HTMLTextAreaElement_destructor;
413
414     return &ret->element;
415 }