user32: Convert menu and string table resources to po files.
[wine.git] / dlls / mshtml / htmlstyleelem.c
blob942f422bbeb2dc0fac05076cba1942a377f76c7e
1 /*
2 * Copyright 2010 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 "winreg.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 HTMLElement element;
38 IHTMLStyleElement IHTMLStyleElement_iface;
40 nsIDOMHTMLStyleElement *nsstyle;
41 } HTMLStyleElement;
43 static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
45 return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
48 static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
49 REFIID riid, void **ppv)
51 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
58 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
65 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
72 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
87 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
88 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
89 cNames, lcid, rgDispId);
92 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
93 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
96 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
97 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
98 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
101 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
103 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
104 nsAString type_str;
105 nsresult nsres;
107 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
109 nsAString_InitDepend(&type_str, v);
110 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
111 nsAString_Finish(&type_str);
112 if(NS_FAILED(nsres)) {
113 ERR("SetType failed: %08x\n", nsres);
114 return E_FAIL;
117 return S_OK;
120 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
122 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
123 nsAString nsstr;
124 nsresult nsres;
126 TRACE("(%p)->(%p)\n", This, p);
128 nsAString_Init(&nsstr, NULL);
129 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
130 return return_nsstr(nsres, &nsstr, p);
133 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
135 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
136 FIXME("(%p)->(%p)\n", This, p);
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
142 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
143 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
149 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
150 FIXME("(%p)->(%p)\n", This, p);
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
156 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
157 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
158 return E_NOTIMPL;
161 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
163 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
164 FIXME("(%p)->(%p)\n", This, p);
165 return E_NOTIMPL;
168 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
170 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
171 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
172 return E_NOTIMPL;
175 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
177 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
178 FIXME("(%p)->(%p)\n", This, p);
179 return E_NOTIMPL;
182 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
184 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
185 FIXME("(%p)->(%p)\n", This, p);
186 return E_NOTIMPL;
189 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
191 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
192 FIXME("(%p)->(%x)\n", This, v);
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
198 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
199 FIXME("(%p)->(%p)\n", This, p);
200 return E_NOTIMPL;
203 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
205 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
206 nsAString media_str;
207 nsresult nsres;
209 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
211 nsAString_InitDepend(&media_str, v);
212 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
213 nsAString_Finish(&media_str);
214 if(NS_FAILED(nsres)) {
215 ERR("SetMedia failed: %08x\n", nsres);
216 return E_FAIL;
219 return S_OK;
222 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
224 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
225 nsAString nsstr;
226 nsresult nsres;
228 TRACE("(%p)->(%p)\n", This, p);
230 nsAString_Init(&nsstr, NULL);
231 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
232 return return_nsstr(nsres, &nsstr, p);
235 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
236 HTMLStyleElement_QueryInterface,
237 HTMLStyleElement_AddRef,
238 HTMLStyleElement_Release,
239 HTMLStyleElement_GetTypeInfoCount,
240 HTMLStyleElement_GetTypeInfo,
241 HTMLStyleElement_GetIDsOfNames,
242 HTMLStyleElement_Invoke,
243 HTMLStyleElement_put_type,
244 HTMLStyleElement_get_type,
245 HTMLStyleElement_get_readyState,
246 HTMLStyleElement_put_onreadystatechange,
247 HTMLStyleElement_get_onreadystatechange,
248 HTMLStyleElement_put_onload,
249 HTMLStyleElement_get_onload,
250 HTMLStyleElement_put_onerror,
251 HTMLStyleElement_get_onerror,
252 HTMLStyleElement_get_styleSheet,
253 HTMLStyleElement_put_disabled,
254 HTMLStyleElement_get_disabled,
255 HTMLStyleElement_put_media,
256 HTMLStyleElement_get_media
259 static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
261 return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
264 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
266 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
268 if(IsEqualGUID(&IID_IUnknown, riid)) {
269 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
270 *ppv = &This->IHTMLStyleElement_iface;
271 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
272 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
273 *ppv = &This->IHTMLStyleElement_iface;
274 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
275 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
276 *ppv = &This->IHTMLStyleElement_iface;
277 }else {
278 return HTMLElement_QI(&This->element.node, riid, ppv);
281 IUnknown_AddRef((IUnknown*)*ppv);
282 return S_OK;
285 static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
287 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
289 if(This->nsstyle)
290 nsIDOMHTMLStyleElement_Release(This->nsstyle);
292 HTMLElement_destructor(&This->element.node);
295 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
296 HTMLStyleElement_QI,
297 HTMLStyleElement_destructor,
298 HTMLElement_clone
301 static const tid_t HTMLStyleElement_iface_tids[] = {
302 HTMLELEMENT_TIDS,
303 IHTMLStyleElement_tid,
306 static dispex_static_data_t HTMLStyleElement_dispex = {
307 NULL,
308 DispHTMLStyleElement_tid,
309 NULL,
310 HTMLStyleElement_iface_tids
313 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
315 HTMLStyleElement *ret;
316 nsresult nsres;
318 ret = heap_alloc_zero(sizeof(*ret));
319 if(!ret)
320 return E_OUTOFMEMORY;
322 ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
323 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
325 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
326 if(NS_FAILED(nsres)) {
327 ERR("Could not get nsIDOMHTMLStyleElement iface: %08x\n", nsres);
328 heap_free(ret);
329 return E_FAIL;
332 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
333 *elem = &ret->element;
334 return S_OK;