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);
70 else if(node_query_interface(&This->node, riid, ppvObject))
72 return *ppvObject ? S_OK : E_NOINTERFACE;
76 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
80 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
84 static ULONG WINAPI domattr_AddRef(
85 IXMLDOMAttribute *iface )
87 domattr *This = impl_from_IXMLDOMAttribute( iface );
88 return InterlockedIncrement( &This->ref );
91 static ULONG WINAPI domattr_Release(
92 IXMLDOMAttribute *iface )
94 domattr *This = impl_from_IXMLDOMAttribute( iface );
97 ref = InterlockedDecrement( &This->ref );
100 destroy_xmlnode(&This->node);
107 static HRESULT WINAPI domattr_GetTypeInfoCount(
108 IXMLDOMAttribute *iface,
111 domattr *This = impl_from_IXMLDOMAttribute( iface );
113 TRACE("(%p)->(%p)\n", This, pctinfo);
120 static HRESULT WINAPI domattr_GetTypeInfo(
121 IXMLDOMAttribute *iface,
122 UINT iTInfo, LCID lcid,
123 ITypeInfo** ppTInfo )
125 domattr *This = impl_from_IXMLDOMAttribute( iface );
128 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
130 hr = get_typeinfo(IXMLDOMAttribute_tid, ppTInfo);
135 static HRESULT WINAPI domattr_GetIDsOfNames(
136 IXMLDOMAttribute *iface,
137 REFIID riid, LPOLESTR* rgszNames,
138 UINT cNames, LCID lcid, DISPID* rgDispId )
140 domattr *This = impl_from_IXMLDOMAttribute( iface );
144 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
147 if(!rgszNames || cNames == 0 || !rgDispId)
150 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
153 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
154 ITypeInfo_Release(typeinfo);
160 static HRESULT WINAPI domattr_Invoke(
161 IXMLDOMAttribute *iface,
162 DISPID dispIdMember, REFIID riid, LCID lcid,
163 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
164 EXCEPINFO* pExcepInfo, UINT* puArgErr )
166 domattr *This = impl_from_IXMLDOMAttribute( iface );
170 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
171 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
173 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
176 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
177 pVarResult, pExcepInfo, puArgErr);
178 ITypeInfo_Release(typeinfo);
183 static HRESULT WINAPI domattr_get_nodeName(
184 IXMLDOMAttribute *iface,
187 domattr *This = impl_from_IXMLDOMAttribute( iface );
188 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
191 static HRESULT WINAPI domattr_get_nodeValue(
192 IXMLDOMAttribute *iface,
195 domattr *This = impl_from_IXMLDOMAttribute( iface );
196 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
199 static HRESULT WINAPI domattr_put_nodeValue(
200 IXMLDOMAttribute *iface,
203 domattr *This = impl_from_IXMLDOMAttribute( iface );
204 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
207 static HRESULT WINAPI domattr_get_nodeType(
208 IXMLDOMAttribute *iface,
209 DOMNodeType* domNodeType )
211 domattr *This = impl_from_IXMLDOMAttribute( iface );
212 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), domNodeType );
215 static HRESULT WINAPI domattr_get_parentNode(
216 IXMLDOMAttribute *iface,
217 IXMLDOMNode** parent )
219 domattr *This = impl_from_IXMLDOMAttribute( iface );
220 TRACE("(%p)->(%p)\n", This, parent);
221 if (!parent) return E_INVALIDARG;
226 static HRESULT WINAPI domattr_get_childNodes(
227 IXMLDOMAttribute *iface,
228 IXMLDOMNodeList** outList)
230 domattr *This = impl_from_IXMLDOMAttribute( iface );
231 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
234 static HRESULT WINAPI domattr_get_firstChild(
235 IXMLDOMAttribute *iface,
236 IXMLDOMNode** domNode)
238 domattr *This = impl_from_IXMLDOMAttribute( iface );
239 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
242 static HRESULT WINAPI domattr_get_lastChild(
243 IXMLDOMAttribute *iface,
244 IXMLDOMNode** domNode)
246 domattr *This = impl_from_IXMLDOMAttribute( iface );
247 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
250 static HRESULT WINAPI domattr_get_previousSibling(
251 IXMLDOMAttribute *iface,
252 IXMLDOMNode** domNode)
254 domattr *This = impl_from_IXMLDOMAttribute( iface );
255 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
258 static HRESULT WINAPI domattr_get_nextSibling(
259 IXMLDOMAttribute *iface,
260 IXMLDOMNode** domNode)
262 domattr *This = impl_from_IXMLDOMAttribute( iface );
263 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
266 static HRESULT WINAPI domattr_get_attributes(
267 IXMLDOMAttribute *iface,
268 IXMLDOMNamedNodeMap** attributeMap)
270 domattr *This = impl_from_IXMLDOMAttribute( iface );
271 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
274 static HRESULT WINAPI domattr_insertBefore(
275 IXMLDOMAttribute *iface,
276 IXMLDOMNode* newNode, VARIANT var1,
277 IXMLDOMNode** outOldNode)
279 domattr *This = impl_from_IXMLDOMAttribute( iface );
280 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
283 static HRESULT WINAPI domattr_replaceChild(
284 IXMLDOMAttribute *iface,
285 IXMLDOMNode* newNode,
286 IXMLDOMNode* oldNode,
287 IXMLDOMNode** outOldNode)
289 domattr *This = impl_from_IXMLDOMAttribute( iface );
290 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
293 static HRESULT WINAPI domattr_removeChild(
294 IXMLDOMAttribute *iface,
295 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
297 domattr *This = impl_from_IXMLDOMAttribute( iface );
298 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
301 static HRESULT WINAPI domattr_appendChild(
302 IXMLDOMAttribute *iface,
303 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
305 domattr *This = impl_from_IXMLDOMAttribute( iface );
306 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
309 static HRESULT WINAPI domattr_hasChildNodes(
310 IXMLDOMAttribute *iface,
313 domattr *This = impl_from_IXMLDOMAttribute( iface );
314 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
317 static HRESULT WINAPI domattr_get_ownerDocument(
318 IXMLDOMAttribute *iface,
319 IXMLDOMDocument** domDocument)
321 domattr *This = impl_from_IXMLDOMAttribute( iface );
322 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
325 static HRESULT WINAPI domattr_cloneNode(
326 IXMLDOMAttribute *iface,
327 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
329 domattr *This = impl_from_IXMLDOMAttribute( iface );
330 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
333 static HRESULT WINAPI domattr_get_nodeTypeString(
334 IXMLDOMAttribute *iface,
337 domattr *This = impl_from_IXMLDOMAttribute( iface );
338 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
341 static HRESULT WINAPI domattr_get_text(
342 IXMLDOMAttribute *iface,
345 domattr *This = impl_from_IXMLDOMAttribute( iface );
346 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
349 static HRESULT WINAPI domattr_put_text(
350 IXMLDOMAttribute *iface,
353 domattr *This = impl_from_IXMLDOMAttribute( iface );
354 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
357 static HRESULT WINAPI domattr_get_specified(
358 IXMLDOMAttribute *iface,
361 domattr *This = impl_from_IXMLDOMAttribute( iface );
362 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
365 static HRESULT WINAPI domattr_get_definition(
366 IXMLDOMAttribute *iface,
367 IXMLDOMNode** domNode)
369 domattr *This = impl_from_IXMLDOMAttribute( iface );
370 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
373 static HRESULT WINAPI domattr_get_nodeTypedValue(
374 IXMLDOMAttribute *iface,
377 domattr *This = impl_from_IXMLDOMAttribute( iface );
378 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
381 static HRESULT WINAPI domattr_put_nodeTypedValue(
382 IXMLDOMAttribute *iface,
385 domattr *This = impl_from_IXMLDOMAttribute( iface );
386 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
389 static HRESULT WINAPI domattr_get_dataType(
390 IXMLDOMAttribute *iface,
393 domattr *This = impl_from_IXMLDOMAttribute( iface );
394 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
397 static HRESULT WINAPI domattr_put_dataType(
398 IXMLDOMAttribute *iface,
401 domattr *This = impl_from_IXMLDOMAttribute( iface );
402 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
405 static HRESULT WINAPI domattr_get_xml(
406 IXMLDOMAttribute *iface,
409 domattr *This = impl_from_IXMLDOMAttribute( iface );
410 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
413 static HRESULT WINAPI domattr_transformNode(
414 IXMLDOMAttribute *iface,
415 IXMLDOMNode* domNode, BSTR* p)
417 domattr *This = impl_from_IXMLDOMAttribute( iface );
418 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
421 static HRESULT WINAPI domattr_selectNodes(
422 IXMLDOMAttribute *iface,
423 BSTR p, IXMLDOMNodeList** outList)
425 domattr *This = impl_from_IXMLDOMAttribute( iface );
426 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
429 static HRESULT WINAPI domattr_selectSingleNode(
430 IXMLDOMAttribute *iface,
431 BSTR p, IXMLDOMNode** outNode)
433 domattr *This = impl_from_IXMLDOMAttribute( iface );
434 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
437 static HRESULT WINAPI domattr_get_parsed(
438 IXMLDOMAttribute *iface,
441 domattr *This = impl_from_IXMLDOMAttribute( iface );
442 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
445 static HRESULT WINAPI domattr_get_namespaceURI(
446 IXMLDOMAttribute *iface,
449 domattr *This = impl_from_IXMLDOMAttribute( iface );
450 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
453 static HRESULT WINAPI domattr_get_prefix(
454 IXMLDOMAttribute *iface,
457 domattr *This = impl_from_IXMLDOMAttribute( iface );
458 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
461 static HRESULT WINAPI domattr_get_baseName(
462 IXMLDOMAttribute *iface,
465 domattr *This = impl_from_IXMLDOMAttribute( iface );
466 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
469 static HRESULT WINAPI domattr_transformNodeToObject(
470 IXMLDOMAttribute *iface,
471 IXMLDOMNode* domNode, VARIANT var1)
473 domattr *This = impl_from_IXMLDOMAttribute( iface );
474 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
477 static HRESULT WINAPI domattr_get_name(
478 IXMLDOMAttribute *iface,
481 /* name property returns the same value as nodeName */
482 domattr *This = impl_from_IXMLDOMAttribute( iface );
483 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
486 static HRESULT WINAPI domattr_get_value(
487 IXMLDOMAttribute *iface,
490 domattr *This = impl_from_IXMLDOMAttribute( iface );
491 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
494 static HRESULT WINAPI domattr_put_value(
495 IXMLDOMAttribute *iface,
498 domattr *This = impl_from_IXMLDOMAttribute( iface );
499 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
502 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
504 domattr_QueryInterface,
507 domattr_GetTypeInfoCount,
509 domattr_GetIDsOfNames,
511 domattr_get_nodeName,
512 domattr_get_nodeValue,
513 domattr_put_nodeValue,
514 domattr_get_nodeType,
515 domattr_get_parentNode,
516 domattr_get_childNodes,
517 domattr_get_firstChild,
518 domattr_get_lastChild,
519 domattr_get_previousSibling,
520 domattr_get_nextSibling,
521 domattr_get_attributes,
522 domattr_insertBefore,
523 domattr_replaceChild,
526 domattr_hasChildNodes,
527 domattr_get_ownerDocument,
529 domattr_get_nodeTypeString,
532 domattr_get_specified,
533 domattr_get_definition,
534 domattr_get_nodeTypedValue,
535 domattr_put_nodeTypedValue,
536 domattr_get_dataType,
537 domattr_put_dataType,
539 domattr_transformNode,
541 domattr_selectSingleNode,
543 domattr_get_namespaceURI,
545 domattr_get_baseName,
546 domattr_transformNodeToObject,
552 IUnknown* create_attribute( xmlNodePtr attribute )
556 This = heap_alloc( sizeof *This );
560 This->lpVtbl = &domattr_vtbl;
563 init_xmlnode(&This->node, attribute, (IXMLDOMNode*)&This->lpVtbl, NULL);
565 return (IUnknown*) &This->lpVtbl;