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