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_IDispatch
) ||
62 IsEqualGUID( riid
, &IID_IUnknown
) )
66 else if ( IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
68 *ppvObject
= IXMLDOMNode_from_impl(&This
->node
);
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
76 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
80 static ULONG WINAPI
domattr_AddRef(
81 IXMLDOMAttribute
*iface
)
83 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
84 return InterlockedIncrement( &This
->ref
);
87 static ULONG WINAPI
domattr_Release(
88 IXMLDOMAttribute
*iface
)
90 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
93 ref
= InterlockedDecrement( &This
->ref
);
96 destroy_xmlnode(&This
->node
);
103 static HRESULT WINAPI
domattr_GetTypeInfoCount(
104 IXMLDOMAttribute
*iface
,
107 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
109 TRACE("(%p)->(%p)\n", This
, pctinfo
);
116 static HRESULT WINAPI
domattr_GetTypeInfo(
117 IXMLDOMAttribute
*iface
,
118 UINT iTInfo
, LCID lcid
,
119 ITypeInfo
** ppTInfo
)
121 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
124 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
126 hr
= get_typeinfo(IXMLDOMAttribute_tid
, ppTInfo
);
131 static HRESULT WINAPI
domattr_GetIDsOfNames(
132 IXMLDOMAttribute
*iface
,
133 REFIID riid
, LPOLESTR
* rgszNames
,
134 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
136 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
140 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
143 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
146 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
149 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
150 ITypeInfo_Release(typeinfo
);
156 static HRESULT WINAPI
domattr_Invoke(
157 IXMLDOMAttribute
*iface
,
158 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
159 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
160 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
162 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
166 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
167 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
169 hr
= get_typeinfo(IXMLDOMAttribute_tid
, &typeinfo
);
172 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
173 pVarResult
, pExcepInfo
, puArgErr
);
174 ITypeInfo_Release(typeinfo
);
179 static HRESULT WINAPI
domattr_get_nodeName(
180 IXMLDOMAttribute
*iface
,
183 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
184 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This
->node
), p
);
187 static HRESULT WINAPI
domattr_get_nodeValue(
188 IXMLDOMAttribute
*iface
,
191 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
192 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
195 static HRESULT WINAPI
domattr_put_nodeValue(
196 IXMLDOMAttribute
*iface
,
199 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
200 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
203 static HRESULT WINAPI
domattr_get_nodeType(
204 IXMLDOMAttribute
*iface
,
205 DOMNodeType
* domNodeType
)
207 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
208 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This
->node
), domNodeType
);
211 static HRESULT WINAPI
domattr_get_parentNode(
212 IXMLDOMAttribute
*iface
,
213 IXMLDOMNode
** parent
)
215 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
216 TRACE("(%p)->(%p)\n", This
, parent
);
217 if (!parent
) return E_INVALIDARG
;
222 static HRESULT WINAPI
domattr_get_childNodes(
223 IXMLDOMAttribute
*iface
,
224 IXMLDOMNodeList
** outList
)
226 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
227 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This
->node
), outList
);
230 static HRESULT WINAPI
domattr_get_firstChild(
231 IXMLDOMAttribute
*iface
,
232 IXMLDOMNode
** domNode
)
234 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
235 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This
->node
), domNode
);
238 static HRESULT WINAPI
domattr_get_lastChild(
239 IXMLDOMAttribute
*iface
,
240 IXMLDOMNode
** domNode
)
242 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
243 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This
->node
), domNode
);
246 static HRESULT WINAPI
domattr_get_previousSibling(
247 IXMLDOMAttribute
*iface
,
248 IXMLDOMNode
** domNode
)
250 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
251 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This
->node
), domNode
);
254 static HRESULT WINAPI
domattr_get_nextSibling(
255 IXMLDOMAttribute
*iface
,
256 IXMLDOMNode
** domNode
)
258 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
259 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This
->node
), domNode
);
262 static HRESULT WINAPI
domattr_get_attributes(
263 IXMLDOMAttribute
*iface
,
264 IXMLDOMNamedNodeMap
** attributeMap
)
266 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
267 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This
->node
), attributeMap
);
270 static HRESULT WINAPI
domattr_insertBefore(
271 IXMLDOMAttribute
*iface
,
272 IXMLDOMNode
* newNode
, VARIANT var1
,
273 IXMLDOMNode
** outOldNode
)
275 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
276 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This
->node
), newNode
, var1
, outOldNode
);
279 static HRESULT WINAPI
domattr_replaceChild(
280 IXMLDOMAttribute
*iface
,
281 IXMLDOMNode
* newNode
,
282 IXMLDOMNode
* oldNode
,
283 IXMLDOMNode
** outOldNode
)
285 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
286 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, oldNode
, outOldNode
);
289 static HRESULT WINAPI
domattr_removeChild(
290 IXMLDOMAttribute
*iface
,
291 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
293 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
294 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), domNode
, oldNode
);
297 static HRESULT WINAPI
domattr_appendChild(
298 IXMLDOMAttribute
*iface
,
299 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
301 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
302 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, outNewNode
);
305 static HRESULT WINAPI
domattr_hasChildNodes(
306 IXMLDOMAttribute
*iface
,
309 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
310 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), pbool
);
313 static HRESULT WINAPI
domattr_get_ownerDocument(
314 IXMLDOMAttribute
*iface
,
315 IXMLDOMDocument
** domDocument
)
317 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
318 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), domDocument
);
321 static HRESULT WINAPI
domattr_cloneNode(
322 IXMLDOMAttribute
*iface
,
323 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
325 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
326 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This
->node
), pbool
, outNode
);
329 static HRESULT WINAPI
domattr_get_nodeTypeString(
330 IXMLDOMAttribute
*iface
,
333 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
334 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This
->node
), p
);
337 static HRESULT WINAPI
domattr_get_text(
338 IXMLDOMAttribute
*iface
,
341 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
342 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), p
);
345 static HRESULT WINAPI
domattr_put_text(
346 IXMLDOMAttribute
*iface
,
349 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
350 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This
->node
), p
);
353 static HRESULT WINAPI
domattr_get_specified(
354 IXMLDOMAttribute
*iface
,
357 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
358 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This
->node
), pbool
);
361 static HRESULT WINAPI
domattr_get_definition(
362 IXMLDOMAttribute
*iface
,
363 IXMLDOMNode
** domNode
)
365 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
366 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This
->node
), domNode
);
369 static HRESULT WINAPI
domattr_get_nodeTypedValue(
370 IXMLDOMAttribute
*iface
,
373 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
374 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
377 static HRESULT WINAPI
domattr_put_nodeTypedValue(
378 IXMLDOMAttribute
*iface
,
381 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
382 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
385 static HRESULT WINAPI
domattr_get_dataType(
386 IXMLDOMAttribute
*iface
,
389 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
390 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This
->node
), var1
);
393 static HRESULT WINAPI
domattr_put_dataType(
394 IXMLDOMAttribute
*iface
,
397 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
398 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), p
);
401 static HRESULT WINAPI
domattr_get_xml(
402 IXMLDOMAttribute
*iface
,
405 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
406 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This
->node
), p
);
409 static HRESULT WINAPI
domattr_transformNode(
410 IXMLDOMAttribute
*iface
,
411 IXMLDOMNode
* domNode
, BSTR
* p
)
413 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
414 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), domNode
, p
);
417 static HRESULT WINAPI
domattr_selectNodes(
418 IXMLDOMAttribute
*iface
,
419 BSTR p
, IXMLDOMNodeList
** outList
)
421 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
422 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), p
, outList
);
425 static HRESULT WINAPI
domattr_selectSingleNode(
426 IXMLDOMAttribute
*iface
,
427 BSTR p
, IXMLDOMNode
** outNode
)
429 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
430 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), p
, outNode
);
433 static HRESULT WINAPI
domattr_get_parsed(
434 IXMLDOMAttribute
*iface
,
437 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
438 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This
->node
), pbool
);
441 static HRESULT WINAPI
domattr_get_namespaceURI(
442 IXMLDOMAttribute
*iface
,
445 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
446 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), p
);
449 static HRESULT WINAPI
domattr_get_prefix(
450 IXMLDOMAttribute
*iface
,
453 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
454 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This
->node
), p
);
457 static HRESULT WINAPI
domattr_get_baseName(
458 IXMLDOMAttribute
*iface
,
461 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
462 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This
->node
), p
);
465 static HRESULT WINAPI
domattr_transformNodeToObject(
466 IXMLDOMAttribute
*iface
,
467 IXMLDOMNode
* domNode
, VARIANT var1
)
469 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
470 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), domNode
, var1
);
473 static HRESULT WINAPI
domattr_get_name(
474 IXMLDOMAttribute
*iface
,
477 /* name property returns the same value as nodeName */
478 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
479 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This
->node
), p
);
482 static HRESULT WINAPI
domattr_get_value(
483 IXMLDOMAttribute
*iface
,
486 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
487 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
490 static HRESULT WINAPI
domattr_put_value(
491 IXMLDOMAttribute
*iface
,
494 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
495 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
498 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
500 domattr_QueryInterface
,
503 domattr_GetTypeInfoCount
,
505 domattr_GetIDsOfNames
,
507 domattr_get_nodeName
,
508 domattr_get_nodeValue
,
509 domattr_put_nodeValue
,
510 domattr_get_nodeType
,
511 domattr_get_parentNode
,
512 domattr_get_childNodes
,
513 domattr_get_firstChild
,
514 domattr_get_lastChild
,
515 domattr_get_previousSibling
,
516 domattr_get_nextSibling
,
517 domattr_get_attributes
,
518 domattr_insertBefore
,
519 domattr_replaceChild
,
522 domattr_hasChildNodes
,
523 domattr_get_ownerDocument
,
525 domattr_get_nodeTypeString
,
528 domattr_get_specified
,
529 domattr_get_definition
,
530 domattr_get_nodeTypedValue
,
531 domattr_put_nodeTypedValue
,
532 domattr_get_dataType
,
533 domattr_put_dataType
,
535 domattr_transformNode
,
537 domattr_selectSingleNode
,
539 domattr_get_namespaceURI
,
541 domattr_get_baseName
,
542 domattr_transformNodeToObject
,
548 IUnknown
* create_attribute( xmlNodePtr attribute
)
552 This
= heap_alloc( sizeof *This
);
556 This
->lpVtbl
= &domattr_vtbl
;
559 init_xmlnode(&This
->node
, attribute
, (IUnknown
*)&This
->lpVtbl
, NULL
);
561 return (IUnknown
*) &This
->lpVtbl
;