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 const tid_t domfrag_se_tids[] = {
54 IXMLDOMDocumentFragment_tid,
58 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
60 return CONTAINING_RECORD(iface, domfrag, IXMLDOMDocumentFragment_iface);
63 static HRESULT WINAPI domfrag_QueryInterface(
64 IXMLDOMDocumentFragment *iface,
68 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
69 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
71 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
72 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
73 IsEqualGUID( riid, &IID_IDispatch ) ||
74 IsEqualGUID( riid, &IID_IUnknown ) )
78 else if(node_query_interface(&This->node, riid, ppvObject))
80 return *ppvObject ? S_OK : E_NOINTERFACE;
82 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
84 return node_create_supporterrorinfo(domfrag_se_tids, ppvObject);
88 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
93 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
97 static ULONG WINAPI domfrag_AddRef(
98 IXMLDOMDocumentFragment *iface )
100 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
101 ULONG ref = InterlockedIncrement( &This->ref );
102 TRACE("(%p)->(%d)\n", This, ref);
106 static ULONG WINAPI domfrag_Release(
107 IXMLDOMDocumentFragment *iface )
109 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
110 ULONG ref = InterlockedDecrement( &This->ref );
112 TRACE("(%p)->(%d)\n", This, ref);
115 destroy_xmlnode(&This->node);
122 static HRESULT WINAPI domfrag_GetTypeInfoCount(
123 IXMLDOMDocumentFragment *iface,
126 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
127 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
130 static HRESULT WINAPI domfrag_GetTypeInfo(
131 IXMLDOMDocumentFragment *iface,
132 UINT iTInfo, LCID lcid,
133 ITypeInfo** ppTInfo )
135 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
136 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
137 iTInfo, lcid, 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 );
146 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
147 riid, rgszNames, cNames, lcid, rgDispId);
150 static HRESULT WINAPI domfrag_Invoke(
151 IXMLDOMDocumentFragment *iface,
152 DISPID dispIdMember, REFIID riid, LCID lcid,
153 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
154 EXCEPINFO* pExcepInfo, UINT* puArgErr )
156 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
157 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
158 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
161 static HRESULT WINAPI domfrag_get_nodeName(
162 IXMLDOMDocumentFragment *iface,
165 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
167 static const WCHAR document_fragmentW[] =
168 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
170 TRACE("(%p)->(%p)\n", This, p);
172 return return_bstr(document_fragmentW, p);
175 static HRESULT WINAPI domfrag_get_nodeValue(
176 IXMLDOMDocumentFragment *iface,
179 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
180 TRACE("(%p)->(%p)\n", This, value);
181 return return_null_var(value);
184 static HRESULT WINAPI domfrag_put_nodeValue(
185 IXMLDOMDocumentFragment *iface,
188 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
189 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
193 static HRESULT WINAPI domfrag_get_nodeType(
194 IXMLDOMDocumentFragment *iface,
195 DOMNodeType* domNodeType )
197 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
199 TRACE("(%p)->(%p)\n", This, domNodeType);
201 *domNodeType = NODE_DOCUMENT_FRAGMENT;
205 static HRESULT WINAPI domfrag_get_parentNode(
206 IXMLDOMDocumentFragment *iface,
207 IXMLDOMNode** parent )
209 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
211 TRACE("(%p)->(%p)\n", This, parent);
213 return node_get_parent(&This->node, parent);
216 static HRESULT WINAPI domfrag_get_childNodes(
217 IXMLDOMDocumentFragment *iface,
218 IXMLDOMNodeList** outList)
220 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
222 TRACE("(%p)->(%p)\n", This, outList);
224 return node_get_child_nodes(&This->node, outList);
227 static HRESULT WINAPI domfrag_get_firstChild(
228 IXMLDOMDocumentFragment *iface,
229 IXMLDOMNode** domNode)
231 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
233 TRACE("(%p)->(%p)\n", This, domNode);
235 return node_get_first_child(&This->node, domNode);
238 static HRESULT WINAPI domfrag_get_lastChild(
239 IXMLDOMDocumentFragment *iface,
240 IXMLDOMNode** domNode)
242 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
244 TRACE("(%p)->(%p)\n", This, domNode);
246 return node_get_last_child(&This->node, domNode);
249 static HRESULT WINAPI domfrag_get_previousSibling(
250 IXMLDOMDocumentFragment *iface,
251 IXMLDOMNode** domNode)
253 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
255 TRACE("(%p)->(%p)\n", This, domNode);
257 return return_null_node(domNode);
260 static HRESULT WINAPI domfrag_get_nextSibling(
261 IXMLDOMDocumentFragment *iface,
262 IXMLDOMNode** domNode)
264 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
266 TRACE("(%p)->(%p)\n", This, domNode);
268 return return_null_node(domNode);
271 static HRESULT WINAPI domfrag_get_attributes(
272 IXMLDOMDocumentFragment *iface,
273 IXMLDOMNamedNodeMap** attributeMap)
275 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
277 TRACE("(%p)->(%p)\n", This, attributeMap);
279 return return_null_ptr((void**)attributeMap);
282 static HRESULT WINAPI domfrag_insertBefore(
283 IXMLDOMDocumentFragment *iface,
284 IXMLDOMNode* newNode, VARIANT refChild,
285 IXMLDOMNode** outOldNode)
287 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
289 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
292 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
295 static HRESULT WINAPI domfrag_replaceChild(
296 IXMLDOMDocumentFragment *iface,
297 IXMLDOMNode* newNode,
298 IXMLDOMNode* oldNode,
299 IXMLDOMNode** outOldNode)
301 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
303 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
306 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
309 static HRESULT WINAPI domfrag_removeChild(
310 IXMLDOMDocumentFragment *iface,
311 IXMLDOMNode *child, IXMLDOMNode **oldChild)
313 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
314 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
315 return node_remove_child(&This->node, child, oldChild);
318 static HRESULT WINAPI domfrag_appendChild(
319 IXMLDOMDocumentFragment *iface,
320 IXMLDOMNode *child, IXMLDOMNode **outChild)
322 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
323 TRACE("(%p)->(%p %p)\n", This, child, outChild);
324 return node_append_child(&This->node, child, outChild);
327 static HRESULT WINAPI domfrag_hasChildNodes(
328 IXMLDOMDocumentFragment *iface,
331 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
332 TRACE("(%p)->(%p)\n", This, ret);
333 return node_has_childnodes(&This->node, ret);
336 static HRESULT WINAPI domfrag_get_ownerDocument(
337 IXMLDOMDocumentFragment *iface,
338 IXMLDOMDocument **doc)
340 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
341 TRACE("(%p)->(%p)\n", This, doc);
342 return node_get_owner_doc(&This->node, doc);
345 static HRESULT WINAPI domfrag_cloneNode(
346 IXMLDOMDocumentFragment *iface,
347 VARIANT_BOOL deep, IXMLDOMNode** outNode)
349 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
350 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
351 return node_clone( &This->node, deep, outNode );
354 static HRESULT WINAPI domfrag_get_nodeTypeString(
355 IXMLDOMDocumentFragment *iface,
358 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
359 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
361 TRACE("(%p)->(%p)\n", This, p);
363 return return_bstr(documentfragmentW, p);
366 static HRESULT WINAPI domfrag_get_text(
367 IXMLDOMDocumentFragment *iface,
370 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
371 TRACE("(%p)->(%p)\n", This, p);
372 return node_get_text(&This->node, p);
375 static HRESULT WINAPI domfrag_put_text(
376 IXMLDOMDocumentFragment *iface,
379 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
380 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
381 return node_put_text( &This->node, p );
384 static HRESULT WINAPI domfrag_get_specified(
385 IXMLDOMDocumentFragment *iface,
386 VARIANT_BOOL* isSpecified)
388 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
389 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
390 *isSpecified = VARIANT_TRUE;
394 static HRESULT WINAPI domfrag_get_definition(
395 IXMLDOMDocumentFragment *iface,
396 IXMLDOMNode** definitionNode)
398 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
399 FIXME("(%p)->(%p)\n", This, definitionNode);
403 static HRESULT WINAPI domfrag_get_nodeTypedValue(
404 IXMLDOMDocumentFragment *iface,
407 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
408 TRACE("(%p)->(%p)\n", This, v);
409 return return_null_var(v);
412 static HRESULT WINAPI domfrag_put_nodeTypedValue(
413 IXMLDOMDocumentFragment *iface,
416 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
417 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
421 static HRESULT WINAPI domfrag_get_dataType(
422 IXMLDOMDocumentFragment *iface,
425 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
426 TRACE("(%p)->(%p)\n", This, typename);
427 return return_null_var( typename );
430 static HRESULT WINAPI domfrag_put_dataType(
431 IXMLDOMDocumentFragment *iface,
434 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
436 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
444 static HRESULT WINAPI domfrag_get_xml(
445 IXMLDOMDocumentFragment *iface,
448 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
450 TRACE("(%p)->(%p)\n", This, p);
452 return node_get_xml(&This->node, FALSE, FALSE, p);
455 static HRESULT WINAPI domfrag_transformNode(
456 IXMLDOMDocumentFragment *iface,
457 IXMLDOMNode *node, BSTR *p)
459 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
460 TRACE("(%p)->(%p %p)\n", This, node, p);
461 return node_transform_node(&This->node, node, p);
464 static HRESULT WINAPI domfrag_selectNodes(
465 IXMLDOMDocumentFragment *iface,
466 BSTR p, IXMLDOMNodeList** outList)
468 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
469 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
470 return node_select_nodes(&This->node, p, outList);
473 static HRESULT WINAPI domfrag_selectSingleNode(
474 IXMLDOMDocumentFragment *iface,
475 BSTR p, IXMLDOMNode** outNode)
477 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
478 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
479 return node_select_singlenode(&This->node, p, outNode);
482 static HRESULT WINAPI domfrag_get_parsed(
483 IXMLDOMDocumentFragment *iface,
484 VARIANT_BOOL* isParsed)
486 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
487 FIXME("(%p)->(%p) stub!\n", This, isParsed);
488 *isParsed = VARIANT_TRUE;
492 static HRESULT WINAPI domfrag_get_namespaceURI(
493 IXMLDOMDocumentFragment *iface,
496 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
497 TRACE("(%p)->(%p)\n", This, p);
498 return node_get_namespaceURI(&This->node, p);
501 static HRESULT WINAPI domfrag_get_prefix(
502 IXMLDOMDocumentFragment *iface,
505 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
506 TRACE("(%p)->(%p)\n", This, prefix);
507 return return_null_bstr( prefix );
510 static HRESULT WINAPI domfrag_get_baseName(
511 IXMLDOMDocumentFragment *iface,
514 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
515 FIXME("(%p)->(%p): needs test\n", This, name);
516 return return_null_bstr( name );
519 static HRESULT WINAPI domfrag_transformNodeToObject(
520 IXMLDOMDocumentFragment *iface,
521 IXMLDOMNode* domNode, VARIANT var1)
523 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
524 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
528 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
530 domfrag_QueryInterface,
533 domfrag_GetTypeInfoCount,
535 domfrag_GetIDsOfNames,
537 domfrag_get_nodeName,
538 domfrag_get_nodeValue,
539 domfrag_put_nodeValue,
540 domfrag_get_nodeType,
541 domfrag_get_parentNode,
542 domfrag_get_childNodes,
543 domfrag_get_firstChild,
544 domfrag_get_lastChild,
545 domfrag_get_previousSibling,
546 domfrag_get_nextSibling,
547 domfrag_get_attributes,
548 domfrag_insertBefore,
549 domfrag_replaceChild,
552 domfrag_hasChildNodes,
553 domfrag_get_ownerDocument,
555 domfrag_get_nodeTypeString,
558 domfrag_get_specified,
559 domfrag_get_definition,
560 domfrag_get_nodeTypedValue,
561 domfrag_put_nodeTypedValue,
562 domfrag_get_dataType,
563 domfrag_put_dataType,
565 domfrag_transformNode,
567 domfrag_selectSingleNode,
569 domfrag_get_namespaceURI,
571 domfrag_get_baseName,
572 domfrag_transformNodeToObject
575 static const tid_t domfrag_iface_tids[] = {
576 IXMLDOMDocumentFragment_tid,
580 static dispex_static_data_t domfrag_dispex = {
582 IXMLDOMDocumentFragment_tid,
587 IUnknown* create_doc_fragment( xmlNodePtr fragment )
591 This = heap_alloc( sizeof *This );
595 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
598 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, &domfrag_dispex);
600 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;