mshtml: Reimplement IHTMLStyle::get_backgroundPositionY using background-position...
[wine] / dlls / msxml3 / parseerror.c
1 /*
2  *    ParseError implementation
3  *
4  * Copyright 2005 Huw Davies
5  *
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.
10  *
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.
15  *
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
19  */
20
21
22 #define COBJMACROS
23
24 #include "config.h"
25
26 #include <stdarg.h>
27 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 #endif
31
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
35 #include "winuser.h"
36 #include "ole2.h"
37 #include "msxml6.h"
38
39 #include "msxml_private.h"
40
41 #include "wine/debug.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44
45 typedef struct
46 {
47     IXMLDOMParseError IXMLDOMParseError_iface;
48     LONG ref;
49     LONG code, line, linepos, filepos;
50     BSTR url, reason, srcText;
51 } parse_error_t;
52
53 static inline parse_error_t *impl_from_IXMLDOMParseError( IXMLDOMParseError *iface )
54 {
55     return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError_iface);
56 }
57
58 static HRESULT WINAPI parseError_QueryInterface(
59     IXMLDOMParseError *iface,
60     REFIID riid,
61     void** ppvObject )
62 {
63     TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject);
64
65     if ( IsEqualGUID( riid, &IID_IUnknown ) ||
66          IsEqualGUID( riid, &IID_IDispatch ) ||
67          IsEqualGUID( riid, &IID_IXMLDOMParseError ) )
68     {
69         *ppvObject = iface;
70     }
71     else
72     {
73         FIXME("interface %s not implemented\n", debugstr_guid(riid));
74         return E_NOINTERFACE;
75     }
76
77     IXMLDOMParseError_AddRef( iface );
78
79     return S_OK;
80 }
81
82 static ULONG WINAPI parseError_AddRef(
83     IXMLDOMParseError *iface )
84 {
85     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
86     ULONG ref = InterlockedIncrement( &This->ref );
87     TRACE("(%p) ref now %d\n", This, ref);
88     return ref;
89 }
90
91 static ULONG WINAPI parseError_Release(
92     IXMLDOMParseError *iface )
93 {
94     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
95     ULONG ref;
96
97     ref = InterlockedDecrement( &This->ref );
98     TRACE("(%p) ref now %d\n", This, ref);
99     if ( ref == 0 )
100     {
101         SysFreeString(This->url);
102         SysFreeString(This->reason);
103         SysFreeString(This->srcText);
104         heap_free( This );
105     }
106
107     return ref;
108 }
109
110 static HRESULT WINAPI parseError_GetTypeInfoCount(
111     IXMLDOMParseError *iface,
112     UINT* pctinfo )
113 {
114     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
115
116     TRACE("(%p)->(%p)\n", This, pctinfo);
117
118     *pctinfo = 1;
119
120     return S_OK;
121 }
122
123 static HRESULT WINAPI parseError_GetTypeInfo(
124     IXMLDOMParseError *iface,
125     UINT iTInfo,
126     LCID lcid,
127     ITypeInfo** ppTInfo )
128 {
129     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
130     HRESULT hr;
131
132     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
133
134     hr = get_typeinfo(IXMLDOMParseError_tid, ppTInfo);
135
136     return hr;
137 }
138
139 static HRESULT WINAPI parseError_GetIDsOfNames(
140     IXMLDOMParseError *iface,
141     REFIID riid,
142     LPOLESTR* rgszNames,
143     UINT cNames,
144     LCID lcid,
145     DISPID* rgDispId )
146 {
147     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
148     ITypeInfo *typeinfo;
149     HRESULT hr;
150
151     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
152           lcid, rgDispId);
153
154     if(!rgszNames || cNames == 0 || !rgDispId)
155         return E_INVALIDARG;
156
157     hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
158     if(SUCCEEDED(hr))
159     {
160         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
161         ITypeInfo_Release(typeinfo);
162     }
163
164     return hr;
165 }
166
167 static HRESULT WINAPI parseError_Invoke(
168     IXMLDOMParseError *iface,
169     DISPID dispIdMember,
170     REFIID riid,
171     LCID lcid,
172     WORD wFlags,
173     DISPPARAMS* pDispParams,
174     VARIANT* pVarResult,
175     EXCEPINFO* pExcepInfo,
176     UINT* puArgErr )
177 {
178     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
179     ITypeInfo *typeinfo;
180     HRESULT hr;
181
182     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
183           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
184
185     hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
186     if(SUCCEEDED(hr))
187     {
188         hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMParseError_iface, dispIdMember, wFlags,
189                 pDispParams, pVarResult, pExcepInfo, puArgErr);
190         ITypeInfo_Release(typeinfo);
191     }
192
193     return hr;
194 }
195
196 static HRESULT WINAPI parseError_get_errorCode(
197     IXMLDOMParseError *iface,
198     LONG *code )
199 {
200     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
201     TRACE("(%p)->(%p)\n", This, code);
202
203     *code = This->code;
204
205     if(This->code == 0)
206         return S_FALSE;
207
208     return S_OK;
209 }
210
211 static HRESULT WINAPI parseError_get_url(
212     IXMLDOMParseError *iface,
213     BSTR *url )
214 {
215     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
216     FIXME("(%p)->(%p)\n", This, url);
217     return E_NOTIMPL;
218 }
219
220 static HRESULT WINAPI parseError_get_reason(
221     IXMLDOMParseError *iface,
222     BSTR *reason )
223 {
224     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
225     TRACE("(%p)->(%p)\n", This, reason);
226     
227     if(!This->reason)
228     {
229         *reason = NULL;
230         return S_FALSE;
231     }
232     *reason = SysAllocString(This->reason);
233     return S_OK;
234 }
235
236 static HRESULT WINAPI parseError_get_srcText(
237     IXMLDOMParseError *iface,
238     BSTR *srcText )
239 {
240     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
241     FIXME("(%p)->(%p)\n", This, srcText);
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI parseError_get_line(
246     IXMLDOMParseError *iface,
247     LONG *line )
248 {
249     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
250     FIXME("(%p)->(%p)\n", This, line);
251     return E_NOTIMPL;
252 }
253
254 static HRESULT WINAPI parseError_get_linepos(
255     IXMLDOMParseError *iface,
256     LONG *linepos )
257 {
258     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
259     FIXME("(%p)->(%p)\n", This, linepos);
260     return E_NOTIMPL;
261 }
262
263 static HRESULT WINAPI parseError_get_filepos(
264     IXMLDOMParseError *iface,
265     LONG *filepos )
266 {
267     parse_error_t *This = impl_from_IXMLDOMParseError( iface );
268     FIXME("(%p)->(%p)\n", This, filepos);
269     return E_NOTIMPL;
270 }
271
272 static const struct IXMLDOMParseErrorVtbl parseError_vtbl =
273 {
274     parseError_QueryInterface,
275     parseError_AddRef,
276     parseError_Release,
277     parseError_GetTypeInfoCount,
278     parseError_GetTypeInfo,
279     parseError_GetIDsOfNames,
280     parseError_Invoke,
281     parseError_get_errorCode,
282     parseError_get_url,
283     parseError_get_reason,
284     parseError_get_srcText,
285     parseError_get_line,
286     parseError_get_linepos,
287     parseError_get_filepos
288 };
289
290 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
291                                       LONG line, LONG linepos, LONG filepos )
292 {
293     parse_error_t *This;
294
295     This = heap_alloc( sizeof(*This) );
296     if ( !This )
297         return NULL;
298
299     This->IXMLDOMParseError_iface.lpVtbl = &parseError_vtbl;
300     This->ref = 1;
301
302     This->code = code;
303     This->url = url;
304     This->reason = reason;
305     This->srcText = srcText;
306     This->line = line;
307     This->linepos = linepos;
308     This->filepos = filepos;
309
310     return &This->IXMLDOMParseError_iface;
311 }