winmm/tests: Fix a mismatched failure message.
[wine/hacks.git] / dlls / msxml3 / docfrag.c
blobf922faaa229c0a8d9af10621ad652ad39044a829
1 /*
2 * DOM Document Fragment implementation
4 * Copyright 2007 Alistair Leslie-Hughes
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 _domfrag
42 const struct IXMLDOMDocumentFragmentVtbl *lpVtbl;
43 LONG ref;
44 IUnknown *node_unk;
45 IXMLDOMNode *node;
46 } domfrag;
48 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
50 return (domfrag *)((char*)iface - FIELD_OFFSET(domfrag, lpVtbl));
53 static HRESULT WINAPI domfrag_QueryInterface(
54 IXMLDOMDocumentFragment *iface,
55 REFIID riid,
56 void** ppvObject )
58 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
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 IXMLDOMDocumentFragment_AddRef( iface );
79 return S_OK;
82 static ULONG WINAPI domfrag_AddRef(
83 IXMLDOMDocumentFragment *iface )
85 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI domfrag_Release(
90 IXMLDOMDocumentFragment *iface )
92 domfrag *This = impl_from_IXMLDOMDocumentFragment( 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 domfrag_GetTypeInfoCount(
106 IXMLDOMDocumentFragment *iface,
107 UINT* pctinfo )
109 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
111 TRACE("(%p)->(%p)\n", This, pctinfo);
113 *pctinfo = 1;
115 return S_OK;
118 static HRESULT WINAPI domfrag_GetTypeInfo(
119 IXMLDOMDocumentFragment *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
123 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
124 HRESULT hr;
126 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
128 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, ppTInfo);
130 return hr;
133 static HRESULT WINAPI domfrag_GetIDsOfNames(
134 IXMLDOMDocumentFragment *iface,
135 REFIID riid, LPOLESTR* rgszNames,
136 UINT cNames, LCID lcid, DISPID* rgDispId )
138 domfrag *This = impl_from_IXMLDOMDocumentFragment( 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(IXMLDOMDocumentFragment_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 domfrag_Invoke(
159 IXMLDOMDocumentFragment *iface,
160 DISPID dispIdMember, REFIID riid, LCID lcid,
161 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
162 EXCEPINFO* pExcepInfo, UINT* puArgErr )
164 domfrag *This = impl_from_IXMLDOMDocumentFragment( 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(IXMLDOMDocumentFragment_tid, &typeinfo);
172 if(SUCCEEDED(hr))
174 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
175 pVarResult, pExcepInfo, puArgErr);
176 ITypeInfo_Release(typeinfo);
179 return hr;
182 static HRESULT WINAPI domfrag_get_nodeName(
183 IXMLDOMDocumentFragment *iface,
184 BSTR* p )
186 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
187 return IXMLDOMNode_get_nodeName( This->node, p );
190 static HRESULT WINAPI domfrag_get_nodeValue(
191 IXMLDOMDocumentFragment *iface,
192 VARIANT* var1 )
194 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
195 return IXMLDOMNode_get_nodeValue( This->node, var1 );
198 static HRESULT WINAPI domfrag_put_nodeValue(
199 IXMLDOMDocumentFragment *iface,
200 VARIANT var1 )
202 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
203 return IXMLDOMNode_put_nodeValue( This->node, var1 );
206 static HRESULT WINAPI domfrag_get_nodeType(
207 IXMLDOMDocumentFragment *iface,
208 DOMNodeType* domNodeType )
210 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
211 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
214 static HRESULT WINAPI domfrag_get_parentNode(
215 IXMLDOMDocumentFragment *iface,
216 IXMLDOMNode** parent )
218 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
219 return IXMLDOMNode_get_parentNode( This->node, parent );
222 static HRESULT WINAPI domfrag_get_childNodes(
223 IXMLDOMDocumentFragment *iface,
224 IXMLDOMNodeList** outList)
226 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
227 return IXMLDOMNode_get_childNodes( This->node, outList );
230 static HRESULT WINAPI domfrag_get_firstChild(
231 IXMLDOMDocumentFragment *iface,
232 IXMLDOMNode** domNode)
234 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
235 return IXMLDOMNode_get_firstChild( This->node, domNode );
238 static HRESULT WINAPI domfrag_get_lastChild(
239 IXMLDOMDocumentFragment *iface,
240 IXMLDOMNode** domNode)
242 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
243 return IXMLDOMNode_get_lastChild( This->node, domNode );
246 static HRESULT WINAPI domfrag_get_previousSibling(
247 IXMLDOMDocumentFragment *iface,
248 IXMLDOMNode** domNode)
250 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
251 return IXMLDOMNode_get_previousSibling( This->node, domNode );
254 static HRESULT WINAPI domfrag_get_nextSibling(
255 IXMLDOMDocumentFragment *iface,
256 IXMLDOMNode** domNode)
258 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
259 return IXMLDOMNode_get_nextSibling( This->node, domNode );
262 static HRESULT WINAPI domfrag_get_attributes(
263 IXMLDOMDocumentFragment *iface,
264 IXMLDOMNamedNodeMap** attributeMap)
266 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
267 return IXMLDOMNode_get_attributes( This->node, attributeMap );
270 static HRESULT WINAPI domfrag_insertBefore(
271 IXMLDOMDocumentFragment *iface,
272 IXMLDOMNode* newNode, VARIANT var1,
273 IXMLDOMNode** outOldNode)
275 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
276 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
279 static HRESULT WINAPI domfrag_replaceChild(
280 IXMLDOMDocumentFragment *iface,
281 IXMLDOMNode* newNode,
282 IXMLDOMNode* oldNode,
283 IXMLDOMNode** outOldNode)
285 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
286 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
289 static HRESULT WINAPI domfrag_removeChild(
290 IXMLDOMDocumentFragment *iface,
291 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
293 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
294 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
297 static HRESULT WINAPI domfrag_appendChild(
298 IXMLDOMDocumentFragment *iface,
299 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
301 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
302 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
305 static HRESULT WINAPI domfrag_hasChildNodes(
306 IXMLDOMDocumentFragment *iface,
307 VARIANT_BOOL* pbool)
309 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
310 return IXMLDOMNode_hasChildNodes( This->node, pbool );
313 static HRESULT WINAPI domfrag_get_ownerDocument(
314 IXMLDOMDocumentFragment *iface,
315 IXMLDOMDocument** domDocument)
317 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
318 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
321 static HRESULT WINAPI domfrag_cloneNode(
322 IXMLDOMDocumentFragment *iface,
323 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
325 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
326 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
329 static HRESULT WINAPI domfrag_get_nodeTypeString(
330 IXMLDOMDocumentFragment *iface,
331 BSTR* p)
333 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
334 return IXMLDOMNode_get_nodeTypeString( This->node, p );
337 static HRESULT WINAPI domfrag_get_text(
338 IXMLDOMDocumentFragment *iface,
339 BSTR* p)
341 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
342 return IXMLDOMNode_get_text( This->node, p );
345 static HRESULT WINAPI domfrag_put_text(
346 IXMLDOMDocumentFragment *iface,
347 BSTR p)
349 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
350 return IXMLDOMNode_put_text( This->node, p );
353 static HRESULT WINAPI domfrag_get_specified(
354 IXMLDOMDocumentFragment *iface,
355 VARIANT_BOOL* pbool)
357 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
358 return IXMLDOMNode_get_specified( This->node, pbool );
361 static HRESULT WINAPI domfrag_get_definition(
362 IXMLDOMDocumentFragment *iface,
363 IXMLDOMNode** domNode)
365 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
366 return IXMLDOMNode_get_definition( This->node, domNode );
369 static HRESULT WINAPI domfrag_get_nodeTypedValue(
370 IXMLDOMDocumentFragment *iface,
371 VARIANT* var1)
373 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
374 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
377 static HRESULT WINAPI domfrag_put_nodeTypedValue(
378 IXMLDOMDocumentFragment *iface,
379 VARIANT var1)
381 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
382 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
385 static HRESULT WINAPI domfrag_get_dataType(
386 IXMLDOMDocumentFragment *iface,
387 VARIANT* var1)
389 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
390 return IXMLDOMNode_get_dataType( This->node, var1 );
393 static HRESULT WINAPI domfrag_put_dataType(
394 IXMLDOMDocumentFragment *iface,
395 BSTR p)
397 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
398 return IXMLDOMNode_put_dataType( This->node, p );
401 static HRESULT WINAPI domfrag_get_xml(
402 IXMLDOMDocumentFragment *iface,
403 BSTR* p)
405 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
406 return IXMLDOMNode_get_xml( This->node, p );
409 static HRESULT WINAPI domfrag_transformNode(
410 IXMLDOMDocumentFragment *iface,
411 IXMLDOMNode* domNode, BSTR* p)
413 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
414 return IXMLDOMNode_transformNode( This->node, domNode, p );
417 static HRESULT WINAPI domfrag_selectNodes(
418 IXMLDOMDocumentFragment *iface,
419 BSTR p, IXMLDOMNodeList** outList)
421 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
422 return IXMLDOMNode_selectNodes( This->node, p, outList );
425 static HRESULT WINAPI domfrag_selectSingleNode(
426 IXMLDOMDocumentFragment *iface,
427 BSTR p, IXMLDOMNode** outNode)
429 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
430 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
433 static HRESULT WINAPI domfrag_get_parsed(
434 IXMLDOMDocumentFragment *iface,
435 VARIANT_BOOL* pbool)
437 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
438 return IXMLDOMNode_get_parsed( This->node, pbool );
441 static HRESULT WINAPI domfrag_get_namespaceURI(
442 IXMLDOMDocumentFragment *iface,
443 BSTR* p)
445 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
446 return IXMLDOMNode_get_namespaceURI( This->node, p );
449 static HRESULT WINAPI domfrag_get_prefix(
450 IXMLDOMDocumentFragment *iface,
451 BSTR* p)
453 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
454 return IXMLDOMNode_get_prefix( This->node, p );
457 static HRESULT WINAPI domfrag_get_baseName(
458 IXMLDOMDocumentFragment *iface,
459 BSTR* p)
461 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
462 return IXMLDOMNode_get_baseName( This->node, p );
465 static HRESULT WINAPI domfrag_transformNodeToObject(
466 IXMLDOMDocumentFragment *iface,
467 IXMLDOMNode* domNode, VARIANT var1)
469 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
470 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
473 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
475 domfrag_QueryInterface,
476 domfrag_AddRef,
477 domfrag_Release,
478 domfrag_GetTypeInfoCount,
479 domfrag_GetTypeInfo,
480 domfrag_GetIDsOfNames,
481 domfrag_Invoke,
482 domfrag_get_nodeName,
483 domfrag_get_nodeValue,
484 domfrag_put_nodeValue,
485 domfrag_get_nodeType,
486 domfrag_get_parentNode,
487 domfrag_get_childNodes,
488 domfrag_get_firstChild,
489 domfrag_get_lastChild,
490 domfrag_get_previousSibling,
491 domfrag_get_nextSibling,
492 domfrag_get_attributes,
493 domfrag_insertBefore,
494 domfrag_replaceChild,
495 domfrag_removeChild,
496 domfrag_appendChild,
497 domfrag_hasChildNodes,
498 domfrag_get_ownerDocument,
499 domfrag_cloneNode,
500 domfrag_get_nodeTypeString,
501 domfrag_get_text,
502 domfrag_put_text,
503 domfrag_get_specified,
504 domfrag_get_definition,
505 domfrag_get_nodeTypedValue,
506 domfrag_put_nodeTypedValue,
507 domfrag_get_dataType,
508 domfrag_put_dataType,
509 domfrag_get_xml,
510 domfrag_transformNode,
511 domfrag_selectNodes,
512 domfrag_selectSingleNode,
513 domfrag_get_parsed,
514 domfrag_get_namespaceURI,
515 domfrag_get_prefix,
516 domfrag_get_baseName,
517 domfrag_transformNodeToObject
520 IUnknown* create_doc_fragment( xmlNodePtr fragment )
522 domfrag *This;
523 HRESULT hr;
525 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
526 if ( !This )
527 return NULL;
529 This->lpVtbl = &domfrag_vtbl;
530 This->ref = 1;
532 This->node_unk = create_basic_node( fragment, (IUnknown*)&This->lpVtbl );
533 if(!This->node_unk)
535 HeapFree(GetProcessHeap(), 0, This);
536 return NULL;
539 hr = IUnknown_QueryInterface(This->node_unk, &IID_IXMLDOMNode, (LPVOID*)&This->node);
540 if(FAILED(hr))
542 IUnknown_Release(This->node_unk);
543 HeapFree( GetProcessHeap(), 0, This );
544 return NULL;
546 /* The ref on This->node is actually looped back into this object, so release it */
547 IXMLDOMNode_Release(This->node);
549 return (IUnknown*) &This->lpVtbl;
552 #endif