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
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct _domfrag
48 IXMLDOMDocumentFragment IXMLDOMDocumentFragment_iface;
52 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
54 return CONTAINING_RECORD(iface, domfrag, IXMLDOMDocumentFragment_iface);
57 static HRESULT WINAPI domfrag_QueryInterface(
58 IXMLDOMDocumentFragment *iface,
62 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
63 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
65 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
66 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
67 IsEqualGUID( riid, &IID_IDispatch ) ||
68 IsEqualGUID( riid, &IID_IUnknown ) )
72 else if(node_query_interface(&This->node, riid, ppvObject))
74 return *ppvObject ? S_OK : E_NOINTERFACE;
78 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
82 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
86 static ULONG WINAPI domfrag_AddRef(
87 IXMLDOMDocumentFragment *iface )
89 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
90 return InterlockedIncrement( &This->ref );
93 static ULONG WINAPI domfrag_Release(
94 IXMLDOMDocumentFragment *iface )
96 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
99 ref = InterlockedDecrement( &This->ref );
102 destroy_xmlnode(&This->node);
109 static HRESULT WINAPI domfrag_GetTypeInfoCount(
110 IXMLDOMDocumentFragment *iface,
113 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
115 TRACE("(%p)->(%p)\n", This, pctinfo);
122 static HRESULT WINAPI domfrag_GetTypeInfo(
123 IXMLDOMDocumentFragment *iface,
124 UINT iTInfo, LCID lcid,
125 ITypeInfo** ppTInfo )
127 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
130 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
132 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, ppTInfo);
137 static HRESULT WINAPI domfrag_GetIDsOfNames(
138 IXMLDOMDocumentFragment *iface,
139 REFIID riid, LPOLESTR* rgszNames,
140 UINT cNames, LCID lcid, DISPID* rgDispId )
142 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
146 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
149 if(!rgszNames || cNames == 0 || !rgDispId)
152 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
155 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
156 ITypeInfo_Release(typeinfo);
162 static HRESULT WINAPI domfrag_Invoke(
163 IXMLDOMDocumentFragment *iface,
164 DISPID dispIdMember, REFIID riid, LCID lcid,
165 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
166 EXCEPINFO* pExcepInfo, UINT* puArgErr )
168 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
172 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
173 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
175 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
178 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMDocumentFragment_iface, dispIdMember,
179 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
180 ITypeInfo_Release(typeinfo);
186 static HRESULT WINAPI domfrag_get_nodeName(
187 IXMLDOMDocumentFragment *iface,
190 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
192 static const WCHAR document_fragmentW[] =
193 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
195 TRACE("(%p)->(%p)\n", This, p);
197 return return_bstr(document_fragmentW, p);
200 static HRESULT WINAPI domfrag_get_nodeValue(
201 IXMLDOMDocumentFragment *iface,
204 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
206 FIXME("(%p)->(%p)\n", This, value);
211 V_VT(value) = VT_NULL;
215 static HRESULT WINAPI domfrag_put_nodeValue(
216 IXMLDOMDocumentFragment *iface,
219 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
220 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
224 static HRESULT WINAPI domfrag_get_nodeType(
225 IXMLDOMDocumentFragment *iface,
226 DOMNodeType* domNodeType )
228 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
230 TRACE("(%p)->(%p)\n", This, domNodeType);
232 *domNodeType = NODE_DOCUMENT_FRAGMENT;
236 static HRESULT WINAPI domfrag_get_parentNode(
237 IXMLDOMDocumentFragment *iface,
238 IXMLDOMNode** parent )
240 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
242 TRACE("(%p)->(%p)\n", This, parent);
244 return node_get_parent(&This->node, parent);
247 static HRESULT WINAPI domfrag_get_childNodes(
248 IXMLDOMDocumentFragment *iface,
249 IXMLDOMNodeList** outList)
251 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
253 TRACE("(%p)->(%p)\n", This, outList);
255 return node_get_child_nodes(&This->node, outList);
258 static HRESULT WINAPI domfrag_get_firstChild(
259 IXMLDOMDocumentFragment *iface,
260 IXMLDOMNode** domNode)
262 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
264 TRACE("(%p)->(%p)\n", This, domNode);
266 return node_get_first_child(&This->node, domNode);
269 static HRESULT WINAPI domfrag_get_lastChild(
270 IXMLDOMDocumentFragment *iface,
271 IXMLDOMNode** domNode)
273 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
275 TRACE("(%p)->(%p)\n", This, domNode);
277 return node_get_last_child(&This->node, domNode);
280 static HRESULT WINAPI domfrag_get_previousSibling(
281 IXMLDOMDocumentFragment *iface,
282 IXMLDOMNode** domNode)
284 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
286 TRACE("(%p)->(%p)\n", This, domNode);
288 return return_null_node(domNode);
291 static HRESULT WINAPI domfrag_get_nextSibling(
292 IXMLDOMDocumentFragment *iface,
293 IXMLDOMNode** domNode)
295 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
297 TRACE("(%p)->(%p)\n", This, domNode);
299 return return_null_node(domNode);
302 static HRESULT WINAPI domfrag_get_attributes(
303 IXMLDOMDocumentFragment *iface,
304 IXMLDOMNamedNodeMap** attributeMap)
306 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
308 TRACE("(%p)->(%p)\n", This, attributeMap);
310 return return_null_ptr((void**)attributeMap);
313 static HRESULT WINAPI domfrag_insertBefore(
314 IXMLDOMDocumentFragment *iface,
315 IXMLDOMNode* newNode, VARIANT refChild,
316 IXMLDOMNode** outOldNode)
318 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
320 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
323 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
326 static HRESULT WINAPI domfrag_replaceChild(
327 IXMLDOMDocumentFragment *iface,
328 IXMLDOMNode* newNode,
329 IXMLDOMNode* oldNode,
330 IXMLDOMNode** outOldNode)
332 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
334 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
337 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
340 static HRESULT WINAPI domfrag_removeChild(
341 IXMLDOMDocumentFragment *iface,
342 IXMLDOMNode *child, IXMLDOMNode **oldChild)
344 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
345 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
346 return node_remove_child(&This->node, child, oldChild);
349 static HRESULT WINAPI domfrag_appendChild(
350 IXMLDOMDocumentFragment *iface,
351 IXMLDOMNode *child, IXMLDOMNode **outChild)
353 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
354 TRACE("(%p)->(%p %p)\n", This, child, outChild);
355 return node_append_child(&This->node, child, outChild);
358 static HRESULT WINAPI domfrag_hasChildNodes(
359 IXMLDOMDocumentFragment *iface,
362 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
363 TRACE("(%p)->(%p)\n", This, ret);
364 return node_has_childnodes(&This->node, ret);
367 static HRESULT WINAPI domfrag_get_ownerDocument(
368 IXMLDOMDocumentFragment *iface,
369 IXMLDOMDocument **doc)
371 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
372 TRACE("(%p)->(%p)\n", This, doc);
373 return node_get_owner_doc(&This->node, doc);
376 static HRESULT WINAPI domfrag_cloneNode(
377 IXMLDOMDocumentFragment *iface,
378 VARIANT_BOOL deep, IXMLDOMNode** outNode)
380 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
381 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
382 return node_clone( &This->node, deep, outNode );
385 static HRESULT WINAPI domfrag_get_nodeTypeString(
386 IXMLDOMDocumentFragment *iface,
389 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
390 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
392 TRACE("(%p)->(%p)\n", This, p);
394 return return_bstr(documentfragmentW, p);
397 static HRESULT WINAPI domfrag_get_text(
398 IXMLDOMDocumentFragment *iface,
401 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
402 TRACE("(%p)->(%p)\n", This, p);
403 return node_get_text(&This->node, p);
406 static HRESULT WINAPI domfrag_put_text(
407 IXMLDOMDocumentFragment *iface,
410 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
411 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
412 return node_put_text( &This->node, p );
415 static HRESULT WINAPI domfrag_get_specified(
416 IXMLDOMDocumentFragment *iface,
417 VARIANT_BOOL* isSpecified)
419 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
420 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
421 *isSpecified = VARIANT_TRUE;
425 static HRESULT WINAPI domfrag_get_definition(
426 IXMLDOMDocumentFragment *iface,
427 IXMLDOMNode** definitionNode)
429 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
430 FIXME("(%p)->(%p)\n", This, definitionNode);
434 static HRESULT WINAPI domfrag_get_nodeTypedValue(
435 IXMLDOMDocumentFragment *iface,
438 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
439 FIXME("(%p)->(%p)\n", This, var1);
440 return return_null_var(var1);
443 static HRESULT WINAPI domfrag_put_nodeTypedValue(
444 IXMLDOMDocumentFragment *iface,
447 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
448 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
452 static HRESULT WINAPI domfrag_get_dataType(
453 IXMLDOMDocumentFragment *iface,
456 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
457 TRACE("(%p)->(%p)\n", This, typename);
458 return return_null_var( typename );
461 static HRESULT WINAPI domfrag_put_dataType(
462 IXMLDOMDocumentFragment *iface,
465 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
467 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
475 static HRESULT WINAPI domfrag_get_xml(
476 IXMLDOMDocumentFragment *iface,
479 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
481 TRACE("(%p)->(%p)\n", This, p);
483 return node_get_xml(&This->node, FALSE, FALSE, p);
486 static HRESULT WINAPI domfrag_transformNode(
487 IXMLDOMDocumentFragment *iface,
488 IXMLDOMNode* domNode, BSTR* p)
490 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
491 return IXMLDOMNode_transformNode( &This->node.IXMLDOMNode_iface, domNode, p );
494 static HRESULT WINAPI domfrag_selectNodes(
495 IXMLDOMDocumentFragment *iface,
496 BSTR p, IXMLDOMNodeList** outList)
498 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
499 return IXMLDOMNode_selectNodes( &This->node.IXMLDOMNode_iface, p, outList );
502 static HRESULT WINAPI domfrag_selectSingleNode(
503 IXMLDOMDocumentFragment *iface,
504 BSTR p, IXMLDOMNode** outNode)
506 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
507 return IXMLDOMNode_selectSingleNode( &This->node.IXMLDOMNode_iface, p, outNode );
510 static HRESULT WINAPI domfrag_get_parsed(
511 IXMLDOMDocumentFragment *iface,
512 VARIANT_BOOL* isParsed)
514 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
515 FIXME("(%p)->(%p) stub!\n", This, isParsed);
516 *isParsed = VARIANT_TRUE;
520 static HRESULT WINAPI domfrag_get_namespaceURI(
521 IXMLDOMDocumentFragment *iface,
524 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
525 TRACE("(%p)->(%p)\n", This, p);
526 return node_get_namespaceURI(&This->node, p);
529 static HRESULT WINAPI domfrag_get_prefix(
530 IXMLDOMDocumentFragment *iface,
533 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
534 TRACE("(%p)->(%p)\n", This, prefix);
535 return return_null_bstr( prefix );
538 static HRESULT WINAPI domfrag_get_baseName(
539 IXMLDOMDocumentFragment *iface,
542 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
543 FIXME("(%p)->(%p): needs test\n", This, name);
544 return return_null_bstr( name );
547 static HRESULT WINAPI domfrag_transformNodeToObject(
548 IXMLDOMDocumentFragment *iface,
549 IXMLDOMNode* domNode, VARIANT var1)
551 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
552 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
556 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
558 domfrag_QueryInterface,
561 domfrag_GetTypeInfoCount,
563 domfrag_GetIDsOfNames,
565 domfrag_get_nodeName,
566 domfrag_get_nodeValue,
567 domfrag_put_nodeValue,
568 domfrag_get_nodeType,
569 domfrag_get_parentNode,
570 domfrag_get_childNodes,
571 domfrag_get_firstChild,
572 domfrag_get_lastChild,
573 domfrag_get_previousSibling,
574 domfrag_get_nextSibling,
575 domfrag_get_attributes,
576 domfrag_insertBefore,
577 domfrag_replaceChild,
580 domfrag_hasChildNodes,
581 domfrag_get_ownerDocument,
583 domfrag_get_nodeTypeString,
586 domfrag_get_specified,
587 domfrag_get_definition,
588 domfrag_get_nodeTypedValue,
589 domfrag_put_nodeTypedValue,
590 domfrag_get_dataType,
591 domfrag_put_dataType,
593 domfrag_transformNode,
595 domfrag_selectSingleNode,
597 domfrag_get_namespaceURI,
599 domfrag_get_baseName,
600 domfrag_transformNodeToObject
603 IUnknown* create_doc_fragment( xmlNodePtr fragment )
607 This = heap_alloc( sizeof *This );
611 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
614 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, NULL);
616 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;