mshtml/tests: Added IWinInetHttpInfo interface.
[wine] / dlls / msxml3 / doctype.c
1 /*
2  *    DOM DTD node implementation
3  *
4  * Copyright 2010 Nikolay Sivov
5  *
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.
10  *
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #define COBJMACROS
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #ifdef HAVE_LIBXML2
27 # include <libxml/parser.h>
28 # include <libxml/xmlerror.h>
29 #endif
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "winnls.h"
35 #include "ole2.h"
36 #include "msxml6.h"
37
38 #include "msxml_private.h"
39
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
43
44 #ifdef HAVE_LIBXML2
45
46 typedef struct _domdoctype
47 {
48     xmlnode node;
49     IXMLDOMDocumentType IXMLDOMDocumentType_iface;
50     LONG ref;
51 } domdoctype;
52
53 static inline domdoctype *impl_from_IXMLDOMDocumentType( IXMLDOMDocumentType *iface )
54 {
55     return CONTAINING_RECORD(iface, domdoctype, IXMLDOMDocumentType_iface);
56 }
57
58 static HRESULT WINAPI domdoctype_QueryInterface(
59     IXMLDOMDocumentType *iface,
60     REFIID riid,
61     void** ppvObject )
62 {
63     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
64
65     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
66
67     if ( IsEqualGUID( riid, &IID_IXMLDOMDocumentType ) ||
68          IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
69          IsEqualGUID( riid, &IID_IDispatch ) ||
70          IsEqualGUID( riid, &IID_IUnknown ) )
71     {
72         *ppvObject = &This->IXMLDOMDocumentType_iface;
73     }
74     else if(node_query_interface(&This->node, riid, ppvObject))
75     {
76         return *ppvObject ? S_OK : E_NOINTERFACE;
77     }
78     else
79     {
80         TRACE("interface %s not implemented\n", debugstr_guid(riid));
81         *ppvObject = NULL;
82         return E_NOINTERFACE;
83     }
84
85     IUnknown_AddRef( (IUnknown*)*ppvObject );
86     return S_OK;
87 }
88
89 static ULONG WINAPI domdoctype_AddRef(
90     IXMLDOMDocumentType *iface )
91 {
92     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
93     LONG ref = InterlockedIncrement(&This->ref);
94     TRACE("(%p)->(%d)\n", This, ref);
95     return ref;
96 }
97
98 static ULONG WINAPI domdoctype_Release(
99     IXMLDOMDocumentType *iface )
100 {
101     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
102     ULONG ref = InterlockedDecrement(&This->ref);
103
104     TRACE("(%p)->(%d)\n", This, ref);
105
106     if(!ref) {
107         destroy_xmlnode(&This->node);
108         heap_free(This);
109     }
110
111     return ref;
112 }
113
114 static HRESULT WINAPI domdoctype_GetTypeInfoCount(
115     IXMLDOMDocumentType *iface,
116     UINT* pctinfo )
117 {
118     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
119
120     TRACE("(%p)->(%p)\n", This, pctinfo);
121
122     *pctinfo = 1;
123
124     return S_OK;
125 }
126
127 static HRESULT WINAPI domdoctype_GetTypeInfo(
128     IXMLDOMDocumentType *iface,
129     UINT iTInfo, LCID lcid,
130     ITypeInfo** ppTInfo )
131 {
132     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
133     HRESULT hr;
134
135     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
136
137     hr = get_typeinfo(IXMLDOMDocumentType_tid, ppTInfo);
138
139     return hr;
140 }
141
142 static HRESULT WINAPI domdoctype_GetIDsOfNames(
143     IXMLDOMDocumentType *iface,
144     REFIID riid, LPOLESTR* rgszNames,
145     UINT cNames, LCID lcid, DISPID* rgDispId )
146 {
147     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
148     ITypeInfo *typeinfo;
149     HRESULT hr;
150
151     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
152           lcid, rgDispId);
153
154     if(!rgszNames || cNames == 0 || !rgDispId)
155         return E_INVALIDARG;
156
157     hr = get_typeinfo(IXMLDOMDocumentType_tid, &typeinfo);
158     if(SUCCEEDED(hr))
159     {
160         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
161         ITypeInfo_Release(typeinfo);
162     }
163
164     return hr;
165 }
166
167 static HRESULT WINAPI domdoctype_Invoke(
168     IXMLDOMDocumentType *iface,
169     DISPID dispIdMember, REFIID riid, LCID lcid,
170     WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
171     EXCEPINFO* pExcepInfo, UINT* puArgErr )
172 {
173     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
174     ITypeInfo *typeinfo;
175     HRESULT hr;
176
177     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
178           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
179
180     hr = get_typeinfo(IXMLDOMDocumentType_tid, &typeinfo);
181     if(SUCCEEDED(hr))
182     {
183         hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMDocumentType_iface, dispIdMember, wFlags,
184                 pDispParams, pVarResult, pExcepInfo, puArgErr);
185         ITypeInfo_Release(typeinfo);
186     }
187
188     return hr;
189 }
190
191 static HRESULT WINAPI domdoctype_get_nodeName(
192     IXMLDOMDocumentType *iface,
193     BSTR* p )
194 {
195     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
196     FIXME("(%p)->(%p): stub\n", This, p);
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI domdoctype_get_nodeValue(
201     IXMLDOMDocumentType *iface,
202     VARIANT* value)
203 {
204     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
205     FIXME("(%p)->(%p): stub\n", This, value);
206     return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI domdoctype_put_nodeValue(
210     IXMLDOMDocumentType *iface,
211     VARIANT value)
212 {
213     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
214     FIXME("(%p)->(%s): stub\n", This, debugstr_variant(&value));
215     return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI domdoctype_get_nodeType(
219     IXMLDOMDocumentType *iface,
220     DOMNodeType* domNodeType )
221 {
222     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
223
224     TRACE("(%p)->(%p)\n", This, domNodeType);
225
226     *domNodeType = NODE_DOCUMENT_TYPE;
227     return S_OK;
228 }
229
230 static HRESULT WINAPI domdoctype_get_parentNode(
231     IXMLDOMDocumentType *iface,
232     IXMLDOMNode** parent )
233 {
234     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
235     FIXME("(%p)->(%p): stub\n", This, parent);
236     return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI domdoctype_get_childNodes(
240     IXMLDOMDocumentType *iface,
241     IXMLDOMNodeList** outList)
242 {
243     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
244     FIXME("(%p)->(%p): stub\n", This, outList);
245     return E_NOTIMPL;
246 }
247
248 static HRESULT WINAPI domdoctype_get_firstChild(
249     IXMLDOMDocumentType *iface,
250     IXMLDOMNode** domNode)
251 {
252     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
253     FIXME("(%p)->(%p): stub\n", This, domNode);
254     return E_NOTIMPL;
255 }
256
257 static HRESULT WINAPI domdoctype_get_lastChild(
258     IXMLDOMDocumentType *iface,
259     IXMLDOMNode** domNode)
260 {
261     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
262     FIXME("(%p)->(%p): stub\n", This, domNode);
263     return E_NOTIMPL;
264 }
265
266 static HRESULT WINAPI domdoctype_get_previousSibling(
267     IXMLDOMDocumentType *iface,
268     IXMLDOMNode** domNode)
269 {
270     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
271     FIXME("(%p)->(%p): stub\n", This, domNode);
272     return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI domdoctype_get_nextSibling(
276     IXMLDOMDocumentType *iface,
277     IXMLDOMNode** domNode)
278 {
279     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
280     FIXME("(%p)->(%p): stub\n", This, domNode);
281     return E_NOTIMPL;
282 }
283
284 static HRESULT WINAPI domdoctype_get_attributes(
285     IXMLDOMDocumentType *iface,
286     IXMLDOMNamedNodeMap** attributeMap)
287 {
288     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
289     FIXME("(%p)->(%p): stub\n", This, attributeMap);
290     return E_NOTIMPL;
291 }
292
293 static HRESULT WINAPI domdoctype_insertBefore(
294     IXMLDOMDocumentType *iface,
295     IXMLDOMNode* newNode, VARIANT refChild,
296     IXMLDOMNode** outOldNode)
297 {
298     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
299
300     FIXME("(%p)->(%p %s %p): stub\n", This, newNode, debugstr_variant(&refChild), outOldNode);
301
302     return E_NOTIMPL;
303 }
304
305 static HRESULT WINAPI domdoctype_replaceChild(
306     IXMLDOMDocumentType *iface,
307     IXMLDOMNode* newNode,
308     IXMLDOMNode* oldNode,
309     IXMLDOMNode** outOldNode)
310 {
311     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
312
313     FIXME("(%p)->(%p %p %p): stub\n", This, newNode, oldNode, outOldNode);
314
315     return E_NOTIMPL;
316 }
317
318 static HRESULT WINAPI domdoctype_removeChild(
319     IXMLDOMDocumentType *iface,
320     IXMLDOMNode* domNode, IXMLDOMNode** oldNode)
321 {
322     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
323     FIXME("(%p)->(%p %p): stub\n", This, domNode, oldNode);
324     return E_NOTIMPL;
325 }
326
327 static HRESULT WINAPI domdoctype_appendChild(
328     IXMLDOMDocumentType *iface,
329     IXMLDOMNode* newNode, IXMLDOMNode** outNewNode)
330 {
331     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
332     FIXME("(%p)->(%p %p): stub\n", This, newNode, outNewNode);
333     return E_NOTIMPL;
334 }
335
336 static HRESULT WINAPI domdoctype_hasChildNodes(
337     IXMLDOMDocumentType *iface,
338     VARIANT_BOOL* pbool)
339 {
340     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
341     FIXME("(%p)->(%p): stub\n", This, pbool);
342     return E_NOTIMPL;
343 }
344
345 static HRESULT WINAPI domdoctype_get_ownerDocument(
346     IXMLDOMDocumentType *iface,
347     IXMLDOMDocument** domDocument)
348 {
349     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
350     FIXME("(%p)->(%p): stub\n", This, domDocument);
351     return E_NOTIMPL;
352 }
353
354 static HRESULT WINAPI domdoctype_cloneNode(
355     IXMLDOMDocumentType *iface,
356     VARIANT_BOOL deep, IXMLDOMNode** outNode)
357 {
358     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
359     FIXME("(%p)->(%d %p): stub\n", This, deep, outNode);
360     return E_NOTIMPL;
361 }
362
363 static HRESULT WINAPI domdoctype_get_nodeTypeString(
364     IXMLDOMDocumentType *iface,
365     BSTR* p)
366 {
367     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
368     FIXME("(%p)->(%p): stub\n", This, p);
369     return E_NOTIMPL;
370 }
371
372 static HRESULT WINAPI domdoctype_get_text(
373     IXMLDOMDocumentType *iface,
374     BSTR* p)
375 {
376     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
377     FIXME("(%p)->(%p): stub\n", This, p);
378     return E_NOTIMPL;
379 }
380
381 static HRESULT WINAPI domdoctype_put_text(
382     IXMLDOMDocumentType *iface,
383     BSTR p)
384 {
385     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
386     FIXME("(%p)->(%s): stub\n", This, debugstr_w(p));
387     return E_NOTIMPL;
388 }
389
390 static HRESULT WINAPI domdoctype_get_specified(
391     IXMLDOMDocumentType *iface,
392     VARIANT_BOOL* isSpecified)
393 {
394     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
395     FIXME("(%p)->(%p): stub\n", This, isSpecified);
396     return E_NOTIMPL;
397 }
398
399 static HRESULT WINAPI domdoctype_get_definition(
400     IXMLDOMDocumentType *iface,
401     IXMLDOMNode** definitionNode)
402 {
403     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
404     FIXME("(%p)->(%p)\n", This, definitionNode);
405     return E_NOTIMPL;
406 }
407
408 static HRESULT WINAPI domdoctype_get_nodeTypedValue(
409     IXMLDOMDocumentType *iface,
410     VARIANT* v)
411 {
412     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
413     TRACE("(%p)->(%p)\n", This, v);
414     return return_null_var(v);
415 }
416
417 static HRESULT WINAPI domdoctype_put_nodeTypedValue(
418     IXMLDOMDocumentType *iface,
419     VARIANT value)
420 {
421     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
422     FIXME("(%p)->(%s): stub\n", This, debugstr_variant(&value));
423     return E_NOTIMPL;
424 }
425
426 static HRESULT WINAPI domdoctype_get_dataType(
427     IXMLDOMDocumentType *iface,
428     VARIANT* typename)
429 {
430     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
431     FIXME("(%p)->(%p): stub\n", This, typename);
432     return E_NOTIMPL;
433 }
434
435 static HRESULT WINAPI domdoctype_put_dataType(
436     IXMLDOMDocumentType *iface,
437     BSTR p)
438 {
439     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
440     FIXME("(%p)->(%s): stub\n", This, debugstr_w(p));
441     return E_NOTIMPL;
442 }
443
444 static HRESULT WINAPI domdoctype_get_xml(
445     IXMLDOMDocumentType *iface,
446     BSTR* p)
447 {
448     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
449     FIXME("(%p)->(%p): stub\n", This, p);
450     return E_NOTIMPL;
451 }
452
453 static HRESULT WINAPI domdoctype_transformNode(
454     IXMLDOMDocumentType *iface,
455     IXMLDOMNode* domNode, BSTR* p)
456 {
457     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
458     FIXME("(%p)->(%p %p): stub\n", This, domNode, p);
459     return E_NOTIMPL;
460 }
461
462 static HRESULT WINAPI domdoctype_selectNodes(
463     IXMLDOMDocumentType *iface,
464     BSTR p, IXMLDOMNodeList** outList)
465 {
466     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
467     FIXME("(%p)->(%s %p): stub\n", This, debugstr_w(p), outList);
468     return E_NOTIMPL;
469 }
470
471 static HRESULT WINAPI domdoctype_selectSingleNode(
472     IXMLDOMDocumentType *iface,
473     BSTR p, IXMLDOMNode** outNode)
474 {
475     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
476     FIXME("(%p)->(%s %p): stub\n", This, debugstr_w(p), outNode);
477     return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI domdoctype_get_parsed(
481     IXMLDOMDocumentType *iface,
482     VARIANT_BOOL* isParsed)
483 {
484     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
485     FIXME("(%p)->(%p): stub\n", This, isParsed);
486     return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI domdoctype_get_namespaceURI(
490     IXMLDOMDocumentType *iface,
491     BSTR* p)
492 {
493     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
494     FIXME("(%p)->(%p): stub\n", This, p);
495     return E_NOTIMPL;
496 }
497
498 static HRESULT WINAPI domdoctype_get_prefix(
499     IXMLDOMDocumentType *iface,
500     BSTR* prefix)
501 {
502     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
503     FIXME("(%p)->(%p): stub\n", This, prefix);
504     return E_NOTIMPL;
505 }
506
507 static HRESULT WINAPI domdoctype_get_baseName(
508     IXMLDOMDocumentType *iface,
509     BSTR* name)
510 {
511     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
512     FIXME("(%p)->(%p): stub\n", This, name);
513     return E_NOTIMPL;
514 }
515
516 static HRESULT WINAPI domdoctype_transformNodeToObject(
517     IXMLDOMDocumentType *iface,
518     IXMLDOMNode* domNode, VARIANT var1)
519 {
520     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
521     FIXME("(%p)->(%p %s): stub\n", This, domNode, debugstr_variant(&var1));
522     return E_NOTIMPL;
523 }
524
525 static HRESULT WINAPI domdoctype_get_name(
526     IXMLDOMDocumentType *iface,
527     BSTR *p)
528 {
529     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
530     FIXME("(%p)->(%p): stub\n", This, p);
531     return E_NOTIMPL;
532 }
533
534 static HRESULT WINAPI domdoctype_get_entities(
535     IXMLDOMDocumentType *iface,
536     IXMLDOMNamedNodeMap **entityMap)
537 {
538     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
539     FIXME("(%p)->(%p): stub\n", This, entityMap);
540     return E_NOTIMPL;
541 }
542
543 static HRESULT WINAPI domdoctype_get_notations(
544     IXMLDOMDocumentType *iface,
545     IXMLDOMNamedNodeMap **notationMap)
546 {
547     domdoctype *This = impl_from_IXMLDOMDocumentType( iface );
548     FIXME("(%p)->(%p): stub\n", This, notationMap);
549     return E_NOTIMPL;
550 }
551
552 static const struct IXMLDOMDocumentTypeVtbl domdoctype_vtbl =
553 {
554     domdoctype_QueryInterface,
555     domdoctype_AddRef,
556     domdoctype_Release,
557     domdoctype_GetTypeInfoCount,
558     domdoctype_GetTypeInfo,
559     domdoctype_GetIDsOfNames,
560     domdoctype_Invoke,
561     domdoctype_get_nodeName,
562     domdoctype_get_nodeValue,
563     domdoctype_put_nodeValue,
564     domdoctype_get_nodeType,
565     domdoctype_get_parentNode,
566     domdoctype_get_childNodes,
567     domdoctype_get_firstChild,
568     domdoctype_get_lastChild,
569     domdoctype_get_previousSibling,
570     domdoctype_get_nextSibling,
571     domdoctype_get_attributes,
572     domdoctype_insertBefore,
573     domdoctype_replaceChild,
574     domdoctype_removeChild,
575     domdoctype_appendChild,
576     domdoctype_hasChildNodes,
577     domdoctype_get_ownerDocument,
578     domdoctype_cloneNode,
579     domdoctype_get_nodeTypeString,
580     domdoctype_get_text,
581     domdoctype_put_text,
582     domdoctype_get_specified,
583     domdoctype_get_definition,
584     domdoctype_get_nodeTypedValue,
585     domdoctype_put_nodeTypedValue,
586     domdoctype_get_dataType,
587     domdoctype_put_dataType,
588     domdoctype_get_xml,
589     domdoctype_transformNode,
590     domdoctype_selectNodes,
591     domdoctype_selectSingleNode,
592     domdoctype_get_parsed,
593     domdoctype_get_namespaceURI,
594     domdoctype_get_prefix,
595     domdoctype_get_baseName,
596     domdoctype_transformNodeToObject,
597     domdoctype_get_name,
598     domdoctype_get_entities,
599     domdoctype_get_notations
600 };
601
602 static const tid_t domdoctype_iface_tids[] = {
603     IXMLDOMDocumentType_tid,
604     0
605 };
606
607 static dispex_static_data_t domdoctype_dispex = {
608     NULL,
609     IXMLDOMDocumentType_tid,
610     NULL,
611     domdoctype_iface_tids
612 };
613
614 IUnknown* create_doc_type( xmlNodePtr doctype )
615 {
616     domdoctype *This;
617
618     This = heap_alloc( sizeof *This );
619     if ( !This )
620         return NULL;
621
622     This->IXMLDOMDocumentType_iface.lpVtbl = &domdoctype_vtbl;
623     This->ref = 1;
624
625     init_xmlnode(&This->node, doctype, (IXMLDOMNode*)&This->IXMLDOMDocumentType_iface,
626             &domdoctype_dispex);
627
628     return (IUnknown*)&This->IXMLDOMDocumentType_iface;
629 }
630
631 #endif