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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "mshtml_private.h"
21 #define DOCHOST_DOCCANNAVIGATE 0
24 IEnumUnknown IEnumUnknown_iface
;
28 static inline EnumUnknown
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
30 return CONTAINING_RECORD(iface
, EnumUnknown
, IEnumUnknown_iface
);
33 static HRESULT WINAPI
EnumUnknown_QueryInterface(IEnumUnknown
*iface
, REFIID riid
, void **ppv
)
35 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
37 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
38 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
39 *ppv
= &This
->IEnumUnknown_iface
;
40 }else if(IsEqualGUID(&IID_IEnumUnknown
, riid
)) {
41 TRACE("(%p)->(IID_IEnumUnknown %p)\n", This
, ppv
);
42 *ppv
= &This
->IEnumUnknown_iface
;
44 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
49 IUnknown_AddRef((IUnknown
*)*ppv
);
53 static ULONG WINAPI
EnumUnknown_AddRef(IEnumUnknown
*iface
)
55 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
56 LONG ref
= InterlockedIncrement(&This
->ref
);
58 TRACE("(%p) ref=%d\n", This
, ref
);
63 static ULONG WINAPI
EnumUnknown_Release(IEnumUnknown
*iface
)
65 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
66 LONG ref
= InterlockedDecrement(&This
->ref
);
68 TRACE("(%p) ref=%d\n", This
, ref
);
76 static HRESULT WINAPI
EnumUnknown_Next(IEnumUnknown
*iface
, ULONG celt
, IUnknown
**rgelt
, ULONG
*pceltFetched
)
78 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
80 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
82 /* FIXME: It's not clear if we should ever return something here */
88 static HRESULT WINAPI
EnumUnknown_Skip(IEnumUnknown
*iface
, ULONG celt
)
90 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
91 FIXME("(%p)->(%u)\n", This
, celt
);
95 static HRESULT WINAPI
EnumUnknown_Reset(IEnumUnknown
*iface
)
97 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
98 FIXME("(%p)\n", This
);
102 static HRESULT WINAPI
EnumUnknown_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
104 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
105 FIXME("(%p)->(%p)\n", This
, ppenum
);
109 static const IEnumUnknownVtbl EnumUnknownVtbl
= {
110 EnumUnknown_QueryInterface
,
119 /**********************************************************
120 * IOleObject implementation
123 static inline HTMLDocument
*impl_from_IOleObject(IOleObject
*iface
)
125 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleObject_iface
);
128 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
130 HTMLDocument
*This
= impl_from_IOleObject(iface
);
131 return htmldoc_query_interface(This
, riid
, ppv
);
134 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
136 HTMLDocument
*This
= impl_from_IOleObject(iface
);
137 return htmldoc_addref(This
);
140 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
142 HTMLDocument
*This
= impl_from_IOleObject(iface
);
143 return htmldoc_release(This
);
146 static void update_hostinfo(HTMLDocumentObj
*This
, DOCHOSTUIINFO
*hostinfo
)
148 nsIScrollable
*scrollable
;
151 if(!This
->nscontainer
)
154 nsres
= nsIWebBrowser_QueryInterface(This
->nscontainer
->webbrowser
, &IID_nsIScrollable
, (void**)&scrollable
);
155 if(NS_SUCCEEDED(nsres
)) {
156 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
, ScrollOrientation_Y
,
157 (hostinfo
->dwFlags
& DOCHOSTUIFLAG_SCROLL_NO
) ? Scrollbar_Never
: Scrollbar_Always
);
159 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres
);
161 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
, ScrollOrientation_X
,
162 hostinfo
->dwFlags
& DOCHOSTUIFLAG_SCROLL_NO
? Scrollbar_Never
: Scrollbar_Auto
);
164 ERR("Could not set default X scrollbar prefs: %08x\n", nsres
);
166 nsIScrollable_Release(scrollable
);
168 ERR("Could not get nsIScrollable: %08x\n", nsres
);
172 /* Calls undocumented 84 cmd of CGID_ShellDocView */
173 void call_docview_84(HTMLDocumentObj
*doc
)
175 IOleCommandTarget
*olecmd
;
182 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
187 hres
= IOleCommandTarget_Exec(olecmd
, &CGID_ShellDocView
, 84, 0, NULL
, &var
);
188 IOleCommandTarget_Release(olecmd
);
189 if(SUCCEEDED(hres
) && V_VT(&var
) != VT_NULL
)
190 FIXME("handle result\n");
193 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, IOleClientSite
*pClientSite
)
195 HTMLDocument
*This
= impl_from_IOleObject(iface
);
196 IOleCommandTarget
*cmdtrg
= NULL
;
197 IOleWindow
*ole_window
;
198 IBrowserService
*browser_service
;
204 TRACE("(%p)->(%p)\n", This
, pClientSite
);
206 if(pClientSite
== This
->doc_obj
->client
)
209 if(This
->doc_obj
->client
) {
210 IOleClientSite_Release(This
->doc_obj
->client
);
211 This
->doc_obj
->client
= NULL
;
212 This
->doc_obj
->usermode
= UNKNOWN_USERMODE
;
215 if(This
->doc_obj
->client_cmdtrg
) {
216 IOleCommandTarget_Release(This
->doc_obj
->client_cmdtrg
);
217 This
->doc_obj
->client_cmdtrg
= NULL
;
220 if(This
->doc_obj
->hostui
&& !This
->doc_obj
->custom_hostui
) {
221 IDocHostUIHandler_Release(This
->doc_obj
->hostui
);
222 This
->doc_obj
->hostui
= NULL
;
225 if(This
->doc_obj
->doc_object_service
) {
226 IDocObjectService_Release(This
->doc_obj
->doc_object_service
);
227 This
->doc_obj
->doc_object_service
= NULL
;
230 if(This
->doc_obj
->webbrowser
) {
231 IUnknown_Release(This
->doc_obj
->webbrowser
);
232 This
->doc_obj
->webbrowser
= NULL
;
235 if(This
->doc_obj
->browser_service
) {
236 IUnknown_Release(This
->doc_obj
->browser_service
);
237 This
->doc_obj
->browser_service
= NULL
;
240 if(This
->doc_obj
->travel_log
) {
241 ITravelLog_Release(This
->doc_obj
->travel_log
);
242 This
->doc_obj
->travel_log
= NULL
;
245 memset(&This
->doc_obj
->hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
250 IOleClientSite_AddRef(pClientSite
);
251 This
->doc_obj
->client
= pClientSite
;
253 hostui_setup
= This
->doc_obj
->hostui_setup
;
255 if(!This
->doc_obj
->hostui
) {
256 IDocHostUIHandler
*uihandler
;
258 This
->doc_obj
->custom_hostui
= FALSE
;
260 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IDocHostUIHandler
, (void**)&uihandler
);
262 This
->doc_obj
->hostui
= uihandler
;
265 if(This
->doc_obj
->hostui
) {
266 DOCHOSTUIINFO hostinfo
;
267 LPOLESTR key_path
= NULL
, override_key_path
= NULL
;
268 IDocHostUIHandler2
*uihandler2
;
270 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
271 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
272 hres
= IDocHostUIHandler_GetHostInfo(This
->doc_obj
->hostui
, &hostinfo
);
273 if(SUCCEEDED(hres
)) {
274 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
275 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
276 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
277 update_hostinfo(This
->doc_obj
, &hostinfo
);
278 This
->doc_obj
->hostinfo
= hostinfo
;
282 hres
= IDocHostUIHandler_GetOptionKeyPath(This
->doc_obj
->hostui
, &key_path
, 0);
283 if(hres
== S_OK
&& key_path
) {
285 /* FIXME: use key_path */
286 TRACE("key_path = %s\n", debugstr_w(key_path
));
288 CoTaskMemFree(key_path
);
291 hres
= IDocHostUIHandler_QueryInterface(This
->doc_obj
->hostui
, &IID_IDocHostUIHandler2
,
292 (void**)&uihandler2
);
293 if(SUCCEEDED(hres
)) {
294 hres
= IDocHostUIHandler2_GetOverrideKeyPath(uihandler2
, &override_key_path
, 0);
295 if(hres
== S_OK
&& override_key_path
&& override_key_path
[0]) {
296 if(override_key_path
[0]) {
297 /*FIXME: use override_key_path */
298 TRACE("override_key_path = %s\n", debugstr_w(override_key_path
));
300 CoTaskMemFree(override_key_path
);
302 IDocHostUIHandler2_Release(uihandler2
);
305 This
->doc_obj
->hostui_setup
= TRUE
;
309 /* Native calls here GetWindow. What is it for?
310 * We don't have anything to do with it here (yet). */
311 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleWindow
, (void**)&ole_window
);
312 if(SUCCEEDED(hres
)) {
313 IOleWindow_GetWindow(ole_window
, &hwnd
);
314 IOleWindow_Release(ole_window
);
317 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IShellBrowser
,
318 &IID_IBrowserService
, (void**)&browser_service
);
319 if(SUCCEEDED(hres
)) {
320 ITravelLog
*travel_log
;
322 This
->doc_obj
->browser_service
= (IUnknown
*)browser_service
;
324 hres
= IBrowserService_GetTravelLog(browser_service
, &travel_log
);
326 This
->doc_obj
->travel_log
= travel_log
;
328 browser_service
= NULL
;
331 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
332 if(SUCCEEDED(hres
)) {
334 OLECMD cmd
= {OLECMDID_SETPROGRESSTEXT
, 0};
336 This
->doc_obj
->client_cmdtrg
= cmdtrg
;
339 IDocObjectService
*doc_object_service
;
342 V_VT(&var
) = VT_UNKNOWN
;
343 V_UNKNOWN(&var
) = (IUnknown
*)&This
->window
->base
.IHTMLWindow2_iface
;
344 IOleCommandTarget_Exec(cmdtrg
, &CGID_DocHostCmdPriv
, DOCHOST_DOCCANNAVIGATE
, 0, &var
, NULL
);
346 if(browser_service
) {
347 hres
= IBrowserService_QueryInterface(browser_service
,
348 &IID_IDocObjectService
, (void**)&doc_object_service
);
349 if(SUCCEEDED(hres
)) {
350 This
->doc_obj
->doc_object_service
= doc_object_service
;
353 * Some embedding routines, esp. in regards to use of IDocObjectService, differ if
354 * embedder supports IWebBrowserApp.
356 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IWebBrowserApp
, &IID_IWebBrowser2
, (void**)&wb
);
358 This
->doc_obj
->webbrowser
= (IUnknown
*)wb
;
363 call_docview_84(This
->doc_obj
);
365 IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 1, &cmd
, NULL
);
369 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
370 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
371 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
372 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
375 if(This
->doc_obj
->usermode
== UNKNOWN_USERMODE
)
376 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERMODE
);
378 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
,
379 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
);
381 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_SILENT
, &silent
);
382 if(SUCCEEDED(hres
)) {
383 if(V_VT(&silent
) != VT_BOOL
)
384 WARN("silent = %s\n", debugstr_variant(&silent
));
385 else if(V_BOOL(&silent
))
386 FIXME("silent == true\n");
389 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERAGENT
);
390 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_PALETTE
);
395 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, IOleClientSite
**ppClientSite
)
397 HTMLDocument
*This
= impl_from_IOleObject(iface
);
399 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
404 if(This
->doc_obj
->client
)
405 IOleClientSite_AddRef(This
->doc_obj
->client
);
406 *ppClientSite
= This
->doc_obj
->client
;
411 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
)
413 HTMLDocument
*This
= impl_from_IOleObject(iface
);
414 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
418 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
420 HTMLDocument
*This
= impl_from_IOleObject(iface
);
422 TRACE("(%p)->(%08x)\n", This
, dwSaveOption
);
424 if(dwSaveOption
== OLECLOSE_PROMPTSAVE
)
425 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
427 if(This
->doc_obj
->in_place_active
)
428 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
430 HTMLDocument_LockContainer(This
->doc_obj
, FALSE
);
432 if(This
->advise_holder
)
433 IOleAdviseHolder_SendOnClose(This
->advise_holder
);
438 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
*pmk
)
440 HTMLDocument
*This
= impl_from_IOleObject(iface
);
441 FIXME("(%p %d %p)->()\n", This
, dwWhichMoniker
, pmk
);
445 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
**ppmk
)
447 HTMLDocument
*This
= impl_from_IOleObject(iface
);
448 FIXME("(%p)->(%d %d %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
452 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, IDataObject
*pDataObject
, BOOL fCreation
,
455 HTMLDocument
*This
= impl_from_IOleObject(iface
);
456 FIXME("(%p)->(%p %x %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
460 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
, IDataObject
**ppDataObject
)
462 HTMLDocument
*This
= impl_from_IOleObject(iface
);
463 FIXME("(%p)->(%d %p)\n", This
, dwReserved
, ppDataObject
);
467 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, LPMSG lpmsg
, IOleClientSite
*pActiveSite
,
468 LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
470 HTMLDocument
*This
= impl_from_IOleObject(iface
);
471 IOleDocumentSite
*pDocSite
;
474 TRACE("(%p)->(%d %p %p %d %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
, lprcPosRect
);
476 if(iVerb
!= OLEIVERB_SHOW
&& iVerb
!= OLEIVERB_UIACTIVATE
&& iVerb
!= OLEIVERB_INPLACEACTIVATE
) {
477 FIXME("iVerb = %d not supported\n", iVerb
);
482 pActiveSite
= This
->doc_obj
->client
;
484 hres
= IOleClientSite_QueryInterface(pActiveSite
, &IID_IOleDocumentSite
, (void**)&pDocSite
);
485 if(SUCCEEDED(hres
)) {
486 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
488 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
489 hres
= IOleDocumentSite_ActivateMe(pDocSite
, &This
->IOleDocumentView_iface
);
490 IOleDocumentSite_Release(pDocSite
);
492 hres
= IOleDocumentView_UIActivate(&This
->IOleDocumentView_iface
, TRUE
);
493 if(SUCCEEDED(hres
)) {
495 RECT rect
; /* We need to pass rect as not const pointer */
497 IOleDocumentView_SetRect(&This
->IOleDocumentView_iface
, &rect
);
499 IOleDocumentView_Show(&This
->IOleDocumentView_iface
, TRUE
);
506 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
508 HTMLDocument
*This
= impl_from_IOleObject(iface
);
509 FIXME("(%p)->(%p)\n", This
, ppEnumOleVerb
);
513 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
515 HTMLDocument
*This
= impl_from_IOleObject(iface
);
516 FIXME("(%p)\n", This
);
520 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
522 HTMLDocument
*This
= impl_from_IOleObject(iface
);
523 FIXME("(%p)\n", This
);
527 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*pClsid
)
529 HTMLDocument
*This
= impl_from_IOleObject(iface
);
531 TRACE("(%p)->(%p)\n", This
, pClsid
);
536 *pClsid
= CLSID_HTMLDocument
;
540 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
, LPOLESTR
*pszUserType
)
542 HTMLDocument
*This
= impl_from_IOleObject(iface
);
543 FIXME("(%p)->(%d %p)\n", This
, dwFormOfType
, pszUserType
);
547 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
549 HTMLDocument
*This
= impl_from_IOleObject(iface
);
550 FIXME("(%p)->(%d %p)\n", This
, dwDrawAspect
, psizel
);
554 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
556 HTMLDocument
*This
= impl_from_IOleObject(iface
);
557 FIXME("(%p)->(%d %p)\n", This
, dwDrawAspect
, psizel
);
561 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
)
563 HTMLDocument
*This
= impl_from_IOleObject(iface
);
564 TRACE("(%p)->(%p %p)\n", This
, pAdvSink
, pdwConnection
);
574 if(!This
->advise_holder
) {
575 CreateOleAdviseHolder(&This
->advise_holder
);
576 if(!This
->advise_holder
)
577 return E_OUTOFMEMORY
;
580 return IOleAdviseHolder_Advise(This
->advise_holder
, pAdvSink
, pdwConnection
);
583 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
585 HTMLDocument
*This
= impl_from_IOleObject(iface
);
586 TRACE("(%p)->(%d)\n", This
, dwConnection
);
588 if(!This
->advise_holder
)
589 return OLE_E_NOCONNECTION
;
591 return IOleAdviseHolder_Unadvise(This
->advise_holder
, dwConnection
);
594 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
596 HTMLDocument
*This
= impl_from_IOleObject(iface
);
598 if(!This
->advise_holder
) {
599 *ppenumAdvise
= NULL
;
603 return IOleAdviseHolder_EnumAdvise(This
->advise_holder
, ppenumAdvise
);
606 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
608 HTMLDocument
*This
= impl_from_IOleObject(iface
);
609 FIXME("(%p)->(%d %p)\n", This
, dwAspect
, pdwStatus
);
613 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
*pLogpal
)
615 HTMLDocument
*This
= impl_from_IOleObject(iface
);
616 FIXME("(%p)->(%p)\n", This
, pLogpal
);
620 static const IOleObjectVtbl OleObjectVtbl
= {
621 OleObject_QueryInterface
,
624 OleObject_SetClientSite
,
625 OleObject_GetClientSite
,
626 OleObject_SetHostNames
,
628 OleObject_SetMoniker
,
629 OleObject_GetMoniker
,
630 OleObject_InitFromData
,
631 OleObject_GetClipboardData
,
635 OleObject_IsUpToDate
,
636 OleObject_GetUserClassID
,
637 OleObject_GetUserType
,
642 OleObject_EnumAdvise
,
643 OleObject_GetMiscStatus
,
644 OleObject_SetColorScheme
647 /**********************************************************
648 * IOleDocument implementation
651 static inline HTMLDocument
*impl_from_IOleDocument(IOleDocument
*iface
)
653 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleDocument_iface
);
656 static HRESULT WINAPI
OleDocument_QueryInterface(IOleDocument
*iface
, REFIID riid
, void **ppv
)
658 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
659 return htmldoc_query_interface(This
, riid
, ppv
);
662 static ULONG WINAPI
OleDocument_AddRef(IOleDocument
*iface
)
664 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
665 return htmldoc_addref(This
);
668 static ULONG WINAPI
OleDocument_Release(IOleDocument
*iface
)
670 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
671 return htmldoc_release(This
);
674 static HRESULT WINAPI
OleDocument_CreateView(IOleDocument
*iface
, IOleInPlaceSite
*pIPSite
, IStream
*pstm
,
675 DWORD dwReserved
, IOleDocumentView
**ppView
)
677 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
680 TRACE("(%p)->(%p %p %d %p)\n", This
, pIPSite
, pstm
, dwReserved
, ppView
);
686 * Windows implementation creates new IOleDocumentView when function is called for the
687 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
688 * if the application uses returned interfaces, passed to ActivateMe or returned by
689 * QueryInterface, so there is no reason to create new interface. This needs more testing.
693 hres
= IOleDocumentView_SetInPlaceSite(&This
->IOleDocumentView_iface
, pIPSite
);
699 FIXME("pstm is not supported\n");
701 IOleDocumentView_AddRef(&This
->IOleDocumentView_iface
);
702 *ppView
= &This
->IOleDocumentView_iface
;
706 static HRESULT WINAPI
OleDocument_GetDocMiscStatus(IOleDocument
*iface
, DWORD
*pdwStatus
)
708 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
709 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
713 static HRESULT WINAPI
OleDocument_EnumViews(IOleDocument
*iface
, IEnumOleDocumentViews
**ppEnum
,
714 IOleDocumentView
**ppView
)
716 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
717 FIXME("(%p)->(%p %p)\n", This
, ppEnum
, ppView
);
721 static const IOleDocumentVtbl OleDocumentVtbl
= {
722 OleDocument_QueryInterface
,
725 OleDocument_CreateView
,
726 OleDocument_GetDocMiscStatus
,
727 OleDocument_EnumViews
730 /**********************************************************
731 * IOleControl implementation
734 static inline HTMLDocument
*impl_from_IOleControl(IOleControl
*iface
)
736 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleControl_iface
);
739 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **ppv
)
741 HTMLDocument
*This
= impl_from_IOleControl(iface
);
742 return htmldoc_query_interface(This
, riid
, ppv
);
745 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
747 HTMLDocument
*This
= impl_from_IOleControl(iface
);
748 return htmldoc_addref(This
);
751 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
753 HTMLDocument
*This
= impl_from_IOleControl(iface
);
754 return htmldoc_release(This
);
757 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*pCI
)
759 HTMLDocument
*This
= impl_from_IOleControl(iface
);
760 FIXME("(%p)->(%p)\n", This
, pCI
);
764 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*pMsg
)
766 HTMLDocument
*This
= impl_from_IOleControl(iface
);
767 FIXME("(%p)->(%p)\n", This
, pMsg
);
771 HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
773 IDispatch
*disp
= NULL
;
774 DISPPARAMS dispparams
= {NULL
, 0};
778 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
780 TRACE("Could not get IDispatch\n");
786 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
787 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, &err
);
789 IDispatch_Release(disp
);
794 static HRESULT
on_change_dlcontrol(HTMLDocument
*This
)
799 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_DLCONTROL
, &res
);
801 FIXME("unsupported dlcontrol %08x\n", V_I4(&res
));
806 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
808 HTMLDocument
*This
= impl_from_IOleControl(iface
);
809 IOleClientSite
*client
;
813 client
= This
->doc_obj
->client
;
815 TRACE("client = NULL\n");
820 case DISPID_AMBIENT_USERMODE
:
821 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This
);
822 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERMODE
, &res
);
826 if(V_VT(&res
) == VT_BOOL
) {
828 This
->doc_obj
->usermode
= BROWSEMODE
;
830 FIXME("edit mode is not supported\n");
831 This
->doc_obj
->usermode
= EDITMODE
;
834 FIXME("usermode=%s\n", debugstr_variant(&res
));
837 case DISPID_AMBIENT_DLCONTROL
:
838 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This
);
839 return on_change_dlcontrol(This
);
840 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
841 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This
);
842 on_change_dlcontrol(This
);
843 hres
= get_client_disp_property(client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &res
);
847 if(V_VT(&res
) == VT_BOOL
) {
849 FIXME("offline connection is not supported\n");
853 FIXME("offlineconnected=%s\n", debugstr_variant(&res
));
856 case DISPID_AMBIENT_SILENT
:
857 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This
);
858 on_change_dlcontrol(This
);
859 hres
= get_client_disp_property(client
, DISPID_AMBIENT_SILENT
, &res
);
863 if(V_VT(&res
) == VT_BOOL
) {
865 FIXME("silent mode is not supported\n");
869 FIXME("silent=%s\n", debugstr_variant(&res
));
872 case DISPID_AMBIENT_USERAGENT
:
873 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This
);
874 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERAGENT
, &res
);
878 FIXME("not supported AMBIENT_USERAGENT\n");
881 case DISPID_AMBIENT_PALETTE
:
882 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This
);
883 hres
= get_client_disp_property(client
, DISPID_AMBIENT_PALETTE
, &res
);
887 FIXME("not supported AMBIENT_PALETTE\n");
892 FIXME("(%p) unsupported dispID=%d\n", This
, dispID
);
896 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
898 HTMLDocument
*This
= impl_from_IOleControl(iface
);
899 FIXME("(%p)->(%x)\n", This
, bFreeze
);
903 static const IOleControlVtbl OleControlVtbl
= {
904 OleControl_QueryInterface
,
907 OleControl_GetControlInfo
,
908 OleControl_OnMnemonic
,
909 OleControl_OnAmbientPropertyChange
,
910 OleControl_FreezeEvents
913 /**********************************************************
914 * IObjectWithSite implementation
917 static inline HTMLDocument
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
919 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectWithSite_iface
);
922 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
*iface
, REFIID riid
, void **ppv
)
924 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
925 return htmldoc_query_interface(This
, riid
, ppv
);
928 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
930 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
931 return htmldoc_addref(This
);
934 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
936 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
937 return htmldoc_release(This
);
940 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
942 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
943 FIXME("(%p)->(%p)\n", This
, pUnkSite
);
947 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
* iface
, REFIID riid
, PVOID
*ppvSite
)
949 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
950 FIXME("(%p)->(%p)\n", This
, ppvSite
);
954 static const IObjectWithSiteVtbl ObjectWithSiteVtbl
= {
955 ObjectWithSite_QueryInterface
,
956 ObjectWithSite_AddRef
,
957 ObjectWithSite_Release
,
958 ObjectWithSite_SetSite
,
959 ObjectWithSite_GetSite
962 /**********************************************************
963 * IOleContainer implementation
966 static inline HTMLDocument
*impl_from_IOleContainer(IOleContainer
*iface
)
968 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleContainer_iface
);
971 static HRESULT WINAPI
OleContainer_QueryInterface(IOleContainer
*iface
, REFIID riid
, void **ppv
)
973 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
974 return htmldoc_query_interface(This
, riid
, ppv
);
977 static ULONG WINAPI
OleContainer_AddRef(IOleContainer
*iface
)
979 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
980 return htmldoc_addref(This
);
983 static ULONG WINAPI
OleContainer_Release(IOleContainer
*iface
)
985 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
986 return htmldoc_release(This
);
989 static HRESULT WINAPI
OleContainer_ParseDisplayName(IOleContainer
*iface
, IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
990 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
992 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
993 FIXME("(%p)->(%p %s %p %p)\n", This
, pbc
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
997 static HRESULT WINAPI
OleContainer_EnumObjects(IOleContainer
*iface
, DWORD grfFlags
, IEnumUnknown
**ppenum
)
999 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1002 TRACE("(%p)->(%x %p)\n", This
, grfFlags
, ppenum
);
1004 ret
= heap_alloc(sizeof(*ret
));
1006 return E_OUTOFMEMORY
;
1008 ret
->IEnumUnknown_iface
.lpVtbl
= &EnumUnknownVtbl
;
1011 *ppenum
= &ret
->IEnumUnknown_iface
;
1015 static HRESULT WINAPI
OleContainer_LockContainer(IOleContainer
*iface
, BOOL fLock
)
1017 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1018 FIXME("(%p)->(%x)\n", This
, fLock
);
1022 static const IOleContainerVtbl OleContainerVtbl
= {
1023 OleContainer_QueryInterface
,
1024 OleContainer_AddRef
,
1025 OleContainer_Release
,
1026 OleContainer_ParseDisplayName
,
1027 OleContainer_EnumObjects
,
1028 OleContainer_LockContainer
1031 static inline HTMLDocumentObj
*impl_from_ITargetContainer(ITargetContainer
*iface
)
1033 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ITargetContainer_iface
);
1036 static HRESULT WINAPI
TargetContainer_QueryInterface(ITargetContainer
*iface
, REFIID riid
, void **ppv
)
1038 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1039 return ICustomDoc_QueryInterface(&This
->ICustomDoc_iface
, riid
, ppv
);
1042 static ULONG WINAPI
TargetContainer_AddRef(ITargetContainer
*iface
)
1044 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1045 return ICustomDoc_AddRef(&This
->ICustomDoc_iface
);
1048 static ULONG WINAPI
TargetContainer_Release(ITargetContainer
*iface
)
1050 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1051 return ICustomDoc_Release(&This
->ICustomDoc_iface
);
1054 static HRESULT WINAPI
TargetContainer_GetFrameUrl(ITargetContainer
*iface
, LPWSTR
*ppszFrameSrc
)
1056 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1057 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1061 static HRESULT WINAPI
TargetContainer_GetFramesContainer(ITargetContainer
*iface
, IOleContainer
**ppContainer
)
1063 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1065 TRACE("(%p)->(%p)\n", This
, ppContainer
);
1067 /* NOTE: we should return wrapped interface here */
1068 IOleContainer_AddRef(&This
->basedoc
.IOleContainer_iface
);
1069 *ppContainer
= &This
->basedoc
.IOleContainer_iface
;
1073 static const ITargetContainerVtbl TargetContainerVtbl
= {
1074 TargetContainer_QueryInterface
,
1075 TargetContainer_AddRef
,
1076 TargetContainer_Release
,
1077 TargetContainer_GetFrameUrl
,
1078 TargetContainer_GetFramesContainer
1081 void TargetContainer_Init(HTMLDocumentObj
*This
)
1083 This
->ITargetContainer_iface
.lpVtbl
= &TargetContainerVtbl
;
1086 /**********************************************************
1087 * IObjectSafety implementation
1090 static inline HTMLDocument
*impl_from_IObjectSafety(IObjectSafety
*iface
)
1092 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectSafety_iface
);
1095 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1097 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1098 return htmldoc_query_interface(This
, riid
, ppv
);
1101 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1103 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1104 return htmldoc_addref(This
);
1107 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1109 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1110 return htmldoc_release(This
);
1113 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
,
1114 REFIID riid
, DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1116 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1117 FIXME("(%p)->(%s %p %p)\n", This
, debugstr_guid(riid
), pdwSupportedOptions
, pdwEnabledOptions
);
1121 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
,
1122 REFIID riid
, DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1124 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1125 FIXME("(%p)->(%s %x %x)\n", This
, debugstr_guid(riid
), dwOptionSetMask
, dwEnabledOptions
);
1127 if(IsEqualGUID(&IID_IPersistMoniker
, riid
) &&
1128 dwOptionSetMask
==INTERFACESAFE_FOR_UNTRUSTED_DATA
&&
1129 dwEnabledOptions
==INTERFACESAFE_FOR_UNTRUSTED_DATA
)
1135 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1136 ObjectSafety_QueryInterface
,
1137 ObjectSafety_AddRef
,
1138 ObjectSafety_Release
,
1139 ObjectSafety_GetInterfaceSafetyOptions
,
1140 ObjectSafety_SetInterfaceSafetyOptions
1143 void HTMLDocument_LockContainer(HTMLDocumentObj
*This
, BOOL fLock
)
1145 IOleContainer
*container
;
1148 if(!This
->client
|| This
->container_locked
== fLock
)
1151 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
1152 if(SUCCEEDED(hres
)) {
1153 IOleContainer_LockContainer(container
, fLock
);
1154 This
->container_locked
= fLock
;
1155 IOleContainer_Release(container
);
1159 void HTMLDocument_OleObj_Init(HTMLDocument
*This
)
1161 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1162 This
->IOleDocument_iface
.lpVtbl
= &OleDocumentVtbl
;
1163 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1164 This
->IObjectWithSite_iface
.lpVtbl
= &ObjectWithSiteVtbl
;
1165 This
->IOleContainer_iface
.lpVtbl
= &OleContainerVtbl
;
1166 This
->IObjectSafety_iface
.lpVtbl
= &ObjectSafetyVtbl
;