wined3d: Respect the BO buffer offset in wined3d_context_gl_copy_bo_address().
[wine.git] / dlls / msxml3 / domimpl.c
blob3e5b912efd25f7386faefa25cfab2949713fe26e
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(
80 IXMLDOMImplementation *iface )
82 domimpl *This = impl_from_IXMLDOMImplementation( iface );
83 ULONG ref = InterlockedIncrement( &This->ref );
84 TRACE("(%p)->(%d)\n", This, ref);
85 return ref;
88 static ULONG WINAPI domimpl_Release(
89 IXMLDOMImplementation *iface )
91 domimpl *This = impl_from_IXMLDOMImplementation( iface );
92 ULONG ref = InterlockedDecrement( &This->ref );
94 TRACE("(%p)->(%d)\n", This, ref);
95 if ( ref == 0 )
96 heap_free( This );
98 return ref;
101 static HRESULT WINAPI domimpl_GetTypeInfoCount(
102 IXMLDOMImplementation *iface,
103 UINT* pctinfo )
105 domimpl *This = impl_from_IXMLDOMImplementation( iface );
106 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
109 static HRESULT WINAPI domimpl_GetTypeInfo(
110 IXMLDOMImplementation *iface,
111 UINT iTInfo, LCID lcid,
112 ITypeInfo** ppTInfo )
114 domimpl *This = impl_from_IXMLDOMImplementation( iface );
115 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
116 iTInfo, lcid, ppTInfo);
119 static HRESULT WINAPI domimpl_GetIDsOfNames(
120 IXMLDOMImplementation *iface,
121 REFIID riid, LPOLESTR* rgszNames,
122 UINT cNames, LCID lcid, DISPID* rgDispId )
124 domimpl *This = impl_from_IXMLDOMImplementation( iface );
125 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
126 riid, rgszNames, cNames, lcid, rgDispId);
129 static HRESULT WINAPI domimpl_Invoke(
130 IXMLDOMImplementation *iface,
131 DISPID dispIdMember, REFIID riid, LCID lcid,
132 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
133 EXCEPINFO* pExcepInfo, UINT* puArgErr )
135 domimpl *This = impl_from_IXMLDOMImplementation( iface );
136 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
137 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI domimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
142 static const WCHAR bVersion[] = {'1','.','0',0};
143 static const WCHAR bXML[] = {'X','M','L',0};
144 static const WCHAR bDOM[] = {'D','O','M',0};
145 static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
146 BOOL bValidFeature = FALSE;
147 BOOL bValidVersion = FALSE;
149 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
151 if(!feature || !hasFeature)
152 return E_INVALIDARG;
154 *hasFeature = VARIANT_FALSE;
156 if(!version || lstrcmpiW(version, bVersion) == 0)
157 bValidVersion = TRUE;
159 if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
160 bValidFeature = TRUE;
162 if(bValidVersion && bValidFeature)
163 *hasFeature = VARIANT_TRUE;
165 return S_OK;
168 static const struct IXMLDOMImplementationVtbl domimpl_vtbl =
170 domimpl_QueryInterface,
171 domimpl_AddRef,
172 domimpl_Release,
173 domimpl_GetTypeInfoCount,
174 domimpl_GetTypeInfo,
175 domimpl_GetIDsOfNames,
176 domimpl_Invoke,
177 domimpl_hasFeature
180 static const tid_t domimpl_iface_tids[] =
182 IXMLDOMImplementation_tid,
186 static dispex_static_data_t domimpl_dispex =
188 NULL,
189 IXMLDOMImplementation_tid,
190 NULL,
191 domimpl_iface_tids
194 HRESULT create_dom_implementation(IXMLDOMImplementation **ret)
196 domimpl *object;
198 if (!(object = heap_alloc(sizeof(*object))))
199 return E_OUTOFMEMORY;
201 object->IXMLDOMImplementation_iface.lpVtbl = &domimpl_vtbl;
202 object->ref = 1;
203 init_dispex(&object->dispex, (IUnknown *)&object->IXMLDOMImplementation_iface, &domimpl_dispex);
205 *ret = &object->IXMLDOMImplementation_iface;
207 return S_OK;