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 inline xmlNodePtr
get_attribute( domattr
*This
)
55 return xmlNodePtr_from_domnode( This
->node
, XML_ATTRIBUTE_NODE
);
58 static HRESULT WINAPI
domattr_QueryInterface(
59 IXMLDOMAttribute
*iface
,
63 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
64 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
66 if ( IsEqualGUID( riid
, &IID_IXMLDOMAttribute
) ||
67 IsEqualGUID( riid
, &IID_IUnknown
) )
71 else if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
72 IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
74 return IUnknown_QueryInterface(This
->node_unk
, riid
, ppvObject
);
78 FIXME("Unsupported inteferace %s\n", debugstr_guid(riid
));
82 IXMLDOMAttribute_AddRef( iface
);
87 static ULONG WINAPI
domattr_AddRef(
88 IXMLDOMAttribute
*iface
)
90 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
91 return InterlockedIncrement( &This
->ref
);
94 static ULONG WINAPI
domattr_Release(
95 IXMLDOMAttribute
*iface
)
97 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
100 ref
= InterlockedDecrement( &This
->ref
);
103 IUnknown_Release( This
->node_unk
);
104 HeapFree( GetProcessHeap(), 0, This
);
110 static HRESULT WINAPI
domattr_GetTypeInfoCount(
111 IXMLDOMAttribute
*iface
,
118 static HRESULT WINAPI
domattr_GetTypeInfo(
119 IXMLDOMAttribute
*iface
,
120 UINT iTInfo
, LCID lcid
,
121 ITypeInfo
** ppTInfo
)
127 static HRESULT WINAPI
domattr_GetIDsOfNames(
128 IXMLDOMAttribute
*iface
,
129 REFIID riid
, LPOLESTR
* rgszNames
,
130 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
136 static HRESULT WINAPI
domattr_Invoke(
137 IXMLDOMAttribute
*iface
,
138 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
139 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
140 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
146 static HRESULT WINAPI
domattr_get_nodeName(
147 IXMLDOMAttribute
*iface
,
150 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
151 return IXMLDOMNode_get_nodeName( This
->node
, p
);
154 static HRESULT WINAPI
domattr_get_nodeValue(
155 IXMLDOMAttribute
*iface
,
158 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
159 return IXMLDOMNode_get_nodeValue( This
->node
, var1
);
162 static HRESULT WINAPI
domattr_put_nodeValue(
163 IXMLDOMAttribute
*iface
,
166 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
167 return IXMLDOMNode_put_nodeValue( This
->node
, var1
);
170 static HRESULT WINAPI
domattr_get_nodeType(
171 IXMLDOMAttribute
*iface
,
172 DOMNodeType
* domNodeType
)
174 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
175 return IXMLDOMNode_get_nodeType( This
->node
, domNodeType
);
178 static HRESULT WINAPI
domattr_get_parentNode(
179 IXMLDOMAttribute
*iface
,
180 IXMLDOMNode
** parent
)
182 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
183 return IXMLDOMNode_get_parentNode( This
->node
, parent
);
186 static HRESULT WINAPI
domattr_get_childNodes(
187 IXMLDOMAttribute
*iface
,
188 IXMLDOMNodeList
** outList
)
190 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
191 return IXMLDOMNode_get_childNodes( This
->node
, outList
);
194 static HRESULT WINAPI
domattr_get_firstChild(
195 IXMLDOMAttribute
*iface
,
196 IXMLDOMNode
** domNode
)
198 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
199 return IXMLDOMNode_get_firstChild( This
->node
, domNode
);
202 static HRESULT WINAPI
domattr_get_lastChild(
203 IXMLDOMAttribute
*iface
,
204 IXMLDOMNode
** domNode
)
206 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
207 return IXMLDOMNode_get_lastChild( This
->node
, domNode
);
210 static HRESULT WINAPI
domattr_get_previousSibling(
211 IXMLDOMAttribute
*iface
,
212 IXMLDOMNode
** domNode
)
214 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
215 return IXMLDOMNode_get_previousSibling( This
->node
, domNode
);
218 static HRESULT WINAPI
domattr_get_nextSibling(
219 IXMLDOMAttribute
*iface
,
220 IXMLDOMNode
** domNode
)
222 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
223 return IXMLDOMNode_get_nextSibling( This
->node
, domNode
);
226 static HRESULT WINAPI
domattr_get_attributes(
227 IXMLDOMAttribute
*iface
,
228 IXMLDOMNamedNodeMap
** attributeMap
)
230 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
231 return IXMLDOMNode_get_attributes( This
->node
, attributeMap
);
234 static HRESULT WINAPI
domattr_insertBefore(
235 IXMLDOMAttribute
*iface
,
236 IXMLDOMNode
* newNode
, VARIANT var1
,
237 IXMLDOMNode
** outOldNode
)
239 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
240 return IXMLDOMNode_insertBefore( This
->node
, newNode
, var1
, outOldNode
);
243 static HRESULT WINAPI
domattr_replaceChild(
244 IXMLDOMAttribute
*iface
,
245 IXMLDOMNode
* newNode
,
246 IXMLDOMNode
* oldNode
,
247 IXMLDOMNode
** outOldNode
)
249 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
250 return IXMLDOMNode_replaceChild( This
->node
, newNode
, oldNode
, outOldNode
);
253 static HRESULT WINAPI
domattr_removeChild(
254 IXMLDOMAttribute
*iface
,
255 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
257 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
258 return IXMLDOMNode_removeChild( This
->node
, domNode
, oldNode
);
261 static HRESULT WINAPI
domattr_appendChild(
262 IXMLDOMAttribute
*iface
,
263 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
265 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
266 return IXMLDOMNode_appendChild( This
->node
, newNode
, outNewNode
);
269 static HRESULT WINAPI
domattr_hasChildNodes(
270 IXMLDOMAttribute
*iface
,
273 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
274 return IXMLDOMNode_hasChildNodes( This
->node
, pbool
);
277 static HRESULT WINAPI
domattr_get_ownerDocument(
278 IXMLDOMAttribute
*iface
,
279 IXMLDOMDocument
** domDocument
)
281 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
282 return IXMLDOMNode_get_ownerDocument( This
->node
, domDocument
);
285 static HRESULT WINAPI
domattr_cloneNode(
286 IXMLDOMAttribute
*iface
,
287 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
289 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
290 return IXMLDOMNode_cloneNode( This
->node
, pbool
, outNode
);
293 static HRESULT WINAPI
domattr_get_nodeTypeString(
294 IXMLDOMAttribute
*iface
,
297 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
298 return IXMLDOMNode_get_nodeTypeString( This
->node
, p
);
301 static HRESULT WINAPI
domattr_get_text(
302 IXMLDOMAttribute
*iface
,
305 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
306 return IXMLDOMNode_get_text( This
->node
, p
);
309 static HRESULT WINAPI
domattr_put_text(
310 IXMLDOMAttribute
*iface
,
313 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
314 return IXMLDOMNode_put_text( This
->node
, p
);
317 static HRESULT WINAPI
domattr_get_specified(
318 IXMLDOMAttribute
*iface
,
321 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
322 return IXMLDOMNode_get_specified( This
->node
, pbool
);
325 static HRESULT WINAPI
domattr_get_definition(
326 IXMLDOMAttribute
*iface
,
327 IXMLDOMNode
** domNode
)
329 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
330 return IXMLDOMNode_get_definition( This
->node
, domNode
);
333 static HRESULT WINAPI
domattr_get_nodeTypedValue(
334 IXMLDOMAttribute
*iface
,
337 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
338 return IXMLDOMNode_get_nodeTypedValue( This
->node
, var1
);
341 static HRESULT WINAPI
domattr_put_nodeTypedValue(
342 IXMLDOMAttribute
*iface
,
345 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
346 return IXMLDOMNode_put_nodeTypedValue( This
->node
, var1
);
349 static HRESULT WINAPI
domattr_get_dataType(
350 IXMLDOMAttribute
*iface
,
353 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
354 return IXMLDOMNode_get_dataType( This
->node
, var1
);
357 static HRESULT WINAPI
domattr_put_dataType(
358 IXMLDOMAttribute
*iface
,
361 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
362 return IXMLDOMNode_put_dataType( This
->node
, p
);
365 static HRESULT WINAPI
domattr_get_xml(
366 IXMLDOMAttribute
*iface
,
369 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
370 return IXMLDOMNode_get_xml( This
->node
, p
);
373 static HRESULT WINAPI
domattr_transformNode(
374 IXMLDOMAttribute
*iface
,
375 IXMLDOMNode
* domNode
, BSTR
* p
)
377 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
378 return IXMLDOMNode_transformNode( This
->node
, domNode
, p
);
381 static HRESULT WINAPI
domattr_selectNodes(
382 IXMLDOMAttribute
*iface
,
383 BSTR p
, IXMLDOMNodeList
** outList
)
385 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
386 return IXMLDOMNode_selectNodes( This
->node
, p
, outList
);
389 static HRESULT WINAPI
domattr_selectSingleNode(
390 IXMLDOMAttribute
*iface
,
391 BSTR p
, IXMLDOMNode
** outNode
)
393 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
394 return IXMLDOMNode_selectSingleNode( This
->node
, p
, outNode
);
397 static HRESULT WINAPI
domattr_get_parsed(
398 IXMLDOMAttribute
*iface
,
401 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
402 return IXMLDOMNode_get_parsed( This
->node
, pbool
);
405 static HRESULT WINAPI
domattr_get_namespaceURI(
406 IXMLDOMAttribute
*iface
,
409 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
410 return IXMLDOMNode_get_namespaceURI( This
->node
, p
);
413 static HRESULT WINAPI
domattr_get_prefix(
414 IXMLDOMAttribute
*iface
,
417 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
418 return IXMLDOMNode_get_prefix( This
->node
, p
);
421 static HRESULT WINAPI
domattr_get_baseName(
422 IXMLDOMAttribute
*iface
,
425 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
426 return IXMLDOMNode_get_baseName( This
->node
, p
);
429 static HRESULT WINAPI
domattr_transformNodeToObject(
430 IXMLDOMAttribute
*iface
,
431 IXMLDOMNode
* domNode
, VARIANT var1
)
433 domattr
*This
= impl_from_IXMLDOMAttribute( iface
);
434 return IXMLDOMNode_transformNodeToObject( This
->node
, domNode
, var1
);
437 static HRESULT WINAPI
domattr_get_name(
438 IXMLDOMAttribute
*iface
,
445 static HRESULT WINAPI
domattr_get_value(
446 IXMLDOMAttribute
*iface
,
453 static HRESULT WINAPI
domattr_put_value(
454 IXMLDOMAttribute
*iface
,
461 static const struct IXMLDOMAttributeVtbl domattr_vtbl
=
463 domattr_QueryInterface
,
466 domattr_GetTypeInfoCount
,
468 domattr_GetIDsOfNames
,
470 domattr_get_nodeName
,
471 domattr_get_nodeValue
,
472 domattr_put_nodeValue
,
473 domattr_get_nodeType
,
474 domattr_get_parentNode
,
475 domattr_get_childNodes
,
476 domattr_get_firstChild
,
477 domattr_get_lastChild
,
478 domattr_get_previousSibling
,
479 domattr_get_nextSibling
,
480 domattr_get_attributes
,
481 domattr_insertBefore
,
482 domattr_replaceChild
,
485 domattr_hasChildNodes
,
486 domattr_get_ownerDocument
,
488 domattr_get_nodeTypeString
,
491 domattr_get_specified
,
492 domattr_get_definition
,
493 domattr_get_nodeTypedValue
,
494 domattr_put_nodeTypedValue
,
495 domattr_get_dataType
,
496 domattr_put_dataType
,
498 domattr_transformNode
,
500 domattr_selectSingleNode
,
502 domattr_get_namespaceURI
,
504 domattr_get_baseName
,
505 domattr_transformNodeToObject
,
511 IUnknown
* create_attribute( xmlNodePtr attribute
)
516 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
520 This
->lpVtbl
= &domattr_vtbl
;
523 This
->node_unk
= create_basic_node( attribute
, (IUnknown
*)&This
->lpVtbl
);
526 HeapFree(GetProcessHeap(), 0, This
);
530 hr
= IUnknown_QueryInterface(This
->node_unk
, &IID_IXMLDOMNode
, (LPVOID
*)&This
->node
);
533 IUnknown_Release(This
->node_unk
);
534 HeapFree( GetProcessHeap(), 0, This
);
537 /* The ref on This->node is actually looped back into this object, so release it */
538 IXMLDOMNode_Release(This
->node
);
540 return (IUnknown
*) &This
->lpVtbl
;