EnumThemeColors() and EnumThemeSizes() actually do not return a single
[wine] / dlls / msxml3 / nodelist.c
1 /*
2  *    Node list implementation
3  *
4  * Copyright 2005 Mike McCormack
5  *
6  * iface 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.
10  *
11  * iface 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.
15  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #define COBJMACROS
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
31 #include "ocidl.h"
32 #include "msxml.h"
33 #include "xmldom.h"
34 #include "msxml.h"
35
36 #include "msxml_private.h"
37
38 #include "wine/debug.h"
39
40 #ifdef HAVE_LIBXML2
41
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43
44 typedef struct _xmlnodelist
45 {
46     const struct IXMLDOMNodeListVtbl *lpVtbl;
47     LONG ref;
48     xmlNodePtr node;
49     xmlNodePtr current;
50 } xmlnodelist;
51
52 static inline xmlnodelist *impl_from_IXMLDOMNodeList( IXMLDOMNodeList *iface )
53 {
54     return (xmlnodelist *)((char*)iface - FIELD_OFFSET(xmlnodelist, lpVtbl));
55 }
56
57 static HRESULT WINAPI xmlnodelist_QueryInterface(
58     IXMLDOMNodeList *iface,
59     REFIID riid,
60     void** ppvObject )
61 {
62     TRACE("%p %p %p\n", iface, debugstr_guid(riid), ppvObject);
63
64     if ( IsEqualGUID( riid, &IID_IUnknown ) ||
65          IsEqualGUID( riid, &IID_IDispatch ) ||
66          IsEqualGUID( riid, &IID_IXMLDOMNodeList ) )
67     {
68         *ppvObject = iface;
69     }
70     else
71         return E_NOINTERFACE;
72
73     IXMLDOMNodeList_AddRef( iface );
74
75     return S_OK;
76 }
77
78 static ULONG WINAPI xmlnodelist_AddRef(
79     IXMLDOMNodeList *iface )
80 {
81     xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
82     return InterlockedIncrement( &This->ref );
83 }
84
85 static ULONG WINAPI xmlnodelist_Release(
86     IXMLDOMNodeList *iface )
87 {
88     xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
89     ULONG ref;
90
91     ref = InterlockedDecrement( &This->ref );
92     if ( ref == 0 )
93     {
94         HeapFree( GetProcessHeap(), 0, This );
95     }
96
97     return ref;
98 }
99
100 static HRESULT WINAPI xmlnodelist_GetTypeInfoCount(
101     IXMLDOMNodeList *iface,
102     UINT* pctinfo )
103 {
104     FIXME("\n");
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI xmlnodelist_GetTypeInfo(
109     IXMLDOMNodeList *iface,
110     UINT iTInfo,
111     LCID lcid,
112     ITypeInfo** ppTInfo )
113 {
114     FIXME("\n");
115     return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI xmlnodelist_GetIDsOfNames(
119     IXMLDOMNodeList *iface,
120     REFIID riid,
121     LPOLESTR* rgszNames,
122     UINT cNames,
123     LCID lcid,
124     DISPID* rgDispId )
125 {
126     FIXME("\n");
127     return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI xmlnodelist_Invoke(
131     IXMLDOMNodeList *iface,
132     DISPID dispIdMember,
133     REFIID riid,
134     LCID lcid,
135     WORD wFlags,
136     DISPPARAMS* pDispParams,
137     VARIANT* pVarResult,
138     EXCEPINFO* pExcepInfo,
139     UINT* puArgErr )
140 {
141     FIXME("\n");
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI xmlnodelist_get_item(
146         IXMLDOMNodeList* iface,
147         long index,
148         IXMLDOMNode** listItem)
149 {
150     FIXME("\n");
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI xmlnodelist_get_length(
155         IXMLDOMNodeList* iface,
156         long* listLength)
157 {
158     FIXME("\n");
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI xmlnodelist_nextNode(
163         IXMLDOMNodeList* iface,
164         IXMLDOMNode** nextItem)
165 {
166     xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
167
168     TRACE("%p %p\n", This, nextItem );
169
170     if (!This->current)
171         return S_FALSE;
172
173     *nextItem = create_node( This->current );
174     This->current = This->current->next;
175     return S_OK;
176 }
177
178 static HRESULT WINAPI xmlnodelist_reset(
179         IXMLDOMNodeList* iface)
180 {
181     FIXME("\n");
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI xmlnodelist__newEnum(
186         IXMLDOMNodeList* iface,
187         IUnknown** ppUnk)
188 {
189     FIXME("\n");
190     return E_NOTIMPL;
191 }
192
193
194 static const struct IXMLDOMNodeListVtbl xmlnodelist_vtbl =
195 {
196     xmlnodelist_QueryInterface,
197     xmlnodelist_AddRef,
198     xmlnodelist_Release,
199     xmlnodelist_GetTypeInfoCount,
200     xmlnodelist_GetTypeInfo,
201     xmlnodelist_GetIDsOfNames,
202     xmlnodelist_Invoke,
203     xmlnodelist_get_item,
204     xmlnodelist_get_length,
205     xmlnodelist_nextNode,
206     xmlnodelist_reset,
207     xmlnodelist__newEnum,
208 };
209
210 IXMLDOMNodeList* create_nodelist( xmlNodePtr node )
211 {
212     xmlnodelist *nodelist;
213
214     nodelist = HeapAlloc( GetProcessHeap(), 0, sizeof *nodelist );
215     if ( !nodelist )
216         return NULL;
217
218     nodelist->lpVtbl = &xmlnodelist_vtbl;
219     nodelist->ref = 1;
220     nodelist->node = node;
221     nodelist->current = node;
222
223     return (IXMLDOMNodeList*) &nodelist->lpVtbl;
224 }
225
226 #endif