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 const struct IXMLDOMDocumentFragmentVtbl *lpVtbl;
47 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
49 return (domfrag *)((char*)iface - FIELD_OFFSET(domfrag, lpVtbl));
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->lpVtbl), dispIdMember, wFlags, pDispParams,
174 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 FIXME("(%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 );
302 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
305 static HRESULT WINAPI domfrag_insertBefore(
306 IXMLDOMDocumentFragment *iface,
307 IXMLDOMNode* newNode, VARIANT var1,
308 IXMLDOMNode** outOldNode)
310 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
311 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newNode, var1, outOldNode );
314 static HRESULT WINAPI domfrag_replaceChild(
315 IXMLDOMDocumentFragment *iface,
316 IXMLDOMNode* newNode,
317 IXMLDOMNode* oldNode,
318 IXMLDOMNode** outOldNode)
320 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
321 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
324 static HRESULT WINAPI domfrag_removeChild(
325 IXMLDOMDocumentFragment *iface,
326 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
328 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
329 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
332 static HRESULT WINAPI domfrag_appendChild(
333 IXMLDOMDocumentFragment *iface,
334 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
336 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
337 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
340 static HRESULT WINAPI domfrag_hasChildNodes(
341 IXMLDOMDocumentFragment *iface,
344 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
345 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
348 static HRESULT WINAPI domfrag_get_ownerDocument(
349 IXMLDOMDocumentFragment *iface,
350 IXMLDOMDocument** domDocument)
352 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
353 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
356 static HRESULT WINAPI domfrag_cloneNode(
357 IXMLDOMDocumentFragment *iface,
358 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
360 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
361 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
364 static HRESULT WINAPI domfrag_get_nodeTypeString(
365 IXMLDOMDocumentFragment *iface,
368 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
369 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
372 static HRESULT WINAPI domfrag_get_text(
373 IXMLDOMDocumentFragment *iface,
376 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
377 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
380 static HRESULT WINAPI domfrag_put_text(
381 IXMLDOMDocumentFragment *iface,
384 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
385 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
388 static HRESULT WINAPI domfrag_get_specified(
389 IXMLDOMDocumentFragment *iface,
392 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
393 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
396 static HRESULT WINAPI domfrag_get_definition(
397 IXMLDOMDocumentFragment *iface,
398 IXMLDOMNode** domNode)
400 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
401 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
404 static HRESULT WINAPI domfrag_get_nodeTypedValue(
405 IXMLDOMDocumentFragment *iface,
408 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
409 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
412 static HRESULT WINAPI domfrag_put_nodeTypedValue(
413 IXMLDOMDocumentFragment *iface,
416 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
417 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
420 static HRESULT WINAPI domfrag_get_dataType(
421 IXMLDOMDocumentFragment *iface,
424 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
425 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
428 static HRESULT WINAPI domfrag_put_dataType(
429 IXMLDOMDocumentFragment *iface,
432 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
433 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
436 static HRESULT WINAPI domfrag_get_xml(
437 IXMLDOMDocumentFragment *iface,
440 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
441 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
444 static HRESULT WINAPI domfrag_transformNode(
445 IXMLDOMDocumentFragment *iface,
446 IXMLDOMNode* domNode, BSTR* p)
448 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
449 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
452 static HRESULT WINAPI domfrag_selectNodes(
453 IXMLDOMDocumentFragment *iface,
454 BSTR p, IXMLDOMNodeList** outList)
456 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
457 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
460 static HRESULT WINAPI domfrag_selectSingleNode(
461 IXMLDOMDocumentFragment *iface,
462 BSTR p, IXMLDOMNode** outNode)
464 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
465 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
468 static HRESULT WINAPI domfrag_get_parsed(
469 IXMLDOMDocumentFragment *iface,
472 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
473 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
476 static HRESULT WINAPI domfrag_get_namespaceURI(
477 IXMLDOMDocumentFragment *iface,
480 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
481 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
484 static HRESULT WINAPI domfrag_get_prefix(
485 IXMLDOMDocumentFragment *iface,
488 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
489 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
492 static HRESULT WINAPI domfrag_get_baseName(
493 IXMLDOMDocumentFragment *iface,
496 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
497 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
500 static HRESULT WINAPI domfrag_transformNodeToObject(
501 IXMLDOMDocumentFragment *iface,
502 IXMLDOMNode* domNode, VARIANT var1)
504 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
505 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
508 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
510 domfrag_QueryInterface,
513 domfrag_GetTypeInfoCount,
515 domfrag_GetIDsOfNames,
517 domfrag_get_nodeName,
518 domfrag_get_nodeValue,
519 domfrag_put_nodeValue,
520 domfrag_get_nodeType,
521 domfrag_get_parentNode,
522 domfrag_get_childNodes,
523 domfrag_get_firstChild,
524 domfrag_get_lastChild,
525 domfrag_get_previousSibling,
526 domfrag_get_nextSibling,
527 domfrag_get_attributes,
528 domfrag_insertBefore,
529 domfrag_replaceChild,
532 domfrag_hasChildNodes,
533 domfrag_get_ownerDocument,
535 domfrag_get_nodeTypeString,
538 domfrag_get_specified,
539 domfrag_get_definition,
540 domfrag_get_nodeTypedValue,
541 domfrag_put_nodeTypedValue,
542 domfrag_get_dataType,
543 domfrag_put_dataType,
545 domfrag_transformNode,
547 domfrag_selectSingleNode,
549 domfrag_get_namespaceURI,
551 domfrag_get_baseName,
552 domfrag_transformNodeToObject
555 IUnknown* create_doc_fragment( xmlNodePtr fragment )
559 This = heap_alloc( sizeof *This );
563 This->lpVtbl = &domfrag_vtbl;
566 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->lpVtbl, NULL);
568 return (IUnknown*) &This->lpVtbl;