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
42 const struct IXMLDOMDocumentFragmentVtbl *lpVtbl;
48 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
50 return (domfrag *)((char*)iface - FIELD_OFFSET(domfrag, lpVtbl));
53 static HRESULT WINAPI domfrag_QueryInterface(
54 IXMLDOMDocumentFragment *iface,
58 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
59 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
61 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
62 IsEqualGUID( riid, &IID_IDispatch ) ||
63 IsEqualGUID( riid, &IID_IUnknown ) )
67 else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
69 return IUnknown_QueryInterface(This->node_unk, riid, ppvObject);
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
77 IXMLDOMDocumentFragment_AddRef( iface );
82 static ULONG WINAPI domfrag_AddRef(
83 IXMLDOMDocumentFragment *iface )
85 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
86 return InterlockedIncrement( &This->ref );
89 static ULONG WINAPI domfrag_Release(
90 IXMLDOMDocumentFragment *iface )
92 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
95 ref = InterlockedDecrement( &This->ref );
98 IUnknown_Release( This->node_unk );
99 HeapFree( GetProcessHeap(), 0, This );
105 static HRESULT WINAPI domfrag_GetTypeInfoCount(
106 IXMLDOMDocumentFragment *iface,
109 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
111 TRACE("(%p)->(%p)\n", This, pctinfo);
118 static HRESULT WINAPI domfrag_GetTypeInfo(
119 IXMLDOMDocumentFragment *iface,
120 UINT iTInfo, LCID lcid,
121 ITypeInfo** ppTInfo )
123 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
126 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
128 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, 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 );
142 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
145 if(!rgszNames || cNames == 0 || !rgDispId)
148 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
151 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
152 ITypeInfo_Release(typeinfo);
158 static HRESULT WINAPI domfrag_Invoke(
159 IXMLDOMDocumentFragment *iface,
160 DISPID dispIdMember, REFIID riid, LCID lcid,
161 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
162 EXCEPINFO* pExcepInfo, UINT* puArgErr )
164 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
168 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
169 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
171 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
174 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
175 pVarResult, pExcepInfo, puArgErr);
176 ITypeInfo_Release(typeinfo);
182 static HRESULT WINAPI domfrag_get_nodeName(
183 IXMLDOMDocumentFragment *iface,
186 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
187 return IXMLDOMNode_get_nodeName( This->node, p );
190 static HRESULT WINAPI domfrag_get_nodeValue(
191 IXMLDOMDocumentFragment *iface,
194 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
195 return IXMLDOMNode_get_nodeValue( This->node, var1 );
198 static HRESULT WINAPI domfrag_put_nodeValue(
199 IXMLDOMDocumentFragment *iface,
202 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
203 return IXMLDOMNode_put_nodeValue( This->node, var1 );
206 static HRESULT WINAPI domfrag_get_nodeType(
207 IXMLDOMDocumentFragment *iface,
208 DOMNodeType* domNodeType )
210 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
211 return IXMLDOMNode_get_nodeType( This->node, domNodeType );
214 static HRESULT WINAPI domfrag_get_parentNode(
215 IXMLDOMDocumentFragment *iface,
216 IXMLDOMNode** parent )
218 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
219 return IXMLDOMNode_get_parentNode( This->node, parent );
222 static HRESULT WINAPI domfrag_get_childNodes(
223 IXMLDOMDocumentFragment *iface,
224 IXMLDOMNodeList** outList)
226 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
227 return IXMLDOMNode_get_childNodes( This->node, outList );
230 static HRESULT WINAPI domfrag_get_firstChild(
231 IXMLDOMDocumentFragment *iface,
232 IXMLDOMNode** domNode)
234 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
235 return IXMLDOMNode_get_firstChild( This->node, domNode );
238 static HRESULT WINAPI domfrag_get_lastChild(
239 IXMLDOMDocumentFragment *iface,
240 IXMLDOMNode** domNode)
242 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
243 return IXMLDOMNode_get_lastChild( This->node, domNode );
246 static HRESULT WINAPI domfrag_get_previousSibling(
247 IXMLDOMDocumentFragment *iface,
248 IXMLDOMNode** domNode)
250 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
251 return IXMLDOMNode_get_previousSibling( This->node, domNode );
254 static HRESULT WINAPI domfrag_get_nextSibling(
255 IXMLDOMDocumentFragment *iface,
256 IXMLDOMNode** domNode)
258 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
259 return IXMLDOMNode_get_nextSibling( This->node, domNode );
262 static HRESULT WINAPI domfrag_get_attributes(
263 IXMLDOMDocumentFragment *iface,
264 IXMLDOMNamedNodeMap** attributeMap)
266 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
267 return IXMLDOMNode_get_attributes( This->node, attributeMap );
270 static HRESULT WINAPI domfrag_insertBefore(
271 IXMLDOMDocumentFragment *iface,
272 IXMLDOMNode* newNode, VARIANT var1,
273 IXMLDOMNode** outOldNode)
275 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
276 return IXMLDOMNode_insertBefore( This->node, newNode, var1, outOldNode );
279 static HRESULT WINAPI domfrag_replaceChild(
280 IXMLDOMDocumentFragment *iface,
281 IXMLDOMNode* newNode,
282 IXMLDOMNode* oldNode,
283 IXMLDOMNode** outOldNode)
285 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
286 return IXMLDOMNode_replaceChild( This->node, newNode, oldNode, outOldNode );
289 static HRESULT WINAPI domfrag_removeChild(
290 IXMLDOMDocumentFragment *iface,
291 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
293 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
294 return IXMLDOMNode_removeChild( This->node, domNode, oldNode );
297 static HRESULT WINAPI domfrag_appendChild(
298 IXMLDOMDocumentFragment *iface,
299 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
301 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
302 return IXMLDOMNode_appendChild( This->node, newNode, outNewNode );
305 static HRESULT WINAPI domfrag_hasChildNodes(
306 IXMLDOMDocumentFragment *iface,
309 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
310 return IXMLDOMNode_hasChildNodes( This->node, pbool );
313 static HRESULT WINAPI domfrag_get_ownerDocument(
314 IXMLDOMDocumentFragment *iface,
315 IXMLDOMDocument** domDocument)
317 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
318 return IXMLDOMNode_get_ownerDocument( This->node, domDocument );
321 static HRESULT WINAPI domfrag_cloneNode(
322 IXMLDOMDocumentFragment *iface,
323 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
325 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
326 return IXMLDOMNode_cloneNode( This->node, pbool, outNode );
329 static HRESULT WINAPI domfrag_get_nodeTypeString(
330 IXMLDOMDocumentFragment *iface,
333 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
334 return IXMLDOMNode_get_nodeTypeString( This->node, p );
337 static HRESULT WINAPI domfrag_get_text(
338 IXMLDOMDocumentFragment *iface,
341 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
342 return IXMLDOMNode_get_text( This->node, p );
345 static HRESULT WINAPI domfrag_put_text(
346 IXMLDOMDocumentFragment *iface,
349 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
350 return IXMLDOMNode_put_text( This->node, p );
353 static HRESULT WINAPI domfrag_get_specified(
354 IXMLDOMDocumentFragment *iface,
357 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
358 return IXMLDOMNode_get_specified( This->node, pbool );
361 static HRESULT WINAPI domfrag_get_definition(
362 IXMLDOMDocumentFragment *iface,
363 IXMLDOMNode** domNode)
365 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
366 return IXMLDOMNode_get_definition( This->node, domNode );
369 static HRESULT WINAPI domfrag_get_nodeTypedValue(
370 IXMLDOMDocumentFragment *iface,
373 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
374 return IXMLDOMNode_get_nodeTypedValue( This->node, var1 );
377 static HRESULT WINAPI domfrag_put_nodeTypedValue(
378 IXMLDOMDocumentFragment *iface,
381 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
382 return IXMLDOMNode_put_nodeTypedValue( This->node, var1 );
385 static HRESULT WINAPI domfrag_get_dataType(
386 IXMLDOMDocumentFragment *iface,
389 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
390 return IXMLDOMNode_get_dataType( This->node, var1 );
393 static HRESULT WINAPI domfrag_put_dataType(
394 IXMLDOMDocumentFragment *iface,
397 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
398 return IXMLDOMNode_put_dataType( This->node, p );
401 static HRESULT WINAPI domfrag_get_xml(
402 IXMLDOMDocumentFragment *iface,
405 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
406 return IXMLDOMNode_get_xml( This->node, p );
409 static HRESULT WINAPI domfrag_transformNode(
410 IXMLDOMDocumentFragment *iface,
411 IXMLDOMNode* domNode, BSTR* p)
413 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
414 return IXMLDOMNode_transformNode( This->node, domNode, p );
417 static HRESULT WINAPI domfrag_selectNodes(
418 IXMLDOMDocumentFragment *iface,
419 BSTR p, IXMLDOMNodeList** outList)
421 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
422 return IXMLDOMNode_selectNodes( This->node, p, outList );
425 static HRESULT WINAPI domfrag_selectSingleNode(
426 IXMLDOMDocumentFragment *iface,
427 BSTR p, IXMLDOMNode** outNode)
429 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
430 return IXMLDOMNode_selectSingleNode( This->node, p, outNode );
433 static HRESULT WINAPI domfrag_get_parsed(
434 IXMLDOMDocumentFragment *iface,
437 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
438 return IXMLDOMNode_get_parsed( This->node, pbool );
441 static HRESULT WINAPI domfrag_get_namespaceURI(
442 IXMLDOMDocumentFragment *iface,
445 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
446 return IXMLDOMNode_get_namespaceURI( This->node, p );
449 static HRESULT WINAPI domfrag_get_prefix(
450 IXMLDOMDocumentFragment *iface,
453 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
454 return IXMLDOMNode_get_prefix( This->node, p );
457 static HRESULT WINAPI domfrag_get_baseName(
458 IXMLDOMDocumentFragment *iface,
461 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
462 return IXMLDOMNode_get_baseName( This->node, p );
465 static HRESULT WINAPI domfrag_transformNodeToObject(
466 IXMLDOMDocumentFragment *iface,
467 IXMLDOMNode* domNode, VARIANT var1)
469 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
470 return IXMLDOMNode_transformNodeToObject( This->node, domNode, var1 );
473 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
475 domfrag_QueryInterface,
478 domfrag_GetTypeInfoCount,
480 domfrag_GetIDsOfNames,
482 domfrag_get_nodeName,
483 domfrag_get_nodeValue,
484 domfrag_put_nodeValue,
485 domfrag_get_nodeType,
486 domfrag_get_parentNode,
487 domfrag_get_childNodes,
488 domfrag_get_firstChild,
489 domfrag_get_lastChild,
490 domfrag_get_previousSibling,
491 domfrag_get_nextSibling,
492 domfrag_get_attributes,
493 domfrag_insertBefore,
494 domfrag_replaceChild,
497 domfrag_hasChildNodes,
498 domfrag_get_ownerDocument,
500 domfrag_get_nodeTypeString,
503 domfrag_get_specified,
504 domfrag_get_definition,
505 domfrag_get_nodeTypedValue,
506 domfrag_put_nodeTypedValue,
507 domfrag_get_dataType,
508 domfrag_put_dataType,
510 domfrag_transformNode,
512 domfrag_selectSingleNode,
514 domfrag_get_namespaceURI,
516 domfrag_get_baseName,
517 domfrag_transformNodeToObject
520 IUnknown* create_doc_fragment( xmlNodePtr fragment )
525 This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
529 This->lpVtbl = &domfrag_vtbl;
532 node = create_basic_node( fragment, (IUnknown*)&This->lpVtbl );
535 HeapFree(GetProcessHeap(), 0, This);
539 This->node_unk = (IUnknown*)&node->lpInternalUnkVtbl;
540 This->node = IXMLDOMNode_from_impl(node);
542 return (IUnknown*) &This->lpVtbl;