quartz: Fix IAMDirectSound interface definition.
[wine/multimedia.git] / dlls / msxml3 / attribute.c
blob04b8c46cb4edded1392904b8209dd922657d1811
1 /*
2 * DOM Attribute implementation
4 * Copyright 2006 Huw Davies
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _domattr
42 xmlnode node;
43 const struct IXMLDOMAttributeVtbl *lpVtbl;
44 LONG ref;
45 } domattr;
47 static inline domattr *impl_from_IXMLDOMAttribute( IXMLDOMAttribute *iface )
49 return (domattr *)((char*)iface - FIELD_OFFSET(domattr, lpVtbl));
52 static HRESULT WINAPI domattr_QueryInterface(
53 IXMLDOMAttribute *iface,
54 REFIID riid,
55 void** ppvObject )
57 domattr *This = impl_from_IXMLDOMAttribute( iface );
58 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
60 if ( IsEqualGUID( riid, &IID_IXMLDOMAttribute ) ||
61 IsEqualGUID( riid, &IID_IDispatch ) ||
62 IsEqualGUID( riid, &IID_IUnknown ) )
64 *ppvObject = iface;
66 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
68 *ppvObject = IXMLDOMNode_from_impl(&This->node);
70 else
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
76 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
77 return S_OK;
80 static ULONG WINAPI domattr_AddRef(
81 IXMLDOMAttribute *iface )
83 domattr *This = impl_from_IXMLDOMAttribute( iface );
84 return InterlockedIncrement( &This->ref );
87 static ULONG WINAPI domattr_Release(
88 IXMLDOMAttribute *iface )
90 domattr *This = impl_from_IXMLDOMAttribute( iface );
91 ULONG ref;
93 ref = InterlockedDecrement( &This->ref );
94 if ( ref == 0 )
96 destroy_xmlnode(&This->node);
97 heap_free( This );
100 return ref;
103 static HRESULT WINAPI domattr_GetTypeInfoCount(
104 IXMLDOMAttribute *iface,
105 UINT* pctinfo )
107 domattr *This = impl_from_IXMLDOMAttribute( iface );
109 TRACE("(%p)->(%p)\n", This, pctinfo);
111 *pctinfo = 1;
113 return S_OK;
116 static HRESULT WINAPI domattr_GetTypeInfo(
117 IXMLDOMAttribute *iface,
118 UINT iTInfo, LCID lcid,
119 ITypeInfo** ppTInfo )
121 domattr *This = impl_from_IXMLDOMAttribute( iface );
122 HRESULT hr;
124 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
126 hr = get_typeinfo(IXMLDOMAttribute_tid, ppTInfo);
128 return hr;
131 static HRESULT WINAPI domattr_GetIDsOfNames(
132 IXMLDOMAttribute *iface,
133 REFIID riid, LPOLESTR* rgszNames,
134 UINT cNames, LCID lcid, DISPID* rgDispId )
136 domattr *This = impl_from_IXMLDOMAttribute( iface );
137 ITypeInfo *typeinfo;
138 HRESULT hr;
140 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
141 lcid, rgDispId);
143 if(!rgszNames || cNames == 0 || !rgDispId)
144 return E_INVALIDARG;
146 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
147 if(SUCCEEDED(hr))
149 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
150 ITypeInfo_Release(typeinfo);
153 return hr;
156 static HRESULT WINAPI domattr_Invoke(
157 IXMLDOMAttribute *iface,
158 DISPID dispIdMember, REFIID riid, LCID lcid,
159 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
160 EXCEPINFO* pExcepInfo, UINT* puArgErr )
162 domattr *This = impl_from_IXMLDOMAttribute( iface );
163 ITypeInfo *typeinfo;
164 HRESULT hr;
166 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
167 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
169 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
170 if(SUCCEEDED(hr))
172 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
173 pVarResult, pExcepInfo, puArgErr);
174 ITypeInfo_Release(typeinfo);
176 return hr;
179 static HRESULT WINAPI domattr_get_nodeName(
180 IXMLDOMAttribute *iface,
181 BSTR* p )
183 domattr *This = impl_from_IXMLDOMAttribute( iface );
184 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
187 static HRESULT WINAPI domattr_get_nodeValue(
188 IXMLDOMAttribute *iface,
189 VARIANT* var1 )
191 domattr *This = impl_from_IXMLDOMAttribute( iface );
192 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
195 static HRESULT WINAPI domattr_put_nodeValue(
196 IXMLDOMAttribute *iface,
197 VARIANT var1 )
199 domattr *This = impl_from_IXMLDOMAttribute( iface );
200 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
203 static HRESULT WINAPI domattr_get_nodeType(
204 IXMLDOMAttribute *iface,
205 DOMNodeType* domNodeType )
207 domattr *This = impl_from_IXMLDOMAttribute( iface );
208 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), domNodeType );
211 static HRESULT WINAPI domattr_get_parentNode(
212 IXMLDOMAttribute *iface,
213 IXMLDOMNode** parent )
215 domattr *This = impl_from_IXMLDOMAttribute( iface );
216 return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent );
219 static HRESULT WINAPI domattr_get_childNodes(
220 IXMLDOMAttribute *iface,
221 IXMLDOMNodeList** outList)
223 domattr *This = impl_from_IXMLDOMAttribute( iface );
224 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
227 static HRESULT WINAPI domattr_get_firstChild(
228 IXMLDOMAttribute *iface,
229 IXMLDOMNode** domNode)
231 domattr *This = impl_from_IXMLDOMAttribute( iface );
232 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
235 static HRESULT WINAPI domattr_get_lastChild(
236 IXMLDOMAttribute *iface,
237 IXMLDOMNode** domNode)
239 domattr *This = impl_from_IXMLDOMAttribute( iface );
240 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
243 static HRESULT WINAPI domattr_get_previousSibling(
244 IXMLDOMAttribute *iface,
245 IXMLDOMNode** domNode)
247 domattr *This = impl_from_IXMLDOMAttribute( iface );
248 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
251 static HRESULT WINAPI domattr_get_nextSibling(
252 IXMLDOMAttribute *iface,
253 IXMLDOMNode** domNode)
255 domattr *This = impl_from_IXMLDOMAttribute( iface );
256 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
259 static HRESULT WINAPI domattr_get_attributes(
260 IXMLDOMAttribute *iface,
261 IXMLDOMNamedNodeMap** attributeMap)
263 domattr *This = impl_from_IXMLDOMAttribute( iface );
264 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
267 static HRESULT WINAPI domattr_insertBefore(
268 IXMLDOMAttribute *iface,
269 IXMLDOMNode* newNode, VARIANT var1,
270 IXMLDOMNode** outOldNode)
272 domattr *This = impl_from_IXMLDOMAttribute( iface );
273 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
276 static HRESULT WINAPI domattr_replaceChild(
277 IXMLDOMAttribute *iface,
278 IXMLDOMNode* newNode,
279 IXMLDOMNode* oldNode,
280 IXMLDOMNode** outOldNode)
282 domattr *This = impl_from_IXMLDOMAttribute( iface );
283 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
286 static HRESULT WINAPI domattr_removeChild(
287 IXMLDOMAttribute *iface,
288 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
290 domattr *This = impl_from_IXMLDOMAttribute( iface );
291 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
294 static HRESULT WINAPI domattr_appendChild(
295 IXMLDOMAttribute *iface,
296 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
298 domattr *This = impl_from_IXMLDOMAttribute( iface );
299 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
302 static HRESULT WINAPI domattr_hasChildNodes(
303 IXMLDOMAttribute *iface,
304 VARIANT_BOOL* pbool)
306 domattr *This = impl_from_IXMLDOMAttribute( iface );
307 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
310 static HRESULT WINAPI domattr_get_ownerDocument(
311 IXMLDOMAttribute *iface,
312 IXMLDOMDocument** domDocument)
314 domattr *This = impl_from_IXMLDOMAttribute( iface );
315 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
318 static HRESULT WINAPI domattr_cloneNode(
319 IXMLDOMAttribute *iface,
320 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
322 domattr *This = impl_from_IXMLDOMAttribute( iface );
323 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
326 static HRESULT WINAPI domattr_get_nodeTypeString(
327 IXMLDOMAttribute *iface,
328 BSTR* p)
330 domattr *This = impl_from_IXMLDOMAttribute( iface );
331 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
334 static HRESULT WINAPI domattr_get_text(
335 IXMLDOMAttribute *iface,
336 BSTR* p)
338 domattr *This = impl_from_IXMLDOMAttribute( iface );
339 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
342 static HRESULT WINAPI domattr_put_text(
343 IXMLDOMAttribute *iface,
344 BSTR p)
346 domattr *This = impl_from_IXMLDOMAttribute( iface );
347 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
350 static HRESULT WINAPI domattr_get_specified(
351 IXMLDOMAttribute *iface,
352 VARIANT_BOOL* pbool)
354 domattr *This = impl_from_IXMLDOMAttribute( iface );
355 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
358 static HRESULT WINAPI domattr_get_definition(
359 IXMLDOMAttribute *iface,
360 IXMLDOMNode** domNode)
362 domattr *This = impl_from_IXMLDOMAttribute( iface );
363 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
366 static HRESULT WINAPI domattr_get_nodeTypedValue(
367 IXMLDOMAttribute *iface,
368 VARIANT* var1)
370 domattr *This = impl_from_IXMLDOMAttribute( iface );
371 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
374 static HRESULT WINAPI domattr_put_nodeTypedValue(
375 IXMLDOMAttribute *iface,
376 VARIANT var1)
378 domattr *This = impl_from_IXMLDOMAttribute( iface );
379 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
382 static HRESULT WINAPI domattr_get_dataType(
383 IXMLDOMAttribute *iface,
384 VARIANT* var1)
386 domattr *This = impl_from_IXMLDOMAttribute( iface );
387 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
390 static HRESULT WINAPI domattr_put_dataType(
391 IXMLDOMAttribute *iface,
392 BSTR p)
394 domattr *This = impl_from_IXMLDOMAttribute( iface );
395 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
398 static HRESULT WINAPI domattr_get_xml(
399 IXMLDOMAttribute *iface,
400 BSTR* p)
402 domattr *This = impl_from_IXMLDOMAttribute( iface );
403 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
406 static HRESULT WINAPI domattr_transformNode(
407 IXMLDOMAttribute *iface,
408 IXMLDOMNode* domNode, BSTR* p)
410 domattr *This = impl_from_IXMLDOMAttribute( iface );
411 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
414 static HRESULT WINAPI domattr_selectNodes(
415 IXMLDOMAttribute *iface,
416 BSTR p, IXMLDOMNodeList** outList)
418 domattr *This = impl_from_IXMLDOMAttribute( iface );
419 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
422 static HRESULT WINAPI domattr_selectSingleNode(
423 IXMLDOMAttribute *iface,
424 BSTR p, IXMLDOMNode** outNode)
426 domattr *This = impl_from_IXMLDOMAttribute( iface );
427 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
430 static HRESULT WINAPI domattr_get_parsed(
431 IXMLDOMAttribute *iface,
432 VARIANT_BOOL* pbool)
434 domattr *This = impl_from_IXMLDOMAttribute( iface );
435 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
438 static HRESULT WINAPI domattr_get_namespaceURI(
439 IXMLDOMAttribute *iface,
440 BSTR* p)
442 domattr *This = impl_from_IXMLDOMAttribute( iface );
443 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
446 static HRESULT WINAPI domattr_get_prefix(
447 IXMLDOMAttribute *iface,
448 BSTR* p)
450 domattr *This = impl_from_IXMLDOMAttribute( iface );
451 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
454 static HRESULT WINAPI domattr_get_baseName(
455 IXMLDOMAttribute *iface,
456 BSTR* p)
458 domattr *This = impl_from_IXMLDOMAttribute( iface );
459 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
462 static HRESULT WINAPI domattr_transformNodeToObject(
463 IXMLDOMAttribute *iface,
464 IXMLDOMNode* domNode, VARIANT var1)
466 domattr *This = impl_from_IXMLDOMAttribute( iface );
467 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
470 static HRESULT WINAPI domattr_get_name(
471 IXMLDOMAttribute *iface,
472 BSTR *p)
474 /* name property returns the same value as nodeName */
475 domattr *This = impl_from_IXMLDOMAttribute( iface );
476 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
479 static HRESULT WINAPI domattr_get_value(
480 IXMLDOMAttribute *iface,
481 VARIANT *var1)
483 domattr *This = impl_from_IXMLDOMAttribute( iface );
484 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
487 static HRESULT WINAPI domattr_put_value(
488 IXMLDOMAttribute *iface,
489 VARIANT var1)
491 domattr *This = impl_from_IXMLDOMAttribute( iface );
492 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
495 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
497 domattr_QueryInterface,
498 domattr_AddRef,
499 domattr_Release,
500 domattr_GetTypeInfoCount,
501 domattr_GetTypeInfo,
502 domattr_GetIDsOfNames,
503 domattr_Invoke,
504 domattr_get_nodeName,
505 domattr_get_nodeValue,
506 domattr_put_nodeValue,
507 domattr_get_nodeType,
508 domattr_get_parentNode,
509 domattr_get_childNodes,
510 domattr_get_firstChild,
511 domattr_get_lastChild,
512 domattr_get_previousSibling,
513 domattr_get_nextSibling,
514 domattr_get_attributes,
515 domattr_insertBefore,
516 domattr_replaceChild,
517 domattr_removeChild,
518 domattr_appendChild,
519 domattr_hasChildNodes,
520 domattr_get_ownerDocument,
521 domattr_cloneNode,
522 domattr_get_nodeTypeString,
523 domattr_get_text,
524 domattr_put_text,
525 domattr_get_specified,
526 domattr_get_definition,
527 domattr_get_nodeTypedValue,
528 domattr_put_nodeTypedValue,
529 domattr_get_dataType,
530 domattr_put_dataType,
531 domattr_get_xml,
532 domattr_transformNode,
533 domattr_selectNodes,
534 domattr_selectSingleNode,
535 domattr_get_parsed,
536 domattr_get_namespaceURI,
537 domattr_get_prefix,
538 domattr_get_baseName,
539 domattr_transformNodeToObject,
540 domattr_get_name,
541 domattr_get_value,
542 domattr_put_value
545 IUnknown* create_attribute( xmlNodePtr attribute )
547 domattr *This;
549 This = heap_alloc( sizeof *This );
550 if ( !This )
551 return NULL;
553 This->lpVtbl = &domattr_vtbl;
554 This->ref = 1;
556 init_xmlnode(&This->node, attribute, (IUnknown*)&This->lpVtbl, NULL);
558 return (IUnknown*) &This->lpVtbl;
561 #endif