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_IDispatch
) ||
62 IsEqualGUID( riid
, &IID_IUnknown
) )
66 else if ( IsEqualGUID( riid
, &IID_IXMLDOMNode
) )
68 *ppvObject
= IXMLDOMNode_from_impl(&This
->node
);
72 FIXME("Unsupported interface %s\n", debugstr_guid(riid
));
76 IXMLDOMText_AddRef((IUnknown
*)*ppvObject
);
80 static ULONG WINAPI
domfrag_AddRef(
81 IXMLDOMDocumentFragment
*iface
)
83 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
84 return InterlockedIncrement( &This
->ref
);
87 static ULONG WINAPI
domfrag_Release(
88 IXMLDOMDocumentFragment
*iface
)
90 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
93 ref
= InterlockedDecrement( &This
->ref
);
96 destroy_xmlnode(&This
->node
);
97 HeapFree( GetProcessHeap(), 0, This
);
103 static HRESULT WINAPI
domfrag_GetTypeInfoCount(
104 IXMLDOMDocumentFragment
*iface
,
107 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
109 TRACE("(%p)->(%p)\n", This
, pctinfo
);
116 static HRESULT WINAPI
domfrag_GetTypeInfo(
117 IXMLDOMDocumentFragment
*iface
,
118 UINT iTInfo
, LCID lcid
,
119 ITypeInfo
** ppTInfo
)
121 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
124 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
126 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, ppTInfo
);
131 static HRESULT WINAPI
domfrag_GetIDsOfNames(
132 IXMLDOMDocumentFragment
*iface
,
133 REFIID riid
, LPOLESTR
* rgszNames
,
134 UINT cNames
, LCID lcid
, DISPID
* rgDispId
)
136 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
140 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
143 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
146 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, &typeinfo
);
149 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
150 ITypeInfo_Release(typeinfo
);
156 static HRESULT WINAPI
domfrag_Invoke(
157 IXMLDOMDocumentFragment
*iface
,
158 DISPID dispIdMember
, REFIID riid
, LCID lcid
,
159 WORD wFlags
, DISPPARAMS
* pDispParams
, VARIANT
* pVarResult
,
160 EXCEPINFO
* pExcepInfo
, UINT
* puArgErr
)
162 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
166 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
167 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
169 hr
= get_typeinfo(IXMLDOMDocumentFragment_tid
, &typeinfo
);
172 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVtbl
), dispIdMember
, wFlags
, pDispParams
,
173 pVarResult
, pExcepInfo
, puArgErr
);
174 ITypeInfo_Release(typeinfo
);
180 static HRESULT WINAPI
domfrag_get_nodeName(
181 IXMLDOMDocumentFragment
*iface
,
184 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
185 return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This
->node
), p
);
188 static HRESULT WINAPI
domfrag_get_nodeValue(
189 IXMLDOMDocumentFragment
*iface
,
192 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
193 return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
196 static HRESULT WINAPI
domfrag_put_nodeValue(
197 IXMLDOMDocumentFragment
*iface
,
200 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
201 return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
204 static HRESULT WINAPI
domfrag_get_nodeType(
205 IXMLDOMDocumentFragment
*iface
,
206 DOMNodeType
* domNodeType
)
208 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
209 return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This
->node
), domNodeType
);
212 static HRESULT WINAPI
domfrag_get_parentNode(
213 IXMLDOMDocumentFragment
*iface
,
214 IXMLDOMNode
** parent
)
216 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
217 return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This
->node
), parent
);
220 static HRESULT WINAPI
domfrag_get_childNodes(
221 IXMLDOMDocumentFragment
*iface
,
222 IXMLDOMNodeList
** outList
)
224 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
225 return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This
->node
), outList
);
228 static HRESULT WINAPI
domfrag_get_firstChild(
229 IXMLDOMDocumentFragment
*iface
,
230 IXMLDOMNode
** domNode
)
232 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
233 return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This
->node
), domNode
);
236 static HRESULT WINAPI
domfrag_get_lastChild(
237 IXMLDOMDocumentFragment
*iface
,
238 IXMLDOMNode
** domNode
)
240 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
241 return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This
->node
), domNode
);
244 static HRESULT WINAPI
domfrag_get_previousSibling(
245 IXMLDOMDocumentFragment
*iface
,
246 IXMLDOMNode
** domNode
)
248 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
249 return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This
->node
), domNode
);
252 static HRESULT WINAPI
domfrag_get_nextSibling(
253 IXMLDOMDocumentFragment
*iface
,
254 IXMLDOMNode
** domNode
)
256 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
257 return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This
->node
), domNode
);
260 static HRESULT WINAPI
domfrag_get_attributes(
261 IXMLDOMDocumentFragment
*iface
,
262 IXMLDOMNamedNodeMap
** attributeMap
)
264 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
265 return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This
->node
), attributeMap
);
268 static HRESULT WINAPI
domfrag_insertBefore(
269 IXMLDOMDocumentFragment
*iface
,
270 IXMLDOMNode
* newNode
, VARIANT var1
,
271 IXMLDOMNode
** outOldNode
)
273 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
274 return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This
->node
), newNode
, var1
, outOldNode
);
277 static HRESULT WINAPI
domfrag_replaceChild(
278 IXMLDOMDocumentFragment
*iface
,
279 IXMLDOMNode
* newNode
,
280 IXMLDOMNode
* oldNode
,
281 IXMLDOMNode
** outOldNode
)
283 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
284 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, oldNode
, outOldNode
);
287 static HRESULT WINAPI
domfrag_removeChild(
288 IXMLDOMDocumentFragment
*iface
,
289 IXMLDOMNode
* domNode
, IXMLDOMNode
** oldNode
)
291 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
292 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This
->node
), domNode
, oldNode
);
295 static HRESULT WINAPI
domfrag_appendChild(
296 IXMLDOMDocumentFragment
*iface
,
297 IXMLDOMNode
* newNode
, IXMLDOMNode
** outNewNode
)
299 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
300 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This
->node
), newNode
, outNewNode
);
303 static HRESULT WINAPI
domfrag_hasChildNodes(
304 IXMLDOMDocumentFragment
*iface
,
307 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
308 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This
->node
), pbool
);
311 static HRESULT WINAPI
domfrag_get_ownerDocument(
312 IXMLDOMDocumentFragment
*iface
,
313 IXMLDOMDocument
** domDocument
)
315 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
316 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This
->node
), domDocument
);
319 static HRESULT WINAPI
domfrag_cloneNode(
320 IXMLDOMDocumentFragment
*iface
,
321 VARIANT_BOOL pbool
, IXMLDOMNode
** outNode
)
323 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
324 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This
->node
), pbool
, outNode
);
327 static HRESULT WINAPI
domfrag_get_nodeTypeString(
328 IXMLDOMDocumentFragment
*iface
,
331 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
332 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This
->node
), p
);
335 static HRESULT WINAPI
domfrag_get_text(
336 IXMLDOMDocumentFragment
*iface
,
339 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
340 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This
->node
), p
);
343 static HRESULT WINAPI
domfrag_put_text(
344 IXMLDOMDocumentFragment
*iface
,
347 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
348 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This
->node
), p
);
351 static HRESULT WINAPI
domfrag_get_specified(
352 IXMLDOMDocumentFragment
*iface
,
355 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
356 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This
->node
), pbool
);
359 static HRESULT WINAPI
domfrag_get_definition(
360 IXMLDOMDocumentFragment
*iface
,
361 IXMLDOMNode
** domNode
)
363 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
364 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This
->node
), domNode
);
367 static HRESULT WINAPI
domfrag_get_nodeTypedValue(
368 IXMLDOMDocumentFragment
*iface
,
371 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
372 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
375 static HRESULT WINAPI
domfrag_put_nodeTypedValue(
376 IXMLDOMDocumentFragment
*iface
,
379 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
380 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This
->node
), var1
);
383 static HRESULT WINAPI
domfrag_get_dataType(
384 IXMLDOMDocumentFragment
*iface
,
387 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
388 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This
->node
), var1
);
391 static HRESULT WINAPI
domfrag_put_dataType(
392 IXMLDOMDocumentFragment
*iface
,
395 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
396 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This
->node
), p
);
399 static HRESULT WINAPI
domfrag_get_xml(
400 IXMLDOMDocumentFragment
*iface
,
403 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
404 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This
->node
), p
);
407 static HRESULT WINAPI
domfrag_transformNode(
408 IXMLDOMDocumentFragment
*iface
,
409 IXMLDOMNode
* domNode
, BSTR
* p
)
411 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
412 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This
->node
), domNode
, p
);
415 static HRESULT WINAPI
domfrag_selectNodes(
416 IXMLDOMDocumentFragment
*iface
,
417 BSTR p
, IXMLDOMNodeList
** outList
)
419 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
420 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This
->node
), p
, outList
);
423 static HRESULT WINAPI
domfrag_selectSingleNode(
424 IXMLDOMDocumentFragment
*iface
,
425 BSTR p
, IXMLDOMNode
** outNode
)
427 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
428 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This
->node
), p
, outNode
);
431 static HRESULT WINAPI
domfrag_get_parsed(
432 IXMLDOMDocumentFragment
*iface
,
435 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
436 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This
->node
), pbool
);
439 static HRESULT WINAPI
domfrag_get_namespaceURI(
440 IXMLDOMDocumentFragment
*iface
,
443 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
444 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This
->node
), p
);
447 static HRESULT WINAPI
domfrag_get_prefix(
448 IXMLDOMDocumentFragment
*iface
,
451 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
452 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This
->node
), p
);
455 static HRESULT WINAPI
domfrag_get_baseName(
456 IXMLDOMDocumentFragment
*iface
,
459 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
460 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This
->node
), p
);
463 static HRESULT WINAPI
domfrag_transformNodeToObject(
464 IXMLDOMDocumentFragment
*iface
,
465 IXMLDOMNode
* domNode
, VARIANT var1
)
467 domfrag
*This
= impl_from_IXMLDOMDocumentFragment( iface
);
468 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This
->node
), domNode
, var1
);
471 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl
=
473 domfrag_QueryInterface
,
476 domfrag_GetTypeInfoCount
,
478 domfrag_GetIDsOfNames
,
480 domfrag_get_nodeName
,
481 domfrag_get_nodeValue
,
482 domfrag_put_nodeValue
,
483 domfrag_get_nodeType
,
484 domfrag_get_parentNode
,
485 domfrag_get_childNodes
,
486 domfrag_get_firstChild
,
487 domfrag_get_lastChild
,
488 domfrag_get_previousSibling
,
489 domfrag_get_nextSibling
,
490 domfrag_get_attributes
,
491 domfrag_insertBefore
,
492 domfrag_replaceChild
,
495 domfrag_hasChildNodes
,
496 domfrag_get_ownerDocument
,
498 domfrag_get_nodeTypeString
,
501 domfrag_get_specified
,
502 domfrag_get_definition
,
503 domfrag_get_nodeTypedValue
,
504 domfrag_put_nodeTypedValue
,
505 domfrag_get_dataType
,
506 domfrag_put_dataType
,
508 domfrag_transformNode
,
510 domfrag_selectSingleNode
,
512 domfrag_get_namespaceURI
,
514 domfrag_get_baseName
,
515 domfrag_transformNodeToObject
518 IUnknown
* create_doc_fragment( xmlNodePtr fragment
)
522 This
= HeapAlloc( GetProcessHeap(), 0, sizeof *This
);
526 This
->lpVtbl
= &domfrag_vtbl
;
529 init_xmlnode(&This
->node
, fragment
, (IUnknown
*)&This
->lpVtbl
, NULL
);
531 return (IUnknown
*) &This
->lpVtbl
;