msvcrt: Write directly to the console in _putwch.
[wine/multimedia.git] / dlls / msxml3 / xmlelem.c
blob96b2007ce389f274374000f79629c6fd84ab299d
1 /*
2 * XML Element implementation
4 * Copyright 2007 James Hawkins
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"
36 #include "ocidl.h"
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 #ifdef HAVE_LIBXML2
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
46 static HRESULT XMLElementCollection_create( xmlNodePtr node, LPVOID *ppObj );
48 /**********************************************************************
49 * IXMLElement
51 typedef struct _xmlelem
53 IXMLElement IXMLElement_iface;
54 LONG ref;
55 xmlNodePtr node;
56 BOOL own;
57 } xmlelem;
59 static inline xmlelem *impl_from_IXMLElement(IXMLElement *iface)
61 return CONTAINING_RECORD(iface, xmlelem, IXMLElement_iface);
64 static HRESULT WINAPI xmlelem_QueryInterface(IXMLElement *iface, REFIID riid, void** ppvObject)
66 xmlelem *This = impl_from_IXMLElement(iface);
68 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
70 if (IsEqualGUID(riid, &IID_IUnknown) ||
71 IsEqualGUID(riid, &IID_IDispatch) ||
72 IsEqualGUID(riid, &IID_IXMLElement))
74 *ppvObject = iface;
76 else
78 FIXME("interface %s not implemented\n", debugstr_guid(riid));
79 *ppvObject = NULL;
80 return E_NOINTERFACE;
83 IXMLElement_AddRef(iface);
85 return S_OK;
88 static ULONG WINAPI xmlelem_AddRef(IXMLElement *iface)
90 xmlelem *This = impl_from_IXMLElement(iface);
91 TRACE("%p\n", This);
92 return InterlockedIncrement(&This->ref);
95 static ULONG WINAPI xmlelem_Release(IXMLElement *iface)
97 xmlelem *This = impl_from_IXMLElement(iface);
98 LONG ref;
100 TRACE("%p\n", This);
102 ref = InterlockedDecrement(&This->ref);
103 if (ref == 0)
105 if (This->own) xmlFreeNode(This->node);
106 heap_free(This);
109 return ref;
112 static HRESULT WINAPI xmlelem_GetTypeInfoCount(IXMLElement *iface, UINT* pctinfo)
114 xmlelem *This = impl_from_IXMLElement(iface);
116 TRACE("(%p)->(%p)\n", This, pctinfo);
118 *pctinfo = 1;
120 return S_OK;
123 static HRESULT WINAPI xmlelem_GetTypeInfo(IXMLElement *iface, UINT iTInfo,
124 LCID lcid, ITypeInfo** ppTInfo)
126 xmlelem *This = impl_from_IXMLElement(iface);
127 HRESULT hr;
129 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
131 hr = get_typeinfo(IXMLElement_tid, ppTInfo);
133 return hr;
136 static HRESULT WINAPI xmlelem_GetIDsOfNames(IXMLElement *iface, REFIID riid,
137 LPOLESTR* rgszNames, UINT cNames,
138 LCID lcid, DISPID* rgDispId)
140 xmlelem *This = impl_from_IXMLElement(iface);
141 ITypeInfo *typeinfo;
142 HRESULT hr;
144 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
145 lcid, rgDispId);
147 if(!rgszNames || cNames == 0 || !rgDispId)
148 return E_INVALIDARG;
150 hr = get_typeinfo(IXMLElement_tid, &typeinfo);
151 if(SUCCEEDED(hr))
153 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
154 ITypeInfo_Release(typeinfo);
157 return hr;
160 static HRESULT WINAPI xmlelem_Invoke(IXMLElement *iface, DISPID dispIdMember,
161 REFIID riid, LCID lcid, WORD wFlags,
162 DISPPARAMS* pDispParams, VARIANT* pVarResult,
163 EXCEPINFO* pExcepInfo, UINT* puArgErr)
165 xmlelem *This = impl_from_IXMLElement(iface);
166 ITypeInfo *typeinfo;
167 HRESULT hr;
169 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
170 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
172 hr = get_typeinfo(IXMLElement_tid, &typeinfo);
173 if(SUCCEEDED(hr))
175 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLElement_iface, dispIdMember, wFlags, pDispParams,
176 pVarResult, pExcepInfo, puArgErr);
177 ITypeInfo_Release(typeinfo);
180 return hr;
183 static HRESULT WINAPI xmlelem_get_tagName(IXMLElement *iface, BSTR *p)
185 xmlelem *This = impl_from_IXMLElement(iface);
187 TRACE("(%p)->(%p)\n", This, p);
189 if (!p)
190 return E_INVALIDARG;
192 if (*This->node->name) {
193 *p = bstr_from_xmlChar(This->node->name);
194 CharUpperBuffW(*p, SysStringLen(*p));
195 }else {
196 *p = NULL;
199 TRACE("returning %s\n", debugstr_w(*p));
201 return S_OK;
204 static HRESULT WINAPI xmlelem_put_tagName(IXMLElement *iface, BSTR p)
206 xmlelem *This = impl_from_IXMLElement(iface);
208 FIXME("(%p)->(%s): stub\n", This, debugstr_w(p));
210 if (!p)
211 return E_INVALIDARG;
213 return E_NOTIMPL;
216 static HRESULT WINAPI xmlelem_get_parent(IXMLElement *iface, IXMLElement **parent)
218 xmlelem *This = impl_from_IXMLElement(iface);
220 TRACE("(%p)->(%p)\n", This, parent);
222 if (!parent)
223 return E_INVALIDARG;
225 *parent = NULL;
227 if (!This->node->parent)
228 return S_FALSE;
230 return XMLElement_create(This->node->parent, (LPVOID *)parent, FALSE);
233 static HRESULT WINAPI xmlelem_setAttribute(IXMLElement *iface, BSTR strPropertyName,
234 VARIANT PropertyValue)
236 xmlelem *This = impl_from_IXMLElement(iface);
237 xmlChar *name, *value;
238 xmlAttrPtr attr;
240 TRACE("(%p)->(%s %s)\n", This, debugstr_w(strPropertyName), debugstr_variant(&PropertyValue));
242 if (!strPropertyName || V_VT(&PropertyValue) != VT_BSTR)
243 return E_INVALIDARG;
245 name = xmlchar_from_wchar(strPropertyName);
246 value = xmlchar_from_wchar(V_BSTR(&PropertyValue));
247 attr = xmlSetProp(This->node, name, value);
249 heap_free(name);
250 heap_free(value);
251 return (attr) ? S_OK : S_FALSE;
254 static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name,
255 VARIANT *value)
257 static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 };
258 xmlelem *This = impl_from_IXMLElement(iface);
259 xmlChar *val = NULL;
261 TRACE("(%p)->(%s, %p)\n", This, debugstr_w(name), value);
263 if (!value)
264 return E_INVALIDARG;
266 VariantInit(value);
267 V_BSTR(value) = NULL;
269 if (!name)
270 return E_INVALIDARG;
272 /* case for xml:lang attribute */
273 if (!lstrcmpiW(name, xmllangW))
275 xmlNsPtr ns;
276 ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml");
277 val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href);
279 else
281 xmlAttrPtr attr;
282 xmlChar *xml_name;
284 xml_name = xmlchar_from_wchar(name);
285 attr = This->node->properties;
286 while (attr)
288 BSTR attr_name;
290 attr_name = bstr_from_xmlChar(attr->name);
291 if (!lstrcmpiW(name, attr_name))
293 val = xmlNodeListGetString(attr->doc, attr->children, 1);
294 SysFreeString(attr_name);
295 break;
298 attr = attr->next;
299 SysFreeString(attr_name);
302 heap_free(xml_name);
305 if (val)
307 V_VT(value) = VT_BSTR;
308 V_BSTR(value) = bstr_from_xmlChar(val);
311 xmlFree(val);
312 TRACE("returning %s\n", debugstr_w(V_BSTR(value)));
313 return (val) ? S_OK : S_FALSE;
316 static HRESULT WINAPI xmlelem_removeAttribute(IXMLElement *iface, BSTR strPropertyName)
318 xmlelem *This = impl_from_IXMLElement(iface);
319 xmlChar *name;
320 xmlAttrPtr attr;
321 int res;
322 HRESULT hr = S_FALSE;
324 TRACE("(%p)->(%s)\n", This, debugstr_w(strPropertyName));
326 if (!strPropertyName)
327 return E_INVALIDARG;
329 name = xmlchar_from_wchar(strPropertyName);
330 attr = xmlHasProp(This->node, name);
331 if (!attr)
332 goto done;
334 res = xmlRemoveProp(attr);
336 if (res == 0)
337 hr = S_OK;
339 done:
340 heap_free(name);
341 return hr;
344 static HRESULT WINAPI xmlelem_get_children(IXMLElement *iface, IXMLElementCollection **p)
346 xmlelem *This = impl_from_IXMLElement(iface);
348 TRACE("(%p)->(%p)\n", This, p);
350 if (!p)
351 return E_INVALIDARG;
353 return XMLElementCollection_create(This->node, (LPVOID *)p);
356 static LONG type_libxml_to_msxml(xmlElementType type)
358 switch (type)
360 case XML_ELEMENT_NODE:
361 return XMLELEMTYPE_ELEMENT;
362 case XML_TEXT_NODE:
363 return XMLELEMTYPE_TEXT;
364 case XML_COMMENT_NODE:
365 return XMLELEMTYPE_COMMENT;
366 case XML_DOCUMENT_NODE:
367 return XMLELEMTYPE_DOCUMENT;
368 case XML_DTD_NODE:
369 return XMLELEMTYPE_DTD;
370 case XML_PI_NODE:
371 return XMLELEMTYPE_PI;
372 default:
373 break;
376 return XMLELEMTYPE_OTHER;
379 static HRESULT WINAPI xmlelem_get_type(IXMLElement *iface, LONG *p)
381 xmlelem *This = impl_from_IXMLElement(iface);
383 TRACE("(%p)->(%p)\n", This, p);
385 if (!p)
386 return E_INVALIDARG;
388 *p = type_libxml_to_msxml(This->node->type);
389 TRACE("returning %d\n", *p);
390 return S_OK;
393 static HRESULT WINAPI xmlelem_get_text(IXMLElement *iface, BSTR *p)
395 xmlelem *This = impl_from_IXMLElement(iface);
396 xmlChar *content;
398 TRACE("(%p)->(%p)\n", This, p);
400 if (!p)
401 return E_INVALIDARG;
403 content = xmlNodeGetContent(This->node);
404 *p = bstr_from_xmlChar(content);
405 TRACE("returning %s\n", debugstr_w(*p));
407 xmlFree(content);
408 return S_OK;
411 static HRESULT WINAPI xmlelem_put_text(IXMLElement *iface, BSTR p)
413 xmlelem *This = impl_from_IXMLElement(iface);
414 xmlChar *content;
416 TRACE("(%p)->(%s)\n", This, debugstr_w(p));
418 /* FIXME: test which types can be used */
419 if (This->node->type == XML_ELEMENT_NODE)
420 return E_NOTIMPL;
422 content = xmlchar_from_wchar(p);
423 xmlNodeSetContent(This->node, content);
425 heap_free(content);
427 return S_OK;
430 static HRESULT WINAPI xmlelem_addChild(IXMLElement *iface, IXMLElement *pChildElem,
431 LONG lIndex, LONG lreserved)
433 xmlelem *This = impl_from_IXMLElement(iface);
434 xmlelem *childElem = impl_from_IXMLElement(pChildElem);
435 xmlNodePtr child;
437 TRACE("(%p)->(%p %d %d)\n", This, pChildElem, lIndex, lreserved);
439 if (lIndex == 0)
440 child = xmlAddChild(This->node, childElem->node);
441 else
442 child = xmlAddNextSibling(This->node, childElem->node->last);
444 /* parent is responsible for child data */
445 if (child) childElem->own = FALSE;
447 return (child) ? S_OK : S_FALSE;
450 static HRESULT WINAPI xmlelem_removeChild(IXMLElement *iface, IXMLElement *pChildElem)
452 xmlelem *This = impl_from_IXMLElement(iface);
453 xmlelem *childElem = impl_from_IXMLElement(pChildElem);
455 TRACE("(%p)->(%p)\n", This, childElem);
457 if (!pChildElem)
458 return E_INVALIDARG;
460 /* only supported for This is childElem parent case */
461 if (This->node != childElem->node->parent)
462 return E_INVALIDARG;
464 xmlUnlinkNode(childElem->node);
465 /* standalone element now */
466 childElem->own = TRUE;
468 return S_OK;
471 static const struct IXMLElementVtbl xmlelem_vtbl =
473 xmlelem_QueryInterface,
474 xmlelem_AddRef,
475 xmlelem_Release,
476 xmlelem_GetTypeInfoCount,
477 xmlelem_GetTypeInfo,
478 xmlelem_GetIDsOfNames,
479 xmlelem_Invoke,
480 xmlelem_get_tagName,
481 xmlelem_put_tagName,
482 xmlelem_get_parent,
483 xmlelem_setAttribute,
484 xmlelem_getAttribute,
485 xmlelem_removeAttribute,
486 xmlelem_get_children,
487 xmlelem_get_type,
488 xmlelem_get_text,
489 xmlelem_put_text,
490 xmlelem_addChild,
491 xmlelem_removeChild
494 HRESULT XMLElement_create(xmlNodePtr node, LPVOID *ppObj, BOOL own)
496 xmlelem *elem;
498 TRACE("(%p)\n", ppObj);
500 if (!ppObj)
501 return E_INVALIDARG;
503 *ppObj = NULL;
505 elem = heap_alloc(sizeof (*elem));
506 if(!elem)
507 return E_OUTOFMEMORY;
509 elem->IXMLElement_iface.lpVtbl = &xmlelem_vtbl;
510 elem->ref = 1;
511 elem->node = node;
512 elem->own = own;
514 *ppObj = &elem->IXMLElement_iface;
516 TRACE("returning iface %p\n", *ppObj);
517 return S_OK;
520 /************************************************************************
521 * IXMLElementCollection
523 typedef struct _xmlelem_collection
525 IXMLElementCollection IXMLElementCollection_iface;
526 IEnumVARIANT IEnumVARIANT_iface;
527 LONG ref;
528 LONG length;
529 xmlNodePtr node;
531 /* IEnumVARIANT members */
532 xmlNodePtr current;
533 } xmlelem_collection;
535 static inline LONG xmlelem_collection_updatelength(xmlelem_collection *collection)
537 xmlNodePtr ptr = collection->node->children;
539 collection->length = 0;
540 while (ptr)
542 collection->length++;
543 ptr = ptr->next;
545 return collection->length;
548 static inline xmlelem_collection *impl_from_IXMLElementCollection(IXMLElementCollection *iface)
550 return CONTAINING_RECORD(iface, xmlelem_collection, IXMLElementCollection_iface);
553 static inline xmlelem_collection *impl_from_IEnumVARIANT(IEnumVARIANT *iface)
555 return CONTAINING_RECORD(iface, xmlelem_collection, IEnumVARIANT_iface);
558 static HRESULT WINAPI xmlelem_collection_QueryInterface(IXMLElementCollection *iface, REFIID riid, void** ppvObject)
560 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
562 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
564 if (IsEqualGUID(riid, &IID_IUnknown) ||
565 IsEqualGUID(riid, &IID_IXMLElementCollection))
567 *ppvObject = iface;
569 else if (IsEqualGUID(riid, &IID_IEnumVARIANT))
571 *ppvObject = &This->IEnumVARIANT_iface;
573 else
575 FIXME("interface %s not implemented\n", debugstr_guid(riid));
576 *ppvObject = NULL;
577 return E_NOINTERFACE;
580 IXMLElementCollection_AddRef(iface);
582 return S_OK;
585 static ULONG WINAPI xmlelem_collection_AddRef(IXMLElementCollection *iface)
587 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
588 TRACE("(%p)\n", This);
589 return InterlockedIncrement(&This->ref);
592 static ULONG WINAPI xmlelem_collection_Release(IXMLElementCollection *iface)
594 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
595 LONG ref;
597 TRACE("(%p)\n", This);
599 ref = InterlockedDecrement(&This->ref);
600 if (ref == 0)
602 heap_free(This);
605 return ref;
608 static HRESULT WINAPI xmlelem_collection_GetTypeInfoCount(IXMLElementCollection *iface, UINT* pctinfo)
610 FIXME("\n");
611 return E_NOTIMPL;
614 static HRESULT WINAPI xmlelem_collection_GetTypeInfo(IXMLElementCollection *iface, UINT iTInfo,
615 LCID lcid, ITypeInfo** ppTInfo)
617 FIXME("\n");
618 return E_NOTIMPL;
621 static HRESULT WINAPI xmlelem_collection_GetIDsOfNames(IXMLElementCollection *iface, REFIID riid,
622 LPOLESTR* rgszNames, UINT cNames,
623 LCID lcid, DISPID* rgDispId)
625 FIXME("\n");
626 return E_NOTIMPL;
629 static HRESULT WINAPI xmlelem_collection_Invoke(IXMLElementCollection *iface, DISPID dispIdMember,
630 REFIID riid, LCID lcid, WORD wFlags,
631 DISPPARAMS* pDispParams, VARIANT* pVarResult,
632 EXCEPINFO* pExcepInfo, UINT* puArgErr)
634 FIXME("\n");
635 return E_NOTIMPL;
638 static HRESULT WINAPI xmlelem_collection_put_length(IXMLElementCollection *iface, LONG v)
640 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
641 TRACE("(%p)->(%d)\n", This, v);
642 return E_FAIL;
645 static HRESULT WINAPI xmlelem_collection_get_length(IXMLElementCollection *iface, LONG *p)
647 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
649 TRACE("(%p)->(%p)\n", This, p);
651 if (!p)
652 return E_INVALIDARG;
654 *p = xmlelem_collection_updatelength(This);
655 return S_OK;
658 static HRESULT WINAPI xmlelem_collection_get__newEnum(IXMLElementCollection *iface, IUnknown **ppUnk)
660 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
662 TRACE("(%p)->(%p)\n", This, ppUnk);
664 if (!ppUnk)
665 return E_INVALIDARG;
667 IXMLElementCollection_AddRef(iface);
668 *ppUnk = (IUnknown *)&This->IEnumVARIANT_iface;
669 return S_OK;
672 static HRESULT WINAPI xmlelem_collection_item(IXMLElementCollection *iface, VARIANT var1,
673 VARIANT var2, IDispatch **ppDisp)
675 xmlelem_collection *This = impl_from_IXMLElementCollection(iface);
676 xmlNodePtr ptr = This->node->children;
677 int index, i;
679 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&var1), debugstr_variant(&var2), ppDisp);
681 if (!ppDisp)
682 return E_INVALIDARG;
684 *ppDisp = NULL;
686 index = V_I4(&var1);
687 if (index < 0)
688 return E_INVALIDARG;
690 xmlelem_collection_updatelength(This);
691 if (index >= This->length)
692 return E_FAIL;
694 for (i = 0; i < index; i++)
695 ptr = ptr->next;
697 return XMLElement_create(ptr, (LPVOID *)ppDisp, FALSE);
700 static const struct IXMLElementCollectionVtbl xmlelem_collection_vtbl =
702 xmlelem_collection_QueryInterface,
703 xmlelem_collection_AddRef,
704 xmlelem_collection_Release,
705 xmlelem_collection_GetTypeInfoCount,
706 xmlelem_collection_GetTypeInfo,
707 xmlelem_collection_GetIDsOfNames,
708 xmlelem_collection_Invoke,
709 xmlelem_collection_put_length,
710 xmlelem_collection_get_length,
711 xmlelem_collection_get__newEnum,
712 xmlelem_collection_item
715 /************************************************************************
716 * xmlelem_collection implementation of IEnumVARIANT.
718 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_QueryInterface(
719 IEnumVARIANT *iface, REFIID riid, LPVOID *ppvObj)
721 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
723 TRACE("(%p)->(%s %p)\n", this, debugstr_guid(riid), ppvObj);
725 if (IsEqualGUID(riid, &IID_IUnknown) ||
726 IsEqualGUID(riid, &IID_IEnumVARIANT))
728 *ppvObj = iface;
729 IEnumVARIANT_AddRef(iface);
730 return S_OK;
733 FIXME("interface %s not implemented\n", debugstr_guid(riid));
734 *ppvObj = NULL;
735 return E_NOINTERFACE;
738 static ULONG WINAPI xmlelem_collection_IEnumVARIANT_AddRef(
739 IEnumVARIANT *iface)
741 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
742 return IXMLElementCollection_AddRef(&this->IXMLElementCollection_iface);
745 static ULONG WINAPI xmlelem_collection_IEnumVARIANT_Release(
746 IEnumVARIANT *iface)
748 xmlelem_collection *this = impl_from_IEnumVARIANT(iface);
749 return IXMLElementCollection_Release(&this->IXMLElementCollection_iface);
752 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Next(
753 IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *fetched)
755 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
756 xmlNodePtr ptr = This->current;
758 TRACE("(%p)->(%d %p %p)\n", This, celt, rgVar, fetched);
760 if (!rgVar)
761 return E_INVALIDARG;
763 /* FIXME: handle celt */
764 if (fetched)
765 *fetched = 1;
767 if (This->current)
768 This->current = This->current->next;
769 else
771 V_VT(rgVar) = VT_EMPTY;
772 if (fetched) *fetched = 0;
773 return S_FALSE;
776 V_VT(rgVar) = VT_DISPATCH;
777 return XMLElement_create(ptr, (LPVOID *)&V_DISPATCH(rgVar), FALSE);
780 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Skip(
781 IEnumVARIANT *iface, ULONG celt)
783 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
784 FIXME("(%p)->(%d): stub\n", This, celt);
785 return E_NOTIMPL;
788 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Reset(
789 IEnumVARIANT *iface)
791 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
792 TRACE("(%p)\n", This);
793 This->current = This->node->children;
794 return S_OK;
797 static HRESULT WINAPI xmlelem_collection_IEnumVARIANT_Clone(
798 IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
800 xmlelem_collection *This = impl_from_IEnumVARIANT(iface);
801 FIXME("(%p)->(%p): stub\n", This, ppEnum);
802 return E_NOTIMPL;
805 static const struct IEnumVARIANTVtbl xmlelem_collection_IEnumVARIANTvtbl =
807 xmlelem_collection_IEnumVARIANT_QueryInterface,
808 xmlelem_collection_IEnumVARIANT_AddRef,
809 xmlelem_collection_IEnumVARIANT_Release,
810 xmlelem_collection_IEnumVARIANT_Next,
811 xmlelem_collection_IEnumVARIANT_Skip,
812 xmlelem_collection_IEnumVARIANT_Reset,
813 xmlelem_collection_IEnumVARIANT_Clone
816 static HRESULT XMLElementCollection_create(xmlNodePtr node, LPVOID *ppObj)
818 xmlelem_collection *collection;
820 TRACE("(%p)\n", ppObj);
822 *ppObj = NULL;
824 if (!node->children)
825 return S_FALSE;
827 collection = heap_alloc(sizeof (*collection));
828 if(!collection)
829 return E_OUTOFMEMORY;
831 collection->IXMLElementCollection_iface.lpVtbl = &xmlelem_collection_vtbl;
832 collection->IEnumVARIANT_iface.lpVtbl = &xmlelem_collection_IEnumVARIANTvtbl;
833 collection->ref = 1;
834 collection->length = 0;
835 collection->node = node;
836 collection->current = node->children;
837 xmlelem_collection_updatelength(collection);
839 *ppObj = &collection->IXMLElementCollection_iface;
841 TRACE("returning iface %p\n", *ppObj);
842 return S_OK;
845 #endif