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 <stdarg.h>
|
2011-02-24 13:11:53 +01:00
|
|
|
|
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
|
|
|
|
2021-08-19 16:29:01 +02:00
|
|
|
#include "msxml_dispex.h"
|
2008-01-18 10:33:03 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2015-02-21 14:58:41 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2008-01-18 10:33:03 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_QueryInterface(
|
2008-01-18 10:33:03 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-02-03 11:48:04 +01:00
|
|
|
static ULONG WINAPI domimpl_AddRef(IXMLDOMImplementation *iface)
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
2022-02-03 11:48:04 +01:00
|
|
|
domimpl *domimpl = impl_from_IXMLDOMImplementation(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&domimpl->ref);
|
|
|
|
TRACE("%p, refcount %lu.\n", iface, ref);
|
2011-03-05 19:32:31 +01:00
|
|
|
return ref;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
2022-02-03 11:48:04 +01:00
|
|
|
static ULONG WINAPI domimpl_Release(IXMLDOMImplementation *iface)
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
2022-02-03 11:48:04 +01:00
|
|
|
domimpl *domimpl = impl_from_IXMLDOMImplementation(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&domimpl->ref);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %lu.\n", iface, ref);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2022-02-03 11:48:04 +01:00
|
|
|
if (!ref)
|
|
|
|
heap_free(domimpl);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_GetTypeInfoCount(
|
2008-01-18 10:33:03 +01:00
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_GetTypeInfo(
|
2008-01-18 10:33:03 +01:00
|
|
|
IXMLDOMImplementation *iface,
|
|
|
|
UINT iTInfo, LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
2008-02-20 13:05:45 +01:00
|
|
|
domimpl *This = impl_from_IXMLDOMImplementation( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
|
|
|
|
iTInfo, lcid, ppTInfo);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_GetIDsOfNames(
|
2008-01-18 10:33:03 +01:00
|
|
|
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 );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
|
|
|
|
riid, rgszNames, cNames, lcid, rgDispId);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_Invoke(
|
2008-01-18 10:33:03 +01:00
|
|
|
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 );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
|
|
|
|
dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static HRESULT WINAPI domimpl_hasFeature(IXMLDOMImplementation* This, BSTR feature, BSTR version, VARIANT_BOOL *hasFeature)
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static const struct IXMLDOMImplementationVtbl domimpl_vtbl =
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
2021-08-19 16:29:03 +02:00
|
|
|
domimpl_QueryInterface,
|
|
|
|
domimpl_AddRef,
|
|
|
|
domimpl_Release,
|
|
|
|
domimpl_GetTypeInfoCount,
|
|
|
|
domimpl_GetTypeInfo,
|
|
|
|
domimpl_GetIDsOfNames,
|
|
|
|
domimpl_Invoke,
|
|
|
|
domimpl_hasFeature
|
2008-01-18 10:33:03 +01:00
|
|
|
};
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static const tid_t domimpl_iface_tids[] =
|
|
|
|
{
|
2011-11-14 08:03:31 +01:00
|
|
|
IXMLDOMImplementation_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
static dispex_static_data_t domimpl_dispex =
|
|
|
|
{
|
2011-11-14 08:03:31 +01:00
|
|
|
NULL,
|
|
|
|
IXMLDOMImplementation_tid,
|
|
|
|
NULL,
|
2021-08-19 16:29:03 +02:00
|
|
|
domimpl_iface_tids
|
2011-11-14 08:03:31 +01:00
|
|
|
};
|
|
|
|
|
2021-08-19 16:29:02 +02:00
|
|
|
HRESULT create_dom_implementation(IXMLDOMImplementation **ret)
|
2008-01-18 10:33:03 +01:00
|
|
|
{
|
2021-08-19 16:29:02 +02:00
|
|
|
domimpl *object;
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2021-08-19 16:29:02 +02:00
|
|
|
if (!(object = heap_alloc(sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2021-08-19 16:29:03 +02:00
|
|
|
object->IXMLDOMImplementation_iface.lpVtbl = &domimpl_vtbl;
|
2021-08-19 16:29:02 +02:00
|
|
|
object->ref = 1;
|
2021-08-19 16:29:03 +02:00
|
|
|
init_dispex(&object->dispex, (IUnknown *)&object->IXMLDOMImplementation_iface, &domimpl_dispex);
|
2008-01-18 10:33:03 +01:00
|
|
|
|
2021-08-19 16:29:02 +02:00
|
|
|
*ret = &object->IXMLDOMImplementation_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2008-01-18 10:33:03 +01:00
|
|
|
}
|