push 0f15bbd80d260bbd8adf052e820484a405c49375
[wine/hacks.git] / dlls / mshtml / htmlstylesheet.c
blob30c25cee57101aa22c9819a55a368fa6185495a3
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39 typedef struct {
40 const IHTMLStyleSheetVtbl *lpHTMLStyleSheetVtbl;
42 LONG ref;
44 nsIDOMCSSStyleSheet *nsstylesheet;
45 } HTMLStyleSheet;
47 typedef struct {
48 const IHTMLStyleSheetsCollectionVtbl *lpHTMLStyleSheetsCollectionVtbl;
50 LONG ref;
52 nsIDOMStyleSheetList *nslist;
53 } HTMLStyleSheetsCollection;
55 #define HTMLSTYLESHEET(x) ((IHTMLStyleSheet*) &(x)->lpHTMLStyleSheetVtbl);
56 #define HTMLSTYLESHEETSCOL(x) ((IHTMLStyleSheetsCollection*) &(x)->lpHTMLStyleSheetsCollectionVtbl);
58 #define HTMLSTYLESHEETSCOL_THIS(iface) \
59 DEFINE_THIS(HTMLStyleSheetsCollection, HTMLStyleSheetsCollection, iface)
61 static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
62 REFIID riid, void **ppv)
64 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
66 *ppv = NULL;
68 if(IsEqualGUID(&IID_IUnknown, riid)) {
69 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
70 *ppv = HTMLSTYLESHEETSCOL(This);
71 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
72 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
73 *ppv = HTMLSTYLESHEETSCOL(This);
74 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
75 TRACE("(%p)->(IID_IHTMLStyleSheetsCollection %p)\n", This, ppv);
76 *ppv = HTMLSTYLESHEETSCOL(This);
79 if(*ppv) {
80 IUnknown_AddRef((IUnknown*)*ppv);
81 return S_OK;
84 WARN("unsupported %s\n", debugstr_guid(riid));
85 return E_NOINTERFACE;
88 static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
90 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
91 LONG ref = InterlockedIncrement(&This->ref);
93 TRACE("(%p) ref=%d\n", This, ref);
95 return ref;
98 static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
100 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
101 LONG ref = InterlockedDecrement(&This->ref);
103 TRACE("(%p) ref=%d\n", This, ref);
105 if(!ref)
106 mshtml_free(This);
108 return ref;
111 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
112 UINT *pctinfo)
114 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
115 FIXME("(%p)->(%p)\n", This, pctinfo);
116 return E_NOTIMPL;
119 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
120 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
122 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
123 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
124 return E_NOTIMPL;
127 static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
128 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
130 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
131 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
132 lcid, rgDispId);
133 return E_NOTIMPL;
136 static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
137 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
138 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
140 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
141 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
142 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
143 return E_NOTIMPL;
146 static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
147 long *p)
149 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
150 PRUint32 len = 0;
152 TRACE("(%p)->(%p)\n", This, p);
154 if(This->nslist)
155 nsIDOMStyleSheetList_GetLength(This->nslist, &len);
157 *p = len;
158 return S_OK;
161 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
162 IUnknown **p)
164 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
165 FIXME("(%p)->(%p)\n", This, p);
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
170 VARIANT *pvarIndex, VARIANT *pvarResult)
172 HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
174 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
176 switch(V_VT(pvarIndex)) {
177 case VT_I4: {
178 nsIDOMStyleSheet *nsstylesheet;
179 nsresult nsres;
181 TRACE("index=%d\n", V_I4(pvarIndex));
183 nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
184 if(NS_FAILED(nsres) || !nsstylesheet) {
185 WARN("Item failed: %08x\n", nsres);
186 V_VT(pvarResult) = VT_EMPTY;
187 return E_INVALIDARG;
190 V_VT(pvarResult) = VT_DISPATCH;
191 V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
193 return S_OK;
196 case VT_BSTR:
197 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
198 return E_NOTIMPL;
200 default:
201 WARN("Invalid vt=%d\n", V_VT(pvarIndex));
204 return E_INVALIDARG;
207 #undef HTMLSTYLESHEETSCOL_THIS
209 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
210 HTMLStyleSheetsCollection_QueryInterface,
211 HTMLStyleSheetsCollection_AddRef,
212 HTMLStyleSheetsCollection_Release,
213 HTMLStyleSheetsCollection_GetTypeInfoCount,
214 HTMLStyleSheetsCollection_GetTypeInfo,
215 HTMLStyleSheetsCollection_GetIDsOfNames,
216 HTMLStyleSheetsCollection_Invoke,
217 HTMLStyleSheetsCollection_get_length,
218 HTMLStyleSheetsCollection_get__newEnum,
219 HTMLStyleSheetsCollection_item
222 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
224 HTMLStyleSheetsCollection *ret = mshtml_alloc(sizeof(HTMLStyleSheetsCollection));
226 ret->lpHTMLStyleSheetsCollectionVtbl = &HTMLStyleSheetsCollectionVtbl;
227 ret->ref = 1;
229 if(nslist)
230 nsIDOMStyleSheetList_AddRef(nslist);
231 ret->nslist = nslist;
233 return HTMLSTYLESHEETSCOL(ret);
236 #define HTMLSTYLESHEET_THIS(iface) DEFINE_THIS(HTMLStyleSheet, HTMLStyleSheet, iface)
238 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
240 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
242 *ppv = NULL;
244 if(IsEqualGUID(&IID_IUnknown, riid)) {
245 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
246 *ppv = HTMLSTYLESHEET(This);
247 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
248 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
249 *ppv = HTMLSTYLESHEET(This);
250 }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
251 TRACE("(%p)->(IID_IHTMLStyleSheet %p)\n", This, ppv);
252 *ppv = HTMLSTYLESHEET(This);
255 if(*ppv) {
256 IUnknown_AddRef((IUnknown*)*ppv);
257 return S_OK;
260 WARN("unsupported %s\n", debugstr_guid(riid));
261 return E_NOINTERFACE;
264 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
266 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
267 LONG ref = InterlockedIncrement(&This->ref);
269 TRACE("(%p) ref=%d\n", This, ref);
271 return ref;
274 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
276 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
277 LONG ref = InterlockedDecrement(&This->ref);
279 TRACE("(%p) ref=%d\n", This, ref);
281 if(!ref)
282 mshtml_free(This);
284 return ref;
287 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
289 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
290 FIXME("(%p)->(%p)\n", This, pctinfo);
291 return E_NOTIMPL;
294 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
295 LCID lcid, ITypeInfo **ppTInfo)
297 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
298 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
299 return E_NOTIMPL;
302 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
303 LPOLESTR *rgszNames, UINT cNames,
304 LCID lcid, DISPID *rgDispId)
306 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
307 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
308 lcid, rgDispId);
309 return E_NOTIMPL;
312 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
313 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
314 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
316 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
317 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
318 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
319 return E_NOTIMPL;
322 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
324 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
325 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
326 return E_NOTIMPL;
329 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
331 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
332 FIXME("(%p)->(%p)\n", This, p);
333 return E_NOTIMPL;
336 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
337 IHTMLStyleSheet **p)
339 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
340 FIXME("(%p)->(%p)\n", This, p);
341 return E_NOTIMPL;
344 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
346 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
347 FIXME("(%p)->(%p)\n", This, p);
348 return E_NOTIMPL;
351 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
353 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
354 FIXME("(%p)->(%x)\n", This, v);
355 return E_NOTIMPL;
358 static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
360 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
361 FIXME("(%p)->(%p)\n", This, p);
362 return E_NOTIMPL;
365 static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
367 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
368 FIXME("(%p)->(%p)\n", This, p);
369 return E_NOTIMPL;
372 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
373 IHTMLStyleSheetsCollection **p)
375 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
376 FIXME("(%p)->(%p)\n", This, p);
377 return E_NOTIMPL;
380 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
382 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
383 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
384 return E_NOTIMPL;
387 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
389 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
390 FIXME("(%p)->(%p)\n", This, p);
391 return E_NOTIMPL;
394 static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
396 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
397 FIXME("(%p)->(%p)\n", This, p);
398 return E_NOTIMPL;
401 static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
403 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
404 FIXME("(%p)->(%p)\n", This, p);
405 return E_NOTIMPL;
408 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
409 long lIndex, long *plIndex)
411 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
412 FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
413 return E_NOTIMPL;
416 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
417 BSTR bstrStyle, long lIndex, long *plIndex)
419 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
420 FIXME("(%p)->(%s %s %ld %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
421 lIndex, plIndex);
422 return E_NOTIMPL;
425 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, long lIndex)
427 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
428 FIXME("(%p)->(%ld)\n", This, lIndex);
429 return E_NOTIMPL;
432 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, long lIndex)
434 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
435 FIXME("(%p)->(%ld)\n", This, lIndex);
436 return E_NOTIMPL;
439 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
441 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
442 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
443 return E_NOTIMPL;
446 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
448 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
449 FIXME("(%p)->(%p)\n", This, p);
450 return E_NOTIMPL;
453 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
455 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
456 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
457 return E_NOTIMPL;
460 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
462 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
463 FIXME("(%p)->(%p)\n", This, p);
464 return E_NOTIMPL;
467 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
468 IHTMLStyleSheetRulesCollection **p)
470 HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, p);
472 return E_NOTIMPL;
475 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
476 HTMLStyleSheet_QueryInterface,
477 HTMLStyleSheet_AddRef,
478 HTMLStyleSheet_Release,
479 HTMLStyleSheet_GetTypeInfoCount,
480 HTMLStyleSheet_GetTypeInfo,
481 HTMLStyleSheet_GetIDsOfNames,
482 HTMLStyleSheet_Invoke,
483 HTMLStyleSheet_put_title,
484 HTMLStyleSheet_get_title,
485 HTMLStyleSheet_get_parentStyleSheet,
486 HTMLStyleSheet_get_owningElement,
487 HTMLStyleSheet_put_disabled,
488 HTMLStyleSheet_get_disabled,
489 HTMLStyleSheet_get_readOnly,
490 HTMLStyleSheet_get_imports,
491 HTMLStyleSheet_put_href,
492 HTMLStyleSheet_get_href,
493 HTMLStyleSheet_get_type,
494 HTMLStyleSheet_get_id,
495 HTMLStyleSheet_addImport,
496 HTMLStyleSheet_addRule,
497 HTMLStyleSheet_removeImport,
498 HTMLStyleSheet_removeRule,
499 HTMLStyleSheet_put_media,
500 HTMLStyleSheet_get_media,
501 HTMLStyleSheet_put_cssText,
502 HTMLStyleSheet_get_cssText,
503 HTMLStyleSheet_get_rules
506 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
508 HTMLStyleSheet *ret = mshtml_alloc(sizeof(HTMLStyleSheet));
509 nsresult nsres;
511 ret->lpHTMLStyleSheetVtbl = &HTMLStyleSheetVtbl;
512 ret->ref = 1;
513 ret->nsstylesheet = NULL;
515 if(nsstylesheet) {
516 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
517 (void**)&ret->nsstylesheet);
518 if(NS_FAILED(nsres))
519 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
522 return HTMLSTYLESHEET(ret);