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
42 const struct IXMLDOMAttributeVtbl
*lpVtbl
;
48 static inline domattr
*impl_from_IXMLDOMAttribute( IXMLDOMAttribute
*iface
)
50 return (domattr
*)((char*)iface
- FIELD_OFFSET(domattr
, lpVtbl
));
53 static HRESULT WINAPI
domattr_QueryInterface(
54 IXMLDOMAttribute
*iface
,
58 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
59 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
61 if ( IsEqualGUID( riid
, &IID_IXMLDOMAttribute
) ||
62 IsEqualGUID( riid
, &IID_IDispatch
) ||
63 IsEqualGUID( riid
, &IID_IUnknown
) )
67 else if ( IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
69 return IUnknown_QueryInterface(This
->node_unk
, riid
, ppvObject
);
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
77 IXMLDOMAttribute_AddRef( iface
);
82 static ULONG WINAPI
domattr_AddRef(
83 IXMLDOMAttribute
*iface
)
85 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
86 return InterlockedIncrement( &This
->ref
);
89 static ULONG WINAPI
domattr_Release(
90 IXMLDOMAttribute
*iface
)
92 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
95 ref
= InterlockedDecrement( &This
->ref
);
98 IUnknown_Release( This
->node_unk
);
99 HeapFree( GetProcessHeap(), 0, This
);
105 static HRESULT WINAPI
domattr_GetTypeInfoCount(
106 IXMLDOMAttribute
*iface
,
109 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
111 TRACE("(%p)->(%p)\n", This
, pctinfo
);
118 static HRESULT WINAPI
domattr_GetTypeInfo(
119 IXMLDOMAttribute
*iface
,
120 UINT iTInfo
, LCID lcid
,
121 ITypeInfo
** ppTInfo
)
123 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
126 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
128 hr
= get_typeinfo(IXMLDOMAttribute_tid
, ppTInfo
);
133 static HRESULT WINAPI
domattr_GetIDsOfNames(
134 IXMLDOMAttribute
*iface
,
135 REFIID riid
, LPOLESTR
* rgszNames
,
136 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
138 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
142 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
145 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
148 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
151 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
152 ITypeInfo_Release(typeinfo
);
158 static HRESULT WINAPI
domattr_Invoke(
159 IXMLDOMAttribute
*iface
,
160 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
161 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
162 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
164 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
168 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
169 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
171 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
174 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
175 pVarResult
, pExcepInfo
, puArgErr
);
176 ITypeInfo_Release(typeinfo
);
181 static HRESULT WINAPI
domattr_get_nodeName(
182 IXMLDOMAttribute
*iface
,
185 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
186 return IXMLDOMNode_get_nodeName( This
->node
, p
);
189 static HRESULT WINAPI
domattr_get_nodeValue(
190 IXMLDOMAttribute
*iface
,
193 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
194 return IXMLDOMNode_get_nodeValue( This
->node
, var1
);
197 static HRESULT WINAPI
domattr_put_nodeValue(
198 IXMLDOMAttribute
*iface
,
201 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
202 return IXMLDOMNode_put_nodeValue( This
->node
, var1
);
205 static HRESULT WINAPI
domattr_get_nodeType(
206 IXMLDOMAttribute
*iface
,
207 DOMNodeType
* domNodeType
)
209 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
210 return IXMLDOMNode_get_nodeType( This
->node
, domNodeType
);
213 static HRESULT WINAPI
domattr_get_parentNode(
214 IXMLDOMAttribute
*iface
,
215 IXMLDOMNode
** parent
)
217 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
218 return IXMLDOMNode_get_parentNode( This
->node
, parent
);
221 static HRESULT WINAPI
domattr_get_childNodes(
222 IXMLDOMAttribute
*iface
,
223 IXMLDOMNodeList
** outList
)
225 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
226 return IXMLDOMNode_get_childNodes( This
->node
, outList
);
229 static HRESULT WINAPI
domattr_get_firstChild(
230 IXMLDOMAttribute
*iface
,
231 IXMLDOMNode
** domNode
)
233 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
234 return IXMLDOMNode_get_firstChild( This
->node
, domNode
);
237 static HRESULT WINAPI
domattr_get_lastChild(
238 IXMLDOMAttribute
*iface
,
239 IXMLDOMNode
** domNode
)
241 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
242 return IXMLDOMNode_get_lastChild( This
->node
, domNode
);
245 static HRESULT WINAPI
domattr_get_previousSibling(
246 IXMLDOMAttribute
*iface
,
247 IXMLDOMNode
** domNode
)
249 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
250 return IXMLDOMNode_get_previousSibling( This
->node
, domNode
);
253 static HRESULT WINAPI
domattr_get_nextSibling(
254 IXMLDOMAttribute
*iface
,
255 IXMLDOMNode
** domNode
)
257 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
258 return IXMLDOMNode_get_nextSibling( This
->node
, domNode
);
261 static HRESULT WINAPI
domattr_get_attributes(
262 IXMLDOMAttribute
*iface
,
263 IXMLDOMNamedNodeMap
** attributeMap
)
265 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
266 return IXMLDOMNode_get_attributes( This
->node
, attributeMap
);
269 static HRESULT WINAPI
domattr_insertBefore(
270 IXMLDOMAttribute
*iface
,
271 IXMLDOMNode
* newNode
, VARIANT var1
,
272 IXMLDOMNode
** outOldNode
)
274 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
275 return IXMLDOMNode_insertBefore( This
->node
, newNode
, var1
, outOldNode
);
278 static HRESULT WINAPI
domattr_replaceChild(
279 IXMLDOMAttribute
*iface
,
280 IXMLDOMNode
* newNode
,
281 IXMLDOMNode
* oldNode
,
282 IXMLDOMNode
** outOldNode
)
284 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
285 return IXMLDOMNode_replaceChild( This
->node
, newNode
, oldNode
, outOldNode
);
288 static HRESULT WINAPI
domattr_removeChild(
289 IXMLDOMAttribute
*iface
,
290 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
292 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
293 return IXMLDOMNode_removeChild( This
->node
, domNode
, oldNode
);
296 static HRESULT WINAPI
domattr_appendChild(
297 IXMLDOMAttribute
*iface
,
298 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
300 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
301 return IXMLDOMNode_appendChild( This
->node
, newNode
, outNewNode
);
304 static HRESULT WINAPI
domattr_hasChildNodes(
305 IXMLDOMAttribute
*iface
,
308 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
309 return IXMLDOMNode_hasChildNodes( This
->node
, pbool
);
312 static HRESULT WINAPI
domattr_get_ownerDocument(
313 IXMLDOMAttribute
*iface
,
314 IXMLDOMDocument
** domDocument
)
316 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
317 return IXMLDOMNode_get_ownerDocument( This
->node
, domDocument
);
320 static HRESULT WINAPI
domattr_cloneNode(
321 IXMLDOMAttribute
*iface
,
322 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
324 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
325 return IXMLDOMNode_cloneNode( This
->node
, pbool
, outNode
);
328 static HRESULT WINAPI
domattr_get_nodeTypeString(
329 IXMLDOMAttribute
*iface
,
332 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
333 return IXMLDOMNode_get_nodeTypeString( This
->node
, p
);
336 static HRESULT WINAPI
domattr_get_text(
337 IXMLDOMAttribute
*iface
,
340 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
341 return IXMLDOMNode_get_text( This
->node
, p
);
344 static HRESULT WINAPI
domattr_put_text(
345 IXMLDOMAttribute
*iface
,
348 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
349 return IXMLDOMNode_put_text( This
->node
, p
);
352 static HRESULT WINAPI
domattr_get_specified(
353 IXMLDOMAttribute
*iface
,
356 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
357 return IXMLDOMNode_get_specified( This
->node
, pbool
);
360 static HRESULT WINAPI
domattr_get_definition(
361 IXMLDOMAttribute
*iface
,
362 IXMLDOMNode
** domNode
)
364 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
365 return IXMLDOMNode_get_definition( This
->node
, domNode
);
368 static HRESULT WINAPI
domattr_get_nodeTypedValue(
369 IXMLDOMAttribute
*iface
,
372 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
373 return IXMLDOMNode_get_nodeTypedValue( This
->node
, var1
);
376 static HRESULT WINAPI
domattr_put_nodeTypedValue(
377 IXMLDOMAttribute
*iface
,
380 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
381 return IXMLDOMNode_put_nodeTypedValue( This
->node
, var1
);
384 static HRESULT WINAPI
domattr_get_dataType(
385 IXMLDOMAttribute
*iface
,
388 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
389 return IXMLDOMNode_get_dataType( This
->node
, var1
);
392 static HRESULT WINAPI
domattr_put_dataType(
393 IXMLDOMAttribute
*iface
,
396 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
397 return IXMLDOMNode_put_dataType( This
->node
, p
);
400 static HRESULT WINAPI
domattr_get_xml(
401 IXMLDOMAttribute
*iface
,
404 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
405 return IXMLDOMNode_get_xml( This
->node
, p
);
408 static HRESULT WINAPI
domattr_transformNode(
409 IXMLDOMAttribute
*iface
,
410 IXMLDOMNode
* domNode
, BSTR
* p
)
412 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
413 return IXMLDOMNode_transformNode( This
->node
, domNode
, p
);
416 static HRESULT WINAPI
domattr_selectNodes(
417 IXMLDOMAttribute
*iface
,
418 BSTR p
, IXMLDOMNodeList
** outList
)
420 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
421 return IXMLDOMNode_selectNodes( This
->node
, p
, outList
);
424 static HRESULT WINAPI
domattr_selectSingleNode(
425 IXMLDOMAttribute
*iface
,
426 BSTR p
, IXMLDOMNode
** outNode
)
428 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
429 return IXMLDOMNode_selectSingleNode( This
->node
, p
, outNode
);
432 static HRESULT WINAPI
domattr_get_parsed(
433 IXMLDOMAttribute
*iface
,
436 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
437 return IXMLDOMNode_get_parsed( This
->node
, pbool
);
440 static HRESULT WINAPI
domattr_get_namespaceURI(
441 IXMLDOMAttribute
*iface
,
444 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
445 return IXMLDOMNode_get_namespaceURI( This
->node
, p
);
448 static HRESULT WINAPI
domattr_get_prefix(
449 IXMLDOMAttribute
*iface
,
452 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
453 return IXMLDOMNode_get_prefix( This
->node
, p
);
456 static HRESULT WINAPI
domattr_get_baseName(
457 IXMLDOMAttribute
*iface
,
460 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
461 return IXMLDOMNode_get_baseName( This
->node
, p
);
464 static HRESULT WINAPI
domattr_transformNodeToObject(
465 IXMLDOMAttribute
*iface
,
466 IXMLDOMNode
* domNode
, VARIANT var1
)
468 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
469 return IXMLDOMNode_transformNodeToObject( This
->node
, domNode
, var1
);
472 static HRESULT WINAPI
domattr_get_name(
473 IXMLDOMAttribute
*iface
,
476 /* name property returns the same value as nodeName */
477 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
478 return IXMLDOMNode_get_nodeName( This
->node
, p
);
481 static HRESULT WINAPI
domattr_get_value(
482 IXMLDOMAttribute
*iface
,
489 static HRESULT WINAPI
domattr_put_value(
490 IXMLDOMAttribute
*iface
,
497 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
499 domattr_QueryInterface
,
502 domattr_GetTypeInfoCount
,
504 domattr_GetIDsOfNames
,
506 domattr_get_nodeName
,
507 domattr_get_nodeValue
,
508 domattr_put_nodeValue
,
509 domattr_get_nodeType
,
510 domattr_get_parentNode
,
511 domattr_get_childNodes
,
512 domattr_get_firstChild
,
513 domattr_get_lastChild
,
514 domattr_get_previousSibling
,
515 domattr_get_nextSibling
,
516 domattr_get_attributes
,
517 domattr_insertBefore
,
518 domattr_replaceChild
,
521 domattr_hasChildNodes
,
522 domattr_get_ownerDocument
,
524 domattr_get_nodeTypeString
,
527 domattr_get_specified
,
528 domattr_get_definition
,
529 domattr_get_nodeTypedValue
,
530 domattr_put_nodeTypedValue
,
531 domattr_get_dataType
,
532 domattr_put_dataType
,
534 domattr_transformNode
,
536 domattr_selectSingleNode
,
538 domattr_get_namespaceURI
,
540 domattr_get_baseName
,
541 domattr_transformNodeToObject
,
547 IUnknown
* create_attribute( xmlNodePtr attribute
)
552 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
556 This
->lpVtbl
= &domattr_vtbl
;
559 This
->node_unk
= create_basic_node( attribute
, (IUnknown
*)&This
->lpVtbl
);
562 HeapFree(GetProcessHeap(), 0, This
);
566 hr
= IUnknown_QueryInterface(This
->node_unk
, &IID_IXMLDOMNode
, (LPVOID
*)&This
->node
);
569 IUnknown_Release(This
->node_unk
);
570 HeapFree( GetProcessHeap(), 0, This
);
573 /* The ref on This->node is actually looped back into this object, so release it */
574 IXMLDOMNode_Release(This
->node
);
576 return (IUnknown
*) &This
->lpVtbl
;