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_IXMLDOMNode ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
81 static ULONG WINAPI domattr_AddRef(
82 IXMLDOMAttribute *iface )
84 domattr *This = impl_from_IXMLDOMAttribute( iface );
85 return InterlockedIncrement( &This->ref );
88 static ULONG WINAPI domattr_Release(
89 IXMLDOMAttribute *iface )
91 domattr *This = impl_from_IXMLDOMAttribute( iface );
94 ref = InterlockedDecrement( &This->ref );
97 destroy_xmlnode(&This->node);
104 static HRESULT WINAPI domattr_GetTypeInfoCount(
105 IXMLDOMAttribute *iface,
108 domattr *This = impl_from_IXMLDOMAttribute( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
117 static HRESULT WINAPI domattr_GetTypeInfo(
118 IXMLDOMAttribute *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 domattr *This = impl_from_IXMLDOMAttribute( iface );
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMAttribute_tid, ppTInfo);
132 static HRESULT WINAPI domattr_GetIDsOfNames(
133 IXMLDOMAttribute *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 domattr *This = impl_from_IXMLDOMAttribute( iface );
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 if(!rgszNames || cNames == 0 || !rgDispId)
147 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
157 static HRESULT WINAPI domattr_Invoke(
158 IXMLDOMAttribute *iface,
159 DISPID dispIdMember, REFIID riid, LCID lcid,
160 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
161 EXCEPINFO* pExcepInfo, UINT* puArgErr )
163 domattr *This = impl_from_IXMLDOMAttribute( iface );
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
168 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
170 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
173 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
174 pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
180 static HRESULT WINAPI domattr_get_nodeName(
181 IXMLDOMAttribute *iface,
184 domattr *This = impl_from_IXMLDOMAttribute( iface );
185 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
188 static HRESULT WINAPI domattr_get_nodeValue(
189 IXMLDOMAttribute *iface,
192 domattr *This = impl_from_IXMLDOMAttribute( iface );
193 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
196 static HRESULT WINAPI domattr_put_nodeValue(
197 IXMLDOMAttribute *iface,
200 domattr *This = impl_from_IXMLDOMAttribute( iface );
201 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
204 static HRESULT WINAPI domattr_get_nodeType(
205 IXMLDOMAttribute *iface,
206 DOMNodeType* domNodeType )
208 domattr *This = impl_from_IXMLDOMAttribute( iface );
209 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), domNodeType );
212 static HRESULT WINAPI domattr_get_parentNode(
213 IXMLDOMAttribute *iface,
214 IXMLDOMNode** parent )
216 domattr *This = impl_from_IXMLDOMAttribute( iface );
217 TRACE("(%p)->(%p)\n", This, parent);
218 if (!parent) return E_INVALIDARG;
223 static HRESULT WINAPI domattr_get_childNodes(
224 IXMLDOMAttribute *iface,
225 IXMLDOMNodeList** outList)
227 domattr *This = impl_from_IXMLDOMAttribute( iface );
228 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
231 static HRESULT WINAPI domattr_get_firstChild(
232 IXMLDOMAttribute *iface,
233 IXMLDOMNode** domNode)
235 domattr *This = impl_from_IXMLDOMAttribute( iface );
236 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
239 static HRESULT WINAPI domattr_get_lastChild(
240 IXMLDOMAttribute *iface,
241 IXMLDOMNode** domNode)
243 domattr *This = impl_from_IXMLDOMAttribute( iface );
244 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
247 static HRESULT WINAPI domattr_get_previousSibling(
248 IXMLDOMAttribute *iface,
249 IXMLDOMNode** domNode)
251 domattr *This = impl_from_IXMLDOMAttribute( iface );
252 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
255 static HRESULT WINAPI domattr_get_nextSibling(
256 IXMLDOMAttribute *iface,
257 IXMLDOMNode** domNode)
259 domattr *This = impl_from_IXMLDOMAttribute( iface );
260 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
263 static HRESULT WINAPI domattr_get_attributes(
264 IXMLDOMAttribute *iface,
265 IXMLDOMNamedNodeMap** attributeMap)
267 domattr *This = impl_from_IXMLDOMAttribute( iface );
268 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
271 static HRESULT WINAPI domattr_insertBefore(
272 IXMLDOMAttribute *iface,
273 IXMLDOMNode* newNode, VARIANT var1,
274 IXMLDOMNode** outOldNode)
276 domattr *This = impl_from_IXMLDOMAttribute( iface );
277 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
280 static HRESULT WINAPI domattr_replaceChild(
281 IXMLDOMAttribute *iface,
282 IXMLDOMNode* newNode,
283 IXMLDOMNode* oldNode,
284 IXMLDOMNode** outOldNode)
286 domattr *This = impl_from_IXMLDOMAttribute( iface );
287 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
290 static HRESULT WINAPI domattr_removeChild(
291 IXMLDOMAttribute *iface,
292 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
294 domattr *This = impl_from_IXMLDOMAttribute( iface );
295 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
298 static HRESULT WINAPI domattr_appendChild(
299 IXMLDOMAttribute *iface,
300 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
302 domattr *This = impl_from_IXMLDOMAttribute( iface );
303 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
306 static HRESULT WINAPI domattr_hasChildNodes(
307 IXMLDOMAttribute *iface,
310 domattr *This = impl_from_IXMLDOMAttribute( iface );
311 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
314 static HRESULT WINAPI domattr_get_ownerDocument(
315 IXMLDOMAttribute *iface,
316 IXMLDOMDocument** domDocument)
318 domattr *This = impl_from_IXMLDOMAttribute( iface );
319 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
322 static HRESULT WINAPI domattr_cloneNode(
323 IXMLDOMAttribute *iface,
324 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
326 domattr *This = impl_from_IXMLDOMAttribute( iface );
327 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
330 static HRESULT WINAPI domattr_get_nodeTypeString(
331 IXMLDOMAttribute *iface,
334 domattr *This = impl_from_IXMLDOMAttribute( iface );
335 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
338 static HRESULT WINAPI domattr_get_text(
339 IXMLDOMAttribute *iface,
342 domattr *This = impl_from_IXMLDOMAttribute( iface );
343 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
346 static HRESULT WINAPI domattr_put_text(
347 IXMLDOMAttribute *iface,
350 domattr *This = impl_from_IXMLDOMAttribute( iface );
351 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
354 static HRESULT WINAPI domattr_get_specified(
355 IXMLDOMAttribute *iface,
358 domattr *This = impl_from_IXMLDOMAttribute( iface );
359 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
362 static HRESULT WINAPI domattr_get_definition(
363 IXMLDOMAttribute *iface,
364 IXMLDOMNode** domNode)
366 domattr *This = impl_from_IXMLDOMAttribute( iface );
367 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
370 static HRESULT WINAPI domattr_get_nodeTypedValue(
371 IXMLDOMAttribute *iface,
374 domattr *This = impl_from_IXMLDOMAttribute( iface );
375 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
378 static HRESULT WINAPI domattr_put_nodeTypedValue(
379 IXMLDOMAttribute *iface,
382 domattr *This = impl_from_IXMLDOMAttribute( iface );
383 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
386 static HRESULT WINAPI domattr_get_dataType(
387 IXMLDOMAttribute *iface,
390 domattr *This = impl_from_IXMLDOMAttribute( iface );
391 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
394 static HRESULT WINAPI domattr_put_dataType(
395 IXMLDOMAttribute *iface,
398 domattr *This = impl_from_IXMLDOMAttribute( iface );
399 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
402 static HRESULT WINAPI domattr_get_xml(
403 IXMLDOMAttribute *iface,
406 domattr *This = impl_from_IXMLDOMAttribute( iface );
407 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
410 static HRESULT WINAPI domattr_transformNode(
411 IXMLDOMAttribute *iface,
412 IXMLDOMNode* domNode, BSTR* p)
414 domattr *This = impl_from_IXMLDOMAttribute( iface );
415 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
418 static HRESULT WINAPI domattr_selectNodes(
419 IXMLDOMAttribute *iface,
420 BSTR p, IXMLDOMNodeList** outList)
422 domattr *This = impl_from_IXMLDOMAttribute( iface );
423 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
426 static HRESULT WINAPI domattr_selectSingleNode(
427 IXMLDOMAttribute *iface,
428 BSTR p, IXMLDOMNode** outNode)
430 domattr *This = impl_from_IXMLDOMAttribute( iface );
431 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
434 static HRESULT WINAPI domattr_get_parsed(
435 IXMLDOMAttribute *iface,
438 domattr *This = impl_from_IXMLDOMAttribute( iface );
439 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
442 static HRESULT WINAPI domattr_get_namespaceURI(
443 IXMLDOMAttribute *iface,
446 domattr *This = impl_from_IXMLDOMAttribute( iface );
447 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
450 static HRESULT WINAPI domattr_get_prefix(
451 IXMLDOMAttribute *iface,
454 domattr *This = impl_from_IXMLDOMAttribute( iface );
455 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
458 static HRESULT WINAPI domattr_get_baseName(
459 IXMLDOMAttribute *iface,
462 domattr *This = impl_from_IXMLDOMAttribute( iface );
463 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
466 static HRESULT WINAPI domattr_transformNodeToObject(
467 IXMLDOMAttribute *iface,
468 IXMLDOMNode* domNode, VARIANT var1)
470 domattr *This = impl_from_IXMLDOMAttribute( iface );
471 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
474 static HRESULT WINAPI domattr_get_name(
475 IXMLDOMAttribute *iface,
478 /* name property returns the same value as nodeName */
479 domattr *This = impl_from_IXMLDOMAttribute( iface );
480 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
483 static HRESULT WINAPI domattr_get_value(
484 IXMLDOMAttribute *iface,
487 domattr *This = impl_from_IXMLDOMAttribute( iface );
488 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
491 static HRESULT WINAPI domattr_put_value(
492 IXMLDOMAttribute *iface,
495 domattr *This = impl_from_IXMLDOMAttribute( iface );
496 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
499 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
501 domattr_QueryInterface,
504 domattr_GetTypeInfoCount,
506 domattr_GetIDsOfNames,
508 domattr_get_nodeName,
509 domattr_get_nodeValue,
510 domattr_put_nodeValue,
511 domattr_get_nodeType,
512 domattr_get_parentNode,
513 domattr_get_childNodes,
514 domattr_get_firstChild,
515 domattr_get_lastChild,
516 domattr_get_previousSibling,
517 domattr_get_nextSibling,
518 domattr_get_attributes,
519 domattr_insertBefore,
520 domattr_replaceChild,
523 domattr_hasChildNodes,
524 domattr_get_ownerDocument,
526 domattr_get_nodeTypeString,
529 domattr_get_specified,
530 domattr_get_definition,
531 domattr_get_nodeTypedValue,
532 domattr_put_nodeTypedValue,
533 domattr_get_dataType,
534 domattr_put_dataType,
536 domattr_transformNode,
538 domattr_selectSingleNode,
540 domattr_get_namespaceURI,
542 domattr_get_baseName,
543 domattr_transformNodeToObject,
549 IUnknown* create_attribute( xmlNodePtr attribute )
553 This = heap_alloc( sizeof *This );
557 This->lpVtbl = &domattr_vtbl;
560 init_xmlnode(&This->node, attribute, (IXMLDOMNode*)&This->lpVtbl, NULL);
562 return (IUnknown*) &This->lpVtbl;