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
21 #define WIN32_NO_STATUS
30 # include <libxml/parser.h>
31 //# include <libxml/xmlerror.h>
36 //#include "winuser.h"
40 #include "msxml_private.h"
42 #include <wine/debug.h>
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
48 typedef struct _domimpl
51 IXMLDOMImplementation IXMLDOMImplementation_iface
;
55 static inline domimpl
*impl_from_IXMLDOMImplementation( IXMLDOMImplementation
*iface
)
57 return CONTAINING_RECORD(iface
, domimpl
, IXMLDOMImplementation_iface
);
60 static HRESULT WINAPI
dimimpl_QueryInterface(
61 IXMLDOMImplementation
*iface
,
65 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
66 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
68 if ( IsEqualGUID( riid
, &IID_IXMLDOMImplementation
) ||
69 IsEqualGUID( riid
, &IID_IDispatch
) ||
70 IsEqualGUID( riid
, &IID_IUnknown
) )
74 else if (dispex_query_interface(&This
->dispex
, riid
, ppvObject
))
76 return *ppvObject
? S_OK
: E_NOINTERFACE
;
80 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
85 IXMLDOMImplementation_AddRef( iface
);
90 static ULONG WINAPI
dimimpl_AddRef(
91 IXMLDOMImplementation
*iface
)
93 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
94 ULONG ref
= InterlockedIncrement( &This
->ref
);
95 TRACE("(%p)->(%d)\n", This
, ref
);
99 static ULONG WINAPI
dimimpl_Release(
100 IXMLDOMImplementation
*iface
)
102 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
103 ULONG ref
= InterlockedDecrement( &This
->ref
);
105 TRACE("(%p)->(%d)\n", This
, ref
);
108 release_dispex(&This
->dispex
);
115 static HRESULT WINAPI
dimimpl_GetTypeInfoCount(
116 IXMLDOMImplementation
*iface
,
119 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
120 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
123 static HRESULT WINAPI
dimimpl_GetTypeInfo(
124 IXMLDOMImplementation
*iface
,
125 UINT iTInfo
, LCID lcid
,
126 ITypeInfo
** ppTInfo
)
128 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
129 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
130 iTInfo
, lcid
, ppTInfo
);
133 static HRESULT WINAPI
dimimpl_GetIDsOfNames(
134 IXMLDOMImplementation
*iface
,
135 REFIID riid
, LPOLESTR
* rgszNames
,
136 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
138 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
139 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
140 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
143 static HRESULT WINAPI
dimimpl_Invoke(
144 IXMLDOMImplementation
*iface
,
145 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
146 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
147 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
149 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
150 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
151 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
154 static HRESULT WINAPI
dimimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
156 static const WCHAR bVersion
[] = {'1','.','0',0};
157 static const WCHAR bXML
[] = {'X','M','L',0};
158 static const WCHAR bDOM
[] = {'D','O','M',0};
159 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
160 BOOL bValidFeature
= FALSE
;
161 BOOL bValidVersion
= FALSE
;
163 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(feature
), debugstr_w(version
), hasFeature
);
165 if(!feature
|| !hasFeature
)
168 *hasFeature
= VARIANT_FALSE
;
170 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
171 bValidVersion
= TRUE
;
173 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
174 bValidFeature
= TRUE
;
176 if(bValidVersion
&& bValidFeature
)
177 *hasFeature
= VARIANT_TRUE
;
182 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl
=
184 dimimpl_QueryInterface
,
187 dimimpl_GetTypeInfoCount
,
189 dimimpl_GetIDsOfNames
,
194 static const tid_t dimimpl_iface_tids
[] = {
195 IXMLDOMImplementation_tid
,
199 static dispex_static_data_t dimimpl_dispex
= {
201 IXMLDOMImplementation_tid
,
206 IUnknown
* create_doc_Implementation(void)
210 This
= heap_alloc( sizeof *This
);
214 This
->IXMLDOMImplementation_iface
.lpVtbl
= &dimimpl_vtbl
;
216 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IXMLDOMImplementation_iface
, &dimimpl_dispex
);
218 return (IUnknown
*)&This
->IXMLDOMImplementation_iface
;