2005-08-02 13:29:04 +02:00
|
|
|
/*
|
|
|
|
* DOM Document implementation
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack
|
|
|
|
*
|
2005-11-08 13:46:43 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
2005-08-02 13:29:04 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2005-11-08 13:46:43 +01:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2005-08-02 13:29:04 +02:00
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-02 13:29:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2005-12-01 18:46:42 +01:00
|
|
|
#include <assert.h>
|
2005-08-02 13:29:04 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2005-08-10 11:54:22 +02:00
|
|
|
#include "winnls.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
#include "ole2.h"
|
2005-11-08 20:59:36 +01:00
|
|
|
#include "msxml2.h"
|
2006-02-21 12:50:59 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "urlmon.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2007-05-09 20:09:11 +02:00
|
|
|
static const WCHAR SZ_PROPERTY_SELECTION_LANGUAGE[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0};
|
|
|
|
static const WCHAR SZ_VALUE_XPATH[] = {'X','P','a','t','h',0};
|
|
|
|
static const WCHAR SZ_VALUE_XSLPATTERN[] = {'X','S','L','P','a','t','t','e','r','n',0};
|
|
|
|
|
2006-02-21 12:50:59 +01:00
|
|
|
typedef struct {
|
|
|
|
const struct IBindStatusCallbackVtbl *lpVtbl;
|
|
|
|
} bsc;
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_QueryInterface(
|
|
|
|
IBindStatusCallback *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppobj )
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IBindStatusCallback))
|
|
|
|
{
|
|
|
|
IBindStatusCallback_AddRef( iface );
|
|
|
|
*ppobj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI bsc_AddRef(
|
|
|
|
IBindStatusCallback *iface )
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI bsc_Release(
|
|
|
|
IBindStatusCallback *iface )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnStartBinding(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
DWORD dwReserved,
|
|
|
|
IBinding* pib)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_GetPriority(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
LONG* pnPriority)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnLowResource(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
DWORD reserved)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnProgress(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
ULONG ulProgress,
|
|
|
|
ULONG ulProgressMax,
|
|
|
|
ULONG ulStatusCode,
|
|
|
|
LPCWSTR szStatusText)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnStopBinding(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
HRESULT hresult,
|
|
|
|
LPCWSTR szError)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_GetBindInfo(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
DWORD* grfBINDF,
|
|
|
|
BINDINFO* pbindinfo)
|
|
|
|
{
|
|
|
|
*grfBINDF = BINDF_RESYNCHRONIZE;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnDataAvailable(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
DWORD grfBSCF,
|
|
|
|
DWORD dwSize,
|
|
|
|
FORMATETC* pformatetc,
|
|
|
|
STGMEDIUM* pstgmed)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI bsc_OnObjectAvailable(
|
|
|
|
IBindStatusCallback* iface,
|
|
|
|
REFIID riid,
|
|
|
|
IUnknown* punk)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-08-02 13:28:36 +02:00
|
|
|
static const struct IBindStatusCallbackVtbl bsc_vtbl =
|
2006-02-21 12:50:59 +01:00
|
|
|
{
|
|
|
|
bsc_QueryInterface,
|
|
|
|
bsc_AddRef,
|
|
|
|
bsc_Release,
|
|
|
|
bsc_OnStartBinding,
|
|
|
|
bsc_GetPriority,
|
|
|
|
bsc_OnLowResource,
|
|
|
|
bsc_OnProgress,
|
|
|
|
bsc_OnStopBinding,
|
|
|
|
bsc_GetBindInfo,
|
|
|
|
bsc_OnDataAvailable,
|
|
|
|
bsc_OnObjectAvailable
|
|
|
|
};
|
|
|
|
|
|
|
|
static bsc domdoc_bsc = { &bsc_vtbl };
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
typedef struct _domdoc
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
const struct IXMLDOMDocument2Vtbl *lpVtbl;
|
2005-08-02 13:29:04 +02:00
|
|
|
LONG ref;
|
|
|
|
VARIANT_BOOL async;
|
2007-02-18 19:37:18 +01:00
|
|
|
VARIANT_BOOL validating;
|
|
|
|
VARIANT_BOOL resolving;
|
|
|
|
VARIANT_BOOL preserving;
|
2007-05-09 20:09:11 +02:00
|
|
|
BOOL bUseXPath;
|
2005-12-01 18:46:42 +01:00
|
|
|
IUnknown *node_unk;
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *node;
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMSchemaCollection *schema;
|
2006-02-21 12:52:25 +01:00
|
|
|
HRESULT error;
|
2005-08-02 13:29:04 +02:00
|
|
|
} domdoc;
|
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
LONG xmldoc_add_ref(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
LONG ref = InterlockedIncrement((LONG*)&doc->_private);
|
2006-10-05 00:58:11 +02:00
|
|
|
TRACE("%d\n", ref);
|
2005-11-18 16:05:26 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONG xmldoc_release(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
LONG ref = InterlockedDecrement((LONG*)&doc->_private);
|
2006-10-05 00:58:11 +02:00
|
|
|
TRACE("%d\n", ref);
|
2005-11-18 16:05:26 +01:00
|
|
|
if(ref == 0)
|
|
|
|
{
|
|
|
|
TRACE("freeing docptr %p\n", doc);
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static inline domdoc *impl_from_IXMLDOMDocument2( IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpVtbl));
|
|
|
|
}
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
static inline xmlDocPtr get_doc( domdoc *This )
|
|
|
|
{
|
|
|
|
return (xmlDocPtr) xmlNodePtr_from_domnode( This->node, XML_DOCUMENT_NODE );
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID riid, void** ppvObject )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2005-10-31 22:04:31 +01:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument2 ) )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2005-12-01 18:46:42 +01:00
|
|
|
else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) )
|
|
|
|
{
|
|
|
|
return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
else
|
2006-01-27 19:22:56 +01:00
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOINTERFACE;
|
2006-01-27 19:22:56 +01:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
IXMLDOMDocument_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI domdoc_AddRef(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI domdoc_Release(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2005-12-01 18:46:42 +01:00
|
|
|
IUnknown_Release( This->node_unk );
|
2007-02-27 16:11:13 +01:00
|
|
|
if(This->schema) IXMLDOMSchemaCollection_Release( This->schema );
|
2005-08-02 13:29:04 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfoCount( IXMLDOMDocument2 *iface, UINT* pctinfo )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfo(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetIDsOfNames(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_Invoke(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* name )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-19 13:23:02 +02:00
|
|
|
return IXMLDOMNode_get_nodeName( This->node, name );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* value )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-19 13:23:02 +02:00
|
|
|
return IXMLDOMNode_get_nodeValue( This->node, value );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT value)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-19 13:23:02 +02:00
|
|
|
return IXMLDOMNode_put_nodeValue( This->node, value );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
DOMNodeType* type )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-19 13:23:02 +02:00
|
|
|
return IXMLDOMNode_get_nodeType( This->node, type );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parentNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** parent )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_parentNode( This->node, parent );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_childNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNodeList** childList )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_childNodes( This->node, childList );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_firstChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** firstChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_firstChild( This->node, firstChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_lastChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** lastChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_lastChild( This->node, lastChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_previousSibling(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** previousSibling )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_previousSibling( This->node, previousSibling );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nextSibling(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** nextSibling )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_nextSibling( This->node, nextSibling );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_attributes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNamedNodeMap** attributeMap )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_attributes( This->node, attributeMap );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_insertBefore(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
VARIANT refChild,
|
|
|
|
IXMLDOMNode** outNewChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_insertBefore( This->node, newChild, refChild, outNewChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_replaceChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode* oldChild,
|
|
|
|
IXMLDOMNode** outOldChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_replaceChild( This->node, newChild, oldChild, outOldChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_removeChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* childNode,
|
|
|
|
IXMLDOMNode** oldChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_removeChild( This->node, childNode, oldChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_appendChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode** outNewChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_appendChild( This->node, newChild, outNewChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_hasChildNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* hasChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_hasChildNodes( This->node, hasChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_ownerDocument(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMDocument** DOMDocument)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_ownerDocument( This->node, DOMDocument );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_cloneNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL deep,
|
|
|
|
IXMLDOMNode** cloneRoot)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_cloneNode( This->node, deep, cloneRoot );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypeString(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* nodeType )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_nodeTypeString( This->node, nodeType );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_text(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* text )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_text( This->node, text );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_text(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR text )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_put_text( This->node, text );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_specified(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isSpecified )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_specified( This->node, isSpecified );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_definition(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** definitionNode )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_definition( This->node, definitionNode );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypedValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* typedValue )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_nodeTypedValue( This->node, typedValue );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeTypedValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT typedValue )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_put_nodeTypedValue( This->node, typedValue );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_dataType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* dataTypeName )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_dataType( This->node, dataTypeName );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_dataType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR dataTypeName )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_put_dataType( This->node, dataTypeName );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_xml(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* xmlString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_xml( This->node, xmlString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* styleSheet,
|
|
|
|
BSTR* xmlString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_transformNode( This->node, styleSheet, xmlString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNodeList** resultList )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_selectNodes( This->node, queryString, resultList );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectSingleNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNode** resultNode )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_selectSingleNode( This->node, queryString, resultNode );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parsed(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isParsed )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_parsed( This->node, isParsed );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_namespaceURI(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* namespaceURI )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_namespaceURI( This->node, namespaceURI );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_prefix(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* prefixString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_prefix( This->node, prefixString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_baseName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* nameString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_get_baseName( This->node, nameString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNodeToObject(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* stylesheet,
|
|
|
|
VARIANT outputObject)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-22 11:24:36 +02:00
|
|
|
return IXMLDOMNode_transformNodeToObject( This->node, stylesheet, outputObject );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_doctype(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-11-08 20:59:36 +01:00
|
|
|
IXMLDOMDocumentType** documentType )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_implementation(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMImplementation** impl )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_documentElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement** DOMElement )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-10 11:54:22 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
|
|
|
xmlNodePtr root = NULL;
|
2005-12-01 18:46:42 +01:00
|
|
|
IXMLDOMNode *element_node;
|
|
|
|
HRESULT hr;
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2007-11-11 12:35:35 +01:00
|
|
|
TRACE("%p %p\n", This, This->node);
|
|
|
|
|
|
|
|
if(!DOMElement)
|
|
|
|
return E_INVALIDARG;
|
2005-08-03 12:58:47 +02:00
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
*DOMElement = NULL;
|
2005-08-03 12:58:47 +02:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
xmldoc = get_doc( This );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
root = xmlDocGetRootElement( xmldoc );
|
|
|
|
if ( !root )
|
|
|
|
return S_FALSE;
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
element_node = create_node( root );
|
|
|
|
if(!element_node) return S_FALSE;
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_QueryInterface(element_node, &IID_IXMLDOMElement, (LPVOID*)DOMElement);
|
|
|
|
IXMLDOMNode_Release(element_node);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_documentElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement* DOMElement )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagname,
|
|
|
|
IXMLDOMElement** element )
|
|
|
|
{
|
2006-11-17 15:32:17 +01:00
|
|
|
xmlNodePtr xmlnode;
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-11-17 15:32:17 +01:00
|
|
|
xmlChar *xml_name;
|
|
|
|
IUnknown *elem_unk;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p->(%s,%p)\n", iface, debugstr_w(tagname), element);
|
|
|
|
|
|
|
|
xml_name = xmlChar_from_wchar((WCHAR*)tagname);
|
|
|
|
xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL);
|
|
|
|
|
|
|
|
TRACE("created xmlptr %p\n", xmlnode);
|
|
|
|
elem_unk = create_element(xmlnode, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, xml_name);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(elem_unk, &IID_IXMLDOMElement, (void **)element);
|
|
|
|
IUnknown_Release(elem_unk);
|
|
|
|
TRACE("returning %p\n", *element);
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createDocumentFragment(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMDocumentFragment** docFrag )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createTextNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMText** text )
|
|
|
|
{
|
2007-11-15 23:55:49 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
xmlNodePtr xmlnode;
|
|
|
|
xmlChar *xml_content;
|
|
|
|
|
|
|
|
TRACE("%p->(%s %p)\n", iface, debugstr_w(data), text);
|
|
|
|
|
|
|
|
if(!text)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*text = NULL;
|
|
|
|
|
|
|
|
xml_content = xmlChar_from_wchar((WCHAR*)data);
|
|
|
|
xmlnode = xmlNewText(xml_content);
|
|
|
|
HeapFree(GetProcessHeap(), 0, xml_content);
|
|
|
|
|
|
|
|
if(!xmlnode)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
xmlnode->doc = get_doc( This );
|
|
|
|
|
|
|
|
*text = (IXMLDOMText*)create_text(xmlnode);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createComment(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMComment** comment )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createCDATASection(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMCDATASection** cdata )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createProcessingInstruction(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR target,
|
|
|
|
BSTR data,
|
|
|
|
IXMLDOMProcessingInstruction** pi )
|
|
|
|
{
|
2006-11-30 00:59:03 +01:00
|
|
|
#ifdef HAVE_XMLNEWDOCPI
|
2006-11-17 00:17:00 +01:00
|
|
|
xmlNodePtr xmlnode;
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-11-17 00:17:00 +01:00
|
|
|
xmlChar *xml_target, *xml_content;
|
|
|
|
|
|
|
|
TRACE("%p->(%s %s %p)\n", iface, debugstr_w(target), debugstr_w(data), pi);
|
|
|
|
|
|
|
|
xml_target = xmlChar_from_wchar((WCHAR*)target);
|
|
|
|
xml_content = xmlChar_from_wchar((WCHAR*)data);
|
|
|
|
|
|
|
|
xmlnode = xmlNewDocPI(get_doc(This), xml_target, xml_content);
|
|
|
|
TRACE("created xmlptr %p\n", xmlnode);
|
|
|
|
*pi = (IXMLDOMProcessingInstruction*)create_pi(xmlnode);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, xml_content);
|
|
|
|
HeapFree(GetProcessHeap(), 0, xml_target);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-11-30 00:59:03 +01:00
|
|
|
#else
|
2006-12-04 19:56:48 +01:00
|
|
|
FIXME("Libxml 2.6.15 or greater required.\n");
|
2006-11-30 00:59:03 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
#endif
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createAttribute(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR name,
|
|
|
|
IXMLDOMAttribute** attribute )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createEntityReference(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR name,
|
|
|
|
IXMLDOMEntityReference** entityRef )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getElementsByTagName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagName,
|
|
|
|
IXMLDOMNodeList** resultList )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-05-11 17:03:13 +02:00
|
|
|
LPWSTR szPattern;
|
|
|
|
HRESULT hr;
|
2006-02-14 10:38:21 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList);
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
szPattern = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(2+lstrlenW(tagName)+1));
|
|
|
|
szPattern[0] = szPattern[1] = '/';
|
|
|
|
lstrcpyW(szPattern + 2, tagName);
|
2006-02-14 10:38:21 +01:00
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
hr = queryresult_create((xmlNodePtr)get_doc(This), szPattern, resultList);
|
|
|
|
HeapFree(GetProcessHeap(), 0, szPattern);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
static DOMNodeType get_node_type(VARIANT Type)
|
|
|
|
{
|
|
|
|
if(V_VT(&Type) == VT_I4)
|
|
|
|
return V_I4(&Type);
|
|
|
|
|
|
|
|
FIXME("Unsupported variant type %x\n", V_VT(&Type));
|
|
|
|
return 0;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT Type,
|
|
|
|
BSTR name,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-01-11 21:15:12 +01:00
|
|
|
DOMNodeType node_type;
|
|
|
|
xmlNodePtr xmlnode = NULL;
|
|
|
|
xmlChar *xml_name;
|
|
|
|
|
|
|
|
TRACE("(%p)->(type,%s,%s,%p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node);
|
|
|
|
|
|
|
|
node_type = get_node_type(Type);
|
|
|
|
TRACE("node_type %d\n", node_type);
|
|
|
|
|
|
|
|
xml_name = xmlChar_from_wchar((WCHAR*)name);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
switch(node_type)
|
|
|
|
{
|
|
|
|
case NODE_ELEMENT:
|
|
|
|
xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL);
|
|
|
|
*node = create_node(xmlnode);
|
|
|
|
TRACE("created %p\n", xmlnode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unhandled node type %d\n", node_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, xml_name);
|
|
|
|
|
|
|
|
if(xmlnode && *node)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_nodeFromID(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR idString,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-08-12 12:35:17 +02:00
|
|
|
static xmlDocPtr doparse( char *ptr, int len )
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XMLREADMEMORY
|
|
|
|
/*
|
2005-08-17 11:56:24 +02:00
|
|
|
* use xmlReadMemory if possible so we can suppress
|
2005-08-12 12:35:17 +02:00
|
|
|
* writing errors to stderr
|
|
|
|
*/
|
|
|
|
return xmlReadMemory( ptr, len, NULL, NULL,
|
2006-06-14 03:38:20 +02:00
|
|
|
XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NOBLANKS );
|
2005-08-12 12:35:17 +02:00
|
|
|
#else
|
|
|
|
return xmlParseMemory( ptr, len );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
static xmlDocPtr doread( LPWSTR filename )
|
|
|
|
{
|
2005-08-08 20:34:24 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
2006-02-21 12:50:59 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IBindCtx *pbc;
|
|
|
|
IStream *stream, *memstream;
|
|
|
|
WCHAR url[INTERNET_MAX_URL_LENGTH];
|
|
|
|
BYTE buf[4096];
|
|
|
|
DWORD read, written;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w( filename ));
|
|
|
|
|
2006-02-21 12:50:59 +01:00
|
|
|
if(!PathIsURLW(filename))
|
|
|
|
{
|
|
|
|
WCHAR fullpath[MAX_PATH];
|
|
|
|
DWORD needed = sizeof(url)/sizeof(WCHAR);
|
2005-08-08 20:34:24 +02:00
|
|
|
|
2006-02-21 12:50:59 +01:00
|
|
|
if(!PathSearchAndQualifyW(filename, fullpath, sizeof(fullpath)/sizeof(WCHAR)))
|
|
|
|
{
|
|
|
|
WARN("can't find path\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(UrlCreateFromPathW(fullpath, url, &needed, 0)))
|
|
|
|
{
|
|
|
|
ERR("can't create url from path\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
filename = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CreateBindCtx(0, &pbc);
|
|
|
|
if(SUCCEEDED(hr))
|
2005-08-08 20:34:24 +02:00
|
|
|
{
|
2006-02-21 12:50:59 +01:00
|
|
|
hr = RegisterBindStatusCallback(pbc, (IBindStatusCallback*)&domdoc_bsc.lpVtbl, NULL, 0);
|
|
|
|
if(SUCCEEDED(hr))
|
2005-08-08 20:34:24 +02:00
|
|
|
{
|
2006-02-21 12:50:59 +01:00
|
|
|
IMoniker *moniker;
|
|
|
|
hr = CreateURLMoniker(NULL, filename, &moniker);
|
|
|
|
if(SUCCEEDED(hr))
|
2005-08-08 20:34:24 +02:00
|
|
|
{
|
2006-02-21 12:50:59 +01:00
|
|
|
hr = IMoniker_BindToStorage(moniker, pbc, NULL, &IID_IStream, (LPVOID*)&stream);
|
|
|
|
IMoniker_Release(moniker);
|
2005-08-08 20:34:24 +02:00
|
|
|
}
|
|
|
|
}
|
2006-02-21 12:50:59 +01:00
|
|
|
IBindCtx_Release(pbc);
|
|
|
|
}
|
|
|
|
if(FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &memstream);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
IStream_Release(stream);
|
|
|
|
return NULL;
|
2005-08-08 20:34:24 +02:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-02-21 12:50:59 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
IStream_Read(stream, buf, sizeof(buf), &read);
|
|
|
|
hr = IStream_Write(memstream, buf, read, &written);
|
|
|
|
} while(SUCCEEDED(hr) && written != 0 && read != 0);
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
hr = GetHGlobalFromStream(memstream, &hglobal);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
DWORD len = GlobalSize(hglobal);
|
|
|
|
char *ptr = GlobalLock(hglobal);
|
|
|
|
if(len != 0)
|
|
|
|
xmldoc = doparse( ptr, len );
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IStream_Release(memstream);
|
|
|
|
IStream_Release(stream);
|
2005-08-08 20:34:24 +02:00
|
|
|
return xmldoc;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_load(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT xmlSource,
|
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
LPWSTR filename = NULL;
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
|
|
|
HRESULT hr = S_FALSE;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
TRACE("type %d\n", V_VT(&xmlSource) );
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
*isSuccessful = VARIANT_FALSE;
|
|
|
|
|
|
|
|
assert( This->node );
|
|
|
|
|
|
|
|
attach_xmlnode(This->node, NULL);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
switch( V_VT(&xmlSource) )
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
|
|
|
filename = V_BSTR(&xmlSource);
|
|
|
|
}
|
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( filename )
|
2006-02-21 12:52:25 +01:00
|
|
|
{
|
2006-06-27 11:54:40 +02:00
|
|
|
xmldoc = doread( filename );
|
|
|
|
|
|
|
|
if ( !xmldoc )
|
|
|
|
This->error = E_FAIL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
}
|
2006-02-21 12:52:25 +01:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if(!xmldoc)
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
xmldoc->_private = 0;
|
|
|
|
attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_readyState(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
long* value )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parseError(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMParseError** errorObj )
|
|
|
|
{
|
2006-02-21 12:52:25 +01:00
|
|
|
BSTR error_string = NULL;
|
|
|
|
static const WCHAR err[] = {'e','r','r','o','r',0};
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-02-21 12:52:25 +01:00
|
|
|
|
2005-11-08 14:10:49 +01:00
|
|
|
FIXME("(%p)->(%p): creating a dummy parseError\n", iface, errorObj);
|
2006-02-21 12:52:25 +01:00
|
|
|
|
|
|
|
if(This->error)
|
|
|
|
error_string = SysAllocString(err);
|
|
|
|
|
|
|
|
*errorObj = create_parseError(This->error, NULL, error_string, NULL, 0, 0, 0);
|
2005-11-08 14:10:49 +01:00
|
|
|
if(!*errorObj) return E_OUTOFMEMORY;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_url(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* urlString )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_async(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isAsync )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
TRACE("%p <- %d\n", isAsync, This->async);
|
|
|
|
*isAsync = This->async;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_async(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isAsync )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
TRACE("%d\n", isAsync);
|
|
|
|
This->async = isAsync;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_abort(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-02 13:28:36 +02:00
|
|
|
static BOOL bstr_to_utf8( BSTR bstr, char **pstr, int *plen )
|
2005-08-11 12:32:36 +02:00
|
|
|
{
|
|
|
|
UINT len, blen = SysStringLen( bstr );
|
|
|
|
LPSTR str;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_UTF8, 0, bstr, blen, NULL, 0, NULL, NULL );
|
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
if ( !str )
|
|
|
|
return FALSE;
|
|
|
|
WideCharToMultiByte( CP_UTF8, 0, bstr, blen, str, len, NULL, NULL );
|
|
|
|
*plen = len;
|
|
|
|
*pstr = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
static HRESULT WINAPI domdoc_loadXML(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR bstrXML,
|
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
2005-08-11 12:32:36 +02:00
|
|
|
char *str;
|
|
|
|
int len;
|
2006-06-27 11:54:40 +02:00
|
|
|
HRESULT hr = S_FALSE;
|
2005-08-11 12:32:36 +02:00
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_w( bstrXML ), isSuccessful );
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
assert ( This->node );
|
|
|
|
|
|
|
|
attach_xmlnode( This->node, NULL );
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( isSuccessful )
|
2006-02-21 12:52:25 +01:00
|
|
|
{
|
2006-06-27 11:54:40 +02:00
|
|
|
*isSuccessful = VARIANT_FALSE;
|
|
|
|
|
|
|
|
if ( bstrXML && bstr_to_utf8( bstrXML, &str, &len ) )
|
|
|
|
{
|
|
|
|
xmldoc = doparse( str, len );
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
if ( !xmldoc )
|
|
|
|
This->error = E_FAIL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2006-02-21 12:52:25 +01:00
|
|
|
}
|
2006-06-27 11:54:40 +02:00
|
|
|
if(!xmldoc)
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
xmldoc->_private = 0;
|
|
|
|
attach_xmlnode( This->node, (xmlNodePtr) xmldoc );
|
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_save(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT destination )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-01-24 14:43:18 +01:00
|
|
|
HANDLE handle;
|
|
|
|
xmlChar *mem;
|
|
|
|
int size;
|
|
|
|
HRESULT ret = S_OK;
|
|
|
|
DWORD written;
|
|
|
|
|
|
|
|
TRACE("(%p)->(var(vt %x, %s))\n", This, V_VT(&destination),
|
|
|
|
V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL);
|
|
|
|
|
|
|
|
if(V_VT(&destination) != VT_BSTR)
|
|
|
|
{
|
|
|
|
FIXME("Unhandled vt %x\n", V_VT(&destination));
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = CreateFileW( V_BSTR(&destination), GENERIC_WRITE, 0,
|
|
|
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
|
if( handle == INVALID_HANDLE_VALUE )
|
|
|
|
{
|
|
|
|
WARN("failed to create file\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlDocDumpMemory(get_doc(This), &mem, &size);
|
|
|
|
if(!WriteFile(handle, mem, (DWORD)size, &written, NULL) || written != (DWORD)size)
|
|
|
|
{
|
|
|
|
WARN("write error\n");
|
|
|
|
ret = S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlFree(mem);
|
|
|
|
CloseHandle(handle);
|
|
|
|
return ret;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_validateOnParse(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isValidating )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%p <- %d\n", isValidating, This->validating);
|
|
|
|
*isValidating = This->validating;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_validateOnParse(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isValidating )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%d\n", isValidating);
|
|
|
|
This->validating = isValidating;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_resolveExternals(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isResolving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%p <- %d\n", isResolving, This->resolving);
|
|
|
|
*isResolving = This->resolving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_resolveExternals(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2007-02-18 19:37:18 +01:00
|
|
|
VARIANT_BOOL isResolving )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%d\n", isResolving);
|
|
|
|
This->resolving = isResolving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_preserveWhiteSpace(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isPreserving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%p <- %d\n", isPreserving, This->preserving);
|
|
|
|
*isPreserving = This->preserving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_preserveWhiteSpace(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isPreserving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
|
|
|
TRACE("%d\n", isPreserving);
|
|
|
|
This->preserving = isPreserving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onReadyStateChange(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT readyStateChangeSink )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onDataAvailable(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT onDataAvailableSink )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onTransformNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT onTransformNodeSink )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_get_namespaces(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMSchemaCollection** schemaCollection )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_schemas(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
VARIANT* var1 )
|
|
|
|
{
|
2007-02-27 16:11:13 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
IXMLDOMSchemaCollection *cur_schema = This->schema;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, var1);
|
|
|
|
|
|
|
|
VariantInit(var1); /* Test shows we don't call VariantClear here */
|
|
|
|
V_VT(var1) = VT_NULL;
|
|
|
|
|
|
|
|
if(cur_schema)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMSchemaCollection_QueryInterface(cur_schema, &IID_IDispatch, (void**)&V_DISPATCH(var1));
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
V_VT(var1) = VT_DISPATCH;
|
|
|
|
}
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_putref_schemas(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
VARIANT var1)
|
|
|
|
{
|
2007-02-27 16:11:13 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
IXMLDOMSchemaCollection *new_schema = NULL;
|
|
|
|
|
|
|
|
FIXME("(%p): semi-stub\n", This);
|
|
|
|
switch(V_VT(&var1))
|
|
|
|
{
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&var1), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_DISPATCH:
|
|
|
|
hr = IDispatch_QueryInterface(V_DISPATCH(&var1), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_NULL:
|
|
|
|
case VT_EMPTY:
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Can't get schema from vt %x\n", V_VT(&var1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IXMLDOMSchemaCollection *old_schema = InterlockedExchangePointer((void**)&This->schema, new_schema);
|
|
|
|
if(old_schema) IXMLDOMSchemaCollection_Release(old_schema);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_validate(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMParseError** err)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_setProperty(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
|
|
|
VARIANT var)
|
|
|
|
{
|
2007-05-09 20:09:11 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
|
|
|
|
if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0)
|
|
|
|
{
|
|
|
|
VARIANT varStr;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
V_VT(&varStr) = VT_EMPTY;
|
|
|
|
if (V_VT(&var) != VT_BSTR)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = VariantChangeType(&varStr, &var, 0, VT_BSTR)))
|
|
|
|
return hr;
|
|
|
|
bstr = V_BSTR(&varStr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bstr = V_BSTR(&var);
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
if (lstrcmpiW(bstr, SZ_VALUE_XPATH) == 0)
|
|
|
|
This->bUseXPath = TRUE;
|
|
|
|
else if (lstrcmpiW(bstr, SZ_VALUE_XSLPATTERN) == 0)
|
|
|
|
This->bUseXPath = FALSE;
|
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
|
|
|
|
VariantClear(&varStr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unknown property %s\n", wine_dbgstr_w(p));
|
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getProperty(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
|
|
|
VARIANT* var)
|
|
|
|
{
|
2007-05-09 20:09:11 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
|
|
|
|
if (var == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0)
|
|
|
|
{
|
|
|
|
V_VT(var) = VT_BSTR;
|
|
|
|
if (This->bUseXPath)
|
|
|
|
V_BSTR(var) = SysAllocString(SZ_VALUE_XPATH);
|
|
|
|
else
|
|
|
|
V_BSTR(var) = SysAllocString(SZ_VALUE_XSLPATTERN);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unknown property %s\n", wine_dbgstr_w(p));
|
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMDocument2Vtbl domdoc_vtbl =
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
domdoc_QueryInterface,
|
|
|
|
domdoc_AddRef,
|
|
|
|
domdoc_Release,
|
|
|
|
domdoc_GetTypeInfoCount,
|
|
|
|
domdoc_GetTypeInfo,
|
|
|
|
domdoc_GetIDsOfNames,
|
|
|
|
domdoc_Invoke,
|
|
|
|
domdoc_get_nodeName,
|
|
|
|
domdoc_get_nodeValue,
|
|
|
|
domdoc_put_nodeValue,
|
|
|
|
domdoc_get_nodeType,
|
|
|
|
domdoc_get_parentNode,
|
|
|
|
domdoc_get_childNodes,
|
|
|
|
domdoc_get_firstChild,
|
|
|
|
domdoc_get_lastChild,
|
|
|
|
domdoc_get_previousSibling,
|
|
|
|
domdoc_get_nextSibling,
|
|
|
|
domdoc_get_attributes,
|
|
|
|
domdoc_insertBefore,
|
|
|
|
domdoc_replaceChild,
|
|
|
|
domdoc_removeChild,
|
|
|
|
domdoc_appendChild,
|
|
|
|
domdoc_hasChildNodes,
|
|
|
|
domdoc_get_ownerDocument,
|
|
|
|
domdoc_cloneNode,
|
|
|
|
domdoc_get_nodeTypeString,
|
|
|
|
domdoc_get_text,
|
|
|
|
domdoc_put_text,
|
|
|
|
domdoc_get_specified,
|
|
|
|
domdoc_get_definition,
|
|
|
|
domdoc_get_nodeTypedValue,
|
|
|
|
domdoc_put_nodeTypedValue,
|
|
|
|
domdoc_get_dataType,
|
|
|
|
domdoc_put_dataType,
|
|
|
|
domdoc_get_xml,
|
|
|
|
domdoc_transformNode,
|
|
|
|
domdoc_selectNodes,
|
|
|
|
domdoc_selectSingleNode,
|
|
|
|
domdoc_get_parsed,
|
|
|
|
domdoc_get_namespaceURI,
|
|
|
|
domdoc_get_prefix,
|
|
|
|
domdoc_get_baseName,
|
|
|
|
domdoc_transformNodeToObject,
|
|
|
|
domdoc_get_doctype,
|
|
|
|
domdoc_get_implementation,
|
|
|
|
domdoc_get_documentElement,
|
|
|
|
domdoc_documentElement,
|
|
|
|
domdoc_createElement,
|
|
|
|
domdoc_createDocumentFragment,
|
|
|
|
domdoc_createTextNode,
|
|
|
|
domdoc_createComment,
|
|
|
|
domdoc_createCDATASection,
|
|
|
|
domdoc_createProcessingInstruction,
|
|
|
|
domdoc_createAttribute,
|
|
|
|
domdoc_createEntityReference,
|
|
|
|
domdoc_getElementsByTagName,
|
|
|
|
domdoc_createNode,
|
|
|
|
domdoc_nodeFromID,
|
|
|
|
domdoc_load,
|
|
|
|
domdoc_get_readyState,
|
|
|
|
domdoc_get_parseError,
|
|
|
|
domdoc_get_url,
|
|
|
|
domdoc_get_async,
|
|
|
|
domdoc_put_async,
|
|
|
|
domdoc_abort,
|
|
|
|
domdoc_loadXML,
|
|
|
|
domdoc_save,
|
|
|
|
domdoc_get_validateOnParse,
|
|
|
|
domdoc_put_validateOnParse,
|
|
|
|
domdoc_get_resolveExternals,
|
|
|
|
domdoc_put_resolveExternals,
|
|
|
|
domdoc_get_preserveWhiteSpace,
|
|
|
|
domdoc_put_preserveWhiteSpace,
|
|
|
|
domdoc_put_onReadyStateChange,
|
|
|
|
domdoc_put_onDataAvailable,
|
|
|
|
domdoc_put_onTransformNode,
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc_get_namespaces,
|
|
|
|
domdoc_get_schemas,
|
|
|
|
domdoc_putref_schemas,
|
|
|
|
domdoc_validate,
|
|
|
|
domdoc_setProperty,
|
|
|
|
domdoc_getProperty
|
2005-08-02 13:29:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
domdoc *doc;
|
2005-12-01 18:46:42 +01:00
|
|
|
HRESULT hr;
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlDocPtr xmldoc;
|
2005-12-01 18:46:42 +01:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
doc = HeapAlloc( GetProcessHeap(), 0, sizeof (*doc) );
|
|
|
|
if( !doc )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
doc->lpVtbl = &domdoc_vtbl;
|
|
|
|
doc->ref = 1;
|
|
|
|
doc->async = 0;
|
2007-02-18 19:37:18 +01:00
|
|
|
doc->validating = 0;
|
|
|
|
doc->resolving = 0;
|
|
|
|
doc->preserving = 0;
|
2007-05-09 20:09:11 +02:00
|
|
|
doc->bUseXPath = FALSE;
|
2006-02-21 12:52:25 +01:00
|
|
|
doc->error = S_OK;
|
2007-02-27 16:11:13 +01:00
|
|
|
doc->schema = NULL;
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
xmldoc = xmlNewDoc(NULL);
|
|
|
|
if(!xmldoc)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, doc);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmldoc->_private = 0;
|
|
|
|
|
|
|
|
doc->node_unk = create_basic_node( (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl );
|
2005-12-01 18:46:42 +01:00
|
|
|
if(!doc->node_unk)
|
|
|
|
{
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlFreeDoc(xmldoc);
|
2005-12-01 18:46:42 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, doc);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(doc->node_unk, &IID_IXMLDOMNode, (LPVOID*)&doc->node);
|
|
|
|
if(FAILED(hr))
|
|
|
|
{
|
|
|
|
IUnknown_Release(doc->node_unk);
|
|
|
|
HeapFree( GetProcessHeap(), 0, doc );
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
/* The ref on doc->node is actually looped back into this object, so release it */
|
|
|
|
IXMLDOMNode_Release(doc->node);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
*ppObj = &doc->lpVtbl;
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
TRACE("returning iface %p\n", *ppObj);
|
2005-08-02 13:29:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
MESSAGE("This program tried to use a DOMDocument object, but\n"
|
|
|
|
"libxml2 support was not present at compile time.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|