wined3d: Get rid of the WINED3DADAPTER_IDENTIFIER typedef.
[wine/multimedia.git] / dlls / msxml3 / docfrag.c
blob0821ba97945dc0f18b159acda35b195b710ad5a3
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 #ifdef HAVE_LIBXML2
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 #endif
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43 #ifdef HAVE_LIBXML2
45 typedef struct _domfrag
47 xmlnode node;
48 IXMLDOMDocumentFragment IXMLDOMDocumentFragment_iface;
49 LONG ref;
50 } domfrag;
52 static const tid_t domfrag_se_tids[] = {
53 IXMLDOMNode_tid,
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,
65 REFIID riid,
66 void** ppvObject )
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 ) )
76 *ppvObject = iface;
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);
86 else
88 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
89 *ppvObject = NULL;
90 return E_NOINTERFACE;
93 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
94 return S_OK;
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);
103 return 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);
113 if ( ref == 0 )
115 destroy_xmlnode(&This->node);
116 heap_free( This );
119 return ref;
122 static HRESULT WINAPI domfrag_GetTypeInfoCount(
123 IXMLDOMDocumentFragment *iface,
124 UINT* pctinfo )
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,
163 BSTR* p )
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,
177 VARIANT* value)
179 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
181 FIXME("(%p)->(%p)\n", This, value);
183 if(!value)
184 return E_INVALIDARG;
186 V_VT(value) = VT_NULL;
187 return S_FALSE;
190 static HRESULT WINAPI domfrag_put_nodeValue(
191 IXMLDOMDocumentFragment *iface,
192 VARIANT value)
194 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
195 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
196 return E_FAIL;
199 static HRESULT WINAPI domfrag_get_nodeType(
200 IXMLDOMDocumentFragment *iface,
201 DOMNodeType* domNodeType )
203 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
205 TRACE("(%p)->(%p)\n", This, domNodeType);
207 *domNodeType = NODE_DOCUMENT_FRAGMENT;
208 return S_OK;
211 static HRESULT WINAPI domfrag_get_parentNode(
212 IXMLDOMDocumentFragment *iface,
213 IXMLDOMNode** parent )
215 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
217 TRACE("(%p)->(%p)\n", This, parent);
219 return node_get_parent(&This->node, parent);
222 static HRESULT WINAPI domfrag_get_childNodes(
223 IXMLDOMDocumentFragment *iface,
224 IXMLDOMNodeList** outList)
226 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
228 TRACE("(%p)->(%p)\n", This, outList);
230 return node_get_child_nodes(&This->node, outList);
233 static HRESULT WINAPI domfrag_get_firstChild(
234 IXMLDOMDocumentFragment *iface,
235 IXMLDOMNode** domNode)
237 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
239 TRACE("(%p)->(%p)\n", This, domNode);
241 return node_get_first_child(&This->node, domNode);
244 static HRESULT WINAPI domfrag_get_lastChild(
245 IXMLDOMDocumentFragment *iface,
246 IXMLDOMNode** domNode)
248 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
250 TRACE("(%p)->(%p)\n", This, domNode);
252 return node_get_last_child(&This->node, domNode);
255 static HRESULT WINAPI domfrag_get_previousSibling(
256 IXMLDOMDocumentFragment *iface,
257 IXMLDOMNode** domNode)
259 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
261 TRACE("(%p)->(%p)\n", This, domNode);
263 return return_null_node(domNode);
266 static HRESULT WINAPI domfrag_get_nextSibling(
267 IXMLDOMDocumentFragment *iface,
268 IXMLDOMNode** domNode)
270 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
272 TRACE("(%p)->(%p)\n", This, domNode);
274 return return_null_node(domNode);
277 static HRESULT WINAPI domfrag_get_attributes(
278 IXMLDOMDocumentFragment *iface,
279 IXMLDOMNamedNodeMap** attributeMap)
281 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
283 TRACE("(%p)->(%p)\n", This, attributeMap);
285 return return_null_ptr((void**)attributeMap);
288 static HRESULT WINAPI domfrag_insertBefore(
289 IXMLDOMDocumentFragment *iface,
290 IXMLDOMNode* newNode, VARIANT refChild,
291 IXMLDOMNode** outOldNode)
293 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
295 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
297 /* TODO: test */
298 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
301 static HRESULT WINAPI domfrag_replaceChild(
302 IXMLDOMDocumentFragment *iface,
303 IXMLDOMNode* newNode,
304 IXMLDOMNode* oldNode,
305 IXMLDOMNode** outOldNode)
307 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
309 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
311 /* TODO: test */
312 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
315 static HRESULT WINAPI domfrag_removeChild(
316 IXMLDOMDocumentFragment *iface,
317 IXMLDOMNode *child, IXMLDOMNode **oldChild)
319 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
320 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
321 return node_remove_child(&This->node, child, oldChild);
324 static HRESULT WINAPI domfrag_appendChild(
325 IXMLDOMDocumentFragment *iface,
326 IXMLDOMNode *child, IXMLDOMNode **outChild)
328 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
329 TRACE("(%p)->(%p %p)\n", This, child, outChild);
330 return node_append_child(&This->node, child, outChild);
333 static HRESULT WINAPI domfrag_hasChildNodes(
334 IXMLDOMDocumentFragment *iface,
335 VARIANT_BOOL *ret)
337 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
338 TRACE("(%p)->(%p)\n", This, ret);
339 return node_has_childnodes(&This->node, ret);
342 static HRESULT WINAPI domfrag_get_ownerDocument(
343 IXMLDOMDocumentFragment *iface,
344 IXMLDOMDocument **doc)
346 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
347 TRACE("(%p)->(%p)\n", This, doc);
348 return node_get_owner_doc(&This->node, doc);
351 static HRESULT WINAPI domfrag_cloneNode(
352 IXMLDOMDocumentFragment *iface,
353 VARIANT_BOOL deep, IXMLDOMNode** outNode)
355 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
356 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
357 return node_clone( &This->node, deep, outNode );
360 static HRESULT WINAPI domfrag_get_nodeTypeString(
361 IXMLDOMDocumentFragment *iface,
362 BSTR* p)
364 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
365 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
367 TRACE("(%p)->(%p)\n", This, p);
369 return return_bstr(documentfragmentW, p);
372 static HRESULT WINAPI domfrag_get_text(
373 IXMLDOMDocumentFragment *iface,
374 BSTR* p)
376 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
377 TRACE("(%p)->(%p)\n", This, p);
378 return node_get_text(&This->node, p);
381 static HRESULT WINAPI domfrag_put_text(
382 IXMLDOMDocumentFragment *iface,
383 BSTR p)
385 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
386 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
387 return node_put_text( &This->node, p );
390 static HRESULT WINAPI domfrag_get_specified(
391 IXMLDOMDocumentFragment *iface,
392 VARIANT_BOOL* isSpecified)
394 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
395 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
396 *isSpecified = VARIANT_TRUE;
397 return S_OK;
400 static HRESULT WINAPI domfrag_get_definition(
401 IXMLDOMDocumentFragment *iface,
402 IXMLDOMNode** definitionNode)
404 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
405 FIXME("(%p)->(%p)\n", This, definitionNode);
406 return E_NOTIMPL;
409 static HRESULT WINAPI domfrag_get_nodeTypedValue(
410 IXMLDOMDocumentFragment *iface,
411 VARIANT *v)
413 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
414 TRACE("(%p)->(%p)\n", This, v);
415 return return_null_var(v);
418 static HRESULT WINAPI domfrag_put_nodeTypedValue(
419 IXMLDOMDocumentFragment *iface,
420 VARIANT typedValue)
422 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
423 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
424 return E_NOTIMPL;
427 static HRESULT WINAPI domfrag_get_dataType(
428 IXMLDOMDocumentFragment *iface,
429 VARIANT* typename)
431 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
432 TRACE("(%p)->(%p)\n", This, typename);
433 return return_null_var( typename );
436 static HRESULT WINAPI domfrag_put_dataType(
437 IXMLDOMDocumentFragment *iface,
438 BSTR p)
440 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
442 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
444 if(!p)
445 return E_INVALIDARG;
447 return E_FAIL;
450 static HRESULT WINAPI domfrag_get_xml(
451 IXMLDOMDocumentFragment *iface,
452 BSTR* p)
454 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
456 TRACE("(%p)->(%p)\n", This, p);
458 return node_get_xml(&This->node, FALSE, FALSE, p);
461 static HRESULT WINAPI domfrag_transformNode(
462 IXMLDOMDocumentFragment *iface,
463 IXMLDOMNode *node, BSTR *p)
465 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
466 TRACE("(%p)->(%p %p)\n", This, node, p);
467 return node_transform_node(&This->node, node, p);
470 static HRESULT WINAPI domfrag_selectNodes(
471 IXMLDOMDocumentFragment *iface,
472 BSTR p, IXMLDOMNodeList** outList)
474 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
475 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
476 return node_select_nodes(&This->node, p, outList);
479 static HRESULT WINAPI domfrag_selectSingleNode(
480 IXMLDOMDocumentFragment *iface,
481 BSTR p, IXMLDOMNode** outNode)
483 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
484 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
485 return node_select_singlenode(&This->node, p, outNode);
488 static HRESULT WINAPI domfrag_get_parsed(
489 IXMLDOMDocumentFragment *iface,
490 VARIANT_BOOL* isParsed)
492 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
493 FIXME("(%p)->(%p) stub!\n", This, isParsed);
494 *isParsed = VARIANT_TRUE;
495 return S_OK;
498 static HRESULT WINAPI domfrag_get_namespaceURI(
499 IXMLDOMDocumentFragment *iface,
500 BSTR* p)
502 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
503 TRACE("(%p)->(%p)\n", This, p);
504 return node_get_namespaceURI(&This->node, p);
507 static HRESULT WINAPI domfrag_get_prefix(
508 IXMLDOMDocumentFragment *iface,
509 BSTR* prefix)
511 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
512 TRACE("(%p)->(%p)\n", This, prefix);
513 return return_null_bstr( prefix );
516 static HRESULT WINAPI domfrag_get_baseName(
517 IXMLDOMDocumentFragment *iface,
518 BSTR* name)
520 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
521 FIXME("(%p)->(%p): needs test\n", This, name);
522 return return_null_bstr( name );
525 static HRESULT WINAPI domfrag_transformNodeToObject(
526 IXMLDOMDocumentFragment *iface,
527 IXMLDOMNode* domNode, VARIANT var1)
529 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
530 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
531 return E_NOTIMPL;
534 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
536 domfrag_QueryInterface,
537 domfrag_AddRef,
538 domfrag_Release,
539 domfrag_GetTypeInfoCount,
540 domfrag_GetTypeInfo,
541 domfrag_GetIDsOfNames,
542 domfrag_Invoke,
543 domfrag_get_nodeName,
544 domfrag_get_nodeValue,
545 domfrag_put_nodeValue,
546 domfrag_get_nodeType,
547 domfrag_get_parentNode,
548 domfrag_get_childNodes,
549 domfrag_get_firstChild,
550 domfrag_get_lastChild,
551 domfrag_get_previousSibling,
552 domfrag_get_nextSibling,
553 domfrag_get_attributes,
554 domfrag_insertBefore,
555 domfrag_replaceChild,
556 domfrag_removeChild,
557 domfrag_appendChild,
558 domfrag_hasChildNodes,
559 domfrag_get_ownerDocument,
560 domfrag_cloneNode,
561 domfrag_get_nodeTypeString,
562 domfrag_get_text,
563 domfrag_put_text,
564 domfrag_get_specified,
565 domfrag_get_definition,
566 domfrag_get_nodeTypedValue,
567 domfrag_put_nodeTypedValue,
568 domfrag_get_dataType,
569 domfrag_put_dataType,
570 domfrag_get_xml,
571 domfrag_transformNode,
572 domfrag_selectNodes,
573 domfrag_selectSingleNode,
574 domfrag_get_parsed,
575 domfrag_get_namespaceURI,
576 domfrag_get_prefix,
577 domfrag_get_baseName,
578 domfrag_transformNodeToObject
581 static const tid_t domfrag_iface_tids[] = {
582 IXMLDOMDocumentFragment_tid,
586 static dispex_static_data_t domfrag_dispex = {
587 NULL,
588 IXMLDOMDocumentFragment_tid,
589 NULL,
590 domfrag_iface_tids
593 IUnknown* create_doc_fragment( xmlNodePtr fragment )
595 domfrag *This;
597 This = heap_alloc( sizeof *This );
598 if ( !This )
599 return NULL;
601 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
602 This->ref = 1;
604 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, &domfrag_dispex);
606 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;
609 #endif