Release 1.3.7.
[wine/gsoc-2012-control.git] / dlls / msxml3 / parseerror.c
blobd5e4cdebde62022adb640cdffc05adeb4b81a9d4
1 /*
2 * ParseError implementation
4 * Copyright 2005 Huw Davies
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
22 #define COBJMACROS
24 #include "config.h"
26 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winerror.h"
30 #include "winuser.h"
31 #include "ole2.h"
32 #include "msxml6.h"
34 #include "msxml_private.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
40 typedef struct
42 const struct IXMLDOMParseErrorVtbl *lpVtbl;
43 LONG ref;
44 LONG code, line, linepos, filepos;
45 BSTR url, reason, srcText;
46 } parse_error_t;
48 static inline parse_error_t *impl_from_IXMLDOMParseError( IXMLDOMParseError *iface )
50 return (parse_error_t *)((char*)iface - FIELD_OFFSET(parse_error_t, lpVtbl));
53 static HRESULT WINAPI parseError_QueryInterface(
54 IXMLDOMParseError *iface,
55 REFIID riid,
56 void** ppvObject )
58 TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject);
60 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
61 IsEqualGUID( riid, &IID_IDispatch ) ||
62 IsEqualGUID( riid, &IID_IXMLDOMParseError ) )
64 *ppvObject = iface;
66 else
68 FIXME("interface %s not implemented\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
72 IXMLDOMParseError_AddRef( iface );
74 return S_OK;
77 static ULONG WINAPI parseError_AddRef(
78 IXMLDOMParseError *iface )
80 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
81 ULONG ref = InterlockedIncrement( &This->ref );
82 TRACE("(%p) ref now %d\n", This, ref);
83 return ref;
86 static ULONG WINAPI parseError_Release(
87 IXMLDOMParseError *iface )
89 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
90 ULONG ref;
92 ref = InterlockedDecrement( &This->ref );
93 TRACE("(%p) ref now %d\n", This, ref);
94 if ( ref == 0 )
96 SysFreeString(This->url);
97 SysFreeString(This->reason);
98 SysFreeString(This->srcText);
99 heap_free( This );
102 return ref;
105 static HRESULT WINAPI parseError_GetTypeInfoCount(
106 IXMLDOMParseError *iface,
107 UINT* pctinfo )
109 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
111 TRACE("(%p)->(%p)\n", This, pctinfo);
113 *pctinfo = 1;
115 return S_OK;
118 static HRESULT WINAPI parseError_GetTypeInfo(
119 IXMLDOMParseError *iface,
120 UINT iTInfo,
121 LCID lcid,
122 ITypeInfo** ppTInfo )
124 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
125 HRESULT hr;
127 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
129 hr = get_typeinfo(IXMLDOMParseError_tid, ppTInfo);
131 return hr;
134 static HRESULT WINAPI parseError_GetIDsOfNames(
135 IXMLDOMParseError *iface,
136 REFIID riid,
137 LPOLESTR* rgszNames,
138 UINT cNames,
139 LCID lcid,
140 DISPID* rgDispId )
142 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
143 ITypeInfo *typeinfo;
144 HRESULT hr;
146 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
147 lcid, rgDispId);
149 if(!rgszNames || cNames == 0 || !rgDispId)
150 return E_INVALIDARG;
152 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
153 if(SUCCEEDED(hr))
155 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
156 ITypeInfo_Release(typeinfo);
159 return hr;
162 static HRESULT WINAPI parseError_Invoke(
163 IXMLDOMParseError *iface,
164 DISPID dispIdMember,
165 REFIID riid,
166 LCID lcid,
167 WORD wFlags,
168 DISPPARAMS* pDispParams,
169 VARIANT* pVarResult,
170 EXCEPINFO* pExcepInfo,
171 UINT* puArgErr )
173 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
174 ITypeInfo *typeinfo;
175 HRESULT hr;
177 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
178 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
180 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
181 if(SUCCEEDED(hr))
183 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
184 pVarResult, pExcepInfo, puArgErr);
185 ITypeInfo_Release(typeinfo);
188 return hr;
191 static HRESULT WINAPI parseError_get_errorCode(
192 IXMLDOMParseError *iface,
193 LONG *code )
195 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
196 TRACE("(%p)->(%p)\n", This, code);
198 *code = This->code;
200 if(This->code == 0)
201 return S_FALSE;
203 return S_OK;
206 static HRESULT WINAPI parseError_get_url(
207 IXMLDOMParseError *iface,
208 BSTR *url )
210 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
211 FIXME("(%p)->(%p)\n", This, url);
212 return E_NOTIMPL;
215 static HRESULT WINAPI parseError_get_reason(
216 IXMLDOMParseError *iface,
217 BSTR *reason )
219 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
220 TRACE("(%p)->(%p)\n", This, reason);
222 if(!This->reason)
224 *reason = NULL;
225 return S_FALSE;
227 *reason = SysAllocString(This->reason);
228 return S_OK;
231 static HRESULT WINAPI parseError_get_srcText(
232 IXMLDOMParseError *iface,
233 BSTR *srcText )
235 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
236 FIXME("(%p)->(%p)\n", This, srcText);
237 return E_NOTIMPL;
240 static HRESULT WINAPI parseError_get_line(
241 IXMLDOMParseError *iface,
242 LONG *line )
244 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
245 FIXME("(%p)->(%p)\n", This, line);
246 return E_NOTIMPL;
249 static HRESULT WINAPI parseError_get_linepos(
250 IXMLDOMParseError *iface,
251 LONG *linepos )
253 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
254 FIXME("(%p)->(%p)\n", This, linepos);
255 return E_NOTIMPL;
258 static HRESULT WINAPI parseError_get_filepos(
259 IXMLDOMParseError *iface,
260 LONG *filepos )
262 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
263 FIXME("(%p)->(%p)\n", This, filepos);
264 return E_NOTIMPL;
267 static const struct IXMLDOMParseErrorVtbl parseError_vtbl =
269 parseError_QueryInterface,
270 parseError_AddRef,
271 parseError_Release,
272 parseError_GetTypeInfoCount,
273 parseError_GetTypeInfo,
274 parseError_GetIDsOfNames,
275 parseError_Invoke,
276 parseError_get_errorCode,
277 parseError_get_url,
278 parseError_get_reason,
279 parseError_get_srcText,
280 parseError_get_line,
281 parseError_get_linepos,
282 parseError_get_filepos
285 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
286 LONG line, LONG linepos, LONG filepos )
288 parse_error_t *This;
290 This = heap_alloc( sizeof(*This) );
291 if ( !This )
292 return NULL;
294 This->lpVtbl = &parseError_vtbl;
295 This->ref = 1;
297 This->code = code;
298 This->url = url;
299 This->reason = reason;
300 This->srcText = srcText;
301 This->line = line;
302 This->linepos = linepos;
303 This->filepos = filepos;
305 return (IXMLDOMParseError*) &This->lpVtbl;