msi: Create macro functions to set feature and component states.
[wine.git] / dlls / msxml3 / attribute.c
blob3ef1521783d040896bc7189f71887758bdcafa23
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml2.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _domattr
42 const struct IXMLDOMAttributeVtbl *lpVtbl;
43 LONG ref;
44 IUnknown *node_unk;
45 IXMLDOMNode *node;
46 } domattr;
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,
60 REFIID riid,
61 void** ppvObject )
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 ) )
69 *ppvObject = iface;
71 else if ( IsEqualGUID( riid, &IID_IDispatch ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMNode ) )
74 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
76 else
78 FIXME("Unsupported inteferace %s\n", debugstr_guid(riid));
79 return E_NOINTERFACE;
82 IXMLDOMAttribute_AddRef( iface );
84 return S_OK;
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 );
98 ULONG ref;
100 ref = InterlockedDecrement( &This->ref );
101 if ( ref == 0 )
103 IUnknown_Release( This->node_unk );
104 HeapFree( GetProcessHeap(), 0, This );
107 return ref;
110 static HRESULT WINAPI domattr_GetTypeInfoCount(
111 IXMLDOMAttribute *iface,
112 UINT* pctinfo )
114 FIXME("\n");
115 return E_NOTIMPL;
118 static HRESULT WINAPI domattr_GetTypeInfo(
119 IXMLDOMAttribute *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
123 FIXME("\n");
124 return E_NOTIMPL;
127 static HRESULT WINAPI domattr_GetIDsOfNames(
128 IXMLDOMAttribute *iface,
129 REFIID riid, LPOLESTR* rgszNames,
130 UINT cNames, LCID lcid, DISPID* rgDispId )
132 FIXME("\n");
133 return E_NOTIMPL;
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 )
142 FIXME("\n");
143 return E_NOTIMPL;
146 static HRESULT WINAPI domattr_get_nodeName(
147 IXMLDOMAttribute *iface,
148 BSTR* p )
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,
156 VARIANT* var1 )
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,
164 VARIANT var1 )
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,
271 VARIANT_BOOL* pbool)
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,
295 BSTR* p)
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,
303 BSTR* p)
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,
311 BSTR p)
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,
319 VARIANT_BOOL* pbool)
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,
335 VARIANT* var1)
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,
343 VARIANT var1)
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,
351 VARIANT* var1)
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,
359 BSTR p)
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,
367 BSTR* p)
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,
399 VARIANT_BOOL* pbool)
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,
407 BSTR* p)
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,
415 BSTR* p)
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,
423 BSTR* p)
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,
439 BSTR *p)
441 FIXME("\n");
442 return E_NOTIMPL;
445 static HRESULT WINAPI domattr_get_value(
446 IXMLDOMAttribute *iface,
447 VARIANT *var1)
449 FIXME("\n");
450 return E_NOTIMPL;
453 static HRESULT WINAPI domattr_put_value(
454 IXMLDOMAttribute *iface,
455 VARIANT var1)
457 FIXME("\n");
458 return E_NOTIMPL;
461 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
463 domattr_QueryInterface,
464 domattr_AddRef,
465 domattr_Release,
466 domattr_GetTypeInfoCount,
467 domattr_GetTypeInfo,
468 domattr_GetIDsOfNames,
469 domattr_Invoke,
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,
483 domattr_removeChild,
484 domattr_appendChild,
485 domattr_hasChildNodes,
486 domattr_get_ownerDocument,
487 domattr_cloneNode,
488 domattr_get_nodeTypeString,
489 domattr_get_text,
490 domattr_put_text,
491 domattr_get_specified,
492 domattr_get_definition,
493 domattr_get_nodeTypedValue,
494 domattr_put_nodeTypedValue,
495 domattr_get_dataType,
496 domattr_put_dataType,
497 domattr_get_xml,
498 domattr_transformNode,
499 domattr_selectNodes,
500 domattr_selectSingleNode,
501 domattr_get_parsed,
502 domattr_get_namespaceURI,
503 domattr_get_prefix,
504 domattr_get_baseName,
505 domattr_transformNodeToObject,
506 domattr_get_name,
507 domattr_get_value,
508 domattr_put_value
511 IUnknown* create_attribute( xmlNodePtr attribute )
513 domattr *This;
514 HRESULT hr;
516 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
517 if ( !This )
518 return NULL;
520 This->lpVtbl = &domattr_vtbl;
521 This->ref = 1;
523 This->node_unk = create_basic_node( attribute, (IUnknown*)&This->lpVtbl );
524 if(!This->node_unk)
526 HeapFree(GetProcessHeap(), 0, This);
527 return NULL;
530 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
531 if(FAILED(hr))
533 IUnknown_Release(This->node_unk);
534 HeapFree( GetProcessHeap(), 0, This );
535 return NULL;
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;
543 #endif