shlwapi: Update Finnish translation.
[wine/multimedia.git] / dlls / msxml3 / docfrag.c
blob4a108ec3c1a7ba585a3181e5fa7e9964bfd392a8
1 /*
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
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "msxml6.h"
32 #include "msxml_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
38 #ifdef HAVE_LIBXML2
40 typedef struct _domfrag
42 xmlnode node;
43 const struct IXMLDOMDocumentFragmentVtbl *lpVtbl;
44 LONG ref;
45 } domfrag;
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,
54 REFIID riid,
55 void** ppvObject )
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 ) )
65 *ppvObject = iface;
67 else if(node_query_interface(&This->node, riid, ppvObject))
69 return *ppvObject ? S_OK : E_NOINTERFACE;
71 else
73 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
74 return E_NOINTERFACE;
77 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
78 return S_OK;
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 );
92 ULONG ref;
94 ref = InterlockedDecrement( &This->ref );
95 if ( ref == 0 )
97 destroy_xmlnode(&This->node);
98 heap_free( This );
101 return ref;
104 static HRESULT WINAPI domfrag_GetTypeInfoCount(
105 IXMLDOMDocumentFragment *iface,
106 UINT* pctinfo )
108 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
110 TRACE("(%p)->(%p)\n", This, pctinfo);
112 *pctinfo = 1;
114 return S_OK;
117 static HRESULT WINAPI domfrag_GetTypeInfo(
118 IXMLDOMDocumentFragment *iface,
119 UINT iTInfo, LCID lcid,
120 ITypeInfo** ppTInfo )
122 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
123 HRESULT hr;
125 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, ppTInfo);
129 return hr;
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 );
138 ITypeInfo *typeinfo;
139 HRESULT hr;
141 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
142 lcid, rgDispId);
144 if(!rgszNames || cNames == 0 || !rgDispId)
145 return E_INVALIDARG;
147 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
148 if(SUCCEEDED(hr))
150 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
151 ITypeInfo_Release(typeinfo);
154 return hr;
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 );
164 ITypeInfo *typeinfo;
165 HRESULT hr;
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);
171 if(SUCCEEDED(hr))
173 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
174 pVarResult, pExcepInfo, puArgErr);
175 ITypeInfo_Release(typeinfo);
178 return hr;
181 static HRESULT WINAPI domfrag_get_nodeName(
182 IXMLDOMDocumentFragment *iface,
183 BSTR* p )
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,
197 VARIANT* value)
199 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
201 FIXME("(%p)->(%p)\n", This, value);
203 if(!value)
204 return E_INVALIDARG;
206 V_VT(value) = VT_NULL;
207 return S_FALSE;
210 static HRESULT WINAPI domfrag_put_nodeValue(
211 IXMLDOMDocumentFragment *iface,
212 VARIANT value)
214 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
215 FIXME("(%p)->(v%d)\n", This, V_VT(&value));
216 return E_FAIL;
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;
228 return S_OK;
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 );
303 TRACE("(%p)->(%p)\n", This, attributeMap);
305 return return_null_ptr((void**)attributeMap);
308 static HRESULT WINAPI domfrag_insertBefore(
309 IXMLDOMDocumentFragment *iface,
310 IXMLDOMNode* newNode, VARIANT refChild,
311 IXMLDOMNode** outOldNode)
313 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
315 TRACE("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode);
317 /* TODO: test */
318 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
321 static HRESULT WINAPI domfrag_replaceChild(
322 IXMLDOMDocumentFragment *iface,
323 IXMLDOMNode* newNode,
324 IXMLDOMNode* oldNode,
325 IXMLDOMNode** outOldNode)
327 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
328 return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newNode, oldNode, outOldNode );
331 static HRESULT WINAPI domfrag_removeChild(
332 IXMLDOMDocumentFragment *iface,
333 IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
335 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
336 return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), domNode, oldNode );
339 static HRESULT WINAPI domfrag_appendChild(
340 IXMLDOMDocumentFragment *iface,
341 IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
343 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
344 return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newNode, outNewNode );
347 static HRESULT WINAPI domfrag_hasChildNodes(
348 IXMLDOMDocumentFragment *iface,
349 VARIANT_BOOL* pbool)
351 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
352 return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), pbool );
355 static HRESULT WINAPI domfrag_get_ownerDocument(
356 IXMLDOMDocumentFragment *iface,
357 IXMLDOMDocument** domDocument)
359 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
360 return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), domDocument );
363 static HRESULT WINAPI domfrag_cloneNode(
364 IXMLDOMDocumentFragment *iface,
365 VARIANT_BOOL pbool, IXMLDOMNode** outNode)
367 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
368 return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), pbool, outNode );
371 static HRESULT WINAPI domfrag_get_nodeTypeString(
372 IXMLDOMDocumentFragment *iface,
373 BSTR* p)
375 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
376 return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), p );
379 static HRESULT WINAPI domfrag_get_text(
380 IXMLDOMDocumentFragment *iface,
381 BSTR* p)
383 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
384 return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), p );
387 static HRESULT WINAPI domfrag_put_text(
388 IXMLDOMDocumentFragment *iface,
389 BSTR p)
391 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
392 return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), p );
395 static HRESULT WINAPI domfrag_get_specified(
396 IXMLDOMDocumentFragment *iface,
397 VARIANT_BOOL* pbool)
399 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
400 return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), pbool );
403 static HRESULT WINAPI domfrag_get_definition(
404 IXMLDOMDocumentFragment *iface,
405 IXMLDOMNode** domNode)
407 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
408 return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), domNode );
411 static HRESULT WINAPI domfrag_get_nodeTypedValue(
412 IXMLDOMDocumentFragment *iface,
413 VARIANT* var1)
415 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
416 return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
419 static HRESULT WINAPI domfrag_put_nodeTypedValue(
420 IXMLDOMDocumentFragment *iface,
421 VARIANT var1)
423 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
424 return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), var1 );
427 static HRESULT WINAPI domfrag_get_dataType(
428 IXMLDOMDocumentFragment *iface,
429 VARIANT* var1)
431 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
432 return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), var1 );
435 static HRESULT WINAPI domfrag_put_dataType(
436 IXMLDOMDocumentFragment *iface,
437 BSTR p)
439 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
440 return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), p );
443 static HRESULT WINAPI domfrag_get_xml(
444 IXMLDOMDocumentFragment *iface,
445 BSTR* p)
447 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
448 return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), p );
451 static HRESULT WINAPI domfrag_transformNode(
452 IXMLDOMDocumentFragment *iface,
453 IXMLDOMNode* domNode, BSTR* p)
455 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
456 return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), domNode, p );
459 static HRESULT WINAPI domfrag_selectNodes(
460 IXMLDOMDocumentFragment *iface,
461 BSTR p, IXMLDOMNodeList** outList)
463 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
464 return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), p, outList );
467 static HRESULT WINAPI domfrag_selectSingleNode(
468 IXMLDOMDocumentFragment *iface,
469 BSTR p, IXMLDOMNode** outNode)
471 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
472 return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), p, outNode );
475 static HRESULT WINAPI domfrag_get_parsed(
476 IXMLDOMDocumentFragment *iface,
477 VARIANT_BOOL* pbool)
479 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
480 return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), pbool );
483 static HRESULT WINAPI domfrag_get_namespaceURI(
484 IXMLDOMDocumentFragment *iface,
485 BSTR* p)
487 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
488 return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), p );
491 static HRESULT WINAPI domfrag_get_prefix(
492 IXMLDOMDocumentFragment *iface,
493 BSTR* p)
495 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
496 return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), p );
499 static HRESULT WINAPI domfrag_get_baseName(
500 IXMLDOMDocumentFragment *iface,
501 BSTR* p)
503 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
504 return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), p );
507 static HRESULT WINAPI domfrag_transformNodeToObject(
508 IXMLDOMDocumentFragment *iface,
509 IXMLDOMNode* domNode, VARIANT var1)
511 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
512 return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), domNode, var1 );
515 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
517 domfrag_QueryInterface,
518 domfrag_AddRef,
519 domfrag_Release,
520 domfrag_GetTypeInfoCount,
521 domfrag_GetTypeInfo,
522 domfrag_GetIDsOfNames,
523 domfrag_Invoke,
524 domfrag_get_nodeName,
525 domfrag_get_nodeValue,
526 domfrag_put_nodeValue,
527 domfrag_get_nodeType,
528 domfrag_get_parentNode,
529 domfrag_get_childNodes,
530 domfrag_get_firstChild,
531 domfrag_get_lastChild,
532 domfrag_get_previousSibling,
533 domfrag_get_nextSibling,
534 domfrag_get_attributes,
535 domfrag_insertBefore,
536 domfrag_replaceChild,
537 domfrag_removeChild,
538 domfrag_appendChild,
539 domfrag_hasChildNodes,
540 domfrag_get_ownerDocument,
541 domfrag_cloneNode,
542 domfrag_get_nodeTypeString,
543 domfrag_get_text,
544 domfrag_put_text,
545 domfrag_get_specified,
546 domfrag_get_definition,
547 domfrag_get_nodeTypedValue,
548 domfrag_put_nodeTypedValue,
549 domfrag_get_dataType,
550 domfrag_put_dataType,
551 domfrag_get_xml,
552 domfrag_transformNode,
553 domfrag_selectNodes,
554 domfrag_selectSingleNode,
555 domfrag_get_parsed,
556 domfrag_get_namespaceURI,
557 domfrag_get_prefix,
558 domfrag_get_baseName,
559 domfrag_transformNodeToObject
562 IUnknown* create_doc_fragment( xmlNodePtr fragment )
564 domfrag *This;
566 This = heap_alloc( sizeof *This );
567 if ( !This )
568 return NULL;
570 This->lpVtbl = &domfrag_vtbl;
571 This->ref = 1;
573 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->lpVtbl, NULL);
575 return (IUnknown*) &This->lpVtbl;
578 #endif