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 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
83 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
87 static ULONG WINAPI
domfrag_AddRef(
88 IXMLDOMDocumentFragment
*iface
)
90 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
91 ULONG ref
= InterlockedIncrement( &This
->ref
);
92 TRACE("(%p)->(%d)\n", This
, ref
);
96 static ULONG WINAPI
domfrag_Release(
97 IXMLDOMDocumentFragment
*iface
)
99 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
100 ULONG ref
= InterlockedDecrement( &This
->ref
);
102 TRACE("(%p)->(%d)\n", This
, ref
);
105 destroy_xmlnode(&This
->node
);
112 static HRESULT WINAPI
domfrag_GetTypeInfoCount(
113 IXMLDOMDocumentFragment
*iface
,
116 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
118 TRACE("(%p)->(%p)\n", This
, pctinfo
);
125 static HRESULT WINAPI
domfrag_GetTypeInfo(
126 IXMLDOMDocumentFragment
*iface
,
127 UINT iTInfo
, LCID lcid
,
128 ITypeInfo
** ppTInfo
)
130 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
133 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
135 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, ppTInfo
);
140 static HRESULT WINAPI
domfrag_GetIDsOfNames(
141 IXMLDOMDocumentFragment
*iface
,
142 REFIID riid
, LPOLESTR
* rgszNames
,
143 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
145 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
149 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
152 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
155 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, &typeinfo
);
158 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
159 ITypeInfo_Release(typeinfo
);
165 static HRESULT WINAPI
domfrag_Invoke(
166 IXMLDOMDocumentFragment
*iface
,
167 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
168 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
169 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
171 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
175 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
176 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
178 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, &typeinfo
);
181 hr
= ITypeInfo_Invoke(typeinfo
, &This
->IXMLDOMDocumentFragment_iface
, dispIdMember
,
182 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
183 ITypeInfo_Release(typeinfo
);
189 static HRESULT WINAPI
domfrag_get_nodeName(
190 IXMLDOMDocumentFragment
*iface
,
193 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
195 static const WCHAR document_fragmentW
[] =
196 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
198 TRACE("(%p)->(%p)\n", This
, p
);
200 return return_bstr(document_fragmentW
, p
);
203 static HRESULT WINAPI
domfrag_get_nodeValue(
204 IXMLDOMDocumentFragment
*iface
,
207 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
209 FIXME("(%p)->(%p)\n", This
, value
);
214 V_VT(value
) = VT_NULL
;
218 static HRESULT WINAPI
domfrag_put_nodeValue(
219 IXMLDOMDocumentFragment
*iface
,
222 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
223 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
227 static HRESULT WINAPI
domfrag_get_nodeType(
228 IXMLDOMDocumentFragment
*iface
,
229 DOMNodeType
* domNodeType
)
231 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
233 TRACE("(%p)->(%p)\n", This
, domNodeType
);
235 *domNodeType
= NODE_DOCUMENT_FRAGMENT
;
239 static HRESULT WINAPI
domfrag_get_parentNode(
240 IXMLDOMDocumentFragment
*iface
,
241 IXMLDOMNode
** parent
)
243 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
245 TRACE("(%p)->(%p)\n", This
, parent
);
247 return node_get_parent(&This
->node
, parent
);
250 static HRESULT WINAPI
domfrag_get_childNodes(
251 IXMLDOMDocumentFragment
*iface
,
252 IXMLDOMNodeList
** outList
)
254 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
256 TRACE("(%p)->(%p)\n", This
, outList
);
258 return node_get_child_nodes(&This
->node
, outList
);
261 static HRESULT WINAPI
domfrag_get_firstChild(
262 IXMLDOMDocumentFragment
*iface
,
263 IXMLDOMNode
** domNode
)
265 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
267 TRACE("(%p)->(%p)\n", This
, domNode
);
269 return node_get_first_child(&This
->node
, domNode
);
272 static HRESULT WINAPI
domfrag_get_lastChild(
273 IXMLDOMDocumentFragment
*iface
,
274 IXMLDOMNode
** domNode
)
276 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
278 TRACE("(%p)->(%p)\n", This
, domNode
);
280 return node_get_last_child(&This
->node
, domNode
);
283 static HRESULT WINAPI
domfrag_get_previousSibling(
284 IXMLDOMDocumentFragment
*iface
,
285 IXMLDOMNode
** domNode
)
287 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
289 TRACE("(%p)->(%p)\n", This
, domNode
);
291 return return_null_node(domNode
);
294 static HRESULT WINAPI
domfrag_get_nextSibling(
295 IXMLDOMDocumentFragment
*iface
,
296 IXMLDOMNode
** domNode
)
298 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
300 TRACE("(%p)->(%p)\n", This
, domNode
);
302 return return_null_node(domNode
);
305 static HRESULT WINAPI
domfrag_get_attributes(
306 IXMLDOMDocumentFragment
*iface
,
307 IXMLDOMNamedNodeMap
** attributeMap
)
309 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
311 TRACE("(%p)->(%p)\n", This
, attributeMap
);
313 return return_null_ptr((void**)attributeMap
);
316 static HRESULT WINAPI
domfrag_insertBefore(
317 IXMLDOMDocumentFragment
*iface
,
318 IXMLDOMNode
* newNode
, VARIANT refChild
,
319 IXMLDOMNode
** outOldNode
)
321 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
323 TRACE("(%p)->(%p %s %p)\n", This
, newNode
, debugstr_variant(&refChild
), outOldNode
);
326 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
329 static HRESULT WINAPI
domfrag_replaceChild(
330 IXMLDOMDocumentFragment
*iface
,
331 IXMLDOMNode
* newNode
,
332 IXMLDOMNode
* oldNode
,
333 IXMLDOMNode
** outOldNode
)
335 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
337 TRACE("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
340 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
343 static HRESULT WINAPI
domfrag_removeChild(
344 IXMLDOMDocumentFragment
*iface
,
345 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
347 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
348 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
349 return node_remove_child(&This
->node
, child
, oldChild
);
352 static HRESULT WINAPI
domfrag_appendChild(
353 IXMLDOMDocumentFragment
*iface
,
354 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
356 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
357 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
358 return node_append_child(&This
->node
, child
, outChild
);
361 static HRESULT WINAPI
domfrag_hasChildNodes(
362 IXMLDOMDocumentFragment
*iface
,
365 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
366 TRACE("(%p)->(%p)\n", This
, ret
);
367 return node_has_childnodes(&This
->node
, ret
);
370 static HRESULT WINAPI
domfrag_get_ownerDocument(
371 IXMLDOMDocumentFragment
*iface
,
372 IXMLDOMDocument
**doc
)
374 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
375 TRACE("(%p)->(%p)\n", This
, doc
);
376 return node_get_owner_doc(&This
->node
, doc
);
379 static HRESULT WINAPI
domfrag_cloneNode(
380 IXMLDOMDocumentFragment
*iface
,
381 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
383 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
384 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
385 return node_clone( &This
->node
, deep
, outNode
);
388 static HRESULT WINAPI
domfrag_get_nodeTypeString(
389 IXMLDOMDocumentFragment
*iface
,
392 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
393 static const WCHAR documentfragmentW
[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
395 TRACE("(%p)->(%p)\n", This
, p
);
397 return return_bstr(documentfragmentW
, p
);
400 static HRESULT WINAPI
domfrag_get_text(
401 IXMLDOMDocumentFragment
*iface
,
404 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
405 TRACE("(%p)->(%p)\n", This
, p
);
406 return node_get_text(&This
->node
, p
);
409 static HRESULT WINAPI
domfrag_put_text(
410 IXMLDOMDocumentFragment
*iface
,
413 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
414 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
415 return node_put_text( &This
->node
, p
);
418 static HRESULT WINAPI
domfrag_get_specified(
419 IXMLDOMDocumentFragment
*iface
,
420 VARIANT_BOOL
* isSpecified
)
422 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
423 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
424 *isSpecified
= VARIANT_TRUE
;
428 static HRESULT WINAPI
domfrag_get_definition(
429 IXMLDOMDocumentFragment
*iface
,
430 IXMLDOMNode
** definitionNode
)
432 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
433 FIXME("(%p)->(%p)\n", This
, definitionNode
);
437 static HRESULT WINAPI
domfrag_get_nodeTypedValue(
438 IXMLDOMDocumentFragment
*iface
,
441 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
442 TRACE("(%p)->(%p)\n", This
, v
);
443 return return_null_var(v
);
446 static HRESULT WINAPI
domfrag_put_nodeTypedValue(
447 IXMLDOMDocumentFragment
*iface
,
450 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
451 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
455 static HRESULT WINAPI
domfrag_get_dataType(
456 IXMLDOMDocumentFragment
*iface
,
459 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
460 TRACE("(%p)->(%p)\n", This
, typename
);
461 return return_null_var( typename
);
464 static HRESULT WINAPI
domfrag_put_dataType(
465 IXMLDOMDocumentFragment
*iface
,
468 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
470 FIXME("(%p)->(%s)\n", This
, debugstr_w(p
));
478 static HRESULT WINAPI
domfrag_get_xml(
479 IXMLDOMDocumentFragment
*iface
,
482 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
484 TRACE("(%p)->(%p)\n", This
, p
);
486 return node_get_xml(&This
->node
, FALSE
, FALSE
, p
);
489 static HRESULT WINAPI
domfrag_transformNode(
490 IXMLDOMDocumentFragment
*iface
,
491 IXMLDOMNode
*node
, BSTR
*p
)
493 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
494 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
495 return node_transform_node(&This
->node
, node
, p
);
498 static HRESULT WINAPI
domfrag_selectNodes(
499 IXMLDOMDocumentFragment
*iface
,
500 BSTR p
, IXMLDOMNodeList
** outList
)
502 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
503 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
504 return node_select_nodes(&This
->node
, p
, outList
);
507 static HRESULT WINAPI
domfrag_selectSingleNode(
508 IXMLDOMDocumentFragment
*iface
,
509 BSTR p
, IXMLDOMNode
** outNode
)
511 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
512 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
513 return node_select_singlenode(&This
->node
, p
, outNode
);
516 static HRESULT WINAPI
domfrag_get_parsed(
517 IXMLDOMDocumentFragment
*iface
,
518 VARIANT_BOOL
* isParsed
)
520 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
521 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
522 *isParsed
= VARIANT_TRUE
;
526 static HRESULT WINAPI
domfrag_get_namespaceURI(
527 IXMLDOMDocumentFragment
*iface
,
530 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
531 TRACE("(%p)->(%p)\n", This
, p
);
532 return node_get_namespaceURI(&This
->node
, p
);
535 static HRESULT WINAPI
domfrag_get_prefix(
536 IXMLDOMDocumentFragment
*iface
,
539 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
540 TRACE("(%p)->(%p)\n", This
, prefix
);
541 return return_null_bstr( prefix
);
544 static HRESULT WINAPI
domfrag_get_baseName(
545 IXMLDOMDocumentFragment
*iface
,
548 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
549 FIXME("(%p)->(%p): needs test\n", This
, name
);
550 return return_null_bstr( name
);
553 static HRESULT WINAPI
domfrag_transformNodeToObject(
554 IXMLDOMDocumentFragment
*iface
,
555 IXMLDOMNode
* domNode
, VARIANT var1
)
557 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
558 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
562 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl
=
564 domfrag_QueryInterface
,
567 domfrag_GetTypeInfoCount
,
569 domfrag_GetIDsOfNames
,
571 domfrag_get_nodeName
,
572 domfrag_get_nodeValue
,
573 domfrag_put_nodeValue
,
574 domfrag_get_nodeType
,
575 domfrag_get_parentNode
,
576 domfrag_get_childNodes
,
577 domfrag_get_firstChild
,
578 domfrag_get_lastChild
,
579 domfrag_get_previousSibling
,
580 domfrag_get_nextSibling
,
581 domfrag_get_attributes
,
582 domfrag_insertBefore
,
583 domfrag_replaceChild
,
586 domfrag_hasChildNodes
,
587 domfrag_get_ownerDocument
,
589 domfrag_get_nodeTypeString
,
592 domfrag_get_specified
,
593 domfrag_get_definition
,
594 domfrag_get_nodeTypedValue
,
595 domfrag_put_nodeTypedValue
,
596 domfrag_get_dataType
,
597 domfrag_put_dataType
,
599 domfrag_transformNode
,
601 domfrag_selectSingleNode
,
603 domfrag_get_namespaceURI
,
605 domfrag_get_baseName
,
606 domfrag_transformNodeToObject
609 IUnknown
* create_doc_fragment( xmlNodePtr fragment
)
613 This
= heap_alloc( sizeof *This
);
617 This
->IXMLDOMDocumentFragment_iface
.lpVtbl
= &domfrag_vtbl
;
620 init_xmlnode(&This
->node
, fragment
, (IXMLDOMNode
*)&This
->IXMLDOMDocumentFragment_iface
, NULL
);
622 return (IUnknown
*)&This
->IXMLDOMDocumentFragment_iface
;