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(IXMLDOMImplementation
*iface
)
81 domimpl
*domimpl
= impl_from_IXMLDOMImplementation(iface
);
82 ULONG ref
= InterlockedIncrement(&domimpl
->ref
);
83 TRACE("%p, refcount %lu.\n", iface
, ref
);
87 static ULONG WINAPI
domimpl_Release(IXMLDOMImplementation
*iface
)
89 domimpl
*domimpl
= impl_from_IXMLDOMImplementation(iface
);
90 ULONG ref
= InterlockedDecrement(&domimpl
->ref
);
92 TRACE("%p, refcount %lu.\n", iface
, ref
);
100 static HRESULT WINAPI
domimpl_GetTypeInfoCount(
101 IXMLDOMImplementation
*iface
,
104 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
105 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
108 static HRESULT WINAPI
domimpl_GetTypeInfo(
109 IXMLDOMImplementation
*iface
,
110 UINT iTInfo
, LCID lcid
,
111 ITypeInfo
** ppTInfo
)
113 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
114 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
115 iTInfo
, lcid
, ppTInfo
);
118 static HRESULT WINAPI
domimpl_GetIDsOfNames(
119 IXMLDOMImplementation
*iface
,
120 REFIID riid
, LPOLESTR
* rgszNames
,
121 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
123 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
124 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
125 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
128 static HRESULT WINAPI
domimpl_Invoke(
129 IXMLDOMImplementation
*iface
,
130 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
131 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
132 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
134 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
135 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
136 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
139 static HRESULT WINAPI
domimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
141 static const WCHAR bVersion
[] = {'1','.','0',0};
142 static const WCHAR bXML
[] = {'X','M','L',0};
143 static const WCHAR bDOM
[] = {'D','O','M',0};
144 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
145 BOOL bValidFeature
= FALSE
;
146 BOOL bValidVersion
= FALSE
;
148 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(feature
), debugstr_w(version
), hasFeature
);
150 if(!feature
|| !hasFeature
)
153 *hasFeature
= VARIANT_FALSE
;
155 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
156 bValidVersion
= TRUE
;
158 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
159 bValidFeature
= TRUE
;
161 if(bValidVersion
&& bValidFeature
)
162 *hasFeature
= VARIANT_TRUE
;
167 static const struct IXMLDOMImplementationVtbl domimpl_vtbl
=
169 domimpl_QueryInterface
,
172 domimpl_GetTypeInfoCount
,
174 domimpl_GetIDsOfNames
,
179 static const tid_t domimpl_iface_tids
[] =
181 IXMLDOMImplementation_tid
,
185 static dispex_static_data_t domimpl_dispex
=
188 IXMLDOMImplementation_tid
,
193 HRESULT
create_dom_implementation(IXMLDOMImplementation
**ret
)
197 if (!(object
= heap_alloc(sizeof(*object
))))
198 return E_OUTOFMEMORY
;
200 object
->IXMLDOMImplementation_iface
.lpVtbl
= &domimpl_vtbl
;
202 init_dispex(&object
->dispex
, (IUnknown
*)&object
->IXMLDOMImplementation_iface
, &domimpl_dispex
);
204 *ret
= &object
->IXMLDOMImplementation_iface
;