2 * DOM Document Implementation implementation
4 * Copyright 2007 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "msxml_dispex.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
37 typedef struct _domimpl
40 IXMLDOMImplementation IXMLDOMImplementation_iface
;
44 static inline domimpl
*impl_from_IXMLDOMImplementation( IXMLDOMImplementation
*iface
)
46 return CONTAINING_RECORD(iface
, domimpl
, IXMLDOMImplementation_iface
);
49 static HRESULT WINAPI
domimpl_QueryInterface(
50 IXMLDOMImplementation
*iface
,
54 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
55 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
57 if ( IsEqualGUID( riid
, &IID_IXMLDOMImplementation
) ||
58 IsEqualGUID( riid
, &IID_IDispatch
) ||
59 IsEqualGUID( riid
, &IID_IUnknown
) )
63 else if (dispex_query_interface(&This
->dispex
, riid
, ppvObject
))
65 return *ppvObject
? S_OK
: E_NOINTERFACE
;
69 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
74 IXMLDOMImplementation_AddRef( iface
);
79 static ULONG WINAPI
domimpl_AddRef(
80 IXMLDOMImplementation
*iface
)
82 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
83 ULONG ref
= InterlockedIncrement( &This
->ref
);
84 TRACE("(%p)->(%d)\n", This
, ref
);
88 static ULONG WINAPI
domimpl_Release(
89 IXMLDOMImplementation
*iface
)
91 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
92 ULONG ref
= InterlockedDecrement( &This
->ref
);
94 TRACE("(%p)->(%d)\n", This
, ref
);
101 static HRESULT WINAPI
domimpl_GetTypeInfoCount(
102 IXMLDOMImplementation
*iface
,
105 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
106 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
109 static HRESULT WINAPI
domimpl_GetTypeInfo(
110 IXMLDOMImplementation
*iface
,
111 UINT iTInfo
, LCID lcid
,
112 ITypeInfo
** ppTInfo
)
114 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
115 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
116 iTInfo
, lcid
, ppTInfo
);
119 static HRESULT WINAPI
domimpl_GetIDsOfNames(
120 IXMLDOMImplementation
*iface
,
121 REFIID riid
, LPOLESTR
* rgszNames
,
122 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
124 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
125 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
126 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
129 static HRESULT WINAPI
domimpl_Invoke(
130 IXMLDOMImplementation
*iface
,
131 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
132 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
133 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
135 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
136 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
137 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
140 static HRESULT WINAPI
domimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
142 static const WCHAR bVersion
[] = {'1','.','0',0};
143 static const WCHAR bXML
[] = {'X','M','L',0};
144 static const WCHAR bDOM
[] = {'D','O','M',0};
145 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
146 BOOL bValidFeature
= FALSE
;
147 BOOL bValidVersion
= FALSE
;
149 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(feature
), debugstr_w(version
), hasFeature
);
151 if(!feature
|| !hasFeature
)
154 *hasFeature
= VARIANT_FALSE
;
156 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
157 bValidVersion
= TRUE
;
159 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
160 bValidFeature
= TRUE
;
162 if(bValidVersion
&& bValidFeature
)
163 *hasFeature
= VARIANT_TRUE
;
168 static const struct IXMLDOMImplementationVtbl domimpl_vtbl
=
170 domimpl_QueryInterface
,
173 domimpl_GetTypeInfoCount
,
175 domimpl_GetIDsOfNames
,
180 static const tid_t domimpl_iface_tids
[] =
182 IXMLDOMImplementation_tid
,
186 static dispex_static_data_t domimpl_dispex
=
189 IXMLDOMImplementation_tid
,
194 HRESULT
create_dom_implementation(IXMLDOMImplementation
**ret
)
198 if (!(object
= heap_alloc(sizeof(*object
))))
199 return E_OUTOFMEMORY
;
201 object
->IXMLDOMImplementation_iface
.lpVtbl
= &domimpl_vtbl
;
203 init_dispex(&object
->dispex
, (IUnknown
*)&object
->IXMLDOMImplementation_iface
, &domimpl_dispex
);
205 *ret
= &object
->IXMLDOMImplementation_iface
;