[MSHTML]
[reactos.git] / reactos / dll / win32 / 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 #define HTMLDOC5_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument5, iface)
38
39 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
40 REFIID riid, void **ppv)
41 {
42 HTMLDocument *This = HTMLDOC5_THIS(iface);
43 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
44 }
45
46 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
47 {
48 HTMLDocument *This = HTMLDOC5_THIS(iface);
49 return IHTMLDocument2_AddRef(HTMLDOC(This));
50 }
51
52 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
53 {
54 HTMLDocument *This = HTMLDOC5_THIS(iface);
55 return IHTMLDocument2_Release(HTMLDOC(This));
56 }
57
58 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
59 {
60 HTMLDocument *This = HTMLDOC5_THIS(iface);
61 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
62 }
63
64 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
65 LCID lcid, ITypeInfo **ppTInfo)
66 {
67 HTMLDocument *This = HTMLDOC5_THIS(iface);
68 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
69 }
70
71 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
72 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
73 {
74 HTMLDocument *This = HTMLDOC5_THIS(iface);
75 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
76 }
77
78 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
79 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
80 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
81 {
82 HTMLDocument *This = HTMLDOC5_THIS(iface);
83 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
84 pVarResult, pExcepInfo, puArgErr);
85 }
86
87 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
88 {
89 HTMLDocument *This = HTMLDOC5_THIS(iface);
90 FIXME("(%p)->(v)\n", This);
91 return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
95 {
96 HTMLDocument *This = HTMLDOC5_THIS(iface);
97 FIXME("(%p)->(%p)\n", This, p);
98 return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
102 {
103 HTMLDocument *This = HTMLDOC5_THIS(iface);
104 FIXME("(%p)->(%p)\n", This, p);
105 return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
109 {
110 HTMLDocument *This = HTMLDOC5_THIS(iface);
111 FIXME("(%p)->(%p)\n", This, p);
112 return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
116 IHTMLDOMAttribute **ppattribute)
117 {
118 HTMLDocument *This = HTMLDOC5_THIS(iface);
119 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
120 return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
124 IHTMLDOMNode **ppRetNode)
125 {
126 HTMLDocument *This = HTMLDOC5_THIS(iface);
127 nsIDOMComment *nscomment;
128 HTMLDOMNode *node;
129 nsAString str;
130 nsresult nsres;
131
132 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
133
134 if(!This->doc_node->nsdoc) {
135 WARN("NULL nsdoc\n");
136 return E_UNEXPECTED;
137 }
138
139 nsAString_InitDepend(&str, bstrdata);
140 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
141 nsAString_Finish(&str);
142 if(NS_FAILED(nsres)) {
143 ERR("CreateTextNode failed: %08x\n", nsres);
144 return E_FAIL;
145 }
146
147 node = &HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment)->node;
148 nsIDOMElement_Release(nscomment);
149
150 *ppRetNode = HTMLDOMNODE(node);
151 IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
152 return S_OK;
153 }
154
155 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
156 {
157 HTMLDocument *This = HTMLDOC5_THIS(iface);
158 FIXME("(%p)->(v)\n", This);
159 return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
163 {
164 HTMLDocument *This = HTMLDOC5_THIS(iface);
165 FIXME("(%p)->(%p)\n", This, p);
166 return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
170 {
171 HTMLDocument *This = HTMLDOC5_THIS(iface);
172 FIXME("(%p)->(v)\n", This);
173 return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
177 {
178 HTMLDocument *This = HTMLDOC5_THIS(iface);
179 FIXME("(%p)->(%p)\n", This, p);
180 return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
184 {
185 HTMLDocument *This = HTMLDOC5_THIS(iface);
186 FIXME("(%p)->(v)\n", This);
187 return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
191 {
192 HTMLDocument *This = HTMLDOC5_THIS(iface);
193 FIXME("(%p)->(%p)\n", This, p);
194 return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
198 {
199 HTMLDocument *This = HTMLDOC5_THIS(iface);
200 FIXME("(%p)->(v)\n", This);
201 return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
205 {
206 HTMLDocument *This = HTMLDOC5_THIS(iface);
207 FIXME("(%p)->(%p)\n", This, p);
208 return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
212 {
213 HTMLDocument *This = HTMLDOC5_THIS(iface);
214 FIXME("(%p)->(v)\n", This);
215 return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
219 {
220 HTMLDocument *This = HTMLDOC5_THIS(iface);
221 FIXME("(%p)->(%p)\n", This, p);
222 return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
226 {
227 HTMLDocument *This = HTMLDOC5_THIS(iface);
228 FIXME("(%p)->(v)\n", This);
229 return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
233 {
234 HTMLDocument *This = HTMLDOC5_THIS(iface);
235 FIXME("(%p)->(%p)\n", This, p);
236 return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
240 {
241 HTMLDocument *This = HTMLDOC5_THIS(iface);
242 nsIDOMNSHTMLDocument *nshtmldoc;
243 nsAString mode_str;
244 const PRUnichar *mode;
245 nsresult nsres;
246
247 TRACE("(%p)->(%p)\n", This, p);
248
249 if(!This->doc_node->nsdoc) {
250 WARN("NULL nsdoc\n");
251 return E_UNEXPECTED;
252 }
253
254 nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument, (void**)&nshtmldoc);
255 if(NS_FAILED(nsres)) {
256 ERR("Could not get nsIDOMNSHTMLDocument: %08x\n", nsres);
257 return S_OK;
258 }
259
260 nsAString_Init(&mode_str, NULL);
261 nsIDOMNSHTMLDocument_GetCompatMode(nshtmldoc, &mode_str);
262 nsIDOMNSHTMLDocument_Release(nshtmldoc);
263
264 nsAString_GetData(&mode_str, &mode);
265 *p = SysAllocString(mode);
266 nsAString_Finish(&mode_str);
267
268 return S_OK;
269 }
270
271 #undef HTMLDOC5_THIS
272
273 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
274 HTMLDocument5_QueryInterface,
275 HTMLDocument5_AddRef,
276 HTMLDocument5_Release,
277 HTMLDocument5_GetTypeInfoCount,
278 HTMLDocument5_GetTypeInfo,
279 HTMLDocument5_GetIDsOfNames,
280 HTMLDocument5_Invoke,
281 HTMLDocument5_put_onmousewheel,
282 HTMLDocument5_get_onmousewheel,
283 HTMLDocument5_get_doctype,
284 HTMLDocument5_get_implementation,
285 HTMLDocument5_createAttribute,
286 HTMLDocument5_createComment,
287 HTMLDocument5_put_onfocusin,
288 HTMLDocument5_get_onfocusin,
289 HTMLDocument5_put_onfocusout,
290 HTMLDocument5_get_onfocusout,
291 HTMLDocument5_put_onactivate,
292 HTMLDocument5_get_onactivate,
293 HTMLDocument5_put_ondeactivate,
294 HTMLDocument5_get_ondeactivate,
295 HTMLDocument5_put_onbeforeactivate,
296 HTMLDocument5_get_onbeforeactivate,
297 HTMLDocument5_put_onbeforedeactivate,
298 HTMLDocument5_get_onbeforedeactivate,
299 HTMLDocument5_get_compatMode
300 };
301
302 #define HTMLDOC6_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument6, iface)
303
304 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
305 REFIID riid, void **ppv)
306 {
307 HTMLDocument *This = HTMLDOC6_THIS(iface);
308 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
309 }
310
311 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
312 {
313 HTMLDocument *This = HTMLDOC6_THIS(iface);
314 return IHTMLDocument2_AddRef(HTMLDOC(This));
315 }
316
317 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
318 {
319 HTMLDocument *This = HTMLDOC6_THIS(iface);
320 return IHTMLDocument2_Release(HTMLDOC(This));
321 }
322
323 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
324 {
325 HTMLDocument *This = HTMLDOC6_THIS(iface);
326 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
327 }
328
329 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
330 LCID lcid, ITypeInfo **ppTInfo)
331 {
332 HTMLDocument *This = HTMLDOC6_THIS(iface);
333 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
334 }
335
336 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
337 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
338 {
339 HTMLDocument *This = HTMLDOC6_THIS(iface);
340 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
341 }
342
343 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
344 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
345 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
346 {
347 HTMLDocument *This = HTMLDOC6_THIS(iface);
348 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
349 pVarResult, pExcepInfo, puArgErr);
350 }
351
352 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
353 IHTMLDocumentCompatibleInfoCollection **p)
354 {
355 HTMLDocument *This = HTMLDOC6_THIS(iface);
356 FIXME("(%p)->(%p)\n", This, p);
357 return E_NOTIMPL;
358 }
359
360 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
361 VARIANT *p)
362 {
363 HTMLDocument *This = HTMLDOC6_THIS(iface);
364 FIXME("(%p)->(%p)\n", This, p);
365 return E_NOTIMPL;
366 }
367
368 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
369 VARIANT *p)
370 {
371 HTMLDocument *This = HTMLDOC6_THIS(iface);
372 FIXME("(%p)->(%p)\n", This, p);
373 return E_NOTIMPL;
374 }
375
376 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface,
377 VARIANT p)
378 {
379 HTMLDocument *This = HTMLDOC6_THIS(iface);
380 FIXME("(%p)->(v)\n", This);
381 return E_NOTIMPL;
382 }
383
384 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
385 VARIANT *p)
386 {
387 HTMLDocument *This = HTMLDOC6_THIS(iface);
388 FIXME("(%p)->(%p)\n", This, p);
389 return E_NOTIMPL;
390 }
391
392 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface,
393 VARIANT p)
394 {
395 HTMLDocument *This = HTMLDOC6_THIS(iface);
396 FIXME("(%p)->(v)\n", This);
397 return E_NOTIMPL;
398 }
399
400 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
401 BSTR bstrId, IHTMLElement2 **p)
402 {
403 HTMLDocument *This = HTMLDOC6_THIS(iface);
404 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
405 return E_NOTIMPL;
406 }
407
408 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
409 {
410 HTMLDocument *This = HTMLDOC6_THIS(iface);
411 FIXME("(%p)->()\n", This);
412 return E_NOTIMPL;
413 }
414
415 #undef HTMLDOC6_THIS
416
417 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
418 HTMLDocument6_QueryInterface,
419 HTMLDocument6_AddRef,
420 HTMLDocument6_Release,
421 HTMLDocument6_GetTypeInfoCount,
422 HTMLDocument6_GetTypeInfo,
423 HTMLDocument6_GetIDsOfNames,
424 HTMLDocument6_Invoke,
425 HTMLDocument6_get_compatible,
426 HTMLDocument6_get_documentMode,
427 HTMLDocument6_put_onstorage,
428 HTMLDocument6_get_onstorage,
429 HTMLDocument6_put_onstoragecommit,
430 HTMLDocument6_get_onstoragecommit,
431 HTMLDocument6_getElementById,
432 HTMLDocument6_updateSettings
433 };
434
435 void HTMLDocument_HTMLDocument5_Init(HTMLDocument *This)
436 {
437 This->lpHTMLDocument5Vtbl = &HTMLDocument5Vtbl;
438 This->lpHTMLDocument6Vtbl = &HTMLDocument6Vtbl;
439 }