mshtml: Don't use fire_event to dispatch contextmenu event.
[wine.git] / dlls / msxml3 / xmlparser.c
blob6fcdb82c56b040abd9cf7e6917931626ab8b845a
1 /*
2 * XML Parser implementation
4 * Copyright 2011 Alistair Leslie-Hughes
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
20 #define COBJMACROS
22 #include "config.h"
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
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "initguid.h"
40 #include "xmlparser.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
46 typedef struct _xmlparser
48 IXMLParser IXMLParser_iface;
49 IXMLNodeFactory *nodefactory;
50 IUnknown *input;
51 LONG ref;
53 int flags;
54 XML_PARSER_STATE state;
55 } xmlparser;
57 static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
59 return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
62 /*** IUnknown methods ***/
63 static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
65 xmlparser *This = impl_from_IXMLParser( iface );
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
68 if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
69 IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
70 IsEqualGUID( riid, &IID_IUnknown ) )
72 *ppvObject = iface;
74 else
76 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
77 *ppvObject = NULL;
78 return E_NOINTERFACE;
81 IXMLParser_AddRef(iface);
82 return S_OK;
85 static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
87 xmlparser *This = impl_from_IXMLParser( iface );
88 ULONG ref = InterlockedIncrement( &This->ref );
89 TRACE("(%p)->(%d)\n", This, ref);
90 return ref;
93 static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
95 xmlparser *This = impl_from_IXMLParser( iface );
96 ULONG ref = InterlockedDecrement( &This->ref );
98 TRACE("(%p)->(%d)\n", This, ref);
99 if ( ref == 0 )
101 if(This->input)
102 IUnknown_Release(This->input);
104 if(This->nodefactory)
105 IXMLNodeFactory_Release(This->nodefactory);
107 heap_free( This );
110 return ref;
113 /*** IXMLNodeSource methods ***/
114 static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
116 xmlparser *This = impl_from_IXMLParser( iface );
118 TRACE("(%p %p)\n", This, pNodeFactory);
120 if(This->nodefactory)
121 IXMLNodeFactory_Release(This->nodefactory);
123 This->nodefactory = pNodeFactory;
124 if(This->nodefactory)
125 IXMLNodeFactory_AddRef(This->nodefactory);
127 return S_OK;
130 static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
132 xmlparser *This = impl_from_IXMLParser( iface );
134 TRACE("(%p, %p)\n", This, ppNodeFactory);
136 if(!ppNodeFactory)
137 return E_INVALIDARG;
139 *ppNodeFactory = This->nodefactory;
141 if(*ppNodeFactory)
142 IXMLNodeFactory_AddRef(*ppNodeFactory);
144 return S_OK;
147 static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
149 xmlparser *This = impl_from_IXMLParser( iface );
151 FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
153 return E_NOTIMPL;
156 static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
158 xmlparser *This = impl_from_IXMLParser( iface );
160 FIXME("(%p)\n", This);
162 return 0;
165 static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
167 xmlparser *This = impl_from_IXMLParser( iface );
169 FIXME("(%p)\n", This);
171 return 0;
174 static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
176 xmlparser *This = impl_from_IXMLParser( iface );
178 FIXME("(%p)\n", This);
180 return 0;
183 static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
184 ULONG *len, ULONG *startPos)
186 xmlparser *This = impl_from_IXMLParser( iface );
188 FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
190 return 0;
193 static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
195 xmlparser *This = impl_from_IXMLParser( iface );
197 FIXME("(%p)\n", This);
199 return E_NOTIMPL;
202 static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
204 xmlparser *This = impl_from_IXMLParser( iface );
206 FIXME("(%p %p)\n", This, pErrorInfo);
208 return E_NOTIMPL;
211 static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
213 xmlparser *This = impl_from_IXMLParser( iface );
215 TRACE("(%p)\n", This);
217 return This->flags;
220 static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
222 xmlparser *This = impl_from_IXMLParser( iface );
224 FIXME("(%p %p)\n", This, ppBuf);
226 return E_NOTIMPL;
229 /*** IXMLParser methods ***/
230 static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
231 const WCHAR *relativeUrl, BOOL async)
233 xmlparser *This = impl_from_IXMLParser( iface );
235 FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
237 return E_NOTIMPL;
240 static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
241 IMoniker *pMon, LPBC pBC, DWORD dwMode)
243 xmlparser *This = impl_from_IXMLParser( iface );
245 FIXME("(%p %d %p %p %d)\n", This, bFullyAvailable, pMon, pBC, dwMode);
247 return E_NOTIMPL;
250 static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
252 xmlparser *This = impl_from_IXMLParser( iface );
254 TRACE("(%p %p)\n", This, pStm);
256 if(!pStm)
257 return E_INVALIDARG;
259 if(This->input)
260 IUnknown_Release(This->input);
262 This->input = pStm;
263 IUnknown_AddRef(This->input);
265 return S_OK;
268 static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
269 ULONG nChars, BOOL fLastBuffer)
271 xmlparser *This = impl_from_IXMLParser( iface );
273 FIXME("(%p %s %d %d)\n", This, debugstr_a(pData), nChars, fLastBuffer);
275 return E_NOTIMPL;
278 static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
279 const WCHAR *relativeUrl)
281 xmlparser *This = impl_from_IXMLParser( iface );
283 FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
285 return E_NOTIMPL;
288 static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
289 const WCHAR *relativeUrl, BOOL fpe)
291 xmlparser *This = impl_from_IXMLParser( iface );
293 FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
295 return E_NOTIMPL;
298 static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
299 ULONG len, BOOL fpe)
301 xmlparser *This = impl_from_IXMLParser( iface );
303 FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
305 return E_NOTIMPL;
308 static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
309 ULONG len)
311 xmlparser *This = impl_from_IXMLParser( iface );
313 FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
315 return E_NOTIMPL;
318 static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
320 xmlparser *This = impl_from_IXMLParser( iface );
322 FIXME("(%p %p)\n", This, pRoot);
324 return E_NOTIMPL;
327 static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
329 xmlparser *This = impl_from_IXMLParser( iface );
331 FIXME("(%p %p)\n", This, ppRoot);
333 return E_NOTIMPL;
336 static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
338 xmlparser *This = impl_from_IXMLParser( iface );
340 FIXME("(%p %d)\n", This, chars);
342 return E_NOTIMPL;
345 static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
347 xmlparser *This = impl_from_IXMLParser( iface );
349 TRACE("(%p)\n", This);
351 return This->state;
354 static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
356 xmlparser *This = impl_from_IXMLParser( iface );
358 FIXME("(%p)\n", This);
360 return E_NOTIMPL;
363 static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
365 xmlparser *This = impl_from_IXMLParser( iface );
367 FIXME("(%p)\n", This);
369 return E_NOTIMPL;
372 static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
374 xmlparser *This = impl_from_IXMLParser( iface );
376 TRACE("(%p %d)\n", This, flags);
378 This->flags = flags;
380 return S_OK;
383 static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
385 xmlparser *This = impl_from_IXMLParser( iface );
387 FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
389 return E_NOTIMPL;
392 static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
394 xmlparser *This = impl_from_IXMLParser( iface );
396 FIXME("(%p %p)\n", This, ppBuf);
398 return E_NOTIMPL;
402 static const struct IXMLParserVtbl xmlparser_vtbl =
404 xmlparser_QueryInterface,
405 xmlparser_AddRef,
406 xmlparser_Release,
407 xmlparser_SetFactory,
408 xmlparser_GetFactory,
409 xmlparser_Abort,
410 xmlparser_GetLineNumber,
411 xmlparser_GetLinePosition,
412 xmlparser_GetAbsolutePosition,
413 xmlparser_GetLineBuffer,
414 xmlparser_GetLastError,
415 xmlparser_GetErrorInfo,
416 xmlparser_GetFlags,
417 xmlparser_GetURL,
418 xmlparser_SetURL,
419 xmlparser_Load,
420 xmlparser_SetInput,
421 xmlparser_PushData,
422 xmlparser_LoadDTD,
423 xmlparser_LoadEntity,
424 xmlparser_ParseEntity,
425 xmlparser_ExpandEntity,
426 xmlparser_SetRoot,
427 xmlparser_GetRoot,
428 xmlparser_Run,
429 xmlparser_GetParserState,
430 xmlparser_Suspend,
431 xmlparser_Reset,
432 xmlparser_SetFlags,
433 xmlparser_SetSecureBaseURL,
434 xmlparser_GetSecureBaseURL
437 HRESULT XMLParser_create(void **ppObj)
439 xmlparser *This;
441 TRACE("(%p)\n", ppObj);
443 This = heap_alloc( sizeof(xmlparser) );
444 if(!This)
445 return E_OUTOFMEMORY;
447 This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
448 This->nodefactory = NULL;
449 This->input = NULL;
450 This->flags = 0;
451 This->state = XMLPARSER_IDLE;
452 This->ref = 1;
454 *ppObj = &This->IXMLParser_iface;
456 TRACE("returning iface %p\n", *ppObj);
458 return S_OK;