2008-03-25 03:19:10 +00:00
|
|
|
/*
|
|
|
|
* SAX Reader implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 Alistair Leslie-Hughes
|
2008-07-16 22:40:32 +00:00
|
|
|
* Copyright 2008 Piotr Caban
|
2008-03-25 03:19:10 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "msxml2.h"
|
|
|
|
#include "wininet.h"
|
|
|
|
#include "urlmon.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2008-03-25 20:59:46 +00:00
|
|
|
#include <libxml/SAX2.h>
|
2008-07-31 14:45:30 +00:00
|
|
|
#include <libxml/parserInternals.h>
|
2008-03-25 20:59:46 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
typedef struct _saxreader
|
|
|
|
{
|
2008-07-31 14:47:26 +00:00
|
|
|
const struct IVBSAXXMLReaderVtbl *lpVBSAXXMLReaderVtbl;
|
2008-07-08 18:52:04 +00:00
|
|
|
const struct ISAXXMLReaderVtbl *lpSAXXMLReaderVtbl;
|
2008-03-25 03:19:10 +00:00
|
|
|
LONG ref;
|
2008-07-08 19:00:20 +00:00
|
|
|
struct ISAXContentHandler *contentHandler;
|
2008-07-31 14:48:03 +00:00
|
|
|
struct IVBSAXContentHandler *vbcontentHandler;
|
2008-07-08 18:52:41 +00:00
|
|
|
struct ISAXErrorHandler *errorHandler;
|
2008-07-31 14:48:03 +00:00
|
|
|
struct IVBSAXErrorHandler *vberrorHandler;
|
2008-03-25 03:19:10 +00:00
|
|
|
xmlSAXHandler sax;
|
|
|
|
} saxreader;
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
typedef struct _saxlocator
|
|
|
|
{
|
2008-07-31 14:47:26 +00:00
|
|
|
const struct IVBSAXLocatorVtbl *lpVBSAXLocatorVtbl;
|
2008-07-16 22:40:32 +00:00
|
|
|
const struct ISAXLocatorVtbl *lpSAXLocatorVtbl;
|
|
|
|
LONG ref;
|
|
|
|
saxreader *saxreader;
|
2008-07-16 22:40:53 +00:00
|
|
|
HRESULT ret;
|
|
|
|
xmlParserCtxtPtr pParserCtxt;
|
2008-07-16 22:42:01 +00:00
|
|
|
WCHAR *publicId;
|
2008-07-16 22:42:07 +00:00
|
|
|
WCHAR *systemId;
|
2008-07-23 14:39:04 +00:00
|
|
|
xmlChar *lastCur;
|
|
|
|
int line;
|
|
|
|
int column;
|
2008-07-31 14:48:03 +00:00
|
|
|
BOOL vbInterface;
|
2008-07-16 22:40:32 +00:00
|
|
|
} saxlocator;
|
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
typedef struct _saxattributes
|
|
|
|
{
|
2008-07-31 14:47:26 +00:00
|
|
|
const struct IVBSAXAttributesVtbl *lpVBSAXAttributesVtbl;
|
2008-07-27 17:55:05 +00:00
|
|
|
const struct ISAXAttributesVtbl *lpSAXAttributesVtbl;
|
|
|
|
LONG ref;
|
2008-07-30 18:24:12 +00:00
|
|
|
int nb_attributes;
|
|
|
|
BSTR *szLocalname;
|
|
|
|
BSTR *szURI;
|
|
|
|
BSTR *szValue;
|
2008-07-31 14:45:42 +00:00
|
|
|
BSTR *szQName;
|
2008-07-27 17:55:05 +00:00
|
|
|
} saxattributes;
|
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
|
|
|
|
{
|
2008-07-31 14:47:26 +00:00
|
|
|
return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpVBSAXXMLReaderVtbl));
|
2008-03-31 19:42:18 +00:00
|
|
|
}
|
2008-03-25 03:19:10 +00:00
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
|
|
|
|
{
|
|
|
|
return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpSAXXMLReaderVtbl));
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:47:26 +00:00
|
|
|
static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
|
|
|
|
{
|
|
|
|
return (saxlocator *)((char*)iface - FIELD_OFFSET(saxlocator, lpVBSAXLocatorVtbl));
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
|
|
|
|
{
|
|
|
|
return (saxlocator *)((char*)iface - FIELD_OFFSET(saxlocator, lpSAXLocatorVtbl));
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:47:26 +00:00
|
|
|
static inline saxattributes *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
|
|
|
|
{
|
|
|
|
return (saxattributes *)((char*)iface - FIELD_OFFSET(saxattributes, lpVBSAXAttributesVtbl));
|
|
|
|
}
|
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
static inline saxattributes *impl_from_ISAXAttributes( ISAXAttributes *iface )
|
|
|
|
{
|
|
|
|
return (saxattributes *)((char*)iface - FIELD_OFFSET(saxattributes, lpSAXAttributesVtbl));
|
|
|
|
}
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
|
2008-08-03 12:37:37 +00:00
|
|
|
static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
|
2008-07-30 18:24:12 +00:00
|
|
|
{
|
|
|
|
DWORD dLen;
|
|
|
|
LPWSTR str;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
|
|
|
|
if(len != -1) dLen++;
|
|
|
|
str = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dLen * sizeof (WCHAR));
|
|
|
|
if (!str)
|
|
|
|
return NULL;
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, str, dLen);
|
|
|
|
if(len != -1) str[dLen-1] = '\0';
|
|
|
|
bstr = SysAllocString(str);
|
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2008-08-03 12:37:37 +00:00
|
|
|
static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
|
|
|
|
{
|
|
|
|
DWORD dLen, dLast;
|
|
|
|
LPWSTR str;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if(!name) return NULL;
|
|
|
|
|
|
|
|
if(!prefix || *prefix=='\0')
|
|
|
|
return bstr_from_xmlChar(name);
|
|
|
|
|
|
|
|
dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)prefix, -1, NULL, 0)
|
|
|
|
+ MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, NULL, 0);
|
|
|
|
str = HeapAlloc(GetProcessHeap(), 0, dLen * sizeof(WCHAR));
|
|
|
|
if(!str)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dLast = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)prefix, -1, str, dLen);
|
|
|
|
str[dLast-1] = ':';
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, &str[dLast], dLen-dLast);
|
|
|
|
bstr = SysAllocString(str);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
|
|
|
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
static void format_error_message_from_id(saxlocator *This, HRESULT hr)
|
|
|
|
{
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = hr;
|
|
|
|
|
|
|
|
if(This->saxreader->errorHandler)
|
|
|
|
{
|
|
|
|
WCHAR msg[1024];
|
|
|
|
if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, hr, 0, msg, sizeof(msg), NULL))
|
|
|
|
{
|
|
|
|
FIXME("MSXML errors not yet supported.\n");
|
|
|
|
msg[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
|
|
|
BSTR bstrMsg = SysAllocString(msg);
|
|
|
|
IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
|
|
|
|
(IVBSAXLocator*)&This->lpVBSAXLocatorVtbl, &bstrMsg, hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
|
|
|
|
(ISAXLocator*)&This->lpSAXLocatorVtbl, msg, hr);
|
2008-07-19 20:32:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
static void update_position(saxlocator *This, xmlChar *end)
|
|
|
|
{
|
|
|
|
if(This->lastCur == NULL)
|
|
|
|
{
|
|
|
|
This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
|
|
|
|
This->line = 1;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
2008-07-31 14:45:30 +00:00
|
|
|
else if(This->lastCur < This->pParserCtxt->input->base)
|
|
|
|
{
|
|
|
|
This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
|
|
|
|
This->line = 1;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
2008-07-23 14:39:04 +00:00
|
|
|
|
|
|
|
if(!end) end = (xmlChar*)This->pParserCtxt->input->cur;
|
|
|
|
|
|
|
|
while(This->lastCur < end)
|
|
|
|
{
|
|
|
|
if(*(This->lastCur) == '\n')
|
|
|
|
{
|
|
|
|
This->line++;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
|
|
|
else if(*(This->lastCur) == '\r' && (This->lastCur==This->pParserCtxt->input->end || *(This->lastCur+1)!='\n'))
|
|
|
|
{
|
|
|
|
This->line++;
|
|
|
|
This->column = 1;
|
|
|
|
}
|
|
|
|
else This->column++;
|
|
|
|
|
|
|
|
This->lastCur++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:47:41 +00:00
|
|
|
/*** IVBSAXAttributes interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_QueryInterface(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes(iface);
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IDispatch) ||
|
|
|
|
IsEqualGUID(riid, &IID_IVBSAXAttributes))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IVBSAXAttributes_AddRef(iface);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes(iface);
|
|
|
|
return ISAXAttributes_AddRef((ISAXAttributes*)&This->lpSAXAttributesVtbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes(iface);
|
|
|
|
return ISAXAttributes_Release((ISAXAttributes*)&This->lpSAXAttributesVtbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDispatch methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_Invoke(
|
|
|
|
IVBSAXAttributes *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXAttributesVtbl), dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXAttributes methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_get_length(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int *nLength)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getLength(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getURI(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *uri)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getURI(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nIndex, (const WCHAR**)uri, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getLocalName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *localName)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getLocalName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nIndex, (const WCHAR**)localName, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *QName)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getQName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nIndex, (const WCHAR**)QName, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
int *index)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getIndexFromName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)uri, SysStringLen(uri),
|
|
|
|
(const WCHAR*)localName, SysStringLen(localName), index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
int *index)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getIndexFromQName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)QName, SysStringLen(QName), index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getType(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getType(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nIndex, (const WCHAR**)type, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getTypeFromName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)uri, SysStringLen(uri),
|
|
|
|
(const WCHAR*)localName, SysStringLen(localName),
|
|
|
|
(const WCHAR**)type, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *type)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getTypeFromQName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)QName, SysStringLen(QName),
|
|
|
|
(const WCHAR**)type, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValue(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getValue(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
nIndex, (const WCHAR**)value, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR uri,
|
|
|
|
BSTR localName,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getValueFromName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)uri, SysStringLen(uri),
|
|
|
|
(const WCHAR*)localName, SysStringLen(localName),
|
|
|
|
(const WCHAR**)value, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
|
|
|
|
IVBSAXAttributes* iface,
|
|
|
|
BSTR QName,
|
|
|
|
BSTR *value)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
saxattributes *This = impl_from_IVBSAXAttributes( iface );
|
|
|
|
return ISAXAttributes_getValueFromQName(
|
|
|
|
(ISAXAttributes*)&This->lpSAXAttributesVtbl,
|
|
|
|
(const WCHAR*)QName, SysStringLen(QName),
|
|
|
|
(const WCHAR**)value, &len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl =
|
|
|
|
{
|
|
|
|
ivbsaxattributes_QueryInterface,
|
|
|
|
ivbsaxattributes_AddRef,
|
|
|
|
ivbsaxattributes_Release,
|
|
|
|
ivbsaxattributes_GetTypeInfoCount,
|
|
|
|
ivbsaxattributes_GetTypeInfo,
|
|
|
|
ivbsaxattributes_GetIDsOfNames,
|
|
|
|
ivbsaxattributes_Invoke,
|
|
|
|
ivbsaxattributes_get_length,
|
|
|
|
ivbsaxattributes_getURI,
|
|
|
|
ivbsaxattributes_getLocalName,
|
|
|
|
ivbsaxattributes_getQName,
|
|
|
|
ivbsaxattributes_getIndexFromName,
|
|
|
|
ivbsaxattributes_getIndexFromQName,
|
|
|
|
ivbsaxattributes_getType,
|
|
|
|
ivbsaxattributes_getTypeFromName,
|
|
|
|
ivbsaxattributes_getTypeFromQName,
|
|
|
|
ivbsaxattributes_getValue,
|
|
|
|
ivbsaxattributes_getValueFromName,
|
|
|
|
ivbsaxattributes_getValueFromQName
|
|
|
|
};
|
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
/*** ISAXAttributes interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxattributes_QueryInterface(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void **ppvObject)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes(iface);
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_ISAXAttributes))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXAttributes_AddRef(iface);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes(iface);
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes(iface);
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref==0)
|
|
|
|
{
|
2008-07-30 18:24:12 +00:00
|
|
|
int index;
|
|
|
|
for(index=0; index<This->nb_attributes; index++)
|
|
|
|
{
|
|
|
|
SysFreeString(This->szLocalname[index]);
|
|
|
|
SysFreeString(This->szURI[index]);
|
|
|
|
SysFreeString(This->szValue[index]);
|
2008-08-03 12:37:37 +00:00
|
|
|
SysFreeString(This->szQName[index]);
|
2008-07-30 18:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->szLocalname);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->szURI);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->szValue);
|
2008-08-03 12:37:37 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->szQName);
|
2008-07-30 18:24:12 +00:00
|
|
|
|
2008-07-27 17:55:05 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXAttributes methods ***/
|
|
|
|
static HRESULT WINAPI isaxattributes_getLength(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int *length)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
2008-07-30 18:26:50 +00:00
|
|
|
*length = This->nb_attributes;
|
|
|
|
TRACE("Length set to %d\n", *length);
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getURI(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pUrl,
|
|
|
|
int *pUriSize)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d) stub\n", This, nIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getLocalName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pLocalName,
|
|
|
|
int *pLocalNameLength)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
2008-07-30 18:27:07 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, nIndex);
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2008-07-30 18:27:07 +00:00
|
|
|
if(nIndex >= This->nb_attributes) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pLocalNameLength = SysStringLen(This->szLocalname[nIndex]);
|
|
|
|
*pLocalName = This->szLocalname[nIndex];
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pQName,
|
|
|
|
int *pQNameLength)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
2008-07-31 14:45:42 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, nIndex);
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2008-07-31 14:45:42 +00:00
|
|
|
if(nIndex >= This->nb_attributes) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*pQNameLength = SysStringLen(This->szQName[nIndex]);
|
|
|
|
*pQName = This->szQName[nIndex];
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pUri,
|
|
|
|
int *pUriLength,
|
|
|
|
const WCHAR **pLocalName,
|
|
|
|
int *pLocalNameSize,
|
|
|
|
const WCHAR **pQName,
|
|
|
|
int *pQNameLength)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d) stub\n", This, nIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int cUriLength,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int cocalNameLength,
|
|
|
|
int *index)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), cUriLength,
|
|
|
|
debugstr_w(pLocalName), cocalNameLength);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getIndexFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQNameLength,
|
|
|
|
int *index)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQNameLength);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getType(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *pTypeLength)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d) stub\n", This, nIndex);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
|
|
|
|
debugstr_w(pLocalName), nLocalName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getTypeFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pType,
|
|
|
|
int *nType)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValue(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
int nIndex,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
2008-07-30 18:27:25 +00:00
|
|
|
TRACE("(%p)->(%d)\n", This, nIndex);
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2008-07-30 18:27:25 +00:00
|
|
|
if(nIndex >= This->nb_attributes) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*nValue = SysStringLen(This->szValue[nIndex]);
|
|
|
|
*pValue = This->szValue[nIndex];
|
|
|
|
|
|
|
|
return S_OK;
|
2008-07-27 17:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pUri,
|
|
|
|
int nUri,
|
|
|
|
const WCHAR *pLocalName,
|
|
|
|
int nLocalName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
|
|
|
|
debugstr_w(pLocalName), nLocalName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxattributes_getValueFromQName(
|
|
|
|
ISAXAttributes* iface,
|
|
|
|
const WCHAR *pQName,
|
|
|
|
int nQName,
|
|
|
|
const WCHAR **pValue,
|
|
|
|
int *nValue)
|
|
|
|
{
|
|
|
|
saxattributes *This = impl_from_ISAXAttributes( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISAXAttributesVtbl isaxattributes_vtbl =
|
|
|
|
{
|
|
|
|
isaxattributes_QueryInterface,
|
|
|
|
isaxattributes_AddRef,
|
|
|
|
isaxattributes_Release,
|
|
|
|
isaxattributes_getLength,
|
|
|
|
isaxattributes_getURI,
|
|
|
|
isaxattributes_getLocalName,
|
|
|
|
isaxattributes_getQName,
|
|
|
|
isaxattributes_getName,
|
|
|
|
isaxattributes_getIndexFromName,
|
|
|
|
isaxattributes_getIndexFromQName,
|
|
|
|
isaxattributes_getType,
|
|
|
|
isaxattributes_getTypeFromName,
|
|
|
|
isaxattributes_getTypeFromQName,
|
|
|
|
isaxattributes_getValue,
|
|
|
|
isaxattributes_getValueFromName,
|
|
|
|
isaxattributes_getValueFromQName
|
|
|
|
};
|
|
|
|
|
2008-07-30 18:24:12 +00:00
|
|
|
static HRESULT SAXAttributes_create(saxattributes **attr,
|
|
|
|
int nb_attributes, const xmlChar **xmlAttributes)
|
2008-07-27 17:55:05 +00:00
|
|
|
{
|
|
|
|
saxattributes *attributes;
|
2008-07-30 18:24:12 +00:00
|
|
|
int index;
|
2008-07-27 17:55:05 +00:00
|
|
|
|
|
|
|
attributes = HeapAlloc(GetProcessHeap(), 0, sizeof(*attributes));
|
|
|
|
if(!attributes)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2008-07-31 14:47:41 +00:00
|
|
|
attributes->lpVBSAXAttributesVtbl = &ivbsaxattributes_vtbl;
|
2008-07-27 17:55:05 +00:00
|
|
|
attributes->lpSAXAttributesVtbl = &isaxattributes_vtbl;
|
|
|
|
attributes->ref = 1;
|
|
|
|
|
2008-07-30 18:24:12 +00:00
|
|
|
attributes->nb_attributes = nb_attributes;
|
|
|
|
|
|
|
|
attributes->szLocalname =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*nb_attributes);
|
|
|
|
attributes->szURI =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*nb_attributes);
|
|
|
|
attributes->szValue =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*nb_attributes);
|
2008-07-31 14:45:42 +00:00
|
|
|
attributes->szQName =
|
|
|
|
HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*nb_attributes);
|
2008-07-27 17:55:05 +00:00
|
|
|
|
2008-08-03 12:37:37 +00:00
|
|
|
if(!attributes->szLocalname || !attributes->szURI
|
|
|
|
|| !attributes->szValue || !attributes->szQName)
|
2008-07-30 18:24:12 +00:00
|
|
|
{
|
2008-08-01 19:50:51 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, attributes->szLocalname);
|
|
|
|
HeapFree(GetProcessHeap(), 0, attributes->szURI);
|
|
|
|
HeapFree(GetProcessHeap(), 0, attributes->szValue);
|
|
|
|
HeapFree(GetProcessHeap(), 0, attributes->szQName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, attributes);
|
2008-07-30 18:24:12 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(index=0; index<nb_attributes; index++)
|
|
|
|
{
|
|
|
|
attributes->szLocalname[index] =
|
|
|
|
bstr_from_xmlChar(xmlAttributes[index*5]);
|
|
|
|
attributes->szURI[index] =
|
|
|
|
bstr_from_xmlChar(xmlAttributes[index*5+2]);
|
|
|
|
attributes->szValue[index] =
|
|
|
|
bstr_from_xmlCharN(xmlAttributes[index*5+3],
|
|
|
|
xmlAttributes[index*5+4]-xmlAttributes[index*5+3]);
|
2008-08-03 12:37:37 +00:00
|
|
|
attributes->szQName[index] =
|
|
|
|
QName_from_xmlChar(xmlAttributes[index*5+1], xmlAttributes[index*5]);
|
2008-07-30 18:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*attr = attributes;
|
|
|
|
|
|
|
|
TRACE("returning %p\n", *attr);
|
2008-07-27 17:55:05 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:01 +00:00
|
|
|
/*** LibXML callbacks ***/
|
|
|
|
static void libxmlStartDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if(This->saxreader->contentHandler)
|
|
|
|
{
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_startDocument(This->saxreader->vbcontentHandler);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_startDocument(This->saxreader->contentHandler);
|
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
if(hr != S_OK)
|
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:01 +00:00
|
|
|
}
|
2008-07-16 22:41:11 +00:00
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
update_position(This, NULL);
|
2008-07-16 22:41:01 +00:00
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:19 +00:00
|
|
|
static void libxmlEndDocument(void *ctx)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
This->column = 0;
|
|
|
|
This->line = 0;
|
2008-07-16 22:41:19 +00:00
|
|
|
|
2008-07-19 20:31:56 +00:00
|
|
|
if(This->ret != S_OK) return;
|
|
|
|
|
2008-07-16 22:41:19 +00:00
|
|
|
if(This->saxreader->contentHandler)
|
|
|
|
{
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endDocument(This->saxreader->vbcontentHandler);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endDocument(This->saxreader->contentHandler);
|
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
if(hr != S_OK)
|
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:27 +00:00
|
|
|
static void libxmlStartElementNS(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *localname,
|
|
|
|
const xmlChar *prefix,
|
|
|
|
const xmlChar *URI,
|
|
|
|
int nb_namespaces,
|
|
|
|
const xmlChar **namespaces,
|
|
|
|
int nb_attributes,
|
|
|
|
int nb_defaulted,
|
|
|
|
const xmlChar **attributes)
|
|
|
|
{
|
|
|
|
BSTR NamespaceUri, LocalName, QName;
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
2008-07-30 18:24:12 +00:00
|
|
|
saxattributes *attr;
|
2008-07-16 22:41:27 +00:00
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1);
|
2008-07-16 22:41:27 +00:00
|
|
|
|
|
|
|
if(This->saxreader->contentHandler)
|
|
|
|
{
|
|
|
|
NamespaceUri = bstr_from_xmlChar(URI);
|
|
|
|
LocalName = bstr_from_xmlChar(localname);
|
2008-08-03 12:37:37 +00:00
|
|
|
QName = QName_from_xmlChar(prefix, localname);
|
2008-07-16 22:41:27 +00:00
|
|
|
|
2008-07-30 18:24:12 +00:00
|
|
|
hr = SAXAttributes_create(&attr, nb_attributes, attributes);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_startElement(
|
|
|
|
This->saxreader->vbcontentHandler,
|
|
|
|
&NamespaceUri, &LocalName, &QName,
|
|
|
|
(IVBSAXAttributes*)&attr->lpVBSAXAttributesVtbl);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_startElement(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
NamespaceUri, SysStringLen(NamespaceUri),
|
|
|
|
LocalName, SysStringLen(LocalName),
|
|
|
|
QName, SysStringLen(QName),
|
|
|
|
(ISAXAttributes*)&attr->lpSAXAttributesVtbl);
|
2008-07-30 18:24:12 +00:00
|
|
|
|
|
|
|
ISAXAttributes_Release((ISAXAttributes*)&attr->lpSAXAttributesVtbl);
|
|
|
|
}
|
2008-07-16 22:41:27 +00:00
|
|
|
|
|
|
|
SysFreeString(NamespaceUri);
|
|
|
|
SysFreeString(LocalName);
|
|
|
|
SysFreeString(QName);
|
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
if(hr != S_OK)
|
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:34 +00:00
|
|
|
static void libxmlEndElementNS(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *localname,
|
|
|
|
const xmlChar *prefix,
|
|
|
|
const xmlChar *URI)
|
|
|
|
{
|
|
|
|
BSTR NamespaceUri, LocalName, QName;
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
2008-07-23 14:39:04 +00:00
|
|
|
xmlChar *end;
|
2008-07-16 22:41:34 +00:00
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
end = This->lastCur;
|
|
|
|
while(*end != '<' && *(end+1) != '/') end++;
|
|
|
|
update_position(This, end+2);
|
2008-07-16 22:41:34 +00:00
|
|
|
|
|
|
|
if(This->saxreader->contentHandler)
|
|
|
|
{
|
|
|
|
NamespaceUri = bstr_from_xmlChar(URI);
|
|
|
|
LocalName = bstr_from_xmlChar(localname);
|
2008-08-03 12:37:37 +00:00
|
|
|
QName = QName_from_xmlChar(prefix, localname);
|
2008-07-16 22:41:34 +00:00
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_endElement(
|
|
|
|
This->saxreader->vbcontentHandler,
|
|
|
|
&NamespaceUri, &LocalName, &QName);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_endElement(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
NamespaceUri, SysStringLen(NamespaceUri),
|
|
|
|
LocalName, SysStringLen(LocalName),
|
|
|
|
QName, SysStringLen(QName));
|
2008-07-16 22:41:34 +00:00
|
|
|
|
|
|
|
SysFreeString(NamespaceUri);
|
|
|
|
SysFreeString(LocalName);
|
|
|
|
SysFreeString(QName);
|
|
|
|
|
2008-07-19 20:32:10 +00:00
|
|
|
if(hr != S_OK)
|
|
|
|
format_error_message_from_id(This, hr);
|
2008-07-16 22:41:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:40 +00:00
|
|
|
static void libxmlCharacters(
|
|
|
|
void *ctx,
|
|
|
|
const xmlChar *ch,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
BSTR Chars;
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
2008-07-23 14:39:04 +00:00
|
|
|
xmlChar *end;
|
2008-07-23 14:39:12 +00:00
|
|
|
xmlChar *lastCurCopy;
|
|
|
|
xmlChar *chEnd;
|
|
|
|
int columnCopy;
|
|
|
|
int lineCopy;
|
|
|
|
|
|
|
|
if(*(This->lastCur-1) != '>' && *(This->lastCur-1) != '/') return;
|
2008-07-16 22:41:40 +00:00
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
if(*(This->lastCur-1) != '>')
|
2008-07-16 22:41:40 +00:00
|
|
|
{
|
2008-07-23 14:39:04 +00:00
|
|
|
end = (xmlChar*)This->pParserCtxt->input->cur-len;
|
2008-07-23 14:39:12 +00:00
|
|
|
while(*(end-1) != '>') end--;
|
2008-07-23 14:39:04 +00:00
|
|
|
update_position(This, end);
|
2008-07-16 22:41:40 +00:00
|
|
|
}
|
|
|
|
|
2008-07-23 14:39:12 +00:00
|
|
|
chEnd = This->lastCur+len;
|
|
|
|
while(*chEnd != '<') chEnd++;
|
|
|
|
|
|
|
|
Chars = bstr_from_xmlChar(ch);
|
|
|
|
|
|
|
|
lastCurCopy = This->lastCur;
|
|
|
|
columnCopy = This->column;
|
|
|
|
lineCopy = This->line;
|
|
|
|
end = This->lastCur;
|
|
|
|
|
2008-07-16 22:41:40 +00:00
|
|
|
if(This->saxreader->contentHandler)
|
|
|
|
{
|
2008-07-23 14:39:12 +00:00
|
|
|
while(This->lastCur < chEnd)
|
|
|
|
{
|
|
|
|
end = This->lastCur;
|
|
|
|
while(end < chEnd-1)
|
|
|
|
{
|
|
|
|
if(*end == '\r') break;
|
|
|
|
end++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Chars = bstr_from_xmlChar(This->lastCur);
|
|
|
|
|
|
|
|
if(*end == '\r' && *(end+1) == '\n')
|
|
|
|
{
|
|
|
|
memmove((WCHAR*)Chars+(end-This->lastCur),
|
|
|
|
(WCHAR*)Chars+(end-This->lastCur)+1,
|
|
|
|
(SysStringLen(Chars)-(end-This->lastCur))*sizeof(WCHAR));
|
|
|
|
SysReAllocStringLen(&Chars, Chars, SysStringLen(Chars)-1);
|
|
|
|
}
|
|
|
|
else if(*end == '\r') Chars[end-This->lastCur] = '\n';
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_characters(
|
|
|
|
This->saxreader->vbcontentHandler, &Chars);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_characters(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
Chars, end-This->lastCur+1);
|
|
|
|
|
2008-07-23 14:39:12 +00:00
|
|
|
SysFreeString(Chars);
|
|
|
|
if(hr != S_OK)
|
|
|
|
{
|
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*(end+1) == '\n') end++;
|
|
|
|
if(end < chEnd) end++;
|
|
|
|
|
|
|
|
This->column += end-This->lastCur;
|
|
|
|
This->lastCur = end;
|
|
|
|
}
|
2008-07-16 22:41:40 +00:00
|
|
|
|
2008-07-23 14:39:12 +00:00
|
|
|
This->lastCur = lastCurCopy;
|
|
|
|
This->column = columnCopy;
|
|
|
|
This->line = lineCopy;
|
|
|
|
update_position(This, chEnd);
|
2008-07-16 22:41:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:41:52 +00:00
|
|
|
static void libxmlSetDocumentLocator(
|
|
|
|
void *ctx,
|
|
|
|
xmlSAXLocatorPtr loc)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
hr = IVBSAXContentHandler_putref_documentLocator(
|
|
|
|
This->saxreader->vbcontentHandler,
|
|
|
|
(IVBSAXLocator*)&This->lpVBSAXLocatorVtbl);
|
|
|
|
else
|
|
|
|
hr = ISAXContentHandler_putDocumentLocator(
|
|
|
|
This->saxreader->contentHandler,
|
|
|
|
(ISAXLocator*)&This->lpSAXLocatorVtbl);
|
2008-07-16 22:41:52 +00:00
|
|
|
|
|
|
|
if(FAILED(hr))
|
2008-07-19 20:32:10 +00:00
|
|
|
format_error_message_from_id(This, hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void libxmlFatalError(void *ctx, const char *msg, ...)
|
|
|
|
{
|
|
|
|
saxlocator *This = ctx;
|
|
|
|
char message[1024];
|
|
|
|
WCHAR *wszError;
|
|
|
|
DWORD len;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
if(!This->saxreader->errorHandler)
|
2008-07-16 22:41:52 +00:00
|
|
|
{
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
2008-07-19 20:32:10 +00:00
|
|
|
This->ret = E_FAIL;
|
|
|
|
return;
|
2008-07-16 22:41:52 +00:00
|
|
|
}
|
2008-07-19 20:32:10 +00:00
|
|
|
|
|
|
|
FIXME("Error handling is not compatible.\n");
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
vsprintf(message, msg, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, message, -1, NULL, 0);
|
|
|
|
wszError = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, message, -1, (LPWSTR)wszError, len);
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
if(This->vbInterface)
|
|
|
|
{
|
|
|
|
BSTR bstrError = SysAllocString(wszError);
|
|
|
|
IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
|
|
|
|
(IVBSAXLocator*)&This->lpVBSAXLocatorVtbl, &bstrError, E_FAIL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
|
|
|
|
(ISAXLocator*)&This->lpSAXLocatorVtbl, wszError, E_FAIL);
|
2008-07-19 20:32:10 +00:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wszError);
|
|
|
|
|
|
|
|
xmlStopParser(This->pParserCtxt);
|
|
|
|
This->ret = E_FAIL;
|
2008-07-16 22:41:52 +00:00
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:11 +00:00
|
|
|
/*** IVBSAXLocator interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_QueryInterface(IVBSAXLocator* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch) ||
|
|
|
|
IsEqualGUID( riid, &IID_IVBSAXLocator ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IVBSAXLocator_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxlocator_AddRef(IVBSAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ivbsaxlocator_Release(
|
|
|
|
IVBSAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
return ISAXLocator_Release((ISAXLocator*)&This->lpVBSAXLocatorVtbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDispatch methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetTypeInfo(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_Invoke(
|
|
|
|
IVBSAXLocator *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXLocatorVtbl), dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
return ISAXLocator_getColumnNumber(
|
|
|
|
(ISAXLocator*)&This->lpVBSAXLocatorVtbl,
|
|
|
|
pnColumn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
return ISAXLocator_getLineNumber(
|
|
|
|
(ISAXLocator*)&This->lpVBSAXLocatorVtbl,
|
|
|
|
pnLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_publicId(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
BSTR* publicId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
return ISAXLocator_getPublicId(
|
|
|
|
(ISAXLocator*)&This->lpVBSAXLocatorVtbl,
|
|
|
|
(const WCHAR**)publicId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ivbsaxlocator_get_systemId(
|
|
|
|
IVBSAXLocator* iface,
|
|
|
|
BSTR* systemId)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_IVBSAXLocator( iface );
|
|
|
|
return ISAXLocator_getSystemId(
|
|
|
|
(ISAXLocator*)&This->lpVBSAXLocatorVtbl,
|
|
|
|
(const WCHAR**)systemId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl =
|
|
|
|
{
|
|
|
|
ivbsaxlocator_QueryInterface,
|
|
|
|
ivbsaxlocator_AddRef,
|
|
|
|
ivbsaxlocator_Release,
|
|
|
|
ivbsaxlocator_GetTypeInfoCount,
|
|
|
|
ivbsaxlocator_GetTypeInfo,
|
|
|
|
ivbsaxlocator_GetIDsOfNames,
|
|
|
|
ivbsaxlocator_Invoke,
|
|
|
|
ivbsaxlocator_get_columnNumber,
|
|
|
|
ivbsaxlocator_get_lineNumber,
|
|
|
|
ivbsaxlocator_get_publicId,
|
|
|
|
ivbsaxlocator_get_systemId
|
|
|
|
};
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
/*** ISAXLocator interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_ISAXLocator ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXLocator_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxlocator_Release(
|
|
|
|
ISAXLocator* iface)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2008-07-16 22:42:01 +00:00
|
|
|
if(This->publicId)
|
|
|
|
SysFreeString(This->publicId);
|
2008-07-16 22:42:07 +00:00
|
|
|
if(This->systemId)
|
|
|
|
SysFreeString(This->systemId);
|
2008-07-16 22:42:01 +00:00
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
ISAXXMLReader_Release((ISAXXMLReader*)&This->saxreader->lpSAXXMLReaderVtbl);
|
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXLocator methods ***/
|
|
|
|
static HRESULT WINAPI isaxlocator_getColumnNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnColumn)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
*pnColumn = This->column;
|
2008-07-16 22:41:11 +00:00
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getLineNumber(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
int *pnLine)
|
|
|
|
{
|
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-23 14:39:04 +00:00
|
|
|
*pnLine = This->line;
|
2008-07-16 22:41:11 +00:00
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getPublicId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchPublicId)
|
|
|
|
{
|
2008-07-16 22:42:01 +00:00
|
|
|
BSTR publicId;
|
2008-07-16 22:40:32 +00:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-16 22:42:01 +00:00
|
|
|
if(This->publicId) SysFreeString(This->publicId);
|
|
|
|
|
|
|
|
publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(publicId))
|
|
|
|
This->publicId = (WCHAR*)&publicId;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(publicId);
|
|
|
|
This->publicId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchPublicId = This->publicId;
|
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxlocator_getSystemId(
|
|
|
|
ISAXLocator* iface,
|
|
|
|
const WCHAR ** ppwchSystemId)
|
|
|
|
{
|
2008-07-16 22:42:07 +00:00
|
|
|
BSTR systemId;
|
2008-07-16 22:40:32 +00:00
|
|
|
saxlocator *This = impl_from_ISAXLocator( iface );
|
|
|
|
|
2008-07-16 22:42:07 +00:00
|
|
|
if(This->systemId) SysFreeString(This->systemId);
|
|
|
|
|
|
|
|
systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
|
|
|
|
if(SysStringLen(systemId))
|
|
|
|
This->systemId = (WCHAR*)&systemId;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SysFreeString(systemId);
|
|
|
|
This->systemId = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppwchSystemId = This->systemId;
|
|
|
|
return S_OK;
|
2008-07-16 22:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISAXLocatorVtbl isaxlocator_vtbl =
|
|
|
|
{
|
|
|
|
isaxlocator_QueryInterface,
|
|
|
|
isaxlocator_AddRef,
|
|
|
|
isaxlocator_Release,
|
|
|
|
isaxlocator_getColumnNumber,
|
|
|
|
isaxlocator_getLineNumber,
|
|
|
|
isaxlocator_getPublicId,
|
|
|
|
isaxlocator_getSystemId
|
|
|
|
};
|
|
|
|
|
2008-07-31 14:48:03 +00:00
|
|
|
static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
|
2008-07-16 22:40:32 +00:00
|
|
|
{
|
|
|
|
saxlocator *locator;
|
|
|
|
|
|
|
|
locator = HeapAlloc( GetProcessHeap(), 0, sizeof (*locator) );
|
|
|
|
if( !locator )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2008-07-31 14:48:11 +00:00
|
|
|
locator->lpVBSAXLocatorVtbl = &ivbsaxlocator_vtbl;
|
2008-07-16 22:40:32 +00:00
|
|
|
locator->lpSAXLocatorVtbl = &isaxlocator_vtbl;
|
|
|
|
locator->ref = 1;
|
2008-07-31 14:48:03 +00:00
|
|
|
locator->vbInterface = vbInterface;
|
2008-07-16 22:40:32 +00:00
|
|
|
|
|
|
|
locator->saxreader = reader;
|
|
|
|
ISAXXMLReader_AddRef((ISAXXMLReader*)&reader->lpSAXXMLReaderVtbl);
|
|
|
|
|
2008-07-16 22:40:53 +00:00
|
|
|
locator->pParserCtxt = NULL;
|
2008-07-16 22:42:01 +00:00
|
|
|
locator->publicId = NULL;
|
2008-07-16 22:42:07 +00:00
|
|
|
locator->systemId = NULL;
|
2008-07-23 14:39:04 +00:00
|
|
|
locator->lastCur = NULL;
|
|
|
|
locator->line = 0;
|
|
|
|
locator->column = 0;
|
2008-07-16 22:40:53 +00:00
|
|
|
locator->ret = S_OK;
|
|
|
|
|
2008-07-16 22:40:32 +00:00
|
|
|
*ppsaxlocator = locator;
|
|
|
|
|
|
|
|
TRACE("returning %p\n", *ppsaxlocator);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-31 14:48:20 +00:00
|
|
|
/*** SAXXMLReader internal functions ***/
|
|
|
|
static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
|
|
|
|
{
|
|
|
|
saxlocator *locator;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = SAXLocator_create(This, &locator, vbInterface);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
|
|
|
|
if(!locator->pParserCtxt)
|
|
|
|
{
|
|
|
|
ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
locator->pParserCtxt->sax = &locator->saxreader->sax;
|
|
|
|
locator->pParserCtxt->userData = locator;
|
|
|
|
|
|
|
|
if(xmlParseDocument(locator->pParserCtxt)) hr = E_FAIL;
|
|
|
|
else hr = locator->ret;
|
|
|
|
|
|
|
|
if(locator->pParserCtxt)
|
|
|
|
{
|
|
|
|
locator->pParserCtxt->sax = NULL;
|
|
|
|
xmlFreeParserCtxt(locator->pParserCtxt);
|
|
|
|
locator->pParserCtxt = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_getEntityResolver(
|
|
|
|
saxreader *This,
|
|
|
|
void *pEntityResolver,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_putEntityResolver(
|
|
|
|
saxreader *This,
|
|
|
|
void *pEntityResolver,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_getContentHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *pContentHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, pContentHandler);
|
|
|
|
if(pContentHandler == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
if(This->contentHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_AddRef(This->vbcontentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_AddRef(This->contentHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface) *(IVBSAXContentHandler**)pContentHandler =
|
|
|
|
This->vbcontentHandler;
|
|
|
|
else *(ISAXContentHandler**)pContentHandler = This->contentHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_putContentHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *contentHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, contentHandler);
|
|
|
|
if(contentHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_AddRef((IVBSAXContentHandler*)contentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_AddRef((ISAXContentHandler*)contentHandler);
|
|
|
|
}
|
|
|
|
if(This->contentHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXContentHandler_Release(This->vbcontentHandler);
|
|
|
|
else
|
|
|
|
ISAXContentHandler_Release(This->contentHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface)
|
|
|
|
This->vbcontentHandler = contentHandler;
|
|
|
|
else
|
|
|
|
This->contentHandler = contentHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_getDTDHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *pDTDHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_putDTDHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *pDTDHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_getErrorHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *pErrorHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, pErrorHandler);
|
|
|
|
if(pErrorHandler == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
if(This->errorHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXErrorHandler_AddRef(This->vberrorHandler);
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_AddRef(This->errorHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface)
|
|
|
|
*(IVBSAXErrorHandler**)pErrorHandler = This->vberrorHandler;
|
|
|
|
else
|
|
|
|
*(ISAXErrorHandler**)pErrorHandler = This->errorHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_putErrorHandler(
|
|
|
|
saxreader* This,
|
|
|
|
void *errorHandler,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%p)\n", This, errorHandler);
|
|
|
|
if(errorHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler*)errorHandler);
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_AddRef((ISAXErrorHandler*)errorHandler);
|
|
|
|
}
|
|
|
|
if(This->errorHandler)
|
|
|
|
{
|
|
|
|
if(vbInterface)
|
|
|
|
IVBSAXErrorHandler_Release(This->vberrorHandler);
|
|
|
|
else
|
|
|
|
ISAXErrorHandler_Release(This->errorHandler);
|
|
|
|
}
|
|
|
|
if(vbInterface)
|
|
|
|
This->vberrorHandler = errorHandler;
|
|
|
|
else
|
|
|
|
This->errorHandler = errorHandler;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_parse(
|
|
|
|
saxreader* This,
|
|
|
|
VARIANT varInput,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
switch(V_VT(&varInput))
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
|
|
|
hr = internal_parseBuffer(This, (const char*)V_BSTR(&varInput),
|
|
|
|
SysStringByteLen(V_BSTR(&varInput)), vbInterface);
|
|
|
|
break;
|
|
|
|
case VT_ARRAY|VT_UI1: {
|
|
|
|
void *pSAData;
|
|
|
|
LONG lBound, uBound;
|
|
|
|
ULONG dataRead;
|
|
|
|
|
|
|
|
hr = SafeArrayGetLBound(V_ARRAY(&varInput), 1, &lBound);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput));
|
|
|
|
hr = SafeArrayAccessData(V_ARRAY(&varInput), (void**)&pSAData);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&varInput));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
case VT_DISPATCH: {
|
|
|
|
IPersistStream *persistStream;
|
|
|
|
IStream *stream = NULL;
|
|
|
|
IXMLDOMDocument *xmlDoc;
|
|
|
|
|
|
|
|
if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IPersistStream, (void**)&persistStream) == S_OK)
|
|
|
|
{
|
|
|
|
hr = IPersistStream_Save(persistStream, stream, TRUE);
|
|
|
|
IPersistStream_Release(persistStream);
|
|
|
|
if(hr != S_OK) break;
|
|
|
|
}
|
|
|
|
if(stream || IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IStream, (void**)&stream) == S_OK)
|
|
|
|
{
|
|
|
|
STATSTG dataInfo;
|
|
|
|
ULONG dataRead;
|
|
|
|
char *data;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
hr = IStream_Stat(stream, &dataInfo, STATFLAG_NONAME);
|
|
|
|
if(hr == E_PENDING) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
data = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
dataInfo.cbSize.QuadPart);
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
hr = IStream_Read(stream, data,
|
|
|
|
dataInfo.cbSize.QuadPart, &dataRead);
|
|
|
|
if(hr == E_PENDING) continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hr = internal_parseBuffer(This, data,
|
|
|
|
dataInfo.cbSize.QuadPart, vbInterface);
|
|
|
|
HeapFree(GetProcessHeap(), 0, data);
|
|
|
|
IStream_Release(stream);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
|
|
|
|
&IID_IXMLDOMDocument, (void**)&xmlDoc) == S_OK)
|
|
|
|
{
|
|
|
|
BSTR bstrData;
|
|
|
|
|
|
|
|
IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
|
|
|
|
hr = internal_parseBuffer(This, (const char*)bstrData,
|
|
|
|
SysStringByteLen(bstrData), vbInterface);
|
|
|
|
IXMLDOMDocument_Release(xmlDoc);
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
WARN("vt %d not implemented\n", V_VT(&varInput));
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT internal_vbonDataAvailable(void *obj, char *ptr, DWORD len)
|
|
|
|
{
|
|
|
|
saxreader *This = obj;
|
|
|
|
|
|
|
|
return internal_parseBuffer(This, ptr, len, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT internal_onDataAvailable(void *obj, char *ptr, DWORD len)
|
|
|
|
{
|
|
|
|
saxreader *This = obj;
|
|
|
|
|
|
|
|
return internal_parseBuffer(This, ptr, len, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI internal_parseURL(
|
|
|
|
saxreader* This,
|
|
|
|
const WCHAR *url,
|
|
|
|
BOOL vbInterface)
|
|
|
|
{
|
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(url));
|
|
|
|
|
|
|
|
if(vbInterface) hr = bind_url(url, internal_vbonDataAvailable, This, &bsc);
|
|
|
|
else hr = bind_url(url, internal_onDataAvailable, This, &bsc);
|
|
|
|
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
detach_bsc(bsc);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
/*** IVBSAXXMLReader interface ***/
|
2008-03-25 03:19:10 +00:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2008-07-08 18:52:04 +00:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
|
|
|
|
{
|
|
|
|
*ppvObject = (ISAXXMLReader*)&This->lpSAXXMLReaderVtbl;
|
|
|
|
}
|
2008-03-25 03:19:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IVBSAXXMLReader_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI saxxmlreader_Release(
|
|
|
|
IVBSAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2008-07-08 19:00:20 +00:00
|
|
|
if(This->contentHandler)
|
|
|
|
ISAXContentHandler_Release(This->contentHandler);
|
|
|
|
|
2008-07-08 18:52:41 +00:00
|
|
|
if(This->errorHandler)
|
|
|
|
ISAXErrorHandler_Release(This->errorHandler);
|
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
/*** IDispatch ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetTypeInfo(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXXMLReader_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_Invoke(
|
|
|
|
IVBSAXXMLReader *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2008-07-31 14:47:26 +00:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXXMLReaderVtbl), dispIdMember, wFlags, pDispParams,
|
2008-03-25 03:19:10 +00:00
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IVBSAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI saxxmlreader_getFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL *pValue)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putFeature(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL vfValue)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT *pValue)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putProperty(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(pProp));
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getEntityResolver(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXEntityResolver **pEntityResolver)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getEntityResolver(This, pEntityResolver, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putEntityResolver(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXEntityResolver *pEntityResolver)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putEntityResolver(This, pEntityResolver, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getContentHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXContentHandler **ppContentHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getContentHandler(This, ppContentHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putContentHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXContentHandler *contentHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putContentHandler(This, contentHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getDTDHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXDTDHandler **pDTDHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getDTDHandler(This, pDTDHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putDTDHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXDTDHandler *pDTDHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putDTDHandler(This, pDTDHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getErrorHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXErrorHandler **pErrorHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getErrorHandler(This, pErrorHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putErrorHandler(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
IVBSAXErrorHandler *errorHandler)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putErrorHandler(This, errorHandler, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getBaseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR **pBaseUrl)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putBaseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *pBaseUrl)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_getSecureBaseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR **pSecureBaseUrl)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_putSecureBaseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *secureBaseUrl)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
|
|
|
|
|
|
|
FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
|
2008-03-25 03:19:10 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parse(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parse(This, varInput, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI saxxmlreader_parseURL(
|
|
|
|
IVBSAXXMLReader* iface,
|
|
|
|
const WCHAR *url)
|
|
|
|
{
|
2008-03-31 23:45:13 +00:00
|
|
|
saxreader *This = impl_from_IVBSAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parseURL(This, url, TRUE);
|
2008-03-25 03:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IVBSAXXMLReaderVtbl saxreader_vtbl =
|
|
|
|
{
|
|
|
|
saxxmlreader_QueryInterface,
|
|
|
|
saxxmlreader_AddRef,
|
|
|
|
saxxmlreader_Release,
|
|
|
|
saxxmlreader_GetTypeInfoCount,
|
|
|
|
saxxmlreader_GetTypeInfo,
|
|
|
|
saxxmlreader_GetIDsOfNames,
|
|
|
|
saxxmlreader_Invoke,
|
|
|
|
saxxmlreader_getFeature,
|
|
|
|
saxxmlreader_putFeature,
|
|
|
|
saxxmlreader_getProperty,
|
|
|
|
saxxmlreader_putProperty,
|
|
|
|
saxxmlreader_getEntityResolver,
|
|
|
|
saxxmlreader_putEntityResolver,
|
|
|
|
saxxmlreader_getContentHandler,
|
|
|
|
saxxmlreader_putContentHandler,
|
|
|
|
saxxmlreader_getDTDHandler,
|
|
|
|
saxxmlreader_putDTDHandler,
|
|
|
|
saxxmlreader_getErrorHandler,
|
|
|
|
saxxmlreader_putErrorHandler,
|
|
|
|
saxxmlreader_getBaseURL,
|
|
|
|
saxxmlreader_putBaseURL,
|
|
|
|
saxxmlreader_getSecureBaseURL,
|
|
|
|
saxxmlreader_putSecureBaseURL,
|
|
|
|
saxxmlreader_parse,
|
|
|
|
saxxmlreader_parseURL
|
|
|
|
};
|
|
|
|
|
2008-07-08 18:52:04 +00:00
|
|
|
/*** ISAXXMLReader interface ***/
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:47:26 +00:00
|
|
|
return saxxmlreader_QueryInterface((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl, riid, ppvObject);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:47:26 +00:00
|
|
|
return saxxmlreader_AddRef((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:47:26 +00:00
|
|
|
return saxxmlreader_Release((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** ISAXXMLReader methods ***/
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getFeature(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL *pValue)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_getFeature(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pFeature, pValue);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putFeature(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pFeature,
|
|
|
|
VARIANT_BOOL vfValue)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_putFeature(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pFeature, vfValue);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getProperty(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT *pValue)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_getProperty(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pProp, pValue);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putProperty(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pProp,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_putProperty(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pProp, value);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXEntityResolver **ppEntityResolver)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getEntityResolver(This, ppEntityResolver, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putEntityResolver(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXEntityResolver *pEntityResolver)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putEntityResolver(This, pEntityResolver, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getContentHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXContentHandler **pContentHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getContentHandler(This, pContentHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putContentHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXContentHandler *contentHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putContentHandler(This, contentHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXDTDHandler **pDTDHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getDTDHandler(This, pDTDHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putDTDHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXDTDHandler *pDTDHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putDTDHandler(This, pDTDHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getErrorHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXErrorHandler **pErrorHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_getErrorHandler(This, pErrorHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putErrorHandler(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
ISAXErrorHandler *errorHandler)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_putErrorHandler(This, errorHandler, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR **pBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_get_getBaseURL(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pBaseUrl);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *pBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_put_putBaseURL(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pBaseUrl);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR **pSecureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_get_getSecureBaseURL(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
pSecureBaseUrl);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *secureBaseUrl)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return IVBSAXXMLReader_put_putSecureBaseURL(
|
|
|
|
(IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
|
|
|
|
secureBaseUrl);
|
2008-07-27 17:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parse(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
VARIANT varInput)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parse(This, varInput, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI isaxxmlreader_parseURL(
|
|
|
|
ISAXXMLReader* iface,
|
|
|
|
const WCHAR *url)
|
|
|
|
{
|
|
|
|
saxreader *This = impl_from_ISAXXMLReader( iface );
|
2008-07-31 14:48:20 +00:00
|
|
|
return internal_parseURL(This, url, FALSE);
|
2008-07-08 18:52:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
|
|
|
|
{
|
|
|
|
isaxxmlreader_QueryInterface,
|
|
|
|
isaxxmlreader_AddRef,
|
|
|
|
isaxxmlreader_Release,
|
|
|
|
isaxxmlreader_getFeature,
|
|
|
|
isaxxmlreader_putFeature,
|
|
|
|
isaxxmlreader_getProperty,
|
|
|
|
isaxxmlreader_putProperty,
|
|
|
|
isaxxmlreader_getEntityResolver,
|
|
|
|
isaxxmlreader_putEntityResolver,
|
|
|
|
isaxxmlreader_getContentHandler,
|
|
|
|
isaxxmlreader_putContentHandler,
|
|
|
|
isaxxmlreader_getDTDHandler,
|
|
|
|
isaxxmlreader_putDTDHandler,
|
|
|
|
isaxxmlreader_getErrorHandler,
|
|
|
|
isaxxmlreader_putErrorHandler,
|
|
|
|
isaxxmlreader_getBaseURL,
|
|
|
|
isaxxmlreader_putBaseURL,
|
|
|
|
isaxxmlreader_getSecureBaseURL,
|
|
|
|
isaxxmlreader_putSecureBaseURL,
|
|
|
|
isaxxmlreader_parse,
|
|
|
|
isaxxmlreader_parseURL
|
|
|
|
};
|
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
saxreader *reader;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
|
|
|
|
|
|
|
reader = HeapAlloc( GetProcessHeap(), 0, sizeof (*reader) );
|
|
|
|
if( !reader )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2008-07-31 14:47:26 +00:00
|
|
|
reader->lpVBSAXXMLReaderVtbl = &saxreader_vtbl;
|
2008-07-08 18:52:04 +00:00
|
|
|
reader->lpSAXXMLReaderVtbl = &isaxreader_vtbl;
|
2008-03-25 03:19:10 +00:00
|
|
|
reader->ref = 1;
|
2008-07-08 19:00:20 +00:00
|
|
|
reader->contentHandler = NULL;
|
2008-07-08 18:52:41 +00:00
|
|
|
reader->errorHandler = NULL;
|
2008-03-25 03:19:10 +00:00
|
|
|
|
2008-07-16 22:40:53 +00:00
|
|
|
memset(&reader->sax, 0, sizeof(xmlSAXHandler));
|
|
|
|
reader->sax.initialized = XML_SAX2_MAGIC;
|
2008-07-16 22:41:01 +00:00
|
|
|
reader->sax.startDocument = libxmlStartDocument;
|
2008-07-16 22:41:19 +00:00
|
|
|
reader->sax.endDocument = libxmlEndDocument;
|
2008-07-16 22:41:27 +00:00
|
|
|
reader->sax.startElementNs = libxmlStartElementNS;
|
2008-07-16 22:41:34 +00:00
|
|
|
reader->sax.endElementNs = libxmlEndElementNS;
|
2008-07-16 22:41:40 +00:00
|
|
|
reader->sax.characters = libxmlCharacters;
|
2008-07-16 22:41:52 +00:00
|
|
|
reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
|
2008-07-19 20:32:10 +00:00
|
|
|
reader->sax.error = libxmlFatalError;
|
|
|
|
reader->sax.fatalError = libxmlFatalError;
|
2008-07-16 22:40:53 +00:00
|
|
|
|
2008-07-31 14:47:26 +00:00
|
|
|
*ppObj = &reader->lpVBSAXXMLReaderVtbl;
|
2008-03-26 03:40:01 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
TRACE("returning iface %p\n", *ppObj);
|
2008-03-26 03:40:01 +00:00
|
|
|
|
2008-03-25 03:19:10 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
MESSAGE("This program tried to use a SAX XML Reader object, but\n"
|
|
|
|
"libxml2 support was not present at compile time.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|