mshtml: Added get_body implementation.
[wine] / dlls / mshtml / htmldoc.c
1 /*
2  * Copyright 2005 Jacek Caban
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
38
39 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
40 {
41     HTMLDocument *This = HTMLDOC_THIS(iface);
42
43     *ppvObject = NULL;
44     if(IsEqualGUID(&IID_IUnknown, riid)) {
45         TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
46         *ppvObject = HTMLDOC(This);
47     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48         TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
49         *ppvObject = HTMLDOC(This);
50     }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
51         TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
52         *ppvObject = HTMLDOC(This);
53     }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
54         TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
55         *ppvObject = HTMLDOC(This);
56     }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
57         TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
58         *ppvObject = HTMLDOC3(This);
59     }else if(IsEqualGUID(&IID_IPersist, riid)) {
60         TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
61         *ppvObject = PERSIST(This);
62     }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
63         TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
64         *ppvObject = PERSISTMON(This);
65     }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
66         TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
67         *ppvObject = PERSISTFILE(This);
68     }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
69         TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
70         *ppvObject = MONPROP(This);
71     }else if(IsEqualGUID(&IID_IOleObject, riid)) {
72         TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
73         *ppvObject = OLEOBJ(This);
74     }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
75         TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
76         *ppvObject = OLEDOC(This);
77     }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
78         TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
79         *ppvObject = DOCVIEW(This);
80     }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
81         TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
82         *ppvObject = ACTOBJ(This);
83     }else if(IsEqualGUID(&IID_IViewObject, riid)) {
84         TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
85         *ppvObject = VIEWOBJ(This);
86     }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
87         TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
88         *ppvObject = VIEWOBJ2(This);
89     }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
90         TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
91         *ppvObject = OLEWIN(This);
92     }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
93         TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
94         *ppvObject = INPLACEOBJ(This);
95     }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
96         TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
97         *ppvObject = INPLACEWIN(This);
98     }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
99         TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
100         *ppvObject = SERVPROV(This);
101     }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
102         TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
103         *ppvObject = CMDTARGET(This);
104     }else if(IsEqualGUID(&IID_IOleControl, riid)) {
105         TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
106         *ppvObject = CONTROL(This);
107     }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
108         TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
109         *ppvObject = HLNKTARGET(This);
110     }
111
112     if(*ppvObject) {
113         IHTMLDocument2_AddRef(iface);
114         return S_OK;
115     }
116
117     FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
118     return E_NOINTERFACE;
119 }
120
121 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
122 {
123     HTMLDocument *This = HTMLDOC_THIS(iface);
124     ULONG ref = InterlockedIncrement(&This->ref);
125     TRACE("(%p) ref = %lu\n", This, ref);
126     return ref;
127 }
128
129 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
130 {
131     HTMLDocument *This = HTMLDOC_THIS(iface);
132     ULONG ref = InterlockedDecrement(&This->ref);
133
134     TRACE("(%p) ref = %lu\n", This, ref);
135
136     if(!ref) {
137         if(This->client)
138             IOleObject_SetClientSite(OLEOBJ(This), NULL);
139         if(This->in_place_active)
140             IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
141         if(This->ipsite)
142             IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
143
144         if(This->tooltips_hwnd)
145             DestroyWindow(This->tooltips_hwnd);
146         if(This->hwnd)
147             DestroyWindow(This->hwnd);
148
149         release_nodes(This);
150
151         if(This->nscontainer)
152             NSContainer_Release(This->nscontainer);
153
154         HeapFree(GetProcessHeap(), 0, This);
155
156         UNLOCK_MODULE();
157     }
158
159     return ref;
160 }
161
162 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
163 {
164     FIXME("(%p)->(%p)\n", iface, pctinfo);
165     return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
169                                                 LCID lcid, ITypeInfo **ppTInfo)
170 {
171     FIXME("(%p)->(%u %lu %p)\n", iface, iTInfo, lcid, ppTInfo);
172     return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
176                                                 LPOLESTR *rgszNames, UINT cNames,
177                                                 LCID lcid, DISPID *rgDispId)
178 {
179     FIXME("(%p)->(%s %p %u %lu %p)\n", iface, debugstr_guid(riid), rgszNames, cNames,
180                                         lcid, rgDispId);
181     return E_NOTIMPL;
182 }
183
184 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
185                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
186                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
187 {
188     FIXME("(%p)->(%ld %s %ld %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
189             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
194 {
195     FIXME("(%p)->(%p)\n", iface, p);
196     return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
200 {
201     FIXME("(%p)->(%p)\n", iface, p);
202     return E_NOTIMPL;
203 }
204
205 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
206 {
207     HTMLDocument *This = HTMLDOC_THIS(iface);
208     nsIDOMDocument *nsdoc;
209     nsIDOMHTMLDocument *nshtmldoc;
210     nsIDOMHTMLElement *nsbody = NULL;
211     HTMLDOMNode *node;
212     nsresult nsres;
213
214     TRACE("(%p)->(%p)\n", This, p);
215
216     *p = NULL;
217
218     if(!This->nscontainer)
219         return S_OK;
220
221     nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
222     if(NS_FAILED(nsres)) {
223         ERR("GetDocument failed: %08lx\n", nsres);
224         return S_OK;
225     }
226
227     if(NS_FAILED(nsres) || !nsdoc) 
228         return S_OK;
229
230     nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
231     nsIDOMDocument_Release(nsdoc);
232
233     nsres = nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
234     nsIDOMHTMLDocument_Release(nshtmldoc);
235
236     if(NS_FAILED(nsres) || !nsbody) {
237         TRACE("Could not get body: %08lx\n", nsres);
238         return S_OK;
239     }
240
241     node = get_node(This, (nsIDOMNode*)nsbody);
242     nsIDOMHTMLElement_Release(nsbody);
243
244     IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
245
246     TRACE("*p = %p\n", *p);
247     return S_OK;
248 }
249
250 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
251 {
252     FIXME("(%p)->(%p)\n", iface, p);
253     return E_NOTIMPL;
254 }
255
256 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
257 {
258     FIXME("(%p)->(%p)\n", iface, p);
259     return E_NOTIMPL;
260 }
261
262 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
263 {
264     FIXME("(%p)->(%p)\n", iface, p);
265     return E_NOTIMPL;
266 }
267
268 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
269 {
270     FIXME("(%p)->(%p)\n", iface, p);
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
275 {
276     FIXME("(%p)->(%p)\n", iface, p);
277     return E_NOTIMPL;
278 }
279
280 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
281 {
282     FIXME("(%p)->(%p)\n", iface, p);
283     return E_NOTIMPL;
284 }
285
286 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
287 {
288     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
289     return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
293 {
294     FIXME("(%p)->(%p)\n", iface, p);
295     return E_NOTIMPL;
296 }
297
298 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
299 {
300     FIXME("(%p)->(%p)\n", iface, p);
301     return E_NOTIMPL;
302 }
303
304 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
305 {
306     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
307     return E_NOTIMPL;
308 }
309
310 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
311 {
312     FIXME("(%p)->(%p)\n", iface, p);
313     return E_NOTIMPL;
314 }
315
316 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
317 {
318     FIXME("(%p)->(%p)\n", iface, p);
319     return E_NOTIMPL;
320 }
321
322 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
323 {
324     FIXME("(%p)->(%p)\n", iface, p);
325     return E_NOTIMPL;
326 }
327
328 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
329 {
330     FIXME("(%p)->(%p)\n", iface, p);
331     return E_NOTIMPL;
332 }
333
334 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
335 {
336     FIXME("(%p)->(%p)\n", iface, p);
337     return E_NOTIMPL;
338 }
339
340 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
341 {
342     FIXME("(%p)->(%p)\n", iface, p);
343     return E_NOTIMPL;
344 }
345
346 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
347 {
348     FIXME("(%p)\n", iface);
349     return E_NOTIMPL;
350 }
351
352 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
353 {
354     FIXME("(%p)->(%p)\n", iface, p);
355     return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
359 {
360     FIXME("(%p)\n", iface);
361     return E_NOTIMPL;
362 }
363
364 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
365 {
366     FIXME("(%p)->(%p)\n", iface, p);
367     return E_NOTIMPL;
368 }
369
370 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
371 {
372     FIXME("(%p)\n", iface);
373     return E_NOTIMPL;
374 }
375
376 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
377 {
378     FIXME("(%p)->(%p)\n", iface, p);
379     return E_NOTIMPL;
380 }
381
382 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
383 {
384     FIXME("(%p)->()\n", iface);
385     return E_NOTIMPL;
386 }
387
388 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
389 {
390     FIXME("(%p)->(%p)\n", iface, p);
391     return E_NOTIMPL;
392 }
393
394 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
395 {
396     FIXME("(%p)\n", iface);
397     return E_NOTIMPL;
398 }
399
400 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
401 {
402     FIXME("(%p)->(%p)\n", iface, p);
403     return E_NOTIMPL;
404 }
405
406 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
407 {
408     FIXME("(%p)->(%p)\n", iface, p);
409     return E_NOTIMPL;
410 }
411
412 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
413 {
414     FIXME("(%p)->(%p)\n", iface, p);
415     return E_NOTIMPL;
416 }
417
418 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
419 {
420     FIXME("(%p)->(%p)\n", iface, p);
421     return E_NOTIMPL;
422 }
423
424 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
425 {
426     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
427     return E_NOTIMPL;
428 }
429
430 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
431 {
432     FIXME("(%p)->(%p)\n", iface, p);
433     return E_NOTIMPL;
434 }
435
436 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
437 {
438     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
439     return E_NOTIMPL;
440 }
441
442 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
443 {
444     FIXME("(%p)->(%p)\n", iface, p);
445     return E_NOTIMPL;
446 }
447
448 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
449 {
450     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
451     return E_NOTIMPL;
452 }
453
454 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
455 {
456     FIXME("(%p)->(%p)\n", iface, p);
457     return E_NOTIMPL;
458 }
459
460 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
461 {
462     FIXME("(%p)->(%x)\n", iface, v);
463     return E_NOTIMPL;
464 }
465
466 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
467 {
468     FIXME("(%p)->(%p)\n", iface, p);
469     return E_NOTIMPL;
470 }
471
472 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
473 {
474     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
475     return E_NOTIMPL;
476 }
477
478 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
479 {
480     FIXME("(%p)->(%p)\n", iface, p);
481     return E_NOTIMPL;
482 }
483
484 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
485 {
486     FIXME("(%p)->(%s)\n", iface, debugstr_w(v));
487     return E_NOTIMPL;
488 }
489
490 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
491 {
492     FIXME("(%p)->(%p)\n", iface, p);
493     return E_NOTIMPL;
494 }
495
496 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
497 {
498     FIXME("(%p)->(%p)\n", iface, p);
499     return E_NOTIMPL;
500 }
501
502 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
503 {
504     FIXME("(%p)->(%p)\n", iface, p);
505     return E_NOTIMPL;
506 }
507
508 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
509 {
510     FIXME("(%p)->(%p)\n", iface, p);
511     return E_NOTIMPL;
512 }
513
514 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
515 {
516     FIXME("(%p)->(%p)\n", iface, p);
517     return E_NOTIMPL;
518 }
519
520 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
521 {
522     FIXME("(%p)->(%p)\n", iface, p);
523     return E_NOTIMPL;
524 }
525
526 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
527 {
528     FIXME("(%p)->(%p)\n", iface, p);
529     return E_NOTIMPL;
530 }
531
532 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
533 {
534     FIXME("(%p)->(%p)\n", iface, p);
535     return E_NOTIMPL;
536 }
537
538 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
539 {
540     FIXME("(%p)->(%p)\n", iface, p);
541     return E_NOTIMPL;
542 }
543
544 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
545 {
546     FIXME("(%p)->(%p)\n", iface, psarray);
547     return E_NOTIMPL;
548 }
549
550 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
551 {
552     FIXME("(%p)->(%p)\n", iface, psarray);
553     return E_NOTIMPL;
554 }
555
556 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
557                         VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
558 {
559     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(url), pomWindowResult);
560     return E_NOTIMPL;
561 }
562
563 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
564 {
565     FIXME("(%p)\n", iface);
566     return E_NOTIMPL;
567 }
568
569 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
570 {
571     FIXME("(%p)\n", iface);
572     return E_NOTIMPL;
573 }
574
575 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
576                                                         VARIANT_BOOL *pfRet)
577 {
578     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
579     return E_NOTIMPL;
580 }
581
582 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
583                                                         VARIANT_BOOL *pfRet)
584 {
585     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
586     return E_NOTIMPL;
587 }
588
589 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
590                                                         VARIANT_BOOL *pfRet)
591 {
592     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
593     return E_NOTIMPL;
594 }
595
596 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
597                                                         VARIANT_BOOL *pfRet)
598 {
599     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
600     return E_NOTIMPL;
601 }
602
603 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
604                                                         BSTR *pfRet)
605 {
606     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
607     return E_NOTIMPL;
608 }
609
610 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
611                                                         VARIANT *pfRet)
612 {
613     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
614     return E_NOTIMPL;
615 }
616
617 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
618                                 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
619 {
620     FIXME("(%p)->(%s %x %p)\n", iface, debugstr_w(cmdID), showUI, pfRet);
621     return E_NOTIMPL;
622 }
623
624 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
625                                                         VARIANT_BOOL *pfRet)
626 {
627     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(cmdID), pfRet);
628     return E_NOTIMPL;
629 }
630
631 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
632                                                     IHTMLElement **newElem)
633 {
634     FIXME("(%p)->(%s %p)\n", iface, debugstr_w(eTag), newElem);
635     return E_NOTIMPL;
636 }
637
638 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
639 {
640     FIXME("(%p)\n", iface);
641     return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
645 {
646     FIXME("(%p)->(%p)\n", iface, p);
647     return E_NOTIMPL;
648 }
649
650 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
651 {
652     FIXME("(%p)\n", iface);
653     return E_NOTIMPL;
654 }
655
656 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
657 {
658     FIXME("(%p)->(%p)\n", iface, p);
659     return E_NOTIMPL;
660 }
661
662 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
663 {
664     FIXME("(%p)\n", iface);
665     return E_NOTIMPL;
666 }
667
668 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
669 {
670     FIXME("(%p)->(%p)\n", iface, p);
671     return E_NOTIMPL;
672 }
673
674 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
675 {
676     FIXME("(%p)\n", iface);
677     return E_NOTIMPL;
678 }
679
680 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
681 {
682     FIXME("(%p)->(%p)\n", iface, p);
683     return E_NOTIMPL;
684 }
685
686 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
687 {
688     FIXME("(%p)\n", iface);
689     return E_NOTIMPL;
690 }
691
692 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
693 {
694     FIXME("(%p)->(%p)\n", iface, p);
695     return E_NOTIMPL;
696 }
697
698 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
699 {
700     FIXME("(%p)\n", iface);
701     return E_NOTIMPL;
702 }
703
704 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
705 {
706     FIXME("(%p)->(%p)\n", iface, p);
707     return E_NOTIMPL;
708 }
709
710 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
711 {
712     FIXME("(%p)\n", iface);
713     return E_NOTIMPL;
714 }
715
716 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
717 {
718     FIXME("(%p)->(%p)\n", iface, p);
719     return E_NOTIMPL;
720 }
721
722 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
723 {
724     FIXME("(%p)\n", iface);
725     return E_NOTIMPL;
726 }
727
728 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
729 {
730     FIXME("(%p)->(%p)\n", iface, p);
731     return E_NOTIMPL;
732 }
733
734 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
735 {
736     FIXME("(%p)\n", iface);
737     return E_NOTIMPL;
738 }
739
740 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
741 {
742     FIXME("(%p)->(%p)\n", iface, p);
743     return E_NOTIMPL;
744 }
745
746 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
747 {
748     FIXME("(%p)\n", iface);
749     return E_NOTIMPL;
750 }
751
752 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
753 {
754     FIXME("(%p)->(%p)\n", iface, p);
755     return E_NOTIMPL;
756 }
757
758 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
759 {
760     FIXME("(%p)\n", iface);
761     return E_NOTIMPL;
762 }
763
764 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
765 {
766     FIXME("(%p)->(%p)\n", iface, p);
767     return E_NOTIMPL;
768 }
769
770 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
771 {
772     FIXME("(%p)\n", iface);
773     return E_NOTIMPL;
774 }
775
776 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
777 {
778     FIXME("(%p)->(%p)\n", iface, p);
779     return E_NOTIMPL;
780 }
781
782 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
783 {
784     FIXME("(%p)\n", iface);
785     return E_NOTIMPL;
786 }
787
788 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
789 {
790     FIXME("(%p)->(%p)\n", iface, p);
791     return E_NOTIMPL;
792 }
793
794 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
795 {
796     FIXME("(%p)\n", iface);
797     return E_NOTIMPL;
798 }
799
800 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
801 {
802     FIXME("(%p)->(%p)\n", iface, p);
803     return E_NOTIMPL;
804 }
805
806 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
807 {
808     FIXME("(%p)\n", iface);
809     return E_NOTIMPL;
810 }
811
812 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
813 {
814     FIXME("(%p)->(%p)\n", iface, p);
815     return E_NOTIMPL;
816 }
817
818 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
819 {
820     FIXME("(%p)\n", iface);
821     return E_NOTIMPL;
822 }
823
824 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
825 {
826     FIXME("(%p)->(%p)\n", iface, p);
827     return E_NOTIMPL;
828 }
829
830 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
831 {
832     FIXME("(%p)\n", iface);
833     return E_NOTIMPL;
834 }
835
836 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
837 {
838     FIXME("(%p)->(%p)\n", iface, p);
839     return E_NOTIMPL;
840 }
841
842 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
843                                                         IHTMLElement **elementHit)
844 {
845     FIXME("(%p)->(%ld %ld %p)\n", iface, x, y, elementHit);
846     return E_NOTIMPL;
847 }
848
849 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
850 {
851     FIXME("(%p)->(%p)\n", iface, p);
852     return E_NOTIMPL;
853 }
854
855 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
856                                                     IHTMLStyleSheetsCollection **p)
857 {
858     FIXME("(%p)->(%p)\n", iface, p);
859     return E_NOTIMPL;
860 }
861
862 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
863 {
864     FIXME("(%p)\n", iface);
865     return E_NOTIMPL;
866 }
867
868 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
869 {
870     FIXME("(%p)->(%p)\n", iface, p);
871     return E_NOTIMPL;
872 }
873
874 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
875 {
876     FIXME("(%p)\n", iface);
877     return E_NOTIMPL;
878 }
879
880 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
881 {
882     FIXME("(%p)->(%p)\n", iface, p);
883     return E_NOTIMPL;
884 }
885
886 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
887 {
888     FIXME("(%p)->(%p)\n", iface, String);
889     return E_NOTIMPL;
890 }
891
892 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
893                                             long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
894 {
895     FIXME("(%p)->(%s %ld %p)\n", iface, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
896     return E_NOTIMPL;
897 }
898
899 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
900     HTMLDocument_QueryInterface,
901     HTMLDocument_AddRef,
902     HTMLDocument_Release,
903     HTMLDocument_GetTypeInfoCount,
904     HTMLDocument_GetTypeInfo,
905     HTMLDocument_GetIDsOfNames,
906     HTMLDocument_Invoke,
907     HTMLDocument_get_Script,
908     HTMLDocument_get_all,
909     HTMLDocument_get_body,
910     HTMLDocument_get_activeElement,
911     HTMLDocument_get_images,
912     HTMLDocument_get_applets,
913     HTMLDocument_get_links,
914     HTMLDocument_get_forms,
915     HTMLDocument_get_anchors,
916     HTMLDocument_put_title,
917     HTMLDocument_get_title,
918     HTMLDocument_get_scripts,
919     HTMLDocument_put_designMode,
920     HTMLDocument_get_designMode,
921     HTMLDocument_get_selection,
922     HTMLDocument_get_readyState,
923     HTMLDocument_get_frames,
924     HTMLDocument_get_embeds,
925     HTMLDocument_get_plugins,
926     HTMLDocument_put_alinkColor,
927     HTMLDocument_get_alinkColor,
928     HTMLDocument_put_bgColor,
929     HTMLDocument_get_bgColor,
930     HTMLDocument_put_fgColor,
931     HTMLDocument_get_fgColor,
932     HTMLDocument_put_linkColor,
933     HTMLDocument_get_linkColor,
934     HTMLDocument_put_vlinkColor,
935     HTMLDocument_get_vlinkColor,
936     HTMLDocument_get_referrer,
937     HTMLDocument_get_location,
938     HTMLDocument_get_lastModified,
939     HTMLDocument_put_URL,
940     HTMLDocument_get_URL,
941     HTMLDocument_put_domain,
942     HTMLDocument_get_domain,
943     HTMLDocument_put_cookie,
944     HTMLDocument_get_cookie,
945     HTMLDocument_put_expando,
946     HTMLDocument_get_expando,
947     HTMLDocument_put_charset,
948     HTMLDocument_get_charset,
949     HTMLDocument_put_defaultCharset,
950     HTMLDocument_get_defaultCharset,
951     HTMLDocument_get_mimeType,
952     HTMLDocument_get_fileSize,
953     HTMLDocument_get_fileCreatedDate,
954     HTMLDocument_get_fileModifiedDate,
955     HTMLDocument_get_fileUpdatedDate,
956     HTMLDocument_get_security,
957     HTMLDocument_get_protocol,
958     HTMLDocument_get_nameProp,
959     HTMLDocument_write,
960     HTMLDocument_writeln,
961     HTMLDocument_open,
962     HTMLDocument_close,
963     HTMLDocument_clear,
964     HTMLDocument_queryCommandSupported,
965     HTMLDocument_queryCommandEnabled,
966     HTMLDocument_queryCommandState,
967     HTMLDocument_queryCommandIndeterm,
968     HTMLDocument_queryCommandText,
969     HTMLDocument_queryCommandValue,
970     HTMLDocument_execCommand,
971     HTMLDocument_execCommandShowHelp,
972     HTMLDocument_createElement,
973     HTMLDocument_put_onhelp,
974     HTMLDocument_get_onhelp,
975     HTMLDocument_put_onclick,
976     HTMLDocument_get_onclick,
977     HTMLDocument_put_ondblclick,
978     HTMLDocument_get_ondblclick,
979     HTMLDocument_put_onkeyup,
980     HTMLDocument_get_onkeyup,
981     HTMLDocument_put_onkeydown,
982     HTMLDocument_get_onkeydown,
983     HTMLDocument_put_onkeypress,
984     HTMLDocument_get_onkeypress,
985     HTMLDocument_put_onmouseup,
986     HTMLDocument_get_onmouseup,
987     HTMLDocument_put_onmousedown,
988     HTMLDocument_get_onmousedown,
989     HTMLDocument_put_onmousemove,
990     HTMLDocument_get_onmousemove,
991     HTMLDocument_put_onmouseout,
992     HTMLDocument_get_onmouseout,
993     HTMLDocument_put_onmouseover,
994     HTMLDocument_get_onmouseover,
995     HTMLDocument_put_onreadystatechange,
996     HTMLDocument_get_onreadystatechange,
997     HTMLDocument_put_onafterupdate,
998     HTMLDocument_get_onafterupdate,
999     HTMLDocument_put_onrowexit,
1000     HTMLDocument_get_onrowexit,
1001     HTMLDocument_put_onrowenter,
1002     HTMLDocument_get_onrowenter,
1003     HTMLDocument_put_ondragstart,
1004     HTMLDocument_get_ondragstart,
1005     HTMLDocument_put_onselectstart,
1006     HTMLDocument_get_onselectstart,
1007     HTMLDocument_elementFromPoint,
1008     HTMLDocument_get_parentWindow,
1009     HTMLDocument_get_styleSheets,
1010     HTMLDocument_put_onbeforeupdate,
1011     HTMLDocument_get_onbeforeupdate,
1012     HTMLDocument_put_onerrorupdate,
1013     HTMLDocument_get_onerrorupdate,
1014     HTMLDocument_toString,
1015     HTMLDocument_createStyleSheet
1016 };
1017
1018 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1019 {
1020     HTMLDocument *ret;
1021     HRESULT hres;
1022
1023     TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1024
1025     ret = HeapAlloc(GetProcessHeap(), 0, sizeof(HTMLDocument));
1026     ret->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1027     ret->ref = 0;
1028     ret->nscontainer = NULL;
1029     ret->nodes = NULL;
1030
1031     hres = IHTMLDocument_QueryInterface(HTMLDOC(ret), riid, ppvObject);
1032     if(FAILED(hres)) {
1033         HeapFree(GetProcessHeap(), 0, ret);
1034         return hres;
1035     }
1036
1037     LOCK_MODULE();
1038
1039     HTMLDocument_HTMLDocument3_Init(ret);
1040     HTMLDocument_Persist_Init(ret);
1041     HTMLDocument_OleObj_Init(ret);
1042     HTMLDocument_View_Init(ret);
1043     HTMLDocument_Window_Init(ret);
1044     HTMLDocument_Service_Init(ret);
1045     HTMLDocument_Hlink_Init(ret);
1046
1047     ret->nscontainer = NSContainer_Create(ret, NULL);
1048
1049     return hres;
1050 }