msxml3: Implement get_line() and get_linepos().
[wine/multimedia.git] / dlls / msxml3 / parseerror.c
blobc4610955e8797f7dd0a311955a9382989f91b639
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 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 #endif
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
35 #include "winuser.h"
36 #include "ole2.h"
37 #include "msxml6.h"
39 #include "msxml_private.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct
47 DispatchEx dispex;
48 IXMLDOMParseError IXMLDOMParseError_iface;
49 LONG ref;
50 LONG code, line, linepos, filepos;
51 BSTR url, reason, srcText;
52 } parse_error_t;
54 static inline parse_error_t *impl_from_IXMLDOMParseError( IXMLDOMParseError *iface )
56 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError_iface);
59 static HRESULT WINAPI parseError_QueryInterface(
60 IXMLDOMParseError *iface,
61 REFIID riid,
62 void** ppvObject )
64 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
68 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
69 IsEqualGUID( riid, &IID_IDispatch ) ||
70 IsEqualGUID( riid, &IID_IXMLDOMParseError ) )
72 *ppvObject = iface;
74 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
76 return *ppvObject ? S_OK : E_NOINTERFACE;
78 else
80 FIXME("interface %s not implemented\n", debugstr_guid(riid));
81 *ppvObject = NULL;
82 return E_NOINTERFACE;
85 IXMLDOMParseError_AddRef( iface );
87 return S_OK;
90 static ULONG WINAPI parseError_AddRef(
91 IXMLDOMParseError *iface )
93 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
94 ULONG ref = InterlockedIncrement( &This->ref );
95 TRACE("(%p)->(%d)\n", This, ref);
96 return ref;
99 static ULONG WINAPI parseError_Release(
100 IXMLDOMParseError *iface )
102 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
103 ULONG ref = InterlockedDecrement( &This->ref );
105 TRACE("(%p)->(%d)\n", This, ref);
106 if ( ref == 0 )
108 SysFreeString(This->url);
109 SysFreeString(This->reason);
110 SysFreeString(This->srcText);
111 release_dispex(&This->dispex);
112 heap_free( This );
115 return ref;
118 static HRESULT WINAPI parseError_GetTypeInfoCount(
119 IXMLDOMParseError *iface,
120 UINT* pctinfo )
122 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
124 TRACE("(%p)->(%p)\n", This, pctinfo);
126 *pctinfo = 1;
128 return S_OK;
131 static HRESULT WINAPI parseError_GetTypeInfo(
132 IXMLDOMParseError *iface,
133 UINT iTInfo,
134 LCID lcid,
135 ITypeInfo** ppTInfo )
137 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
139 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
141 return get_typeinfo(IXMLDOMParseError_tid, ppTInfo);
144 static HRESULT WINAPI parseError_GetIDsOfNames(
145 IXMLDOMParseError *iface,
146 REFIID riid,
147 LPOLESTR* rgszNames,
148 UINT cNames,
149 LCID lcid,
150 DISPID* rgDispId )
152 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
153 ITypeInfo *typeinfo;
154 HRESULT hr;
156 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
157 lcid, rgDispId);
159 if(!rgszNames || cNames == 0 || !rgDispId)
160 return E_INVALIDARG;
162 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
163 if(SUCCEEDED(hr))
165 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
166 ITypeInfo_Release(typeinfo);
169 return hr;
172 static HRESULT WINAPI parseError_Invoke(
173 IXMLDOMParseError *iface,
174 DISPID dispIdMember,
175 REFIID riid,
176 LCID lcid,
177 WORD wFlags,
178 DISPPARAMS* pDispParams,
179 VARIANT* pVarResult,
180 EXCEPINFO* pExcepInfo,
181 UINT* puArgErr )
183 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
184 ITypeInfo *typeinfo;
185 HRESULT hr;
187 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
188 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
190 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
191 if(SUCCEEDED(hr))
193 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMParseError_iface, dispIdMember, wFlags,
194 pDispParams, pVarResult, pExcepInfo, puArgErr);
195 ITypeInfo_Release(typeinfo);
198 return hr;
201 static HRESULT WINAPI parseError_get_errorCode(
202 IXMLDOMParseError *iface,
203 LONG *code )
205 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
206 TRACE("(%p)->(%p)\n", This, code);
208 *code = This->code;
210 if(This->code == 0)
211 return S_FALSE;
213 return S_OK;
216 static HRESULT WINAPI parseError_get_url(
217 IXMLDOMParseError *iface,
218 BSTR *url )
220 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
221 FIXME("(%p)->(%p)\n", This, url);
222 return E_NOTIMPL;
225 static HRESULT WINAPI parseError_get_reason(
226 IXMLDOMParseError *iface,
227 BSTR *reason )
229 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
230 TRACE("(%p)->(%p)\n", This, reason);
232 if(!This->reason)
234 *reason = NULL;
235 return S_FALSE;
237 *reason = SysAllocString(This->reason);
238 return S_OK;
241 static HRESULT WINAPI parseError_get_srcText(
242 IXMLDOMParseError *iface,
243 BSTR *srcText )
245 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
246 FIXME("(%p)->(%p)\n", This, srcText);
247 return E_NOTIMPL;
250 static HRESULT WINAPI parseError_get_line(
251 IXMLDOMParseError *iface,
252 LONG *line )
254 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
256 TRACE("(%p)->(%p): stub\n", This, line);
258 if (!line) return E_INVALIDARG;
260 *line = This->line;
261 return S_OK;
264 static HRESULT WINAPI parseError_get_linepos(
265 IXMLDOMParseError *iface,
266 LONG *linepos )
268 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
270 TRACE("(%p)->(%p)\n", This, linepos);
272 if (!linepos) return E_INVALIDARG;
274 *linepos = This->linepos;
275 return S_OK;
278 static HRESULT WINAPI parseError_get_filepos(
279 IXMLDOMParseError *iface,
280 LONG *filepos )
282 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
283 FIXME("(%p)->(%p)\n", This, filepos);
284 return E_NOTIMPL;
287 static const struct IXMLDOMParseErrorVtbl parseError_vtbl =
289 parseError_QueryInterface,
290 parseError_AddRef,
291 parseError_Release,
292 parseError_GetTypeInfoCount,
293 parseError_GetTypeInfo,
294 parseError_GetIDsOfNames,
295 parseError_Invoke,
296 parseError_get_errorCode,
297 parseError_get_url,
298 parseError_get_reason,
299 parseError_get_srcText,
300 parseError_get_line,
301 parseError_get_linepos,
302 parseError_get_filepos
305 static const tid_t parseError_iface_tids[] = {
306 IXMLDOMParseError_tid,
310 static dispex_static_data_t parseError_dispex = {
311 NULL,
312 IXMLDOMParseError_tid,
313 NULL,
314 parseError_iface_tids
317 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
318 LONG line, LONG linepos, LONG filepos )
320 parse_error_t *This;
322 This = heap_alloc( sizeof(*This) );
323 if ( !This )
324 return NULL;
326 This->IXMLDOMParseError_iface.lpVtbl = &parseError_vtbl;
327 This->ref = 1;
329 This->code = code;
330 This->url = url;
331 This->reason = reason;
332 This->srcText = srcText;
333 This->line = line;
334 This->linepos = linepos;
335 This->filepos = filepos;
337 init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError_iface, &parseError_dispex);
339 return &This->IXMLDOMParseError_iface;