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
24 #include <libxml/parser.h>
25 #include <libxml/xmlerror.h>
33 #include "msxml_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
39 typedef struct _domfrag
42 IXMLDOMDocumentFragment IXMLDOMDocumentFragment_iface
;
46 static const tid_t domfrag_se_tids
[] = {
48 IXMLDOMDocumentFragment_tid
,
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
;
76 else if(IsEqualGUID( riid
, &IID_ISupportErrorInfo
))
78 return node_create_supporterrorinfo(domfrag_se_tids
, ppvObject
);
82 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
87 IXMLDOMDocumentFragment_AddRef(iface
);
91 static ULONG WINAPI
domfrag_AddRef(IXMLDOMDocumentFragment
*iface
)
93 domfrag
*domfrag
= impl_from_IXMLDOMDocumentFragment(iface
);
94 ULONG ref
= InterlockedIncrement(&domfrag
->ref
);
95 TRACE("%p, refcount %lu.\n", iface
, ref
);
99 static ULONG WINAPI
domfrag_Release(IXMLDOMDocumentFragment
*iface
)
101 domfrag
*domfrag
= impl_from_IXMLDOMDocumentFragment(iface
);
102 ULONG ref
= InterlockedDecrement(&domfrag
->ref
);
104 TRACE("%p, refcount %lu.\n", iface
, ref
);
108 destroy_xmlnode(&domfrag
->node
);
115 static HRESULT WINAPI
domfrag_GetTypeInfoCount(
116 IXMLDOMDocumentFragment
*iface
,
119 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
120 return IDispatchEx_GetTypeInfoCount(&This
->node
.dispex
.IDispatchEx_iface
, pctinfo
);
123 static HRESULT WINAPI
domfrag_GetTypeInfo(
124 IXMLDOMDocumentFragment
*iface
,
125 UINT iTInfo
, LCID lcid
,
126 ITypeInfo
** ppTInfo
)
128 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
129 return IDispatchEx_GetTypeInfo(&This
->node
.dispex
.IDispatchEx_iface
,
130 iTInfo
, lcid
, ppTInfo
);
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 return IDispatchEx_GetIDsOfNames(&This
->node
.dispex
.IDispatchEx_iface
,
140 riid
, rgszNames
, cNames
, lcid
, rgDispId
);
143 static HRESULT WINAPI
domfrag_Invoke(
144 IXMLDOMDocumentFragment
*iface
,
145 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
146 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
147 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
149 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
150 return IDispatchEx_Invoke(&This
->node
.dispex
.IDispatchEx_iface
,
151 dispIdMember
, riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
154 static HRESULT WINAPI
domfrag_get_nodeName(
155 IXMLDOMDocumentFragment
*iface
,
158 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
160 static const WCHAR document_fragmentW
[] =
161 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
163 TRACE("(%p)->(%p)\n", This
, p
);
165 return return_bstr(document_fragmentW
, p
);
168 static HRESULT WINAPI
domfrag_get_nodeValue(
169 IXMLDOMDocumentFragment
*iface
,
172 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
173 TRACE("(%p)->(%p)\n", This
, value
);
174 return return_null_var(value
);
177 static HRESULT WINAPI
domfrag_put_nodeValue(
178 IXMLDOMDocumentFragment
*iface
,
181 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
182 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&value
));
186 static HRESULT WINAPI
domfrag_get_nodeType(
187 IXMLDOMDocumentFragment
*iface
,
188 DOMNodeType
* domNodeType
)
190 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
192 TRACE("(%p)->(%p)\n", This
, domNodeType
);
194 *domNodeType
= NODE_DOCUMENT_FRAGMENT
;
198 static HRESULT WINAPI
domfrag_get_parentNode(
199 IXMLDOMDocumentFragment
*iface
,
200 IXMLDOMNode
** parent
)
202 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
204 TRACE("(%p)->(%p)\n", This
, parent
);
206 return node_get_parent(&This
->node
, parent
);
209 static HRESULT WINAPI
domfrag_get_childNodes(
210 IXMLDOMDocumentFragment
*iface
,
211 IXMLDOMNodeList
** outList
)
213 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
215 TRACE("(%p)->(%p)\n", This
, outList
);
217 return node_get_child_nodes(&This
->node
, outList
);
220 static HRESULT WINAPI
domfrag_get_firstChild(
221 IXMLDOMDocumentFragment
*iface
,
222 IXMLDOMNode
** domNode
)
224 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
226 TRACE("(%p)->(%p)\n", This
, domNode
);
228 return node_get_first_child(&This
->node
, domNode
);
231 static HRESULT WINAPI
domfrag_get_lastChild(
232 IXMLDOMDocumentFragment
*iface
,
233 IXMLDOMNode
** domNode
)
235 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
237 TRACE("(%p)->(%p)\n", This
, domNode
);
239 return node_get_last_child(&This
->node
, domNode
);
242 static HRESULT WINAPI
domfrag_get_previousSibling(
243 IXMLDOMDocumentFragment
*iface
,
244 IXMLDOMNode
** domNode
)
246 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
248 TRACE("(%p)->(%p)\n", This
, domNode
);
250 return return_null_node(domNode
);
253 static HRESULT WINAPI
domfrag_get_nextSibling(
254 IXMLDOMDocumentFragment
*iface
,
255 IXMLDOMNode
** domNode
)
257 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
259 TRACE("(%p)->(%p)\n", This
, domNode
);
261 return return_null_node(domNode
);
264 static HRESULT WINAPI
domfrag_get_attributes(
265 IXMLDOMDocumentFragment
*iface
,
266 IXMLDOMNamedNodeMap
** attributeMap
)
268 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
270 TRACE("(%p)->(%p)\n", This
, attributeMap
);
272 return return_null_ptr((void**)attributeMap
);
275 static HRESULT WINAPI
domfrag_insertBefore(
276 IXMLDOMDocumentFragment
*iface
,
277 IXMLDOMNode
* newNode
, VARIANT refChild
,
278 IXMLDOMNode
** outOldNode
)
280 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
282 TRACE("(%p)->(%p %s %p)\n", This
, newNode
, debugstr_variant(&refChild
), outOldNode
);
285 return node_insert_before(&This
->node
, newNode
, &refChild
, outOldNode
);
288 static HRESULT WINAPI
domfrag_replaceChild(
289 IXMLDOMDocumentFragment
*iface
,
290 IXMLDOMNode
* newNode
,
291 IXMLDOMNode
* oldNode
,
292 IXMLDOMNode
** outOldNode
)
294 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
296 TRACE("(%p)->(%p %p %p)\n", This
, newNode
, oldNode
, outOldNode
);
299 return node_replace_child(&This
->node
, newNode
, oldNode
, outOldNode
);
302 static HRESULT WINAPI
domfrag_removeChild(
303 IXMLDOMDocumentFragment
*iface
,
304 IXMLDOMNode
*child
, IXMLDOMNode
**oldChild
)
306 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
307 TRACE("(%p)->(%p %p)\n", This
, child
, oldChild
);
308 return node_remove_child(&This
->node
, child
, oldChild
);
311 static HRESULT WINAPI
domfrag_appendChild(
312 IXMLDOMDocumentFragment
*iface
,
313 IXMLDOMNode
*child
, IXMLDOMNode
**outChild
)
315 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
316 TRACE("(%p)->(%p %p)\n", This
, child
, outChild
);
317 return node_append_child(&This
->node
, child
, outChild
);
320 static HRESULT WINAPI
domfrag_hasChildNodes(
321 IXMLDOMDocumentFragment
*iface
,
324 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
325 TRACE("(%p)->(%p)\n", This
, ret
);
326 return node_has_childnodes(&This
->node
, ret
);
329 static HRESULT WINAPI
domfrag_get_ownerDocument(
330 IXMLDOMDocumentFragment
*iface
,
331 IXMLDOMDocument
**doc
)
333 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
334 TRACE("(%p)->(%p)\n", This
, doc
);
335 return node_get_owner_doc(&This
->node
, doc
);
338 static HRESULT WINAPI
domfrag_cloneNode(
339 IXMLDOMDocumentFragment
*iface
,
340 VARIANT_BOOL deep
, IXMLDOMNode
** outNode
)
342 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
343 TRACE("(%p)->(%d %p)\n", This
, deep
, outNode
);
344 return node_clone( &This
->node
, deep
, outNode
);
347 static HRESULT WINAPI
domfrag_get_nodeTypeString(
348 IXMLDOMDocumentFragment
*iface
,
351 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
352 static const WCHAR documentfragmentW
[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
354 TRACE("(%p)->(%p)\n", This
, p
);
356 return return_bstr(documentfragmentW
, p
);
359 static HRESULT WINAPI
domfrag_get_text(
360 IXMLDOMDocumentFragment
*iface
,
363 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
364 TRACE("(%p)->(%p)\n", This
, p
);
365 return node_get_text(&This
->node
, p
);
368 static HRESULT WINAPI
domfrag_put_text(
369 IXMLDOMDocumentFragment
*iface
,
372 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
373 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
374 return node_put_text( &This
->node
, p
);
377 static HRESULT WINAPI
domfrag_get_specified(
378 IXMLDOMDocumentFragment
*iface
,
379 VARIANT_BOOL
* isSpecified
)
381 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
382 FIXME("(%p)->(%p) stub!\n", This
, isSpecified
);
383 *isSpecified
= VARIANT_TRUE
;
387 static HRESULT WINAPI
domfrag_get_definition(
388 IXMLDOMDocumentFragment
*iface
,
389 IXMLDOMNode
** definitionNode
)
391 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
392 FIXME("(%p)->(%p)\n", This
, definitionNode
);
396 static HRESULT WINAPI
domfrag_get_nodeTypedValue(
397 IXMLDOMDocumentFragment
*iface
,
400 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
401 TRACE("(%p)->(%p)\n", This
, v
);
402 return return_null_var(v
);
405 static HRESULT WINAPI
domfrag_put_nodeTypedValue(
406 IXMLDOMDocumentFragment
*iface
,
409 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
410 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&typedValue
));
414 static HRESULT WINAPI
domfrag_get_dataType(
415 IXMLDOMDocumentFragment
*iface
,
418 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
419 TRACE("(%p)->(%p)\n", This
, typename
);
420 return return_null_var( typename
);
423 static HRESULT WINAPI
domfrag_put_dataType(
424 IXMLDOMDocumentFragment
*iface
,
427 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
429 TRACE("(%p)->(%s)\n", This
, debugstr_w(p
));
437 static HRESULT WINAPI
domfrag_get_xml(
438 IXMLDOMDocumentFragment
*iface
,
441 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
443 TRACE("(%p)->(%p)\n", This
, p
);
445 return node_get_xml(&This
->node
, FALSE
, p
);
448 static HRESULT WINAPI
domfrag_transformNode(
449 IXMLDOMDocumentFragment
*iface
,
450 IXMLDOMNode
*node
, BSTR
*p
)
452 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
453 TRACE("(%p)->(%p %p)\n", This
, node
, p
);
454 return node_transform_node(&This
->node
, node
, p
);
457 static HRESULT WINAPI
domfrag_selectNodes(
458 IXMLDOMDocumentFragment
*iface
,
459 BSTR p
, IXMLDOMNodeList
** outList
)
461 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
462 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outList
);
463 return node_select_nodes(&This
->node
, p
, outList
);
466 static HRESULT WINAPI
domfrag_selectSingleNode(
467 IXMLDOMDocumentFragment
*iface
,
468 BSTR p
, IXMLDOMNode
** outNode
)
470 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
471 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(p
), outNode
);
472 return node_select_singlenode(&This
->node
, p
, outNode
);
475 static HRESULT WINAPI
domfrag_get_parsed(
476 IXMLDOMDocumentFragment
*iface
,
477 VARIANT_BOOL
* isParsed
)
479 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
480 FIXME("(%p)->(%p) stub!\n", This
, isParsed
);
481 *isParsed
= VARIANT_TRUE
;
485 static HRESULT WINAPI
domfrag_get_namespaceURI(
486 IXMLDOMDocumentFragment
*iface
,
489 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
490 TRACE("(%p)->(%p)\n", This
, p
);
491 return node_get_namespaceURI(&This
->node
, p
);
494 static HRESULT WINAPI
domfrag_get_prefix(
495 IXMLDOMDocumentFragment
*iface
,
498 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
499 TRACE("(%p)->(%p)\n", This
, prefix
);
500 return return_null_bstr( prefix
);
503 static HRESULT WINAPI
domfrag_get_baseName(
504 IXMLDOMDocumentFragment
*iface
,
507 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
508 FIXME("(%p)->(%p): needs test\n", This
, name
);
509 return return_null_bstr( name
);
512 static HRESULT WINAPI
domfrag_transformNodeToObject(
513 IXMLDOMDocumentFragment
*iface
,
514 IXMLDOMNode
* domNode
, VARIANT var1
)
516 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
517 FIXME("(%p)->(%p %s)\n", This
, domNode
, debugstr_variant(&var1
));
521 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl
=
523 domfrag_QueryInterface
,
526 domfrag_GetTypeInfoCount
,
528 domfrag_GetIDsOfNames
,
530 domfrag_get_nodeName
,
531 domfrag_get_nodeValue
,
532 domfrag_put_nodeValue
,
533 domfrag_get_nodeType
,
534 domfrag_get_parentNode
,
535 domfrag_get_childNodes
,
536 domfrag_get_firstChild
,
537 domfrag_get_lastChild
,
538 domfrag_get_previousSibling
,
539 domfrag_get_nextSibling
,
540 domfrag_get_attributes
,
541 domfrag_insertBefore
,
542 domfrag_replaceChild
,
545 domfrag_hasChildNodes
,
546 domfrag_get_ownerDocument
,
548 domfrag_get_nodeTypeString
,
551 domfrag_get_specified
,
552 domfrag_get_definition
,
553 domfrag_get_nodeTypedValue
,
554 domfrag_put_nodeTypedValue
,
555 domfrag_get_dataType
,
556 domfrag_put_dataType
,
558 domfrag_transformNode
,
560 domfrag_selectSingleNode
,
562 domfrag_get_namespaceURI
,
564 domfrag_get_baseName
,
565 domfrag_transformNodeToObject
568 static const tid_t domfrag_iface_tids
[] = {
569 IXMLDOMDocumentFragment_tid
,
573 static dispex_static_data_t domfrag_dispex
= {
575 IXMLDOMDocumentFragment_tid
,
580 IUnknown
* create_doc_fragment( xmlNodePtr fragment
)
584 This
= heap_alloc( sizeof *This
);
588 This
->IXMLDOMDocumentFragment_iface
.lpVtbl
= &domfrag_vtbl
;
591 init_xmlnode(&This
->node
, fragment
, (IXMLDOMNode
*)&This
->IXMLDOMDocumentFragment_iface
, &domfrag_dispex
);
593 return (IUnknown
*)&This
->IXMLDOMDocumentFragment_iface
;