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);
97 HeapFree( GetProcessHeap(), 0, This );
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 return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent );
219 static HRESULT WINAPI domattr_get_childNodes(
220 IXMLDOMAttribute *iface,
221 IXMLDOMNodeList** outList)
223 domattr *This = impl_from_IXMLDOMAttribute( iface );
224 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
227 static HRESULT WINAPI domattr_get_firstChild(
228 IXMLDOMAttribute *iface,
229 IXMLDOMNode** domNode)
231 domattr *This = impl_from_IXMLDOMAttribute( iface );
232 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
235 static HRESULT WINAPI domattr_get_lastChild(
236 IXMLDOMAttribute *iface,
237 IXMLDOMNode** domNode)
239 domattr *This = impl_from_IXMLDOMAttribute( iface );
240 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
243 static HRESULT WINAPI domattr_get_previousSibling(
244 IXMLDOMAttribute *iface,
245 IXMLDOMNode** domNode)
247 domattr *This = impl_from_IXMLDOMAttribute( iface );
248 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
251 static HRESULT WINAPI domattr_get_nextSibling(
252 IXMLDOMAttribute *iface,
253 IXMLDOMNode** domNode)
255 domattr *This = impl_from_IXMLDOMAttribute( iface );
256 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
259 static HRESULT WINAPI domattr_get_attributes(
260 IXMLDOMAttribute *iface,
261 IXMLDOMNamedNodeMap** attributeMap)
263 domattr *This = impl_from_IXMLDOMAttribute( iface );
264 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
267 static HRESULT WINAPI domattr_insertBefore(
268 IXMLDOMAttribute *iface,
269 IXMLDOMNode* newNode, VARIANT var1,
270 IXMLDOMNode** outOldNode)
272 domattr *This = impl_from_IXMLDOMAttribute( iface );
273 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
276 static HRESULT WINAPI domattr_replaceChild(
277 IXMLDOMAttribute *iface,
278 IXMLDOMNode* newNode,
279 IXMLDOMNode* oldNode,
280 IXMLDOMNode** outOldNode)
282 domattr *This = impl_from_IXMLDOMAttribute( iface );
283 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
286 static HRESULT WINAPI domattr_removeChild(
287 IXMLDOMAttribute *iface,
288 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
290 domattr *This = impl_from_IXMLDOMAttribute( iface );
291 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
294 static HRESULT WINAPI domattr_appendChild(
295 IXMLDOMAttribute *iface,
296 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
298 domattr *This = impl_from_IXMLDOMAttribute( iface );
299 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
302 static HRESULT WINAPI domattr_hasChildNodes(
303 IXMLDOMAttribute *iface,
306 domattr *This = impl_from_IXMLDOMAttribute( iface );
307 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
310 static HRESULT WINAPI domattr_get_ownerDocument(
311 IXMLDOMAttribute *iface,
312 IXMLDOMDocument** domDocument)
314 domattr *This = impl_from_IXMLDOMAttribute( iface );
315 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
318 static HRESULT WINAPI domattr_cloneNode(
319 IXMLDOMAttribute *iface,
320 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
322 domattr *This = impl_from_IXMLDOMAttribute( iface );
323 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
326 static HRESULT WINAPI domattr_get_nodeTypeString(
327 IXMLDOMAttribute *iface,
330 domattr *This = impl_from_IXMLDOMAttribute( iface );
331 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
334 static HRESULT WINAPI domattr_get_text(
335 IXMLDOMAttribute *iface,
338 domattr *This = impl_from_IXMLDOMAttribute( iface );
339 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
342 static HRESULT WINAPI domattr_put_text(
343 IXMLDOMAttribute *iface,
346 domattr *This = impl_from_IXMLDOMAttribute( iface );
347 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
350 static HRESULT WINAPI domattr_get_specified(
351 IXMLDOMAttribute *iface,
354 domattr *This = impl_from_IXMLDOMAttribute( iface );
355 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
358 static HRESULT WINAPI domattr_get_definition(
359 IXMLDOMAttribute *iface,
360 IXMLDOMNode** domNode)
362 domattr *This = impl_from_IXMLDOMAttribute( iface );
363 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
366 static HRESULT WINAPI domattr_get_nodeTypedValue(
367 IXMLDOMAttribute *iface,
370 domattr *This = impl_from_IXMLDOMAttribute( iface );
371 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
374 static HRESULT WINAPI domattr_put_nodeTypedValue(
375 IXMLDOMAttribute *iface,
378 domattr *This = impl_from_IXMLDOMAttribute( iface );
379 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
382 static HRESULT WINAPI domattr_get_dataType(
383 IXMLDOMAttribute *iface,
386 domattr *This = impl_from_IXMLDOMAttribute( iface );
387 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
390 static HRESULT WINAPI domattr_put_dataType(
391 IXMLDOMAttribute *iface,
394 domattr *This = impl_from_IXMLDOMAttribute( iface );
395 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
398 static HRESULT WINAPI domattr_get_xml(
399 IXMLDOMAttribute *iface,
402 domattr *This = impl_from_IXMLDOMAttribute( iface );
403 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
406 static HRESULT WINAPI domattr_transformNode(
407 IXMLDOMAttribute *iface,
408 IXMLDOMNode* domNode, BSTR* p)
410 domattr *This = impl_from_IXMLDOMAttribute( iface );
411 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
414 static HRESULT WINAPI domattr_selectNodes(
415 IXMLDOMAttribute *iface,
416 BSTR p, IXMLDOMNodeList** outList)
418 domattr *This = impl_from_IXMLDOMAttribute( iface );
419 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
422 static HRESULT WINAPI domattr_selectSingleNode(
423 IXMLDOMAttribute *iface,
424 BSTR p, IXMLDOMNode** outNode)
426 domattr *This = impl_from_IXMLDOMAttribute( iface );
427 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
430 static HRESULT WINAPI domattr_get_parsed(
431 IXMLDOMAttribute *iface,
434 domattr *This = impl_from_IXMLDOMAttribute( iface );
435 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
438 static HRESULT WINAPI domattr_get_namespaceURI(
439 IXMLDOMAttribute *iface,
442 domattr *This = impl_from_IXMLDOMAttribute( iface );
443 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
446 static HRESULT WINAPI domattr_get_prefix(
447 IXMLDOMAttribute *iface,
450 domattr *This = impl_from_IXMLDOMAttribute( iface );
451 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
454 static HRESULT WINAPI domattr_get_baseName(
455 IXMLDOMAttribute *iface,
458 domattr *This = impl_from_IXMLDOMAttribute( iface );
459 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
462 static HRESULT WINAPI domattr_transformNodeToObject(
463 IXMLDOMAttribute *iface,
464 IXMLDOMNode* domNode, VARIANT var1)
466 domattr *This = impl_from_IXMLDOMAttribute( iface );
467 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
470 static HRESULT WINAPI domattr_get_name(
471 IXMLDOMAttribute *iface,
474 /* name property returns the same value as nodeName */
475 domattr *This = impl_from_IXMLDOMAttribute( iface );
476 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
479 static HRESULT WINAPI domattr_get_value(
480 IXMLDOMAttribute *iface,
483 domattr *This = impl_from_IXMLDOMAttribute( iface );
484 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
487 static HRESULT WINAPI domattr_put_value(
488 IXMLDOMAttribute *iface,
491 domattr *This = impl_from_IXMLDOMAttribute( iface );
492 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
495 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
497 domattr_QueryInterface,
500 domattr_GetTypeInfoCount,
502 domattr_GetIDsOfNames,
504 domattr_get_nodeName,
505 domattr_get_nodeValue,
506 domattr_put_nodeValue,
507 domattr_get_nodeType,
508 domattr_get_parentNode,
509 domattr_get_childNodes,
510 domattr_get_firstChild,
511 domattr_get_lastChild,
512 domattr_get_previousSibling,
513 domattr_get_nextSibling,
514 domattr_get_attributes,
515 domattr_insertBefore,
516 domattr_replaceChild,
519 domattr_hasChildNodes,
520 domattr_get_ownerDocument,
522 domattr_get_nodeTypeString,
525 domattr_get_specified,
526 domattr_get_definition,
527 domattr_get_nodeTypedValue,
528 domattr_put_nodeTypedValue,
529 domattr_get_dataType,
530 domattr_put_dataType,
532 domattr_transformNode,
534 domattr_selectSingleNode,
536 domattr_get_namespaceURI,
538 domattr_get_baseName,
539 domattr_transformNodeToObject,
545 IUnknown* create_attribute( xmlNodePtr attribute )
549 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
553 This->lpVtbl = &domattr_vtbl;
556 init_xmlnode(&This->node, attribute, (IUnknown*)&This->lpVtbl, NULL);
558 return (IUnknown*) &This->lpVtbl;