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 const tid_t domattr_se_tids[] = {
59 static inline domattr *impl_from_IXMLDOMAttribute( IXMLDOMAttribute *iface )
61 return CONTAINING_RECORD(iface, domattr, IXMLDOMAttribute_iface);
64 static HRESULT WINAPI domattr_QueryInterface(
65 IXMLDOMAttribute *iface,
69 domattr *This = impl_from_IXMLDOMAttribute( iface );
70 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
72 if ( IsEqualGUID( riid, &IID_IXMLDOMAttribute ) ||
73 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
74 IsEqualGUID( riid, &IID_IDispatch ) ||
75 IsEqualGUID( riid, &IID_IUnknown ) )
79 else if(node_query_interface(&This->node, riid, ppvObject))
81 return *ppvObject ? S_OK : E_NOINTERFACE;
83 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
85 return node_create_supporterrorinfo(domattr_se_tids, ppvObject);
89 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
94 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
98 static ULONG WINAPI domattr_AddRef(
99 IXMLDOMAttribute *iface )
101 domattr *This = impl_from_IXMLDOMAttribute( iface );
102 ULONG ref = InterlockedIncrement( &This->ref );
103 TRACE("(%p)->(%d)\n", This, ref);
107 static ULONG WINAPI domattr_Release(
108 IXMLDOMAttribute *iface )
110 domattr *This = impl_from_IXMLDOMAttribute( iface );
111 ULONG ref = InterlockedDecrement( &This->ref );
113 TRACE("(%p)->(%d)\n", This, ref);
116 destroy_xmlnode(&This->node);
123 static HRESULT WINAPI domattr_GetTypeInfoCount(
124 IXMLDOMAttribute *iface,
127 domattr *This = impl_from_IXMLDOMAttribute( iface );
128 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
131 static HRESULT WINAPI domattr_GetTypeInfo(
132 IXMLDOMAttribute *iface,
133 UINT iTInfo, LCID lcid,
134 ITypeInfo** ppTInfo )
136 domattr *This = impl_from_IXMLDOMAttribute( iface );
137 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
138 iTInfo, lcid, 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 );
147 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
148 riid, rgszNames, cNames, lcid, rgDispId);
151 static HRESULT WINAPI domattr_Invoke(
152 IXMLDOMAttribute *iface,
153 DISPID dispIdMember, REFIID riid, LCID lcid,
154 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
155 EXCEPINFO* pExcepInfo, UINT* puArgErr )
157 domattr *This = impl_from_IXMLDOMAttribute( iface );
158 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
159 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
162 static HRESULT WINAPI domattr_get_nodeName(
163 IXMLDOMAttribute *iface,
166 domattr *This = impl_from_IXMLDOMAttribute( iface );
168 TRACE("(%p)->(%p)\n", This, p);
170 return node_get_nodeName(&This->node, p);
173 static HRESULT WINAPI domattr_get_nodeValue(
174 IXMLDOMAttribute *iface,
177 domattr *This = impl_from_IXMLDOMAttribute( iface );
179 TRACE("(%p)->(%p)\n", This, value);
181 return node_get_content(&This->node, value);
184 static HRESULT WINAPI domattr_put_nodeValue(
185 IXMLDOMAttribute *iface,
188 domattr *This = impl_from_IXMLDOMAttribute( iface );
190 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
192 return node_put_value_escaped(&This->node, &value);
195 static HRESULT WINAPI domattr_get_nodeType(
196 IXMLDOMAttribute *iface,
197 DOMNodeType* domNodeType )
199 domattr *This = impl_from_IXMLDOMAttribute( iface );
201 TRACE("(%p)->(%p)\n", This, domNodeType);
203 *domNodeType = NODE_ATTRIBUTE;
207 static HRESULT WINAPI domattr_get_parentNode(
208 IXMLDOMAttribute *iface,
209 IXMLDOMNode** parent )
211 domattr *This = impl_from_IXMLDOMAttribute( iface );
212 TRACE("(%p)->(%p)\n", This, parent);
213 if (!parent) return E_INVALIDARG;
218 static HRESULT WINAPI domattr_get_childNodes(
219 IXMLDOMAttribute *iface,
220 IXMLDOMNodeList** outList)
222 domattr *This = impl_from_IXMLDOMAttribute( iface );
224 TRACE("(%p)->(%p)\n", This, outList);
226 return node_get_child_nodes(&This->node, outList);
229 static HRESULT WINAPI domattr_get_firstChild(
230 IXMLDOMAttribute *iface,
231 IXMLDOMNode** domNode)
233 domattr *This = impl_from_IXMLDOMAttribute( iface );
235 TRACE("(%p)->(%p)\n", This, domNode);
237 return node_get_first_child(&This->node, domNode);
240 static HRESULT WINAPI domattr_get_lastChild(
241 IXMLDOMAttribute *iface,
242 IXMLDOMNode** domNode)
244 domattr *This = impl_from_IXMLDOMAttribute( iface );
246 TRACE("(%p)->(%p)\n", This, domNode);
248 return node_get_last_child(&This->node, domNode);
251 static HRESULT WINAPI domattr_get_previousSibling(
252 IXMLDOMAttribute *iface,
253 IXMLDOMNode** domNode)
255 domattr *This = impl_from_IXMLDOMAttribute( iface );
257 TRACE("(%p)->(%p)\n", This, domNode);
259 return return_null_node(domNode);
262 static HRESULT WINAPI domattr_get_nextSibling(
263 IXMLDOMAttribute *iface,
264 IXMLDOMNode** domNode)
266 domattr *This = impl_from_IXMLDOMAttribute( iface );
268 TRACE("(%p)->(%p)\n", This, domNode);
270 return return_null_node(domNode);
273 static HRESULT WINAPI domattr_get_attributes(
274 IXMLDOMAttribute *iface,
275 IXMLDOMNamedNodeMap** attributeMap)
277 domattr *This = impl_from_IXMLDOMAttribute( iface );
279 TRACE("(%p)->(%p)\n", This, attributeMap);
281 return return_null_ptr((void**)attributeMap);
284 static HRESULT WINAPI domattr_insertBefore(
285 IXMLDOMAttribute *iface,
286 IXMLDOMNode* newNode, VARIANT refChild,
287 IXMLDOMNode** old_node)
289 domattr *This = impl_from_IXMLDOMAttribute( iface );
293 FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), old_node);
295 if (!newNode) return E_INVALIDARG;
297 hr = IXMLDOMNode_get_nodeType(newNode, &type);
298 if (hr != S_OK) return hr;
300 TRACE("new node type %d\n", type);
304 case NODE_CDATA_SECTION:
307 case NODE_PROCESSING_INSTRUCTION:
308 if (old_node) *old_node = NULL;
311 return node_insert_before(&This->node, newNode, &refChild, old_node);
315 static HRESULT WINAPI domattr_replaceChild(
316 IXMLDOMAttribute *iface,
317 IXMLDOMNode* newNode,
318 IXMLDOMNode* oldNode,
319 IXMLDOMNode** outOldNode)
321 domattr *This = impl_from_IXMLDOMAttribute( iface );
323 FIXME("(%p)->(%p %p %p) needs tests\n", This, newNode, oldNode, outOldNode);
325 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
328 static HRESULT WINAPI domattr_removeChild(
329 IXMLDOMAttribute *iface,
330 IXMLDOMNode *child, IXMLDOMNode **oldChild)
332 domattr *This = impl_from_IXMLDOMAttribute( iface );
333 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
334 return node_remove_child(&This->node, child, oldChild);
337 static HRESULT WINAPI domattr_appendChild(
338 IXMLDOMAttribute *iface,
339 IXMLDOMNode *child, IXMLDOMNode **outChild)
341 domattr *This = impl_from_IXMLDOMAttribute( iface );
342 TRACE("(%p)->(%p %p)\n", This, child, outChild);
343 return node_append_child(&This->node, child, outChild);
346 static HRESULT WINAPI domattr_hasChildNodes(
347 IXMLDOMAttribute *iface,
350 domattr *This = impl_from_IXMLDOMAttribute( iface );
351 TRACE("(%p)->(%p)\n", This, ret);
352 return node_has_childnodes(&This->node, ret);
355 static HRESULT WINAPI domattr_get_ownerDocument(
356 IXMLDOMAttribute *iface,
357 IXMLDOMDocument **doc)
359 domattr *This = impl_from_IXMLDOMAttribute( iface );
360 TRACE("(%p)->(%p)\n", This, doc);
361 return node_get_owner_doc(&This->node, doc);
364 static HRESULT WINAPI domattr_cloneNode(
365 IXMLDOMAttribute *iface,
366 VARIANT_BOOL deep, IXMLDOMNode** outNode)
368 domattr *This = impl_from_IXMLDOMAttribute( iface );
369 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
370 return node_clone( &This->node, deep, outNode );
373 static HRESULT WINAPI domattr_get_nodeTypeString(
374 IXMLDOMAttribute *iface,
377 domattr *This = impl_from_IXMLDOMAttribute( iface );
378 static const WCHAR attributeW[] = {'a','t','t','r','i','b','u','t','e',0};
380 TRACE("(%p)->(%p)\n", This, p);
382 return return_bstr(attributeW, p);
385 static HRESULT WINAPI domattr_get_text(
386 IXMLDOMAttribute *iface,
389 domattr *This = impl_from_IXMLDOMAttribute( iface );
390 TRACE("(%p)->(%p)\n", This, p);
391 return node_get_text(&This->node, p);
394 static HRESULT WINAPI domattr_put_text(
395 IXMLDOMAttribute *iface,
398 domattr *This = impl_from_IXMLDOMAttribute( iface );
399 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
400 return node_put_text( &This->node, p );
403 static HRESULT WINAPI domattr_get_specified(
404 IXMLDOMAttribute *iface,
405 VARIANT_BOOL* isSpecified)
407 domattr *This = impl_from_IXMLDOMAttribute( iface );
408 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
409 *isSpecified = VARIANT_TRUE;
413 static HRESULT WINAPI domattr_get_definition(
414 IXMLDOMAttribute *iface,
415 IXMLDOMNode** definitionNode)
417 domattr *This = impl_from_IXMLDOMAttribute( iface );
418 FIXME("(%p)->(%p)\n", This, definitionNode);
422 static HRESULT WINAPI domattr_get_nodeTypedValue(
423 IXMLDOMAttribute *iface,
426 domattr *This = impl_from_IXMLDOMAttribute( iface );
427 IXMLDOMDocument *doc;
430 TRACE("(%p)->(%p)\n", This, value);
432 hr = IXMLDOMAttribute_get_ownerDocument(iface, &doc);
435 IXMLDOMDocument3 *doc3;
437 hr = IXMLDOMDocument_QueryInterface(doc, &IID_IXMLDOMDocument3, (void**)&doc3);
438 IXMLDOMDocument_Release(doc);
444 hr = IXMLDOMDocument3_get_schemas(doc3, &schemas);
445 IXMLDOMDocument3_Release(doc3);
448 return IXMLDOMAttribute_get_value(iface, value);
451 FIXME("need to query schema for attribute type\n");
452 VariantClear(&schemas);
457 return return_null_var(value);
460 static HRESULT WINAPI domattr_put_nodeTypedValue(
461 IXMLDOMAttribute *iface,
464 domattr *This = impl_from_IXMLDOMAttribute( iface );
465 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
469 static HRESULT WINAPI domattr_get_dataType(
470 IXMLDOMAttribute *iface,
473 domattr *This = impl_from_IXMLDOMAttribute( iface );
474 TRACE("(%p)->(%p)\n", This, typename);
475 return return_null_var( typename );
478 static HRESULT WINAPI domattr_put_dataType(
479 IXMLDOMAttribute *iface,
482 domattr *This = impl_from_IXMLDOMAttribute( iface );
484 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
492 static HRESULT WINAPI domattr_get_xml(
493 IXMLDOMAttribute *iface,
496 domattr *This = impl_from_IXMLDOMAttribute( iface );
498 TRACE("(%p)->(%p)\n", This, p);
500 return node_get_xml(&This->node, FALSE, FALSE, p);
503 static HRESULT WINAPI domattr_transformNode(
504 IXMLDOMAttribute *iface,
505 IXMLDOMNode *node, BSTR *p)
507 domattr *This = impl_from_IXMLDOMAttribute( iface );
508 TRACE("(%p)->(%p %p)\n", This, node, p);
509 return node_transform_node(&This->node, node, p);
512 static HRESULT WINAPI domattr_selectNodes(
513 IXMLDOMAttribute *iface,
514 BSTR p, IXMLDOMNodeList** outList)
516 domattr *This = impl_from_IXMLDOMAttribute( iface );
517 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
518 return node_select_nodes(&This->node, p, outList);
521 static HRESULT WINAPI domattr_selectSingleNode(
522 IXMLDOMAttribute *iface,
523 BSTR p, IXMLDOMNode** outNode)
525 domattr *This = impl_from_IXMLDOMAttribute( iface );
526 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
527 return node_select_singlenode(&This->node, p, outNode);
530 static HRESULT WINAPI domattr_get_parsed(
531 IXMLDOMAttribute *iface,
532 VARIANT_BOOL* isParsed)
534 domattr *This = impl_from_IXMLDOMAttribute( iface );
535 FIXME("(%p)->(%p) stub!\n", This, isParsed);
536 *isParsed = VARIANT_TRUE;
540 static HRESULT WINAPI domattr_get_namespaceURI(
541 IXMLDOMAttribute *iface,
544 domattr *This = impl_from_IXMLDOMAttribute( iface );
545 TRACE("(%p)->(%p)\n", This, p);
546 return node_get_namespaceURI(&This->node, p);
549 static HRESULT WINAPI domattr_get_prefix(
550 IXMLDOMAttribute *iface,
553 domattr *This = impl_from_IXMLDOMAttribute( iface );
554 TRACE("(%p)->(%p)\n", This, prefix);
555 return node_get_prefix( &This->node, prefix );
558 static HRESULT WINAPI domattr_get_baseName(
559 IXMLDOMAttribute *iface,
562 domattr *This = impl_from_IXMLDOMAttribute( iface );
563 TRACE("(%p)->(%p)\n", This, name);
564 return node_get_base_name( &This->node, name );
567 static HRESULT WINAPI domattr_transformNodeToObject(
568 IXMLDOMAttribute *iface,
569 IXMLDOMNode* domNode, VARIANT var1)
571 domattr *This = impl_from_IXMLDOMAttribute( iface );
572 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
576 static HRESULT WINAPI domattr_get_name(
577 IXMLDOMAttribute *iface,
580 domattr *This = impl_from_IXMLDOMAttribute( iface );
582 TRACE("(%p)->(%p)\n", This, p);
584 return node_get_nodeName(&This->node, p);
587 static HRESULT WINAPI domattr_get_value(
588 IXMLDOMAttribute *iface,
591 domattr *This = impl_from_IXMLDOMAttribute( iface );
593 TRACE("(%p)->(%p)\n", This, value);
595 return node_get_content(&This->node, value);
598 static HRESULT WINAPI domattr_put_value(
599 IXMLDOMAttribute *iface,
602 domattr *This = impl_from_IXMLDOMAttribute( iface );
604 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
606 return node_put_value(&This->node, &value);
609 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
611 domattr_QueryInterface,
614 domattr_GetTypeInfoCount,
616 domattr_GetIDsOfNames,
618 domattr_get_nodeName,
619 domattr_get_nodeValue,
620 domattr_put_nodeValue,
621 domattr_get_nodeType,
622 domattr_get_parentNode,
623 domattr_get_childNodes,
624 domattr_get_firstChild,
625 domattr_get_lastChild,
626 domattr_get_previousSibling,
627 domattr_get_nextSibling,
628 domattr_get_attributes,
629 domattr_insertBefore,
630 domattr_replaceChild,
633 domattr_hasChildNodes,
634 domattr_get_ownerDocument,
636 domattr_get_nodeTypeString,
639 domattr_get_specified,
640 domattr_get_definition,
641 domattr_get_nodeTypedValue,
642 domattr_put_nodeTypedValue,
643 domattr_get_dataType,
644 domattr_put_dataType,
646 domattr_transformNode,
648 domattr_selectSingleNode,
650 domattr_get_namespaceURI,
652 domattr_get_baseName,
653 domattr_transformNodeToObject,
659 static const tid_t domattr_iface_tids[] = {
660 IXMLDOMAttribute_tid,
664 static dispex_static_data_t domattr_dispex = {
666 IXMLDOMAttribute_tid,
671 IUnknown* create_attribute( xmlNodePtr attribute )
675 This = heap_alloc( sizeof *This );
679 This->IXMLDOMAttribute_iface.lpVtbl = &domattr_vtbl;
682 init_xmlnode(&This->node, attribute, (IXMLDOMNode*)&This->IXMLDOMAttribute_iface, &domattr_dispex);
684 return (IUnknown*)&This->IXMLDOMAttribute_iface;