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_IUnknown
) )
66 else if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
67 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
69 return IUnknown_QueryInterface(This
->node_unk
, riid
, ppvObject
);
73 FIXME("Unsupported inteferace %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
,
113 static HRESULT WINAPI
domattr_GetTypeInfo(
114 IXMLDOMAttribute
*iface
,
115 UINT iTInfo
, LCID lcid
,
116 ITypeInfo
** ppTInfo
)
122 static HRESULT WINAPI
domattr_GetIDsOfNames(
123 IXMLDOMAttribute
*iface
,
124 REFIID riid
, LPOLESTR
* rgszNames
,
125 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
131 static HRESULT WINAPI
domattr_Invoke(
132 IXMLDOMAttribute
*iface
,
133 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
134 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
135 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
141 static HRESULT WINAPI
domattr_get_nodeName(
142 IXMLDOMAttribute
*iface
,
145 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
146 return IXMLDOMNode_get_nodeName( This
->node
, p
);
149 static HRESULT WINAPI
domattr_get_nodeValue(
150 IXMLDOMAttribute
*iface
,
153 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
154 return IXMLDOMNode_get_nodeValue( This
->node
, var1
);
157 static HRESULT WINAPI
domattr_put_nodeValue(
158 IXMLDOMAttribute
*iface
,
161 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
162 return IXMLDOMNode_put_nodeValue( This
->node
, var1
);
165 static HRESULT WINAPI
domattr_get_nodeType(
166 IXMLDOMAttribute
*iface
,
167 DOMNodeType
* domNodeType
)
169 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
170 return IXMLDOMNode_get_nodeType( This
->node
, domNodeType
);
173 static HRESULT WINAPI
domattr_get_parentNode(
174 IXMLDOMAttribute
*iface
,
175 IXMLDOMNode
** parent
)
177 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
178 return IXMLDOMNode_get_parentNode( This
->node
, parent
);
181 static HRESULT WINAPI
domattr_get_childNodes(
182 IXMLDOMAttribute
*iface
,
183 IXMLDOMNodeList
** outList
)
185 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
186 return IXMLDOMNode_get_childNodes( This
->node
, outList
);
189 static HRESULT WINAPI
domattr_get_firstChild(
190 IXMLDOMAttribute
*iface
,
191 IXMLDOMNode
** domNode
)
193 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
194 return IXMLDOMNode_get_firstChild( This
->node
, domNode
);
197 static HRESULT WINAPI
domattr_get_lastChild(
198 IXMLDOMAttribute
*iface
,
199 IXMLDOMNode
** domNode
)
201 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
202 return IXMLDOMNode_get_lastChild( This
->node
, domNode
);
205 static HRESULT WINAPI
domattr_get_previousSibling(
206 IXMLDOMAttribute
*iface
,
207 IXMLDOMNode
** domNode
)
209 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
210 return IXMLDOMNode_get_previousSibling( This
->node
, domNode
);
213 static HRESULT WINAPI
domattr_get_nextSibling(
214 IXMLDOMAttribute
*iface
,
215 IXMLDOMNode
** domNode
)
217 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
218 return IXMLDOMNode_get_nextSibling( This
->node
, domNode
);
221 static HRESULT WINAPI
domattr_get_attributes(
222 IXMLDOMAttribute
*iface
,
223 IXMLDOMNamedNodeMap
** attributeMap
)
225 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
226 return IXMLDOMNode_get_attributes( This
->node
, attributeMap
);
229 static HRESULT WINAPI
domattr_insertBefore(
230 IXMLDOMAttribute
*iface
,
231 IXMLDOMNode
* newNode
, VARIANT var1
,
232 IXMLDOMNode
** outOldNode
)
234 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
235 return IXMLDOMNode_insertBefore( This
->node
, newNode
, var1
, outOldNode
);
238 static HRESULT WINAPI
domattr_replaceChild(
239 IXMLDOMAttribute
*iface
,
240 IXMLDOMNode
* newNode
,
241 IXMLDOMNode
* oldNode
,
242 IXMLDOMNode
** outOldNode
)
244 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
245 return IXMLDOMNode_replaceChild( This
->node
, newNode
, oldNode
, outOldNode
);
248 static HRESULT WINAPI
domattr_removeChild(
249 IXMLDOMAttribute
*iface
,
250 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
252 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
253 return IXMLDOMNode_removeChild( This
->node
, domNode
, oldNode
);
256 static HRESULT WINAPI
domattr_appendChild(
257 IXMLDOMAttribute
*iface
,
258 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
260 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
261 return IXMLDOMNode_appendChild( This
->node
, newNode
, outNewNode
);
264 static HRESULT WINAPI
domattr_hasChildNodes(
265 IXMLDOMAttribute
*iface
,
268 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
269 return IXMLDOMNode_hasChildNodes( This
->node
, pbool
);
272 static HRESULT WINAPI
domattr_get_ownerDocument(
273 IXMLDOMAttribute
*iface
,
274 IXMLDOMDocument
** domDocument
)
276 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
277 return IXMLDOMNode_get_ownerDocument( This
->node
, domDocument
);
280 static HRESULT WINAPI
domattr_cloneNode(
281 IXMLDOMAttribute
*iface
,
282 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
284 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
285 return IXMLDOMNode_cloneNode( This
->node
, pbool
, outNode
);
288 static HRESULT WINAPI
domattr_get_nodeTypeString(
289 IXMLDOMAttribute
*iface
,
292 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
293 return IXMLDOMNode_get_nodeTypeString( This
->node
, p
);
296 static HRESULT WINAPI
domattr_get_text(
297 IXMLDOMAttribute
*iface
,
300 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
301 return IXMLDOMNode_get_text( This
->node
, p
);
304 static HRESULT WINAPI
domattr_put_text(
305 IXMLDOMAttribute
*iface
,
308 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
309 return IXMLDOMNode_put_text( This
->node
, p
);
312 static HRESULT WINAPI
domattr_get_specified(
313 IXMLDOMAttribute
*iface
,
316 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
317 return IXMLDOMNode_get_specified( This
->node
, pbool
);
320 static HRESULT WINAPI
domattr_get_definition(
321 IXMLDOMAttribute
*iface
,
322 IXMLDOMNode
** domNode
)
324 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
325 return IXMLDOMNode_get_definition( This
->node
, domNode
);
328 static HRESULT WINAPI
domattr_get_nodeTypedValue(
329 IXMLDOMAttribute
*iface
,
332 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
333 return IXMLDOMNode_get_nodeTypedValue( This
->node
, var1
);
336 static HRESULT WINAPI
domattr_put_nodeTypedValue(
337 IXMLDOMAttribute
*iface
,
340 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
341 return IXMLDOMNode_put_nodeTypedValue( This
->node
, var1
);
344 static HRESULT WINAPI
domattr_get_dataType(
345 IXMLDOMAttribute
*iface
,
348 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
349 return IXMLDOMNode_get_dataType( This
->node
, var1
);
352 static HRESULT WINAPI
domattr_put_dataType(
353 IXMLDOMAttribute
*iface
,
356 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
357 return IXMLDOMNode_put_dataType( This
->node
, p
);
360 static HRESULT WINAPI
domattr_get_xml(
361 IXMLDOMAttribute
*iface
,
364 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
365 return IXMLDOMNode_get_xml( This
->node
, p
);
368 static HRESULT WINAPI
domattr_transformNode(
369 IXMLDOMAttribute
*iface
,
370 IXMLDOMNode
* domNode
, BSTR
* p
)
372 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
373 return IXMLDOMNode_transformNode( This
->node
, domNode
, p
);
376 static HRESULT WINAPI
domattr_selectNodes(
377 IXMLDOMAttribute
*iface
,
378 BSTR p
, IXMLDOMNodeList
** outList
)
380 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
381 return IXMLDOMNode_selectNodes( This
->node
, p
, outList
);
384 static HRESULT WINAPI
domattr_selectSingleNode(
385 IXMLDOMAttribute
*iface
,
386 BSTR p
, IXMLDOMNode
** outNode
)
388 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
389 return IXMLDOMNode_selectSingleNode( This
->node
, p
, outNode
);
392 static HRESULT WINAPI
domattr_get_parsed(
393 IXMLDOMAttribute
*iface
,
396 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
397 return IXMLDOMNode_get_parsed( This
->node
, pbool
);
400 static HRESULT WINAPI
domattr_get_namespaceURI(
401 IXMLDOMAttribute
*iface
,
404 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
405 return IXMLDOMNode_get_namespaceURI( This
->node
, p
);
408 static HRESULT WINAPI
domattr_get_prefix(
409 IXMLDOMAttribute
*iface
,
412 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
413 return IXMLDOMNode_get_prefix( This
->node
, p
);
416 static HRESULT WINAPI
domattr_get_baseName(
417 IXMLDOMAttribute
*iface
,
420 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
421 return IXMLDOMNode_get_baseName( This
->node
, p
);
424 static HRESULT WINAPI
domattr_transformNodeToObject(
425 IXMLDOMAttribute
*iface
,
426 IXMLDOMNode
* domNode
, VARIANT var1
)
428 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
429 return IXMLDOMNode_transformNodeToObject( This
->node
, domNode
, var1
);
432 static HRESULT WINAPI
domattr_get_name(
433 IXMLDOMAttribute
*iface
,
440 static HRESULT WINAPI
domattr_get_value(
441 IXMLDOMAttribute
*iface
,
448 static HRESULT WINAPI
domattr_put_value(
449 IXMLDOMAttribute
*iface
,
456 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
458 domattr_QueryInterface
,
461 domattr_GetTypeInfoCount
,
463 domattr_GetIDsOfNames
,
465 domattr_get_nodeName
,
466 domattr_get_nodeValue
,
467 domattr_put_nodeValue
,
468 domattr_get_nodeType
,
469 domattr_get_parentNode
,
470 domattr_get_childNodes
,
471 domattr_get_firstChild
,
472 domattr_get_lastChild
,
473 domattr_get_previousSibling
,
474 domattr_get_nextSibling
,
475 domattr_get_attributes
,
476 domattr_insertBefore
,
477 domattr_replaceChild
,
480 domattr_hasChildNodes
,
481 domattr_get_ownerDocument
,
483 domattr_get_nodeTypeString
,
486 domattr_get_specified
,
487 domattr_get_definition
,
488 domattr_get_nodeTypedValue
,
489 domattr_put_nodeTypedValue
,
490 domattr_get_dataType
,
491 domattr_put_dataType
,
493 domattr_transformNode
,
495 domattr_selectSingleNode
,
497 domattr_get_namespaceURI
,
499 domattr_get_baseName
,
500 domattr_transformNodeToObject
,
506 IUnknown
* create_attribute( xmlNodePtr attribute
)
511 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
515 This
->lpVtbl
= &domattr_vtbl
;
518 This
->node_unk
= create_basic_node( attribute
, (IUnknown
*)&This
->lpVtbl
);
521 HeapFree(GetProcessHeap(), 0, This
);
525 hr
= IUnknown_QueryInterface(This
->node_unk
, &IID_IXMLDOMNode
, (LPVOID
*)&This
->node
);
528 IUnknown_Release(This
->node_unk
);
529 HeapFree( GetProcessHeap(), 0, This
);
532 /* The ref on This->node is actually looped back into this object, so release it */
533 IXMLDOMNode_Release(This
->node
);
535 return (IUnknown
*) &This
->lpVtbl
;