2 * Copyright 2005 Jacek Caban
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.
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.
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
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
40 /**********************************************************
41 * IOleObject implementation
44 #define OLEOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleObject, iface)
46 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppvObject
)
48 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
49 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
52 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
54 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
55 return IHTMLDocument2_AddRef(HTMLDOC(This
));
58 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
60 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
61 return IHTMLDocument2_Release(HTMLDOC(This
));
64 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, IOleClientSite
*pClientSite
)
66 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
67 IDocHostUIHandler
*pDocHostUIHandler
= NULL
;
68 IOleCommandTarget
*cmdtrg
= NULL
;
71 TRACE("(%p)->(%p)\n", This
, pClientSite
);
73 if(pClientSite
== This
->client
)
77 IOleClientSite_Release(This
->client
);
80 IDocHostUIHandler_Release(This
->hostui
);
87 hres
= IOleObject_QueryInterface(pClientSite
, &IID_IDocHostUIHandler
, (void**)&pDocHostUIHandler
);
89 DOCHOSTUIINFO hostinfo
;
90 LPOLESTR key_path
= NULL
, override_key_path
= NULL
;
91 IDocHostUIHandler2
*pDocHostUIHandler2
;
93 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
94 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
95 hres
= IDocHostUIHandler_GetHostInfo(pDocHostUIHandler
, &hostinfo
);
97 /* FIXME: use hostinfo */
98 TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
99 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
100 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
102 if(!This
->has_key_path
) {
103 hres
= IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler
, &key_path
, 0);
104 if(hres
== S_OK
&& key_path
) {
106 /* FIXME: use key_path */
107 TRACE("key_path = %s\n", debugstr_w(key_path
));
109 CoTaskMemFree(key_path
);
112 hres
= IDocHostUIHandler_QueryInterface(pDocHostUIHandler
, &IID_IDocHostUIHandler2
,
113 (void**)&pDocHostUIHandler2
);
114 if(SUCCEEDED(hres
)) {
115 hres
= IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2
, &override_key_path
, 0);
116 if(hres
== S_OK
&& override_key_path
&& override_key_path
[0]) {
117 if(override_key_path
[0]) {
118 /*FIXME: use override_key_path */
119 TRACE("override_key_path = %s\n", debugstr_w(override_key_path
));
121 CoTaskMemFree(override_key_path
);
125 This
->has_key_path
= TRUE
;
129 /* Native calls here GetWindow. What is it for?
130 * We don't have anything to do with it here (yet). */
132 IOleWindow
*pOleWindow
= NULL
;
135 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleWindow
, (void**)&pOleWindow
);
136 if(SUCCEEDED(hres
)) {
137 IOleWindow_GetWindow(pOleWindow
, &hwnd
);
138 IOleWindow_Release(pOleWindow
);
142 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
143 if(SUCCEEDED(hres
)) {
145 OLECMD cmd
= {OLECMDID_SETPROGRESSTEXT
, 0};
147 IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 1, &cmd
, NULL
);
151 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
, 0, &var
, NULL
);
152 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
, 0, &var
, NULL
);
154 IOleCommandTarget_Release(cmdtrg
);
157 IOleClientSite_AddRef(pClientSite
);
158 This
->client
= pClientSite
;
159 This
->hostui
= pDocHostUIHandler
;
161 IOleControl_OnAmbientPropertyChange(CONTROL(This
), DISPID_AMBIENT_USERMODE
);
162 IOleControl_OnAmbientPropertyChange(CONTROL(This
), DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
);
163 IOleControl_OnAmbientPropertyChange(CONTROL(This
), DISPID_AMBIENT_SILENT
);
164 IOleControl_OnAmbientPropertyChange(CONTROL(This
), DISPID_AMBIENT_USERAGENT
);
165 IOleControl_OnAmbientPropertyChange(CONTROL(This
), DISPID_AMBIENT_PALETTE
);
170 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, IOleClientSite
**ppClientSite
)
172 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
174 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
180 IOleClientSite_AddRef(This
->client
);
181 *ppClientSite
= This
->client
;
186 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
)
188 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
189 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
193 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
195 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
197 TRACE("(%p)->(%08lx)\n", This
, dwSaveOption
);
199 if(dwSaveOption
== OLECLOSE_PROMPTSAVE
)
200 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
202 if(This
->in_place_active
)
203 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This
));
205 HTMLDocument_LockContainer(This
, FALSE
);
210 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
*pmk
)
212 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
213 FIXME("(%p %ld %p)->()\n", This
, dwWhichMoniker
, pmk
);
217 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
**ppmk
)
219 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
220 FIXME("(%p)->(%ld %ld %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
224 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, IDataObject
*pDataObject
, BOOL fCreation
,
227 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
228 FIXME("(%p)->(%p %x %ld)\n", This
, pDataObject
, fCreation
, dwReserved
);
232 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
, IDataObject
**ppDataObject
)
234 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
235 FIXME("(%p)->(%ld %p)\n", This
, dwReserved
, ppDataObject
);
239 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, LPMSG lpmsg
, IOleClientSite
*pActiveSite
,
240 LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
242 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
243 IOleDocumentSite
*pDocSite
;
246 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
, lprcPosRect
);
248 if(iVerb
!= OLEIVERB_SHOW
&& iVerb
!= OLEIVERB_UIACTIVATE
&& iVerb
!= OLEIVERB_INPLACEACTIVATE
) {
249 FIXME("iVerb = %ld not supported\n", iVerb
);
254 pActiveSite
= This
->client
;
256 hres
= IOleClientSite_QueryInterface(pActiveSite
, &IID_IOleDocumentSite
, (void**)&pDocSite
);
257 if(SUCCEEDED(hres
)) {
258 HTMLDocument_LockContainer(This
, TRUE
);
260 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
261 hres
= IOleDocumentSite_ActivateMe(pDocSite
, DOCVIEW(This
));
262 IOleDocumentSite_Release(pDocSite
);
264 hres
= IOleDocumentView_UIActivate(DOCVIEW(This
), TRUE
);
265 if(SUCCEEDED(hres
)) {
267 RECT rect
; /* We need to pass rect as not const pointer */
268 memcpy(&rect
, lprcPosRect
, sizeof(RECT
));
269 IOleDocumentView_SetRect(DOCVIEW(This
), &rect
);
271 IOleDocumentView_Show(DOCVIEW(This
), TRUE
);
278 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
280 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
281 FIXME("(%p)->(%p)\n", This
, ppEnumOleVerb
);
285 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
287 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
288 FIXME("(%p)\n", This
);
292 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
294 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
295 FIXME("(%p)\n", This
);
299 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*pClsid
)
301 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
303 TRACE("(%p)->(%p)\n", This
, pClsid
);
308 memcpy(pClsid
, &CLSID_HTMLDocument
, sizeof(GUID
));
312 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
, LPOLESTR
*pszUserType
)
314 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
315 FIXME("(%p)->(%ld %p)\n", This
, dwFormOfType
, pszUserType
);
319 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
321 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
322 FIXME("(%p)->(%ld %p)\n", This
, dwDrawAspect
, psizel
);
326 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
328 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
329 FIXME("(%p)->(%ld %p)\n", This
, dwDrawAspect
, psizel
);
333 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
)
335 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
336 FIXME("(%p)->(%p %p)\n", This
, pAdvSink
, pdwConnection
);
340 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
342 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
343 FIXME("(%p)->(%ld)\n", This
, dwConnection
);
347 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
349 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
350 FIXME("(%p)->(%p)\n", This
, ppenumAdvise
);
354 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
356 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
357 FIXME("(%p)->(%ld %p)\n", This
, dwAspect
, pdwStatus
);
361 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
*pLogpal
)
363 HTMLDocument
*This
= OLEOBJ_THIS(iface
);
364 FIXME("(%p)->(%p)\n", This
, pLogpal
);
370 static const IOleObjectVtbl OleObjectVtbl
= {
371 OleObject_QueryInterface
,
374 OleObject_SetClientSite
,
375 OleObject_GetClientSite
,
376 OleObject_SetHostNames
,
378 OleObject_SetMoniker
,
379 OleObject_GetMoniker
,
380 OleObject_InitFromData
,
381 OleObject_GetClipboardData
,
385 OleObject_IsUpToDate
,
386 OleObject_GetUserClassID
,
387 OleObject_GetUserType
,
392 OleObject_EnumAdvise
,
393 OleObject_GetMiscStatus
,
394 OleObject_SetColorScheme
397 /**********************************************************
398 * IOleDocument implementation
401 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
403 static HRESULT WINAPI
OleDocument_QueryInterface(IOleDocument
*iface
, REFIID riid
, void **ppvObject
)
405 HTMLDocument
*This
= OLEDOC_THIS(iface
);
406 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppvObject
);
409 static ULONG WINAPI
OleDocument_AddRef(IOleDocument
*iface
)
411 HTMLDocument
*This
= OLEDOC_THIS(iface
);
412 return IHTMLDocument2_AddRef(HTMLDOC(This
));
415 static ULONG WINAPI
OleDocument_Release(IOleDocument
*iface
)
417 HTMLDocument
*This
= OLEDOC_THIS(iface
);
418 return IHTMLDocument2_Release(HTMLDOC(This
));
421 static HRESULT WINAPI
OleDocument_CreateView(IOleDocument
*iface
, IOleInPlaceSite
*pIPSite
, IStream
*pstm
,
422 DWORD dwReserved
, IOleDocumentView
**ppView
)
424 HTMLDocument
*This
= OLEDOC_THIS(iface
);
427 TRACE("(%p)->(%p %p %ld %p)\n", This
, pIPSite
, pstm
, dwReserved
, ppView
);
433 * Windows implementation creates new IOleDocumentView when function is called for the
434 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
435 * if the application uses returned interfaces, passed to ActivateMe or returned by
436 * QueryInterface, so there is no reason to create new interface. This needs more testing.
440 hres
= IOleDocumentView_SetInPlaceSite(DOCVIEW(This
), pIPSite
);
446 FIXME("pstm is not supported\n");
448 IOleDocumentView_AddRef(DOCVIEW(This
));
449 *ppView
= DOCVIEW(This
);
453 static HRESULT WINAPI
OleDocument_GetDocMiscStatus(IOleDocument
*iface
, DWORD
*pdwStatus
)
455 HTMLDocument
*This
= OLEDOC_THIS(iface
);
456 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
460 static HRESULT WINAPI
OleDocument_EnumViews(IOleDocument
*iface
, IEnumOleDocumentViews
**ppEnum
,
461 IOleDocumentView
**ppView
)
463 HTMLDocument
*This
= OLEDOC_THIS(iface
);
464 FIXME("(%p)->(%p %p)\n", This
, ppEnum
, ppView
);
470 static const IOleDocumentVtbl OleDocumentVtbl
= {
471 OleDocument_QueryInterface
,
474 OleDocument_CreateView
,
475 OleDocument_GetDocMiscStatus
,
476 OleDocument_EnumViews
479 /**********************************************************
480 * IOleCommandTarget implementation
483 #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
485 static HRESULT
exec_open(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
487 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
491 static HRESULT
exec_new(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
493 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
497 static HRESULT
exec_save(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
499 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
503 static HRESULT
exec_save_as(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
505 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
509 static HRESULT
exec_save_copy_as(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
511 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
515 static HRESULT
exec_print(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
517 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
521 static HRESULT
exec_print_preview(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
523 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
527 static HRESULT
exec_page_setup(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
529 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
533 static HRESULT
exec_spell(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
535 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
539 static HRESULT
exec_properties(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
541 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
545 static HRESULT
exec_cut(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
547 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
551 static HRESULT
exec_copy(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
553 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
557 static HRESULT
exec_paste(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
559 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
563 static HRESULT
exec_paste_special(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
565 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
569 static HRESULT
exec_undo(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
571 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
575 static HRESULT
exec_rendo(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
577 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
581 static HRESULT
exec_select_all(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
583 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
587 static HRESULT
exec_clear_selection(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
589 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
593 static HRESULT
exec_zoom(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
595 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
599 static HRESULT
exec_get_zoom_range(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
601 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
605 static HRESULT
exec_refresh(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
607 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
611 static HRESULT
exec_stop(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
613 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
617 static HRESULT
exec_stop_download(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
619 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
623 static HRESULT
exec_delete(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
625 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
629 static HRESULT
exec_enable_interaction(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
631 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
635 static HRESULT
exec_on_unload(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
637 TRACE("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
639 /* Tests show that we have nothing more to do here */
642 V_VT(pvaOut
) = VT_BOOL
;
643 V_BOOL(pvaOut
) = VARIANT_TRUE
;
649 static HRESULT
exec_show_page_setup(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
651 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
655 static HRESULT
exec_show_print(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
657 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
661 static HRESULT
exec_close(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
663 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
667 static HRESULT
exec_set_print_template(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
669 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
673 static HRESULT
exec_get_print_template(HTMLDocument
*This
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
675 FIXME("(%p)->(%ld %p %p)\n", This
, nCmdexecopt
, pvaIn
, pvaOut
);
679 static const struct {
681 HRESULT (*func
)(HTMLDocument
*,DWORD
,VARIANT
*,VARIANT
*);
682 } exec_table
[OLECMDID_GETPRINTTEMPLATE
+1] = {
684 { OLECMDF_SUPPORTED
, exec_open
}, /* OLECMDID_OPEN */
685 { OLECMDF_SUPPORTED
, exec_new
}, /* OLECMDID_NEW */
686 { OLECMDF_SUPPORTED
, exec_save
}, /* OLECMDID_SAVE */
687 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_save_as
}, /* OLECMDID_SAVEAS */
688 { OLECMDF_SUPPORTED
, exec_save_copy_as
}, /* OLECMDID_SAVECOPYAS */
689 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_print
}, /* OLECMDID_PRINT */
690 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_print_preview
}, /* OLECMDID_PRINTPREVIEW */
691 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_page_setup
}, /* OLECMDID_PAGESETUP */
692 { OLECMDF_SUPPORTED
, exec_spell
}, /* OLECMDID_SPELL */
693 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_properties
}, /* OLECMDID_PROPERTIES */
694 { OLECMDF_SUPPORTED
, exec_cut
}, /* OLECMDID_CUT */
695 { OLECMDF_SUPPORTED
, exec_copy
}, /* OLECMDID_COPY */
696 { OLECMDF_SUPPORTED
, exec_paste
}, /* OLECMDID_PASTE */
697 { OLECMDF_SUPPORTED
, exec_paste_special
}, /* OLECMDID_PASTESPECIAL */
698 { OLECMDF_SUPPORTED
, exec_undo
}, /* OLECMDID_UNDO */
699 { OLECMDF_SUPPORTED
, exec_rendo
}, /* OLECMDID_REDO */
700 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_select_all
}, /* OLECMDID_SELECTALL */
701 { OLECMDF_SUPPORTED
, exec_clear_selection
}, /* OLECMDID_CLEARSELECTION */
702 { OLECMDF_SUPPORTED
, exec_zoom
}, /* OLECMDID_ZOOM */
703 { OLECMDF_SUPPORTED
, exec_get_zoom_range
}, /* OLECMDID_GETZOOMRANGE */
705 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_refresh
}, /* OLECMDID_REFRESH */
706 { OLECMDF_SUPPORTED
|OLECMDF_ENABLED
, exec_stop
}, /* OLECMDID_STOP */
707 {0},{0},{0},{0},{0},{0},
708 { OLECMDF_SUPPORTED
, exec_stop_download
}, /* OLECMDID_STOPDOWNLOAD */
710 { OLECMDF_SUPPORTED
, exec_delete
}, /* OLECMDID_DELETE */
712 { OLECMDF_SUPPORTED
, exec_enable_interaction
}, /* OLECMDID_ENABLE_INTERACTION */
713 { OLECMDF_SUPPORTED
, exec_on_unload
}, /* OLECMDID_ONUNLOAD */
715 { OLECMDF_SUPPORTED
, exec_show_page_setup
}, /* OLECMDID_SHOWPAGESETUP */
716 { OLECMDF_SUPPORTED
, exec_show_print
}, /* OLECMDID_SHOWPRINT */
718 { OLECMDF_SUPPORTED
, exec_close
}, /* OLECMDID_CLOSE */
720 { OLECMDF_SUPPORTED
, exec_set_print_template
}, /* OLECMDID_SETPRINTTEMPLATE */
721 { OLECMDF_SUPPORTED
, exec_get_print_template
} /* OLECMDID_GETPRINTTEMPLATE */
724 static HRESULT WINAPI
OleCommandTarget_QueryInterface(IOleCommandTarget
*iface
, REFIID riid
, void **ppv
)
726 HTMLDocument
*This
= CMDTARGET_THIS(iface
);
727 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppv
);
730 static ULONG WINAPI
OleCommandTarget_AddRef(IOleCommandTarget
*iface
)
732 HTMLDocument
*This
= CMDTARGET_THIS(iface
);
733 return IHTMLDocument2_AddRef(HTMLDOC(This
));
736 static ULONG WINAPI
OleCommandTarget_Release(IOleCommandTarget
*iface
)
738 HTMLDocument
*This
= CMDTARGET_THIS(iface
);
739 return IHTMLDocument_Release(HTMLDOC(This
));
742 static HRESULT WINAPI
OleCommandTarget_QueryStatus(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
743 ULONG cCmds
, OLECMD prgCmds
[], OLECMDTEXT
*pCmdText
)
745 HTMLDocument
*This
= CMDTARGET_THIS(iface
);
746 HRESULT hres
= S_OK
, hr
;
748 TRACE("(%p)->(%s %ld %p %p)\n", This
, debugstr_guid(pguidCmdGroup
), cCmds
, prgCmds
, pCmdText
);
753 for(i
=0; i
<cCmds
; i
++) {
754 if(prgCmds
[i
].cmdID
<OLECMDID_OPEN
|| prgCmds
[i
].cmdID
>OLECMDID_GETPRINTTEMPLATE
) {
755 WARN("Unsupported cmdID = %ld\n", prgCmds
[i
].cmdID
);
757 hres
= OLECMDERR_E_NOTSUPPORTED
;
759 if(prgCmds
[i
].cmdID
== OLECMDID_OPEN
|| prgCmds
[i
].cmdID
== OLECMDID_NEW
) {
760 IOleCommandTarget
*cmdtrg
= NULL
;
763 prgCmds
[i
].cmdf
= OLECMDF_SUPPORTED
;
765 hr
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
,
768 olecmd
.cmdID
= prgCmds
[i
].cmdID
;
771 hr
= IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 1, &olecmd
, NULL
);
772 if(SUCCEEDED(hr
) && olecmd
.cmdf
)
773 prgCmds
[i
].cmdf
= olecmd
.cmdf
;
776 ERR("This->client == NULL, native would crash\n");
779 prgCmds
[i
].cmdf
= exec_table
[prgCmds
[i
].cmdID
].cmdf
;
780 TRACE("cmdID = %ld returning %lx\n", prgCmds
[i
].cmdID
, prgCmds
[i
].cmdf
);
787 FIXME("Set pCmdText\n");
789 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup
));
790 hres
= OLECMDERR_E_UNKNOWNGROUP
;
796 static HRESULT WINAPI
OleCommandTarget_Exec(IOleCommandTarget
*iface
, const GUID
*pguidCmdGroup
,
797 DWORD nCmdID
, DWORD nCmdexecopt
, VARIANT
*pvaIn
, VARIANT
*pvaOut
)
799 HTMLDocument
*This
= CMDTARGET_THIS(iface
);
802 if(nCmdID
<OLECMDID_OPEN
|| nCmdID
>OLECMDID_GETPRINTTEMPLATE
|| !exec_table
[nCmdID
].func
) {
803 WARN("Unsupported cmdID = %ld\n", nCmdID
);
804 return OLECMDERR_E_NOTSUPPORTED
;
807 return exec_table
[nCmdID
].func(This
, nCmdexecopt
, pvaIn
, pvaOut
);
808 }else if(IsEqualGUID(&CGID_Explorer
, pguidCmdGroup
)) {
809 FIXME("unsupported nCmdID %ld of CGID_Explorer group\n", nCmdID
);
810 TRACE("%p %p\n", pvaIn
, pvaOut
);
811 return OLECMDERR_E_NOTSUPPORTED
;
812 }else if(IsEqualGUID(&CGID_ShellDocView
, pguidCmdGroup
)) {
813 FIXME("unsupported nCmdID %ld of CGID_ShellDocView group\n", nCmdID
);
814 return OLECMDERR_E_NOTSUPPORTED
;
817 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup
));
818 return OLECMDERR_E_UNKNOWNGROUP
;
821 #undef CMDTARGET_THIS
823 static const IOleCommandTargetVtbl OleCommandTargetVtbl
= {
824 OleCommandTarget_QueryInterface
,
825 OleCommandTarget_AddRef
,
826 OleCommandTarget_Release
,
827 OleCommandTarget_QueryStatus
,
828 OleCommandTarget_Exec
831 /**********************************************************
832 * IOleControl implementation
835 #define CONTROL_THIS(iface) DEFINE_THIS(HTMLDocument, OleControl, iface)
837 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **ppv
)
839 HTMLDocument
*This
= CONTROL_THIS(iface
);
840 return IHTMLDocument2_QueryInterface(HTMLDOC(This
), riid
, ppv
);
843 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
845 HTMLDocument
*This
= CONTROL_THIS(iface
);
846 return IHTMLDocument2_AddRef(HTMLDOC(This
));
849 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
851 HTMLDocument
*This
= CONTROL_THIS(iface
);
852 return IHTMLDocument_Release(HTMLDOC(This
));
855 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*pCI
)
857 HTMLDocument
*This
= CONTROL_THIS(iface
);
858 FIXME("(%p)->(%p)\n", This
, pCI
);
862 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*pMsg
)
864 HTMLDocument
*This
= CONTROL_THIS(iface
);
865 FIXME("(%p)->(%p)\n", This
, pMsg
);
869 static HRESULT
get_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
871 IDispatch
*disp
= NULL
;
872 DISPPARAMS dispparams
= {NULL
, 0};
876 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
878 TRACE("Could not get IDispatch\n");
884 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
885 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, &err
);
887 IDispatch_Release(disp
);
892 static HRESULT
on_change_dlcontrol(HTMLDocument
*This
)
897 hres
= get_property(This
->client
, DISPID_AMBIENT_DLCONTROL
, &res
);
899 FIXME("unsupported dlcontrol %08lx\n", V_I4(&res
));
904 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
906 HTMLDocument
*This
= CONTROL_THIS(iface
);
911 TRACE("This->client = NULL\n");
916 case DISPID_AMBIENT_USERMODE
:
917 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This
);
918 hres
= get_property(This
->client
, DISPID_AMBIENT_USERMODE
, &res
);
922 if(V_VT(&res
) == VT_BOOL
) {
924 FIXME("edit mode is not supported\n");
928 FIXME("V_VT(res)=%d\n", V_VT(&res
));
931 case DISPID_AMBIENT_DLCONTROL
:
932 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This
);
933 return on_change_dlcontrol(This
);
934 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
935 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This
);
936 on_change_dlcontrol(This
);
937 hres
= get_property(This
->client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &res
);
941 if(V_VT(&res
) == VT_BOOL
) {
943 FIXME("offline connection is not supported\n");
947 FIXME("V_VT(res)=%d\n", V_VT(&res
));
950 case DISPID_AMBIENT_SILENT
:
951 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This
);
952 on_change_dlcontrol(This
);
953 hres
= get_property(This
->client
, DISPID_AMBIENT_SILENT
, &res
);
957 if(V_VT(&res
) == VT_BOOL
) {
959 FIXME("silent mode is not supported\n");
963 FIXME("V_VT(res)=%d\n", V_VT(&res
));
966 case DISPID_AMBIENT_USERAGENT
:
967 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This
);
968 hres
= get_property(This
->client
, DISPID_AMBIENT_USERAGENT
, &res
);
972 FIXME("not supported AMBIENT_USERAGENT\n");
975 case DISPID_AMBIENT_PALETTE
:
976 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This
);
977 hres
= get_property(This
->client
, DISPID_AMBIENT_PALETTE
, &res
);
981 FIXME("not supported AMBIENT_PALETTE\n");
986 FIXME("(%p) unsupported dispID=%ld\n", This
, dispID
);
990 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
992 HTMLDocument
*This
= CONTROL_THIS(iface
);
993 FIXME("(%p)->(%x)\n", This
, bFreeze
);
999 static const IOleControlVtbl OleControlVtbl
= {
1000 OleControl_QueryInterface
,
1003 OleControl_GetControlInfo
,
1004 OleControl_OnMnemonic
,
1005 OleControl_OnAmbientPropertyChange
,
1006 OleControl_FreezeEvents
1009 void HTMLDocument_LockContainer(HTMLDocument
*This
, BOOL fLock
)
1011 IOleContainer
*container
;
1014 if(!This
->client
|| This
->container_locked
== fLock
)
1017 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
1018 if(SUCCEEDED(hres
)) {
1019 IOleContainer_LockContainer(container
, fLock
);
1020 This
->container_locked
= fLock
;
1021 IOleContainer_Release(container
);
1025 void HTMLDocument_OleObj_Init(HTMLDocument
*This
)
1027 This
->lpOleObjectVtbl
= &OleObjectVtbl
;
1028 This
->lpOleDocumentVtbl
= &OleDocumentVtbl
;
1029 This
->lpOleCommandTargetVtbl
= &OleCommandTargetVtbl
;
1030 This
->lpOleControlVtbl
= &OleControlVtbl
;
1032 This
->client
= NULL
;
1033 This
->hostui
= NULL
;
1035 This
->has_key_path
= FALSE
;
1036 This
->container_locked
= FALSE
;