2005-08-08 17:04:00 +02:00
|
|
|
/*
|
|
|
|
* Node map 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-08 17:04:00 +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-08 17:04:00 +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-08 17:04:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#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-08 17:04:00 +02:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2005-08-08 20:01:52 +02:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2005-08-08 17:04:00 +02:00
|
|
|
typedef struct _xmlnodemap
|
|
|
|
{
|
2010-12-16 01:04:17 +01:00
|
|
|
IXMLDOMNamedNodeMap IXMLDOMNamedNodeMap_iface;
|
|
|
|
ISupportErrorInfo ISupportErrorInfo_iface;
|
2005-08-08 17:04:00 +02:00
|
|
|
LONG ref;
|
2005-08-18 12:48:13 +02:00
|
|
|
IXMLDOMNode *node;
|
2009-03-09 23:28:53 +01:00
|
|
|
LONG iterator;
|
2005-08-08 17:04:00 +02:00
|
|
|
} xmlnodemap;
|
|
|
|
|
|
|
|
static inline xmlnodemap *impl_from_IXMLDOMNamedNodeMap( IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
2010-12-16 01:04:17 +01:00
|
|
|
return CONTAINING_RECORD(iface, xmlnodemap, IXMLDOMNamedNodeMap_iface);
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
2006-02-10 15:14:33 +01:00
|
|
|
static inline xmlnodemap *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
|
|
|
|
{
|
2010-12-16 01:04:17 +01:00
|
|
|
return CONTAINING_RECORD(iface, xmlnodemap, ISupportErrorInfo_iface);
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
|
|
|
|
2005-08-08 17:04:00 +02:00
|
|
|
static HRESULT WINAPI xmlnodemap_QueryInterface(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
REFIID riid, void** ppvObject )
|
|
|
|
{
|
2006-02-10 15:14:33 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject);
|
2005-08-08 17:04:00 +02:00
|
|
|
|
2006-02-10 15:14:33 +01:00
|
|
|
if( IsEqualGUID( riid, &IID_IUnknown ) ||
|
2005-08-08 17:04:00 +02:00
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
2006-02-10 15:14:33 +01:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMNamedNodeMap ) )
|
2005-08-08 17:04:00 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2006-02-10 15:14:33 +01:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
|
|
|
|
{
|
2010-12-16 01:04:17 +01:00
|
|
|
*ppvObject = &This->ISupportErrorInfo_iface;
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
2005-08-08 17:04:00 +02:00
|
|
|
else
|
2006-01-27 19:22:56 +01:00
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-08-08 17:04:00 +02:00
|
|
|
return E_NOINTERFACE;
|
2006-01-27 19:22:56 +01:00
|
|
|
}
|
2005-08-08 17:04:00 +02:00
|
|
|
|
|
|
|
IXMLDOMElement_AddRef( iface );
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnodemap_AddRef(
|
|
|
|
IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmlnodemap_Release(
|
|
|
|
IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
ULONG ref;
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2005-08-18 12:48:13 +02:00
|
|
|
IXMLDOMNode_Release( This->node );
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( This );
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetTypeInfoCount(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2008-02-19 02:24:18 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetTypeInfo(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
UINT iTInfo, LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
2008-02-19 02:24:18 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
2010-09-03 10:13:29 +02:00
|
|
|
return get_typeinfo(IXMLDOMNamedNodeMap_tid, ppTInfo);
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetIDsOfNames(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
REFIID riid, LPOLESTR* rgszNames,
|
|
|
|
UINT cNames, LCID lcid, DISPID* rgDispId )
|
|
|
|
{
|
2008-02-19 02:24:18 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( 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(IXMLDOMNamedNodeMap_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_Invoke(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo, UINT* puArgErr )
|
|
|
|
{
|
2008-02-19 02:24:18 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( 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(IXMLDOMNamedNodeMap_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2010-12-16 01:04:17 +01:00
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMNamedNodeMap_iface, dispIdMember, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-02-19 02:24:18 +01:00
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
2010-09-01 22:29:18 +02:00
|
|
|
xmlChar *xmlChar_from_wchar( LPCWSTR str )
|
2005-08-08 17:04:00 +02:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
xmlChar *xmlstr;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
|
2010-02-03 20:47:53 +01:00
|
|
|
xmlstr = heap_alloc( len );
|
2005-08-08 17:04:00 +02:00
|
|
|
if ( xmlstr )
|
|
|
|
WideCharToMultiByte( CP_UTF8, 0, str, -1, (LPSTR) xmlstr, len, NULL, NULL );
|
|
|
|
return xmlstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_getNamedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR name,
|
|
|
|
IXMLDOMNode** namedItem)
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem );
|
2010-09-03 10:13:29 +02:00
|
|
|
return IXMLDOMNamedNodeMap_getQualifiedItem(iface, name, NULL, namedItem);
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_setNamedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IXMLDOMNode* newItem,
|
|
|
|
IXMLDOMNode** namedItem)
|
|
|
|
{
|
2008-01-03 23:06:03 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlNodePtr nodeNew;
|
|
|
|
xmlNodePtr node;
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlnode *ThisNew;
|
2008-01-03 23:06:03 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, newItem, namedItem );
|
2008-01-03 23:06:03 +01:00
|
|
|
|
|
|
|
if(!newItem)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if(namedItem) *namedItem = NULL;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/* Must be an Attribute */
|
2010-09-04 17:55:04 +02:00
|
|
|
ThisNew = get_node_obj( newItem );
|
|
|
|
if(!ThisNew) {
|
|
|
|
FIXME("ThisNew is not our node implementation\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2008-01-03 23:06:03 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(ThisNew->node->type != XML_ATTRIBUTE_NODE)
|
|
|
|
return E_FAIL;
|
2008-01-03 23:06:03 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(!ThisNew->node->parent)
|
|
|
|
if(xmldoc_remove_orphan(ThisNew->node->doc, ThisNew->node) != S_OK)
|
|
|
|
WARN("%p is not an orphan of %p\n", ThisNew->node, ThisNew->node->doc);
|
2008-01-03 23:06:03 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
nodeNew = xmlAddChild(node, ThisNew->node);
|
2008-01-03 23:06:03 +01:00
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
if(namedItem)
|
|
|
|
*namedItem = create_node( nodeNew );
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_removeNamedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR name,
|
|
|
|
IXMLDOMNode** namedItem)
|
|
|
|
{
|
2008-10-11 23:57:48 +02:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), namedItem );
|
2010-09-04 16:41:10 +02:00
|
|
|
return IXMLDOMNamedNodeMap_removeQualifiedItem(iface, name, NULL, namedItem);
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_get_item(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
2009-03-09 23:28:16 +01:00
|
|
|
LONG index,
|
2005-08-08 17:04:00 +02:00
|
|
|
IXMLDOMNode** listItem)
|
|
|
|
{
|
2005-11-03 13:04:52 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 23:28:53 +01:00
|
|
|
LONG attrIndex;
|
2005-11-03 13:04:52 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, index, listItem);
|
2005-11-03 13:04:52 +01:00
|
|
|
|
|
|
|
*listItem = NULL;
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
curr = node->properties;
|
|
|
|
|
|
|
|
for (attrIndex = 0; attrIndex < index; attrIndex++) {
|
|
|
|
if (curr->next == NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
else
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
*listItem = create_node( (xmlNodePtr) curr );
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_get_length(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
2009-03-09 23:28:16 +01:00
|
|
|
LONG *listLength)
|
2005-08-08 17:04:00 +02:00
|
|
|
{
|
2005-11-03 13:04:52 +01:00
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr first;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 23:28:53 +01:00
|
|
|
LONG attrCount;
|
2005-11-03 13:04:52 +01:00
|
|
|
|
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, listLength);
|
2005-11-03 13:04:52 +01:00
|
|
|
|
2008-10-11 23:58:02 +02:00
|
|
|
if( !listLength )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-11-03 13:04:52 +01:00
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
first = node->properties;
|
|
|
|
if (first == NULL) {
|
|
|
|
*listLength = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
curr = first;
|
|
|
|
attrCount = 1;
|
2010-09-03 10:13:29 +02:00
|
|
|
while (curr->next) {
|
2005-11-03 13:04:52 +01:00
|
|
|
attrCount++;
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
*listLength = attrCount;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_getQualifiedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR baseName,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** qualifiedItem)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2010-09-03 10:13:29 +02:00
|
|
|
xmlAttrPtr attr;
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlChar *href;
|
|
|
|
xmlChar *name;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem);
|
|
|
|
|
|
|
|
if (!baseName || !qualifiedItem) return E_INVALIDARG;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode(This->node, XML_ELEMENT_NODE);
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if (namespaceURI && *namespaceURI)
|
|
|
|
{
|
|
|
|
href = xmlChar_from_wchar(namespaceURI);
|
|
|
|
if (!href) return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
href = NULL;
|
|
|
|
|
|
|
|
name = xmlChar_from_wchar(baseName);
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
heap_free(href);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
attr = xmlHasNsProp(node, name, href);
|
2010-09-04 16:41:10 +02:00
|
|
|
|
|
|
|
heap_free(name);
|
|
|
|
heap_free(href);
|
|
|
|
|
2010-09-03 10:13:29 +02:00
|
|
|
if (!attr)
|
|
|
|
{
|
|
|
|
*qualifiedItem = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*qualifiedItem = create_node((xmlNodePtr)attr);
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_removeQualifiedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR baseName,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** qualifiedItem)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2010-09-04 16:41:10 +02:00
|
|
|
xmlAttrPtr attr;
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlChar *name;
|
|
|
|
xmlChar *href;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(baseName), debugstr_w(namespaceURI), qualifiedItem);
|
|
|
|
|
|
|
|
if (!baseName) return E_INVALIDARG;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, XML_ELEMENT_NODE );
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if (namespaceURI && *namespaceURI)
|
|
|
|
{
|
|
|
|
href = xmlChar_from_wchar(namespaceURI);
|
|
|
|
if (!href) return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
href = NULL;
|
|
|
|
|
|
|
|
name = xmlChar_from_wchar(baseName);
|
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
heap_free(href);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
attr = xmlHasNsProp( node, name, href );
|
|
|
|
|
|
|
|
heap_free(name);
|
|
|
|
heap_free(href);
|
|
|
|
|
|
|
|
if ( !attr )
|
|
|
|
{
|
|
|
|
if (qualifiedItem) *qualifiedItem = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( qualifiedItem )
|
|
|
|
{
|
|
|
|
xmlUnlinkNode( (xmlNodePtr) attr );
|
|
|
|
xmldoc_add_orphan( attr->doc, (xmlNodePtr) attr );
|
|
|
|
*qualifiedItem = create_node( (xmlNodePtr) attr );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (xmlRemoveProp(attr) == -1)
|
|
|
|
ERR("xmlRemoveProp failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_nextNode(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IXMLDOMNode** nextItem)
|
|
|
|
{
|
2006-12-28 16:22:31 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 23:28:53 +01:00
|
|
|
LONG attrIndex;
|
2006-12-28 16:22:31 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, nextItem, This->iterator);
|
2006-12-28 16:22:31 +01:00
|
|
|
|
|
|
|
*nextItem = NULL;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
curr = node->properties;
|
|
|
|
|
|
|
|
for (attrIndex = 0; attrIndex < This->iterator; attrIndex++) {
|
|
|
|
if (curr->next == NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
else
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->iterator++;
|
|
|
|
|
|
|
|
*nextItem = create_node( (xmlNodePtr) curr );
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_reset(
|
|
|
|
IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
2006-12-28 16:22:31 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p: %d)\n", This, This->iterator);
|
2006-12-28 16:22:31 +01:00
|
|
|
|
|
|
|
This->iterator = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap__newEnum(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IUnknown** ppUnk)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppUnk);
|
2005-08-08 17:04:00 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMNamedNodeMapVtbl xmlnodemap_vtbl =
|
|
|
|
{
|
|
|
|
xmlnodemap_QueryInterface,
|
|
|
|
xmlnodemap_AddRef,
|
|
|
|
xmlnodemap_Release,
|
|
|
|
xmlnodemap_GetTypeInfoCount,
|
|
|
|
xmlnodemap_GetTypeInfo,
|
|
|
|
xmlnodemap_GetIDsOfNames,
|
|
|
|
xmlnodemap_Invoke,
|
|
|
|
xmlnodemap_getNamedItem,
|
|
|
|
xmlnodemap_setNamedItem,
|
|
|
|
xmlnodemap_removeNamedItem,
|
|
|
|
xmlnodemap_get_item,
|
|
|
|
xmlnodemap_get_length,
|
|
|
|
xmlnodemap_getQualifiedItem,
|
|
|
|
xmlnodemap_removeQualifiedItem,
|
|
|
|
xmlnodemap_nextNode,
|
|
|
|
xmlnodemap_reset,
|
|
|
|
xmlnodemap__newEnum,
|
|
|
|
};
|
|
|
|
|
2006-02-10 15:14:33 +01:00
|
|
|
static HRESULT WINAPI support_error_QueryInterface(
|
|
|
|
ISupportErrorInfo *iface,
|
|
|
|
REFIID riid, void** ppvObject )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
|
|
|
|
TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
|
2010-12-16 01:04:17 +01:00
|
|
|
return IXMLDOMNamedNodeMap_QueryInterface(&This->IXMLDOMNamedNodeMap_iface, riid, ppvObject);
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_AddRef(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
|
2010-12-16 01:04:17 +01:00
|
|
|
return IXMLDOMNamedNodeMap_AddRef(&This->IXMLDOMNamedNodeMap_iface);
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_Release(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
|
2010-12-16 01:04:17 +01:00
|
|
|
return IXMLDOMNamedNodeMap_Release(&This->IXMLDOMNamedNodeMap_iface);
|
2006-02-10 15:14:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI support_error_InterfaceSupportsErrorInfo(
|
|
|
|
ISupportErrorInfo *iface,
|
|
|
|
REFIID riid )
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISupportErrorInfoVtbl support_error_vtbl =
|
|
|
|
{
|
|
|
|
support_error_QueryInterface,
|
|
|
|
support_error_AddRef,
|
|
|
|
support_error_Release,
|
|
|
|
support_error_InterfaceSupportsErrorInfo
|
|
|
|
};
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node )
|
2005-08-08 17:04:00 +02:00
|
|
|
{
|
|
|
|
xmlnodemap *nodemap;
|
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
nodemap = heap_alloc( sizeof *nodemap );
|
2005-08-08 17:04:00 +02:00
|
|
|
if ( !nodemap )
|
2005-08-18 12:48:13 +02:00
|
|
|
return NULL;
|
2005-08-08 17:04:00 +02:00
|
|
|
|
2010-12-16 01:04:17 +01:00
|
|
|
nodemap->IXMLDOMNamedNodeMap_iface.lpVtbl = &xmlnodemap_vtbl;
|
|
|
|
nodemap->ISupportErrorInfo_iface.lpVtbl = &support_error_vtbl;
|
2005-08-08 17:04:00 +02:00
|
|
|
nodemap->node = node;
|
|
|
|
nodemap->ref = 1;
|
2006-12-28 16:22:31 +01:00
|
|
|
nodemap->iterator = 0;
|
2005-08-08 17:04:00 +02:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
IXMLDOMNode_AddRef( node );
|
2005-11-18 16:05:26 +01:00
|
|
|
/* Since we AddRef a node here, we don't need to call xmldoc_add_ref() */
|
2005-08-08 17:04:00 +02:00
|
|
|
|
2010-12-16 01:04:17 +01:00
|
|
|
return &nodemap->IXMLDOMNamedNodeMap_iface;
|
2005-08-08 17:04:00 +02:00
|
|
|
}
|
2005-08-08 20:01:52 +02:00
|
|
|
|
|
|
|
#endif
|