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
25 typedef struct _domimpl
28 IXMLDOMImplementation IXMLDOMImplementation_iface
;
32 static inline domimpl
*impl_from_IXMLDOMImplementation( IXMLDOMImplementation
*iface
)
34 return CONTAINING_RECORD(iface
, domimpl
, IXMLDOMImplementation_iface
);
37 static HRESULT WINAPI
dimimpl_QueryInterface(
38 IXMLDOMImplementation
*iface
,
42 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
43 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
45 if ( IsEqualGUID( riid
, &IID_IXMLDOMImplementation
) ||
46 IsEqualGUID( riid
, &IID_IDispatch
) ||
47 IsEqualGUID( riid
, &IID_IUnknown
) )
51 else if (dispex_query_interface(&This
->dispex
, riid
, ppvObject
))
53 return *ppvObject
? S_OK
: E_NOINTERFACE
;
57 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
62 IXMLDOMImplementation_AddRef( iface
);
67 static ULONG WINAPI
dimimpl_AddRef(
68 IXMLDOMImplementation
*iface
)
70 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
71 ULONG ref
= InterlockedIncrement( &This
->ref
);
72 TRACE("(%p)->(%d)\n", This
, ref
);
76 static ULONG WINAPI
dimimpl_Release(
77 IXMLDOMImplementation
*iface
)
79 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
80 ULONG ref
= InterlockedDecrement( &This
->ref
);
82 TRACE("(%p)->(%d)\n", This
, ref
);
85 release_dispex(&This
->dispex
);
92 static HRESULT WINAPI
dimimpl_GetTypeInfoCount(
93 IXMLDOMImplementation
*iface
,
96 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
97 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
100 static HRESULT WINAPI
dimimpl_GetTypeInfo(
101 IXMLDOMImplementation
*iface
,
102 UINT iTInfo
, LCID lcid
,
103 ITypeInfo
** ppTInfo
)
105 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
106 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
,
107 iTInfo
, lcid
, ppTInfo
);
110 static HRESULT WINAPI
dimimpl_GetIDsOfNames(
111 IXMLDOMImplementation
*iface
,
112 REFIID riid
, LPOLESTR
* rgszNames
,
113 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
115 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
116 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
,
117 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
120 static HRESULT WINAPI
dimimpl_Invoke(
121 IXMLDOMImplementation
*iface
,
122 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
123 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
124 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
126 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
127 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
,
128 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
131 static HRESULT WINAPI
dimimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
133 static const WCHAR bVersion
[] = {'1','.','0',0};
134 static const WCHAR bXML
[] = {'X','M','L',0};
135 static const WCHAR bDOM
[] = {'D','O','M',0};
136 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
137 BOOL bValidFeature
= FALSE
;
138 BOOL bValidVersion
= FALSE
;
140 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(feature
), debugstr_w(version
), hasFeature
);
142 if(!feature
|| !hasFeature
)
145 *hasFeature
= VARIANT_FALSE
;
147 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
148 bValidVersion
= TRUE
;
150 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
151 bValidFeature
= TRUE
;
153 if(bValidVersion
&& bValidFeature
)
154 *hasFeature
= VARIANT_TRUE
;
159 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl
=
161 dimimpl_QueryInterface
,
164 dimimpl_GetTypeInfoCount
,
166 dimimpl_GetIDsOfNames
,
171 static const tid_t dimimpl_iface_tids
[] = {
172 IXMLDOMImplementation_tid
,
176 static dispex_static_data_t dimimpl_dispex
= {
178 IXMLDOMImplementation_tid
,
183 IUnknown
* create_doc_Implementation(void)
187 This
= heap_alloc( sizeof *This
);
191 This
->IXMLDOMImplementation_iface
.lpVtbl
= &dimimpl_vtbl
;
193 init_dispex(&This
->dispex
, (IUnknown
*)&This
->IXMLDOMImplementation_iface
, &dimimpl_dispex
);
195 return (IUnknown
*)&This
->IXMLDOMImplementation_iface
;