d3dxof: Turn some TRACEs into WARNs in case of parsing error.
[wine/multimedia.git] / dlls / msxml3 / attribute.c
blobd78fa479f40ae897f53f5b9299fa62e6dfdb1089
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 xmlnode node;
43 const struct IXMLDOMAttributeVtbl *lpVtbl;
44 LONG ref;
45 } domattr;
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,
54 REFIID riid,
55 void** ppvObject )
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 ) )
64 *ppvObject = iface;
66 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
68 *ppvObject = IXMLDOMNode_from_impl(&This->node);
70 else
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
73 return E_NOINTERFACE;
76 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
77 return S_OK;
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 );
91 ULONG ref;
93 ref = InterlockedDecrement( &This->ref );
94 if ( ref == 0 )
96 destroy_xmlnode(&This->node);
97 heap_free( This );
100 return ref;
103 static HRESULT WINAPI domattr_GetTypeInfoCount(
104 IXMLDOMAttribute *iface,
105 UINT* pctinfo )
107 domattr *This = impl_from_IXMLDOMAttribute( iface );
109 TRACE("(%p)->(%p)\n", This, pctinfo);
111 *pctinfo = 1;
113 return S_OK;
116 static HRESULT WINAPI domattr_GetTypeInfo(
117 IXMLDOMAttribute *iface,
118 UINT iTInfo, LCID lcid,
119 ITypeInfo** ppTInfo )
121 domattr *This = impl_from_IXMLDOMAttribute( iface );
122 HRESULT hr;
124 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
126 hr = get_typeinfo(IXMLDOMAttribute_tid, ppTInfo);
128 return hr;
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 );
137 ITypeInfo *typeinfo;
138 HRESULT hr;
140 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
141 lcid, rgDispId);
143 if(!rgszNames || cNames == 0 || !rgDispId)
144 return E_INVALIDARG;
146 hr = get_typeinfo(IXMLDOMAttribute_tid, &typeinfo);
147 if(SUCCEEDED(hr))
149 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
150 ITypeInfo_Release(typeinfo);
153 return hr;
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 );
163 ITypeInfo *typeinfo;
164 HRESULT hr;
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);
170 if(SUCCEEDED(hr))
172 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
173 pVarResult, pExcepInfo, puArgErr);
174 ITypeInfo_Release(typeinfo);
176 return hr;
179 static HRESULT WINAPI domattr_get_nodeName(
180 IXMLDOMAttribute *iface,
181 BSTR* p )
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,
189 VARIANT* var1 )
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,
197 VARIANT var1 )
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 TRACE("(%p)->(%p)\n", This, parent);
217 if (!parent) return E_INVALIDARG;
218 *parent = NULL;
219 return S_FALSE;
222 static HRESULT WINAPI domattr_get_childNodes(
223 IXMLDOMAttribute *iface,
224 IXMLDOMNodeList** outList)
226 domattr *This = impl_from_IXMLDOMAttribute( iface );
227 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), outList );
230 static HRESULT WINAPI domattr_get_firstChild(
231 IXMLDOMAttribute *iface,
232 IXMLDOMNode** domNode)
234 domattr *This = impl_from_IXMLDOMAttribute( iface );
235 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode );
238 static HRESULT WINAPI domattr_get_lastChild(
239 IXMLDOMAttribute *iface,
240 IXMLDOMNode** domNode)
242 domattr *This = impl_from_IXMLDOMAttribute( iface );
243 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode );
246 static HRESULT WINAPI domattr_get_previousSibling(
247 IXMLDOMAttribute *iface,
248 IXMLDOMNode** domNode)
250 domattr *This = impl_from_IXMLDOMAttribute( iface );
251 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), domNode );
254 static HRESULT WINAPI domattr_get_nextSibling(
255 IXMLDOMAttribute *iface,
256 IXMLDOMNode** domNode)
258 domattr *This = impl_from_IXMLDOMAttribute( iface );
259 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), domNode );
262 static HRESULT WINAPI domattr_get_attributes(
263 IXMLDOMAttribute *iface,
264 IXMLDOMNamedNodeMap** attributeMap)
266 domattr *This = impl_from_IXMLDOMAttribute( iface );
267 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
270 static HRESULT WINAPI domattr_insertBefore(
271 IXMLDOMAttribute *iface,
272 IXMLDOMNode* newNode, VARIANT var1,
273 IXMLDOMNode** outOldNode)
275 domattr *This = impl_from_IXMLDOMAttribute( iface );
276 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
279 static HRESULT WINAPI domattr_replaceChild(
280 IXMLDOMAttribute *iface,
281 IXMLDOMNode* newNode,
282 IXMLDOMNode* oldNode,
283 IXMLDOMNode** outOldNode)
285 domattr *This = impl_from_IXMLDOMAttribute( iface );
286 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
289 static HRESULT WINAPI domattr_removeChild(
290 IXMLDOMAttribute *iface,
291 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
293 domattr *This = impl_from_IXMLDOMAttribute( iface );
294 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
297 static HRESULT WINAPI domattr_appendChild(
298 IXMLDOMAttribute *iface,
299 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
301 domattr *This = impl_from_IXMLDOMAttribute( iface );
302 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
305 static HRESULT WINAPI domattr_hasChildNodes(
306 IXMLDOMAttribute *iface,
307 VARIANT_BOOL* pbool)
309 domattr *This = impl_from_IXMLDOMAttribute( iface );
310 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
313 static HRESULT WINAPI domattr_get_ownerDocument(
314 IXMLDOMAttribute *iface,
315 IXMLDOMDocument** domDocument)
317 domattr *This = impl_from_IXMLDOMAttribute( iface );
318 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
321 static HRESULT WINAPI domattr_cloneNode(
322 IXMLDOMAttribute *iface,
323 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
325 domattr *This = impl_from_IXMLDOMAttribute( iface );
326 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
329 static HRESULT WINAPI domattr_get_nodeTypeString(
330 IXMLDOMAttribute *iface,
331 BSTR* p)
333 domattr *This = impl_from_IXMLDOMAttribute( iface );
334 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
337 static HRESULT WINAPI domattr_get_text(
338 IXMLDOMAttribute *iface,
339 BSTR* p)
341 domattr *This = impl_from_IXMLDOMAttribute( iface );
342 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
345 static HRESULT WINAPI domattr_put_text(
346 IXMLDOMAttribute *iface,
347 BSTR p)
349 domattr *This = impl_from_IXMLDOMAttribute( iface );
350 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
353 static HRESULT WINAPI domattr_get_specified(
354 IXMLDOMAttribute *iface,
355 VARIANT_BOOL* pbool)
357 domattr *This = impl_from_IXMLDOMAttribute( iface );
358 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
361 static HRESULT WINAPI domattr_get_definition(
362 IXMLDOMAttribute *iface,
363 IXMLDOMNode** domNode)
365 domattr *This = impl_from_IXMLDOMAttribute( iface );
366 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
369 static HRESULT WINAPI domattr_get_nodeTypedValue(
370 IXMLDOMAttribute *iface,
371 VARIANT* var1)
373 domattr *This = impl_from_IXMLDOMAttribute( iface );
374 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
377 static HRESULT WINAPI domattr_put_nodeTypedValue(
378 IXMLDOMAttribute *iface,
379 VARIANT var1)
381 domattr *This = impl_from_IXMLDOMAttribute( iface );
382 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
385 static HRESULT WINAPI domattr_get_dataType(
386 IXMLDOMAttribute *iface,
387 VARIANT* var1)
389 domattr *This = impl_from_IXMLDOMAttribute( iface );
390 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
393 static HRESULT WINAPI domattr_put_dataType(
394 IXMLDOMAttribute *iface,
395 BSTR p)
397 domattr *This = impl_from_IXMLDOMAttribute( iface );
398 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
401 static HRESULT WINAPI domattr_get_xml(
402 IXMLDOMAttribute *iface,
403 BSTR* p)
405 domattr *This = impl_from_IXMLDOMAttribute( iface );
406 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
409 static HRESULT WINAPI domattr_transformNode(
410 IXMLDOMAttribute *iface,
411 IXMLDOMNode* domNode, BSTR* p)
413 domattr *This = impl_from_IXMLDOMAttribute( iface );
414 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
417 static HRESULT WINAPI domattr_selectNodes(
418 IXMLDOMAttribute *iface,
419 BSTR p, IXMLDOMNodeList** outList)
421 domattr *This = impl_from_IXMLDOMAttribute( iface );
422 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
425 static HRESULT WINAPI domattr_selectSingleNode(
426 IXMLDOMAttribute *iface,
427 BSTR p, IXMLDOMNode** outNode)
429 domattr *This = impl_from_IXMLDOMAttribute( iface );
430 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
433 static HRESULT WINAPI domattr_get_parsed(
434 IXMLDOMAttribute *iface,
435 VARIANT_BOOL* pbool)
437 domattr *This = impl_from_IXMLDOMAttribute( iface );
438 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
441 static HRESULT WINAPI domattr_get_namespaceURI(
442 IXMLDOMAttribute *iface,
443 BSTR* p)
445 domattr *This = impl_from_IXMLDOMAttribute( iface );
446 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
449 static HRESULT WINAPI domattr_get_prefix(
450 IXMLDOMAttribute *iface,
451 BSTR* p)
453 domattr *This = impl_from_IXMLDOMAttribute( iface );
454 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
457 static HRESULT WINAPI domattr_get_baseName(
458 IXMLDOMAttribute *iface,
459 BSTR* p)
461 domattr *This = impl_from_IXMLDOMAttribute( iface );
462 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
465 static HRESULT WINAPI domattr_transformNodeToObject(
466 IXMLDOMAttribute *iface,
467 IXMLDOMNode* domNode, VARIANT var1)
469 domattr *This = impl_from_IXMLDOMAttribute( iface );
470 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
473 static HRESULT WINAPI domattr_get_name(
474 IXMLDOMAttribute *iface,
475 BSTR *p)
477 /* name property returns the same value as nodeName */
478 domattr *This = impl_from_IXMLDOMAttribute( iface );
479 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), p );
482 static HRESULT WINAPI domattr_get_value(
483 IXMLDOMAttribute *iface,
484 VARIANT *var1)
486 domattr *This = impl_from_IXMLDOMAttribute( iface );
487 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
490 static HRESULT WINAPI domattr_put_value(
491 IXMLDOMAttribute *iface,
492 VARIANT var1)
494 domattr *This = impl_from_IXMLDOMAttribute( iface );
495 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), var1 );
498 static const struct IXMLDOMAttributeVtbl domattr_vtbl =
500 domattr_QueryInterface,
501 domattr_AddRef,
502 domattr_Release,
503 domattr_GetTypeInfoCount,
504 domattr_GetTypeInfo,
505 domattr_GetIDsOfNames,
506 domattr_Invoke,
507 domattr_get_nodeName,
508 domattr_get_nodeValue,
509 domattr_put_nodeValue,
510 domattr_get_nodeType,
511 domattr_get_parentNode,
512 domattr_get_childNodes,
513 domattr_get_firstChild,
514 domattr_get_lastChild,
515 domattr_get_previousSibling,
516 domattr_get_nextSibling,
517 domattr_get_attributes,
518 domattr_insertBefore,
519 domattr_replaceChild,
520 domattr_removeChild,
521 domattr_appendChild,
522 domattr_hasChildNodes,
523 domattr_get_ownerDocument,
524 domattr_cloneNode,
525 domattr_get_nodeTypeString,
526 domattr_get_text,
527 domattr_put_text,
528 domattr_get_specified,
529 domattr_get_definition,
530 domattr_get_nodeTypedValue,
531 domattr_put_nodeTypedValue,
532 domattr_get_dataType,
533 domattr_put_dataType,
534 domattr_get_xml,
535 domattr_transformNode,
536 domattr_selectNodes,
537 domattr_selectSingleNode,
538 domattr_get_parsed,
539 domattr_get_namespaceURI,
540 domattr_get_prefix,
541 domattr_get_baseName,
542 domattr_transformNodeToObject,
543 domattr_get_name,
544 domattr_get_value,
545 domattr_put_value
548 IUnknown* create_attribute( xmlNodePtr attribute )
550 domattr *This;
552 This = heap_alloc( sizeof *This );
553 if ( !This )
554 return NULL;
556 This->lpVtbl = &domattr_vtbl;
557 This->ref = 1;
559 init_xmlnode(&This->node, attribute, (IUnknown*)&This->lpVtbl, NULL);
561 return (IUnknown*) &This->lpVtbl;
564 #endif