From 2f853fadb1fedf387d11677e474d2b4ef81606ea Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 17 Nov 2006 13:08:09 +0100 Subject: [PATCH] mshtml: Added semi-stub createStyleSheet implementation. --- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmldoc.c | 8 +- dlls/mshtml/htmlstylesheet.c | 324 +++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 1 + 4 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 dlls/mshtml/htmlstylesheet.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 1ed59f400b..d4a08038fd 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -20,6 +20,7 @@ C_SRCS = \ htmlnode.c \ htmlselect.c \ htmlstyle.c \ + htmlstylesheet.c \ htmltextcont.c \ htmltextarea.c \ install.c \ diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 716ec5826a..b133fbcc2d 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -964,8 +964,12 @@ static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String) static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref, long lIndex, IHTMLStyleSheet **ppnewStyleSheet) { - FIXME("(%p)->(%s %ld %p)\n", iface, debugstr_w(bstrHref), lIndex, ppnewStyleSheet); - return E_NOTIMPL; + HTMLDocument *This = HTMLDOC_THIS(iface); + + FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet); + + *ppnewStyleSheet = HTMLStyleSheet_Create(); + return S_OK; } static const IHTMLDocument2Vtbl HTMLDocumentVtbl = { diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c new file mode 100644 index 0000000000..0f0ef12c3f --- /dev/null +++ b/dlls/mshtml/htmlstylesheet.c @@ -0,0 +1,324 @@ +/* + * Copyright 2006 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" +#include "ole2.h" + +#include "wine/debug.h" +#include "wine/unicode.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + const IHTMLStyleSheetVtbl *lpHTMLStyleSheetVtbl; + LONG ref; +} HTMLStyleSheet; + +#define HTMLSTYLESHEET(x) ((IHTMLStyleSheet*) &(x)->lpHTMLStyleSheetVtbl); + +#define HTMLSTYLESHEET_THIS(iface) DEFINE_THIS(HTMLStyleSheet, HTMLStyleSheet, iface) + +static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLSTYLESHEET(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLSTYLESHEET(This); + }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) { + TRACE("(%p)->(IID_IHTMLStyleSheet %p)\n", This, ppv); + *ppv = HTMLSTYLESHEET(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + WARN("unsupported %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) + mshtml_free(This); + + return ref; +} + +static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, pctinfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + lcid, rgDispId); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface, + IHTMLStyleSheet **p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%x)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface, + IHTMLStyleSheetsCollection **p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL, + long lIndex, long *plIndex) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s %ld %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector, + BSTR bstrStyle, long lIndex, long *plIndex) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s %s %ld %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle), + lIndex, plIndex); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, long lIndex) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%ld)\n", This, lIndex); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, long lIndex) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%ld)\n", This, lIndex); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface, + IHTMLStyleSheetRulesCollection **p) +{ + HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = { + HTMLStyleSheet_QueryInterface, + HTMLStyleSheet_AddRef, + HTMLStyleSheet_Release, + HTMLStyleSheet_GetTypeInfoCount, + HTMLStyleSheet_GetTypeInfo, + HTMLStyleSheet_GetIDsOfNames, + HTMLStyleSheet_Invoke, + HTMLStyleSheet_put_title, + HTMLStyleSheet_get_title, + HTMLStyleSheet_get_parentStyleSheet, + HTMLStyleSheet_get_owningElement, + HTMLStyleSheet_put_disabled, + HTMLStyleSheet_get_disabled, + HTMLStyleSheet_get_readOnly, + HTMLStyleSheet_get_imports, + HTMLStyleSheet_put_href, + HTMLStyleSheet_get_href, + HTMLStyleSheet_get_type, + HTMLStyleSheet_get_id, + HTMLStyleSheet_addImport, + HTMLStyleSheet_addRule, + HTMLStyleSheet_removeImport, + HTMLStyleSheet_removeRule, + HTMLStyleSheet_put_media, + HTMLStyleSheet_get_media, + HTMLStyleSheet_put_cssText, + HTMLStyleSheet_get_cssText, + HTMLStyleSheet_get_rules +}; + +IHTMLStyleSheet *HTMLStyleSheet_Create(void) +{ + HTMLStyleSheet *ret = mshtml_alloc(sizeof(HTMLStyleSheet)); + + ret->lpHTMLStyleSheetVtbl = &HTMLStyleSheetVtbl; + ret->ref = 1; + + return HTMLSTYLESHEET(ret); +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index abc283b393..452a53cb04 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -330,6 +330,7 @@ IHlink *Hlink_Create(void); IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*); IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*); IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*); +IHTMLStyleSheet *HTMLStyleSheet_Create(void); void HTMLElement_Create(HTMLDOMNode*); void HTMLBodyElement_Create(HTMLElement*);