cmd: Fix a couple of issues with redirections.
[wine.git] / dlls / msxml3 / docfrag.c
blobc307b6751f92cb1a47ea5f88d640fc289407e875
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 <stdarg.h>
24 #include <libxml/parser.h>
25 #include <libxml/xmlerror.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "ole2.h"
31 #include "msxml6.h"
33 #include "msxml_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
39 typedef struct _domfrag
41 xmlnode node;
42 IXMLDOMDocumentFragment IXMLDOMDocumentFragment_iface;
43 LONG ref;
44 } domfrag;
46 static const tid_t domfrag_se_tids[] = {
47 IXMLDOMNode_tid,
48 IXMLDOMDocumentFragment_tid,
49 NULL_tid
52 static inline domfrag *impl_from_IXMLDOMDocumentFragment( IXMLDOMDocumentFragment *iface )
54 return CONTAINING_RECORD(iface, domfrag, IXMLDOMDocumentFragment_iface);
57 static HRESULT WINAPI domfrag_QueryInterface(
58 IXMLDOMDocumentFragment *iface,
59 REFIID riid,
60 void** ppvObject )
62 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
63 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
65 if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentFragment ) ||
66 IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
67 IsEqualGUID( riid, &IID_IDispatch ) ||
68 IsEqualGUID( riid, &IID_IUnknown ) )
70 *ppvObject = iface;
72 else if(node_query_interface(&This->node, riid, ppvObject))
74 return *ppvObject ? S_OK : E_NOINTERFACE;
76 else if(IsEqualGUID( riid, &IID_ISupportErrorInfo ))
78 return node_create_supporterrorinfo(domfrag_se_tids, ppvObject);
80 else
82 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
83 *ppvObject = NULL;
84 return E_NOINTERFACE;
87 IXMLDOMDocumentFragment_AddRef(iface);
88 return S_OK;
91 static ULONG WINAPI domfrag_AddRef(IXMLDOMDocumentFragment *iface)
93 domfrag *domfrag = impl_from_IXMLDOMDocumentFragment(iface);
94 ULONG ref = InterlockedIncrement(&domfrag->ref);
95 TRACE("%p, refcount %lu.\n", iface, ref);
96 return ref;
99 static ULONG WINAPI domfrag_Release(IXMLDOMDocumentFragment *iface)
101 domfrag *domfrag = impl_from_IXMLDOMDocumentFragment(iface);
102 ULONG ref = InterlockedDecrement(&domfrag->ref);
104 TRACE("%p, refcount %lu.\n", iface, ref);
106 if (!ref)
108 destroy_xmlnode(&domfrag->node);
109 free(domfrag);
112 return ref;
115 static HRESULT WINAPI domfrag_GetTypeInfoCount(
116 IXMLDOMDocumentFragment *iface,
117 UINT* pctinfo )
119 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
120 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
123 static HRESULT WINAPI domfrag_GetTypeInfo(
124 IXMLDOMDocumentFragment *iface,
125 UINT iTInfo, LCID lcid,
126 ITypeInfo** ppTInfo )
128 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
129 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface,
130 iTInfo, lcid, 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 );
139 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
140 riid, rgszNames, cNames, lcid, rgDispId);
143 static HRESULT WINAPI domfrag_Invoke(
144 IXMLDOMDocumentFragment *iface,
145 DISPID dispIdMember, REFIID riid, LCID lcid,
146 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
147 EXCEPINFO* pExcepInfo, UINT* puArgErr )
149 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
150 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
151 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
154 static HRESULT WINAPI domfrag_get_nodeName(
155 IXMLDOMDocumentFragment *iface,
156 BSTR* p )
158 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
160 static const WCHAR document_fragmentW[] =
161 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
163 TRACE("(%p)->(%p)\n", This, p);
165 return return_bstr(document_fragmentW, p);
168 static HRESULT WINAPI domfrag_get_nodeValue(
169 IXMLDOMDocumentFragment *iface,
170 VARIANT* value)
172 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
173 TRACE("(%p)->(%p)\n", This, value);
174 return return_null_var(value);
177 static HRESULT WINAPI domfrag_put_nodeValue(
178 IXMLDOMDocumentFragment *iface,
179 VARIANT value)
181 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
182 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
183 return E_FAIL;
186 static HRESULT WINAPI domfrag_get_nodeType(
187 IXMLDOMDocumentFragment *iface,
188 DOMNodeType* domNodeType )
190 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
192 TRACE("(%p)->(%p)\n", This, domNodeType);
194 *domNodeType = NODE_DOCUMENT_FRAGMENT;
195 return S_OK;
198 static HRESULT WINAPI domfrag_get_parentNode(
199 IXMLDOMDocumentFragment *iface,
200 IXMLDOMNode** parent )
202 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
204 TRACE("(%p)->(%p)\n", This, parent);
206 return node_get_parent(&This->node, parent);
209 static HRESULT WINAPI domfrag_get_childNodes(
210 IXMLDOMDocumentFragment *iface,
211 IXMLDOMNodeList** outList)
213 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
215 TRACE("(%p)->(%p)\n", This, outList);
217 return node_get_child_nodes(&This->node, outList);
220 static HRESULT WINAPI domfrag_get_firstChild(
221 IXMLDOMDocumentFragment *iface,
222 IXMLDOMNode** domNode)
224 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
226 TRACE("(%p)->(%p)\n", This, domNode);
228 return node_get_first_child(&This->node, domNode);
231 static HRESULT WINAPI domfrag_get_lastChild(
232 IXMLDOMDocumentFragment *iface,
233 IXMLDOMNode** domNode)
235 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
237 TRACE("(%p)->(%p)\n", This, domNode);
239 return node_get_last_child(&This->node, domNode);
242 static HRESULT WINAPI domfrag_get_previousSibling(
243 IXMLDOMDocumentFragment *iface,
244 IXMLDOMNode** domNode)
246 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
248 TRACE("(%p)->(%p)\n", This, domNode);
250 return return_null_node(domNode);
253 static HRESULT WINAPI domfrag_get_nextSibling(
254 IXMLDOMDocumentFragment *iface,
255 IXMLDOMNode** domNode)
257 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
259 TRACE("(%p)->(%p)\n", This, domNode);
261 return return_null_node(domNode);
264 static HRESULT WINAPI domfrag_get_attributes(
265 IXMLDOMDocumentFragment *iface,
266 IXMLDOMNamedNodeMap** attributeMap)
268 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
270 TRACE("(%p)->(%p)\n", This, attributeMap);
272 return return_null_ptr((void**)attributeMap);
275 static HRESULT WINAPI domfrag_insertBefore(
276 IXMLDOMDocumentFragment *iface,
277 IXMLDOMNode* newNode, VARIANT refChild,
278 IXMLDOMNode** outOldNode)
280 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
282 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
284 /* TODO: test */
285 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
288 static HRESULT WINAPI domfrag_replaceChild(
289 IXMLDOMDocumentFragment *iface,
290 IXMLDOMNode* newNode,
291 IXMLDOMNode* oldNode,
292 IXMLDOMNode** outOldNode)
294 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
296 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
298 /* TODO: test */
299 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
302 static HRESULT WINAPI domfrag_removeChild(
303 IXMLDOMDocumentFragment *iface,
304 IXMLDOMNode *child, IXMLDOMNode **oldChild)
306 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
307 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
308 return node_remove_child(&This->node, child, oldChild);
311 static HRESULT WINAPI domfrag_appendChild(
312 IXMLDOMDocumentFragment *iface,
313 IXMLDOMNode *child, IXMLDOMNode **outChild)
315 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
316 TRACE("(%p)->(%p %p)\n", This, child, outChild);
317 return node_append_child(&This->node, child, outChild);
320 static HRESULT WINAPI domfrag_hasChildNodes(
321 IXMLDOMDocumentFragment *iface,
322 VARIANT_BOOL *ret)
324 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
325 TRACE("(%p)->(%p)\n", This, ret);
326 return node_has_childnodes(&This->node, ret);
329 static HRESULT WINAPI domfrag_get_ownerDocument(
330 IXMLDOMDocumentFragment *iface,
331 IXMLDOMDocument **doc)
333 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
334 TRACE("(%p)->(%p)\n", This, doc);
335 return node_get_owner_doc(&This->node, doc);
338 static HRESULT WINAPI domfrag_cloneNode(
339 IXMLDOMDocumentFragment *iface,
340 VARIANT_BOOL deep, IXMLDOMNode** outNode)
342 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
343 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
344 return node_clone( &This->node, deep, outNode );
347 static HRESULT WINAPI domfrag_get_nodeTypeString(
348 IXMLDOMDocumentFragment *iface,
349 BSTR* p)
351 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
352 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
354 TRACE("(%p)->(%p)\n", This, p);
356 return return_bstr(documentfragmentW, p);
359 static HRESULT WINAPI domfrag_get_text(
360 IXMLDOMDocumentFragment *iface,
361 BSTR* p)
363 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
364 TRACE("(%p)->(%p)\n", This, p);
365 return node_get_text(&This->node, p);
368 static HRESULT WINAPI domfrag_put_text(
369 IXMLDOMDocumentFragment *iface,
370 BSTR p)
372 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
373 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
374 return node_put_text( &This->node, p );
377 static HRESULT WINAPI domfrag_get_specified(
378 IXMLDOMDocumentFragment *iface,
379 VARIANT_BOOL* isSpecified)
381 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
382 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
383 *isSpecified = VARIANT_TRUE;
384 return S_OK;
387 static HRESULT WINAPI domfrag_get_definition(
388 IXMLDOMDocumentFragment *iface,
389 IXMLDOMNode** definitionNode)
391 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
392 FIXME("(%p)->(%p)\n", This, definitionNode);
393 return E_NOTIMPL;
396 static HRESULT WINAPI domfrag_get_nodeTypedValue(
397 IXMLDOMDocumentFragment *iface,
398 VARIANT *v)
400 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
401 TRACE("(%p)->(%p)\n", This, v);
402 return return_null_var(v);
405 static HRESULT WINAPI domfrag_put_nodeTypedValue(
406 IXMLDOMDocumentFragment *iface,
407 VARIANT typedValue)
409 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
410 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
411 return E_NOTIMPL;
414 static HRESULT WINAPI domfrag_get_dataType(
415 IXMLDOMDocumentFragment *iface,
416 VARIANT* typename)
418 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
419 TRACE("(%p)->(%p)\n", This, typename);
420 return return_null_var( typename );
423 static HRESULT WINAPI domfrag_put_dataType(
424 IXMLDOMDocumentFragment *iface,
425 BSTR p)
427 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
429 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
431 if(!p)
432 return E_INVALIDARG;
434 return E_FAIL;
437 static HRESULT WINAPI domfrag_get_xml(
438 IXMLDOMDocumentFragment *iface,
439 BSTR* p)
441 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
443 TRACE("(%p)->(%p)\n", This, p);
445 return node_get_xml(&This->node, FALSE, p);
448 static HRESULT WINAPI domfrag_transformNode(
449 IXMLDOMDocumentFragment *iface,
450 IXMLDOMNode *node, BSTR *p)
452 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
453 TRACE("(%p)->(%p %p)\n", This, node, p);
454 return node_transform_node(&This->node, node, p);
457 static HRESULT WINAPI domfrag_selectNodes(
458 IXMLDOMDocumentFragment *iface,
459 BSTR p, IXMLDOMNodeList** outList)
461 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
462 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
463 return node_select_nodes(&This->node, p, outList);
466 static HRESULT WINAPI domfrag_selectSingleNode(
467 IXMLDOMDocumentFragment *iface,
468 BSTR p, IXMLDOMNode** outNode)
470 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
471 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
472 return node_select_singlenode(&This->node, p, outNode);
475 static HRESULT WINAPI domfrag_get_parsed(
476 IXMLDOMDocumentFragment *iface,
477 VARIANT_BOOL* isParsed)
479 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
480 FIXME("(%p)->(%p) stub!\n", This, isParsed);
481 *isParsed = VARIANT_TRUE;
482 return S_OK;
485 static HRESULT WINAPI domfrag_get_namespaceURI(
486 IXMLDOMDocumentFragment *iface,
487 BSTR* p)
489 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
490 TRACE("(%p)->(%p)\n", This, p);
491 return node_get_namespaceURI(&This->node, p);
494 static HRESULT WINAPI domfrag_get_prefix(
495 IXMLDOMDocumentFragment *iface,
496 BSTR* prefix)
498 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
499 TRACE("(%p)->(%p)\n", This, prefix);
500 return return_null_bstr( prefix );
503 static HRESULT WINAPI domfrag_get_baseName(
504 IXMLDOMDocumentFragment *iface,
505 BSTR* name)
507 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
508 FIXME("(%p)->(%p): needs test\n", This, name);
509 return return_null_bstr( name );
512 static HRESULT WINAPI domfrag_transformNodeToObject(
513 IXMLDOMDocumentFragment *iface,
514 IXMLDOMNode* domNode, VARIANT var1)
516 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
517 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
518 return E_NOTIMPL;
521 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
523 domfrag_QueryInterface,
524 domfrag_AddRef,
525 domfrag_Release,
526 domfrag_GetTypeInfoCount,
527 domfrag_GetTypeInfo,
528 domfrag_GetIDsOfNames,
529 domfrag_Invoke,
530 domfrag_get_nodeName,
531 domfrag_get_nodeValue,
532 domfrag_put_nodeValue,
533 domfrag_get_nodeType,
534 domfrag_get_parentNode,
535 domfrag_get_childNodes,
536 domfrag_get_firstChild,
537 domfrag_get_lastChild,
538 domfrag_get_previousSibling,
539 domfrag_get_nextSibling,
540 domfrag_get_attributes,
541 domfrag_insertBefore,
542 domfrag_replaceChild,
543 domfrag_removeChild,
544 domfrag_appendChild,
545 domfrag_hasChildNodes,
546 domfrag_get_ownerDocument,
547 domfrag_cloneNode,
548 domfrag_get_nodeTypeString,
549 domfrag_get_text,
550 domfrag_put_text,
551 domfrag_get_specified,
552 domfrag_get_definition,
553 domfrag_get_nodeTypedValue,
554 domfrag_put_nodeTypedValue,
555 domfrag_get_dataType,
556 domfrag_put_dataType,
557 domfrag_get_xml,
558 domfrag_transformNode,
559 domfrag_selectNodes,
560 domfrag_selectSingleNode,
561 domfrag_get_parsed,
562 domfrag_get_namespaceURI,
563 domfrag_get_prefix,
564 domfrag_get_baseName,
565 domfrag_transformNodeToObject
568 static const tid_t domfrag_iface_tids[] = {
569 IXMLDOMDocumentFragment_tid,
573 static dispex_static_data_t domfrag_dispex = {
574 NULL,
575 IXMLDOMDocumentFragment_tid,
576 NULL,
577 domfrag_iface_tids
580 IUnknown* create_doc_fragment( xmlNodePtr fragment )
582 domfrag *This;
584 This = malloc(sizeof(*This));
585 if ( !This )
586 return NULL;
588 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
589 This->ref = 1;
591 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, &domfrag_dispex);
593 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;