Added an initial (mostly stub) implementation of MSHTML.DLL.
[wine] / dlls / mshtml / document.c
1 /*
2  *    HTML Document class
3  *
4  * Copyright 2003 Mike McCormack
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winnls.h"
29 #include "docobj.h"
30 #include "ole2.h"
31 #include "uuids.h"
32 #include "urlmon.h"
33 #include "oleidl.h"
34 #include "objidl.h"
35
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
39
40 typedef struct _HTMLDocument_impl {
41     ICOM_VTABLE(IPersistMoniker) *IPersistMoniker_vtbl;
42     ICOM_VTABLE(IPersistFile) *IPersistFile_vtbl;
43     ICOM_VTABLE(IPersist) *IPersist_vtbl;
44     ICOM_VTABLE(IOleObject) *IOleObject_vtbl;
45     ICOM_VTABLE(IViewObject) *IViewObject_vtbl;
46     ICOM_VTABLE(IOleDocument) *IOleDocument_vtbl;
47     ULONG ref_count;
48     IOleClientSite *site;
49 } HTMLDocument_impl;
50
51
52 static ULONG WINAPI HTMLDocument_AddRef(HTMLDocument_impl *This)
53 {
54     return ++This->ref_count;
55 }
56
57 static ULONG WINAPI HTMLDocument_Release(HTMLDocument_impl *This)
58 {
59     ULONG count;
60
61     count = --This->ref_count ;
62     if( !count )
63         HeapFree( GetProcessHeap(), 0, This );
64     
65     return count;
66 }
67
68 static HRESULT WINAPI HTMLDocument_QueryInterface(
69          HTMLDocument_impl *This, REFIID riid, LPVOID *ppv)
70 {
71     TRACE("%p %s %p\n", This, debugstr_guid(riid), ppv);
72
73     if( IsEqualGUID( riid, &IID_IUnknown ) )
74     {
75         TRACE("returning IUnknown\n");
76         HTMLDocument_AddRef(This);
77         *ppv = This;
78         return S_OK;
79     }
80     if( IsEqualGUID( riid, &IID_IPersistMoniker ) )
81     {
82         TRACE("returning IPersistMoniker\n");
83         HTMLDocument_AddRef(This);
84         *ppv = This;
85         return S_OK;
86     }
87     if( IsEqualGUID( riid, &IID_IPersistFile ) )
88     {
89         TRACE("returning IPersistFile\n");
90         HTMLDocument_AddRef(This);
91         *ppv = &(This->IPersistFile_vtbl);
92         return S_OK;
93     }
94     if( IsEqualGUID( riid, &IID_IOleObject ) )
95     {
96         TRACE("returning IOleObject\n");
97         HTMLDocument_AddRef(This);
98         *ppv = &(This->IOleObject_vtbl);
99         return S_OK;
100     }
101     if( IsEqualGUID( riid, &IID_IPersist ) )
102     {
103         TRACE("returning IPersist\n");
104         HTMLDocument_AddRef(This);
105         *ppv = &(This->IPersist_vtbl);
106         return S_OK;
107     }
108     if( IsEqualGUID( riid, &IID_IViewObject ) )
109     {
110         TRACE("returning IViewObject\n");
111         HTMLDocument_AddRef(This);
112         *ppv = &(This->IViewObject_vtbl);
113         return S_OK;
114     }
115     if( IsEqualGUID( riid, &IID_IOleDocument ) )
116     {
117         TRACE("returning IOleDocument\n");
118         HTMLDocument_AddRef(This);
119         *ppv = &(This->IOleDocument_vtbl);
120         return S_OK;
121     }
122     if( IsEqualGUID( riid, &IID_IDispatch ) )
123     {
124         TRACE("returning IDispatch\n");
125     }
126     if( IsEqualGUID( riid, &IID_IOleCommandTarget ) )
127     {
128         TRACE("returning IOleCommandTarget\n");
129     }
130     return E_NOINTERFACE;
131 }
132
133 static HRESULT WINAPI fnIPersistMoniker_QueryInterface(
134          IPersistMoniker *iface, REFIID riid, LPVOID *ppv)
135 {
136     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
137     return HTMLDocument_QueryInterface(This, riid, ppv);
138 }
139
140 static ULONG WINAPI fnIPersistMoniker_AddRef(IPersistMoniker *iface)
141 {
142     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
143     return HTMLDocument_AddRef(This);
144 }
145
146 static ULONG WINAPI fnIPersistMoniker_Release(IPersistMoniker *iface)
147 {
148     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
149     return HTMLDocument_Release(This);
150 }
151
152 static HRESULT WINAPI fnIPersistMoniker_GetClassID(IPersistMoniker *iface,
153            CLSID *pClassID )
154 {
155     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
156     FIXME("%p\n", This);
157     return E_NOTIMPL;
158 }
159
160 static HRESULT WINAPI fnIPersistMoniker_IsDirty(IPersistMoniker *iface )
161 {
162     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
163     FIXME("%p\n", This);
164     return E_NOTIMPL;
165 }
166
167 static HRESULT WINAPI fnIPersistMoniker_Load(IPersistMoniker *iface,
168            BOOL fFullyAvailable, IMoniker *pimkName, LPBC pibc, DWORD grfMode )
169 {
170     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
171     IStream *stm;
172     HRESULT r;
173     unsigned char buffer[0x201];
174     ULONG count;
175
176     TRACE("%p %d %p %p %08lx\n", This, 
177           fFullyAvailable, pimkName, pibc, grfMode);
178
179     r = IMoniker_BindToStorage( pimkName, pibc, NULL, 
180                                 &IID_IStream, (LPVOID*) &stm );
181     if( FAILED( r ) )
182     {
183         TRACE("IMoniker_BindToStorage failed %08lx\n", r);
184         return r;
185     }
186
187     while( 1 )
188     {
189         r = IStream_Read( stm, buffer, sizeof buffer-1, &count);
190         if( FAILED( r ) )
191             break;
192         if( count == 0 )
193             break;
194         buffer[count]=0;
195         TRACE("%s\n",buffer);
196     }
197
198     IStream_Release( stm );
199
200     return S_OK;
201 }
202
203 static HRESULT WINAPI fnIPersistMoniker_Save(IPersistMoniker *iface,
204            IMoniker *pinkName, LPBC pibc, BOOL fRemember )
205 {
206     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
207     FIXME("%p %p %p %d\n", This, pinkName, pibc, fRemember);
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI fnIPersistMoniker_SaveCompleted(IPersistMoniker *iface,
212            IMoniker *pinkName, LPBC pibc )
213 {
214     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
215     FIXME("%p %p %p\n", This, pinkName, pibc);
216     return E_NOTIMPL;
217 }
218
219 static HRESULT WINAPI fnIPersistMoniker_GetCurMoniker(IPersistMoniker *iface,
220            IMoniker **pinkName )
221 {
222     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistMoniker_vtbl, iface);
223     FIXME("%p\n", This);
224     return E_NOTIMPL;
225 }
226
227 static ICOM_VTABLE(IPersistMoniker) IPersistMoniker_vtbl =
228 {
229     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
230     fnIPersistMoniker_QueryInterface,
231     fnIPersistMoniker_AddRef,
232     fnIPersistMoniker_Release,
233     fnIPersistMoniker_GetClassID,
234     fnIPersistMoniker_IsDirty,
235     fnIPersistMoniker_Load,
236     fnIPersistMoniker_Save,
237     fnIPersistMoniker_SaveCompleted,
238     fnIPersistMoniker_GetCurMoniker
239 };
240
241 static ULONG WINAPI fnIPersistFile_AddRef(IPersistFile *iface)
242 {
243     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
244     return HTMLDocument_AddRef(This);
245 }
246
247 static ULONG WINAPI fnIPersistFile_Release(IPersistFile *iface)
248 {
249     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
250     return HTMLDocument_Release(This);
251 }
252
253 static HRESULT WINAPI fnIPersistFile_QueryInterface(
254            IPersistFile *iface, REFIID riid, LPVOID *ppv)
255 {
256     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
257     return HTMLDocument_QueryInterface(This, riid, ppv);
258 }
259
260 static HRESULT WINAPI fnIPersistFile_GetClassID(IPersistFile *iface,
261            CLSID *pClassID )
262 {
263     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
264
265     TRACE("%p\n", This);
266
267     memcpy( pClassID, &CLSID_HTMLDocument, sizeof CLSID_HTMLDocument);
268     return S_OK;
269 }
270
271 static HRESULT WINAPI fnIPersistFile_IsDirty(IPersistFile *iface )
272 {
273     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
274     FIXME("%p\n",This);
275     return E_NOTIMPL;
276 }
277
278 static HRESULT WINAPI fnIPersistFile_Load(IPersistFile *iface,
279            LPCOLESTR pszFileName, DWORD grfMode )
280 {
281     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
282     FIXME("%p %s %08lx\n", This, debugstr_w(pszFileName), grfMode);
283     return E_NOTIMPL;
284 }
285
286 static HRESULT WINAPI fnIPersistFile_Save(IPersistFile *iface, 
287            LPCOLESTR pszFileName, BOOL fRemember )
288 {
289     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
290     FIXME("%p %s %d\n", This, debugstr_w(pszFileName), fRemember);
291     return E_NOTIMPL;
292 }
293
294 static HRESULT WINAPI fnIPersistFile_SaveCompleted(IPersistFile *iface,
295            LPCOLESTR pszFileName )
296 {
297     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
298     FIXME("%p %s\n", This, debugstr_w(pszFileName));
299     return E_NOTIMPL;
300 }
301
302 static HRESULT WINAPI fnIPersistFile_GetCurFile(IPersistFile *iface,
303            LPOLESTR* ppszFileName)
304 {
305     ICOM_THIS_MULTI(HTMLDocument_impl, IPersistFile_vtbl, iface);
306     FIXME("%p %p\n",This,ppszFileName);
307     return E_NOTIMPL;
308 }
309
310 static ICOM_VTABLE(IPersistFile) IPersistFile_vtbl =
311 {
312     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
313     fnIPersistFile_QueryInterface,
314     fnIPersistFile_AddRef,
315     fnIPersistFile_Release,
316     fnIPersistFile_GetClassID,
317     fnIPersistFile_IsDirty,
318     fnIPersistFile_Load,
319     fnIPersistFile_Save,
320     fnIPersistFile_SaveCompleted,
321     fnIPersistFile_GetCurFile,
322 };
323
324 static ULONG WINAPI fnIOleObject_AddRef(IOleObject *iface)
325 {
326     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
327     return HTMLDocument_AddRef(This);
328 }
329
330 static ULONG WINAPI fnIOleObject_Release(IOleObject *iface)
331 {
332     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
333     return HTMLDocument_Release(This);
334 }
335
336 static HRESULT WINAPI fnIOleObject_QueryInterface(
337            IOleObject *iface, REFIID riid, LPVOID *ppv)
338 {
339     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
340     return HTMLDocument_QueryInterface(This, riid, ppv);
341 }
342
343 static HRESULT WINAPI fnIOleObject_SetClientSite(IOleObject *iface,
344            IOleClientSite *pClientSite)
345 {
346     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
347
348     TRACE("%p %p\n",This, pClientSite);
349
350     if( This->site )
351         IOleClientSite_Release( This->site );
352     if( pClientSite )
353         IOleClientSite_AddRef(pClientSite);
354     This->site = pClientSite;
355
356     return S_OK;
357 }
358
359 static HRESULT WINAPI fnIOleObject_GetClientSite(IOleObject *iface,
360            IOleClientSite **ppClientSite)
361 {
362     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
363
364     TRACE("%p\n",This);
365
366     if( This->site )
367         IOleClientSite_AddRef( This->site );
368     *ppClientSite = This->site;
369
370     return S_OK;
371 }
372
373 static HRESULT WINAPI fnIOleObject_SetHostNames(IOleObject *iface,
374            LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
375 {
376     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
377     TRACE("%p\n",This);
378     return E_NOTIMPL;
379 }
380
381 static HRESULT WINAPI fnIOleObject_Close(IOleObject *iface,
382            DWORD dwSaveOption)
383 {
384     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
385     TRACE("%p\n",This);
386     return E_NOTIMPL;
387 }
388
389 static HRESULT WINAPI fnIOleObject_SetMoniker(IOleObject *iface,
390            DWORD dwWhichMoniker, IMoniker *pmk)
391 {
392     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
393     TRACE("%p\n",This);
394     return E_NOTIMPL;
395 }
396
397 static HRESULT WINAPI fnIOleObject_GetMoniker(IOleObject *iface,
398            DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
399 {
400     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
401     TRACE("%p\n",This);
402     return E_NOTIMPL;
403 }
404
405 static HRESULT WINAPI fnIOleObject_InitFromData(IOleObject *iface,
406            IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved)
407 {
408     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
409     TRACE("%p\n",This);
410     return E_NOTIMPL;
411 }
412
413 static HRESULT WINAPI fnIOleObject_GetClipboardData(IOleObject *iface,
414            DWORD dwReserved, IDataObject **ppDataObject)
415 {
416     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
417     TRACE("%p\n",This);
418     return E_NOTIMPL;
419 }
420
421 static HRESULT WINAPI fnIOleObject_DoVerb(IOleObject *iface,
422            LONG iVerb, struct tagMSG *lpmsg, IOleClientSite *pActiveSite,
423            LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
424 {
425     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
426
427     TRACE("%p %ld %p %p %ld %p %p\n", This, 
428           iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
429
430     switch( iVerb )
431     {
432     case OLEIVERB_SHOW:
433         TRACE("OLEIVERB_SHOW  r = (%ld,%ld)-(%ld,%ld)\n",
434               lprcPosRect->left,  lprcPosRect->top,
435               lprcPosRect->right, lprcPosRect->bottom );
436         break;
437     }
438
439     /*return E_NOTIMPL; */
440     return S_OK;
441 }
442
443 static HRESULT WINAPI fnIOleObject_EnumVerbs(IOleObject *iface,
444            IEnumOLEVERB **ppEnumOleVerb)
445 {
446     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
447     TRACE("%p\n",This);
448     return E_NOTIMPL;
449 }
450
451 static HRESULT WINAPI fnIOleObject_Update(IOleObject *iface)
452 {
453     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
454     TRACE("%p\n",This);
455     return E_NOTIMPL;
456 }
457
458 static HRESULT WINAPI fnIOleObject_IsUpToDate(IOleObject *iface)
459 {
460     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
461     TRACE("%p\n",This);
462     return E_NOTIMPL;
463 }
464
465 static HRESULT WINAPI fnIOleObject_GetUserClassID(IOleObject *iface,
466            CLSID *pClsid)
467 {
468     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
469     TRACE("%p\n",This);
470     return E_NOTIMPL;
471 }
472
473 static HRESULT WINAPI fnIOleObject_GetUserType(IOleObject *iface,
474            DWORD dwFormOfType, LPOLESTR *pszUserType)
475 {
476     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
477     TRACE("%p\n",This);
478     return E_NOTIMPL;
479 }
480
481 static HRESULT WINAPI fnIOleObject_SetExtent(IOleObject *iface,
482            DWORD dwDrawAspect, SIZEL *psizel)
483 {
484     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
485     TRACE("%p\n",This);
486     return E_NOTIMPL;
487 }
488
489 static HRESULT WINAPI fnIOleObject_GetExtent(IOleObject *iface,
490            DWORD dwDrawAspect, SIZEL *psizel)
491 {
492     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
493     TRACE("%p\n",This);
494     return E_NOTIMPL;
495 }
496
497 static HRESULT WINAPI fnIOleObject_Advise(IOleObject *iface,
498            IAdviseSink *pAdvSink, DWORD *pdwConnection)
499 {
500     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
501     TRACE("%p\n",This);
502     return E_NOTIMPL;
503 }
504
505 static HRESULT WINAPI fnIOleObject_Unadvise(IOleObject *iface,
506            DWORD dwConnection)
507 {
508     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
509     TRACE("%p\n",This);
510     return E_NOTIMPL;
511 }
512
513 static HRESULT WINAPI fnIOleObject_EnumAdvise(IOleObject *iface,
514            IEnumSTATDATA **ppenumAdvise)
515 {
516     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
517     TRACE("%p\n",This);
518     return E_NOTIMPL;
519 }
520
521 static HRESULT WINAPI fnIOleObject_GetMiscStatus(IOleObject *iface,
522            DWORD dwAspect, DWORD *pdwStatus)
523 {
524     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
525     TRACE("%p\n",This);
526     return E_NOTIMPL;
527 }
528
529 static HRESULT WINAPI fnIOleObject_SetColorScheme(IOleObject *iface,
530            struct tagLOGPALETTE *pLogpal)
531 {
532     ICOM_THIS_MULTI(HTMLDocument_impl, IOleObject_vtbl, iface);
533     TRACE("%p\n",This);
534     return E_NOTIMPL;
535 }
536
537 static ICOM_VTABLE(IOleObject) IOleObject_vtbl =
538 {
539     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
540     fnIOleObject_QueryInterface,
541     fnIOleObject_AddRef,
542     fnIOleObject_Release,
543     fnIOleObject_SetClientSite,
544     fnIOleObject_GetClientSite,
545     fnIOleObject_SetHostNames,
546     fnIOleObject_Close,
547     fnIOleObject_SetMoniker,
548     fnIOleObject_GetMoniker,
549     fnIOleObject_InitFromData,
550     fnIOleObject_GetClipboardData,
551     fnIOleObject_DoVerb,
552     fnIOleObject_EnumVerbs,
553     fnIOleObject_Update,
554     fnIOleObject_IsUpToDate,
555     fnIOleObject_GetUserClassID,
556     fnIOleObject_GetUserType,
557     fnIOleObject_SetExtent,
558     fnIOleObject_GetExtent,
559     fnIOleObject_Advise,
560     fnIOleObject_Unadvise,
561     fnIOleObject_EnumAdvise,
562     fnIOleObject_GetMiscStatus,
563     fnIOleObject_SetColorScheme,
564 };
565
566 static ULONG WINAPI fnIPersist_AddRef(IPersist *iface)
567 {
568     ICOM_THIS_MULTI(HTMLDocument_impl, IPersist_vtbl, iface);
569     return HTMLDocument_AddRef(This);
570 }
571
572 static ULONG WINAPI fnIPersist_Release(IPersist *iface)
573 {
574     ICOM_THIS_MULTI(HTMLDocument_impl, IPersist_vtbl, iface);
575     return HTMLDocument_Release(This);
576 }
577
578 static HRESULT WINAPI fnIPersist_QueryInterface(
579            IPersist *iface, REFIID riid, LPVOID *ppv)
580 {
581     ICOM_THIS_MULTI(HTMLDocument_impl, IPersist_vtbl, iface);
582     return HTMLDocument_QueryInterface(This, riid, ppv);
583 }
584
585 static HRESULT WINAPI fnIPersist_GetClassID(
586            IPersist *iface, CLSID * pClassID)
587 {
588     ICOM_THIS_MULTI(HTMLDocument_impl, IPersist_vtbl, iface);
589     TRACE("%p %p\n", This, pClassID );
590     memcpy( pClassID, &CLSID_HTMLDocument, sizeof CLSID_HTMLDocument);
591     return S_OK;
592 }
593
594 static ICOM_VTABLE(IPersist) IPersist_vtbl =
595 {
596     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
597     fnIPersist_QueryInterface,
598     fnIPersist_AddRef,
599     fnIPersist_Release,
600     fnIPersist_GetClassID,
601 };
602
603 static ULONG WINAPI fnIViewObject_AddRef(IViewObject *iface)
604 {
605     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
606     return HTMLDocument_AddRef(This);
607 }
608
609 static ULONG WINAPI fnIViewObject_Release(IViewObject *iface)
610 {
611     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
612     return HTMLDocument_Release(This);
613 }
614
615 static HRESULT WINAPI fnIViewObject_QueryInterface(
616            IViewObject *iface, REFIID riid, LPVOID *ppv)
617 {
618     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
619     return HTMLDocument_QueryInterface(This, riid, ppv);
620 }
621
622 static HRESULT WINAPI fnIViewObject_Draw( IViewObject *iface,
623            DWORD dwDrawAspect, LONG lindex, void *pvAspect,
624            DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw,
625            LPCRECTL lprcBounds, LPCRECTL lprcWBounds, 
626            BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
627            DWORD dwContinue)
628 {
629     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
630     FIXME("%p\n",This);
631     return E_NOTIMPL;
632 }
633
634 static HRESULT WINAPI fnIViewObject_GetColorSet( IViewObject *iface,
635             DWORD dwDrawAspect, LONG lindex, void *pvAspect,
636             DVTARGETDEVICE *ptd, HDC hicTargetDevice,
637             struct tagLOGPALETTE **ppColorSet)
638 {
639     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
640     FIXME("%p\n",This);
641     return E_NOTIMPL;
642 }
643
644 static HRESULT WINAPI fnIViewObject_Freeze( IViewObject *iface,
645            DWORD dwDrawAspect, LONG lindex, void *pvAspect, DWORD *pdwFreeze)
646 {
647     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
648     FIXME("%p\n",This);
649     return E_NOTIMPL;
650 }
651
652 static HRESULT WINAPI fnIViewObject_Unfreeze( IViewObject *iface,
653            DWORD dwFreeze)
654 {
655     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
656     FIXME("%p\n",This);
657     return E_NOTIMPL;
658 }
659
660 static HRESULT WINAPI fnIViewObject_SetAdvise( IViewObject *iface,
661            DWORD aspects, DWORD advf, IAdviseSink *pAdvSink)
662 {
663     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
664     FIXME("%p\n",This);
665     return E_NOTIMPL;
666 }
667
668 static HRESULT WINAPI fnIViewObject_GetAdvise( IViewObject *iface,
669            DWORD *pAspects, DWORD *pAdvf, IAdviseSink **ppAdvSink)
670 {
671     ICOM_THIS_MULTI(HTMLDocument_impl, IViewObject_vtbl, iface);
672     FIXME("%p\n",This);
673     return E_NOTIMPL;
674 }
675
676
677 static ICOM_VTABLE(IViewObject) IViewObject_vtbl =
678 {
679     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
680     fnIViewObject_QueryInterface,
681     fnIViewObject_AddRef,
682     fnIViewObject_Release,
683     fnIViewObject_Draw,
684     fnIViewObject_GetColorSet,
685     fnIViewObject_Freeze,
686     fnIViewObject_Unfreeze,
687     fnIViewObject_SetAdvise,
688     fnIViewObject_GetAdvise,
689 };
690
691 static ULONG WINAPI fnIOleDocument_AddRef(IOleDocument *iface)
692 {
693     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
694     return HTMLDocument_AddRef(This);
695 }
696
697 static ULONG WINAPI fnIOleDocument_Release(IOleDocument *iface)
698 {
699     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
700     return HTMLDocument_Release(This);
701 }
702
703 static HRESULT WINAPI fnIOleDocument_QueryInterface(
704            IOleDocument *iface, REFIID riid, LPVOID *ppv)
705 {
706     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
707     return HTMLDocument_QueryInterface(This, riid, ppv);
708 }
709
710 static HRESULT WINAPI fnIOleDocument_CreateView(IOleDocument *iface,
711            IOleInPlaceSite *pIPSite, IStream *pstm, DWORD dwReserved, 
712            IOleDocumentView **ppView)
713 {
714     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
715     TRACE("%p\n",This);
716     return E_NOTIMPL;
717 }
718
719 static HRESULT WINAPI fnIOleDocument_GetDocMiscStatus(IOleDocument *iface,
720            DWORD *pdwStatus)
721 {
722     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
723     TRACE("%p\n",This);
724     return E_NOTIMPL;
725 }
726
727 static HRESULT WINAPI fnIOleDocument_EnumViews(IOleDocument *iface,
728            IEnumOleDocumentViews **ppEnum, IOleDocumentView **ppView)
729 {
730     ICOM_THIS_MULTI(HTMLDocument_impl, IOleDocument_vtbl, iface);
731     TRACE("%p\n",This);
732     return E_NOTIMPL;
733 }
734
735 static ICOM_VTABLE(IOleDocument) IOleDocument_vtbl =
736 {
737     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
738     fnIOleDocument_QueryInterface,
739     fnIOleDocument_AddRef,
740     fnIOleDocument_Release,
741     fnIOleDocument_CreateView,
742     fnIOleDocument_GetDocMiscStatus,
743     fnIOleDocument_EnumViews,
744 };
745
746 HRESULT HTMLDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
747 {
748     HTMLDocument_impl *This;
749
750     TRACE("%p %p\n",pUnkOuter,ppObj);
751
752     This = HeapAlloc(GetProcessHeap(), 0, sizeof (HTMLDocument_impl));
753     This->IPersistMoniker_vtbl = &IPersistMoniker_vtbl;
754     This->IPersistFile_vtbl = &IPersistFile_vtbl;
755     This->IOleObject_vtbl = &IOleObject_vtbl;
756     This->IPersist_vtbl = &IPersist_vtbl;
757     This->IViewObject_vtbl = &IViewObject_vtbl;
758     This->IOleDocument_vtbl = &IOleDocument_vtbl;
759     This->ref_count = 1;
760     This->site = NULL;
761
762     *ppObj = (LPVOID) This;
763
764     TRACE("(%p) <- %p\n", ppObj, This);
765     
766     return S_OK;
767 }