2 * Node map implementation
4 * Copyright 2005 Mike McCormack
6 * iface library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * iface library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "msxml_private.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
44 typedef struct _xmlnodemap
46 const struct IXMLDOMNamedNodeMapVtbl
*lpVtbl
;
51 static inline xmlnodemap
*impl_from_IXMLDOMNamedNodeMap( IXMLDOMNamedNodeMap
*iface
)
53 return (xmlnodemap
*)((char*)iface
- FIELD_OFFSET(xmlnodemap
, lpVtbl
));
56 static HRESULT WINAPI
xmlnodemap_QueryInterface(
57 IXMLDOMNamedNodeMap
*iface
,
58 REFIID riid
, void** ppvObject
)
60 TRACE("%p %p %p\n", iface
, debugstr_guid(riid
), ppvObject
);
62 if( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
63 IsEqualGUID( riid
, &IID_IUnknown
) ||
64 IsEqualGUID( riid
, &IID_IDispatch
) ||
65 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
72 IXMLDOMElement_AddRef( iface
);
77 static ULONG WINAPI
xmlnodemap_AddRef(
78 IXMLDOMNamedNodeMap
*iface
)
80 xmlnodemap
*This
= impl_from_IXMLDOMNamedNodeMap( iface
);
81 return InterlockedIncrement( &This
->ref
);
84 static ULONG WINAPI
xmlnodemap_Release(
85 IXMLDOMNamedNodeMap
*iface
)
87 xmlnodemap
*This
= impl_from_IXMLDOMNamedNodeMap( iface
);
90 ref
= InterlockedDecrement( &This
->ref
);
93 IXMLDOMNode_Release( This
->node
);
94 HeapFree( GetProcessHeap(), 0, This
);
100 static HRESULT WINAPI
xmlnodemap_GetTypeInfoCount(
101 IXMLDOMNamedNodeMap
*iface
,
108 static HRESULT WINAPI
xmlnodemap_GetTypeInfo(
109 IXMLDOMNamedNodeMap
*iface
,
110 UINT iTInfo
, LCID lcid
,
111 ITypeInfo
** ppTInfo
)
117 static HRESULT WINAPI
xmlnodemap_GetIDsOfNames(
118 IXMLDOMNamedNodeMap
*iface
,
119 REFIID riid
, LPOLESTR
* rgszNames
,
120 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
126 static HRESULT WINAPI
xmlnodemap_Invoke(
127 IXMLDOMNamedNodeMap
*iface
,
128 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
129 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
130 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
136 xmlChar
*xmlChar_from_wchar( LPWSTR str
)
141 len
= WideCharToMultiByte( CP_UTF8
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
142 xmlstr
= (xmlChar
*) HeapAlloc( GetProcessHeap(), 0, len
);
144 WideCharToMultiByte( CP_UTF8
, 0, str
, -1, (LPSTR
) xmlstr
, len
, NULL
, NULL
);
148 static HRESULT WINAPI
xmlnodemap_getNamedItem(
149 IXMLDOMNamedNodeMap
*iface
,
151 IXMLDOMNode
** namedItem
)
153 xmlnodemap
*This
= impl_from_IXMLDOMNamedNodeMap( iface
);
154 xmlChar
*element_name
;
158 TRACE("%p %s\n", This
, debugstr_w(name
) );
160 node
= xmlNodePtr_from_domnode( This
->node
, 0 );
164 element_name
= xmlChar_from_wchar( name
);
165 attr
= xmlHasNsProp( node
, element_name
, NULL
);
166 HeapFree( GetProcessHeap(), 0, element_name
);
171 *namedItem
= create_node( (xmlNodePtr
) attr
);
176 static HRESULT WINAPI
xmlnodemap_setNamedItem(
177 IXMLDOMNamedNodeMap
*iface
,
178 IXMLDOMNode
* newItem
,
179 IXMLDOMNode
** namedItem
)
185 static HRESULT WINAPI
xmlnodemap_removeNamedItem(
186 IXMLDOMNamedNodeMap
*iface
,
188 IXMLDOMNode
** namedItem
)
194 static HRESULT WINAPI
xmlnodemap_get_item(
195 IXMLDOMNamedNodeMap
*iface
,
197 IXMLDOMNode
** listItem
)
203 static HRESULT WINAPI
xmlnodemap_get_length(
204 IXMLDOMNamedNodeMap
*iface
,
211 static HRESULT WINAPI
xmlnodemap_getQualifiedItem(
212 IXMLDOMNamedNodeMap
*iface
,
215 IXMLDOMNode
** qualifiedItem
)
221 static HRESULT WINAPI
xmlnodemap_removeQualifiedItem(
222 IXMLDOMNamedNodeMap
*iface
,
225 IXMLDOMNode
** qualifiedItem
)
231 static HRESULT WINAPI
xmlnodemap_nextNode(
232 IXMLDOMNamedNodeMap
*iface
,
233 IXMLDOMNode
** nextItem
)
239 static HRESULT WINAPI
xmlnodemap_reset(
240 IXMLDOMNamedNodeMap
*iface
)
246 static HRESULT WINAPI
xmlnodemap__newEnum(
247 IXMLDOMNamedNodeMap
*iface
,
254 static const struct IXMLDOMNamedNodeMapVtbl xmlnodemap_vtbl
=
256 xmlnodemap_QueryInterface
,
259 xmlnodemap_GetTypeInfoCount
,
260 xmlnodemap_GetTypeInfo
,
261 xmlnodemap_GetIDsOfNames
,
263 xmlnodemap_getNamedItem
,
264 xmlnodemap_setNamedItem
,
265 xmlnodemap_removeNamedItem
,
267 xmlnodemap_get_length
,
268 xmlnodemap_getQualifiedItem
,
269 xmlnodemap_removeQualifiedItem
,
275 IXMLDOMNamedNodeMap
*create_nodemap( IXMLDOMNode
*node
)
279 nodemap
= HeapAlloc( GetProcessHeap(), 0, sizeof *nodemap
);
283 nodemap
->lpVtbl
= &xmlnodemap_vtbl
;
284 nodemap
->node
= node
;
287 IXMLDOMNode_AddRef( node
);
289 return (IXMLDOMNamedNodeMap
*) &nodemap
->lpVtbl
;