2005-08-08 15:04:00 +00:00
|
|
|
/*
|
|
|
|
* Node map implementation
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack
|
|
|
|
*
|
2005-11-08 12:46:43 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
2005-08-08 15:04:00 +00: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 12:46:43 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2005-08-08 15:04:00 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-08 15:04:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "ole2.h"
|
2005-11-08 19:59:36 +00:00
|
|
|
#include "msxml2.h"
|
2005-08-08 15:04:00 +00:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
2005-08-08 18:01:52 +00:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2005-08-08 15:04:00 +00:00
|
|
|
typedef struct _xmlnodemap
|
|
|
|
{
|
|
|
|
const struct IXMLDOMNamedNodeMapVtbl *lpVtbl;
|
2006-02-10 14:14:33 +00:00
|
|
|
const struct ISupportErrorInfoVtbl *lpSEIVtbl;
|
2005-08-08 15:04:00 +00:00
|
|
|
LONG ref;
|
2005-08-18 10:48:13 +00:00
|
|
|
IXMLDOMNode *node;
|
2009-03-09 22:28:53 +00:00
|
|
|
LONG iterator;
|
2005-08-08 15:04:00 +00:00
|
|
|
} xmlnodemap;
|
|
|
|
|
|
|
|
static inline xmlnodemap *impl_from_IXMLDOMNamedNodeMap( IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
|
|
|
return (xmlnodemap *)((char*)iface - FIELD_OFFSET(xmlnodemap, lpVtbl));
|
|
|
|
}
|
|
|
|
|
2006-02-10 14:14:33 +00:00
|
|
|
static inline xmlnodemap *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
return (xmlnodemap *)((char*)iface - FIELD_OFFSET(xmlnodemap, lpSEIVtbl));
|
|
|
|
}
|
|
|
|
|
2005-08-08 15:04:00 +00:00
|
|
|
static HRESULT WINAPI xmlnodemap_QueryInterface(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
REFIID riid, void** ppvObject )
|
|
|
|
{
|
2006-02-10 14:14:33 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
2005-10-31 21:04:31 +00:00
|
|
|
TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
|
2005-08-08 15:04:00 +00:00
|
|
|
|
2006-02-10 14:14:33 +00:00
|
|
|
if( IsEqualGUID( riid, &IID_IUnknown ) ||
|
2005-08-08 15:04:00 +00:00
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
2006-02-10 14:14:33 +00:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMNamedNodeMap ) )
|
2005-08-08 15:04:00 +00:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2006-02-10 14:14:33 +00:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->lpSEIVtbl;
|
|
|
|
}
|
2005-08-08 15:04:00 +00:00
|
|
|
else
|
2006-01-27 18:22:56 +00:00
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-08-08 15:04:00 +00:00
|
|
|
return E_NOINTERFACE;
|
2006-01-27 18:22:56 +00:00
|
|
|
}
|
2005-08-08 15:04:00 +00: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 10:48:13 +00:00
|
|
|
IXMLDOMNode_Release( This->node );
|
2005-08-08 15:04:00 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetTypeInfoCount(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
UINT* pctinfo )
|
|
|
|
{
|
2008-02-19 01:24:18 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetTypeInfo(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
UINT iTInfo, LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo )
|
|
|
|
{
|
2008-02-19 01:24:18 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMNamedNodeMap_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_GetIDsOfNames(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
REFIID riid, LPOLESTR* rgszNames,
|
|
|
|
UINT cNames, LCID lcid, DISPID* rgDispId )
|
|
|
|
{
|
2008-02-19 01:24:18 +00: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 15:04:00 +00: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 01:24:18 +00: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))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
2005-08-10 09:54:22 +00:00
|
|
|
xmlChar *xmlChar_from_wchar( LPWSTR str )
|
2005-08-08 15:04:00 +00:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
xmlChar *xmlstr;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
|
2007-06-26 22:16:11 +00:00
|
|
|
xmlstr = HeapAlloc( GetProcessHeap(), 0, len );
|
2005-08-08 15:04:00 +00: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 );
|
|
|
|
xmlChar *element_name;
|
|
|
|
xmlAttrPtr attr;
|
2005-08-18 10:48:13 +00:00
|
|
|
xmlNodePtr node;
|
|
|
|
|
2006-09-20 23:41:30 +00:00
|
|
|
TRACE("%p %s %p\n", This, debugstr_w(name), namedItem );
|
|
|
|
|
|
|
|
if ( !namedItem )
|
|
|
|
return E_INVALIDARG;
|
2005-08-18 10:48:13 +00:00
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
2005-08-08 15:04:00 +00:00
|
|
|
|
|
|
|
element_name = xmlChar_from_wchar( name );
|
2005-08-18 10:48:13 +00:00
|
|
|
attr = xmlHasNsProp( node, element_name, NULL );
|
2005-08-08 15:04:00 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, element_name );
|
|
|
|
|
|
|
|
if ( !attr )
|
2006-09-20 23:41:30 +00:00
|
|
|
{
|
|
|
|
*namedItem = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
2005-08-18 10:48:13 +00:00
|
|
|
|
2005-08-19 10:03:27 +00:00
|
|
|
*namedItem = create_node( (xmlNodePtr) attr );
|
2005-08-18 10:48:13 +00:00
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_setNamedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IXMLDOMNode* newItem,
|
|
|
|
IXMLDOMNode** namedItem)
|
|
|
|
{
|
2008-01-03 22:06:03 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlnode *ThisNew = NULL;
|
|
|
|
xmlNodePtr nodeNew;
|
|
|
|
IXMLDOMNode *pAttr = NULL;
|
|
|
|
xmlNodePtr node;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", This, newItem, namedItem );
|
|
|
|
|
|
|
|
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 */
|
|
|
|
IUnknown_QueryInterface(newItem, &IID_IXMLDOMNode, (LPVOID*)&pAttr);
|
|
|
|
if(pAttr)
|
|
|
|
{
|
|
|
|
ThisNew = impl_from_IXMLDOMNode( pAttr );
|
|
|
|
|
|
|
|
if(ThisNew->node->type != XML_ATTRIBUTE_NODE)
|
|
|
|
{
|
|
|
|
IUnknown_Release(pAttr);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2008-10-11 21:59:25 +00: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 22:06:03 +00:00
|
|
|
nodeNew = xmlAddChild(node, ThisNew->node);
|
|
|
|
|
|
|
|
if(namedItem)
|
2008-01-12 16:05:33 +00:00
|
|
|
*namedItem = create_node( nodeNew );
|
2008-01-03 22:06:03 +00:00
|
|
|
|
|
|
|
IUnknown_Release(pAttr);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_INVALIDARG;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_removeNamedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR name,
|
|
|
|
IXMLDOMNode** namedItem)
|
|
|
|
{
|
2008-10-11 21:57:48 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlChar *element_name;
|
2008-11-02 12:34:44 +00:00
|
|
|
xmlAttrPtr attr;
|
2008-10-11 21:57:48 +00:00
|
|
|
xmlNodePtr node;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", This, debugstr_w(name), namedItem );
|
|
|
|
|
|
|
|
if ( !name)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
node = xmlNodePtr_from_domnode( This->node, 0 );
|
|
|
|
if ( !node )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
element_name = xmlChar_from_wchar( name );
|
|
|
|
attr = xmlHasNsProp( node, element_name, NULL );
|
|
|
|
HeapFree( GetProcessHeap(), 0, element_name );
|
|
|
|
|
|
|
|
if ( !attr )
|
|
|
|
{
|
|
|
|
if( namedItem )
|
|
|
|
*namedItem = NULL;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( namedItem )
|
|
|
|
{
|
2008-11-02 12:34:44 +00:00
|
|
|
xmlUnlinkNode( (xmlNodePtr) attr );
|
|
|
|
xmldoc_add_orphan( attr->doc, (xmlNodePtr) attr );
|
|
|
|
*namedItem = create_node( (xmlNodePtr) attr );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( xmlRemoveProp( attr ) == -1 )
|
|
|
|
ERR("xmlRemoveProp failed\n");
|
2008-10-11 21:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_get_item(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
2009-03-09 22:28:16 +00:00
|
|
|
LONG index,
|
2005-08-08 15:04:00 +00:00
|
|
|
IXMLDOMNode** listItem)
|
|
|
|
{
|
2005-11-03 12:04:52 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 22:28:53 +00:00
|
|
|
LONG attrIndex;
|
2005-11-03 12:04:52 +00:00
|
|
|
|
2009-03-09 22:28:16 +00:00
|
|
|
TRACE("%p %d\n", This, index);
|
2005-11-03 12:04:52 +00: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 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_get_length(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
2009-03-09 22:28:16 +00:00
|
|
|
LONG *listLength)
|
2005-08-08 15:04:00 +00:00
|
|
|
{
|
2005-11-03 12:04:52 +00:00
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr first;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 22:28:53 +00:00
|
|
|
LONG attrCount;
|
2005-11-03 12:04:52 +00:00
|
|
|
|
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
2008-10-11 21:58:02 +00:00
|
|
|
if( !listLength )
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2005-11-03 12:04:52 +00: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;
|
|
|
|
while (curr->next != NULL) {
|
|
|
|
attrCount++;
|
|
|
|
curr = curr->next;
|
|
|
|
}
|
|
|
|
*listLength = attrCount;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_getQualifiedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR baseName,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** qualifiedItem)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_removeQualifiedItem(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
BSTR baseName,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** qualifiedItem)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_nextNode(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IXMLDOMNode** nextItem)
|
|
|
|
{
|
2006-12-28 15:22:31 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
xmlNodePtr node;
|
|
|
|
xmlAttrPtr curr;
|
2009-03-09 22:28:53 +00:00
|
|
|
LONG attrIndex;
|
2006-12-28 15:22:31 +00:00
|
|
|
|
2009-03-09 22:28:53 +00:00
|
|
|
TRACE("%p %d\n", This, This->iterator);
|
2006-12-28 15:22:31 +00: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 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap_reset(
|
|
|
|
IXMLDOMNamedNodeMap *iface )
|
|
|
|
{
|
2006-12-28 15:22:31 +00:00
|
|
|
xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
|
|
|
|
|
2009-03-09 22:28:53 +00:00
|
|
|
TRACE("%p %d\n", This, This->iterator);
|
2006-12-28 15:22:31 +00:00
|
|
|
|
|
|
|
This->iterator = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmlnodemap__newEnum(
|
|
|
|
IXMLDOMNamedNodeMap *iface,
|
|
|
|
IUnknown** ppUnk)
|
|
|
|
{
|
|
|
|
FIXME("\n");
|
|
|
|
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 14:14:33 +00: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);
|
|
|
|
|
|
|
|
return IXMLDOMNamedNodeMap_QueryInterface((IXMLDOMNamedNodeMap*)&This->lpVtbl, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_AddRef(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
|
|
|
|
return IXMLDOMNamedNodeMap_AddRef((IXMLDOMNamedNodeMap*)&This->lpVtbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_Release(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
|
|
|
|
return IXMLDOMNamedNodeMap_Release((IXMLDOMNamedNodeMap*)&This->lpVtbl);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 10:48:13 +00:00
|
|
|
IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node )
|
2005-08-08 15:04:00 +00:00
|
|
|
{
|
|
|
|
xmlnodemap *nodemap;
|
|
|
|
|
|
|
|
nodemap = HeapAlloc( GetProcessHeap(), 0, sizeof *nodemap );
|
|
|
|
if ( !nodemap )
|
2005-08-18 10:48:13 +00:00
|
|
|
return NULL;
|
2005-08-08 15:04:00 +00:00
|
|
|
|
|
|
|
nodemap->lpVtbl = &xmlnodemap_vtbl;
|
2006-02-10 14:14:33 +00:00
|
|
|
nodemap->lpSEIVtbl = &support_error_vtbl;
|
2005-08-08 15:04:00 +00:00
|
|
|
nodemap->node = node;
|
|
|
|
nodemap->ref = 1;
|
2006-12-28 15:22:31 +00:00
|
|
|
nodemap->iterator = 0;
|
2005-08-08 15:04:00 +00:00
|
|
|
|
2005-08-18 10:48:13 +00:00
|
|
|
IXMLDOMNode_AddRef( node );
|
2005-11-18 15:05:26 +00:00
|
|
|
/* Since we AddRef a node here, we don't need to call xmldoc_add_ref() */
|
2005-08-08 15:04:00 +00:00
|
|
|
|
2005-08-18 10:48:13 +00:00
|
|
|
return (IXMLDOMNamedNodeMap*) &nodemap->lpVtbl;
|
2005-08-08 15:04:00 +00:00
|
|
|
}
|
2005-08-08 18:01:52 +00:00
|
|
|
|
|
|
|
#endif
|