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( &This->node.IXMLDOMNode_iface, 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( &This->node.IXMLDOMNode_iface, newNode, outNewNode );
351 static HRESULT WINAPI domfrag_hasChildNodes(
352 IXMLDOMDocumentFragment *iface,
355 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
356 return IXMLDOMNode_hasChildNodes( &This->node.IXMLDOMNode_iface, 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( &This->node.IXMLDOMNode_iface, 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( &This->node.IXMLDOMNode_iface, 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 FIXME("(%p)->(%p)\n", This, var1);
430 return return_null_var(var1);
433 static HRESULT WINAPI domfrag_put_nodeTypedValue(
434 IXMLDOMDocumentFragment *iface,
437 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
438 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
442 static HRESULT WINAPI domfrag_get_dataType(
443 IXMLDOMDocumentFragment *iface,
446 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
447 TRACE("(%p)->(%p)\n", This, typename);
448 return return_null_var( typename );
451 static HRESULT WINAPI domfrag_put_dataType(
452 IXMLDOMDocumentFragment *iface,
455 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
457 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
465 static HRESULT WINAPI domfrag_get_xml(
466 IXMLDOMDocumentFragment *iface,
469 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
471 TRACE("(%p)->(%p)\n", This, p);
473 return node_get_xml(&This->node, FALSE, FALSE, p);
476 static HRESULT WINAPI domfrag_transformNode(
477 IXMLDOMDocumentFragment *iface,
478 IXMLDOMNode* domNode, BSTR* p)
480 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
481 return IXMLDOMNode_transformNode( &This->node.IXMLDOMNode_iface, domNode, p );
484 static HRESULT WINAPI domfrag_selectNodes(
485 IXMLDOMDocumentFragment *iface,
486 BSTR p, IXMLDOMNodeList** outList)
488 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
489 return IXMLDOMNode_selectNodes( &This->node.IXMLDOMNode_iface, p, outList );
492 static HRESULT WINAPI domfrag_selectSingleNode(
493 IXMLDOMDocumentFragment *iface,
494 BSTR p, IXMLDOMNode** outNode)
496 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
497 return IXMLDOMNode_selectSingleNode( &This->node.IXMLDOMNode_iface, p, outNode );
500 static HRESULT WINAPI domfrag_get_parsed(
501 IXMLDOMDocumentFragment *iface,
502 VARIANT_BOOL* isParsed)
504 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
505 FIXME("(%p)->(%p) stub!\n", This, isParsed);
506 *isParsed = VARIANT_TRUE;
510 static HRESULT WINAPI domfrag_get_namespaceURI(
511 IXMLDOMDocumentFragment *iface,
514 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
515 TRACE("(%p)->(%p)\n", This, p);
516 return node_get_namespaceURI(&This->node, p);
519 static HRESULT WINAPI domfrag_get_prefix(
520 IXMLDOMDocumentFragment *iface,
523 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
524 TRACE("(%p)->(%p)\n", This, prefix);
525 return return_null_bstr( prefix );
528 static HRESULT WINAPI domfrag_get_baseName(
529 IXMLDOMDocumentFragment *iface,
532 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
533 FIXME("(%p)->(%p): needs test\n", This, name);
534 return return_null_bstr( name );
537 static HRESULT WINAPI domfrag_transformNodeToObject(
538 IXMLDOMDocumentFragment *iface,
539 IXMLDOMNode* domNode, VARIANT var1)
541 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
542 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
546 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
548 domfrag_QueryInterface,
551 domfrag_GetTypeInfoCount,
553 domfrag_GetIDsOfNames,
555 domfrag_get_nodeName,
556 domfrag_get_nodeValue,
557 domfrag_put_nodeValue,
558 domfrag_get_nodeType,
559 domfrag_get_parentNode,
560 domfrag_get_childNodes,
561 domfrag_get_firstChild,
562 domfrag_get_lastChild,
563 domfrag_get_previousSibling,
564 domfrag_get_nextSibling,
565 domfrag_get_attributes,
566 domfrag_insertBefore,
567 domfrag_replaceChild,
570 domfrag_hasChildNodes,
571 domfrag_get_ownerDocument,
573 domfrag_get_nodeTypeString,
576 domfrag_get_specified,
577 domfrag_get_definition,
578 domfrag_get_nodeTypedValue,
579 domfrag_put_nodeTypedValue,
580 domfrag_get_dataType,
581 domfrag_put_dataType,
583 domfrag_transformNode,
585 domfrag_selectSingleNode,
587 domfrag_get_namespaceURI,
589 domfrag_get_baseName,
590 domfrag_transformNodeToObject
593 IUnknown* create_doc_fragment( xmlNodePtr fragment )
597 This = heap_alloc( sizeof *This );
601 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
604 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, NULL);
606 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;