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