d3d8: Add detection for GL_ARB_point_parameters support.
[wine/multimedia.git] / dlls / msxml3 / nodemap.c
blob51660204fa8f3e04dede01542a45ec705c962ad1
1 /*
2 * Node map implementation
4 * Copyright 2005 Mike McCormack
6 * This 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 * This 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
21 #include "config.h"
23 #define COBJMACROS
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
31 #include "msxml2.h"
33 #include "msxml_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39 #ifdef HAVE_LIBXML2
41 typedef struct _xmlnodemap
43 const struct IXMLDOMNamedNodeMapVtbl *lpVtbl;
44 LONG ref;
45 IXMLDOMNode *node;
46 } xmlnodemap;
48 static inline xmlnodemap *impl_from_IXMLDOMNamedNodeMap( IXMLDOMNamedNodeMap *iface )
50 return (xmlnodemap *)((char*)iface - FIELD_OFFSET(xmlnodemap, lpVtbl));
53 static HRESULT WINAPI xmlnodemap_QueryInterface(
54 IXMLDOMNamedNodeMap *iface,
55 REFIID riid, void** ppvObject )
57 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
59 if( IsEqualGUID( riid, &IID_IXMLDOMElement ) ||
60 IsEqualGUID( riid, &IID_IUnknown ) ||
61 IsEqualGUID( riid, &IID_IDispatch ) ||
62 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
64 *ppvObject = iface;
66 else
68 FIXME("interface %s not implemented\n", debugstr_guid(riid));
69 return E_NOINTERFACE;
72 IXMLDOMElement_AddRef( iface );
74 return S_OK;
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 );
88 ULONG ref;
90 ref = InterlockedDecrement( &This->ref );
91 if ( ref == 0 )
93 IXMLDOMNode_Release( This->node );
94 HeapFree( GetProcessHeap(), 0, This );
97 return ref;
100 static HRESULT WINAPI xmlnodemap_GetTypeInfoCount(
101 IXMLDOMNamedNodeMap *iface,
102 UINT* pctinfo )
104 FIXME("\n");
105 return E_NOTIMPL;
108 static HRESULT WINAPI xmlnodemap_GetTypeInfo(
109 IXMLDOMNamedNodeMap *iface,
110 UINT iTInfo, LCID lcid,
111 ITypeInfo** ppTInfo )
113 FIXME("\n");
114 return E_NOTIMPL;
117 static HRESULT WINAPI xmlnodemap_GetIDsOfNames(
118 IXMLDOMNamedNodeMap *iface,
119 REFIID riid, LPOLESTR* rgszNames,
120 UINT cNames, LCID lcid, DISPID* rgDispId )
122 FIXME("\n");
123 return E_NOTIMPL;
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 )
132 FIXME("\n");
133 return E_NOTIMPL;
136 xmlChar *xmlChar_from_wchar( LPWSTR str )
138 DWORD len;
139 xmlChar *xmlstr;
141 len = WideCharToMultiByte( CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL );
142 xmlstr = (xmlChar*) HeapAlloc( GetProcessHeap(), 0, len );
143 if ( xmlstr )
144 WideCharToMultiByte( CP_UTF8, 0, str, -1, (LPSTR) xmlstr, len, NULL, NULL );
145 return xmlstr;
148 static HRESULT WINAPI xmlnodemap_getNamedItem(
149 IXMLDOMNamedNodeMap *iface,
150 BSTR name,
151 IXMLDOMNode** namedItem)
153 xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
154 xmlChar *element_name;
155 xmlAttrPtr attr;
156 xmlNodePtr node;
158 TRACE("%p %s\n", This, debugstr_w(name) );
160 node = xmlNodePtr_from_domnode( This->node, 0 );
161 if ( !node )
162 return E_FAIL;
164 element_name = xmlChar_from_wchar( name );
165 attr = xmlHasNsProp( node, element_name, NULL );
166 HeapFree( GetProcessHeap(), 0, element_name );
168 if ( !attr )
169 return E_FAIL;
171 *namedItem = create_node( (xmlNodePtr) attr );
173 return S_OK;
176 static HRESULT WINAPI xmlnodemap_setNamedItem(
177 IXMLDOMNamedNodeMap *iface,
178 IXMLDOMNode* newItem,
179 IXMLDOMNode** namedItem)
181 FIXME("\n");
182 return E_NOTIMPL;
185 static HRESULT WINAPI xmlnodemap_removeNamedItem(
186 IXMLDOMNamedNodeMap *iface,
187 BSTR name,
188 IXMLDOMNode** namedItem)
190 FIXME("\n");
191 return E_NOTIMPL;
194 static HRESULT WINAPI xmlnodemap_get_item(
195 IXMLDOMNamedNodeMap *iface,
196 long index,
197 IXMLDOMNode** listItem)
199 xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
200 xmlNodePtr node;
201 xmlAttrPtr curr;
202 long attrIndex;
204 TRACE("%p %ld\n", This, index);
206 *listItem = NULL;
208 if (index < 0)
209 return S_FALSE;
211 node = xmlNodePtr_from_domnode( This->node, 0 );
212 curr = node->properties;
214 for (attrIndex = 0; attrIndex < index; attrIndex++) {
215 if (curr->next == NULL)
216 return S_FALSE;
217 else
218 curr = curr->next;
221 *listItem = create_node( (xmlNodePtr) curr );
223 return S_OK;
226 static HRESULT WINAPI xmlnodemap_get_length(
227 IXMLDOMNamedNodeMap *iface,
228 long* listLength)
230 xmlNodePtr node;
231 xmlAttrPtr first;
232 xmlAttrPtr curr;
233 long attrCount;
235 xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
237 TRACE("%p\n", This);
239 node = xmlNodePtr_from_domnode( This->node, 0 );
240 if ( !node )
241 return E_FAIL;
243 first = node->properties;
244 if (first == NULL) {
245 *listLength = 0;
246 return S_OK;
249 curr = first;
250 attrCount = 1;
251 while (curr->next != NULL) {
252 attrCount++;
253 curr = curr->next;
255 *listLength = attrCount;
257 return S_OK;
260 static HRESULT WINAPI xmlnodemap_getQualifiedItem(
261 IXMLDOMNamedNodeMap *iface,
262 BSTR baseName,
263 BSTR namespaceURI,
264 IXMLDOMNode** qualifiedItem)
266 FIXME("\n");
267 return E_NOTIMPL;
270 static HRESULT WINAPI xmlnodemap_removeQualifiedItem(
271 IXMLDOMNamedNodeMap *iface,
272 BSTR baseName,
273 BSTR namespaceURI,
274 IXMLDOMNode** qualifiedItem)
276 FIXME("\n");
277 return E_NOTIMPL;
280 static HRESULT WINAPI xmlnodemap_nextNode(
281 IXMLDOMNamedNodeMap *iface,
282 IXMLDOMNode** nextItem)
284 FIXME("\n");
285 return E_NOTIMPL;
288 static HRESULT WINAPI xmlnodemap_reset(
289 IXMLDOMNamedNodeMap *iface )
291 FIXME("\n");
292 return E_NOTIMPL;
295 static HRESULT WINAPI xmlnodemap__newEnum(
296 IXMLDOMNamedNodeMap *iface,
297 IUnknown** ppUnk)
299 FIXME("\n");
300 return E_NOTIMPL;
303 static const struct IXMLDOMNamedNodeMapVtbl xmlnodemap_vtbl =
305 xmlnodemap_QueryInterface,
306 xmlnodemap_AddRef,
307 xmlnodemap_Release,
308 xmlnodemap_GetTypeInfoCount,
309 xmlnodemap_GetTypeInfo,
310 xmlnodemap_GetIDsOfNames,
311 xmlnodemap_Invoke,
312 xmlnodemap_getNamedItem,
313 xmlnodemap_setNamedItem,
314 xmlnodemap_removeNamedItem,
315 xmlnodemap_get_item,
316 xmlnodemap_get_length,
317 xmlnodemap_getQualifiedItem,
318 xmlnodemap_removeQualifiedItem,
319 xmlnodemap_nextNode,
320 xmlnodemap_reset,
321 xmlnodemap__newEnum,
324 IXMLDOMNamedNodeMap *create_nodemap( IXMLDOMNode *node )
326 xmlnodemap *nodemap;
328 nodemap = HeapAlloc( GetProcessHeap(), 0, sizeof *nodemap );
329 if ( !nodemap )
330 return NULL;
332 nodemap->lpVtbl = &xmlnodemap_vtbl;
333 nodemap->node = node;
334 nodemap->ref = 1;
336 IXMLDOMNode_AddRef( node );
337 /* Since we AddRef a node here, we don't need to call xmldoc_add_ref() */
339 return (IXMLDOMNamedNodeMap*) &nodemap->lpVtbl;
342 #endif