kernel32: Update Italian translation.
[wine/testsucceed.git] / dlls / mshtml / htmlscript.c
blobf39e3061c5d2aa6943c8578f09dcf245b912f199
1 /*
2 * Copyright 2008 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 IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl;
39 nsIDOMHTMLScriptElement *nsscript;
40 } HTMLScriptElement;
42 #define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl)
44 #define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface)
46 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
47 REFIID riid, void **ppv)
49 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
56 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
63 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
70 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
71 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
74 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
75 LCID lcid, ITypeInfo **ppTInfo)
77 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
78 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
81 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
82 LPOLESTR *rgszNames, UINT cNames,
83 LCID lcid, DISPID *rgDispId)
85 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
86 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
94 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
95 pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
100 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
101 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
102 return E_NOTIMPL;
105 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
107 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
108 FIXME("(%p)->(%p)\n", This, p);
109 return E_NOTIMPL;
112 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
114 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
115 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
116 return E_NOTIMPL;
119 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
121 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
122 FIXME("(%p)->(%p)\n", This, p);
123 return E_NOTIMPL;
126 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
128 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
129 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
130 return E_NOTIMPL;
133 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
135 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
136 FIXME("(%p)->(%p)\n", This, p);
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
142 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
143 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
149 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
150 FIXME("(%p)->(%p)\n", This, p);
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
156 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
157 HRESULT hr = S_OK;
158 nsresult nsres;
160 TRACE("(%p)->(%x)\n", This, v);
162 nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
163 if(NS_FAILED(nsres))
165 hr = E_FAIL;
168 return hr;
171 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
173 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
174 PRBool defer = FALSE;
175 nsresult nsres;
177 TRACE("(%p)->(%p)\n", This, p);
179 if(!p)
180 return E_INVALIDARG;
182 nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
183 if(NS_FAILED(nsres)) {
184 ERR("GetSrc failed: %08x\n", nsres);
187 *p = defer ? VARIANT_TRUE : VARIANT_FALSE;
189 TRACE("*p = %d\n", *p);
190 return S_OK;
193 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
195 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
196 FIXME("(%p)->(%p)\n", This, p);
197 return E_NOTIMPL;
200 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
202 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
203 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
204 return E_NOTIMPL;
207 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
209 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
210 FIXME("(%p)->(%p)\n", This, p);
211 return E_NOTIMPL;
214 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
216 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
217 nsAString nstype_str;
218 nsresult nsres;
220 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
222 nsAString_Init(&nstype_str, v);
223 nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str);
224 if (NS_FAILED(nsres))
225 ERR("SetType failed: %08x\n", nsres);
226 nsAString_Finish (&nstype_str);
228 return S_OK;
231 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
233 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
234 const PRUnichar *nstype;
235 nsAString nstype_str;
236 nsresult nsres;
238 TRACE("(%p)->(%p)\n", This, p);
240 nsAString_Init(&nstype_str, NULL);
241 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
242 if(NS_FAILED(nsres))
243 ERR("GetType failed: %08x\n", nsres);
245 nsAString_GetData(&nstype_str, &nstype);
246 *p = *nstype ? SysAllocString(nstype) : NULL;
247 nsAString_Finish(&nstype_str);
249 return S_OK;
252 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
253 HTMLScriptElement_QueryInterface,
254 HTMLScriptElement_AddRef,
255 HTMLScriptElement_Release,
256 HTMLScriptElement_GetTypeInfoCount,
257 HTMLScriptElement_GetTypeInfo,
258 HTMLScriptElement_GetIDsOfNames,
259 HTMLScriptElement_Invoke,
260 HTMLScriptElement_put_src,
261 HTMLScriptElement_get_src,
262 HTMLScriptElement_put_htmlFor,
263 HTMLScriptElement_get_htmlFor,
264 HTMLScriptElement_put_event,
265 HTMLScriptElement_get_event,
266 HTMLScriptElement_put_text,
267 HTMLScriptElement_get_text,
268 HTMLScriptElement_put_defer,
269 HTMLScriptElement_get_defer,
270 HTMLScriptElement_get_readyState,
271 HTMLScriptElement_put_onerror,
272 HTMLScriptElement_get_onerror,
273 HTMLScriptElement_put_type,
274 HTMLScriptElement_get_type
277 #undef HTMLSCRIPT_THIS
279 #define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface)
281 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
283 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
285 *ppv = NULL;
287 if(IsEqualGUID(&IID_IUnknown, riid)) {
288 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
289 *ppv = HTMLSCRIPT(This);
290 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
291 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
292 *ppv = HTMLSCRIPT(This);
293 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
294 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
295 *ppv = HTMLSCRIPT(This);
298 if(*ppv) {
299 IUnknown_AddRef((IUnknown*)*ppv);
300 return S_OK;
303 return HTMLElement_QI(&This->element.node, riid, ppv);
306 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
308 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
309 HTMLElement_destructor(&This->element.node);
312 static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
314 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
316 return IHTMLScriptElement_get_readyState(HTMLSCRIPT(This), p);
319 #undef HTMLSCRIPT_NODE_THIS
321 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
322 HTMLScriptElement_QI,
323 HTMLScriptElement_destructor,
324 NULL,
325 NULL,
326 NULL,
327 NULL,
328 NULL,
329 HTMLScriptElement_get_readystate
332 static const tid_t HTMLScriptElement_iface_tids[] = {
333 HTMLELEMENT_TIDS,
334 IHTMLScriptElement_tid,
338 static dispex_static_data_t HTMLScriptElement_dispex = {
339 NULL,
340 DispHTMLScriptElement_tid,
341 NULL,
342 HTMLScriptElement_iface_tids
345 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
347 HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement));
348 nsresult nsres;
350 ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
351 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
353 HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
355 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
356 if(NS_FAILED(nsres))
357 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
359 return &ret->element;