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
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
40 typedef struct _domattr
43 const struct IXMLDOMAttributeVtbl
*lpVtbl
;
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
,
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_IXMLDOMNode
) ||
62 IsEqualGUID( riid
, &IID_IDispatch
) ||
63 IsEqualGUID( riid
, &IID_IUnknown
) )
67 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
69 return *ppvObject
? S_OK
: E_NOINTERFACE
;
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
77 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
81 static ULONG WINAPI
domattr_AddRef(
82 IXMLDOMAttribute
*iface
)
84 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
85 return InterlockedIncrement( &This
->ref
);
88 static ULONG WINAPI
domattr_Release(
89 IXMLDOMAttribute
*iface
)
91 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
94 ref
= InterlockedDecrement( &This
->ref
);
97 destroy_xmlnode(&This
->node
);
104 static HRESULT WINAPI
domattr_GetTypeInfoCount(
105 IXMLDOMAttribute
*iface
,
108 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
110 TRACE("(%p)->(%p)\n", This
, pctinfo
);
117 static HRESULT WINAPI
domattr_GetTypeInfo(
118 IXMLDOMAttribute
*iface
,
119 UINT iTInfo
, LCID lcid
,
120 ITypeInfo
** ppTInfo
)
122 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
125 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
127 hr
= get_typeinfo(IXMLDOMAttribute_tid
, ppTInfo
);
132 static HRESULT WINAPI
domattr_GetIDsOfNames(
133 IXMLDOMAttribute
*iface
,
134 REFIID riid
, LPOLESTR
* rgszNames
,
135 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
137 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
141 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
144 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
147 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
150 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
151 ITypeInfo_Release(typeinfo
);
157 static HRESULT WINAPI
domattr_Invoke(
158 IXMLDOMAttribute
*iface
,
159 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
160 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
161 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
163 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
168 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
170 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
173 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
174 pVarResult
, pExcepInfo
, puArgErr
);
175 ITypeInfo_Release(typeinfo
);
180 static HRESULT WINAPI
domattr_get_nodeName(
181 IXMLDOMAttribute
*iface
,
184 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
186 TRACE("(%p)->(%p)\n", This
, p
);
188 return node_get_nodeName(&This
->node
, p
);
191 static HRESULT WINAPI
domattr_get_nodeValue(
192 IXMLDOMAttribute
*iface
,
195 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
197 TRACE("(%p)->(%p)\n", This
, value
);
199 return node_get_content(&This
->node
, value
);
202 static HRESULT WINAPI
domattr_put_nodeValue(
203 IXMLDOMAttribute
*iface
,
206 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
208 TRACE("(%p)->(v%d)\n", This
, V_VT(&value
));
210 return node_put_value_escaped(&This
->node
, &value
);
213 static HRESULT WINAPI
domattr_get_nodeType(
214 IXMLDOMAttribute
*iface
,
215 DOMNodeType
* domNodeType
)
217 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
219 TRACE("(%p)->(%p)\n", This
, domNodeType
);
221 *domNodeType
= NODE_ATTRIBUTE
;
225 static HRESULT WINAPI
domattr_get_parentNode(
226 IXMLDOMAttribute
*iface
,
227 IXMLDOMNode
** parent
)
229 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
230 TRACE("(%p)->(%p)\n", This
, parent
);
231 if (!parent
) return E_INVALIDARG
;
236 static HRESULT WINAPI
domattr_get_childNodes(
237 IXMLDOMAttribute
*iface
,
238 IXMLDOMNodeList
** outList
)
240 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
242 TRACE("(%p)->(%p)\n", This
, outList
);
244 return node_get_child_nodes(&This
->node
, outList
);
247 static HRESULT WINAPI
domattr_get_firstChild(
248 IXMLDOMAttribute
*iface
,
249 IXMLDOMNode
** domNode
)
251 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
253 TRACE("(%p)->(%p)\n", This
, domNode
);
255 return node_get_first_child(&This
->node
, domNode
);
258 static HRESULT WINAPI
domattr_get_lastChild(
259 IXMLDOMAttribute
*iface
,
260 IXMLDOMNode
** domNode
)
262 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
264 TRACE("(%p)->(%p)\n", This
, domNode
);
266 return node_get_last_child(&This
->node
, domNode
);
269 static HRESULT WINAPI
domattr_get_previousSibling(
270 IXMLDOMAttribute
*iface
,
271 IXMLDOMNode
** domNode
)
273 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
275 TRACE("(%p)->(%p)\n", This
, domNode
);
277 return return_null_node(domNode
);
280 static HRESULT WINAPI
domattr_get_nextSibling(
281 IXMLDOMAttribute
*iface
,
282 IXMLDOMNode
** domNode
)
284 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
286 TRACE("(%p)->(%p)\n", This
, domNode
);
288 return return_null_node(domNode
);
291 static HRESULT WINAPI
domattr_get_attributes(
292 IXMLDOMAttribute
*iface
,
293 IXMLDOMNamedNodeMap
** attributeMap
)
295 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
297 TRACE("(%p)->(%p)\n", This
, attributeMap
);
299 return return_null_ptr((void**)attributeMap
);
302 static HRESULT WINAPI
domattr_insertBefore(
303 IXMLDOMAttribute
*iface
,
304 IXMLDOMNode
* newNode
, VARIANT refChild
,
305 IXMLDOMNode
** outOldNode
)
307 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
309 FIXME("(%p)->(%p x%d %p) needs test\n", This
, newNode
, V_VT(&refChild
), outOldNode
);
311 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
314 static HRESULT WINAPI
domattr_replaceChild(
315 IXMLDOMAttribute
*iface
,
316 IXMLDOMNode
* newNode
,
317 IXMLDOMNode
* oldNode
,
318 IXMLDOMNode
** outOldNode
)
320 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
322 FIXME("(%p)->(%p %p %p) needs tests\n", This
, newNode
, oldNode
, outOldNode
);
324 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
327 static HRESULT WINAPI
domattr_removeChild(
328 IXMLDOMAttribute
*iface
,
329 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
331 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
332 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), domNode
, oldNode
);
335 static HRESULT WINAPI
domattr_appendChild(
336 IXMLDOMAttribute
*iface
,
337 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
339 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
340 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, outNewNode
);
343 static HRESULT WINAPI
domattr_hasChildNodes(
344 IXMLDOMAttribute
*iface
,
347 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
348 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), pbool
);
351 static HRESULT WINAPI
domattr_get_ownerDocument(
352 IXMLDOMAttribute
*iface
,
353 IXMLDOMDocument
** domDocument
)
355 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
356 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), domDocument
);
359 static HRESULT WINAPI
domattr_cloneNode(
360 IXMLDOMAttribute
*iface
,
361 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
363 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
364 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
365 return node_clone( &This
->node
, deep
, outNode
);
368 static HRESULT WINAPI
domattr_get_nodeTypeString(
369 IXMLDOMAttribute
*iface
,
372 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
373 static const WCHAR attributeW
[] = {'a','t','t','r','i','b','u','t','e',0};
375 TRACE("(%p)->(%p)\n", This
, p
);
377 return return_bstr(attributeW
, p
);
380 static HRESULT WINAPI
domattr_get_text(
381 IXMLDOMAttribute
*iface
,
384 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
385 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), p
);
388 static HRESULT WINAPI
domattr_put_text(
389 IXMLDOMAttribute
*iface
,
392 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
393 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
394 return node_put_text( &This
->node
, p
);
397 static HRESULT WINAPI
domattr_get_specified(
398 IXMLDOMAttribute
*iface
,
399 VARIANT_BOOL
* isSpecified
)
401 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
402 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
403 *isSpecified
= VARIANT_TRUE
;
407 static HRESULT WINAPI
domattr_get_definition(
408 IXMLDOMAttribute
*iface
,
409 IXMLDOMNode
** definitionNode
)
411 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
412 FIXME("(%p)->(%p)\n", This
, definitionNode
);
416 static HRESULT WINAPI
domattr_get_nodeTypedValue(
417 IXMLDOMAttribute
*iface
,
420 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
421 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
424 static HRESULT WINAPI
domattr_put_nodeTypedValue(
425 IXMLDOMAttribute
*iface
,
428 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
429 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
432 static HRESULT WINAPI
domattr_get_dataType(
433 IXMLDOMAttribute
*iface
,
436 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
437 TRACE("(%p)->(%p)\n", This
, typename
);
438 return return_null_var( typename
);
441 static HRESULT WINAPI
domattr_put_dataType(
442 IXMLDOMAttribute
*iface
,
445 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
446 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), p
);
449 static HRESULT WINAPI
domattr_get_xml(
450 IXMLDOMAttribute
*iface
,
453 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
455 TRACE("(%p)->(%p)\n", This
, p
);
457 return node_get_xml(&This
->node
, FALSE
, FALSE
, p
);
460 static HRESULT WINAPI
domattr_transformNode(
461 IXMLDOMAttribute
*iface
,
462 IXMLDOMNode
* domNode
, BSTR
* p
)
464 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
465 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), domNode
, p
);
468 static HRESULT WINAPI
domattr_selectNodes(
469 IXMLDOMAttribute
*iface
,
470 BSTR p
, IXMLDOMNodeList
** outList
)
472 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
473 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), p
, outList
);
476 static HRESULT WINAPI
domattr_selectSingleNode(
477 IXMLDOMAttribute
*iface
,
478 BSTR p
, IXMLDOMNode
** outNode
)
480 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
481 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), p
, outNode
);
484 static HRESULT WINAPI
domattr_get_parsed(
485 IXMLDOMAttribute
*iface
,
486 VARIANT_BOOL
* isParsed
)
488 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
489 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
490 *isParsed
= VARIANT_TRUE
;
494 static HRESULT WINAPI
domattr_get_namespaceURI(
495 IXMLDOMAttribute
*iface
,
498 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
499 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), p
);
502 static HRESULT WINAPI
domattr_get_prefix(
503 IXMLDOMAttribute
*iface
,
506 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
507 TRACE("(%p)->(%p)\n", This
, prefix
);
508 return node_get_prefix( &This
->node
, prefix
);
511 static HRESULT WINAPI
domattr_get_baseName(
512 IXMLDOMAttribute
*iface
,
515 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
516 TRACE("(%p)->(%p)\n", This
, name
);
517 return node_get_base_name( &This
->node
, name
);
520 static HRESULT WINAPI
domattr_transformNodeToObject(
521 IXMLDOMAttribute
*iface
,
522 IXMLDOMNode
* domNode
, VARIANT var1
)
524 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
525 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), domNode
, var1
);
528 static HRESULT WINAPI
domattr_get_name(
529 IXMLDOMAttribute
*iface
,
532 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
534 TRACE("(%p)->(%p)\n", This
, p
);
536 return node_get_nodeName(&This
->node
, p
);
539 static HRESULT WINAPI
domattr_get_value(
540 IXMLDOMAttribute
*iface
,
543 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
545 TRACE("(%p)->(%p)\n", This
, value
);
547 return node_get_content(&This
->node
, value
);
550 static HRESULT WINAPI
domattr_put_value(
551 IXMLDOMAttribute
*iface
,
554 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
556 TRACE("(%p)->(v%d)\n", This
, V_VT(&value
));
558 return node_put_value(&This
->node
, &value
);
561 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
563 domattr_QueryInterface
,
566 domattr_GetTypeInfoCount
,
568 domattr_GetIDsOfNames
,
570 domattr_get_nodeName
,
571 domattr_get_nodeValue
,
572 domattr_put_nodeValue
,
573 domattr_get_nodeType
,
574 domattr_get_parentNode
,
575 domattr_get_childNodes
,
576 domattr_get_firstChild
,
577 domattr_get_lastChild
,
578 domattr_get_previousSibling
,
579 domattr_get_nextSibling
,
580 domattr_get_attributes
,
581 domattr_insertBefore
,
582 domattr_replaceChild
,
585 domattr_hasChildNodes
,
586 domattr_get_ownerDocument
,
588 domattr_get_nodeTypeString
,
591 domattr_get_specified
,
592 domattr_get_definition
,
593 domattr_get_nodeTypedValue
,
594 domattr_put_nodeTypedValue
,
595 domattr_get_dataType
,
596 domattr_put_dataType
,
598 domattr_transformNode
,
600 domattr_selectSingleNode
,
602 domattr_get_namespaceURI
,
604 domattr_get_baseName
,
605 domattr_transformNodeToObject
,
611 IUnknown
* create_attribute( xmlNodePtr attribute
)
615 This
= heap_alloc( sizeof *This
);
619 This
->lpVtbl
= &domattr_vtbl
;
622 init_xmlnode(&This
->node
, attribute
, (IXMLDOMNode
*)&This
->lpVtbl
, NULL
);
624 return (IUnknown
*) &This
->lpVtbl
;