Update Russian translations.
[wine/gsoc_dplay.git] / dlls / msxml3 / attribute.c
blob2681a76fab0df95efc824285cc830b7708a51fe6
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 HRESULT WINAPI domattr_QueryInterface(
54 IXMLDOMAttribute *iface,
55 REFIID riid,
56 void** ppvObject )
58 domattr *This = impl_from_IXMLDOMAttribute( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMAttribute ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
65 *ppvObject = iface;
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
69 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IXMLDOMAttribute_AddRef( iface );
79 return S_OK;
82 static ULONG WINAPI domattr_AddRef(
83 IXMLDOMAttribute *iface )
85 domattr *This = impl_from_IXMLDOMAttribute( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI domattr_Release(
90 IXMLDOMAttribute *iface )
92 domattr *This = impl_from_IXMLDOMAttribute( iface );
93 ULONG ref;
95 ref = InterlockedDecrement( &This->ref );
96 if ( ref == 0 )
98 IUnknown_Release( This->node_unk );
99 HeapFree( GetProcessHeap(), 0, This );
102 return ref;
105 static HRESULT WINAPI domattr_GetTypeInfoCount(
106 IXMLDOMAttribute *iface,
107 UINT* pctinfo )
109 domattr *This = impl_from_IXMLDOMAttribute( iface );
111 TRACE("(%p)->(%p)\n", This, pctinfo);
113 *pctinfo = 1;
115 return S_OK;
118 static HRESULT WINAPI domattr_GetTypeInfo(
119 IXMLDOMAttribute *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
123 domattr *This = impl_from_IXMLDOMAttribute( iface );
124 HRESULT hr;
126 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
128 hr = get_typeinfo(IXMLDOMAttribute_tid, ppTInfo);
130 return hr;
133 static HRESULT WINAPI domattr_GetIDsOfNames(
134 IXMLDOMAttribute *iface,
135 REFIID riid, LPOLESTR* rgszNames,
136 UINT cNames, LCID lcid, DISPID* rgDispId )
138 domattr *This = impl_from_IXMLDOMAttribute( iface );
139 ITypeInfo *typeinfo;
140 HRESULT hr;
142 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
143 lcid, rgDispId);
145 if(!rgszNames || cNames == 0 || !rgDispId)
146 return E_INVALIDARG;
148 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
149 if(SUCCEEDED(hr))
151 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
152 ITypeInfo_Release(typeinfo);
155 return hr;
158 static HRESULT WINAPI domattr_Invoke(
159 IXMLDOMAttribute *iface,
160 DISPID dispIdMember, REFIID riid, LCID lcid,
161 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
162 EXCEPINFO* pExcepInfo, UINT* puArgErr )
164 domattr *This = impl_from_IXMLDOMAttribute( iface );
165 ITypeInfo *typeinfo;
166 HRESULT hr;
168 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
169 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
171 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
172 if(SUCCEEDED(hr))
174 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
175 pVarResult, pExcepInfo, puArgErr);
176 ITypeInfo_Release(typeinfo);
178 return hr;
181 static HRESULT WINAPI domattr_get_nodeName(
182 IXMLDOMAttribute *iface,
183 BSTR* p )
185 domattr *This = impl_from_IXMLDOMAttribute( iface );
186 return IXMLDOMNode_get_nodeName( This->node, p );
189 static HRESULT WINAPI domattr_get_nodeValue(
190 IXMLDOMAttribute *iface,
191 VARIANT* var1 )
193 domattr *This = impl_from_IXMLDOMAttribute( iface );
194 return IXMLDOMNode_get_nodeValue( This->node, var1 );
197 static HRESULT WINAPI domattr_put_nodeValue(
198 IXMLDOMAttribute *iface,
199 VARIANT var1 )
201 domattr *This = impl_from_IXMLDOMAttribute( iface );
202 return IXMLDOMNode_put_nodeValue( This->node, var1 );
205 static HRESULT WINAPI domattr_get_nodeType(
206 IXMLDOMAttribute *iface,
207 DOMNodeType* domNodeType )
209 domattr *This = impl_from_IXMLDOMAttribute( iface );
210 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
213 static HRESULT WINAPI domattr_get_parentNode(
214 IXMLDOMAttribute *iface,
215 IXMLDOMNode** parent )
217 domattr *This = impl_from_IXMLDOMAttribute( iface );
218 return IXMLDOMNode_get_parentNode( This->node, parent );
221 static HRESULT WINAPI domattr_get_childNodes(
222 IXMLDOMAttribute *iface,
223 IXMLDOMNodeList** outList)
225 domattr *This = impl_from_IXMLDOMAttribute( iface );
226 return IXMLDOMNode_get_childNodes( This->node, outList );
229 static HRESULT WINAPI domattr_get_firstChild(
230 IXMLDOMAttribute *iface,
231 IXMLDOMNode** domNode)
233 domattr *This = impl_from_IXMLDOMAttribute( iface );
234 return IXMLDOMNode_get_firstChild( This->node, domNode );
237 static HRESULT WINAPI domattr_get_lastChild(
238 IXMLDOMAttribute *iface,
239 IXMLDOMNode** domNode)
241 domattr *This = impl_from_IXMLDOMAttribute( iface );
242 return IXMLDOMNode_get_lastChild( This->node, domNode );
245 static HRESULT WINAPI domattr_get_previousSibling(
246 IXMLDOMAttribute *iface,
247 IXMLDOMNode** domNode)
249 domattr *This = impl_from_IXMLDOMAttribute( iface );
250 return IXMLDOMNode_get_previousSibling( This->node, domNode );
253 static HRESULT WINAPI domattr_get_nextSibling(
254 IXMLDOMAttribute *iface,
255 IXMLDOMNode** domNode)
257 domattr *This = impl_from_IXMLDOMAttribute( iface );
258 return IXMLDOMNode_get_nextSibling( This->node, domNode );
261 static HRESULT WINAPI domattr_get_attributes(
262 IXMLDOMAttribute *iface,
263 IXMLDOMNamedNodeMap** attributeMap)
265 domattr *This = impl_from_IXMLDOMAttribute( iface );
266 return IXMLDOMNode_get_attributes( This->node, attributeMap );
269 static HRESULT WINAPI domattr_insertBefore(
270 IXMLDOMAttribute *iface,
271 IXMLDOMNode* newNode, VARIANT var1,
272 IXMLDOMNode** outOldNode)
274 domattr *This = impl_from_IXMLDOMAttribute( iface );
275 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
278 static HRESULT WINAPI domattr_replaceChild(
279 IXMLDOMAttribute *iface,
280 IXMLDOMNode* newNode,
281 IXMLDOMNode* oldNode,
282 IXMLDOMNode** outOldNode)
284 domattr *This = impl_from_IXMLDOMAttribute( iface );
285 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
288 static HRESULT WINAPI domattr_removeChild(
289 IXMLDOMAttribute *iface,
290 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
292 domattr *This = impl_from_IXMLDOMAttribute( iface );
293 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
296 static HRESULT WINAPI domattr_appendChild(
297 IXMLDOMAttribute *iface,
298 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
300 domattr *This = impl_from_IXMLDOMAttribute( iface );
301 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
304 static HRESULT WINAPI domattr_hasChildNodes(
305 IXMLDOMAttribute *iface,
306 VARIANT_BOOL* pbool)
308 domattr *This = impl_from_IXMLDOMAttribute( iface );
309 return IXMLDOMNode_hasChildNodes( This->node, pbool );
312 static HRESULT WINAPI domattr_get_ownerDocument(
313 IXMLDOMAttribute *iface,
314 IXMLDOMDocument** domDocument)
316 domattr *This = impl_from_IXMLDOMAttribute( iface );
317 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
320 static HRESULT WINAPI domattr_cloneNode(
321 IXMLDOMAttribute *iface,
322 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
324 domattr *This = impl_from_IXMLDOMAttribute( iface );
325 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
328 static HRESULT WINAPI domattr_get_nodeTypeString(
329 IXMLDOMAttribute *iface,
330 BSTR* p)
332 domattr *This = impl_from_IXMLDOMAttribute( iface );
333 return IXMLDOMNode_get_nodeTypeString( This->node, p );
336 static HRESULT WINAPI domattr_get_text(
337 IXMLDOMAttribute *iface,
338 BSTR* p)
340 domattr *This = impl_from_IXMLDOMAttribute( iface );
341 return IXMLDOMNode_get_text( This->node, p );
344 static HRESULT WINAPI domattr_put_text(
345 IXMLDOMAttribute *iface,
346 BSTR p)
348 domattr *This = impl_from_IXMLDOMAttribute( iface );
349 return IXMLDOMNode_put_text( This->node, p );
352 static HRESULT WINAPI domattr_get_specified(
353 IXMLDOMAttribute *iface,
354 VARIANT_BOOL* pbool)
356 domattr *This = impl_from_IXMLDOMAttribute( iface );
357 return IXMLDOMNode_get_specified( This->node, pbool );
360 static HRESULT WINAPI domattr_get_definition(
361 IXMLDOMAttribute *iface,
362 IXMLDOMNode** domNode)
364 domattr *This = impl_from_IXMLDOMAttribute( iface );
365 return IXMLDOMNode_get_definition( This->node, domNode );
368 static HRESULT WINAPI domattr_get_nodeTypedValue(
369 IXMLDOMAttribute *iface,
370 VARIANT* var1)
372 domattr *This = impl_from_IXMLDOMAttribute( iface );
373 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
376 static HRESULT WINAPI domattr_put_nodeTypedValue(
377 IXMLDOMAttribute *iface,
378 VARIANT var1)
380 domattr *This = impl_from_IXMLDOMAttribute( iface );
381 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
384 static HRESULT WINAPI domattr_get_dataType(
385 IXMLDOMAttribute *iface,
386 VARIANT* var1)
388 domattr *This = impl_from_IXMLDOMAttribute( iface );
389 return IXMLDOMNode_get_dataType( This->node, var1 );
392 static HRESULT WINAPI domattr_put_dataType(
393 IXMLDOMAttribute *iface,
394 BSTR p)
396 domattr *This = impl_from_IXMLDOMAttribute( iface );
397 return IXMLDOMNode_put_dataType( This->node, p );
400 static HRESULT WINAPI domattr_get_xml(
401 IXMLDOMAttribute *iface,
402 BSTR* p)
404 domattr *This = impl_from_IXMLDOMAttribute( iface );
405 return IXMLDOMNode_get_xml( This->node, p );
408 static HRESULT WINAPI domattr_transformNode(
409 IXMLDOMAttribute *iface,
410 IXMLDOMNode* domNode, BSTR* p)
412 domattr *This = impl_from_IXMLDOMAttribute( iface );
413 return IXMLDOMNode_transformNode( This->node, domNode, p );
416 static HRESULT WINAPI domattr_selectNodes(
417 IXMLDOMAttribute *iface,
418 BSTR p, IXMLDOMNodeList** outList)
420 domattr *This = impl_from_IXMLDOMAttribute( iface );
421 return IXMLDOMNode_selectNodes( This->node, p, outList );
424 static HRESULT WINAPI domattr_selectSingleNode(
425 IXMLDOMAttribute *iface,
426 BSTR p, IXMLDOMNode** outNode)
428 domattr *This = impl_from_IXMLDOMAttribute( iface );
429 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
432 static HRESULT WINAPI domattr_get_parsed(
433 IXMLDOMAttribute *iface,
434 VARIANT_BOOL* pbool)
436 domattr *This = impl_from_IXMLDOMAttribute( iface );
437 return IXMLDOMNode_get_parsed( This->node, pbool );
440 static HRESULT WINAPI domattr_get_namespaceURI(
441 IXMLDOMAttribute *iface,
442 BSTR* p)
444 domattr *This = impl_from_IXMLDOMAttribute( iface );
445 return IXMLDOMNode_get_namespaceURI( This->node, p );
448 static HRESULT WINAPI domattr_get_prefix(
449 IXMLDOMAttribute *iface,
450 BSTR* p)
452 domattr *This = impl_from_IXMLDOMAttribute( iface );
453 return IXMLDOMNode_get_prefix( This->node, p );
456 static HRESULT WINAPI domattr_get_baseName(
457 IXMLDOMAttribute *iface,
458 BSTR* p)
460 domattr *This = impl_from_IXMLDOMAttribute( iface );
461 return IXMLDOMNode_get_baseName( This->node, p );
464 static HRESULT WINAPI domattr_transformNodeToObject(
465 IXMLDOMAttribute *iface,
466 IXMLDOMNode* domNode, VARIANT var1)
468 domattr *This = impl_from_IXMLDOMAttribute( iface );
469 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
472 static HRESULT WINAPI domattr_get_name(
473 IXMLDOMAttribute *iface,
474 BSTR *p)
476 /* name property returns the same value as nodeName */
477 domattr *This = impl_from_IXMLDOMAttribute( iface );
478 return IXMLDOMNode_get_nodeName( This->node, p );
481 static HRESULT WINAPI domattr_get_value(
482 IXMLDOMAttribute *iface,
483 VARIANT *var1)
485 FIXME("\n");
486 return E_NOTIMPL;
489 static HRESULT WINAPI domattr_put_value(
490 IXMLDOMAttribute *iface,
491 VARIANT var1)
493 FIXME("\n");
494 return E_NOTIMPL;
497 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
499 domattr_QueryInterface,
500 domattr_AddRef,
501 domattr_Release,
502 domattr_GetTypeInfoCount,
503 domattr_GetTypeInfo,
504 domattr_GetIDsOfNames,
505 domattr_Invoke,
506 domattr_get_nodeName,
507 domattr_get_nodeValue,
508 domattr_put_nodeValue,
509 domattr_get_nodeType,
510 domattr_get_parentNode,
511 domattr_get_childNodes,
512 domattr_get_firstChild,
513 domattr_get_lastChild,
514 domattr_get_previousSibling,
515 domattr_get_nextSibling,
516 domattr_get_attributes,
517 domattr_insertBefore,
518 domattr_replaceChild,
519 domattr_removeChild,
520 domattr_appendChild,
521 domattr_hasChildNodes,
522 domattr_get_ownerDocument,
523 domattr_cloneNode,
524 domattr_get_nodeTypeString,
525 domattr_get_text,
526 domattr_put_text,
527 domattr_get_specified,
528 domattr_get_definition,
529 domattr_get_nodeTypedValue,
530 domattr_put_nodeTypedValue,
531 domattr_get_dataType,
532 domattr_put_dataType,
533 domattr_get_xml,
534 domattr_transformNode,
535 domattr_selectNodes,
536 domattr_selectSingleNode,
537 domattr_get_parsed,
538 domattr_get_namespaceURI,
539 domattr_get_prefix,
540 domattr_get_baseName,
541 domattr_transformNodeToObject,
542 domattr_get_name,
543 domattr_get_value,
544 domattr_put_value
547 IUnknown* create_attribute( xmlNodePtr attribute )
549 domattr *This;
550 HRESULT hr;
552 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
553 if ( !This )
554 return NULL;
556 This->lpVtbl = &domattr_vtbl;
557 This->ref = 1;
559 This->node_unk = create_basic_node( attribute, (IUnknown*)&This->lpVtbl );
560 if(!This->node_unk)
562 HeapFree(GetProcessHeap(), 0, This);
563 return NULL;
566 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
567 if(FAILED(hr))
569 IUnknown_Release(This->node_unk);
570 HeapFree( GetProcessHeap(), 0, This );
571 return NULL;
573 /* The ref on This->node is actually looped back into this object, so release it */
574 IXMLDOMNode_Release(This->node);
576 return (IUnknown*) &This->lpVtbl;
579 #endif