dplayx: Introduce impl_from_IDirectPlayLobby3A().
[wine] / dlls / mshtml / htmldoc5.c
1 /*
2  * Copyright 2007 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
38 {
39     return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
40 }
41
42 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
43         REFIID riid, void **ppv)
44 {
45     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
46     return htmldoc_query_interface(This, riid, ppv);
47 }
48
49 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
50 {
51     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
52     return htmldoc_addref(This);
53 }
54
55 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
56 {
57     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
58     return htmldoc_release(This);
59 }
60
61 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
62 {
63     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
64     return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
65 }
66
67 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
68         LCID lcid, ITypeInfo **ppTInfo)
69 {
70     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
71     return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
72 }
73
74 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
75         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
76 {
77     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
78     return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
79             rgDispId);
80 }
81
82 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
83                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
84                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
85 {
86     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
87     return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
88             pDispParams, pVarResult, pExcepInfo, puArgErr);
89 }
90
91 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
92 {
93     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
94     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
95     return E_NOTIMPL;
96 }
97
98 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
99 {
100     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
101     FIXME("(%p)->(%p)\n", This, p);
102     return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
106 {
107     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
108     FIXME("(%p)->(%p)\n", This, p);
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
113 {
114     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
115     FIXME("(%p)->(%p)\n", This, p);
116     return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
120         IHTMLDOMAttribute **ppattribute)
121 {
122     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
123     HTMLDOMAttribute *attr;
124     HRESULT hres;
125
126     TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
127
128     hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
129     if(FAILED(hres))
130         return hres;
131
132     *ppattribute = &attr->IHTMLDOMAttribute_iface;
133     return S_OK;
134 }
135
136 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
137         IHTMLDOMNode **ppRetNode)
138 {
139     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
140     nsIDOMComment *nscomment;
141     HTMLElement *elem;
142     nsAString str;
143     nsresult nsres;
144     HRESULT hres;
145
146     TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
147
148     if(!This->doc_node->nsdoc) {
149         WARN("NULL nsdoc\n");
150         return E_UNEXPECTED;
151     }
152
153     nsAString_InitDepend(&str, bstrdata);
154     nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
155     nsAString_Finish(&str);
156     if(NS_FAILED(nsres)) {
157         ERR("CreateTextNode failed: %08x\n", nsres);
158         return E_FAIL;
159     }
160
161     hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
162     nsIDOMComment_Release(nscomment);
163     if(FAILED(hres))
164         return hres;
165
166     *ppRetNode = &elem->node.IHTMLDOMNode_iface;
167     return S_OK;
168 }
169
170 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
171 {
172     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
173     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
174     return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
178 {
179     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
180     FIXME("(%p)->(%p)\n", This, p);
181     return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
185 {
186     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
187     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
188     return E_NOTIMPL;
189 }
190
191 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
192 {
193     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
194     FIXME("(%p)->(%p)\n", This, p);
195     return E_NOTIMPL;
196 }
197
198 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
199 {
200     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
201     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
206 {
207     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
208     FIXME("(%p)->(%p)\n", This, p);
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
213 {
214     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
215     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
220 {
221     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
222     FIXME("(%p)->(%p)\n", This, p);
223     return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
227 {
228     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
229     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
230     return E_NOTIMPL;
231 }
232
233 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
234 {
235     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
236     FIXME("(%p)->(%p)\n", This, p);
237     return E_NOTIMPL;
238 }
239
240 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
241 {
242     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
243     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
244     return E_NOTIMPL;
245 }
246
247 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
248 {
249     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
250     FIXME("(%p)->(%p)\n", This, p);
251     return E_NOTIMPL;
252 }
253
254 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
255 {
256     HTMLDocument *This = impl_from_IHTMLDocument5(iface);
257     nsAString mode_str;
258     const PRUnichar *mode;
259
260     TRACE("(%p)->(%p)\n", This, p);
261
262     if(!This->doc_node->nsdoc) {
263         WARN("NULL nsdoc\n");
264         return E_UNEXPECTED;
265     }
266
267     nsAString_Init(&mode_str, NULL);
268     nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
269
270     nsAString_GetData(&mode_str, &mode);
271     *p = SysAllocString(mode);
272     nsAString_Finish(&mode_str);
273
274     return S_OK;
275 }
276
277 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
278     HTMLDocument5_QueryInterface,
279     HTMLDocument5_AddRef,
280     HTMLDocument5_Release,
281     HTMLDocument5_GetTypeInfoCount,
282     HTMLDocument5_GetTypeInfo,
283     HTMLDocument5_GetIDsOfNames,
284     HTMLDocument5_Invoke,
285     HTMLDocument5_put_onmousewheel,
286     HTMLDocument5_get_onmousewheel,
287     HTMLDocument5_get_doctype,
288     HTMLDocument5_get_implementation,
289     HTMLDocument5_createAttribute,
290     HTMLDocument5_createComment,
291     HTMLDocument5_put_onfocusin,
292     HTMLDocument5_get_onfocusin,
293     HTMLDocument5_put_onfocusout,
294     HTMLDocument5_get_onfocusout,
295     HTMLDocument5_put_onactivate,
296     HTMLDocument5_get_onactivate,
297     HTMLDocument5_put_ondeactivate,
298     HTMLDocument5_get_ondeactivate,
299     HTMLDocument5_put_onbeforeactivate,
300     HTMLDocument5_get_onbeforeactivate,
301     HTMLDocument5_put_onbeforedeactivate,
302     HTMLDocument5_get_onbeforedeactivate,
303     HTMLDocument5_get_compatMode
304 };
305
306 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
307 {
308     return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
309 }
310
311 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
312         REFIID riid, void **ppv)
313 {
314     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
315     return htmldoc_query_interface(This, riid, ppv);
316 }
317
318 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
319 {
320     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
321     return htmldoc_addref(This);
322 }
323
324 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
325 {
326     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
327     return htmldoc_release(This);
328 }
329
330 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
331 {
332     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
333     return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
334 }
335
336 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
337         LCID lcid, ITypeInfo **ppTInfo)
338 {
339     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
340     return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
341 }
342
343 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
344         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
345 {
346     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
347     return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
348             rgDispId);
349 }
350
351 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
352                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
353                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
354 {
355     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
356     return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
357             pDispParams, pVarResult, pExcepInfo, puArgErr);
358 }
359
360 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
361         IHTMLDocumentCompatibleInfoCollection **p)
362 {
363     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
364     FIXME("(%p)->(%p)\n", This, p);
365     return E_NOTIMPL;
366 }
367
368 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
369         VARIANT *p)
370 {
371     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
372     FIXME("(%p)->(%p)\n", This, p);
373     return E_NOTIMPL;
374 }
375
376 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
377         VARIANT *p)
378 {
379     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
380     FIXME("(%p)->(%p)\n", This, p);
381     return E_NOTIMPL;
382 }
383
384 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
385 {
386     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
387     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
388     return E_NOTIMPL;
389 }
390
391 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
392         VARIANT *p)
393 {
394     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
395     FIXME("(%p)->(%p)\n", This, p);
396     return E_NOTIMPL;
397 }
398
399 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
400 {
401     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
402     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
403     return E_NOTIMPL;
404 }
405
406 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
407         BSTR bstrId, IHTMLElement2 **p)
408 {
409     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
410     FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
411     return E_NOTIMPL;
412 }
413
414 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
415 {
416     HTMLDocument *This = impl_from_IHTMLDocument6(iface);
417     FIXME("(%p)->()\n", This);
418     return E_NOTIMPL;
419 }
420
421 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
422     HTMLDocument6_QueryInterface,
423     HTMLDocument6_AddRef,
424     HTMLDocument6_Release,
425     HTMLDocument6_GetTypeInfoCount,
426     HTMLDocument6_GetTypeInfo,
427     HTMLDocument6_GetIDsOfNames,
428     HTMLDocument6_Invoke,
429     HTMLDocument6_get_compatible,
430     HTMLDocument6_get_documentMode,
431     HTMLDocument6_put_onstorage,
432     HTMLDocument6_get_onstorage,
433     HTMLDocument6_put_onstoragecommit,
434     HTMLDocument6_get_onstoragecommit,
435     HTMLDocument6_getElementById,
436     HTMLDocument6_updateSettings
437 };
438
439 void HTMLDocument_HTMLDocument5_Init(HTMLDocument *This)
440 {
441     This->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
442     This->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;
443 }