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>
|
2005-08-18 12:48:13 +02:00
|
|
|
#include <assert.h>
|
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"
|
|
|
|
|
2008-04-24 14:22:14 +02:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/HTMLtree.h>
|
|
|
|
#endif
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2008-02-20 06:03:41 +01:00
|
|
|
static const WCHAR szBinBase64[] = {'b','i','n','.','b','a','s','e','6','4',0};
|
|
|
|
static const WCHAR szString[] = {'s','t','r','i','n','g',0};
|
|
|
|
static const WCHAR szNumber[] = {'n','u','m','b','e','r',0};
|
|
|
|
static const WCHAR szInt[] = {'I','n','t',0};
|
|
|
|
static const WCHAR szFixed[] = {'F','i','x','e','d','.','1','4','.','4',0};
|
|
|
|
static const WCHAR szBoolean[] = {'B','o','o','l','e','a','n',0};
|
|
|
|
static const WCHAR szDateTime[] = {'d','a','t','e','T','i','m','e',0};
|
|
|
|
static const WCHAR szDateTimeTZ[] = {'d','a','t','e','T','i','m','e','.','t','z',0};
|
|
|
|
static const WCHAR szDate[] = {'D','a','t','e',0};
|
|
|
|
static const WCHAR szTime[] = {'T','i','m','e',0};
|
|
|
|
static const WCHAR szTimeTZ[] = {'T','i','m','e','.','t','z',0};
|
|
|
|
static const WCHAR szI1[] = {'i','1',0};
|
|
|
|
static const WCHAR szI2[] = {'i','2',0};
|
|
|
|
static const WCHAR szI4[] = {'i','4',0};
|
|
|
|
static const WCHAR szIU1[] = {'u','i','1',0};
|
|
|
|
static const WCHAR szIU2[] = {'u','i','2',0};
|
|
|
|
static const WCHAR szIU4[] = {'u','i','4',0};
|
|
|
|
static const WCHAR szR4[] = {'r','4',0};
|
|
|
|
static const WCHAR szR8[] = {'r','8',0};
|
|
|
|
static const WCHAR szFloat[] = {'f','l','o','a','t',0};
|
|
|
|
static const WCHAR szUUID[] = {'u','u','i','d',0};
|
|
|
|
static const WCHAR szBinHex[] = {'b','i','n','.','h','e','x',0};
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:54:46 +02:00
|
|
|
if(This->dispex.outer)
|
|
|
|
return dispex_query_interface(&This->dispex, riid, ppv);
|
2010-09-04 17:55:04 +02:00
|
|
|
|
2010-09-04 17:54:46 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlnode *get_node_obj(IXMLDOMNode *node)
|
|
|
|
{
|
|
|
|
xmlnode *obj;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IXMLDOMNode_QueryInterface(node, &IID_xmlnode, (void**)&obj);
|
|
|
|
return SUCCEEDED(hres) ? obj : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline xmlnode *impl_from_IXMLDOMNode( IXMLDOMNode *iface )
|
|
|
|
{
|
|
|
|
return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpVtbl));
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_QueryInterface(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOINTERFACE;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnode_AddRef(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return 2;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnode_Release(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return 1;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetTypeInfoCount(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetTypeInfo(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetIDsOfNames(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_Invoke(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr )
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:56:25 +02:00
|
|
|
HRESULT node_get_nodeName(xmlnode *This, BSTR *name)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2005-11-02 20:55:30 +01:00
|
|
|
if (!name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-09-04 17:56:25 +02:00
|
|
|
*name = bstr_from_xmlChar(This->node->name);
|
2005-11-02 11:55:03 +01:00
|
|
|
if (!*name)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:56:25 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* name)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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-09-04 17:56:45 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeValue(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* value)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
HRESULT node_put_value(xmlnode *This, VARIANT *value)
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2010-09-07 15:27:31 +02:00
|
|
|
VARIANT string_value;
|
|
|
|
xmlChar *str;
|
2008-10-11 23:58:11 +02:00
|
|
|
HRESULT hr;
|
2008-02-25 09:56:22 +01:00
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
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
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
str = xmlChar_from_wchar(V_BSTR(&string_value));
|
|
|
|
VariantClear(&string_value);
|
2010-02-13 00:25:08 +01:00
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
xmlNodeSetContent(This->node, str);
|
|
|
|
heap_free(str);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-02-25 09:56:22 +01:00
|
|
|
|
2010-09-07 15:27:31 +02:00
|
|
|
static HRESULT WINAPI xmlnode_put_nodeValue(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeType(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
DOMNodeType* type)
|
|
|
|
{
|
2010-09-07 15:28:21 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02: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 );
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_parentNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** parent)
|
|
|
|
{
|
2010-09-07 15:28:21 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
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:02 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_childNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNodeList** childList)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_firstChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** firstChild)
|
|
|
|
{
|
2010-09-08 15:12:14 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_lastChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** lastChild)
|
|
|
|
{
|
2010-09-08 15:12:14 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
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);
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_previousSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** previousSibling)
|
|
|
|
{
|
2010-09-10 16:53:48 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2008-01-08 01:34:29 +01:00
|
|
|
|
2010-09-10 16:53:48 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_nextSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** nextSibling)
|
|
|
|
{
|
2010-09-10 16:53:48 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_attributes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNamedNodeMap** attributeMap)
|
|
|
|
{
|
2010-09-10 16:54:06 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2006-01-11 21:15:12 +01:00
|
|
|
xmlNodePtr before_node, new_child_node;
|
2010-09-04 17:55:04 +02:00
|
|
|
IXMLDOMNode *before = NULL;
|
|
|
|
xmlnode *node_obj;
|
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);
|
|
|
|
if(!node_obj) {
|
|
|
|
FIXME("newChild is not our node implementation\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
2010-09-10 16:55:14 +02:00
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(ref_child), &IID_IXMLDOMNode, (LPVOID)&before);
|
2006-01-11 21:15:12 +01:00
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_child_node = node_obj->node;
|
2006-01-11 21:15:12 +01:00
|
|
|
TRACE("new_child_node %p This->node %p\n", new_child_node, This->node);
|
|
|
|
|
2008-10-11 23:59:25 +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);
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
if(before)
|
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
node_obj = get_node_obj(before);
|
2006-01-11 21:15:12 +01:00
|
|
|
IXMLDOMNode_Release(before);
|
2010-09-04 17:55:04 +02:00
|
|
|
if(!node_obj) {
|
|
|
|
FIXME("before node is not our node implementation\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
before_node = node_obj->node;
|
|
|
|
xmlAddPrevSibling(before_node, new_child_node);
|
2006-01-11 21:15:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlAddChild(This->node, new_child_node);
|
|
|
|
}
|
|
|
|
|
2010-09-10 16:55:14 +02:00
|
|
|
if(ret) {
|
|
|
|
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-09-10 16:55:14 +02:00
|
|
|
static HRESULT WINAPI xmlnode_insertBefore(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
VARIANT refChild,
|
|
|
|
IXMLDOMNode** outNewChild)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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;
|
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);
|
|
|
|
if(!old_child) {
|
|
|
|
FIXME("oldChild is not our node implementation\n");
|
|
|
|
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);
|
|
|
|
if(!new_child) {
|
|
|
|
FIXME("newChild is not our node implementation\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
xmldoc_add_ref(old_child->node->doc);
|
|
|
|
xmlReplaceNode(old_child->node, new_child->node);
|
2008-10-07 11:55:01 +02:00
|
|
|
xmldoc_release(leaving_doc);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-10-13 15:11:32 +02:00
|
|
|
static HRESULT WINAPI xmlnode_replaceChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode* oldChild,
|
|
|
|
IXMLDOMNode** outOldChild)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_removeChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* childNode,
|
|
|
|
IXMLDOMNode** oldChild)
|
|
|
|
{
|
2006-07-10 15:48:45 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlnode *child_node;
|
2006-07-10 15:48:45 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, childNode, oldChild);
|
2006-07-10 15:48:45 +02:00
|
|
|
|
2008-10-05 12:12:56 +02:00
|
|
|
if(!childNode) return E_INVALIDARG;
|
|
|
|
|
2008-07-10 15:22:21 +02:00
|
|
|
if(oldChild)
|
|
|
|
*oldChild = NULL;
|
2006-07-18 16:54:16 +02:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
child_node = get_node_obj(childNode);
|
|
|
|
if(!child_node) {
|
|
|
|
FIXME("childNode is not our node implementation\n");
|
|
|
|
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
|
|
|
{
|
|
|
|
WARN("childNode %p is not a child of %p\n", childNode, iface);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlUnlinkNode(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
|
|
|
{
|
|
|
|
IXMLDOMNode_AddRef(childNode);
|
2008-07-10 15:22:21 +02:00
|
|
|
*oldChild = childNode;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_appendChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode** outNewChild)
|
|
|
|
{
|
2006-01-11 21:15:12 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
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
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, newChild, outNewChild);
|
2008-01-03 23:15:00 +01:00
|
|
|
|
2008-07-08 20:53:58 +02:00
|
|
|
hr = IXMLDOMNode_get_nodeType(newChild, &type);
|
|
|
|
if(FAILED(hr) || type == NODE_ATTRIBUTE) {
|
|
|
|
if(outNewChild) *outNewChild = NULL;
|
|
|
|
return E_FAIL;
|
2008-01-03 23:15:00 +01:00
|
|
|
}
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
VariantInit(&var);
|
2010-09-04 17:56:08 +02:00
|
|
|
return IXMLDOMNode_insertBefore(This->iface, newChild, var, outNewChild);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_hasChildNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* hasChild)
|
|
|
|
{
|
2005-08-22 11:24:44 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, hasChild);
|
2005-08-22 11:24:44 +02:00
|
|
|
|
|
|
|
if (!hasChild)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (!This->node->children)
|
|
|
|
{
|
|
|
|
*hasChild = VARIANT_FALSE;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*hasChild = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_ownerDocument(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMDocument** DOMDocument)
|
|
|
|
{
|
2008-07-08 20:56:28 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, DOMDocument);
|
2008-07-08 20:56:28 +02:00
|
|
|
|
2010-08-29 23:31:49 +02:00
|
|
|
return DOMDocument_create_from_xmldoc(This->node->doc, (IXMLDOMDocument3**)DOMDocument);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_cloneNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL deep,
|
|
|
|
IXMLDOMNode** cloneRoot)
|
|
|
|
{
|
2007-12-02 22:17:48 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlNodePtr pClone = NULL;
|
|
|
|
IXMLDOMNode *pNode = NULL;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, deep, cloneRoot);
|
2007-12-02 22:17:48 +01:00
|
|
|
|
|
|
|
if(!cloneRoot)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pClone = xmlCopyNode(This->node, deep ? 1 : 2);
|
|
|
|
if(pClone)
|
|
|
|
{
|
|
|
|
pClone->doc = This->node->doc;
|
2008-10-11 23:59:25 +02:00
|
|
|
xmldoc_add_orphan(pClone->doc, pClone);
|
2007-12-02 22:17:48 +01:00
|
|
|
|
|
|
|
pNode = create_node(pClone);
|
|
|
|
if(!pNode)
|
|
|
|
{
|
|
|
|
ERR("Copy failed\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cloneRoot = pNode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Copy failed\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeTypeString(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* xmlnodeType)
|
|
|
|
{
|
2008-01-16 06:47:19 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
const xmlChar *str;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, xmlnodeType );
|
2008-01-16 06:47:19 +01:00
|
|
|
|
|
|
|
if (!xmlnodeType)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ( !This->node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
str = (const xmlChar*) "attribute";
|
|
|
|
break;
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
str = (const xmlChar*) "cdatasection";
|
|
|
|
break;
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
str = (const xmlChar*) "comment";
|
|
|
|
break;
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
str = (const xmlChar*) "document";
|
|
|
|
break;
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
str = (const xmlChar*) "documentfragment";
|
|
|
|
break;
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
str = (const xmlChar*) "element";
|
|
|
|
break;
|
|
|
|
case XML_ENTITY_NODE:
|
|
|
|
str = (const xmlChar*) "entity";
|
|
|
|
break;
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
str = (const xmlChar*) "entityreference";
|
|
|
|
break;
|
|
|
|
case XML_NOTATION_NODE:
|
|
|
|
str = (const xmlChar*) "notation";
|
|
|
|
break;
|
|
|
|
case XML_PI_NODE:
|
|
|
|
str = (const xmlChar*) "processinginstruction";
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
str = (const xmlChar*) "text";
|
|
|
|
break;
|
|
|
|
default:
|
2008-09-03 05:04:50 +02:00
|
|
|
FIXME("Unknown node type (%d)\n", This->node->type);
|
2008-01-16 06:47:19 +01:00
|
|
|
str = This->node->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*xmlnodeType = bstr_from_xmlChar( str );
|
|
|
|
if (!*xmlnodeType)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* text)
|
|
|
|
{
|
2005-08-18 12:48:13 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
BSTR str = NULL;
|
2008-12-23 09:29:33 +01:00
|
|
|
xmlChar *pContent;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p, type %d)->(%p)\n", This, This->node->type, text);
|
2005-08-18 12:48:13 +02:00
|
|
|
|
|
|
|
if ( !text )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-12-23 09:29:33 +01:00
|
|
|
pContent = xmlNodeGetContent((xmlNodePtr)This->node);
|
|
|
|
if(pContent)
|
2006-02-16 19:33:39 +01:00
|
|
|
{
|
2008-12-23 09:29:33 +01:00
|
|
|
str = bstr_from_xmlChar(pContent);
|
|
|
|
xmlFree(pContent);
|
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
|
|
|
|
2009-01-26 11:01:02 +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-10-19 01:27:48 +02:00
|
|
|
static HRESULT WINAPI xmlnode_put_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR text)
|
|
|
|
{
|
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_specified(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* isSpecified)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2010-03-30 19:56:44 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isSpecified);
|
|
|
|
*isSpecified = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_definition(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** definitionNode)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
FIXME("(%p)->(%p)\n", This, definitionNode);
|
2005-08-10 11:54:22 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:02:06 +01:00
|
|
|
static inline BYTE hex_to_byte(xmlChar c)
|
2009-11-19 20:50:33 +01:00
|
|
|
{
|
|
|
|
if(c <= '9') return c-'0';
|
|
|
|
if(c <= 'F') return c-'A'+10;
|
|
|
|
return c-'a'+10;
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:02:06 +01:00
|
|
|
static inline BYTE base64_to_byte(xmlChar c)
|
2009-11-19 20:50:41 +01:00
|
|
|
{
|
|
|
|
if(c == '+') return 62;
|
|
|
|
if(c == '/') return 63;
|
|
|
|
if(c <= '9') return c-'0'+52;
|
|
|
|
if(c <= 'Z') return c-'A';
|
|
|
|
return c-'a'+26;
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:02:06 +01:00
|
|
|
static inline HRESULT VARIANT_from_xmlChar(xmlChar *str, VARIANT *v, BSTR type)
|
2009-11-18 00:51:03 +01:00
|
|
|
{
|
2009-11-18 00:51:11 +01:00
|
|
|
if(!type || !lstrcmpiW(type, szString) ||
|
2009-11-19 20:50:22 +01:00
|
|
|
!lstrcmpiW(type, szNumber) || !lstrcmpiW(type, szUUID))
|
2009-11-18 00:51:03 +01:00
|
|
|
{
|
|
|
|
V_VT(v) = VT_BSTR;
|
|
|
|
V_BSTR(v) = bstr_from_xmlChar(str);
|
|
|
|
|
|
|
|
if(!V_BSTR(v))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2009-11-18 00:51:40 +01:00
|
|
|
else if(!lstrcmpiW(type, szDateTime) || !lstrcmpiW(type, szDateTimeTZ) ||
|
|
|
|
!lstrcmpiW(type, szDate) || !lstrcmpiW(type, szTime) ||
|
|
|
|
!lstrcmpiW(type, szTimeTZ))
|
|
|
|
{
|
|
|
|
VARIANT src;
|
|
|
|
WCHAR *p, *e;
|
|
|
|
SYSTEMTIME st;
|
|
|
|
DOUBLE date = 0.0;
|
|
|
|
|
|
|
|
st.wYear = 1899;
|
|
|
|
st.wMonth = 12;
|
|
|
|
st.wDay = 30;
|
|
|
|
st.wDayOfWeek = st.wHour = st.wMinute = st.wSecond = st.wMilliseconds = 0;
|
|
|
|
|
|
|
|
V_VT(&src) = VT_BSTR;
|
|
|
|
V_BSTR(&src) = bstr_from_xmlChar(str);
|
|
|
|
|
|
|
|
if(!V_BSTR(&src))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
p = V_BSTR(&src);
|
|
|
|
e = p + SysStringLen(V_BSTR(&src));
|
|
|
|
|
|
|
|
if(p+4<e && *(p+4)=='-') /* parse date (yyyy-mm-dd) */
|
|
|
|
{
|
|
|
|
st.wYear = atoiW(p);
|
|
|
|
st.wMonth = atoiW(p+5);
|
|
|
|
st.wDay = atoiW(p+8);
|
|
|
|
p += 10;
|
|
|
|
|
|
|
|
if(*p == 'T') p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p+2<e && *(p+2)==':') /* parse time (hh:mm:ss.?) */
|
|
|
|
{
|
|
|
|
st.wHour = atoiW(p);
|
|
|
|
st.wMinute = atoiW(p+3);
|
|
|
|
st.wSecond = atoiW(p+6);
|
|
|
|
p += 8;
|
|
|
|
|
|
|
|
if(*p == '.')
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
while(isdigitW(*p)) p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemTimeToVariantTime(&st, &date);
|
|
|
|
V_VT(v) = VT_DATE;
|
|
|
|
V_DATE(v) = date;
|
|
|
|
|
|
|
|
if(*p == '+') /* parse timezone offset (+hh:mm) */
|
|
|
|
V_DATE(v) += (DOUBLE)atoiW(p+1)/24 + (DOUBLE)atoiW(p+4)/1440;
|
|
|
|
else if(*p == '-') /* parse timezone offset (-hh:mm) */
|
|
|
|
V_DATE(v) -= (DOUBLE)atoiW(p+1)/24 + (DOUBLE)atoiW(p+4)/1440;
|
|
|
|
|
|
|
|
VariantClear(&src);
|
|
|
|
}
|
2009-11-19 20:50:33 +01:00
|
|
|
else if(!lstrcmpiW(type, szBinHex))
|
|
|
|
{
|
|
|
|
SAFEARRAYBOUND sab;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
len = xmlStrlen(str)/2;
|
|
|
|
sab.lLbound = 0;
|
|
|
|
sab.cElements = len;
|
|
|
|
|
|
|
|
V_VT(v) = (VT_ARRAY|VT_UI1);
|
|
|
|
V_ARRAY(v) = SafeArrayCreate(VT_UI1, 1, &sab);
|
|
|
|
|
|
|
|
if(!V_ARRAY(v))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
for(i=0; i<len; i++)
|
|
|
|
((BYTE*)V_ARRAY(v)->pvData)[i] = (hex_to_byte(str[2*i])<<4)
|
|
|
|
+ hex_to_byte(str[2*i+1]);
|
|
|
|
}
|
2009-11-19 20:50:41 +01:00
|
|
|
else if(!lstrcmpiW(type, szBinBase64))
|
|
|
|
{
|
|
|
|
SAFEARRAYBOUND sab;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
len = xmlStrlen(str);
|
|
|
|
if(str[len-2] == '=') i = 2;
|
|
|
|
else if(str[len-1] == '=') i = 1;
|
|
|
|
else i = 0;
|
|
|
|
|
|
|
|
sab.lLbound = 0;
|
|
|
|
sab.cElements = len/4*3-i;
|
|
|
|
|
|
|
|
V_VT(v) = (VT_ARRAY|VT_UI1);
|
|
|
|
V_ARRAY(v) = SafeArrayCreate(VT_UI1, 1, &sab);
|
|
|
|
|
|
|
|
if(!V_ARRAY(v))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
for(i=0; i<len/4; i++)
|
|
|
|
{
|
|
|
|
((BYTE*)V_ARRAY(v)->pvData)[3*i] = (base64_to_byte(str[4*i])<<2)
|
|
|
|
+ (base64_to_byte(str[4*i+1])>>4);
|
|
|
|
if(3*i+1 < sab.cElements)
|
|
|
|
((BYTE*)V_ARRAY(v)->pvData)[3*i+1] = (base64_to_byte(str[4*i+1])<<4)
|
|
|
|
+ (base64_to_byte(str[4*i+2])>>2);
|
|
|
|
if(3*i+2 < sab.cElements)
|
|
|
|
((BYTE*)V_ARRAY(v)->pvData)[3*i+2] = (base64_to_byte(str[4*i+2])<<6)
|
|
|
|
+ base64_to_byte(str[4*i+3]);
|
|
|
|
}
|
|
|
|
}
|
2009-11-18 00:51:03 +01:00
|
|
|
else
|
|
|
|
{
|
2009-11-18 00:51:17 +01:00
|
|
|
VARIANT src;
|
|
|
|
HRESULT hres;
|
2009-11-18 00:51:03 +01:00
|
|
|
|
2009-11-19 20:50:22 +01:00
|
|
|
if(!lstrcmpiW(type, szInt) || !lstrcmpiW(type, szI4))
|
2009-11-18 00:51:17 +01:00
|
|
|
V_VT(v) = VT_I4;
|
2009-11-18 00:51:24 +01:00
|
|
|
else if(!lstrcmpiW(type, szFixed))
|
|
|
|
V_VT(v) = VT_CY;
|
2009-11-18 00:51:30 +01:00
|
|
|
else if(!lstrcmpiW(type, szBoolean))
|
|
|
|
V_VT(v) = VT_BOOL;
|
2009-11-18 19:02:07 +01:00
|
|
|
else if(!lstrcmpiW(type, szI1))
|
|
|
|
V_VT(v) = VT_I1;
|
2009-11-19 20:50:22 +01:00
|
|
|
else if(!lstrcmpiW(type, szI2))
|
|
|
|
V_VT(v) = VT_I2;
|
|
|
|
else if(!lstrcmpiW(type, szIU1))
|
|
|
|
V_VT(v) = VT_UI1;
|
|
|
|
else if(!lstrcmpiW(type, szIU2))
|
|
|
|
V_VT(v) = VT_UI2;
|
|
|
|
else if(!lstrcmpiW(type, szIU4))
|
|
|
|
V_VT(v) = VT_UI4;
|
|
|
|
else if(!lstrcmpiW(type, szR4))
|
|
|
|
V_VT(v) = VT_R4;
|
|
|
|
else if(!lstrcmpiW(type, szR8) || !lstrcmpiW(type, szFloat))
|
|
|
|
V_VT(v) = VT_R8;
|
2009-11-18 00:51:17 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Type handling not yet implemented\n");
|
|
|
|
V_VT(v) = VT_BSTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(&src) = VT_BSTR;
|
|
|
|
V_BSTR(&src) = bstr_from_xmlChar(str);
|
|
|
|
|
|
|
|
if(!V_BSTR(&src))
|
2009-11-18 00:51:03 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2009-11-18 00:51:17 +01:00
|
|
|
|
2009-12-06 01:07:57 +01:00
|
|
|
hres = VariantChangeTypeEx(v, &src, MAKELCID(MAKELANGID(
|
|
|
|
LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),0, V_VT(v));
|
2009-11-18 00:51:17 +01:00
|
|
|
VariantClear(&src);
|
|
|
|
return hres;
|
2009-11-18 00:51:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeTypedValue(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* typedValue)
|
|
|
|
{
|
2008-10-28 09:47:15 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2009-11-18 00:51:03 +01:00
|
|
|
VARIANT type;
|
|
|
|
xmlChar *content;
|
|
|
|
HRESULT hres = S_FALSE;
|
2008-10-28 09:47:15 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, typedValue);
|
2008-10-28 09:47:15 +01:00
|
|
|
|
|
|
|
if(!typedValue)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
V_VT(typedValue) = VT_NULL;
|
|
|
|
|
2009-11-18 00:51:03 +01:00
|
|
|
if(This->node->type == XML_ELEMENT_NODE ||
|
|
|
|
This->node->type == XML_TEXT_NODE ||
|
|
|
|
This->node->type == XML_ENTITY_REF_NODE)
|
2010-09-04 17:56:08 +02:00
|
|
|
hres = IXMLDOMNode_get_dataType(This->iface, &type);
|
2008-10-28 09:47:15 +01:00
|
|
|
|
2009-11-18 00:51:03 +01:00
|
|
|
if(hres != S_OK && This->node->type != XML_ELEMENT_NODE)
|
2010-09-04 17:56:08 +02:00
|
|
|
return IXMLDOMNode_get_nodeValue(This->iface, typedValue);
|
2009-11-18 00:51:03 +01:00
|
|
|
|
|
|
|
content = xmlNodeGetContent(This->node);
|
|
|
|
hres = VARIANT_from_xmlChar(content, typedValue,
|
|
|
|
hres==S_OK ? V_BSTR(&type) : NULL);
|
|
|
|
xmlFree(content);
|
|
|
|
VariantClear(&type);
|
|
|
|
|
|
|
|
return hres;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_put_nodeTypedValue(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT typedValue)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
FIXME("%p\n", This);
|
2005-08-10 11:54:22 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* dataTypeName)
|
|
|
|
{
|
2010-10-19 01:13:30 +02:00
|
|
|
ERR("Should not be called\n");
|
|
|
|
return E_NOTIMPL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_put_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR dataTypeName)
|
|
|
|
{
|
2008-02-20 06:03:41 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(dataTypeName));
|
2008-02-20 06:03:41 +01:00
|
|
|
|
|
|
|
if(dataTypeName == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* An example of this is. The Text in the node needs to be a 0 or 1 for a boolean type.
|
|
|
|
This applies to changing types (string->bool) or setting a new one
|
|
|
|
*/
|
|
|
|
FIXME("Need to Validate the data before allowing a type to be set.\n");
|
|
|
|
|
|
|
|
/* Check all supported types. */
|
|
|
|
if(lstrcmpiW(dataTypeName,szString) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szNumber) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szUUID) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szInt) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szI4) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szFixed) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szBoolean) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szDateTime) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szDateTimeTZ) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szDate) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szTime) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szTimeTZ) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szI1) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szI2) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szIU1) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szIU2) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szIU4) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szR4) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szR8) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szFloat) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szBinHex) == 0 ||
|
|
|
|
lstrcmpiW(dataTypeName,szBinBase64) == 0)
|
|
|
|
{
|
2009-01-26 11:01:02 +01:00
|
|
|
xmlChar* str = xmlChar_from_wchar(dataTypeName);
|
2010-09-14 06:55:40 +02:00
|
|
|
xmlAttrPtr attr;
|
2008-02-20 06:03:41 +01:00
|
|
|
|
2010-09-14 06:55:40 +02:00
|
|
|
if (!str) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
attr = xmlHasNsProp(This->node, (const xmlChar*)"dt",
|
2010-03-27 16:19:45 +01:00
|
|
|
(const xmlChar*)"urn:schemas-microsoft-com:datatypes");
|
2010-09-14 06:55:40 +02:00
|
|
|
if (attr)
|
2008-02-20 06:03:41 +01:00
|
|
|
{
|
2010-09-14 06:55:40 +02:00
|
|
|
attr = xmlSetNsProp(This->node, attr->ns, (const xmlChar*)"dt", str);
|
2008-02-20 06:03:41 +01:00
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-14 06:55:40 +02:00
|
|
|
xmlNsPtr ns = xmlNewNs(This->node, (const xmlChar*)"urn:schemas-microsoft-com:datatypes", (const xmlChar*)"dt");
|
|
|
|
if (ns)
|
2008-02-20 06:03:41 +01:00
|
|
|
{
|
2010-09-14 06:55:40 +02:00
|
|
|
attr = xmlNewNsProp(This->node, ns, (const xmlChar*)"dt", str);
|
|
|
|
if (attr)
|
2008-02-20 06:03:41 +01:00
|
|
|
{
|
2010-09-14 06:55:40 +02:00
|
|
|
xmlAddChild(This->node, (xmlNodePtr)attr);
|
2008-02-20 06:03:41 +01:00
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Failed to create Attribute\n");
|
|
|
|
}
|
|
|
|
else
|
2010-09-14 06:55:40 +02:00
|
|
|
ERR("Failed to create Namespace\n");
|
2008-02-20 06:03:41 +01:00
|
|
|
}
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( str );
|
2008-02-20 06:03:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2008-07-26 13:06:41 +02:00
|
|
|
static BSTR EnsureCorrectEOL(BSTR sInput)
|
|
|
|
{
|
|
|
|
int nNum = 0;
|
|
|
|
BSTR sNew;
|
|
|
|
int nLen;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
nLen = lstrlenW(sInput);
|
|
|
|
/* 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;
|
|
|
|
sNew = SysAllocStringLen(NULL, nLen + nNum+1);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("len %d\n", lstrlenW(sNew));
|
|
|
|
|
|
|
|
return sNew;
|
|
|
|
}
|
|
|
|
|
2008-09-19 16:01:14 +02:00
|
|
|
/* Removes encoding information and last character (nullbyte) */
|
|
|
|
static BSTR EnsureNoEncoding(BSTR sInput)
|
|
|
|
{
|
|
|
|
static const WCHAR wszEncoding[] = {'e','n','c','o','d','i','n','g','='};
|
|
|
|
BSTR sNew;
|
|
|
|
WCHAR *pBeg, *pEnd;
|
|
|
|
|
|
|
|
pBeg = sInput;
|
|
|
|
while(*pBeg != '\n' && memcmp(pBeg, wszEncoding, sizeof(wszEncoding)))
|
|
|
|
pBeg++;
|
|
|
|
|
|
|
|
if(*pBeg == '\n')
|
|
|
|
{
|
|
|
|
SysReAllocStringLen(&sInput, sInput, SysStringLen(sInput)-1);
|
|
|
|
return sInput;
|
|
|
|
}
|
|
|
|
pBeg--;
|
|
|
|
|
|
|
|
pEnd = pBeg + sizeof(wszEncoding)/sizeof(WCHAR) + 2;
|
|
|
|
while(*pEnd != '\"') pEnd++;
|
|
|
|
pEnd++;
|
|
|
|
|
|
|
|
sNew = SysAllocStringLen(NULL,
|
|
|
|
pBeg-sInput + SysStringLen(sInput)-(pEnd-sInput)-1);
|
|
|
|
memcpy(sNew, sInput, (pBeg-sInput)*sizeof(WCHAR));
|
|
|
|
memcpy(&sNew[pBeg-sInput], pEnd, (SysStringLen(sInput)-(pEnd-sInput)-1)*sizeof(WCHAR));
|
|
|
|
|
|
|
|
SysFreeString(sInput);
|
|
|
|
return sNew;
|
|
|
|
}
|
|
|
|
|
2008-07-26 13:06:41 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_xml(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* xmlString)
|
|
|
|
{
|
2008-01-03 23:15:28 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlBufferPtr pXmlBuf;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlNodePtr xmldecl;
|
2008-01-03 23:15:28 +01:00
|
|
|
int nSize;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p %d)->(%p)\n", This, This->node->type, xmlString);
|
2008-01-03 23:15:28 +01:00
|
|
|
|
|
|
|
if(!xmlString)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*xmlString = NULL;
|
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldecl = xmldoc_unlink_xmldecl( This->node->doc );
|
|
|
|
|
2008-01-03 23:15:28 +01:00
|
|
|
pXmlBuf = xmlBufferCreate();
|
|
|
|
if(pXmlBuf)
|
|
|
|
{
|
2008-07-26 13:06:41 +02:00
|
|
|
nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 1);
|
2008-01-03 23:15:28 +01:00
|
|
|
if(nSize > 0)
|
|
|
|
{
|
|
|
|
const xmlChar *pContent;
|
2008-07-26 13:06:41 +02:00
|
|
|
BSTR bstrContent;
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2008-04-08 23:22:43 +02:00
|
|
|
/* Attribute Nodes return a space in front of their name */
|
2008-01-03 23:15:28 +01:00
|
|
|
pContent = xmlBufferContent(pXmlBuf);
|
2010-03-27 16:19:45 +01:00
|
|
|
if( ((const char*)pContent)[0] == ' ')
|
2008-07-26 13:06:41 +02:00
|
|
|
bstrContent = bstr_from_xmlChar(pContent+1);
|
2008-01-03 23:15:28 +01:00
|
|
|
else
|
2008-07-26 13:06:41 +02:00
|
|
|
bstrContent = bstr_from_xmlChar(pContent);
|
2008-01-03 23:15:28 +01:00
|
|
|
|
2008-09-19 16:01:14 +02:00
|
|
|
switch(This->node->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
*xmlString = EnsureCorrectEOL(bstrContent);
|
|
|
|
break;
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
*xmlString = EnsureCorrectEOL(bstrContent);
|
|
|
|
*xmlString = EnsureNoEncoding(*xmlString);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*xmlString = bstrContent;
|
|
|
|
}
|
2008-01-03 23:15:28 +01:00
|
|
|
}
|
2008-07-26 13:06:41 +02:00
|
|
|
|
|
|
|
xmlBufferFree(pXmlBuf);
|
2008-01-03 23:15:28 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldoc_link_xmldecl( This->node->doc, xmldecl );
|
|
|
|
|
2008-01-03 23:15:28 +01:00
|
|
|
/* Always returns a string. */
|
|
|
|
if(*xmlString == NULL) *xmlString = SysAllocStringLen( NULL, 0 );
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_transformNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* styleSheet,
|
|
|
|
BSTR* xmlString)
|
|
|
|
{
|
2008-11-17 19:29:32 +01:00
|
|
|
#ifdef SONAME_LIBXSLT
|
2008-03-26 09:52:36 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlnode *pStyleSheet = NULL;
|
|
|
|
xsltStylesheetPtr xsltSS = NULL;
|
|
|
|
xmlDocPtr result = NULL;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, styleSheet, xmlString);
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2008-11-17 19:29:32 +01:00
|
|
|
if (!libxslt_handle)
|
|
|
|
return E_NOTIMPL;
|
2008-03-26 09:52:36 +01:00
|
|
|
if(!styleSheet || !xmlString)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*xmlString = NULL;
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
pStyleSheet = get_node_obj(styleSheet);
|
|
|
|
if(!pStyleSheet) {
|
|
|
|
FIXME("styleSheet is not our xmlnode implementation\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xsltSS = pxsltParseStylesheetDoc( pStyleSheet->node->doc);
|
|
|
|
if(xsltSS)
|
|
|
|
{
|
|
|
|
result = pxsltApplyStylesheet(xsltSS, This->node->doc, NULL);
|
|
|
|
if(result)
|
2008-03-26 09:52:36 +01:00
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
const xmlChar *pContent;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(result->type == XML_HTML_DOCUMENT_NODE)
|
|
|
|
{
|
|
|
|
xmlOutputBufferPtr pOutput = xmlAllocOutputBuffer(NULL);
|
|
|
|
if(pOutput)
|
2008-03-26 09:52:36 +01:00
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
htmlDocContentDumpOutput(pOutput, result->doc, NULL);
|
|
|
|
pContent = xmlBufferContent(pOutput->buffer);
|
|
|
|
*xmlString = bstr_from_xmlChar(pContent);
|
|
|
|
xmlOutputBufferClose(pOutput);
|
2008-04-24 14:22:14 +02:00
|
|
|
}
|
2010-09-04 17:55:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlBufferPtr pXmlBuf;
|
|
|
|
int nSize;
|
2008-03-26 09:52:36 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
pXmlBuf = xmlBufferCreate();
|
|
|
|
if(pXmlBuf)
|
|
|
|
{
|
|
|
|
nSize = xmlNodeDump(pXmlBuf, NULL, (xmlNodePtr)result, 0, 0);
|
|
|
|
if(nSize > 0)
|
2008-04-24 14:22:14 +02:00
|
|
|
{
|
2010-09-04 17:55:04 +02:00
|
|
|
pContent = xmlBufferContent(pXmlBuf);
|
|
|
|
*xmlString = bstr_from_xmlChar(pContent);
|
2008-03-26 09:52:36 +01:00
|
|
|
}
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlBufferFree(pXmlBuf);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if(*xmlString == NULL)
|
|
|
|
*xmlString = SysAllocStringLen(NULL, 0);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_selectNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNodeList** resultList)
|
|
|
|
{
|
2005-09-03 11:39:38 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultList );
|
2005-09-03 11:39:38 +02:00
|
|
|
|
2010-09-16 21:41:00 +02:00
|
|
|
if (!queryString || !resultList) return E_INVALIDARG;
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
return queryresult_create( This->node, queryString, resultList );
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_selectSingleNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNode** resultNode)
|
|
|
|
{
|
2005-11-08 17:10:13 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
IXMLDOMNodeList *list;
|
|
|
|
HRESULT r;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(queryString), resultNode );
|
2005-11-08 17:10:13 +01:00
|
|
|
|
2010-09-04 17:56:08 +02:00
|
|
|
r = IXMLDOMNode_selectNodes(This->iface, queryString, &list);
|
2006-01-11 20:54:32 +01:00
|
|
|
if(r == S_OK)
|
2005-11-08 17:10:13 +01:00
|
|
|
{
|
|
|
|
r = IXMLDOMNodeList_nextNode(list, resultNode);
|
|
|
|
IXMLDOMNodeList_Release(list);
|
|
|
|
}
|
|
|
|
return r;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_parsed(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* isParsed)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2010-03-30 19:56:27 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isParsed);
|
|
|
|
*isParsed = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_namespaceURI(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* namespaceURI)
|
|
|
|
{
|
2008-04-18 13:29:59 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2010-09-14 07:01:16 +02:00
|
|
|
xmlNsPtr *ns;
|
2008-04-18 13:29:59 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, namespaceURI );
|
2008-04-18 13:29:59 +02:00
|
|
|
|
|
|
|
if(!namespaceURI)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*namespaceURI = NULL;
|
|
|
|
|
2010-09-14 07:01:16 +02:00
|
|
|
if ((ns = xmlGetNsList(This->node->doc, This->node)))
|
2008-04-18 13:29:59 +02:00
|
|
|
{
|
2010-09-14 07:01:16 +02:00
|
|
|
if (ns[0]->href) *namespaceURI = bstr_from_xmlChar( ns[0]->href );
|
|
|
|
xmlFree(ns);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_prefix(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* prefixString)
|
|
|
|
{
|
2008-04-18 13:23:22 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2010-09-14 07:00:02 +02:00
|
|
|
xmlNsPtr *ns;
|
2008-04-18 13:23:22 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, prefixString );
|
2008-04-18 13:23:22 +02:00
|
|
|
|
|
|
|
if(!prefixString)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*prefixString = NULL;
|
|
|
|
|
2010-09-14 07:00:02 +02:00
|
|
|
if ((ns = xmlGetNsList(This->node->doc, This->node)))
|
2008-04-18 13:23:22 +02:00
|
|
|
{
|
2010-09-14 07:00:02 +02:00
|
|
|
if (ns[0]->prefix) *prefixString = bstr_from_xmlChar( ns[0]->prefix );
|
|
|
|
xmlFree(ns);
|
2008-04-18 13:23:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-14 07:01:16 +02:00
|
|
|
TRACE("prefix: %s\n", debugstr_w(*prefixString));
|
2010-09-14 07:00:02 +02:00
|
|
|
|
|
|
|
return *prefixString ? S_OK : S_FALSE;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_baseName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* nameString)
|
|
|
|
{
|
2005-08-18 12:48:13 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
BSTR str = NULL;
|
|
|
|
HRESULT r = S_FALSE;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, nameString );
|
2005-08-18 12:48:13 +02:00
|
|
|
|
|
|
|
if ( !nameString )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch ( This->node->type )
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
2010-02-10 13:12:39 +01:00
|
|
|
case XML_PI_NODE:
|
2005-08-18 12:48:13 +02:00
|
|
|
str = bstr_from_xmlChar( This->node->name );
|
|
|
|
r = S_OK;
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
2010-02-09 16:07:54 +01:00
|
|
|
case XML_COMMENT_NODE:
|
2010-06-22 20:47:36 +02:00
|
|
|
case XML_DOCUMENT_NODE:
|
2005-08-18 12:48:13 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unhandled type %d\n", This->node->type );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-10-05 00:58:11 +02:00
|
|
|
TRACE("returning %08x str = %s\n", r, debugstr_w( str ) );
|
2005-08-18 12:48:13 +02:00
|
|
|
|
|
|
|
*nameString = str;
|
|
|
|
return r;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_transformNodeToObject(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* stylesheet,
|
|
|
|
VARIANT outputObject)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
FIXME("(%p)->(%p)\n", This, stylesheet);
|
2005-08-10 11:54:22 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMNodeVtbl xmlnode_vtbl =
|
|
|
|
{
|
|
|
|
xmlnode_QueryInterface,
|
|
|
|
xmlnode_AddRef,
|
|
|
|
xmlnode_Release,
|
|
|
|
xmlnode_GetTypeInfoCount,
|
|
|
|
xmlnode_GetTypeInfo,
|
|
|
|
xmlnode_GetIDsOfNames,
|
|
|
|
xmlnode_Invoke,
|
2005-08-17 11:53:08 +02:00
|
|
|
xmlnode_get_nodeName,
|
|
|
|
xmlnode_get_nodeValue,
|
|
|
|
xmlnode_put_nodeValue,
|
|
|
|
xmlnode_get_nodeType,
|
2005-08-10 11:54:22 +02:00
|
|
|
xmlnode_get_parentNode,
|
|
|
|
xmlnode_get_childNodes,
|
|
|
|
xmlnode_get_firstChild,
|
|
|
|
xmlnode_get_lastChild,
|
|
|
|
xmlnode_get_previousSibling,
|
|
|
|
xmlnode_get_nextSibling,
|
|
|
|
xmlnode_get_attributes,
|
|
|
|
xmlnode_insertBefore,
|
|
|
|
xmlnode_replaceChild,
|
|
|
|
xmlnode_removeChild,
|
|
|
|
xmlnode_appendChild,
|
|
|
|
xmlnode_hasChildNodes,
|
|
|
|
xmlnode_get_ownerDocument,
|
|
|
|
xmlnode_cloneNode,
|
2005-08-17 11:53:08 +02:00
|
|
|
xmlnode_get_nodeTypeString,
|
2005-08-10 11:54:22 +02:00
|
|
|
xmlnode_get_text,
|
|
|
|
xmlnode_put_text,
|
|
|
|
xmlnode_get_specified,
|
|
|
|
xmlnode_get_definition,
|
2005-08-17 11:53:08 +02:00
|
|
|
xmlnode_get_nodeTypedValue,
|
|
|
|
xmlnode_put_nodeTypedValue,
|
2005-08-10 11:54:22 +02:00
|
|
|
xmlnode_get_dataType,
|
|
|
|
xmlnode_put_dataType,
|
|
|
|
xmlnode_get_xml,
|
|
|
|
xmlnode_transformNode,
|
|
|
|
xmlnode_selectNodes,
|
|
|
|
xmlnode_selectSingleNode,
|
|
|
|
xmlnode_get_parsed,
|
|
|
|
xmlnode_get_namespaceURI,
|
|
|
|
xmlnode_get_prefix,
|
|
|
|
xmlnode_get_baseName,
|
|
|
|
xmlnode_transformNodeToObject,
|
|
|
|
};
|
|
|
|
|
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)
|
|
|
|
xmldoc_release(This->node->doc);
|
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)
|
|
|
|
xmldoc_add_ref( node->doc );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
This->lpVtbl = &xmlnode_vtbl;
|
2005-08-18 12:48:13 +02:00
|
|
|
This->node = node;
|
2010-09-04 17:54:13 +02:00
|
|
|
This->iface = node_iface;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
if(dispex_data)
|
2010-09-04 17:54:13 +02:00
|
|
|
init_dispex(&This->dispex, (IUnknown*)This->iface, dispex_data);
|
2010-09-04 17:54:46 +02:00
|
|
|
else
|
|
|
|
This->dispex.outer = NULL;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2010-09-04 17:55:27 +02:00
|
|
|
typedef struct {
|
|
|
|
xmlnode node;
|
|
|
|
const IXMLDOMNodeVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
} unknode;
|
|
|
|
|
|
|
|
static inline unknode *impl_from_unkIXMLDOMNode(IXMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return (unknode *)((char*)iface - FIELD_OFFSET(unknode, lpVtbl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_QueryInterface(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
*ppvObject = &This->lpVtbl;
|
|
|
|
}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 )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI unknode_Release(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_GetTypeInfo(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMNode_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_GetIDsOfNames(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMNode_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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 )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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 )
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( 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)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_appendChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_hasChildNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* pbool)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_ownerDocument(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMDocument** domDocument)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_cloneNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL pbool, IXMLDOMNode** outNode)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeTypeString(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_specified(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* pbool)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_definition(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** domNode)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_nodeTypedValue(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* var1)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_nodeTypedValue(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT var1)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* var1)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_put_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_xml(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_transformNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* domNode, BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_selectNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p, IXMLDOMNodeList** outList)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_selectSingleNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR p, IXMLDOMNode** outNode)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_parsed(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* pbool)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_namespaceURI(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_prefix(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_get_baseName(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* p)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI unknode_transformNodeToObject(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* domNode, VARIANT var1)
|
|
|
|
{
|
|
|
|
unknode *This = impl_from_unkIXMLDOMNode( iface );
|
|
|
|
return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
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;
|
|
|
|
|
2010-09-04 17:55:27 +02:00
|
|
|
new_node->lpVtbl = &unknode_vtbl;
|
|
|
|
new_node->ref = 1;
|
|
|
|
init_xmlnode(&new_node->node, node, (IXMLDOMNode*)&new_node->lpVtbl, NULL);
|
|
|
|
pUnk = (IUnknown*)&new_node->lpVtbl;
|
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
|