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(&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 );
321 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
324 static HRESULT WINAPI domattr_removeChild(
325 IXMLDOMAttribute *iface,
326 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
328 domattr *This = impl_from_IXMLDOMAttribute( iface );
329 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
332 static HRESULT WINAPI domattr_appendChild(
333 IXMLDOMAttribute *iface,
334 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
336 domattr *This = impl_from_IXMLDOMAttribute( iface );
337 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
340 static HRESULT WINAPI domattr_hasChildNodes(
341 IXMLDOMAttribute *iface,
344 domattr *This = impl_from_IXMLDOMAttribute( iface );
345 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
348 static HRESULT WINAPI domattr_get_ownerDocument(
349 IXMLDOMAttribute *iface,
350 IXMLDOMDocument** domDocument)
352 domattr *This = impl_from_IXMLDOMAttribute( iface );
353 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
356 static HRESULT WINAPI domattr_cloneNode(
357 IXMLDOMAttribute *iface,
358 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
360 domattr *This = impl_from_IXMLDOMAttribute( iface );
361 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
364 static HRESULT WINAPI domattr_get_nodeTypeString(
365 IXMLDOMAttribute *iface,
368 domattr *This = impl_from_IXMLDOMAttribute( iface );
369 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
372 static HRESULT WINAPI domattr_get_text(
373 IXMLDOMAttribute *iface,
376 domattr *This = impl_from_IXMLDOMAttribute( iface );
377 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
380 static HRESULT WINAPI domattr_put_text(
381 IXMLDOMAttribute *iface,
384 domattr *This = impl_from_IXMLDOMAttribute( iface );
385 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
388 static HRESULT WINAPI domattr_get_specified(
389 IXMLDOMAttribute *iface,
392 domattr *This = impl_from_IXMLDOMAttribute( iface );
393 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
396 static HRESULT WINAPI domattr_get_definition(
397 IXMLDOMAttribute *iface,
398 IXMLDOMNode** domNode)
400 domattr *This = impl_from_IXMLDOMAttribute( iface );
401 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
404 static HRESULT WINAPI domattr_get_nodeTypedValue(
405 IXMLDOMAttribute *iface,
408 domattr *This = impl_from_IXMLDOMAttribute( iface );
409 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
412 static HRESULT WINAPI domattr_put_nodeTypedValue(
413 IXMLDOMAttribute *iface,
416 domattr *This = impl_from_IXMLDOMAttribute( iface );
417 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
420 static HRESULT WINAPI domattr_get_dataType(
421 IXMLDOMAttribute *iface,
424 domattr *This = impl_from_IXMLDOMAttribute( iface );
425 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
428 static HRESULT WINAPI domattr_put_dataType(
429 IXMLDOMAttribute *iface,
432 domattr *This = impl_from_IXMLDOMAttribute( iface );
433 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
436 static HRESULT WINAPI domattr_get_xml(
437 IXMLDOMAttribute *iface,
440 domattr *This = impl_from_IXMLDOMAttribute( iface );
441 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
444 static HRESULT WINAPI domattr_transformNode(
445 IXMLDOMAttribute *iface,
446 IXMLDOMNode* domNode, BSTR* p)
448 domattr *This = impl_from_IXMLDOMAttribute( iface );
449 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
452 static HRESULT WINAPI domattr_selectNodes(
453 IXMLDOMAttribute *iface,
454 BSTR p, IXMLDOMNodeList** outList)
456 domattr *This = impl_from_IXMLDOMAttribute( iface );
457 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
460 static HRESULT WINAPI domattr_selectSingleNode(
461 IXMLDOMAttribute *iface,
462 BSTR p, IXMLDOMNode** outNode)
464 domattr *This = impl_from_IXMLDOMAttribute( iface );
465 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
468 static HRESULT WINAPI domattr_get_parsed(
469 IXMLDOMAttribute *iface,
472 domattr *This = impl_from_IXMLDOMAttribute( iface );
473 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
476 static HRESULT WINAPI domattr_get_namespaceURI(
477 IXMLDOMAttribute *iface,
480 domattr *This = impl_from_IXMLDOMAttribute( iface );
481 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
484 static HRESULT WINAPI domattr_get_prefix(
485 IXMLDOMAttribute *iface,
488 domattr *This = impl_from_IXMLDOMAttribute( iface );
489 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
492 static HRESULT WINAPI domattr_get_baseName(
493 IXMLDOMAttribute *iface,
496 domattr *This = impl_from_IXMLDOMAttribute( iface );
497 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
500 static HRESULT WINAPI domattr_transformNodeToObject(
501 IXMLDOMAttribute *iface,
502 IXMLDOMNode* domNode, VARIANT var1)
504 domattr *This = impl_from_IXMLDOMAttribute( iface );
505 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
508 static HRESULT WINAPI domattr_get_name(
509 IXMLDOMAttribute *iface,
512 domattr *This = impl_from_IXMLDOMAttribute( iface );
514 TRACE("(%p)->(%p)\n", This, p);
516 return node_get_nodeName(&This->node, p);
519 static HRESULT WINAPI domattr_get_value(
520 IXMLDOMAttribute *iface,
523 domattr *This = impl_from_IXMLDOMAttribute( iface );
525 TRACE("(%p)->(%p)\n", This, value);
527 return node_get_content(&This->node, value);
530 static HRESULT WINAPI domattr_put_value(
531 IXMLDOMAttribute *iface,
534 domattr *This = impl_from_IXMLDOMAttribute( iface );
536 TRACE("(%p)->(v%d)\n", This, V_VT(&value));
538 return node_put_value(&This->node, &value);
541 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
543 domattr_QueryInterface,
546 domattr_GetTypeInfoCount,
548 domattr_GetIDsOfNames,
550 domattr_get_nodeName,
551 domattr_get_nodeValue,
552 domattr_put_nodeValue,
553 domattr_get_nodeType,
554 domattr_get_parentNode,
555 domattr_get_childNodes,
556 domattr_get_firstChild,
557 domattr_get_lastChild,
558 domattr_get_previousSibling,
559 domattr_get_nextSibling,
560 domattr_get_attributes,
561 domattr_insertBefore,
562 domattr_replaceChild,
565 domattr_hasChildNodes,
566 domattr_get_ownerDocument,
568 domattr_get_nodeTypeString,
571 domattr_get_specified,
572 domattr_get_definition,
573 domattr_get_nodeTypedValue,
574 domattr_put_nodeTypedValue,
575 domattr_get_dataType,
576 domattr_put_dataType,
578 domattr_transformNode,
580 domattr_selectSingleNode,
582 domattr_get_namespaceURI,
584 domattr_get_baseName,
585 domattr_transformNodeToObject,
591 IUnknown* create_attribute( xmlNodePtr attribute )
595 This = heap_alloc( sizeof *This );
599 This->lpVtbl = &domattr_vtbl;
602 init_xmlnode(&This->node, attribute, (IXMLDOMNode*)&This->lpVtbl, NULL);
604 return (IUnknown*) &This->lpVtbl;