2005-08-10 11:54:22 +02:00
|
|
|
/*
|
|
|
|
* Node 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-10 11:54:22 +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-10 11:54:22 +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-10 11:54:22 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2011-02-24 13:11:53 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/xmlerror.h>
|
|
|
|
# include <libxml/HTMLtree.h>
|
|
|
|
# ifdef SONAME_LIBXSLT
|
|
|
|
# ifdef HAVE_LIBXSLT_PATTERN_H
|
|
|
|
# include <libxslt/pattern.h>
|
|
|
|
# endif
|
|
|
|
# ifdef HAVE_LIBXSLT_TRANSFORM_H
|
|
|
|
# include <libxslt/transform.h>
|
|
|
|
# endif
|
|
|
|
# include <libxslt/xsltutils.h>
|
|
|
|
# include <libxslt/xsltInternals.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
2010-08-29 23:31:49 +02:00
|
|
|
#include "msxml6.h"
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2011-02-24 13:11:53 +01:00
|
|
|
#ifdef SONAME_LIBXSLT
|
|
|
|
extern void* libxslt_handle;
|
|
|
|
# define MAKE_FUNCPTR(f) extern typeof(f) * p##f
|
|
|
|
MAKE_FUNCPTR(xsltApplyStylesheet);
|
|
|
|
MAKE_FUNCPTR(xsltCleanupGlobals);
|
|
|
|
MAKE_FUNCPTR(xsltFreeStylesheet);
|
|
|
|
MAKE_FUNCPTR(xsltParseStylesheetDoc);
|
|
|
|
# undef MAKE_FUNCPTR
|
|
|
|
#endif
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
static const IID IID_xmlnode = {0x4f2f4ba2,0xb822,0x11df,{0x8b,0x8a,0x68,0x50,0xdf,0xd7,0x20,0x85}};
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
xmlNodePtr xmlNodePtr_from_domnode( IXMLDOMNode *iface, xmlElementType type )
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
|
|
|
xmlnode *This;
|
|
|
|
|
|
|
|
if ( !iface )
|
|
|
|
return NULL;
|
2010-09-04 17:55:04 +02:00
|
|
|
This = get_node_obj( iface );
|
|
|
|
if ( !This || !This->node )
|
2005-08-10 11:54:22 +02:00
|
|
|
return NULL;
|
2005-08-18 12:48:13 +02:00
|
|
|
if ( type && This->node->type != type )
|
2005-08-10 11:54:22 +02:00
|
|
|
return NULL;
|
2005-08-18 12:48:13 +02:00
|
|
|
return This->node;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:54:46 +02:00
|
|
|
BOOL node_query_interface(xmlnode *This, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
if(IsEqualGUID(&IID_xmlnode, riid)) {
|
|
|
|
TRACE("(%p)->(IID_xmlnode %p)\n", This, ppv);
|
|
|
|
*ppv = This;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-10-31 20:09:12 +01:00
|
|
|
return dispex_query_interface(&This->dispex, riid, ppv);
|
2010-09-04 17:54:46 +02:00
|
|
|
}
|
|
|
|
|
2011-11-19 14:33:10 +01:00
|
|
|
/* common ISupportErrorInfo implementation */
|
|
|
|
typedef struct {
|
|
|
|
ISupportErrorInfo ISupportErrorInfo_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
const tid_t* iids;
|
|
|
|
} SupportErrorInfo;
|
|
|
|
|
|
|
|
static inline SupportErrorInfo *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, SupportErrorInfo, ISupportErrorInfo_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SupportErrorInfo_QueryInterface(ISupportErrorInfo *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ISupportErrorInfo)) {
|
|
|
|
*obj = iface;
|
|
|
|
ISupportErrorInfo_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI SupportErrorInfo_AddRef(ISupportErrorInfo *iface)
|
|
|
|
{
|
|
|
|
SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref );
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI SupportErrorInfo_Release(ISupportErrorInfo *iface)
|
|
|
|
{
|
|
|
|
SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
if (ref == 0)
|
|
|
|
heap_free(This);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SupportErrorInfo_InterfaceSupportsErrorInfo(ISupportErrorInfo *iface, REFIID riid)
|
|
|
|
{
|
|
|
|
SupportErrorInfo *This = impl_from_ISupportErrorInfo(iface);
|
|
|
|
enum tid_t const *tid;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
|
|
|
|
|
|
|
|
tid = This->iids;
|
2013-05-07 13:07:28 +02:00
|
|
|
while (*tid != NULL_tid)
|
2011-11-19 14:33:10 +01:00
|
|
|
{
|
|
|
|
if (IsEqualGUID(riid, get_riid_from_tid(*tid)))
|
|
|
|
return S_OK;
|
|
|
|
tid++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISupportErrorInfoVtbl SupportErrorInfoVtbl = {
|
|
|
|
SupportErrorInfo_QueryInterface,
|
|
|
|
SupportErrorInfo_AddRef,
|
|
|
|
SupportErrorInfo_Release,
|
|
|
|
SupportErrorInfo_InterfaceSupportsErrorInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT node_create_supporterrorinfo(enum tid_t const *iids, void **obj)
|
|
|
|
{
|
|
|
|
SupportErrorInfo *This;
|
|
|
|
|
|
|
|
This = heap_alloc(sizeof(*This));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->ISupportErrorInfo_iface.lpVtbl = &SupportErrorInfoVtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->iids = iids;
|
|
|
|
|
|
|
|
*obj = &This->ISupportErrorInfo_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlnode *get_node_obj(IXMLDOMNode *node)
|
|
|
|
{
|
2011-03-03 23:03:15 +01:00
|
|
|
xmlnode *obj = NULL;
|
2010-09-04 17:55:04 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IXMLDOMNode_QueryInterface(node, &IID_xmlnode, (void**)&obj);
|
2011-03-03 23:03:15 +01:00
|
|
|
if (!obj) WARN("node is not our IXMLDOMNode implementation\n");
|
2010-09-04 17:55:04 +02:00
|
|
|
return SUCCEEDED(hres) ? obj : NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:56:25 +02:00
|
|
|
HRESULT node_get_nodeName(xmlnode *This, BSTR *name)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2011-11-15 22:31:40 +01:00
|
|
|
BSTR prefix, base;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2005-11-02 20:55:30 +01:00
|
|
|
if (!name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2011-11-15 22:31:40 +01:00
|
|
|
hr = node_get_base_name(This, &base);
|
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = node_get_prefix(This, &prefix);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
static const WCHAR colW = ':';
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
/* +1 for ':' */
|
|
|
|
ptr = *name = SysAllocStringLen(NULL, SysStringLen(base) + SysStringLen(prefix) + 1);
|
|
|
|
memcpy(ptr, prefix, SysStringByteLen(prefix));
|
|
|
|
ptr += SysStringLen(prefix);
|
|
|
|
memcpy(ptr++, &colW, sizeof(WCHAR));
|
|
|
|
memcpy(ptr, base, SysStringByteLen(base));
|
|
|
|
|
|
|
|
SysFreeString(base);
|
|
|
|
SysFreeString(prefix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*name = base;
|
2005-11-02 11:55:03 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:56:45 +02:00
|
|
|
HRESULT node_get_content(xmlnode *This, VARIANT *value)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-04 17:56:45 +02:00
|
|
|
xmlChar *content;
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2008-01-03 06:02:36 +01:00
|
|
|
if(!value)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-09-04 17:56:45 +02:00
|
|
|
content = xmlNodeGetContent(This->node);
|
|
|
|
V_VT(value) = VT_BSTR;
|
|
|
|
V_BSTR(value) = bstr_from_xmlChar( content );
|
|
|
|
xmlFree(content);
|
2008-02-20 12:34:01 +01:00
|
|
|
|
2010-09-04 17:56:45 +02:00
|
|
|
TRACE("%p returned %s\n", This, debugstr_w(V_BSTR(value)));
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2010-10-26 00:06:52 +02:00
|
|
|
HRESULT node_set_content(xmlnode *This, LPCWSTR value)
|
|
|
|
{
|
|
|
|
xmlChar *str;
|
|
|
|
|
2010-11-07 22:50:38 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(value));
|
2011-03-10 20:15:09 +01:00
|
|
|
str = xmlchar_from_wchar(value);
|
2010-10-26 00:06:52 +02:00
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
xmlNodeSetContent(This->node, str);
|
|
|
|
heap_free(str);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-04 16:35:58 +01:00
|
|
|
static HRESULT node_set_content_escaped(xmlnode *This, LPCWSTR value)
|
|
|
|
{
|
|
|
|
xmlChar *str, *escaped;
|
|
|
|
|
2010-11-07 22:50:38 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(value));
|
2011-03-10 20:15:09 +01:00
|
|
|
str = xmlchar_from_wchar(value);
|
2010-11-04 16:35:58 +01:00
|
|
|
if(!str)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
escaped = xmlEncodeSpecialChars(NULL, str);
|
|
|
|
if(!escaped)
|
|
|
|
{
|
|
|
|
heap_free(str);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlNodeSetContent(This->node, escaped);
|
|
|
|
|
|
|
|
heap_free(str);
|
|
|
|
xmlFree(escaped);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
HRESULT node_put_value(xmlnode *This, VARIANT *value)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2008-10-11 23:58:11 +02:00
|
|
|
HRESULT hr;
|
2008-02-25 09:56:22 +01:00
|
|
|
|
2013-03-01 06:02:49 +01:00
|
|
|
if (V_VT(value) != VT_BSTR)
|
|
|
|
{
|
|
|
|
VARIANT string_value;
|
|
|
|
|
|
|
|
VariantInit(&string_value);
|
|
|
|
hr = VariantChangeType(&string_value, value, 0, VT_BSTR);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
WARN("Couldn't convert to VT_BSTR\n");
|
|
|
|
return hr;
|
|
|
|
}
|
2010-02-13 00:25:08 +01:00
|
|
|
|
2013-03-01 06:02:49 +01:00
|
|
|
hr = node_set_content(This, V_BSTR(&string_value));
|
|
|
|
VariantClear(&string_value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = node_set_content(This, V_BSTR(value));
|
2010-02-13 00:25:08 +01:00
|
|
|
|
2010-11-04 17:16:12 +01:00
|
|
|
return hr;
|
2010-09-07 15:27:31 +02:00
|
|
|
}
|
2008-02-25 09:56:22 +01:00
|
|
|
|
2010-11-04 16:35:58 +01:00
|
|
|
HRESULT node_put_value_escaped(xmlnode *This, VARIANT *value)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2013-03-01 06:02:49 +01:00
|
|
|
if (V_VT(value) != VT_BSTR)
|
|
|
|
{
|
|
|
|
VARIANT string_value;
|
|
|
|
|
|
|
|
VariantInit(&string_value);
|
|
|
|
hr = VariantChangeType(&string_value, value, 0, VT_BSTR);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
WARN("Couldn't convert to VT_BSTR\n");
|
|
|
|
return hr;
|
|
|
|
}
|
2010-11-04 16:35:58 +01:00
|
|
|
|
2013-03-01 06:02:49 +01:00
|
|
|
hr = node_set_content_escaped(This, V_BSTR(&string_value));
|
|
|
|
VariantClear(&string_value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = node_set_content_escaped(This, V_BSTR(value));
|
2010-11-04 16:35:58 +01:00
|
|
|
|
2010-11-04 17:16:12 +01:00
|
|
|
return hr;
|
2010-11-04 16:35:58 +01:00
|
|
|
}
|
|
|
|
|
2005-08-19 13:22:47 +02:00
|
|
|
static HRESULT get_node(
|
|
|
|
xmlnode *This,
|
|
|
|
const char *name,
|
|
|
|
xmlNodePtr node,
|
|
|
|
IXMLDOMNode **out )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, name, node, out );
|
2005-08-19 13:22:47 +02:00
|
|
|
|
|
|
|
if ( !out )
|
|
|
|
return E_INVALIDARG;
|
2009-02-05 10:43:59 +01:00
|
|
|
|
2009-04-20 14:47:23 +02:00
|
|
|
/* if we don't have a doc, use our parent. */
|
2009-02-05 10:43:59 +01:00
|
|
|
if(node && !node->doc && node->parent)
|
|
|
|
node->doc = node->parent->doc;
|
|
|
|
|
2005-08-19 13:22:47 +02:00
|
|
|
*out = create_node( node );
|
|
|
|
if (!*out)
|
|
|
|
return S_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:28:21 +02:00
|
|
|
HRESULT node_get_parent(xmlnode *This, IXMLDOMNode **parent)
|
|
|
|
{
|
|
|
|
return get_node( This, "parent", This->node->parent, parent );
|
|
|
|
}
|
|
|
|
|
2010-09-08 15:12:02 +02:00
|
|
|
HRESULT node_get_child_nodes(xmlnode *This, IXMLDOMNodeList **ret)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-08 15:12:02 +02:00
|
|
|
if(!ret)
|
2005-08-18 12:48:13 +02:00
|
|
|
return E_INVALIDARG;
|
2005-11-05 11:42:45 +01:00
|
|
|
|
2010-09-08 15:12:02 +02:00
|
|
|
*ret = create_children_nodelist(This->node);
|
|
|
|
if(!*ret)
|
2007-05-11 17:03:13 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2005-11-05 11:42:45 +01:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-08 15:12:14 +02:00
|
|
|
HRESULT node_get_first_child(xmlnode *This, IXMLDOMNode **ret)
|
|
|
|
{
|
|
|
|
return get_node(This, "firstChild", This->node->children, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT node_get_last_child(xmlnode *This, IXMLDOMNode **ret)
|
|
|
|
{
|
|
|
|
return get_node(This, "lastChild", This->node->last, ret);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-10 16:53:48 +02:00
|
|
|
HRESULT node_get_previous_sibling(xmlnode *This, IXMLDOMNode **ret)
|
|
|
|
{
|
|
|
|
return get_node(This, "previous", This->node->prev, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT node_get_next_sibling(xmlnode *This, IXMLDOMNode **ret)
|
|
|
|
{
|
|
|
|
return get_node(This, "next", This->node->next, ret);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
static int node_get_inst_cnt(xmlNodePtr node)
|
|
|
|
{
|
|
|
|
int ret = *(LONG *)&node->_private;
|
|
|
|
xmlNodePtr child;
|
|
|
|
|
|
|
|
/* add attribute counts */
|
|
|
|
if (node->type == XML_ELEMENT_NODE)
|
|
|
|
{
|
|
|
|
xmlAttrPtr prop = node->properties;
|
|
|
|
|
|
|
|
while (prop)
|
|
|
|
{
|
|
|
|
ret += node_get_inst_cnt((xmlNodePtr)prop);
|
|
|
|
prop = prop->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add children counts */
|
|
|
|
child = node->children;
|
|
|
|
while (child)
|
|
|
|
{
|
|
|
|
ret += node_get_inst_cnt(child);
|
|
|
|
child = child->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-02-26 07:46:33 +01:00
|
|
|
int xmlnode_get_inst_cnt(xmlnode *node)
|
2013-02-24 21:30:22 +01:00
|
|
|
{
|
|
|
|
return node_get_inst_cnt(node->node);
|
|
|
|
}
|
|
|
|
|
2010-09-10 16:55:14 +02:00
|
|
|
HRESULT node_insert_before(xmlnode *This, IXMLDOMNode *new_child, const VARIANT *ref_child,
|
|
|
|
IXMLDOMNode **ret)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
IXMLDOMNode *before = NULL;
|
|
|
|
xmlnode *node_obj;
|
2013-02-24 21:30:22 +01:00
|
|
|
int refcount = 0;
|
2011-03-06 20:28:29 +01:00
|
|
|
xmlDocPtr doc;
|
2006-01-11 21:15:12 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2010-09-10 16:55:14 +02:00
|
|
|
if(!new_child)
|
2006-11-02 10:42:05 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-09-10 16:55:14 +02:00
|
|
|
node_obj = get_node_obj(new_child);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!node_obj) return E_FAIL;
|
2010-09-10 16:55:14 +02:00
|
|
|
|
|
|
|
switch(V_VT(ref_child))
|
2006-01-11 21:15:12 +01:00
|
|
|
{
|
|
|
|
case VT_EMPTY:
|
|
|
|
case VT_NULL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
case VT_DISPATCH:
|
2011-10-22 19:22:05 +02:00
|
|
|
if (V_UNKNOWN(ref_child))
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(ref_child), &IID_IXMLDOMNode, (void**)&before);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
}
|
2006-01-11 21:15:12 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-09-10 16:55:14 +02:00
|
|
|
FIXME("refChild var type %x\n", V_VT(ref_child));
|
2010-09-04 17:55:04 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2011-03-08 15:45:20 +01:00
|
|
|
TRACE("new child %p, This->node %p\n", node_obj->node, This->node);
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2011-03-08 15:45:20 +01:00
|
|
|
if(!node_obj->node->parent)
|
|
|
|
if(xmldoc_remove_orphan(node_obj->node->doc, node_obj->node) != S_OK)
|
|
|
|
WARN("%p is not an orphan of %p\n", node_obj->node, node_obj->node->doc);
|
2008-10-11 23:59:25 +02:00
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
refcount = xmlnode_get_inst_cnt(node_obj);
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
if(before)
|
|
|
|
{
|
2011-03-03 23:03:15 +01:00
|
|
|
xmlnode *before_node_obj = get_node_obj(before);
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release(before);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!before_node_obj) return E_FAIL;
|
2010-09-04 17:55:04 +02:00
|
|
|
|
2011-03-03 23:03:15 +01:00
|
|
|
/* unlink from current parent first */
|
|
|
|
if(node_obj->parent)
|
2011-03-08 15:45:20 +01:00
|
|
|
{
|
|
|
|
hr = IXMLDOMNode_removeChild(node_obj->parent, node_obj->iface, NULL);
|
|
|
|
if (hr == S_OK) xmldoc_remove_orphan(node_obj->node->doc, node_obj->node);
|
|
|
|
}
|
2013-02-24 21:30:22 +01:00
|
|
|
|
2011-03-08 15:45:20 +01:00
|
|
|
doc = node_obj->node->doc;
|
2013-02-24 21:30:22 +01:00
|
|
|
|
|
|
|
/* refs count including subtree */
|
|
|
|
if (doc != before_node_obj->node->doc)
|
|
|
|
refcount = xmlnode_get_inst_cnt(node_obj);
|
|
|
|
|
|
|
|
if (refcount) xmldoc_add_refs(before_node_obj->node->doc, refcount);
|
2011-03-08 15:45:20 +01:00
|
|
|
xmlAddPrevSibling(before_node_obj->node, node_obj->node);
|
2013-02-24 21:30:22 +01:00
|
|
|
if (refcount) xmldoc_release_refs(doc, refcount);
|
2011-03-03 23:03:15 +01:00
|
|
|
node_obj->parent = This->parent;
|
2006-01-11 21:15:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-03 23:03:15 +01:00
|
|
|
/* unlink from current parent first */
|
|
|
|
if(node_obj->parent)
|
2011-03-08 15:45:20 +01:00
|
|
|
{
|
|
|
|
hr = IXMLDOMNode_removeChild(node_obj->parent, node_obj->iface, NULL);
|
|
|
|
if (hr == S_OK) xmldoc_remove_orphan(node_obj->node->doc, node_obj->node);
|
|
|
|
}
|
|
|
|
doc = node_obj->node->doc;
|
2013-02-24 21:30:22 +01:00
|
|
|
|
|
|
|
if (doc != This->node->doc)
|
|
|
|
refcount = xmlnode_get_inst_cnt(node_obj);
|
|
|
|
|
|
|
|
if (refcount) xmldoc_add_refs(This->node->doc, refcount);
|
2011-03-12 23:57:36 +01:00
|
|
|
/* xmlAddChild doesn't unlink node from previous parent */
|
|
|
|
xmlUnlinkNode(node_obj->node);
|
2011-03-08 15:45:20 +01:00
|
|
|
xmlAddChild(This->node, node_obj->node);
|
2013-02-24 21:30:22 +01:00
|
|
|
if (refcount) xmldoc_release_refs(doc, refcount);
|
2011-03-03 23:03:15 +01:00
|
|
|
node_obj->parent = This->iface;
|
2006-01-11 21:15:12 +01:00
|
|
|
}
|
|
|
|
|
2011-03-03 23:03:15 +01:00
|
|
|
if(ret)
|
|
|
|
{
|
2010-09-10 16:55:14 +02:00
|
|
|
IXMLDOMNode_AddRef(new_child);
|
|
|
|
*ret = new_child;
|
|
|
|
}
|
2007-11-14 06:05:17 +01:00
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
TRACE("ret S_OK\n");
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-10-13 15:11:32 +02:00
|
|
|
HRESULT node_replace_child(xmlnode *This, IXMLDOMNode *newChild, IXMLDOMNode *oldChild,
|
|
|
|
IXMLDOMNode **ret)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-04 17:55:42 +02:00
|
|
|
xmlnode *old_child, *new_child;
|
2008-10-07 11:55:01 +02:00
|
|
|
xmlDocPtr leaving_doc;
|
|
|
|
xmlNode *my_ancestor;
|
2013-02-25 12:36:56 +01:00
|
|
|
int refcount = 0;
|
2008-10-05 12:13:37 +02:00
|
|
|
|
|
|
|
/* Do not believe any documentation telling that newChild == NULL
|
|
|
|
means removal. It does certainly *not* apply to msxml3! */
|
|
|
|
if(!newChild || !oldChild)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-10-13 15:11:32 +02:00
|
|
|
if(ret)
|
|
|
|
*ret = NULL;
|
2008-10-07 11:55:01 +02:00
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
old_child = get_node_obj(oldChild);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!old_child) return E_FAIL;
|
2008-10-07 11:55:45 +02:00
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
if(old_child->node->parent != This->node)
|
2008-10-07 11:55:01 +02:00
|
|
|
{
|
2010-10-13 15:11:32 +02:00
|
|
|
WARN("childNode %p is not a child of %p\n", oldChild, This);
|
2008-10-07 11:55:01 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
new_child = get_node_obj(newChild);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!new_child) return E_FAIL;
|
2010-09-04 17:55:42 +02:00
|
|
|
|
2008-10-07 11:55:01 +02:00
|
|
|
my_ancestor = This->node;
|
|
|
|
while(my_ancestor)
|
|
|
|
{
|
2010-09-04 17:55:42 +02:00
|
|
|
if(my_ancestor == new_child->node)
|
2008-10-07 11:55:01 +02:00
|
|
|
{
|
|
|
|
WARN("tried to create loop\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
my_ancestor = my_ancestor->parent;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
if(!new_child->node->parent)
|
|
|
|
if(xmldoc_remove_orphan(new_child->node->doc, new_child->node) != S_OK)
|
|
|
|
WARN("%p is not an orphan of %p\n", new_child->node, new_child->node->doc);
|
2008-10-11 23:59:25 +02:00
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
leaving_doc = new_child->node->doc;
|
2013-02-25 12:36:56 +01:00
|
|
|
|
|
|
|
if (leaving_doc != old_child->node->doc)
|
|
|
|
refcount = xmlnode_get_inst_cnt(new_child);
|
|
|
|
|
|
|
|
if (refcount) xmldoc_add_refs(old_child->node->doc, refcount);
|
2010-09-04 17:55:42 +02:00
|
|
|
xmlReplaceNode(old_child->node, new_child->node);
|
2013-02-25 12:36:56 +01:00
|
|
|
if (refcount) xmldoc_release_refs(leaving_doc, refcount);
|
2011-03-03 23:03:15 +01:00
|
|
|
new_child->parent = old_child->parent;
|
|
|
|
old_child->parent = NULL;
|
2008-10-07 11:55:01 +02:00
|
|
|
|
2010-09-04 17:55:42 +02:00
|
|
|
xmldoc_add_orphan(old_child->node->doc, old_child->node);
|
2008-10-11 23:59:25 +02:00
|
|
|
|
2010-10-13 15:11:32 +02:00
|
|
|
if(ret)
|
2008-10-07 11:55:01 +02:00
|
|
|
{
|
|
|
|
IXMLDOMNode_AddRef(oldChild);
|
2010-10-13 15:11:32 +02:00
|
|
|
*ret = oldChild;
|
2008-10-07 11:55:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:28:44 +01:00
|
|
|
HRESULT node_remove_child(xmlnode *This, IXMLDOMNode* child, IXMLDOMNode** oldChild)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlnode *child_node;
|
2006-07-10 15:48:45 +02:00
|
|
|
|
2011-02-23 12:28:44 +01:00
|
|
|
if(!child) return E_INVALIDARG;
|
2008-10-05 12:12:56 +02:00
|
|
|
|
2008-07-10 15:22:21 +02:00
|
|
|
if(oldChild)
|
|
|
|
*oldChild = NULL;
|
2006-07-18 16:54:16 +02:00
|
|
|
|
2011-02-23 12:28:44 +01:00
|
|
|
child_node = get_node_obj(child);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!child_node) return E_FAIL;
|
2008-10-07 11:56:06 +02:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(child_node->node->parent != This->node)
|
2006-07-10 15:48:45 +02:00
|
|
|
{
|
2011-02-23 12:28:44 +01:00
|
|
|
WARN("childNode %p is not a child of %p\n", child, This);
|
2006-07-10 15:48:45 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlUnlinkNode(child_node->node);
|
2011-03-03 23:03:15 +01:00
|
|
|
child_node->parent = NULL;
|
2011-03-08 15:45:20 +01:00
|
|
|
xmldoc_add_orphan(child_node->node->doc, child_node->node);
|
2008-10-07 11:56:06 +02:00
|
|
|
|
2008-07-10 15:22:21 +02:00
|
|
|
if(oldChild)
|
2008-07-11 00:36:12 +02:00
|
|
|
{
|
2011-02-23 12:28:44 +01:00
|
|
|
IXMLDOMNode_AddRef(child);
|
|
|
|
*oldChild = child;
|
2008-07-11 00:36:12 +02:00
|
|
|
}
|
|
|
|
|
2006-07-10 15:48:45 +02:00
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:32:16 +01:00
|
|
|
HRESULT node_append_child(xmlnode *This, IXMLDOMNode *child, IXMLDOMNode **outChild)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2008-07-08 20:53:58 +02:00
|
|
|
DOMNodeType type;
|
2006-01-11 21:15:12 +01:00
|
|
|
VARIANT var;
|
2008-07-08 20:53:58 +02:00
|
|
|
HRESULT hr;
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2011-02-23 12:32:16 +01:00
|
|
|
hr = IXMLDOMNode_get_nodeType(child, &type);
|
2008-07-08 20:53:58 +02:00
|
|
|
if(FAILED(hr) || type == NODE_ATTRIBUTE) {
|
2011-02-23 12:32:16 +01:00
|
|
|
if (outChild) *outChild = NULL;
|
2008-07-08 20:53:58 +02:00
|
|
|
return E_FAIL;
|
2008-01-03 23:15:00 +01:00
|
|
|
}
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
VariantInit(&var);
|
2011-02-23 12:32:16 +01:00
|
|
|
return IXMLDOMNode_insertBefore(This->iface, child, var, outChild);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:35:35 +01:00
|
|
|
HRESULT node_has_childnodes(const xmlnode *This, VARIANT_BOOL *ret)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2011-02-23 12:35:35 +01:00
|
|
|
if (!ret) return E_INVALIDARG;
|
2005-08-22 11:24:44 +02:00
|
|
|
|
|
|
|
if (!This->node->children)
|
|
|
|
{
|
2011-02-23 12:35:35 +01:00
|
|
|
*ret = VARIANT_FALSE;
|
2005-08-22 11:24:44 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-23 12:35:35 +01:00
|
|
|
*ret = VARIANT_TRUE;
|
2005-08-22 11:24:44 +02:00
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:38:32 +01:00
|
|
|
HRESULT node_get_owner_doc(const xmlnode *This, IXMLDOMDocument **doc)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2011-02-23 12:38:32 +01:00
|
|
|
return get_domdoc_from_xmldoc(This->node->doc, (IXMLDOMDocument3**)doc);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-10-31 09:50:58 +01:00
|
|
|
HRESULT node_clone(xmlnode *This, VARIANT_BOOL deep, IXMLDOMNode **cloneNode)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-10-31 09:50:58 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
xmlNodePtr clone;
|
2007-12-02 22:17:48 +01:00
|
|
|
|
2010-10-31 09:50:58 +01:00
|
|
|
if(!cloneNode) return E_INVALIDARG;
|
2007-12-02 22:17:48 +01:00
|
|
|
|
2010-10-31 09:50:58 +01:00
|
|
|
clone = xmlCopyNode(This->node, deep ? 1 : 2);
|
|
|
|
if (clone)
|
2007-12-02 22:17:48 +01:00
|
|
|
{
|
2012-11-22 01:50:32 +01:00
|
|
|
xmlSetTreeDoc(clone, This->node->doc);
|
2010-10-31 09:50:58 +01:00
|
|
|
xmldoc_add_orphan(clone->doc, clone);
|
2007-12-02 22:17:48 +01:00
|
|
|
|
2010-10-31 09:50:58 +01:00
|
|
|
node = create_node(clone);
|
|
|
|
if (!node)
|
2007-12-02 22:17:48 +01:00
|
|
|
{
|
|
|
|
ERR("Copy failed\n");
|
2011-03-08 15:45:20 +01:00
|
|
|
xmldoc_remove_orphan(clone->doc, clone);
|
|
|
|
xmlFreeNode(clone);
|
2007-12-02 22:17:48 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-10-31 09:50:58 +01:00
|
|
|
*cloneNode = node;
|
2007-12-02 22:17:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Copy failed\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-11-03 22:13:58 +01:00
|
|
|
static inline xmlChar* trim_whitespace(xmlChar* str)
|
|
|
|
{
|
|
|
|
xmlChar* ret = str;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
while (*ret && isspace(*ret))
|
|
|
|
++ret;
|
|
|
|
len = xmlStrlen(ret);
|
2011-01-23 12:13:01 +01:00
|
|
|
if (len)
|
|
|
|
while (isspace(ret[len-1])) --len;
|
2010-11-03 22:13:58 +01:00
|
|
|
|
|
|
|
ret = xmlStrndup(ret, len);
|
|
|
|
xmlFree(str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static xmlChar* do_get_text(xmlNodePtr node)
|
|
|
|
{
|
|
|
|
xmlNodePtr child;
|
|
|
|
xmlChar* str;
|
|
|
|
BOOL preserving = is_preserving_whitespace(node);
|
|
|
|
|
|
|
|
if (!node->children)
|
|
|
|
{
|
|
|
|
str = xmlNodeGetContent(node);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlElementType prev_type = XML_TEXT_NODE;
|
|
|
|
xmlChar* tmp;
|
|
|
|
str = xmlStrdup(BAD_CAST "");
|
|
|
|
for (child = node->children; child != NULL; child = child->next)
|
|
|
|
{
|
|
|
|
switch (child->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
tmp = do_get_text(child);
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
case XML_ENTITY_NODE:
|
|
|
|
tmp = xmlNodeGetContent(child);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tmp = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
if (*tmp)
|
|
|
|
{
|
|
|
|
if (prev_type == XML_ELEMENT_NODE && child->type == XML_ELEMENT_NODE)
|
|
|
|
str = xmlStrcat(str, BAD_CAST " ");
|
|
|
|
str = xmlStrcat(str, tmp);
|
|
|
|
prev_type = child->type;
|
|
|
|
}
|
|
|
|
xmlFree(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (node->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
case XML_ENTITY_NODE:
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
if (!preserving)
|
|
|
|
str = trim_whitespace(str);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2011-02-23 12:40:43 +01:00
|
|
|
HRESULT node_get_text(const xmlnode *This, BSTR *text)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2005-08-18 12:48:13 +02:00
|
|
|
BSTR str = NULL;
|
2011-02-23 12:40:43 +01:00
|
|
|
xmlChar *content;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2011-02-23 12:40:43 +01:00
|
|
|
if (!text) return E_INVALIDARG;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2011-02-23 12:40:43 +01:00
|
|
|
content = do_get_text(This->node);
|
|
|
|
if (content)
|
2006-02-16 19:33:39 +01:00
|
|
|
{
|
2011-02-23 12:40:43 +01:00
|
|
|
str = bstr_from_xmlChar(content);
|
|
|
|
xmlFree(content);
|
2006-02-16 19:33:39 +01:00
|
|
|
}
|
2007-11-20 11:31:43 +01:00
|
|
|
|
|
|
|
/* Always return a string. */
|
|
|
|
if (!str) str = SysAllocStringLen( NULL, 0 );
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
TRACE("%p %s\n", This, debugstr_w(str) );
|
|
|
|
*text = str;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-10-19 01:27:48 +02:00
|
|
|
HRESULT node_put_text(xmlnode *This, BSTR text)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2008-11-29 10:51:20 +01:00
|
|
|
xmlChar *str, *str2;
|
2008-01-16 03:44:51 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(text));
|
2008-01-16 03:44:51 +01:00
|
|
|
|
2011-03-10 20:15:09 +01:00
|
|
|
str = xmlchar_from_wchar(text);
|
2008-01-16 03:44:51 +01:00
|
|
|
|
|
|
|
/* Escape the string. */
|
2008-10-11 23:58:35 +02:00
|
|
|
str2 = xmlEncodeEntitiesReentrant(This->node->doc, str);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free(str);
|
2008-01-16 03:44:51 +01:00
|
|
|
|
2008-11-29 10:51:20 +01:00
|
|
|
xmlNodeSetContent(This->node, str2);
|
|
|
|
xmlFree(str2);
|
2008-01-16 03:44:51 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-11-06 20:07:11 +01:00
|
|
|
BSTR EnsureCorrectEOL(BSTR sInput)
|
2008-07-26 13:06:41 +02:00
|
|
|
{
|
|
|
|
int nNum = 0;
|
|
|
|
BSTR sNew;
|
|
|
|
int nLen;
|
|
|
|
int i;
|
|
|
|
|
2010-10-26 23:10:53 +02:00
|
|
|
nLen = SysStringLen(sInput);
|
2008-07-26 13:06:41 +02:00
|
|
|
/* Count line endings */
|
|
|
|
for(i=0; i < nLen; i++)
|
|
|
|
{
|
2010-03-31 11:47:10 +02:00
|
|
|
if(sInput[i] == '\n')
|
2008-07-26 13:06:41 +02:00
|
|
|
nNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("len=%d, num=%d\n", nLen, nNum);
|
|
|
|
|
|
|
|
/* Add linefeed as needed */
|
|
|
|
if(nNum > 0)
|
|
|
|
{
|
|
|
|
int nPlace = 0;
|
2011-06-17 04:43:54 +02:00
|
|
|
sNew = SysAllocStringLen(NULL, nLen + nNum);
|
2008-07-26 13:06:41 +02:00
|
|
|
for(i=0; i < nLen; i++)
|
|
|
|
{
|
2010-03-31 11:47:10 +02:00
|
|
|
if(sInput[i] == '\n')
|
2008-07-26 13:06:41 +02:00
|
|
|
{
|
2010-03-31 11:47:10 +02:00
|
|
|
sNew[i+nPlace] = '\r';
|
2008-07-26 13:06:41 +02:00
|
|
|
nPlace++;
|
|
|
|
}
|
|
|
|
sNew[i+nPlace] = sInput[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
SysFreeString(sInput);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sNew = sInput;
|
|
|
|
}
|
|
|
|
|
2010-10-26 23:10:53 +02:00
|
|
|
TRACE("len %d\n", SysStringLen(sNew));
|
2008-07-26 13:06:41 +02:00
|
|
|
|
|
|
|
return sNew;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We are trying to replicate the same behaviour as msxml by converting
|
2010-03-22 19:48:29 +01:00
|
|
|
* line endings to \r\n and using indents as \t. The problem is that msxml
|
2008-07-26 13:06:41 +02:00
|
|
|
* only formats nodes that have a line ending. Using libxml we cannot
|
|
|
|
* reproduce behaviour exactly.
|
|
|
|
*
|
|
|
|
*/
|
2012-05-15 09:49:58 +02:00
|
|
|
HRESULT node_get_xml(xmlnode *This, BOOL ensure_eol, BSTR *ret)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-10-29 16:27:09 +02:00
|
|
|
xmlBufferPtr xml_buf;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlNodePtr xmldecl;
|
2010-10-29 16:27:09 +02:00
|
|
|
int size;
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
if(!ret)
|
2008-01-03 23:15:28 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
xml_buf = xmlBufferCreate();
|
|
|
|
if(!xml_buf)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
|
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
size = xmlNodeDump(xml_buf, This->node->doc, This->node, 0, 1);
|
|
|
|
if(size > 0) {
|
|
|
|
const xmlChar *buf_content;
|
|
|
|
BSTR content;
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
/* Attribute Nodes return a space in front of their name */
|
|
|
|
buf_content = xmlBufferContent(xml_buf);
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
content = bstr_from_xmlChar(buf_content + (buf_content[0] == ' ' ? 1 : 0));
|
|
|
|
if(ensure_eol)
|
|
|
|
content = EnsureCorrectEOL(content);
|
2008-07-26 13:06:41 +02:00
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
*ret = content;
|
|
|
|
}else {
|
|
|
|
*ret = SysAllocStringLen(NULL, 0);
|
2008-01-03 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
2010-10-29 16:27:09 +02:00
|
|
|
xmlBufferFree(xml_buf);
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldoc_link_xmldecl( This->node->doc, xmldecl );
|
2010-10-29 16:27:09 +02:00
|
|
|
return *ret ? S_OK : E_OUTOFMEMORY;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2013-08-21 12:31:28 +02:00
|
|
|
/* duplicates xmlBufferWriteQuotedString() logic */
|
|
|
|
static void xml_write_quotedstring(xmlOutputBufferPtr buf, const xmlChar *string)
|
|
|
|
{
|
|
|
|
const xmlChar *cur, *base;
|
|
|
|
|
|
|
|
if (xmlStrchr(string, '\"'))
|
|
|
|
{
|
|
|
|
if (xmlStrchr(string, '\''))
|
|
|
|
{
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\"");
|
|
|
|
base = cur = string;
|
|
|
|
|
|
|
|
while (*cur)
|
|
|
|
{
|
|
|
|
if (*cur == '"')
|
|
|
|
{
|
|
|
|
if (base != cur)
|
|
|
|
xmlOutputBufferWrite(buf, cur-base, (const char*)base);
|
|
|
|
xmlOutputBufferWrite(buf, 6, """);
|
|
|
|
cur++;
|
|
|
|
base = cur;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cur++;
|
|
|
|
}
|
|
|
|
if (base != cur)
|
|
|
|
xmlOutputBufferWrite(buf, cur-base, (const char*)base);
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\"");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\'");
|
|
|
|
xmlOutputBufferWriteString(buf, (const char*)string);
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\"");
|
|
|
|
xmlOutputBufferWriteString(buf, (const char*)string);
|
|
|
|
xmlOutputBufferWrite(buf, 1, "\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-10 04:22:25 +01:00
|
|
|
static void htmldtd_dumpcontent(xmlOutputBufferPtr buf, xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
xmlDtdPtr cur = doc->intSubset;
|
|
|
|
|
|
|
|
xmlOutputBufferWriteString(buf, "<!DOCTYPE ");
|
|
|
|
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
|
|
|
if (cur->ExternalID)
|
|
|
|
{
|
|
|
|
xmlOutputBufferWriteString(buf, " PUBLIC ");
|
2013-08-21 12:31:28 +02:00
|
|
|
xml_write_quotedstring(buf, cur->ExternalID);
|
2012-11-10 04:22:25 +01:00
|
|
|
if (cur->SystemID)
|
|
|
|
{
|
|
|
|
xmlOutputBufferWriteString(buf, " ");
|
2013-08-21 12:31:28 +02:00
|
|
|
xml_write_quotedstring(buf, cur->SystemID);
|
2012-11-10 04:22:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (cur->SystemID)
|
|
|
|
{
|
|
|
|
xmlOutputBufferWriteString(buf, " SYSTEM ");
|
2013-08-21 12:31:28 +02:00
|
|
|
xml_write_quotedstring(buf, cur->SystemID);
|
2012-11-10 04:22:25 +01:00
|
|
|
}
|
|
|
|
xmlOutputBufferWriteString(buf, ">\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void htmldoc_dumpcontent(xmlOutputBufferPtr buf, xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
xmlElementType type;
|
|
|
|
|
|
|
|
/* force HTML output */
|
|
|
|
type = doc->type;
|
|
|
|
doc->type = XML_HTML_DOCUMENT_NODE;
|
|
|
|
if (doc->intSubset)
|
|
|
|
htmldtd_dumpcontent(buf, doc);
|
|
|
|
if (doc->children)
|
|
|
|
{
|
|
|
|
xmlNodePtr cur = doc->children;
|
|
|
|
|
|
|
|
while (cur)
|
|
|
|
{
|
|
|
|
htmlNodeDumpFormatOutput(buf, doc, cur, NULL, 1);
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
doc->type = type;
|
|
|
|
}
|
|
|
|
|
2013-08-21 14:11:05 +02:00
|
|
|
static const xmlChar *get_output_buffer_content(xmlOutputBufferPtr output)
|
|
|
|
{
|
|
|
|
#ifdef LIBXML2_NEW_BUFFER
|
|
|
|
return xmlOutputBufferGetContent(output);
|
|
|
|
#else
|
|
|
|
return xmlBufferContent(output->buffer);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
HRESULT node_transform_node(const xmlnode *This, IXMLDOMNode *stylesheet, BSTR *p)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2008-11-17 19:29:32 +01:00
|
|
|
#ifdef SONAME_LIBXSLT
|
2011-02-23 13:03:42 +01:00
|
|
|
xsltStylesheetPtr xsltSS;
|
|
|
|
xmlnode *sheet;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
if (!libxslt_handle) return E_NOTIMPL;
|
|
|
|
if (!stylesheet || !p) return E_INVALIDARG;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
*p = NULL;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
sheet = get_node_obj(stylesheet);
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!sheet) return E_FAIL;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
xsltSS = pxsltParseStylesheetDoc(sheet->node->doc);
|
2010-09-04 17:55:04 +02:00
|
|
|
if(xsltSS)
|
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
xmlDocPtr result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
|
2010-09-04 17:55:04 +02:00
|
|
|
if(result)
|
2008-03-26 09:52:36 +01:00
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
const xmlChar *content;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(result->type == XML_HTML_DOCUMENT_NODE)
|
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
xmlOutputBufferPtr output = xmlAllocOutputBuffer(NULL);
|
|
|
|
if (output)
|
2008-03-26 09:52:36 +01:00
|
|
|
{
|
2012-11-10 04:22:25 +01:00
|
|
|
htmldoc_dumpcontent(output, result->doc);
|
2013-08-21 14:11:05 +02:00
|
|
|
content = get_output_buffer_content(output);
|
2011-02-23 13:03:42 +01:00
|
|
|
*p = bstr_from_xmlChar(content);
|
|
|
|
xmlOutputBufferClose(output);
|
2008-04-24 14:22:14 +02:00
|
|
|
}
|
2010-09-04 17:55:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
xmlBufferPtr buf = xmlBufferCreate();
|
|
|
|
if (buf)
|
2010-09-04 17:55:04 +02:00
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
int size = xmlNodeDump(buf, NULL, (xmlNodePtr)result, 0, 0);
|
|
|
|
if(size > 0)
|
2008-04-24 14:22:14 +02:00
|
|
|
{
|
2011-02-23 13:03:42 +01:00
|
|
|
content = xmlBufferContent(buf);
|
|
|
|
*p = bstr_from_xmlChar(content);
|
2008-03-26 09:52:36 +01:00
|
|
|
}
|
2011-02-23 13:03:42 +01:00
|
|
|
xmlBufferFree(buf);
|
2008-03-26 09:52:36 +01:00
|
|
|
}
|
|
|
|
}
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlFreeDoc(result);
|
2008-03-26 09:52:36 +01:00
|
|
|
}
|
2010-09-04 17:55:04 +02:00
|
|
|
/* libxslt "helpfully" frees the XML document the stylesheet was
|
|
|
|
generated from, too */
|
|
|
|
xsltSS->doc = NULL;
|
|
|
|
pxsltFreeStylesheet(xsltSS);
|
2008-03-26 09:52:36 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 13:03:42 +01:00
|
|
|
if(!*p) *p = SysAllocStringLen(NULL, 0);
|
2008-03-26 09:52:36 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
#else
|
|
|
|
FIXME("libxslt headers were not found at compile time\n");
|
2005-08-10 11:54:22 +02:00
|
|
|
return E_NOTIMPL;
|
2008-03-26 09:52:36 +01:00
|
|
|
#endif
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:42:24 +01:00
|
|
|
HRESULT node_select_nodes(const xmlnode *This, BSTR query, IXMLDOMNodeList **nodes)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-11-23 03:59:20 +01:00
|
|
|
xmlChar* str;
|
|
|
|
HRESULT hr;
|
2005-09-03 11:39:38 +02:00
|
|
|
|
2011-02-23 12:42:24 +01:00
|
|
|
if (!query || !nodes) return E_INVALIDARG;
|
2005-09-03 11:39:38 +02:00
|
|
|
|
2011-03-10 20:15:09 +01:00
|
|
|
str = xmlchar_from_wchar(query);
|
2011-03-13 00:54:47 +01:00
|
|
|
hr = create_selection(This->node, str, nodes);
|
2010-11-23 03:59:20 +01:00
|
|
|
heap_free(str);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-23 12:44:20 +01:00
|
|
|
HRESULT node_select_singlenode(const xmlnode *This, BSTR query, IXMLDOMNode **node)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2005-11-08 17:10:13 +01:00
|
|
|
IXMLDOMNodeList *list;
|
2011-02-23 12:44:20 +01:00
|
|
|
HRESULT hr;
|
2005-11-08 17:10:13 +01:00
|
|
|
|
2011-02-23 12:44:20 +01:00
|
|
|
hr = node_select_nodes(This, query, &list);
|
|
|
|
if (hr == S_OK)
|
2005-11-08 17:10:13 +01:00
|
|
|
{
|
2011-02-23 12:44:20 +01:00
|
|
|
hr = IXMLDOMNodeList_nextNode(list, node);
|
2005-11-08 17:10:13 +01:00
|
|
|
IXMLDOMNodeList_Release(list);
|
|
|
|
}
|
2011-02-23 12:44:20 +01:00
|
|
|
return hr;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2011-01-09 21:42:55 +01:00
|
|
|
HRESULT node_get_namespaceURI(xmlnode *This, BSTR *namespaceURI)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2011-11-15 22:28:51 +01:00
|
|
|
xmlNsPtr ns = This->node->ns;
|
2008-04-18 13:29:59 +02:00
|
|
|
|
|
|
|
if(!namespaceURI)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*namespaceURI = NULL;
|
|
|
|
|
2011-11-15 22:28:51 +01:00
|
|
|
if (ns && ns->href)
|
|
|
|
*namespaceURI = bstr_from_xmlChar(ns->href);
|
2008-04-18 13:29:59 +02:00
|
|
|
|
2010-09-14 07:01:16 +02:00
|
|
|
TRACE("uri: %s\n", debugstr_w(*namespaceURI));
|
|
|
|
|
|
|
|
return *namespaceURI ? S_OK : S_FALSE;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-10-31 10:22:53 +01:00
|
|
|
HRESULT node_get_prefix(xmlnode *This, BSTR *prefix)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2011-11-15 22:19:28 +01:00
|
|
|
xmlNsPtr ns = This->node->ns;
|
2008-04-18 13:23:22 +02:00
|
|
|
|
2010-10-31 10:22:53 +01:00
|
|
|
if (!prefix) return E_INVALIDARG;
|
2008-04-18 13:23:22 +02:00
|
|
|
|
2010-10-31 10:22:53 +01:00
|
|
|
*prefix = NULL;
|
2008-04-18 13:23:22 +02:00
|
|
|
|
2011-11-15 22:19:28 +01:00
|
|
|
if (ns && ns->prefix)
|
|
|
|
*prefix = bstr_from_xmlChar(ns->prefix);
|
2008-04-18 13:23:22 +02:00
|
|
|
|
2010-10-31 10:22:53 +01:00
|
|
|
TRACE("prefix: %s\n", debugstr_w(*prefix));
|
2010-09-14 07:00:02 +02:00
|
|
|
|
2010-10-31 10:22:53 +01:00
|
|
|
return *prefix ? S_OK : S_FALSE;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-10-31 10:39:53 +01:00
|
|
|
HRESULT node_get_base_name(xmlnode *This, BSTR *name)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-10-31 10:39:53 +01:00
|
|
|
if (!name) return E_INVALIDARG;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2010-10-31 10:39:53 +01:00
|
|
|
*name = bstr_from_xmlChar(This->node->name);
|
|
|
|
if (!*name) return E_OUTOFMEMORY;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2010-10-31 10:39:53 +01:00
|
|
|
TRACE("returning %s\n", debugstr_w(*name));
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2010-10-31 10:39:53 +01:00
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
/* _private field holds a number of COM instances spawned from this libxml2 node */
|
|
|
|
static void xmlnode_add_ref(xmlNodePtr node)
|
|
|
|
{
|
|
|
|
if (node->type == XML_DOCUMENT_NODE) return;
|
|
|
|
InterlockedIncrement((LONG*)&node->_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xmlnode_release(xmlNodePtr node)
|
|
|
|
{
|
|
|
|
if (node->type == XML_DOCUMENT_NODE) return;
|
|
|
|
InterlockedDecrement((LONG*)&node->_private);
|
|
|
|
}
|
|
|
|
|
2009-09-30 15:36:38 +02:00
|
|
|
void destroy_xmlnode(xmlnode *This)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2009-09-30 15:36:38 +02:00
|
|
|
if(This->node)
|
2013-02-24 21:30:22 +01:00
|
|
|
{
|
|
|
|
xmlnode_release(This->node);
|
2009-09-30 15:36:38 +02:00
|
|
|
xmldoc_release(This->node->doc);
|
2013-02-24 21:30:22 +01:00
|
|
|
}
|
2011-10-29 23:27:50 +02:00
|
|
|
release_dispex(&This->dispex);
|
2005-12-01 18:46:42 +01:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:54:13 +02:00
|
|
|
void init_xmlnode(xmlnode *This, xmlNodePtr node, IXMLDOMNode *node_iface, dispex_static_data_t *dispex_data)
|
2005-12-01 18:46:42 +01:00
|
|
|
{
|
|
|
|
if(node)
|
2013-02-24 21:30:22 +01:00
|
|
|
{
|
|
|
|
xmlnode_add_ref(node);
|
|
|
|
xmldoc_add_ref(node->doc);
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
This->node = node;
|
2010-09-04 17:54:13 +02:00
|
|
|
This->iface = node_iface;
|
2011-03-03 01:57:01 +01:00
|
|
|
This->parent = NULL;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2011-10-31 20:09:12 +01:00
|
|
|
init_dispex(&This->dispex, (IUnknown*)This->iface, dispex_data);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:27 +02:00
|
|
|
typedef struct {
|
|
|
|
xmlnode node;
|
2011-01-24 10:31:25 +01:00
|
|
|
IXMLDOMNode IXMLDOMNode_iface;
|
2010-09-04 17:55:27 +02:00
|
|
|
LONG ref;
|
|
|
|
} unknode;
|
|
|
|
|
2011-01-24 10:31:25 +01:00
|
|
|
static inline unknode *unknode_from_IXMLDOMNode(IXMLDOMNode *iface)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
return CONTAINING_RECORD(iface, unknode, IXMLDOMNode_iface);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_QueryInterface(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
*ppvObject = iface;
|
|
|
|
}else if (IsEqualGUID( riid, &IID_IDispatch) ||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMNode)) {
|
2011-01-24 10:31:25 +01:00
|
|
|
*ppvObject = &This->IXMLDOMNode_iface;
|
2010-09-04 17:55:27 +02:00
|
|
|
}else if(node_query_interface(&This->node, riid, ppvObject)) {
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}else {
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
*ppvObject = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unknode_AddRef(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unknode_Release(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if(!ref) {
|
|
|
|
destroy_xmlnode(&This->node);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_GetTypeInfoCount(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_GetTypeInfo(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo** ppTInfo )
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-11-29 13:32:38 +01:00
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMNode_tid, ppTInfo);
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_GetIDsOfNames(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
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(IXMLDOMNode_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 13:32:38 +01:00
|
|
|
{
|
2010-09-04 17:55:27 +02:00
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_Invoke(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:27 +02:00
|
|
|
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(IXMLDOMNode_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
2012-11-29 13:32:38 +01:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMNode_iface, dispIdMember, wFlags, pDispParams,
|
2010-09-04 17:55:27 +02:00
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2012-11-29 13:32:38 +01:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
2010-09-04 17:55:27 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:56:25 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return node_get_nodeName(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeValue(
|
|
|
|
IXMLDOMNode *iface,
|
2010-09-04 17:56:45 +02:00
|
|
|
VARIANT* value)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-04 17:56:45 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, value);
|
|
|
|
|
|
|
|
if(!value)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
V_VT(value) = VT_NULL;
|
|
|
|
return S_FALSE;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_nodeValue(
|
|
|
|
IXMLDOMNode *iface,
|
2010-09-07 15:27:31 +02:00
|
|
|
VARIANT value)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-07 15:27:31 +02:00
|
|
|
FIXME("(%p)->(v%d)\n", This, V_VT(&value));
|
|
|
|
return E_FAIL;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
DOMNodeType* domNodeType )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-07 15:28:21 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, domNodeType);
|
|
|
|
|
|
|
|
*domNodeType = This->node.node->type;
|
|
|
|
return S_OK;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_parentNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** parent )
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-07 15:28:21 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, parent);
|
2010-09-04 17:55:27 +02:00
|
|
|
if (!parent) return E_INVALIDARG;
|
|
|
|
*parent = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_childNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNodeList** outList)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-08 15:12:02 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, outList);
|
|
|
|
|
|
|
|
return node_get_child_nodes(&This->node, outList);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_firstChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** domNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-08 15:12:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, domNode);
|
|
|
|
|
|
|
|
return node_get_first_child(&This->node, domNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_lastChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** domNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-08 15:12:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, domNode);
|
|
|
|
|
2010-09-08 21:55:37 +02:00
|
|
|
return node_get_last_child(&This->node, domNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_previousSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** domNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-10 16:53:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, domNode);
|
|
|
|
|
|
|
|
return node_get_previous_sibling(&This->node, domNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nextSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** domNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-10 16:53:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, domNode);
|
|
|
|
|
|
|
|
return node_get_next_sibling(&This->node, domNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_attributes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNamedNodeMap** attributeMap)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-10 16:54:06 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, attributeMap);
|
|
|
|
|
|
|
|
return return_null_ptr((void**)attributeMap);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_insertBefore(
|
|
|
|
IXMLDOMNode *iface,
|
2010-09-10 16:55:14 +02:00
|
|
|
IXMLDOMNode* newNode, VARIANT refChild,
|
2010-09-04 17:55:27 +02:00
|
|
|
IXMLDOMNode** outOldNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-09-10 16:55:14 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode);
|
|
|
|
|
|
|
|
return node_insert_before(&This->node, newNode, &refChild, outOldNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_replaceChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newNode,
|
|
|
|
IXMLDOMNode* oldNode,
|
|
|
|
IXMLDOMNode** outOldNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-10-13 15:11:32 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
|
|
|
|
|
|
|
|
return node_replace_child(&This->node, newNode, oldNode, outOldNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_removeChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:28:44 +01:00
|
|
|
return node_remove_child(&This->node, domNode, oldNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_appendChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:32:16 +01:00
|
|
|
return node_append_child(&This->node, newNode, outNewNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_hasChildNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* pbool)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:35:35 +01:00
|
|
|
return node_has_childnodes(&This->node, pbool);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_ownerDocument(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMDocument** domDocument)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:38:32 +01:00
|
|
|
return node_get_owner_doc(&This->node, domDocument);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_cloneNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL pbool, IXMLDOMNode** outNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:13:36 +01:00
|
|
|
return node_clone(&This->node, pbool, outNode );
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeTypeString(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-11-07 20:28:36 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return node_get_nodeName(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:40:43 +01:00
|
|
|
return node_get_text(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:13:36 +01:00
|
|
|
return node_put_text(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_specified(
|
|
|
|
IXMLDOMNode *iface,
|
2010-10-24 22:55:04 +02:00
|
|
|
VARIANT_BOOL* isSpecified)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isSpecified);
|
|
|
|
*isSpecified = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_definition(
|
|
|
|
IXMLDOMNode *iface,
|
2010-10-24 22:55:04 +02:00
|
|
|
IXMLDOMNode** definitionNode)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, definitionNode);
|
|
|
|
return E_NOTIMPL;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeTypedValue(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* var1)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-01-09 21:42:37 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, var1);
|
|
|
|
return return_null_var(var1);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_nodeTypedValue(
|
|
|
|
IXMLDOMNode *iface,
|
2010-12-30 13:07:50 +01:00
|
|
|
VARIANT typedValue)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-12-30 13:07:50 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
|
|
|
|
return E_NOTIMPL;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* var1)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:13:36 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, var1);
|
|
|
|
return return_null_var(var1);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-12-30 13:07:50 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(p));
|
|
|
|
|
|
|
|
if(!p)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return E_FAIL;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_xml(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-10-29 16:27:09 +02:00
|
|
|
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
|
2012-05-15 09:49:58 +02:00
|
|
|
return node_get_xml(&This->node, FALSE, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_transformNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* domNode, BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:03:42 +01:00
|
|
|
return node_transform_node(&This->node, domNode, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_selectNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p, IXMLDOMNodeList** outList)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:42:24 +01:00
|
|
|
return node_select_nodes(&This->node, p, outList);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_selectSingleNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p, IXMLDOMNode** outNode)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 12:44:20 +01:00
|
|
|
return node_select_singlenode(&This->node, p, outNode);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_parsed(
|
|
|
|
IXMLDOMNode *iface,
|
2010-10-24 22:55:04 +02:00
|
|
|
VARIANT_BOOL* isParsed)
|
2010-09-04 17:55:27 +02:00
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isParsed);
|
|
|
|
*isParsed = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_namespaceURI(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-01-09 21:42:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
return node_get_namespaceURI(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_prefix(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:13:36 +01:00
|
|
|
return node_get_prefix(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_baseName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-02-23 13:13:36 +01:00
|
|
|
return node_get_base_name(&This->node, p);
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_transformNodeToObject(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* domNode, VARIANT var1)
|
|
|
|
{
|
2011-01-24 10:31:25 +01:00
|
|
|
unknode *This = unknode_from_IXMLDOMNode( iface );
|
2011-01-06 17:21:02 +01:00
|
|
|
FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
|
|
|
|
return E_NOTIMPL;
|
2010-09-04 17:55:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMNodeVtbl unknode_vtbl =
|
|
|
|
{
|
|
|
|
unknode_QueryInterface,
|
|
|
|
unknode_AddRef,
|
|
|
|
unknode_Release,
|
|
|
|
unknode_GetTypeInfoCount,
|
|
|
|
unknode_GetTypeInfo,
|
|
|
|
unknode_GetIDsOfNames,
|
|
|
|
unknode_Invoke,
|
|
|
|
unknode_get_nodeName,
|
|
|
|
unknode_get_nodeValue,
|
|
|
|
unknode_put_nodeValue,
|
|
|
|
unknode_get_nodeType,
|
|
|
|
unknode_get_parentNode,
|
|
|
|
unknode_get_childNodes,
|
|
|
|
unknode_get_firstChild,
|
|
|
|
unknode_get_lastChild,
|
|
|
|
unknode_get_previousSibling,
|
|
|
|
unknode_get_nextSibling,
|
|
|
|
unknode_get_attributes,
|
|
|
|
unknode_insertBefore,
|
|
|
|
unknode_replaceChild,
|
|
|
|
unknode_removeChild,
|
|
|
|
unknode_appendChild,
|
|
|
|
unknode_hasChildNodes,
|
|
|
|
unknode_get_ownerDocument,
|
|
|
|
unknode_cloneNode,
|
|
|
|
unknode_get_nodeTypeString,
|
|
|
|
unknode_get_text,
|
|
|
|
unknode_put_text,
|
|
|
|
unknode_get_specified,
|
|
|
|
unknode_get_definition,
|
|
|
|
unknode_get_nodeTypedValue,
|
|
|
|
unknode_put_nodeTypedValue,
|
|
|
|
unknode_get_dataType,
|
|
|
|
unknode_put_dataType,
|
|
|
|
unknode_get_xml,
|
|
|
|
unknode_transformNode,
|
|
|
|
unknode_selectNodes,
|
|
|
|
unknode_selectSingleNode,
|
|
|
|
unknode_get_parsed,
|
|
|
|
unknode_get_namespaceURI,
|
|
|
|
unknode_get_prefix,
|
|
|
|
unknode_get_baseName,
|
|
|
|
unknode_transformNodeToObject
|
|
|
|
};
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
IXMLDOMNode *create_node( xmlNodePtr node )
|
|
|
|
{
|
|
|
|
IUnknown *pUnk;
|
|
|
|
IXMLDOMNode *ret;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if ( !node )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
TRACE("type %d\n", node->type);
|
|
|
|
switch(node->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
2009-08-22 19:51:45 +02:00
|
|
|
pUnk = create_element( node );
|
2005-12-01 18:46:42 +01:00
|
|
|
break;
|
2006-02-16 19:37:53 +01:00
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
pUnk = create_attribute( node );
|
|
|
|
break;
|
2006-01-19 11:56:34 +01:00
|
|
|
case XML_TEXT_NODE:
|
|
|
|
pUnk = create_text( node );
|
|
|
|
break;
|
2008-07-16 17:41:14 +02:00
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
pUnk = create_cdata( node );
|
|
|
|
break;
|
2010-02-09 01:43:38 +01:00
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
pUnk = create_doc_entity_ref( node );
|
|
|
|
break;
|
2010-02-09 01:03:30 +01:00
|
|
|
case XML_PI_NODE:
|
|
|
|
pUnk = create_pi( node );
|
|
|
|
break;
|
2006-02-16 19:37:53 +01:00
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
pUnk = create_comment( node );
|
|
|
|
break;
|
2005-12-01 18:46:42 +01:00
|
|
|
case XML_DOCUMENT_NODE:
|
2008-07-16 14:13:18 +02:00
|
|
|
pUnk = create_domdoc( node );
|
|
|
|
break;
|
2010-02-12 01:48:46 +01:00
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
pUnk = create_doc_fragment( node );
|
|
|
|
break;
|
2010-11-04 23:34:01 +01:00
|
|
|
case XML_DTD_NODE:
|
|
|
|
pUnk = create_doc_type( node );
|
|
|
|
break;
|
2009-10-14 20:01:42 +02:00
|
|
|
default: {
|
2010-09-04 17:55:27 +02:00
|
|
|
unknode *new_node;
|
2009-10-14 20:01:42 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
FIXME("only creating basic node for type %d\n", node->type);
|
2009-10-14 20:01:42 +02:00
|
|
|
|
2010-09-04 17:55:27 +02:00
|
|
|
new_node = heap_alloc(sizeof(unknode));
|
2009-10-14 20:01:42 +02:00
|
|
|
if(!new_node)
|
|
|
|
return NULL;
|
|
|
|
|
2011-01-24 10:31:25 +01:00
|
|
|
new_node->IXMLDOMNode_iface.lpVtbl = &unknode_vtbl;
|
2010-09-04 17:55:27 +02:00
|
|
|
new_node->ref = 1;
|
2011-01-24 10:31:25 +01:00
|
|
|
init_xmlnode(&new_node->node, node, &new_node->IXMLDOMNode_iface, NULL);
|
|
|
|
pUnk = (IUnknown*)&new_node->IXMLDOMNode_iface;
|
2009-10-14 20:01:42 +02:00
|
|
|
}
|
2005-12-01 18:46:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMNode, (LPVOID*)&ret);
|
|
|
|
IUnknown_Release(pUnk);
|
|
|
|
if(FAILED(hr)) return NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
#endif
|