wineps: Fix a couple of typos in the path painting function.
[wine/testsucceed.git] / dlls / msxml3 / docfrag.c
blob892ed4b534e832f5343805018514347416223e17
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 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
78 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
79 *ppvObject = NULL;
80 return E_NOINTERFACE;
83 IXMLDOMText_AddRef((IUnknown*)*ppvObject);
84 return S_OK;
87 static ULONG WINAPI domfrag_AddRef(
88 IXMLDOMDocumentFragment *iface )
90 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
91 ULONG ref = InterlockedIncrement( &This->ref );
92 TRACE("(%p)->(%d)\n", This, ref);
93 return ref;
96 static ULONG WINAPI domfrag_Release(
97 IXMLDOMDocumentFragment *iface )
99 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
100 ULONG ref = InterlockedDecrement( &This->ref );
102 TRACE("(%p)->(%d)\n", This, ref);
103 if ( ref == 0 )
105 destroy_xmlnode(&This->node);
106 heap_free( This );
109 return ref;
112 static HRESULT WINAPI domfrag_GetTypeInfoCount(
113 IXMLDOMDocumentFragment *iface,
114 UINT* pctinfo )
116 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
118 TRACE("(%p)->(%p)\n", This, pctinfo);
120 *pctinfo = 1;
122 return S_OK;
125 static HRESULT WINAPI domfrag_GetTypeInfo(
126 IXMLDOMDocumentFragment *iface,
127 UINT iTInfo, LCID lcid,
128 ITypeInfo** ppTInfo )
130 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
131 HRESULT hr;
133 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
135 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, ppTInfo);
137 return hr;
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 ITypeInfo *typeinfo;
147 HRESULT hr;
149 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
150 lcid, rgDispId);
152 if(!rgszNames || cNames == 0 || !rgDispId)
153 return E_INVALIDARG;
155 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
156 if(SUCCEEDED(hr))
158 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
159 ITypeInfo_Release(typeinfo);
162 return hr;
165 static HRESULT WINAPI domfrag_Invoke(
166 IXMLDOMDocumentFragment *iface,
167 DISPID dispIdMember, REFIID riid, LCID lcid,
168 WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
169 EXCEPINFO* pExcepInfo, UINT* puArgErr )
171 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
172 ITypeInfo *typeinfo;
173 HRESULT hr;
175 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
176 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
178 hr = get_typeinfo(IXMLDOMDocumentFragment_tid, &typeinfo);
179 if(SUCCEEDED(hr))
181 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMDocumentFragment_iface, dispIdMember,
182 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
183 ITypeInfo_Release(typeinfo);
186 return hr;
189 static HRESULT WINAPI domfrag_get_nodeName(
190 IXMLDOMDocumentFragment *iface,
191 BSTR* p )
193 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
195 static const WCHAR document_fragmentW[] =
196 {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0};
198 TRACE("(%p)->(%p)\n", This, p);
200 return return_bstr(document_fragmentW, p);
203 static HRESULT WINAPI domfrag_get_nodeValue(
204 IXMLDOMDocumentFragment *iface,
205 VARIANT* value)
207 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
209 FIXME("(%p)->(%p)\n", This, value);
211 if(!value)
212 return E_INVALIDARG;
214 V_VT(value) = VT_NULL;
215 return S_FALSE;
218 static HRESULT WINAPI domfrag_put_nodeValue(
219 IXMLDOMDocumentFragment *iface,
220 VARIANT value)
222 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
223 TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
224 return E_FAIL;
227 static HRESULT WINAPI domfrag_get_nodeType(
228 IXMLDOMDocumentFragment *iface,
229 DOMNodeType* domNodeType )
231 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
233 TRACE("(%p)->(%p)\n", This, domNodeType);
235 *domNodeType = NODE_DOCUMENT_FRAGMENT;
236 return S_OK;
239 static HRESULT WINAPI domfrag_get_parentNode(
240 IXMLDOMDocumentFragment *iface,
241 IXMLDOMNode** parent )
243 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
245 TRACE("(%p)->(%p)\n", This, parent);
247 return node_get_parent(&This->node, parent);
250 static HRESULT WINAPI domfrag_get_childNodes(
251 IXMLDOMDocumentFragment *iface,
252 IXMLDOMNodeList** outList)
254 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
256 TRACE("(%p)->(%p)\n", This, outList);
258 return node_get_child_nodes(&This->node, outList);
261 static HRESULT WINAPI domfrag_get_firstChild(
262 IXMLDOMDocumentFragment *iface,
263 IXMLDOMNode** domNode)
265 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
267 TRACE("(%p)->(%p)\n", This, domNode);
269 return node_get_first_child(&This->node, domNode);
272 static HRESULT WINAPI domfrag_get_lastChild(
273 IXMLDOMDocumentFragment *iface,
274 IXMLDOMNode** domNode)
276 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
278 TRACE("(%p)->(%p)\n", This, domNode);
280 return node_get_last_child(&This->node, domNode);
283 static HRESULT WINAPI domfrag_get_previousSibling(
284 IXMLDOMDocumentFragment *iface,
285 IXMLDOMNode** domNode)
287 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
289 TRACE("(%p)->(%p)\n", This, domNode);
291 return return_null_node(domNode);
294 static HRESULT WINAPI domfrag_get_nextSibling(
295 IXMLDOMDocumentFragment *iface,
296 IXMLDOMNode** domNode)
298 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
300 TRACE("(%p)->(%p)\n", This, domNode);
302 return return_null_node(domNode);
305 static HRESULT WINAPI domfrag_get_attributes(
306 IXMLDOMDocumentFragment *iface,
307 IXMLDOMNamedNodeMap** attributeMap)
309 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
311 TRACE("(%p)->(%p)\n", This, attributeMap);
313 return return_null_ptr((void**)attributeMap);
316 static HRESULT WINAPI domfrag_insertBefore(
317 IXMLDOMDocumentFragment *iface,
318 IXMLDOMNode* newNode, VARIANT refChild,
319 IXMLDOMNode** outOldNode)
321 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
323 TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode);
325 /* TODO: test */
326 return node_insert_before(&This->node, newNode, &refChild, outOldNode);
329 static HRESULT WINAPI domfrag_replaceChild(
330 IXMLDOMDocumentFragment *iface,
331 IXMLDOMNode* newNode,
332 IXMLDOMNode* oldNode,
333 IXMLDOMNode** outOldNode)
335 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
337 TRACE("(%p)->(%p %p %p)\n", This, newNode, oldNode, outOldNode);
339 /* TODO: test */
340 return node_replace_child(&This->node, newNode, oldNode, outOldNode);
343 static HRESULT WINAPI domfrag_removeChild(
344 IXMLDOMDocumentFragment *iface,
345 IXMLDOMNode *child, IXMLDOMNode **oldChild)
347 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
348 TRACE("(%p)->(%p %p)\n", This, child, oldChild);
349 return node_remove_child(&This->node, child, oldChild);
352 static HRESULT WINAPI domfrag_appendChild(
353 IXMLDOMDocumentFragment *iface,
354 IXMLDOMNode *child, IXMLDOMNode **outChild)
356 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
357 TRACE("(%p)->(%p %p)\n", This, child, outChild);
358 return node_append_child(&This->node, child, outChild);
361 static HRESULT WINAPI domfrag_hasChildNodes(
362 IXMLDOMDocumentFragment *iface,
363 VARIANT_BOOL *ret)
365 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
366 TRACE("(%p)->(%p)\n", This, ret);
367 return node_has_childnodes(&This->node, ret);
370 static HRESULT WINAPI domfrag_get_ownerDocument(
371 IXMLDOMDocumentFragment *iface,
372 IXMLDOMDocument **doc)
374 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
375 TRACE("(%p)->(%p)\n", This, doc);
376 return node_get_owner_doc(&This->node, doc);
379 static HRESULT WINAPI domfrag_cloneNode(
380 IXMLDOMDocumentFragment *iface,
381 VARIANT_BOOL deep, IXMLDOMNode** outNode)
383 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
384 TRACE("(%p)->(%d %p)\n", This, deep, outNode);
385 return node_clone( &This->node, deep, outNode );
388 static HRESULT WINAPI domfrag_get_nodeTypeString(
389 IXMLDOMDocumentFragment *iface,
390 BSTR* p)
392 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
393 static const WCHAR documentfragmentW[] = {'d','o','c','u','m','e','n','t','f','r','a','g','m','e','n','t',0};
395 TRACE("(%p)->(%p)\n", This, p);
397 return return_bstr(documentfragmentW, p);
400 static HRESULT WINAPI domfrag_get_text(
401 IXMLDOMDocumentFragment *iface,
402 BSTR* p)
404 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
405 TRACE("(%p)->(%p)\n", This, p);
406 return node_get_text(&This->node, p);
409 static HRESULT WINAPI domfrag_put_text(
410 IXMLDOMDocumentFragment *iface,
411 BSTR p)
413 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
414 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
415 return node_put_text( &This->node, p );
418 static HRESULT WINAPI domfrag_get_specified(
419 IXMLDOMDocumentFragment *iface,
420 VARIANT_BOOL* isSpecified)
422 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
423 FIXME("(%p)->(%p) stub!\n", This, isSpecified);
424 *isSpecified = VARIANT_TRUE;
425 return S_OK;
428 static HRESULT WINAPI domfrag_get_definition(
429 IXMLDOMDocumentFragment *iface,
430 IXMLDOMNode** definitionNode)
432 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
433 FIXME("(%p)->(%p)\n", This, definitionNode);
434 return E_NOTIMPL;
437 static HRESULT WINAPI domfrag_get_nodeTypedValue(
438 IXMLDOMDocumentFragment *iface,
439 VARIANT *v)
441 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
442 TRACE("(%p)->(%p)\n", This, v);
443 return return_null_var(v);
446 static HRESULT WINAPI domfrag_put_nodeTypedValue(
447 IXMLDOMDocumentFragment *iface,
448 VARIANT typedValue)
450 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
451 FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
452 return E_NOTIMPL;
455 static HRESULT WINAPI domfrag_get_dataType(
456 IXMLDOMDocumentFragment *iface,
457 VARIANT* typename)
459 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
460 TRACE("(%p)->(%p)\n", This, typename);
461 return return_null_var( typename );
464 static HRESULT WINAPI domfrag_put_dataType(
465 IXMLDOMDocumentFragment *iface,
466 BSTR p)
468 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
470 FIXME("(%p)->(%s)\n", This, debugstr_w(p));
472 if(!p)
473 return E_INVALIDARG;
475 return E_FAIL;
478 static HRESULT WINAPI domfrag_get_xml(
479 IXMLDOMDocumentFragment *iface,
480 BSTR* p)
482 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
484 TRACE("(%p)->(%p)\n", This, p);
486 return node_get_xml(&This->node, FALSE, FALSE, p);
489 static HRESULT WINAPI domfrag_transformNode(
490 IXMLDOMDocumentFragment *iface,
491 IXMLDOMNode *node, BSTR *p)
493 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
494 TRACE("(%p)->(%p %p)\n", This, node, p);
495 return node_transform_node(&This->node, node, p);
498 static HRESULT WINAPI domfrag_selectNodes(
499 IXMLDOMDocumentFragment *iface,
500 BSTR p, IXMLDOMNodeList** outList)
502 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
503 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
504 return node_select_nodes(&This->node, p, outList);
507 static HRESULT WINAPI domfrag_selectSingleNode(
508 IXMLDOMDocumentFragment *iface,
509 BSTR p, IXMLDOMNode** outNode)
511 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
512 TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
513 return node_select_singlenode(&This->node, p, outNode);
516 static HRESULT WINAPI domfrag_get_parsed(
517 IXMLDOMDocumentFragment *iface,
518 VARIANT_BOOL* isParsed)
520 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
521 FIXME("(%p)->(%p) stub!\n", This, isParsed);
522 *isParsed = VARIANT_TRUE;
523 return S_OK;
526 static HRESULT WINAPI domfrag_get_namespaceURI(
527 IXMLDOMDocumentFragment *iface,
528 BSTR* p)
530 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
531 TRACE("(%p)->(%p)\n", This, p);
532 return node_get_namespaceURI(&This->node, p);
535 static HRESULT WINAPI domfrag_get_prefix(
536 IXMLDOMDocumentFragment *iface,
537 BSTR* prefix)
539 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
540 TRACE("(%p)->(%p)\n", This, prefix);
541 return return_null_bstr( prefix );
544 static HRESULT WINAPI domfrag_get_baseName(
545 IXMLDOMDocumentFragment *iface,
546 BSTR* name)
548 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
549 FIXME("(%p)->(%p): needs test\n", This, name);
550 return return_null_bstr( name );
553 static HRESULT WINAPI domfrag_transformNodeToObject(
554 IXMLDOMDocumentFragment *iface,
555 IXMLDOMNode* domNode, VARIANT var1)
557 domfrag *This = impl_from_IXMLDOMDocumentFragment( iface );
558 FIXME("(%p)->(%p %s)\n", This, domNode, debugstr_variant(&var1));
559 return E_NOTIMPL;
562 static const struct IXMLDOMDocumentFragmentVtbl domfrag_vtbl =
564 domfrag_QueryInterface,
565 domfrag_AddRef,
566 domfrag_Release,
567 domfrag_GetTypeInfoCount,
568 domfrag_GetTypeInfo,
569 domfrag_GetIDsOfNames,
570 domfrag_Invoke,
571 domfrag_get_nodeName,
572 domfrag_get_nodeValue,
573 domfrag_put_nodeValue,
574 domfrag_get_nodeType,
575 domfrag_get_parentNode,
576 domfrag_get_childNodes,
577 domfrag_get_firstChild,
578 domfrag_get_lastChild,
579 domfrag_get_previousSibling,
580 domfrag_get_nextSibling,
581 domfrag_get_attributes,
582 domfrag_insertBefore,
583 domfrag_replaceChild,
584 domfrag_removeChild,
585 domfrag_appendChild,
586 domfrag_hasChildNodes,
587 domfrag_get_ownerDocument,
588 domfrag_cloneNode,
589 domfrag_get_nodeTypeString,
590 domfrag_get_text,
591 domfrag_put_text,
592 domfrag_get_specified,
593 domfrag_get_definition,
594 domfrag_get_nodeTypedValue,
595 domfrag_put_nodeTypedValue,
596 domfrag_get_dataType,
597 domfrag_put_dataType,
598 domfrag_get_xml,
599 domfrag_transformNode,
600 domfrag_selectNodes,
601 domfrag_selectSingleNode,
602 domfrag_get_parsed,
603 domfrag_get_namespaceURI,
604 domfrag_get_prefix,
605 domfrag_get_baseName,
606 domfrag_transformNodeToObject
609 static const tid_t domfrag_iface_tids[] = {
610 IXMLDOMDocumentFragment_tid,
614 static dispex_static_data_t domfrag_dispex = {
615 NULL,
616 IXMLDOMDocumentFragment_tid,
617 NULL,
618 domfrag_iface_tids
621 IUnknown* create_doc_fragment( xmlNodePtr fragment )
623 domfrag *This;
625 This = heap_alloc( sizeof *This );
626 if ( !This )
627 return NULL;
629 This->IXMLDOMDocumentFragment_iface.lpVtbl = &domfrag_vtbl;
630 This->ref = 1;
632 init_xmlnode(&This->node, fragment, (IXMLDOMNode*)&This->IXMLDOMDocumentFragment_iface, &domfrag_dispex);
634 return (IUnknown*)&This->IXMLDOMDocumentFragment_iface;
637 #endif