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
31 #include "shdeprecated.h"
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 #define DOCHOST_DOCCANNAVIGATE 0
44 IEnumUnknown IEnumUnknown_iface
;
48 static inline EnumUnknown
*impl_from_IEnumUnknown(IEnumUnknown
*iface
)
50 return CONTAINING_RECORD(iface
, EnumUnknown
, IEnumUnknown_iface
);
53 static HRESULT WINAPI
EnumUnknown_QueryInterface(IEnumUnknown
*iface
, REFIID riid
, void **ppv
)
55 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
57 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
58 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
59 *ppv
= &This
->IEnumUnknown_iface
;
60 }else if(IsEqualGUID(&IID_IEnumUnknown
, riid
)) {
61 TRACE("(%p)->(IID_IEnumUnknown %p)\n", This
, ppv
);
62 *ppv
= &This
->IEnumUnknown_iface
;
64 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
69 IUnknown_AddRef((IUnknown
*)*ppv
);
73 static ULONG WINAPI
EnumUnknown_AddRef(IEnumUnknown
*iface
)
75 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
76 LONG ref
= InterlockedIncrement(&This
->ref
);
78 TRACE("(%p) ref=%d\n", This
, ref
);
83 static ULONG WINAPI
EnumUnknown_Release(IEnumUnknown
*iface
)
85 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
86 LONG ref
= InterlockedDecrement(&This
->ref
);
88 TRACE("(%p) ref=%d\n", This
, ref
);
96 static HRESULT WINAPI
EnumUnknown_Next(IEnumUnknown
*iface
, ULONG celt
, IUnknown
**rgelt
, ULONG
*pceltFetched
)
98 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
100 TRACE("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
102 /* FIXME: It's not clear if we should ever return something here */
108 static HRESULT WINAPI
EnumUnknown_Skip(IEnumUnknown
*iface
, ULONG celt
)
110 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
111 FIXME("(%p)->(%u)\n", This
, celt
);
115 static HRESULT WINAPI
EnumUnknown_Reset(IEnumUnknown
*iface
)
117 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
118 FIXME("(%p)\n", This
);
122 static HRESULT WINAPI
EnumUnknown_Clone(IEnumUnknown
*iface
, IEnumUnknown
**ppenum
)
124 EnumUnknown
*This
= impl_from_IEnumUnknown(iface
);
125 FIXME("(%p)->(%p)\n", This
, ppenum
);
129 static const IEnumUnknownVtbl EnumUnknownVtbl
= {
130 EnumUnknown_QueryInterface
,
139 /**********************************************************
140 * IOleObject implementation
143 static inline HTMLDocument
*impl_from_IOleObject(IOleObject
*iface
)
145 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleObject_iface
);
148 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **ppv
)
150 HTMLDocument
*This
= impl_from_IOleObject(iface
);
151 return htmldoc_query_interface(This
, riid
, ppv
);
154 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
156 HTMLDocument
*This
= impl_from_IOleObject(iface
);
157 return htmldoc_addref(This
);
160 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
162 HTMLDocument
*This
= impl_from_IOleObject(iface
);
163 return htmldoc_release(This
);
166 static void update_hostinfo(HTMLDocumentObj
*This
, DOCHOSTUIINFO
*hostinfo
)
168 nsIScrollable
*scrollable
;
171 if(!This
->nscontainer
)
174 nsres
= nsIWebBrowser_QueryInterface(This
->nscontainer
->webbrowser
, &IID_nsIScrollable
, (void**)&scrollable
);
175 if(NS_SUCCEEDED(nsres
)) {
176 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
, ScrollOrientation_Y
,
177 (hostinfo
->dwFlags
& DOCHOSTUIFLAG_SCROLL_NO
) ? Scrollbar_Never
: Scrollbar_Always
);
179 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres
);
181 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
, ScrollOrientation_X
,
182 hostinfo
->dwFlags
& DOCHOSTUIFLAG_SCROLL_NO
? Scrollbar_Never
: Scrollbar_Auto
);
184 ERR("Could not set default X scrollbar prefs: %08x\n", nsres
);
186 nsIScrollable_Release(scrollable
);
188 ERR("Could not get nsIScrollable: %08x\n", nsres
);
192 /* Calls undocumented 84 cmd of CGID_ShellDocView */
193 void call_docview_84(HTMLDocumentObj
*doc
)
195 IOleCommandTarget
*olecmd
;
202 hres
= IOleClientSite_QueryInterface(doc
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
207 hres
= IOleCommandTarget_Exec(olecmd
, &CGID_ShellDocView
, 84, 0, NULL
, &var
);
208 IOleCommandTarget_Release(olecmd
);
209 if(SUCCEEDED(hres
) && V_VT(&var
) != VT_NULL
)
210 FIXME("handle result\n");
213 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, IOleClientSite
*pClientSite
)
215 HTMLDocument
*This
= impl_from_IOleObject(iface
);
216 IOleCommandTarget
*cmdtrg
= NULL
;
217 IOleWindow
*ole_window
;
223 TRACE("(%p)->(%p)\n", This
, pClientSite
);
225 if(pClientSite
== This
->doc_obj
->client
)
228 if(This
->doc_obj
->client
) {
229 IOleClientSite_Release(This
->doc_obj
->client
);
230 This
->doc_obj
->client
= NULL
;
231 This
->doc_obj
->usermode
= UNKNOWN_USERMODE
;
234 if(This
->doc_obj
->hostui
&& !This
->doc_obj
->custom_hostui
) {
235 IDocHostUIHandler_Release(This
->doc_obj
->hostui
);
236 This
->doc_obj
->hostui
= NULL
;
239 if(This
->doc_obj
->doc_object_service
) {
240 IDocObjectService_Release(This
->doc_obj
->doc_object_service
);
241 This
->doc_obj
->doc_object_service
= NULL
;
244 memset(&This
->doc_obj
->hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
245 This
->doc_obj
->is_webbrowser
= FALSE
;
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
= IOleObject_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
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
318 if(SUCCEEDED(hres
)) {
320 OLECMD cmd
= {OLECMDID_SETPROGRESSTEXT
, 0};
323 IDocObjectService
*doc_object_service
;
324 IBrowserService
*browser_service
;
327 V_VT(&var
) = VT_UNKNOWN
;
328 V_UNKNOWN(&var
) = (IUnknown
*)&This
->window
->base
.IHTMLWindow2_iface
;
329 IOleCommandTarget_Exec(cmdtrg
, &CGID_DocHostCmdPriv
, DOCHOST_DOCCANNAVIGATE
, 0, &var
, NULL
);
331 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IShellBrowser
,
332 &IID_IBrowserService
, (void**)&browser_service
);
333 if(SUCCEEDED(hres
)) {
334 hres
= IBrowserService_QueryInterface(browser_service
,
335 &IID_IDocObjectService
, (void**)&doc_object_service
);
336 if(SUCCEEDED(hres
)) {
337 This
->doc_obj
->doc_object_service
= doc_object_service
;
340 * Some embedding routines, esp. in regards to use of IDocObjectService, differ if
341 * embedder supports IWebBrowserApp.
343 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IWebBrowserApp
, &IID_IWebBrowser2
, (void**)&wb
);
344 if(SUCCEEDED(hres
)) {
345 This
->doc_obj
->is_webbrowser
= TRUE
;
346 IWebBrowser2_Release(wb
);
349 IBrowserService_Release(browser_service
);
354 call_docview_84(This
->doc_obj
);
356 IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 1, &cmd
, NULL
);
360 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
361 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
362 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
363 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
365 IOleCommandTarget_Release(cmdtrg
);
368 if(This
->doc_obj
->usermode
== UNKNOWN_USERMODE
)
369 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERMODE
);
371 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
,
372 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
);
374 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_SILENT
, &silent
);
375 if(SUCCEEDED(hres
)) {
376 if(V_VT(&silent
) != VT_BOOL
)
377 WARN("silent = %s\n", debugstr_variant(&silent
));
378 else if(V_BOOL(&silent
))
379 FIXME("silent == true\n");
382 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERAGENT
);
383 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_PALETTE
);
388 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, IOleClientSite
**ppClientSite
)
390 HTMLDocument
*This
= impl_from_IOleObject(iface
);
392 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
397 if(This
->doc_obj
->client
)
398 IOleClientSite_AddRef(This
->doc_obj
->client
);
399 *ppClientSite
= This
->doc_obj
->client
;
404 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
)
406 HTMLDocument
*This
= impl_from_IOleObject(iface
);
407 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
411 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
413 HTMLDocument
*This
= impl_from_IOleObject(iface
);
415 TRACE("(%p)->(%08x)\n", This
, dwSaveOption
);
417 if(dwSaveOption
== OLECLOSE_PROMPTSAVE
)
418 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
420 if(This
->doc_obj
->in_place_active
)
421 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
423 HTMLDocument_LockContainer(This
->doc_obj
, FALSE
);
425 if(This
->advise_holder
)
426 IOleAdviseHolder_SendOnClose(This
->advise_holder
);
431 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
*pmk
)
433 HTMLDocument
*This
= impl_from_IOleObject(iface
);
434 FIXME("(%p %d %p)->()\n", This
, dwWhichMoniker
, pmk
);
438 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
**ppmk
)
440 HTMLDocument
*This
= impl_from_IOleObject(iface
);
441 FIXME("(%p)->(%d %d %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
445 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, IDataObject
*pDataObject
, BOOL fCreation
,
448 HTMLDocument
*This
= impl_from_IOleObject(iface
);
449 FIXME("(%p)->(%p %x %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
453 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
, IDataObject
**ppDataObject
)
455 HTMLDocument
*This
= impl_from_IOleObject(iface
);
456 FIXME("(%p)->(%d %p)\n", This
, dwReserved
, ppDataObject
);
460 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, LPMSG lpmsg
, IOleClientSite
*pActiveSite
,
461 LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
463 HTMLDocument
*This
= impl_from_IOleObject(iface
);
464 IOleDocumentSite
*pDocSite
;
467 TRACE("(%p)->(%d %p %p %d %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
, lprcPosRect
);
469 if(iVerb
!= OLEIVERB_SHOW
&& iVerb
!= OLEIVERB_UIACTIVATE
&& iVerb
!= OLEIVERB_INPLACEACTIVATE
) {
470 FIXME("iVerb = %d not supported\n", iVerb
);
475 pActiveSite
= This
->doc_obj
->client
;
477 hres
= IOleClientSite_QueryInterface(pActiveSite
, &IID_IOleDocumentSite
, (void**)&pDocSite
);
478 if(SUCCEEDED(hres
)) {
479 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
481 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
482 hres
= IOleDocumentSite_ActivateMe(pDocSite
, &This
->IOleDocumentView_iface
);
483 IOleDocumentSite_Release(pDocSite
);
485 hres
= IOleDocumentView_UIActivate(&This
->IOleDocumentView_iface
, TRUE
);
486 if(SUCCEEDED(hres
)) {
488 RECT rect
; /* We need to pass rect as not const pointer */
490 IOleDocumentView_SetRect(&This
->IOleDocumentView_iface
, &rect
);
492 IOleDocumentView_Show(&This
->IOleDocumentView_iface
, TRUE
);
499 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
501 HTMLDocument
*This
= impl_from_IOleObject(iface
);
502 FIXME("(%p)->(%p)\n", This
, ppEnumOleVerb
);
506 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
508 HTMLDocument
*This
= impl_from_IOleObject(iface
);
509 FIXME("(%p)\n", This
);
513 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
515 HTMLDocument
*This
= impl_from_IOleObject(iface
);
516 FIXME("(%p)\n", This
);
520 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*pClsid
)
522 HTMLDocument
*This
= impl_from_IOleObject(iface
);
524 TRACE("(%p)->(%p)\n", This
, pClsid
);
529 *pClsid
= CLSID_HTMLDocument
;
533 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
, LPOLESTR
*pszUserType
)
535 HTMLDocument
*This
= impl_from_IOleObject(iface
);
536 FIXME("(%p)->(%d %p)\n", This
, dwFormOfType
, pszUserType
);
540 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
542 HTMLDocument
*This
= impl_from_IOleObject(iface
);
543 FIXME("(%p)->(%d %p)\n", This
, dwDrawAspect
, psizel
);
547 static HRESULT WINAPI
OleObject_GetExtent(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_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
)
556 HTMLDocument
*This
= impl_from_IOleObject(iface
);
557 TRACE("(%p)->(%p %p)\n", This
, pAdvSink
, pdwConnection
);
567 if(!This
->advise_holder
) {
568 CreateOleAdviseHolder(&This
->advise_holder
);
569 if(!This
->advise_holder
)
570 return E_OUTOFMEMORY
;
573 return IOleAdviseHolder_Advise(This
->advise_holder
, pAdvSink
, pdwConnection
);
576 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
578 HTMLDocument
*This
= impl_from_IOleObject(iface
);
579 TRACE("(%p)->(%d)\n", This
, dwConnection
);
581 if(!This
->advise_holder
)
582 return OLE_E_NOCONNECTION
;
584 return IOleAdviseHolder_Unadvise(This
->advise_holder
, dwConnection
);
587 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
589 HTMLDocument
*This
= impl_from_IOleObject(iface
);
591 if(!This
->advise_holder
) {
592 *ppenumAdvise
= NULL
;
596 return IOleAdviseHolder_EnumAdvise(This
->advise_holder
, ppenumAdvise
);
599 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
601 HTMLDocument
*This
= impl_from_IOleObject(iface
);
602 FIXME("(%p)->(%d %p)\n", This
, dwAspect
, pdwStatus
);
606 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
*pLogpal
)
608 HTMLDocument
*This
= impl_from_IOleObject(iface
);
609 FIXME("(%p)->(%p)\n", This
, pLogpal
);
613 static const IOleObjectVtbl OleObjectVtbl
= {
614 OleObject_QueryInterface
,
617 OleObject_SetClientSite
,
618 OleObject_GetClientSite
,
619 OleObject_SetHostNames
,
621 OleObject_SetMoniker
,
622 OleObject_GetMoniker
,
623 OleObject_InitFromData
,
624 OleObject_GetClipboardData
,
628 OleObject_IsUpToDate
,
629 OleObject_GetUserClassID
,
630 OleObject_GetUserType
,
635 OleObject_EnumAdvise
,
636 OleObject_GetMiscStatus
,
637 OleObject_SetColorScheme
640 /**********************************************************
641 * IOleDocument implementation
644 static inline HTMLDocument
*impl_from_IOleDocument(IOleDocument
*iface
)
646 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleDocument_iface
);
649 static HRESULT WINAPI
OleDocument_QueryInterface(IOleDocument
*iface
, REFIID riid
, void **ppv
)
651 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
652 return htmldoc_query_interface(This
, riid
, ppv
);
655 static ULONG WINAPI
OleDocument_AddRef(IOleDocument
*iface
)
657 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
658 return htmldoc_addref(This
);
661 static ULONG WINAPI
OleDocument_Release(IOleDocument
*iface
)
663 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
664 return htmldoc_release(This
);
667 static HRESULT WINAPI
OleDocument_CreateView(IOleDocument
*iface
, IOleInPlaceSite
*pIPSite
, IStream
*pstm
,
668 DWORD dwReserved
, IOleDocumentView
**ppView
)
670 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
673 TRACE("(%p)->(%p %p %d %p)\n", This
, pIPSite
, pstm
, dwReserved
, ppView
);
679 * Windows implementation creates new IOleDocumentView when function is called for the
680 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
681 * if the application uses returned interfaces, passed to ActivateMe or returned by
682 * QueryInterface, so there is no reason to create new interface. This needs more testing.
686 hres
= IOleDocumentView_SetInPlaceSite(&This
->IOleDocumentView_iface
, pIPSite
);
692 FIXME("pstm is not supported\n");
694 IOleDocumentView_AddRef(&This
->IOleDocumentView_iface
);
695 *ppView
= &This
->IOleDocumentView_iface
;
699 static HRESULT WINAPI
OleDocument_GetDocMiscStatus(IOleDocument
*iface
, DWORD
*pdwStatus
)
701 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
702 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
706 static HRESULT WINAPI
OleDocument_EnumViews(IOleDocument
*iface
, IEnumOleDocumentViews
**ppEnum
,
707 IOleDocumentView
**ppView
)
709 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
710 FIXME("(%p)->(%p %p)\n", This
, ppEnum
, ppView
);
714 static const IOleDocumentVtbl OleDocumentVtbl
= {
715 OleDocument_QueryInterface
,
718 OleDocument_CreateView
,
719 OleDocument_GetDocMiscStatus
,
720 OleDocument_EnumViews
723 /**********************************************************
724 * IOleControl implementation
727 static inline HTMLDocument
*impl_from_IOleControl(IOleControl
*iface
)
729 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleControl_iface
);
732 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **ppv
)
734 HTMLDocument
*This
= impl_from_IOleControl(iface
);
735 return htmldoc_query_interface(This
, riid
, ppv
);
738 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
740 HTMLDocument
*This
= impl_from_IOleControl(iface
);
741 return htmldoc_addref(This
);
744 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
746 HTMLDocument
*This
= impl_from_IOleControl(iface
);
747 return htmldoc_release(This
);
750 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*pCI
)
752 HTMLDocument
*This
= impl_from_IOleControl(iface
);
753 FIXME("(%p)->(%p)\n", This
, pCI
);
757 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*pMsg
)
759 HTMLDocument
*This
= impl_from_IOleControl(iface
);
760 FIXME("(%p)->(%p)\n", This
, pMsg
);
764 HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
766 IDispatch
*disp
= NULL
;
767 DISPPARAMS dispparams
= {NULL
, 0};
771 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
773 TRACE("Could not get IDispatch\n");
779 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
780 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, &err
);
782 IDispatch_Release(disp
);
787 static HRESULT
on_change_dlcontrol(HTMLDocument
*This
)
792 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_DLCONTROL
, &res
);
794 FIXME("unsupported dlcontrol %08x\n", V_I4(&res
));
799 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
801 HTMLDocument
*This
= impl_from_IOleControl(iface
);
802 IOleClientSite
*client
;
806 client
= This
->doc_obj
->client
;
808 TRACE("client = NULL\n");
813 case DISPID_AMBIENT_USERMODE
:
814 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This
);
815 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERMODE
, &res
);
819 if(V_VT(&res
) == VT_BOOL
) {
821 This
->doc_obj
->usermode
= BROWSEMODE
;
823 FIXME("edit mode is not supported\n");
824 This
->doc_obj
->usermode
= EDITMODE
;
827 FIXME("usermode=%s\n", debugstr_variant(&res
));
830 case DISPID_AMBIENT_DLCONTROL
:
831 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This
);
832 return on_change_dlcontrol(This
);
833 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
834 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This
);
835 on_change_dlcontrol(This
);
836 hres
= get_client_disp_property(client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &res
);
840 if(V_VT(&res
) == VT_BOOL
) {
842 FIXME("offline connection is not supported\n");
846 FIXME("offlineconnected=%s\n", debugstr_variant(&res
));
849 case DISPID_AMBIENT_SILENT
:
850 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This
);
851 on_change_dlcontrol(This
);
852 hres
= get_client_disp_property(client
, DISPID_AMBIENT_SILENT
, &res
);
856 if(V_VT(&res
) == VT_BOOL
) {
858 FIXME("silent mode is not supported\n");
862 FIXME("silent=%s\n", debugstr_variant(&res
));
865 case DISPID_AMBIENT_USERAGENT
:
866 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This
);
867 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERAGENT
, &res
);
871 FIXME("not supported AMBIENT_USERAGENT\n");
874 case DISPID_AMBIENT_PALETTE
:
875 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This
);
876 hres
= get_client_disp_property(client
, DISPID_AMBIENT_PALETTE
, &res
);
880 FIXME("not supported AMBIENT_PALETTE\n");
885 FIXME("(%p) unsupported dispID=%d\n", This
, dispID
);
889 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
891 HTMLDocument
*This
= impl_from_IOleControl(iface
);
892 FIXME("(%p)->(%x)\n", This
, bFreeze
);
896 static const IOleControlVtbl OleControlVtbl
= {
897 OleControl_QueryInterface
,
900 OleControl_GetControlInfo
,
901 OleControl_OnMnemonic
,
902 OleControl_OnAmbientPropertyChange
,
903 OleControl_FreezeEvents
906 /**********************************************************
907 * IObjectWithSite implementation
910 static inline HTMLDocument
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
912 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectWithSite_iface
);
915 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
*iface
, REFIID riid
, void **ppv
)
917 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
918 return htmldoc_query_interface(This
, riid
, ppv
);
921 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
923 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
924 return htmldoc_addref(This
);
927 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
929 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
930 return htmldoc_release(This
);
933 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
935 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
936 FIXME("(%p)->(%p)\n", This
, pUnkSite
);
940 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
* iface
, REFIID riid
, PVOID
*ppvSite
)
942 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
943 FIXME("(%p)->(%p)\n", This
, ppvSite
);
947 static const IObjectWithSiteVtbl ObjectWithSiteVtbl
= {
948 ObjectWithSite_QueryInterface
,
949 ObjectWithSite_AddRef
,
950 ObjectWithSite_Release
,
951 ObjectWithSite_SetSite
,
952 ObjectWithSite_GetSite
955 /**********************************************************
956 * IOleContainer implementation
959 static inline HTMLDocument
*impl_from_IOleContainer(IOleContainer
*iface
)
961 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleContainer_iface
);
964 static HRESULT WINAPI
OleContainer_QueryInterface(IOleContainer
*iface
, REFIID riid
, void **ppv
)
966 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
967 return htmldoc_query_interface(This
, riid
, ppv
);
970 static ULONG WINAPI
OleContainer_AddRef(IOleContainer
*iface
)
972 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
973 return htmldoc_addref(This
);
976 static ULONG WINAPI
OleContainer_Release(IOleContainer
*iface
)
978 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
979 return htmldoc_release(This
);
982 static HRESULT WINAPI
OleContainer_ParseDisplayName(IOleContainer
*iface
, IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
983 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
985 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
986 FIXME("(%p)->(%p %s %p %p)\n", This
, pbc
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
990 static HRESULT WINAPI
OleContainer_EnumObjects(IOleContainer
*iface
, DWORD grfFlags
, IEnumUnknown
**ppenum
)
992 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
995 TRACE("(%p)->(%x %p)\n", This
, grfFlags
, ppenum
);
997 ret
= heap_alloc(sizeof(*ret
));
999 return E_OUTOFMEMORY
;
1001 ret
->IEnumUnknown_iface
.lpVtbl
= &EnumUnknownVtbl
;
1004 *ppenum
= &ret
->IEnumUnknown_iface
;
1008 static HRESULT WINAPI
OleContainer_LockContainer(IOleContainer
*iface
, BOOL fLock
)
1010 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1011 FIXME("(%p)->(%x)\n", This
, fLock
);
1015 static const IOleContainerVtbl OleContainerVtbl
= {
1016 OleContainer_QueryInterface
,
1017 OleContainer_AddRef
,
1018 OleContainer_Release
,
1019 OleContainer_ParseDisplayName
,
1020 OleContainer_EnumObjects
,
1021 OleContainer_LockContainer
1024 static inline HTMLDocumentObj
*impl_from_ITargetContainer(ITargetContainer
*iface
)
1026 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ITargetContainer_iface
);
1029 static HRESULT WINAPI
TargetContainer_QueryInterface(ITargetContainer
*iface
, REFIID riid
, void **ppv
)
1031 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1032 return ICustomDoc_QueryInterface(&This
->ICustomDoc_iface
, riid
, ppv
);
1035 static ULONG WINAPI
TargetContainer_AddRef(ITargetContainer
*iface
)
1037 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1038 return ICustomDoc_AddRef(&This
->ICustomDoc_iface
);
1041 static ULONG WINAPI
TargetContainer_Release(ITargetContainer
*iface
)
1043 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1044 return ICustomDoc_Release(&This
->ICustomDoc_iface
);
1047 static HRESULT WINAPI
TargetContainer_GetFrameUrl(ITargetContainer
*iface
, LPWSTR
*ppszFrameSrc
)
1049 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1050 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1054 static HRESULT WINAPI
TargetContainer_GetFramesContainer(ITargetContainer
*iface
, IOleContainer
**ppContainer
)
1056 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1058 TRACE("(%p)->(%p)\n", This
, ppContainer
);
1060 /* NOTE: we should return wrapped interface here */
1061 IOleContainer_AddRef(&This
->basedoc
.IOleContainer_iface
);
1062 *ppContainer
= &This
->basedoc
.IOleContainer_iface
;
1066 static const ITargetContainerVtbl TargetContainerVtbl
= {
1067 TargetContainer_QueryInterface
,
1068 TargetContainer_AddRef
,
1069 TargetContainer_Release
,
1070 TargetContainer_GetFrameUrl
,
1071 TargetContainer_GetFramesContainer
1074 void TargetContainer_Init(HTMLDocumentObj
*This
)
1076 This
->ITargetContainer_iface
.lpVtbl
= &TargetContainerVtbl
;
1079 /**********************************************************
1080 * IObjectSafety implementation
1083 static inline HTMLDocument
*impl_from_IObjectSafety(IObjectSafety
*iface
)
1085 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectSafety_iface
);
1088 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1090 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1091 return htmldoc_query_interface(This
, riid
, ppv
);
1094 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1096 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1097 return htmldoc_addref(This
);
1100 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1102 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1103 return htmldoc_release(This
);
1106 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
,
1107 REFIID riid
, DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1109 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1110 FIXME("(%p)->(%s %p %p)\n", This
, debugstr_guid(riid
), pdwSupportedOptions
, pdwEnabledOptions
);
1114 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
,
1115 REFIID riid
, DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1117 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1118 FIXME("(%p)->(%s %x %x)\n", This
, debugstr_guid(riid
), dwOptionSetMask
, dwEnabledOptions
);
1120 if(IsEqualGUID(&IID_IPersistMoniker
, riid
) &&
1121 dwOptionSetMask
==INTERFACESAFE_FOR_UNTRUSTED_DATA
&&
1122 dwEnabledOptions
==INTERFACESAFE_FOR_UNTRUSTED_DATA
)
1128 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1129 ObjectSafety_QueryInterface
,
1130 ObjectSafety_AddRef
,
1131 ObjectSafety_Release
,
1132 ObjectSafety_GetInterfaceSafetyOptions
,
1133 ObjectSafety_SetInterfaceSafetyOptions
1136 void HTMLDocument_LockContainer(HTMLDocumentObj
*This
, BOOL fLock
)
1138 IOleContainer
*container
;
1141 if(!This
->client
|| This
->container_locked
== fLock
)
1144 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
1145 if(SUCCEEDED(hres
)) {
1146 IOleContainer_LockContainer(container
, fLock
);
1147 This
->container_locked
= fLock
;
1148 IOleContainer_Release(container
);
1152 void HTMLDocument_OleObj_Init(HTMLDocument
*This
)
1154 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1155 This
->IOleDocument_iface
.lpVtbl
= &OleDocumentVtbl
;
1156 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1157 This
->IObjectWithSite_iface
.lpVtbl
= &ObjectWithSiteVtbl
;
1158 This
->IOleContainer_iface
.lpVtbl
= &OleContainerVtbl
;
1159 This
->IObjectSafety_iface
.lpVtbl
= &ObjectSafetyVtbl
;