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
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 # include <libxml/HTMLtree.h>
38 #include "msxml_private.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
46 typedef struct _domattr
49 IXMLDOMAttribute IXMLDOMAttribute_iface
;
53 static inline domattr
*impl_from_IXMLDOMAttribute( IXMLDOMAttribute
*iface
)
55 return CONTAINING_RECORD(iface
, domattr
, IXMLDOMAttribute_iface
);
58 static HRESULT WINAPI
domattr_QueryInterface(
59 IXMLDOMAttribute
*iface
,
63 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
64 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
66 if ( IsEqualGUID( riid
, &IID_IXMLDOMAttribute
) ||
67 IsEqualGUID( riid
, &IID_IXMLDOMNode
) ||
68 IsEqualGUID( riid
, &IID_IDispatch
) ||
69 IsEqualGUID( riid
, &IID_IUnknown
) )
73 else if(node_query_interface(&This
->node
, riid
, ppvObject
))
75 return *ppvObject
? S_OK
: E_NOINTERFACE
;
79 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
84 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
88 static ULONG WINAPI
domattr_AddRef(
89 IXMLDOMAttribute
*iface
)
91 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
92 ULONG ref
= InterlockedIncrement( &This
->ref
);
93 TRACE("(%p)->(%d)\n", This
, ref
);
97 static ULONG WINAPI
domattr_Release(
98 IXMLDOMAttribute
*iface
)
100 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
101 ULONG ref
= InterlockedDecrement( &This
->ref
);
103 TRACE("(%p)->(%d)\n", This
, ref
);
106 destroy_xmlnode(&This
->node
);
113 static HRESULT WINAPI
domattr_GetTypeInfoCount(
114 IXMLDOMAttribute
*iface
,
117 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
119 TRACE("(%p)->(%p)\n", This
, pctinfo
);
126 static HRESULT WINAPI
domattr_GetTypeInfo(
127 IXMLDOMAttribute
*iface
,
128 UINT iTInfo
, LCID lcid
,
129 ITypeInfo
** ppTInfo
)
131 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
134 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
136 hr
= get_typeinfo(IXMLDOMAttribute_tid
, ppTInfo
);
141 static HRESULT WINAPI
domattr_GetIDsOfNames(
142 IXMLDOMAttribute
*iface
,
143 REFIID riid
, LPOLESTR
* rgszNames
,
144 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
146 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
150 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
153 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
156 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
159 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
160 ITypeInfo_Release(typeinfo
);
166 static HRESULT WINAPI
domattr_Invoke(
167 IXMLDOMAttribute
*iface
,
168 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
169 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
170 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
172 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
176 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
177 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
179 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
182 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMAttribute_iface
, dispIdMember
, wFlags
,
183 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
184 ITypeInfo_Release(typeinfo
);
189 static HRESULT WINAPI
domattr_get_nodeName(
190 IXMLDOMAttribute
*iface
,
193 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
195 TRACE("(%p)->(%p)\n", This
, p
);
197 return node_get_nodeName(&This
->node
, p
);
200 static HRESULT WINAPI
domattr_get_nodeValue(
201 IXMLDOMAttribute
*iface
,
204 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
206 TRACE("(%p)->(%p)\n", This
, value
);
208 return node_get_content(&This
->node
, value
);
211 static HRESULT WINAPI
domattr_put_nodeValue(
212 IXMLDOMAttribute
*iface
,
215 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
217 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
219 return node_put_value_escaped(&This
->node
, &value
);
222 static HRESULT WINAPI
domattr_get_nodeType(
223 IXMLDOMAttribute
*iface
,
224 DOMNodeType
* domNodeType
)
226 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
228 TRACE("(%p)->(%p)\n", This
, domNodeType
);
230 *domNodeType
= NODE_ATTRIBUTE
;
234 static HRESULT WINAPI
domattr_get_parentNode(
235 IXMLDOMAttribute
*iface
,
236 IXMLDOMNode
** parent
)
238 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
239 TRACE("(%p)->(%p)\n", This
, parent
);
240 if (!parent
) return E_INVALIDARG
;
245 static HRESULT WINAPI
domattr_get_childNodes(
246 IXMLDOMAttribute
*iface
,
247 IXMLDOMNodeList
** outList
)
249 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
251 TRACE("(%p)->(%p)\n", This
, outList
);
253 return node_get_child_nodes(&This
->node
, outList
);
256 static HRESULT WINAPI
domattr_get_firstChild(
257 IXMLDOMAttribute
*iface
,
258 IXMLDOMNode
** domNode
)
260 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
262 TRACE("(%p)->(%p)\n", This
, domNode
);
264 return node_get_first_child(&This
->node
, domNode
);
267 static HRESULT WINAPI
domattr_get_lastChild(
268 IXMLDOMAttribute
*iface
,
269 IXMLDOMNode
** domNode
)
271 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
273 TRACE("(%p)->(%p)\n", This
, domNode
);
275 return node_get_last_child(&This
->node
, domNode
);
278 static HRESULT WINAPI
domattr_get_previousSibling(
279 IXMLDOMAttribute
*iface
,
280 IXMLDOMNode
** domNode
)
282 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
284 TRACE("(%p)->(%p)\n", This
, domNode
);
286 return return_null_node(domNode
);
289 static HRESULT WINAPI
domattr_get_nextSibling(
290 IXMLDOMAttribute
*iface
,
291 IXMLDOMNode
** domNode
)
293 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
295 TRACE("(%p)->(%p)\n", This
, domNode
);
297 return return_null_node(domNode
);
300 static HRESULT WINAPI
domattr_get_attributes(
301 IXMLDOMAttribute
*iface
,
302 IXMLDOMNamedNodeMap
** attributeMap
)
304 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
306 TRACE("(%p)->(%p)\n", This
, attributeMap
);
308 return return_null_ptr((void**)attributeMap
);
311 static HRESULT WINAPI
domattr_insertBefore(
312 IXMLDOMAttribute
*iface
,
313 IXMLDOMNode
* newNode
, VARIANT refChild
,
314 IXMLDOMNode
** old_node
)
316 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
320 FIXME("(%p)->(%p %s %p) needs test\n", This
, newNode
, debugstr_variant(&refChild
), old_node
);
322 if (!newNode
) return E_INVALIDARG
;
324 hr
= IXMLDOMNode_get_nodeType(newNode
, &type
);
325 if (hr
!= S_OK
) return hr
;
327 TRACE("new node type %d\n", type
);
331 case NODE_CDATA_SECTION
:
334 case NODE_PROCESSING_INSTRUCTION
:
335 if (old_node
) *old_node
= NULL
;
338 return node_insert_before(&This
->node
, newNode
, &refChild
, old_node
);
342 static HRESULT WINAPI
domattr_replaceChild(
343 IXMLDOMAttribute
*iface
,
344 IXMLDOMNode
* newNode
,
345 IXMLDOMNode
* oldNode
,
346 IXMLDOMNode
** outOldNode
)
348 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
350 FIXME("(%p)->(%p %p %p) needs tests\n", This
, newNode
, oldNode
, outOldNode
);
352 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
355 static HRESULT WINAPI
domattr_removeChild(
356 IXMLDOMAttribute
*iface
,
357 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
359 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
360 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
361 return node_remove_child(&This
->node
, child
, oldChild
);
364 static HRESULT WINAPI
domattr_appendChild(
365 IXMLDOMAttribute
*iface
,
366 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
368 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
369 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
370 return node_append_child(&This
->node
, child
, outChild
);
373 static HRESULT WINAPI
domattr_hasChildNodes(
374 IXMLDOMAttribute
*iface
,
377 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
378 TRACE("(%p)->(%p)\n", This
, ret
);
379 return node_has_childnodes(&This
->node
, ret
);
382 static HRESULT WINAPI
domattr_get_ownerDocument(
383 IXMLDOMAttribute
*iface
,
384 IXMLDOMDocument
**doc
)
386 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
387 TRACE("(%p)->(%p)\n", This
, doc
);
388 return node_get_owner_doc(&This
->node
, doc
);
391 static HRESULT WINAPI
domattr_cloneNode(
392 IXMLDOMAttribute
*iface
,
393 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
395 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
396 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
397 return node_clone( &This
->node
, deep
, outNode
);
400 static HRESULT WINAPI
domattr_get_nodeTypeString(
401 IXMLDOMAttribute
*iface
,
404 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
405 static const WCHAR attributeW
[] = {'a','t','t','r','i','b','u','t','e',0};
407 TRACE("(%p)->(%p)\n", This
, p
);
409 return return_bstr(attributeW
, p
);
412 static HRESULT WINAPI
domattr_get_text(
413 IXMLDOMAttribute
*iface
,
416 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
417 TRACE("(%p)->(%p)\n", This
, p
);
418 return node_get_text(&This
->node
, p
);
421 static HRESULT WINAPI
domattr_put_text(
422 IXMLDOMAttribute
*iface
,
425 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
426 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
427 return node_put_text( &This
->node
, p
);
430 static HRESULT WINAPI
domattr_get_specified(
431 IXMLDOMAttribute
*iface
,
432 VARIANT_BOOL
* isSpecified
)
434 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
435 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
436 *isSpecified
= VARIANT_TRUE
;
440 static HRESULT WINAPI
domattr_get_definition(
441 IXMLDOMAttribute
*iface
,
442 IXMLDOMNode
** definitionNode
)
444 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
445 FIXME("(%p)->(%p)\n", This
, definitionNode
);
449 static HRESULT WINAPI
domattr_get_nodeTypedValue(
450 IXMLDOMAttribute
*iface
,
453 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
454 FIXME("(%p)->(%p)\n", This
, var1
);
455 return return_null_var(var1
);
458 static HRESULT WINAPI
domattr_put_nodeTypedValue(
459 IXMLDOMAttribute
*iface
,
462 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
463 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
467 static HRESULT WINAPI
domattr_get_dataType(
468 IXMLDOMAttribute
*iface
,
471 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
472 TRACE("(%p)->(%p)\n", This
, typename
);
473 return return_null_var( typename
);
476 static HRESULT WINAPI
domattr_put_dataType(
477 IXMLDOMAttribute
*iface
,
480 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
482 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
490 static HRESULT WINAPI
domattr_get_xml(
491 IXMLDOMAttribute
*iface
,
494 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
496 TRACE("(%p)->(%p)\n", This
, p
);
498 return node_get_xml(&This
->node
, FALSE
, FALSE
, p
);
501 static HRESULT WINAPI
domattr_transformNode(
502 IXMLDOMAttribute
*iface
,
503 IXMLDOMNode
*node
, BSTR
*p
)
505 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
506 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
507 return node_transform_node(&This
->node
, node
, p
);
510 static HRESULT WINAPI
domattr_selectNodes(
511 IXMLDOMAttribute
*iface
,
512 BSTR p
, IXMLDOMNodeList
** outList
)
514 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
515 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
516 return node_select_nodes(&This
->node
, p
, outList
);
519 static HRESULT WINAPI
domattr_selectSingleNode(
520 IXMLDOMAttribute
*iface
,
521 BSTR p
, IXMLDOMNode
** outNode
)
523 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
524 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
525 return node_select_singlenode(&This
->node
, p
, outNode
);
528 static HRESULT WINAPI
domattr_get_parsed(
529 IXMLDOMAttribute
*iface
,
530 VARIANT_BOOL
* isParsed
)
532 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
533 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
534 *isParsed
= VARIANT_TRUE
;
538 static HRESULT WINAPI
domattr_get_namespaceURI(
539 IXMLDOMAttribute
*iface
,
542 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
543 TRACE("(%p)->(%p)\n", This
, p
);
544 return node_get_namespaceURI(&This
->node
, p
);
547 static HRESULT WINAPI
domattr_get_prefix(
548 IXMLDOMAttribute
*iface
,
551 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
552 TRACE("(%p)->(%p)\n", This
, prefix
);
553 return node_get_prefix( &This
->node
, prefix
);
556 static HRESULT WINAPI
domattr_get_baseName(
557 IXMLDOMAttribute
*iface
,
560 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
561 TRACE("(%p)->(%p)\n", This
, name
);
562 return node_get_base_name( &This
->node
, name
);
565 static HRESULT WINAPI
domattr_transformNodeToObject(
566 IXMLDOMAttribute
*iface
,
567 IXMLDOMNode
* domNode
, VARIANT var1
)
569 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
570 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
574 static HRESULT WINAPI
domattr_get_name(
575 IXMLDOMAttribute
*iface
,
578 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
580 TRACE("(%p)->(%p)\n", This
, p
);
582 return node_get_nodeName(&This
->node
, p
);
585 static HRESULT WINAPI
domattr_get_value(
586 IXMLDOMAttribute
*iface
,
589 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
591 TRACE("(%p)->(%p)\n", This
, value
);
593 return node_get_content(&This
->node
, value
);
596 static HRESULT WINAPI
domattr_put_value(
597 IXMLDOMAttribute
*iface
,
600 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
602 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
604 return node_put_value(&This
->node
, &value
);
607 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
609 domattr_QueryInterface
,
612 domattr_GetTypeInfoCount
,
614 domattr_GetIDsOfNames
,
616 domattr_get_nodeName
,
617 domattr_get_nodeValue
,
618 domattr_put_nodeValue
,
619 domattr_get_nodeType
,
620 domattr_get_parentNode
,
621 domattr_get_childNodes
,
622 domattr_get_firstChild
,
623 domattr_get_lastChild
,
624 domattr_get_previousSibling
,
625 domattr_get_nextSibling
,
626 domattr_get_attributes
,
627 domattr_insertBefore
,
628 domattr_replaceChild
,
631 domattr_hasChildNodes
,
632 domattr_get_ownerDocument
,
634 domattr_get_nodeTypeString
,
637 domattr_get_specified
,
638 domattr_get_definition
,
639 domattr_get_nodeTypedValue
,
640 domattr_put_nodeTypedValue
,
641 domattr_get_dataType
,
642 domattr_put_dataType
,
644 domattr_transformNode
,
646 domattr_selectSingleNode
,
648 domattr_get_namespaceURI
,
650 domattr_get_baseName
,
651 domattr_transformNodeToObject
,
657 IUnknown
* create_attribute( xmlNodePtr attribute
)
661 This
= heap_alloc( sizeof *This
);
665 This
->IXMLDOMAttribute_iface
.lpVtbl
= &domattr_vtbl
;
668 init_xmlnode(&This
->node
, attribute
, (IXMLDOMNode
*)&This
->IXMLDOMAttribute_iface
, NULL
);
670 return (IUnknown
*)&This
->IXMLDOMAttribute_iface
;