comctl32/imagelist: Use proper color format for merged image lists.
[wine] / dlls / msxml3 / xmlparser.c
1 /*
2  * XML Parser implementation
3  *
4  * Copyright 2011 Alistair Leslie-Hughes
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 #define COBJMACROS
21
22 #include "config.h"
23
24 #include <stdarg.h>
25 #ifdef HAVE_LIBXML2
26 # include <libxml/parser.h>
27 # include <libxml/xmlerror.h>
28 # include <libxml/HTMLtree.h>
29 #endif
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
36
37 #include "msxml_private.h"
38
39 #include "initguid.h"
40 #include "xmlparser.h"
41
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45
46 typedef struct _xmlparser
47 {
48     IXMLParser IXMLParser_iface;
49     IXMLNodeFactory *nodefactory;
50     LONG ref;
51
52     int flags;
53 } xmlparser;
54
55 static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
56 {
57     return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
58 }
59
60 /*** IUnknown methods ***/
61 static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
62 {
63     xmlparser *This = impl_from_IXMLParser( iface );
64     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
65
66     if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
67          IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
68          IsEqualGUID( riid, &IID_IUnknown ) )
69     {
70         *ppvObject = iface;
71     }
72     else
73     {
74         TRACE("Unsupported interface %s\n", debugstr_guid(riid));
75         *ppvObject = NULL;
76         return E_NOINTERFACE;
77     }
78
79     IXMLParser_AddRef(iface);
80     return S_OK;
81 }
82
83 static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
84 {
85     xmlparser *This = impl_from_IXMLParser( iface );
86     ULONG ref = InterlockedIncrement( &This->ref );
87     TRACE("(%p)->(%d)\n", This, ref);
88     return ref;
89 }
90
91 static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
92 {
93     xmlparser *This = impl_from_IXMLParser( iface );
94     ULONG ref = InterlockedDecrement( &This->ref );
95
96     TRACE("(%p)->(%d)\n", This, ref);
97     if ( ref == 0 )
98     {
99         if(This->nodefactory)
100             IXMLNodeFactory_Release(This->nodefactory);
101
102         heap_free( This );
103     }
104
105     return ref;
106 }
107
108 /*** IXMLNodeSource methods ***/
109 static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
110 {
111     xmlparser *This = impl_from_IXMLParser( iface );
112
113     TRACE("(%p %p)\n", This, pNodeFactory);
114
115     if(This->nodefactory)
116         IXMLNodeFactory_Release(This->nodefactory);
117
118     This->nodefactory = pNodeFactory;
119     if(This->nodefactory)
120         IXMLNodeFactory_AddRef(This->nodefactory);
121
122     return S_OK;
123 }
124
125 static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
126 {
127     xmlparser *This = impl_from_IXMLParser( iface );
128
129     TRACE("(%p, %p)\n", This, ppNodeFactory);
130
131     if(!ppNodeFactory)
132         return E_INVALIDARG;
133
134     *ppNodeFactory = This->nodefactory;
135
136     if(*ppNodeFactory)
137         IXMLNodeFactory_AddRef(*ppNodeFactory);
138
139     return S_OK;
140 }
141
142 static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
143 {
144     xmlparser *This = impl_from_IXMLParser( iface );
145
146     FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
147
148     return E_NOTIMPL;
149 }
150
151 static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
152 {
153     xmlparser *This = impl_from_IXMLParser( iface );
154
155     FIXME("(%p)\n", This);
156
157     return 0;
158 }
159
160 static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
161 {
162     xmlparser *This = impl_from_IXMLParser( iface );
163
164     FIXME("(%p)\n", This);
165
166     return 0;
167 }
168
169 static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
170 {
171     xmlparser *This = impl_from_IXMLParser( iface );
172
173     FIXME("(%p)\n", This);
174
175     return 0;
176 }
177
178 static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
179                 ULONG *len, ULONG *startPos)
180 {
181     xmlparser *This = impl_from_IXMLParser( iface );
182
183     FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
184
185     return 0;
186 }
187
188 static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
189 {
190     xmlparser *This = impl_from_IXMLParser( iface );
191
192     FIXME("(%p)\n", This);
193
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
198 {
199     xmlparser *This = impl_from_IXMLParser( iface );
200
201     FIXME("(%p %p)\n", This, pErrorInfo);
202
203     return E_NOTIMPL;
204 }
205
206 static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
207 {
208     xmlparser *This = impl_from_IXMLParser( iface );
209
210     TRACE("(%p)\n", This);
211
212     return This->flags;
213 }
214
215 static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
216 {
217     xmlparser *This = impl_from_IXMLParser( iface );
218
219     FIXME("(%p %p)\n", This, ppBuf);
220
221     return E_NOTIMPL;
222 }
223
224 /*** IXMLParser methods ***/
225 static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
226                 const WCHAR *relativeUrl, BOOL async)
227 {
228     xmlparser *This = impl_from_IXMLParser( iface );
229
230     FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
231
232     return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
236                 IMoniker *pMon, LPBC pBC, DWORD dwMode)
237 {
238     xmlparser *This = impl_from_IXMLParser( iface );
239
240     FIXME("(%p %d %p %p %d)\n", This, bFullyAvailable, pMon, pBC, dwMode);
241
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
246 {
247     xmlparser *This = impl_from_IXMLParser( iface );
248
249     FIXME("(%p %p)\n", This, pStm);
250
251     return E_NOTIMPL;
252 }
253
254 static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
255                 ULONG nChars, BOOL fLastBuffer)
256 {
257     xmlparser *This = impl_from_IXMLParser( iface );
258
259     FIXME("(%p %s %d %d)\n", This, debugstr_a(pData), nChars, fLastBuffer);
260
261     return E_NOTIMPL;
262 }
263
264 static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
265                 const WCHAR *relativeUrl)
266 {
267     xmlparser *This = impl_from_IXMLParser( iface );
268
269     FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
270
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
275                 const WCHAR *relativeUrl, BOOL fpe)
276 {
277     xmlparser *This = impl_from_IXMLParser( iface );
278
279     FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
280
281     return E_NOTIMPL;
282 }
283
284 static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
285                 ULONG len, BOOL fpe)
286 {
287     xmlparser *This = impl_from_IXMLParser( iface );
288
289     FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
290
291     return E_NOTIMPL;
292 }
293
294 static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
295                 ULONG len)
296 {
297     xmlparser *This = impl_from_IXMLParser( iface );
298
299     FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
300
301     return E_NOTIMPL;
302 }
303
304 static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
305 {
306     xmlparser *This = impl_from_IXMLParser( iface );
307
308     FIXME("(%p %p)\n", This, pRoot);
309
310     return E_NOTIMPL;
311 }
312
313 static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
314 {
315     xmlparser *This = impl_from_IXMLParser( iface );
316
317     FIXME("(%p %p)\n", This, ppRoot);
318
319     return E_NOTIMPL;
320 }
321
322 static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
323 {
324     xmlparser *This = impl_from_IXMLParser( iface );
325
326     FIXME("(%p %d)\n", This, chars);
327
328     return E_NOTIMPL;
329 }
330
331 static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
332 {
333     xmlparser *This = impl_from_IXMLParser( iface );
334
335     FIXME("(%p)\n", This);
336
337     return E_NOTIMPL;
338 }
339
340 static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
341 {
342     xmlparser *This = impl_from_IXMLParser( iface );
343
344     FIXME("(%p)\n", This);
345
346     return E_NOTIMPL;
347 }
348
349 static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
350 {
351     xmlparser *This = impl_from_IXMLParser( iface );
352
353     FIXME("(%p)\n", This);
354
355     return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
359 {
360     xmlparser *This = impl_from_IXMLParser( iface );
361
362     TRACE("(%p %d)\n", This, flags);
363
364     This->flags = flags;
365
366     return S_OK;
367 }
368
369 static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
370 {
371     xmlparser *This = impl_from_IXMLParser( iface );
372
373     FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
374
375     return E_NOTIMPL;
376 }
377
378 static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
379 {
380     xmlparser *This = impl_from_IXMLParser( iface );
381
382     FIXME("(%p %p)\n", This, ppBuf);
383
384     return E_NOTIMPL;
385 }
386
387
388 static const struct IXMLParserVtbl xmlparser_vtbl =
389 {
390     xmlparser_QueryInterface,
391     xmlparser_AddRef,
392     xmlparser_Release,
393     xmlparser_SetFactory,
394     xmlparser_GetFactory,
395     xmlparser_Abort,
396     xmlparser_GetLineNumber,
397     xmlparser_GetLinePosition,
398     xmlparser_GetAbsolutePosition,
399     xmlparser_GetLineBuffer,
400     xmlparser_GetLastError,
401     xmlparser_GetErrorInfo,
402     xmlparser_GetFlags,
403     xmlparser_GetURL,
404     xmlparser_SetURL,
405     xmlparser_Load,
406     xmlparser_SetInput,
407     xmlparser_PushData,
408     xmlparser_LoadDTD,
409     xmlparser_LoadEntity,
410     xmlparser_ParseEntity,
411     xmlparser_ExpandEntity,
412     xmlparser_SetRoot,
413     xmlparser_GetRoot,
414     xmlparser_Run,
415     xmlparser_GetParserState,
416     xmlparser_Suspend,
417     xmlparser_Reset,
418     xmlparser_SetFlags,
419     xmlparser_SetSecureBaseURL,
420     xmlparser_GetSecureBaseURL
421 };
422
423 HRESULT XMLParser_create(IUnknown* pUnkOuter, void**ppObj)
424 {
425     xmlparser *This;
426
427     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
428
429     if (pUnkOuter)
430         FIXME("support aggregation, outer\n");
431
432     This = heap_alloc( sizeof(xmlparser) );
433     if(!This)
434         return E_OUTOFMEMORY;
435
436     This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
437     This->nodefactory = NULL;
438     This->flags = 0;
439     This->ref = 1;
440
441     *ppObj = &This->IXMLParser_iface;
442
443     TRACE("returning iface %p\n", *ppObj);
444
445     return S_OK;
446 }