dinput: Clear DIA_APPNOMAP BuildActionMap flag with specific device semantic.
[wine.git] / dlls / msxml3 / domimpl.c
blob77a30e775ff02b5fa1e6d88ffbaf706f89f4c3c1
1 /*
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 COBJMACROS
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "ole2.h"
29 #include "msxml6.h"
31 #include "msxml_dispex.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
37 typedef struct _domimpl
39 DispatchEx dispex;
40 IXMLDOMImplementation IXMLDOMImplementation_iface;
41 LONG ref;
42 } domimpl;
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,
51 REFIID riid,
52 void** ppvObject )
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 ) )
61 *ppvObject = iface;
63 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
65 return *ppvObject ? S_OK : E_NOINTERFACE;
67 else
69 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
70 *ppvObject = NULL;
71 return E_NOINTERFACE;
74 IXMLDOMImplementation_AddRef( iface );
76 return S_OK;
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);
84 return 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);
94 if (!ref)
95 heap_free(domimpl);
97 return ref;
100 static HRESULT WINAPI domimpl_GetTypeInfoCount(
101 IXMLDOMImplementation *iface,
102 UINT* pctinfo )
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)
151 return E_INVALIDARG;
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;
164 return S_OK;
167 static const struct IXMLDOMImplementationVtbl domimpl_vtbl =
169 domimpl_QueryInterface,
170 domimpl_AddRef,
171 domimpl_Release,
172 domimpl_GetTypeInfoCount,
173 domimpl_GetTypeInfo,
174 domimpl_GetIDsOfNames,
175 domimpl_Invoke,
176 domimpl_hasFeature
179 static const tid_t domimpl_iface_tids[] =
181 IXMLDOMImplementation_tid,
185 static dispex_static_data_t domimpl_dispex =
187 NULL,
188 IXMLDOMImplementation_tid,
189 NULL,
190 domimpl_iface_tids
193 HRESULT create_dom_implementation(IXMLDOMImplementation **ret)
195 domimpl *object;
197 if (!(object = heap_alloc(sizeof(*object))))
198 return E_OUTOFMEMORY;
200 object->IXMLDOMImplementation_iface.lpVtbl = &domimpl_vtbl;
201 object->ref = 1;
202 init_dispex(&object->dispex, (IUnknown *)&object->IXMLDOMImplementation_iface, &domimpl_dispex);
204 *ret = &object->IXMLDOMImplementation_iface;
206 return S_OK;