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
;
52 static inline xmlnodemap
*impl_from_IXMLDOMNamedNodeMap( IXMLDOMNamedNodeMap
*iface
)
54 return (xmlnodemap
*)((char*)iface
- FIELD_OFFSET(xmlnodemap
, lpVtbl
));
57 static HRESULT WINAPI
xmlnodemap_QueryInterface(
58 IXMLDOMNamedNodeMap
*iface
,
59 REFIID riid
, void** ppvObject
)
61 TRACE("%p %p %p\n", iface
, debugstr_guid(riid
), ppvObject
);
63 if( IsEqualGUID( riid
, &IID_IXMLDOMElement
) ||
64 IsEqualGUID( riid
, &IID_IUnknown
) ||
65 IsEqualGUID( riid
, &IID_IDispatch
) ||
66 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
73 IXMLDOMElement_AddRef( iface
);
78 static ULONG WINAPI
xmlnodemap_AddRef(
79 IXMLDOMNamedNodeMap
*iface
)
81 xmlnodemap
*This
= impl_from_IXMLDOMNamedNodeMap( iface
);
82 return InterlockedIncrement( &This
->ref
);
85 static ULONG WINAPI
xmlnodemap_Release(
86 IXMLDOMNamedNodeMap
*iface
)
88 xmlnodemap
*This
= impl_from_IXMLDOMNamedNodeMap( iface
);
91 ref
= InterlockedDecrement( &This
->ref
);
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
;
157 element_name
= xmlChar_from_wchar( name
);
158 attr
= xmlHasNsProp( This
->node
, element_name
, NULL
);
159 TRACE("xmlHasNsProp returned %p for %s\n", attr
, element_name
);
160 HeapFree( GetProcessHeap(), 0, element_name
);
164 /* return Node_create( namedItem, This->xmldoc, attr ); */
168 static HRESULT WINAPI
xmlnodemap_setNamedItem(
169 IXMLDOMNamedNodeMap
*iface
,
170 IXMLDOMNode
* newItem
,
171 IXMLDOMNode
** namedItem
)
177 static HRESULT WINAPI
xmlnodemap_removeNamedItem(
178 IXMLDOMNamedNodeMap
*iface
,
180 IXMLDOMNode
** namedItem
)
186 static HRESULT WINAPI
xmlnodemap_get_item(
187 IXMLDOMNamedNodeMap
*iface
,
189 IXMLDOMNode
** listItem
)
195 static HRESULT WINAPI
xmlnodemap_get_length(
196 IXMLDOMNamedNodeMap
*iface
,
203 static HRESULT WINAPI
xmlnodemap_getQualifiedItem(
204 IXMLDOMNamedNodeMap
*iface
,
207 IXMLDOMNode
** qualifiedItem
)
213 static HRESULT WINAPI
xmlnodemap_removeQualifiedItem(
214 IXMLDOMNamedNodeMap
*iface
,
217 IXMLDOMNode
** qualifiedItem
)
223 static HRESULT WINAPI
xmlnodemap_nextNode(
224 IXMLDOMNamedNodeMap
*iface
,
225 IXMLDOMNode
** nextItem
)
231 static HRESULT WINAPI
xmlnodemap_reset(
232 IXMLDOMNamedNodeMap
*iface
)
238 static HRESULT WINAPI
xmlnodemap__newEnum(
239 IXMLDOMNamedNodeMap
*iface
,
246 static const struct IXMLDOMNamedNodeMapVtbl xmlnodemap_vtbl
=
248 xmlnodemap_QueryInterface
,
251 xmlnodemap_GetTypeInfoCount
,
252 xmlnodemap_GetTypeInfo
,
253 xmlnodemap_GetIDsOfNames
,
255 xmlnodemap_getNamedItem
,
256 xmlnodemap_setNamedItem
,
257 xmlnodemap_removeNamedItem
,
259 xmlnodemap_get_length
,
260 xmlnodemap_getQualifiedItem
,
261 xmlnodemap_removeQualifiedItem
,
267 HRESULT
NodeMap_create( IXMLDOMNamedNodeMap
** DomNamedNodeMap
, xmlDocPtr xmldoc
, xmlNodePtr node
)
271 nodemap
= HeapAlloc( GetProcessHeap(), 0, sizeof *nodemap
);
273 return E_OUTOFMEMORY
;
275 nodemap
->lpVtbl
= &xmlnodemap_vtbl
;
276 nodemap
->xmldoc
= xmldoc
;
277 nodemap
->node
= node
;
280 *DomNamedNodeMap
= (IXMLDOMNamedNodeMap
*) &nodemap
->lpVtbl
;