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"
|
2005-11-08 20:59:36 +01:00
|
|
|
#include "msxml2.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
|
|
|
|
|
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 szByte[] = {'B','y','t','e',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};
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
static inline xmlnode *impl_from_InternalUnknown( IUnknown *iface )
|
|
|
|
{
|
|
|
|
return (xmlnode *)((char*)iface - FIELD_OFFSET(xmlnode, lpInternalUnkVtbl));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
This = impl_from_IXMLDOMNode( iface );
|
2005-08-18 12:48:13 +02:00
|
|
|
if ( !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
|
|
|
}
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
void attach_xmlnode( IXMLDOMNode *node, xmlNodePtr xml )
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( node );
|
|
|
|
|
|
|
|
if(This->node)
|
|
|
|
xmldoc_release(This->node->doc);
|
|
|
|
|
|
|
|
This->node = xml;
|
|
|
|
if(This->node)
|
|
|
|
xmldoc_add_ref(This->node->doc);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_QueryInterface(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
|
|
|
{
|
2005-12-01 18:46:42 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnode_AddRef(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2005-12-01 18:46:42 +01:00
|
|
|
return IUnknown_AddRef(This->pUnkOuter);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnode_Release(
|
|
|
|
IXMLDOMNode *iface )
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2005-12-01 18:46:42 +01:00
|
|
|
return IUnknown_Release(This->pUnkOuter);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetTypeInfoCount(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetTypeInfo(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_GetIDsOfNames(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_Invoke(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr )
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeName(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* name)
|
|
|
|
{
|
2005-11-02 11:55:03 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
const xmlChar *str;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
2005-11-02 20:55:30 +01:00
|
|
|
if (!name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-11-02 11:55:03 +01:00
|
|
|
if ( !This->node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
2008-01-03 23:12:21 +01:00
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
str = (const xmlChar*) "#cdata-section";
|
|
|
|
break;
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
str = (const xmlChar*) "#comment";
|
2005-11-02 11:55:03 +01:00
|
|
|
break;
|
2008-01-03 23:12:21 +01:00
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
str = (const xmlChar*) "#document-fragment";
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
str = (const xmlChar*) "#text";
|
|
|
|
break;
|
2005-11-02 20:55:30 +01:00
|
|
|
case XML_DOCUMENT_NODE:
|
2008-01-03 23:12:21 +01:00
|
|
|
str = (const xmlChar*) "#document";
|
|
|
|
break;
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
case XML_ELEMENT_NODE:
|
2008-03-01 13:20:20 +01:00
|
|
|
case XML_PI_NODE:
|
|
|
|
str = This->node->name;
|
2008-01-03 23:12:21 +01:00
|
|
|
break;
|
2005-11-02 11:55:03 +01:00
|
|
|
default:
|
2008-01-03 23:12:21 +01:00
|
|
|
FIXME("nodeName not mapped correctly (%d)\n", This->node->type);
|
2005-11-02 11:55:03 +01:00
|
|
|
str = This->node->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*name = bstr_from_xmlChar( str );
|
|
|
|
if (!*name)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BSTR bstr_from_xmlChar( const xmlChar *buf )
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR str;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
if ( !buf )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, NULL, 0 );
|
|
|
|
str = (LPWSTR) HeapAlloc( GetProcessHeap(), 0, len * sizeof (WCHAR) );
|
|
|
|
if ( !str )
|
|
|
|
return NULL;
|
|
|
|
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) buf, -1, str, len );
|
|
|
|
bstr = SysAllocString( str );
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
return bstr;
|
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_nodeValue(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* value)
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2005-08-18 12:48:13 +02:00
|
|
|
HRESULT r = S_FALSE;
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", This, value);
|
|
|
|
|
2008-01-03 06:02:36 +01:00
|
|
|
if(!value)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
V_BSTR(value) = NULL;
|
|
|
|
V_VT(value) = VT_NULL;
|
|
|
|
|
|
|
|
switch ( This->node->type )
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2008-03-01 12:51:00 +01:00
|
|
|
case XML_CDATA_SECTION_NODE:
|
2008-02-28 11:03:59 +01:00
|
|
|
case XML_COMMENT_NODE:
|
2008-02-20 12:34:01 +01:00
|
|
|
case XML_PI_NODE:
|
2005-08-10 11:54:22 +02:00
|
|
|
case XML_ATTRIBUTE_NODE:
|
2006-01-16 20:43:02 +01:00
|
|
|
{
|
|
|
|
xmlChar *content = xmlNodeGetContent(This->node);
|
2005-08-10 11:54:22 +02:00
|
|
|
V_VT(value) = VT_BSTR;
|
2006-01-16 20:43:02 +01:00
|
|
|
V_BSTR(value) = bstr_from_xmlChar( content );
|
|
|
|
xmlFree(content);
|
2005-08-18 12:48:13 +02:00
|
|
|
r = S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
break;
|
2006-01-16 20:43:02 +01:00
|
|
|
}
|
2005-08-18 12:48:13 +02:00
|
|
|
case XML_TEXT_NODE:
|
|
|
|
V_VT(value) = VT_BSTR;
|
|
|
|
V_BSTR(value) = bstr_from_xmlChar( This->node->content );
|
|
|
|
r = S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
break;
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
case XML_DOCUMENT_NODE:
|
2005-08-18 12:48:13 +02:00
|
|
|
/* these seem to return NULL */
|
2005-08-10 11:54:22 +02:00
|
|
|
break;
|
2008-02-20 12:34:01 +01:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
default:
|
|
|
|
FIXME("node %p type %d\n", This, This->node->type);
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%p returned %s\n", This, debugstr_w( V_BSTR(value) ) );
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
return r;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
2005-08-17 11:53:08 +02:00
|
|
|
static HRESULT WINAPI xmlnode_put_nodeValue(
|
2005-08-10 11:54:22 +02:00
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT value)
|
|
|
|
{
|
2008-02-25 09:56:22 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
xmlChar *str = NULL;
|
|
|
|
|
2008-02-26 11:17:05 +01:00
|
|
|
TRACE("%p type(%d)\n", This, This->node->type);
|
2008-02-25 09:56:22 +01:00
|
|
|
|
|
|
|
/* Document, Document Fragment, Document Type, Element,
|
|
|
|
Entity, Entity Reference, Notation arent supported. */
|
|
|
|
switch ( This->node->type )
|
|
|
|
{
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
case XML_PI_NODE:
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
{
|
|
|
|
str = xmlChar_from_wchar((WCHAR*)V_BSTR(&value));
|
|
|
|
|
|
|
|
xmlNodeSetContent(This->node, str);
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
/* Do nothing for unsupported types. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
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)
|
|
|
|
{
|
2005-08-18 12:48:13 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
|
|
|
|
TRACE("%p %p\n", This, type);
|
|
|
|
|
|
|
|
assert( NODE_ELEMENT == XML_ELEMENT_NODE );
|
|
|
|
assert( NODE_NOTATION == XML_NOTATION_NODE );
|
|
|
|
|
|
|
|
*type = This->node->type;
|
|
|
|
|
|
|
|
return S_OK;
|
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 )
|
|
|
|
{
|
|
|
|
TRACE("%p->%s %p\n", This, name, node );
|
|
|
|
|
|
|
|
if ( !out )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*out = create_node( node );
|
|
|
|
if (!*out)
|
|
|
|
return S_FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
static HRESULT WINAPI xmlnode_get_parentNode(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** parent)
|
|
|
|
{
|
2005-08-19 13:22:47 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
return get_node( This, "parent", This->node->parent, parent );
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_childNodes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNodeList** childList)
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2005-08-18 12:48:13 +02:00
|
|
|
|
|
|
|
TRACE("%p %p\n", This, childList );
|
|
|
|
|
|
|
|
if ( !childList )
|
|
|
|
return E_INVALIDARG;
|
2005-11-05 11:42:45 +01:00
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
*childList = create_children_nodelist(This->node);
|
|
|
|
if (*childList == NULL)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_firstChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** firstChild)
|
|
|
|
{
|
2005-08-19 13:22:47 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
return get_node( This, "firstChild", This->node->children, firstChild );
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_lastChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** lastChild)
|
|
|
|
{
|
2005-08-19 13:22:47 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2008-01-08 00:28:57 +01:00
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
if (!lastChild)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
|
|
|
/* CDATASection, Comment, PI and Text Nodes do not support lastChild */
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
case XML_PI_NODE:
|
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
*lastChild = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
default:
|
|
|
|
return get_node( This, "lastChild", This->node->last, lastChild );
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_previousSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** previousSibling)
|
|
|
|
{
|
2005-08-19 13:22:47 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2008-01-08 01:34:29 +01:00
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
if (!previousSibling)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
|
|
|
/* Attribute, Document and Document Fragment Nodes do not support previousSibling */
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
*previousSibling = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
default:
|
|
|
|
return get_node( This, "previous", This->node->prev, previousSibling );
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_nextSibling(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** nextSibling)
|
|
|
|
{
|
2005-08-19 13:22:47 +02:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2008-01-07 23:59:01 +01:00
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
if (!nextSibling)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
|
|
|
/* Attribute, Document and Document Fragment Nodes do not support nextSibling */
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
*nextSibling = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
default:
|
|
|
|
return get_node( This, "next", This->node->next, nextSibling );
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_attributes(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNamedNodeMap** attributeMap)
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
2005-08-18 12:48:13 +02:00
|
|
|
TRACE("%p\n", This);
|
2008-01-08 02:43:34 +01:00
|
|
|
|
|
|
|
if (!attributeMap)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch( This->node->type )
|
|
|
|
{
|
|
|
|
/* Attribute, CDataSection, Comment, Documents, Documents Fragments,
|
|
|
|
Entity and Text Nodes does not support get_attributes */
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
2008-01-14 03:15:58 +01:00
|
|
|
case XML_CDATA_SECTION_NODE:
|
2008-01-08 02:43:34 +01:00
|
|
|
case XML_COMMENT_NODE:
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
case XML_DOCUMENT_FRAG_NODE:
|
|
|
|
case XML_ENTITY_NODE:
|
2008-01-20 12:50:36 +01:00
|
|
|
case XML_ENTITY_REF_NODE:
|
2008-01-08 02:43:34 +01:00
|
|
|
case XML_TEXT_NODE:
|
|
|
|
*attributeMap = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
default:
|
|
|
|
*attributeMap = create_nodemap( iface );
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_insertBefore(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
VARIANT refChild,
|
|
|
|
IXMLDOMNode** outNewChild)
|
|
|
|
{
|
2006-01-11 21:15:12 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlNodePtr before_node, new_child_node;
|
|
|
|
IXMLDOMNode *before = NULL, *new;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,var,%p)\n",This,newChild,outNewChild);
|
|
|
|
|
2007-11-14 06:05:17 +01:00
|
|
|
if (!newChild)
|
2006-11-02 10:42:05 +01:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
switch(V_VT(&refChild))
|
|
|
|
{
|
|
|
|
case VT_EMPTY:
|
|
|
|
case VT_NULL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&refChild), &IID_IXMLDOMNode, (LPVOID)&before);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_DISPATCH:
|
|
|
|
hr = IDispatch_QueryInterface(V_DISPATCH(&refChild), &IID_IXMLDOMNode, (LPVOID)&before);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("refChild var type %x\n", V_VT(&refChild));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMNode_QueryInterface(newChild, &IID_IXMLDOMNode, (LPVOID)&new);
|
|
|
|
new_child_node = impl_from_IXMLDOMNode(new)->node;
|
|
|
|
TRACE("new_child_node %p This->node %p\n", new_child_node, This->node);
|
|
|
|
|
|
|
|
if(before)
|
|
|
|
{
|
|
|
|
before_node = impl_from_IXMLDOMNode(before)->node;
|
|
|
|
xmlAddPrevSibling(before_node, new_child_node);
|
|
|
|
IXMLDOMNode_Release(before);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlAddChild(This->node, new_child_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMNode_Release(new);
|
|
|
|
IXMLDOMNode_AddRef(newChild);
|
2007-11-14 06:05:17 +01:00
|
|
|
if(outNewChild)
|
|
|
|
*outNewChild = newChild;
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
TRACE("ret S_OK\n");
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_replaceChild(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode* oldChild,
|
|
|
|
IXMLDOMNode** outOldChild)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
xmlNode *ancestor, *child_node_ptr;
|
|
|
|
HRESULT hr;
|
|
|
|
IXMLDOMNode *child;
|
|
|
|
|
|
|
|
TRACE("%p->(%p, %p)\n", This, childNode, oldChild);
|
|
|
|
|
|
|
|
*oldChild = NULL;
|
2006-07-18 16:54:16 +02:00
|
|
|
|
|
|
|
if(!childNode) return E_INVALIDARG;
|
|
|
|
|
2006-07-10 15:48:45 +02:00
|
|
|
hr = IXMLDOMNode_QueryInterface(childNode, &IID_IXMLDOMNode, (LPVOID)&child);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
child_node_ptr = ancestor = impl_from_IXMLDOMNode(child)->node;
|
|
|
|
while(ancestor->parent)
|
|
|
|
{
|
|
|
|
if(ancestor->parent == This->node)
|
|
|
|
break;
|
|
|
|
ancestor = ancestor->parent;
|
|
|
|
}
|
|
|
|
if(!ancestor->parent)
|
|
|
|
{
|
|
|
|
WARN("childNode %p is not a child of %p\n", childNode, iface);
|
|
|
|
IXMLDOMNode_Release(child);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlUnlinkNode(child_node_ptr);
|
|
|
|
|
|
|
|
IXMLDOMNode_Release(child);
|
|
|
|
IXMLDOMNode_AddRef(childNode);
|
|
|
|
*oldChild = childNode;
|
|
|
|
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-01-03 23:15:00 +01:00
|
|
|
IXMLDOMNode *pAttr = NULL;
|
2006-01-11 21:15:12 +01:00
|
|
|
VARIANT var;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%p)\n", This, newChild, outNewChild);
|
2008-01-03 23:15:00 +01:00
|
|
|
|
|
|
|
/* Cannot Append an Attribute node. */
|
|
|
|
IUnknown_QueryInterface(newChild, &IID_IXMLDOMNode, (LPVOID*)&pAttr);
|
|
|
|
if(pAttr)
|
|
|
|
{
|
|
|
|
xmlnode *ThisNew = impl_from_IXMLDOMNode( pAttr );
|
|
|
|
|
|
|
|
if(ThisNew->node->type == XML_ATTRIBUTE_NODE)
|
|
|
|
{
|
|
|
|
if(outNewChild) *outNewChild = NULL;
|
|
|
|
|
|
|
|
IUnknown_Release(pAttr);
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_Release(pAttr);
|
|
|
|
}
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
VariantInit(&var);
|
|
|
|
return IXMLDOMNode_insertBefore(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 );
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("%p (%d)\n", This, deep);
|
|
|
|
|
|
|
|
if(!cloneRoot)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pClone = xmlCopyNode(This->node, deep ? 1 : 2);
|
|
|
|
if(pClone)
|
|
|
|
{
|
|
|
|
pClone->doc = This->node->doc;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
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:
|
|
|
|
FIXME("nodeName not mapped correctly (%d)\n", This->node->type);
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
|
|
|
if ( !text )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2006-02-16 19:33:39 +01:00
|
|
|
switch(This->node->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
{
|
|
|
|
xmlNodePtr child = This->node->children;
|
|
|
|
if ( child && child->type == XML_TEXT_NODE )
|
|
|
|
str = bstr_from_xmlChar( child->content );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case XML_TEXT_NODE:
|
2007-07-12 16:33:36 +02:00
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
case XML_PI_NODE:
|
|
|
|
case XML_COMMENT_NODE:
|
2006-02-16 19:33:39 +01:00
|
|
|
str = bstr_from_xmlChar( This->node->content );
|
|
|
|
break;
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2006-02-16 19:33:39 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled node type %d\n", This->node->type);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_put_text(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR text)
|
|
|
|
{
|
2008-01-16 03:44:51 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlChar *str = NULL;
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
|
|
|
switch(This->node->type)
|
|
|
|
{
|
|
|
|
case XML_DOCUMENT_NODE:
|
|
|
|
return E_FAIL;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = xmlChar_from_wchar((WCHAR*)text);
|
|
|
|
|
|
|
|
/* Escape the string. */
|
|
|
|
str = xmlEncodeEntitiesReentrant(This->node->doc, str);
|
|
|
|
str = xmlEncodeSpecialChars(This->node->doc, str);
|
|
|
|
|
|
|
|
xmlNodeSetContent(This->node, str);
|
|
|
|
xmlFree(str);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_specified(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT_BOOL* isSpecified)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_definition(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
IXMLDOMNode** definitionNode)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2006-01-18 14:22:23 +01:00
|
|
|
FIXME("ignoring data type\n");
|
|
|
|
return xmlnode_get_nodeValue(iface, typedValue);
|
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)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_dataType(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
VARIANT* dataTypeName)
|
|
|
|
{
|
2008-01-14 02:44:56 +01:00
|
|
|
xmlnode *This = impl_from_IXMLDOMNode( iface );
|
|
|
|
xmlChar *pVal;
|
|
|
|
|
|
|
|
TRACE("iface %p\n", iface);
|
|
|
|
|
|
|
|
if(!dataTypeName)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2008-01-18 03:06:31 +01:00
|
|
|
/* Attribute, CDATA Section, Comment, Document, Document Fragment,
|
2008-01-14 02:44:56 +01:00
|
|
|
Entity, Notation, PI, and Text Node are non-typed. */
|
|
|
|
V_BSTR(dataTypeName) = NULL;
|
|
|
|
V_VT(dataTypeName) = VT_NULL;
|
|
|
|
|
|
|
|
switch ( This->node->type )
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
pVal = xmlGetNsProp(This->node, (xmlChar*)"dt",
|
|
|
|
(xmlChar*)"urn:schemas-microsoft-com:datatypes");
|
|
|
|
if (pVal)
|
|
|
|
{
|
|
|
|
V_VT(dataTypeName) = VT_BSTR;
|
|
|
|
V_BSTR(dataTypeName) = bstr_from_xmlChar( pVal );
|
|
|
|
xmlFree(pVal);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case XML_ENTITY_REF_NODE:
|
|
|
|
FIXME("XML_ENTITY_REF_NODE should return a valid value.\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
TRACE("Type %d returning NULL\n", This->node->type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* non-typed nodes return S_FALSE */
|
|
|
|
if(V_VT(dataTypeName) == VT_NULL)
|
|
|
|
{
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
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;
|
|
|
|
|
|
|
|
TRACE("iface %p\n", iface);
|
|
|
|
|
|
|
|
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,szByte) == 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)
|
|
|
|
{
|
|
|
|
xmlNsPtr pNS = NULL;
|
|
|
|
xmlAttrPtr pAttr = NULL;
|
|
|
|
xmlChar* str = xmlChar_from_wchar((WCHAR*)dataTypeName);
|
|
|
|
|
|
|
|
pAttr = xmlHasNsProp(This->node, (xmlChar*)"dt",
|
|
|
|
(xmlChar*)"urn:schemas-microsoft-com:datatypes");
|
|
|
|
if (pAttr)
|
|
|
|
{
|
|
|
|
pAttr = xmlSetNsProp(This->node, pAttr->ns, (xmlChar*)"dt", str);
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pNS = xmlNewNs(This->node, (xmlChar*)"urn:schemas-microsoft-com:datatypes", (xmlChar*)"dt");
|
|
|
|
if(pNS)
|
|
|
|
{
|
|
|
|
pAttr = xmlNewNsProp(This->node, pNS, (xmlChar*)"dt", str);
|
|
|
|
if(pAttr)
|
|
|
|
{
|
|
|
|
xmlAddChild(This->node, (xmlNodePtr)pAttr);
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Failed to create Attribute\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Failed to Create Namepsace\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
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;
|
|
|
|
int nSize;
|
|
|
|
|
|
|
|
TRACE("iface %p\n", iface);
|
|
|
|
|
|
|
|
if(!xmlString)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*xmlString = NULL;
|
|
|
|
|
|
|
|
pXmlBuf = xmlBufferCreate();
|
|
|
|
if(pXmlBuf)
|
|
|
|
{
|
|
|
|
nSize = xmlNodeDump(pXmlBuf, This->node->doc, This->node, 0, 0);
|
|
|
|
if(nSize > 0)
|
|
|
|
{
|
|
|
|
const xmlChar *pContent;
|
|
|
|
|
|
|
|
/* Attribute Nodes return a space infront of their name */
|
|
|
|
pContent = xmlBufferContent(pXmlBuf);
|
|
|
|
if( ((char*)pContent)[0] == ' ')
|
|
|
|
*xmlString = bstr_from_xmlChar(pContent+1);
|
|
|
|
else
|
|
|
|
*xmlString = bstr_from_xmlChar(pContent);
|
|
|
|
|
|
|
|
|
|
|
|
xmlBufferFree(pXmlBuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_w(queryString), resultList );
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_w(queryString), resultNode );
|
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
*resultNode = NULL;
|
2005-11-08 17:10:13 +01:00
|
|
|
r = IXMLDOMNode_selectNodes(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)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_namespaceURI(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* namespaceURI)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnode_get_prefix(
|
|
|
|
IXMLDOMNode *iface,
|
|
|
|
BSTR* prefixString)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
TRACE("%p %p\n", This, nameString );
|
|
|
|
|
|
|
|
if ( !nameString )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
switch ( This->node->type )
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
case XML_ATTRIBUTE_NODE:
|
|
|
|
str = bstr_from_xmlChar( This->node->name );
|
|
|
|
r = S_OK;
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
static HRESULT WINAPI Internal_QueryInterface(
|
|
|
|
IUnknown *iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject )
|
2005-08-10 11:54:22 +02:00
|
|
|
{
|
2005-12-01 18:46:42 +01:00
|
|
|
xmlnode *This = impl_from_InternalUnknown( iface );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
|
2005-08-18 12:48:13 +02:00
|
|
|
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ))
|
|
|
|
*ppvObject = iface;
|
|
|
|
else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMNode ) )
|
|
|
|
*ppvObject = &This->lpVtbl;
|
|
|
|
else
|
|
|
|
{
|
2006-01-27 19:22:56 +01:00
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-12-01 18:46:42 +01:00
|
|
|
*ppvObject = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef( (IUnknown*)*ppvObject );
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Internal_AddRef(
|
|
|
|
IUnknown *iface )
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_InternalUnknown( iface );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Internal_Release(
|
|
|
|
IUnknown *iface )
|
|
|
|
{
|
|
|
|
xmlnode *This = impl_from_InternalUnknown( iface );
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
2005-08-18 12:48:13 +02:00
|
|
|
{
|
2006-01-10 19:58:42 +01:00
|
|
|
if( This->node )
|
|
|
|
xmldoc_release( This->node->doc );
|
2005-12-01 18:46:42 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
2005-11-18 16:05:26 +01:00
|
|
|
}
|
2005-08-18 12:48:13 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IUnknownVtbl internal_unk_vtbl =
|
|
|
|
{
|
|
|
|
Internal_QueryInterface,
|
|
|
|
Internal_AddRef,
|
|
|
|
Internal_Release
|
|
|
|
};
|
|
|
|
|
|
|
|
IUnknown *create_basic_node( xmlNodePtr node, IUnknown *pUnkOuter )
|
|
|
|
{
|
|
|
|
xmlnode *This;
|
|
|
|
|
|
|
|
This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
|
|
|
|
if ( !This )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if(node)
|
|
|
|
xmldoc_add_ref( node->doc );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
This->lpVtbl = &xmlnode_vtbl;
|
2005-12-01 18:46:42 +01:00
|
|
|
This->lpInternalUnkVtbl = &internal_unk_vtbl;
|
|
|
|
|
|
|
|
if(pUnkOuter)
|
|
|
|
This->pUnkOuter = pUnkOuter; /* Don't take a ref on outer Unknown */
|
|
|
|
else
|
|
|
|
This->pUnkOuter = (IUnknown *)&This->lpInternalUnkVtbl;
|
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
This->ref = 1;
|
2005-08-18 12:48:13 +02:00
|
|
|
This->node = node;
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
return (IUnknown*)&This->lpInternalUnkVtbl;
|
2005-08-10 11:54:22 +02:00
|
|
|
}
|
|
|
|
|
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:
|
2006-06-14 03:37:54 +02:00
|
|
|
pUnk = create_element( node, NULL );
|
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;
|
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:
|
|
|
|
ERR("shouldn't be here!\n");
|
|
|
|
return NULL;
|
|
|
|
default:
|
|
|
|
FIXME("only creating basic node for type %d\n", node->type);
|
|
|
|
pUnk = create_basic_node( node, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|