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
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
40 typedef struct _domimpl
42 const struct IXMLDOMImplementationVtbl
*lpVtbl
;
46 static inline domimpl
*impl_from_IXMLDOMImplementation( IXMLDOMImplementation
*iface
)
48 return (domimpl
*)((char*)iface
- FIELD_OFFSET(domimpl
, lpVtbl
));
51 static HRESULT WINAPI
dimimpl_QueryInterface(
52 IXMLDOMImplementation
*iface
,
56 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
57 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
59 if ( IsEqualGUID( riid
, &IID_IXMLDOMImplementation
) ||
60 IsEqualGUID( riid
, &IID_IDispatch
) ||
61 IsEqualGUID( riid
, &IID_IUnknown
) )
67 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
71 IXMLDOMImplementation_AddRef( iface
);
76 static ULONG WINAPI
dimimpl_AddRef(
77 IXMLDOMImplementation
*iface
)
79 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
80 return InterlockedIncrement( &This
->ref
);
83 static ULONG WINAPI
dimimpl_Release(
84 IXMLDOMImplementation
*iface
)
86 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
89 ref
= InterlockedDecrement( &This
->ref
);
92 HeapFree( GetProcessHeap(), 0, This
);
98 static HRESULT WINAPI
dimimpl_GetTypeInfoCount(
99 IXMLDOMImplementation
*iface
,
102 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
104 TRACE("(%p)->(%p)\n", This
, pctinfo
);
111 static HRESULT WINAPI
dimimpl_GetTypeInfo(
112 IXMLDOMImplementation
*iface
,
113 UINT iTInfo
, LCID lcid
,
114 ITypeInfo
** ppTInfo
)
116 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
119 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
121 hr
= get_typeinfo(IXMLDOMImplementation_tid
, ppTInfo
);
126 static HRESULT WINAPI
dimimpl_GetIDsOfNames(
127 IXMLDOMImplementation
*iface
,
128 REFIID riid
, LPOLESTR
* rgszNames
,
129 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
131 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
135 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
138 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
141 hr
= get_typeinfo(IXMLDOMImplementation_tid
, &typeinfo
);
144 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
145 ITypeInfo_Release(typeinfo
);
151 static HRESULT WINAPI
dimimpl_Invoke(
152 IXMLDOMImplementation
*iface
,
153 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
154 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
155 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
157 domimpl
*This
= impl_from_IXMLDOMImplementation( iface
);
161 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
162 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
164 hr
= get_typeinfo(IXMLDOMImplementation_tid
, &typeinfo
);
167 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
168 pVarResult
, pExcepInfo
, puArgErr
);
169 ITypeInfo_Release(typeinfo
);
175 static HRESULT WINAPI
dimimpl_hasFeature(IXMLDOMImplementation
* This
, BSTR feature
, BSTR version
, VARIANT_BOOL
*hasFeature
)
177 static const WCHAR bVersion
[] = {'1','.','0',0};
178 static const WCHAR bXML
[] = {'X','M','L',0};
179 static const WCHAR bDOM
[] = {'D','O','M',0};
180 static const WCHAR bMSDOM
[] = {'M','S','-','D','O','M',0};
181 BOOL bValidFeature
= FALSE
;
182 BOOL bValidVersion
= FALSE
;
184 TRACE("feature(%s) version (%s)\n", debugstr_w(feature
), debugstr_w(version
));
186 if(!feature
|| !hasFeature
)
189 *hasFeature
= VARIANT_FALSE
;
191 if(!version
|| lstrcmpiW(version
, bVersion
) == 0)
192 bValidVersion
= TRUE
;
194 if(lstrcmpiW(feature
, bXML
) == 0 || lstrcmpiW(feature
, bDOM
) == 0 || lstrcmpiW(feature
, bMSDOM
) == 0)
195 bValidFeature
= TRUE
;
197 if(bValidVersion
&& bValidFeature
)
198 *hasFeature
= VARIANT_TRUE
;
203 static const struct IXMLDOMImplementationVtbl dimimpl_vtbl
=
205 dimimpl_QueryInterface
,
208 dimimpl_GetTypeInfoCount
,
210 dimimpl_GetIDsOfNames
,
215 IUnknown
* create_doc_Implementation(void)
219 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
223 This
->lpVtbl
= &dimimpl_vtbl
;
226 return (IUnknown
*) &This
->lpVtbl
;