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