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
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
40 typedef struct _domfrag
43 IXMLDOMDocumentFragment IXMLDOMDocumentFragment_iface;
47 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
49 return CONTAINING_RECORD(iface, domfrag, IXMLDOMDocumentFragment_iface);
52 static HRESULT WINAPI domfrag_QueryInterface(
53 IXMLDOMDocumentFragment *iface,
57 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
58 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
60 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
61 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
81 static ULONG WINAPI domfrag_AddRef(
82 IXMLDOMDocumentFragment *iface )
84 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
85 return InterlockedIncrement( &This->ref );
88 static ULONG WINAPI domfrag_Release(
89 IXMLDOMDocumentFragment *iface )
91 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
94 ref = InterlockedDecrement( &This->ref );
97 destroy_xmlnode(&This->node);
104 static HRESULT WINAPI domfrag_GetTypeInfoCount(
105 IXMLDOMDocumentFragment *iface,
108 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
117 static HRESULT WINAPI domfrag_GetTypeInfo(
118 IXMLDOMDocumentFragment *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, ppTInfo);
132 static HRESULT WINAPI domfrag_GetIDsOfNames(
133 IXMLDOMDocumentFragment *iface,
134 REFIID riid, LPOLESTR* rgszNames,
135 UINT cNames, LCID lcid, DISPID* rgDispId )
137 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
144 if(!rgszNames || cNames == 0 || !rgDispId)
147 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
157 static HRESULT WINAPI domfrag_Invoke(
158 IXMLDOMDocumentFragment *iface,
159 DISPID dispIdMember, REFIID riid, LCID lcid,
160 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
161 EXCEPINFO* pExcepInfo, UINT* puArgErr )
163 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
167 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
168 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
170 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
173 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMDocumentFragment_iface, dispIdMember,
174 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
181 static HRESULT WINAPI domfrag_get_nodeName(
182 IXMLDOMDocumentFragment *iface,
185 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
187 static const WCHAR document_fragmentW[] =
188 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
190 TRACE("(%p)->(%p)\n", This, p);
192 return return_bstr(document_fragmentW, p);
195 static HRESULT WINAPI domfrag_get_nodeValue(
196 IXMLDOMDocumentFragment *iface,
199 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
201 FIXME("(%p)->(%p)\n", This, value);
206 V_VT(value) = VT_NULL;
210 static HRESULT WINAPI domfrag_put_nodeValue(
211 IXMLDOMDocumentFragment *iface,
214 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
215 TRACE("(%p)->(v%d)\n", This, V_VT(&value));
219 static HRESULT WINAPI domfrag_get_nodeType(
220 IXMLDOMDocumentFragment *iface,
221 DOMNodeType* domNodeType )
223 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
225 TRACE("(%p)->(%p)\n", This, domNodeType);
227 *domNodeType = NODE_DOCUMENT_FRAGMENT;
231 static HRESULT WINAPI domfrag_get_parentNode(
232 IXMLDOMDocumentFragment *iface,
233 IXMLDOMNode** parent )
235 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
237 TRACE("(%p)->(%p)\n", This, parent);
239 return node_get_parent(&This->node, parent);
242 static HRESULT WINAPI domfrag_get_childNodes(
243 IXMLDOMDocumentFragment *iface,
244 IXMLDOMNodeList** outList)
246 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
248 TRACE("(%p)->(%p)\n", This, outList);
250 return node_get_child_nodes(&This->node, outList);
253 static HRESULT WINAPI domfrag_get_firstChild(
254 IXMLDOMDocumentFragment *iface,
255 IXMLDOMNode** domNode)
257 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
259 TRACE("(%p)->(%p)\n", This, domNode);
261 return node_get_first_child(&This->node, domNode);
264 static HRESULT WINAPI domfrag_get_lastChild(
265 IXMLDOMDocumentFragment *iface,
266 IXMLDOMNode** domNode)
268 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
270 TRACE("(%p)->(%p)\n", This, domNode);
272 return node_get_last_child(&This->node, domNode);
275 static HRESULT WINAPI domfrag_get_previousSibling(
276 IXMLDOMDocumentFragment *iface,
277 IXMLDOMNode** domNode)
279 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
281 TRACE("(%p)->(%p)\n", This, domNode);
283 return return_null_node(domNode);
286 static HRESULT WINAPI domfrag_get_nextSibling(
287 IXMLDOMDocumentFragment *iface,
288 IXMLDOMNode** domNode)
290 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
292 TRACE("(%p)->(%p)\n", This, domNode);
294 return return_null_node(domNode);
297 static HRESULT WINAPI domfrag_get_attributes(
298 IXMLDOMDocumentFragment *iface,
299 IXMLDOMNamedNodeMap** attributeMap)
301 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
303 TRACE("(%p)->(%p)\n", This, attributeMap);
305 return return_null_ptr((void**)attributeMap);
308 static HRESULT WINAPI domfrag_insertBefore(
309 IXMLDOMDocumentFragment *iface,
310 IXMLDOMNode* newNode, VARIANT refChild,
311 IXMLDOMNode** outOldNode)
313 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
315 TRACE("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode);
318 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
321 static HRESULT WINAPI domfrag_replaceChild(
322 IXMLDOMDocumentFragment *iface,
323 IXMLDOMNode* newNode,
324 IXMLDOMNode* oldNode,
325 IXMLDOMNode** outOldNode)
327 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
329 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
332 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
335 static HRESULT WINAPI domfrag_removeChild(
336 IXMLDOMDocumentFragment *iface,
337 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
339 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
340 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
343 static HRESULT WINAPI domfrag_appendChild(
344 IXMLDOMDocumentFragment *iface,
345 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
347 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
348 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
351 static HRESULT WINAPI domfrag_hasChildNodes(
352 IXMLDOMDocumentFragment *iface,
355 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
356 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
359 static HRESULT WINAPI domfrag_get_ownerDocument(
360 IXMLDOMDocumentFragment *iface,
361 IXMLDOMDocument** domDocument)
363 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
364 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
367 static HRESULT WINAPI domfrag_cloneNode(
368 IXMLDOMDocumentFragment *iface,
369 VARIANT_BOOL deep, IXMLDOMNode** outNode)
371 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
372 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
373 return node_clone( &This->node, deep, outNode );
376 static HRESULT WINAPI domfrag_get_nodeTypeString(
377 IXMLDOMDocumentFragment *iface,
380 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
381 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
383 TRACE("(%p)->(%p)\n", This, p);
385 return return_bstr(documentfragmentW, p);
388 static HRESULT WINAPI domfrag_get_text(
389 IXMLDOMDocumentFragment *iface,
392 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
393 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
396 static HRESULT WINAPI domfrag_put_text(
397 IXMLDOMDocumentFragment *iface,
400 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
401 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
402 return node_put_text( &This->node, p );
405 static HRESULT WINAPI domfrag_get_specified(
406 IXMLDOMDocumentFragment *iface,
407 VARIANT_BOOL* isSpecified)
409 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
410 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
411 *isSpecified = VARIANT_TRUE;
415 static HRESULT WINAPI domfrag_get_definition(
416 IXMLDOMDocumentFragment *iface,
417 IXMLDOMNode** definitionNode)
419 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
420 FIXME("(%p)->(%p)\n", This, definitionNode);
424 static HRESULT WINAPI domfrag_get_nodeTypedValue(
425 IXMLDOMDocumentFragment *iface,
428 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
429 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
432 static HRESULT WINAPI domfrag_put_nodeTypedValue(
433 IXMLDOMDocumentFragment *iface,
436 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
437 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
440 static HRESULT WINAPI domfrag_get_dataType(
441 IXMLDOMDocumentFragment *iface,
444 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
445 TRACE("(%p)->(%p)\n", This, typename);
446 return return_null_var( typename );
449 static HRESULT WINAPI domfrag_put_dataType(
450 IXMLDOMDocumentFragment *iface,
453 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
454 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
457 static HRESULT WINAPI domfrag_get_xml(
458 IXMLDOMDocumentFragment *iface,
461 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
463 TRACE("(%p)->(%p)\n", This, p);
465 return node_get_xml(&This->node, FALSE, FALSE, p);
468 static HRESULT WINAPI domfrag_transformNode(
469 IXMLDOMDocumentFragment *iface,
470 IXMLDOMNode* domNode, BSTR* p)
472 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
473 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
476 static HRESULT WINAPI domfrag_selectNodes(
477 IXMLDOMDocumentFragment *iface,
478 BSTR p, IXMLDOMNodeList** outList)
480 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
481 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
484 static HRESULT WINAPI domfrag_selectSingleNode(
485 IXMLDOMDocumentFragment *iface,
486 BSTR p, IXMLDOMNode** outNode)
488 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
489 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
492 static HRESULT WINAPI domfrag_get_parsed(
493 IXMLDOMDocumentFragment *iface,
494 VARIANT_BOOL* isParsed)
496 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
497 FIXME("(%p)->(%p) stub!\n", This, isParsed);
498 *isParsed = VARIANT_TRUE;
502 static HRESULT WINAPI domfrag_get_namespaceURI(
503 IXMLDOMDocumentFragment *iface,
506 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
507 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
510 static HRESULT WINAPI domfrag_get_prefix(
511 IXMLDOMDocumentFragment *iface,
514 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
515 TRACE("(%p)->(%p)\n", This, prefix);
516 return return_null_bstr( prefix );
519 static HRESULT WINAPI domfrag_get_baseName(
520 IXMLDOMDocumentFragment *iface,
523 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
524 FIXME("(%p)->(%p): needs test\n", This, name);
525 return return_null_bstr( name );
528 static HRESULT WINAPI domfrag_transformNodeToObject(
529 IXMLDOMDocumentFragment *iface,
530 IXMLDOMNode* domNode, VARIANT var1)
532 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
533 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
536 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
538 domfrag_QueryInterface,
541 domfrag_GetTypeInfoCount,
543 domfrag_GetIDsOfNames,
545 domfrag_get_nodeName,
546 domfrag_get_nodeValue,
547 domfrag_put_nodeValue,
548 domfrag_get_nodeType,
549 domfrag_get_parentNode,
550 domfrag_get_childNodes,
551 domfrag_get_firstChild,
552 domfrag_get_lastChild,
553 domfrag_get_previousSibling,
554 domfrag_get_nextSibling,
555 domfrag_get_attributes,
556 domfrag_insertBefore,
557 domfrag_replaceChild,
560 domfrag_hasChildNodes,
561 domfrag_get_ownerDocument,
563 domfrag_get_nodeTypeString,
566 domfrag_get_specified,
567 domfrag_get_definition,
568 domfrag_get_nodeTypedValue,
569 domfrag_put_nodeTypedValue,
570 domfrag_get_dataType,
571 domfrag_put_dataType,
573 domfrag_transformNode,
575 domfrag_selectSingleNode,
577 domfrag_get_namespaceURI,
579 domfrag_get_baseName,
580 domfrag_transformNodeToObject
583 IUnknown* create_doc_fragment( xmlNodePtr fragment )
587 This = heap_alloc( sizeof *This );
591 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
594 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, NULL);
596 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;