2008-01-18 10:33:03 +01:00
|
|
|
/*
|
|
|
|
* DOM Document Implementation implementation
|
|
|
|
*
|
|
|
|
* Copyright 2007 Alistair Leslie-Hughes
|
|
|
|
*
|
|
|
|
* 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>
|
2011-02-24 13:11:53 +01:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/xmlerror.h>
|
|
|
|
#endif
|
|
|
|
|
2008-01-18 10:33:03 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2010-08-29 23:31:49 +02:00
|
|
|
#include "msxml6.h"
|
2008-01-18 10:33:03 +01:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
|
|
|
typedef struct _domimpl
|
|
|
|
{
|
2011-11-14 08:03:31 +01:00
|
|
|
DispatchEx dispex;
|
2010-12-16 01:04:11 +01:00
|
|
|
IXMLDOMImplementation IXMLDOMImplementation_iface;
|
2008-01-18 10:33:03 +01:00
|
|
|
LONG ref;
|
|
|
|
} domimpl;
|
|
|
|
|
|
|
|
static inline domimpl *impl_from_IXMLDOMImplementation( IXMLDOMImplementation *iface )
|
|
|
|
{
|
2010-12-16 01:04:11 +01:00
|
|
|
return CONTAINING_RECORD(iface, domimpl, IXMLDOMImplementation_iface);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_QueryInterface(
|
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
|
|
|
{
|
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
|
|
|
if ( IsEqualGUID( riid, &IID_IXMLDOMImplementation ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IUnknown ) )
|
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2011-11-14 08:03:31 +01:00
|
|
|
else if (dispex_query_interface(&This->dispex, riid, ppvObject))
|
|
|
|
{
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}
|
2008-01-18 10:33:03 +01:00
|
|
|
else
|
|
|
|
{
|
2011-03-13 14:40:26 +01:00
|
|
|
TRACE("Unsupported interface %s\n", debugstr_guid(riid));
|
2011-02-28 20:28:53 +01:00
|
|
|
*ppvObject = NULL;
|
2008-01-18 10:33:03 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMImplementation_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dimimpl_AddRef(
|
|
|
|
IXMLDOMImplementation *iface )
|
|
|
|
{
|
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
2011-03-05 19:32:31 +01:00
|
|
|
ULONG ref = InterlockedIncrement( &This->ref );
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI dimimpl_Release(
|
|
|
|
IXMLDOMImplementation *iface )
|
|
|
|
{
|
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
2011-03-05 19:32:31 +01:00
|
|
|
ULONG ref = InterlockedDecrement( &This->ref );
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2011-03-05 19:32:31 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
2008-01-18 10:33:03 +01:00
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2011-11-14 08:03:31 +01:00
|
|
|
release_dispex(&This->dispex);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( This );
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_GetTypeInfoCount(
|
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_GetTypeInfo(
|
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
UINT iTInfo, LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
2011-11-14 08:03:31 +01:00
|
|
|
return get_typeinfo(IXMLDOMImplementation_tid, ppTInfo);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_GetIDsOfNames(
|
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
REFIID riid, LPOLESTR* rgszNames,
|
|
|
|
UINT cNames, LCID lcid, DISPID* rgDispId )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( 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(IXMLDOMImplementation_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_Invoke(
|
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo, UINT* puArgErr )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( 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(IXMLDOMImplementation_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2010-12-16 01:04:11 +01:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMImplementation_iface, dispIdMember, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-02-20 13:05:45 +01:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dimimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
|
|
|
|
{
|
2008-06-19 23:51:51 +02:00
|
|
|
static const WCHAR bVersion[] = {'1','.','0',0};
|
|
|
|
static const WCHAR bXML[] = {'X','M','L',0};
|
|
|
|
static const WCHAR bDOM[] = {'D','O','M',0};
|
|
|
|
static const WCHAR bMSDOM[] = {'M','S','-','D','O','M',0};
|
2008-01-18 10:33:03 +01:00
|
|
|
BOOL bValidFeature = FALSE;
|
|
|
|
BOOL bValidVersion = FALSE;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_w(version), hasFeature);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
|
|
|
if(!feature || !hasFeature)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*hasFeature = VARIANT_FALSE;
|
|
|
|
|
|
|
|
if(!version || lstrcmpiW(version, bVersion) == 0)
|
|
|
|
bValidVersion = TRUE;
|
|
|
|
|
|
|
|
if(lstrcmpiW(feature, bXML) == 0 || lstrcmpiW(feature, bDOM) == 0 || lstrcmpiW(feature, bMSDOM) == 0)
|
|
|
|
bValidFeature = TRUE;
|
|
|
|
|
|
|
|
if(bValidVersion && bValidFeature)
|
|
|
|
*hasFeature = VARIANT_TRUE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMImplementationVtbl dimimpl_vtbl =
|
|
|
|
{
|
|
|
|
dimimpl_QueryInterface,
|
|
|
|
dimimpl_AddRef,
|
|
|
|
dimimpl_Release,
|
|
|
|
dimimpl_GetTypeInfoCount,
|
|
|
|
dimimpl_GetTypeInfo,
|
|
|
|
dimimpl_GetIDsOfNames,
|
|
|
|
dimimpl_Invoke,
|
|
|
|
dimimpl_hasFeature
|
|
|
|
};
|
|
|
|
|
2011-11-14 08:03:31 +01:00
|
|
|
static const tid_t dimimpl_iface_tids[] = {
|
|
|
|
IXMLDOMImplementation_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static dispex_static_data_t dimimpl_dispex = {
|
|
|
|
NULL,
|
|
|
|
IXMLDOMImplementation_tid,
|
|
|
|
NULL,
|
|
|
|
dimimpl_iface_tids
|
|
|
|
};
|
|
|
|
|
2008-04-30 08:38:33 +02:00
|
|
|
IUnknown* create_doc_Implementation(void)
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
|
|
|
domimpl *This;
|
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
This = heap_alloc( sizeof *This );
|
2008-01-18 10:33:03 +01:00
|
|
|
if ( !This )
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-16 01:04:11 +01:00
|
|
|
This->IXMLDOMImplementation_iface.lpVtbl = &dimimpl_vtbl;
|
2008-01-18 10:33:03 +01:00
|
|
|
This->ref = 1;
|
2011-11-14 08:03:31 +01:00
|
|
|
init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMImplementation_iface, &dimimpl_dispex);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2010-12-16 01:04:11 +01:00
|
|
|
return (IUnknown*)&This->IXMLDOMImplementation_iface;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|