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 void set_document_navigation(HTMLDocumentObj
*doc
, BOOL doc_can_navigate
)
197 if(!doc
->client_cmdtrg
)
200 if(doc_can_navigate
) {
201 V_VT(&var
) = VT_UNKNOWN
;
202 V_UNKNOWN(&var
) = (IUnknown
*)&doc
->basedoc
.window
->base
.IHTMLWindow2_iface
;
205 IOleCommandTarget_Exec(doc
->client_cmdtrg
, &CGID_DocHostCmdPriv
, DOCHOST_DOCCANNAVIGATE
, 0,
206 doc_can_navigate
? &var
: NULL
, NULL
);
209 static void load_settings(HTMLDocumentObj
*doc
)
211 nsIMarkupDocumentViewer
*markup_document_viewer
;
212 nsIContentViewer
*content_viewer
;
213 nsIDocShell
*doc_shell
;
219 static const WCHAR ie_keyW
[] = {
220 'S','O','F','T','W','A','R','E','\\',
221 'M','i','c','r','o','s','o','f','t','\\',
222 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
223 static const WCHAR zoomW
[] = {'Z','o','o','m',0};
224 static const WCHAR zoom_factorW
[] = {'Z','o','o','m','F','a','c','t','o','r',0};
226 res
= RegOpenKeyW(HKEY_CURRENT_USER
, ie_keyW
, &settings_key
);
227 if(res
!= ERROR_SUCCESS
)
231 res
= RegGetValueW(settings_key
, zoomW
, zoom_factorW
, RRF_RT_REG_DWORD
, NULL
, &val
, &size
);
232 RegCloseKey(settings_key
);
233 if(res
!= ERROR_SUCCESS
)
236 TRACE("Setting ZoomFactor to %u\n", val
);
238 nsres
= get_nsinterface((nsISupports
*)doc
->nscontainer
->navigation
, &IID_nsIDocShell
, (void**)&doc_shell
);
239 assert(nsres
== NS_OK
);
241 nsres
= nsIDocShell_GetContentViewer(doc_shell
, &content_viewer
);
242 assert(nsres
== NS_OK
&& content_viewer
);
244 nsres
= nsISupports_QueryInterface(content_viewer
, &IID_nsIMarkupDocumentViewer
, (void**)&markup_document_viewer
);
245 nsISupports_Release(content_viewer
);
246 assert(nsres
== NS_OK
);
248 nsres
= nsIMarkupDocumentViewer_SetFullZoom(markup_document_viewer
, (float)val
/100000);
250 ERR("SetFullZoom failed: %08x\n", nsres
);
252 nsIDocShell_Release(doc_shell
);
255 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, IOleClientSite
*pClientSite
)
257 HTMLDocument
*This
= impl_from_IOleObject(iface
);
258 IOleCommandTarget
*cmdtrg
= NULL
;
259 IOleWindow
*ole_window
;
260 IBrowserService
*browser_service
;
266 TRACE("(%p)->(%p)\n", This
, pClientSite
);
268 if(pClientSite
== This
->doc_obj
->client
)
271 if(This
->doc_obj
->client
) {
272 IOleClientSite_Release(This
->doc_obj
->client
);
273 This
->doc_obj
->client
= NULL
;
274 This
->doc_obj
->usermode
= UNKNOWN_USERMODE
;
277 if(This
->doc_obj
->client_cmdtrg
) {
278 IOleCommandTarget_Release(This
->doc_obj
->client_cmdtrg
);
279 This
->doc_obj
->client_cmdtrg
= NULL
;
282 if(This
->doc_obj
->hostui
&& !This
->doc_obj
->custom_hostui
) {
283 IDocHostUIHandler_Release(This
->doc_obj
->hostui
);
284 This
->doc_obj
->hostui
= NULL
;
287 if(This
->doc_obj
->doc_object_service
) {
288 IDocObjectService_Release(This
->doc_obj
->doc_object_service
);
289 This
->doc_obj
->doc_object_service
= NULL
;
292 if(This
->doc_obj
->webbrowser
) {
293 IUnknown_Release(This
->doc_obj
->webbrowser
);
294 This
->doc_obj
->webbrowser
= NULL
;
297 if(This
->doc_obj
->browser_service
) {
298 IUnknown_Release(This
->doc_obj
->browser_service
);
299 This
->doc_obj
->browser_service
= NULL
;
302 if(This
->doc_obj
->travel_log
) {
303 ITravelLog_Release(This
->doc_obj
->travel_log
);
304 This
->doc_obj
->travel_log
= NULL
;
307 memset(&This
->doc_obj
->hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
312 IOleClientSite_AddRef(pClientSite
);
313 This
->doc_obj
->client
= pClientSite
;
315 hostui_setup
= This
->doc_obj
->hostui_setup
;
317 if(!This
->doc_obj
->hostui
) {
318 IDocHostUIHandler
*uihandler
;
320 This
->doc_obj
->custom_hostui
= FALSE
;
322 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IDocHostUIHandler
, (void**)&uihandler
);
324 This
->doc_obj
->hostui
= uihandler
;
327 if(This
->doc_obj
->hostui
) {
328 DOCHOSTUIINFO hostinfo
;
329 LPOLESTR key_path
= NULL
, override_key_path
= NULL
;
330 IDocHostUIHandler2
*uihandler2
;
332 memset(&hostinfo
, 0, sizeof(DOCHOSTUIINFO
));
333 hostinfo
.cbSize
= sizeof(DOCHOSTUIINFO
);
334 hres
= IDocHostUIHandler_GetHostInfo(This
->doc_obj
->hostui
, &hostinfo
);
335 if(SUCCEEDED(hres
)) {
336 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
337 hostinfo
.cbSize
, hostinfo
.dwFlags
, hostinfo
.dwDoubleClick
,
338 debugstr_w(hostinfo
.pchHostCss
), debugstr_w(hostinfo
.pchHostNS
));
339 update_hostinfo(This
->doc_obj
, &hostinfo
);
340 This
->doc_obj
->hostinfo
= hostinfo
;
344 hres
= IDocHostUIHandler_GetOptionKeyPath(This
->doc_obj
->hostui
, &key_path
, 0);
345 if(hres
== S_OK
&& key_path
) {
347 /* FIXME: use key_path */
348 FIXME("key_path = %s\n", debugstr_w(key_path
));
350 CoTaskMemFree(key_path
);
353 hres
= IDocHostUIHandler_QueryInterface(This
->doc_obj
->hostui
, &IID_IDocHostUIHandler2
,
354 (void**)&uihandler2
);
355 if(SUCCEEDED(hres
)) {
356 hres
= IDocHostUIHandler2_GetOverrideKeyPath(uihandler2
, &override_key_path
, 0);
357 if(hres
== S_OK
&& override_key_path
) {
358 if(override_key_path
[0]) {
359 /*FIXME: use override_key_path */
360 FIXME("override_key_path = %s\n", debugstr_w(override_key_path
));
362 CoTaskMemFree(override_key_path
);
364 IDocHostUIHandler2_Release(uihandler2
);
367 This
->doc_obj
->hostui_setup
= TRUE
;
371 load_settings(This
->doc_obj
);
373 /* Native calls here GetWindow. What is it for?
374 * We don't have anything to do with it here (yet). */
375 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleWindow
, (void**)&ole_window
);
376 if(SUCCEEDED(hres
)) {
377 IOleWindow_GetWindow(ole_window
, &hwnd
);
378 IOleWindow_Release(ole_window
);
381 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IShellBrowser
,
382 &IID_IBrowserService
, (void**)&browser_service
);
383 if(SUCCEEDED(hres
)) {
384 ITravelLog
*travel_log
;
386 This
->doc_obj
->browser_service
= (IUnknown
*)browser_service
;
388 hres
= IBrowserService_GetTravelLog(browser_service
, &travel_log
);
390 This
->doc_obj
->travel_log
= travel_log
;
392 browser_service
= NULL
;
395 hres
= IOleClientSite_QueryInterface(pClientSite
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
396 if(SUCCEEDED(hres
)) {
398 OLECMD cmd
= {OLECMDID_SETPROGRESSTEXT
, 0};
400 This
->doc_obj
->client_cmdtrg
= cmdtrg
;
403 IDocObjectService
*doc_object_service
;
406 set_document_navigation(This
->doc_obj
, TRUE
);
408 if(browser_service
) {
409 hres
= IBrowserService_QueryInterface(browser_service
,
410 &IID_IDocObjectService
, (void**)&doc_object_service
);
411 if(SUCCEEDED(hres
)) {
412 This
->doc_obj
->doc_object_service
= doc_object_service
;
415 * Some embedding routines, esp. in regards to use of IDocObjectService, differ if
416 * embedder supports IWebBrowserApp.
418 hres
= do_query_service((IUnknown
*)pClientSite
, &IID_IWebBrowserApp
, &IID_IWebBrowser2
, (void**)&wb
);
420 This
->doc_obj
->webbrowser
= (IUnknown
*)wb
;
425 call_docview_84(This
->doc_obj
);
427 IOleCommandTarget_QueryStatus(cmdtrg
, NULL
, 1, &cmd
, NULL
);
431 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
432 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
433 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
434 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
437 if(This
->doc_obj
->usermode
== UNKNOWN_USERMODE
)
438 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERMODE
);
440 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
,
441 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
);
443 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_SILENT
, &silent
);
444 if(SUCCEEDED(hres
)) {
445 if(V_VT(&silent
) != VT_BOOL
)
446 WARN("silent = %s\n", debugstr_variant(&silent
));
447 else if(V_BOOL(&silent
))
448 FIXME("silent == true\n");
451 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_USERAGENT
);
452 IOleControl_OnAmbientPropertyChange(&This
->IOleControl_iface
, DISPID_AMBIENT_PALETTE
);
457 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, IOleClientSite
**ppClientSite
)
459 HTMLDocument
*This
= impl_from_IOleObject(iface
);
461 TRACE("(%p)->(%p)\n", This
, ppClientSite
);
466 if(This
->doc_obj
->client
)
467 IOleClientSite_AddRef(This
->doc_obj
->client
);
468 *ppClientSite
= This
->doc_obj
->client
;
473 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR szContainerApp
, LPCOLESTR szContainerObj
)
475 HTMLDocument
*This
= impl_from_IOleObject(iface
);
476 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(szContainerApp
), debugstr_w(szContainerObj
));
480 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD dwSaveOption
)
482 HTMLDocument
*This
= impl_from_IOleObject(iface
);
484 TRACE("(%p)->(%08x)\n", This
, dwSaveOption
);
486 if(dwSaveOption
== OLECLOSE_PROMPTSAVE
)
487 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
489 if(This
->doc_obj
->in_place_active
)
490 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
492 HTMLDocument_LockContainer(This
->doc_obj
, FALSE
);
494 if(This
->advise_holder
)
495 IOleAdviseHolder_SendOnClose(This
->advise_holder
);
500 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD dwWhichMoniker
, IMoniker
*pmk
)
502 HTMLDocument
*This
= impl_from_IOleObject(iface
);
503 FIXME("(%p %d %p)->()\n", This
, dwWhichMoniker
, pmk
);
507 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD dwAssign
, DWORD dwWhichMoniker
, IMoniker
**ppmk
)
509 HTMLDocument
*This
= impl_from_IOleObject(iface
);
510 FIXME("(%p)->(%d %d %p)\n", This
, dwAssign
, dwWhichMoniker
, ppmk
);
514 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, IDataObject
*pDataObject
, BOOL fCreation
,
517 HTMLDocument
*This
= impl_from_IOleObject(iface
);
518 FIXME("(%p)->(%p %x %d)\n", This
, pDataObject
, fCreation
, dwReserved
);
522 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD dwReserved
, IDataObject
**ppDataObject
)
524 HTMLDocument
*This
= impl_from_IOleObject(iface
);
525 FIXME("(%p)->(%d %p)\n", This
, dwReserved
, ppDataObject
);
529 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG iVerb
, LPMSG lpmsg
, IOleClientSite
*pActiveSite
,
530 LONG lindex
, HWND hwndParent
, LPCRECT lprcPosRect
)
532 HTMLDocument
*This
= impl_from_IOleObject(iface
);
533 IOleDocumentSite
*pDocSite
;
536 TRACE("(%p)->(%d %p %p %d %p %p)\n", This
, iVerb
, lpmsg
, pActiveSite
, lindex
, hwndParent
, lprcPosRect
);
538 if(iVerb
!= OLEIVERB_SHOW
&& iVerb
!= OLEIVERB_UIACTIVATE
&& iVerb
!= OLEIVERB_INPLACEACTIVATE
) {
539 FIXME("iVerb = %d not supported\n", iVerb
);
544 pActiveSite
= This
->doc_obj
->client
;
546 hres
= IOleClientSite_QueryInterface(pActiveSite
, &IID_IOleDocumentSite
, (void**)&pDocSite
);
547 if(SUCCEEDED(hres
)) {
548 HTMLDocument_LockContainer(This
->doc_obj
, TRUE
);
550 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
551 hres
= IOleDocumentSite_ActivateMe(pDocSite
, &This
->IOleDocumentView_iface
);
552 IOleDocumentSite_Release(pDocSite
);
554 hres
= IOleDocumentView_UIActivate(&This
->IOleDocumentView_iface
, TRUE
);
555 if(SUCCEEDED(hres
)) {
557 RECT rect
; /* We need to pass rect as not const pointer */
559 IOleDocumentView_SetRect(&This
->IOleDocumentView_iface
, &rect
);
561 IOleDocumentView_Show(&This
->IOleDocumentView_iface
, TRUE
);
568 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**ppEnumOleVerb
)
570 HTMLDocument
*This
= impl_from_IOleObject(iface
);
571 FIXME("(%p)->(%p)\n", This
, ppEnumOleVerb
);
575 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
577 HTMLDocument
*This
= impl_from_IOleObject(iface
);
578 FIXME("(%p)\n", This
);
582 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
584 HTMLDocument
*This
= impl_from_IOleObject(iface
);
585 FIXME("(%p)\n", This
);
589 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*pClsid
)
591 HTMLDocument
*This
= impl_from_IOleObject(iface
);
593 TRACE("(%p)->(%p)\n", This
, pClsid
);
598 *pClsid
= CLSID_HTMLDocument
;
602 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD dwFormOfType
, LPOLESTR
*pszUserType
)
604 HTMLDocument
*This
= impl_from_IOleObject(iface
);
605 FIXME("(%p)->(%d %p)\n", This
, dwFormOfType
, pszUserType
);
609 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
611 HTMLDocument
*This
= impl_from_IOleObject(iface
);
612 FIXME("(%p)->(%d %p)\n", This
, dwDrawAspect
, psizel
);
616 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD dwDrawAspect
, SIZEL
*psizel
)
618 HTMLDocument
*This
= impl_from_IOleObject(iface
);
619 FIXME("(%p)->(%d %p)\n", This
, dwDrawAspect
, psizel
);
623 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*pAdvSink
, DWORD
*pdwConnection
)
625 HTMLDocument
*This
= impl_from_IOleObject(iface
);
626 TRACE("(%p)->(%p %p)\n", This
, pAdvSink
, pdwConnection
);
636 if(!This
->advise_holder
) {
637 CreateOleAdviseHolder(&This
->advise_holder
);
638 if(!This
->advise_holder
)
639 return E_OUTOFMEMORY
;
642 return IOleAdviseHolder_Advise(This
->advise_holder
, pAdvSink
, pdwConnection
);
645 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD dwConnection
)
647 HTMLDocument
*This
= impl_from_IOleObject(iface
);
648 TRACE("(%p)->(%d)\n", This
, dwConnection
);
650 if(!This
->advise_holder
)
651 return OLE_E_NOCONNECTION
;
653 return IOleAdviseHolder_Unadvise(This
->advise_holder
, dwConnection
);
656 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**ppenumAdvise
)
658 HTMLDocument
*This
= impl_from_IOleObject(iface
);
660 if(!This
->advise_holder
) {
661 *ppenumAdvise
= NULL
;
665 return IOleAdviseHolder_EnumAdvise(This
->advise_holder
, ppenumAdvise
);
668 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD dwAspect
, DWORD
*pdwStatus
)
670 HTMLDocument
*This
= impl_from_IOleObject(iface
);
671 FIXME("(%p)->(%d %p)\n", This
, dwAspect
, pdwStatus
);
675 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
*pLogpal
)
677 HTMLDocument
*This
= impl_from_IOleObject(iface
);
678 FIXME("(%p)->(%p)\n", This
, pLogpal
);
682 static const IOleObjectVtbl OleObjectVtbl
= {
683 OleObject_QueryInterface
,
686 OleObject_SetClientSite
,
687 OleObject_GetClientSite
,
688 OleObject_SetHostNames
,
690 OleObject_SetMoniker
,
691 OleObject_GetMoniker
,
692 OleObject_InitFromData
,
693 OleObject_GetClipboardData
,
697 OleObject_IsUpToDate
,
698 OleObject_GetUserClassID
,
699 OleObject_GetUserType
,
704 OleObject_EnumAdvise
,
705 OleObject_GetMiscStatus
,
706 OleObject_SetColorScheme
709 /**********************************************************
710 * IOleDocument implementation
713 static inline HTMLDocument
*impl_from_IOleDocument(IOleDocument
*iface
)
715 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleDocument_iface
);
718 static HRESULT WINAPI
OleDocument_QueryInterface(IOleDocument
*iface
, REFIID riid
, void **ppv
)
720 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
721 return htmldoc_query_interface(This
, riid
, ppv
);
724 static ULONG WINAPI
OleDocument_AddRef(IOleDocument
*iface
)
726 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
727 return htmldoc_addref(This
);
730 static ULONG WINAPI
OleDocument_Release(IOleDocument
*iface
)
732 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
733 return htmldoc_release(This
);
736 static HRESULT WINAPI
OleDocument_CreateView(IOleDocument
*iface
, IOleInPlaceSite
*pIPSite
, IStream
*pstm
,
737 DWORD dwReserved
, IOleDocumentView
**ppView
)
739 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
742 TRACE("(%p)->(%p %p %d %p)\n", This
, pIPSite
, pstm
, dwReserved
, ppView
);
748 * Windows implementation creates new IOleDocumentView when function is called for the
749 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
750 * if the application uses returned interfaces, passed to ActivateMe or returned by
751 * QueryInterface, so there is no reason to create new interface. This needs more testing.
755 hres
= IOleDocumentView_SetInPlaceSite(&This
->IOleDocumentView_iface
, pIPSite
);
761 FIXME("pstm is not supported\n");
763 IOleDocumentView_AddRef(&This
->IOleDocumentView_iface
);
764 *ppView
= &This
->IOleDocumentView_iface
;
768 static HRESULT WINAPI
OleDocument_GetDocMiscStatus(IOleDocument
*iface
, DWORD
*pdwStatus
)
770 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
771 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
775 static HRESULT WINAPI
OleDocument_EnumViews(IOleDocument
*iface
, IEnumOleDocumentViews
**ppEnum
,
776 IOleDocumentView
**ppView
)
778 HTMLDocument
*This
= impl_from_IOleDocument(iface
);
779 FIXME("(%p)->(%p %p)\n", This
, ppEnum
, ppView
);
783 static const IOleDocumentVtbl OleDocumentVtbl
= {
784 OleDocument_QueryInterface
,
787 OleDocument_CreateView
,
788 OleDocument_GetDocMiscStatus
,
789 OleDocument_EnumViews
792 /**********************************************************
793 * IOleControl implementation
796 static inline HTMLDocument
*impl_from_IOleControl(IOleControl
*iface
)
798 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleControl_iface
);
801 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **ppv
)
803 HTMLDocument
*This
= impl_from_IOleControl(iface
);
804 return htmldoc_query_interface(This
, riid
, ppv
);
807 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
809 HTMLDocument
*This
= impl_from_IOleControl(iface
);
810 return htmldoc_addref(This
);
813 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
815 HTMLDocument
*This
= impl_from_IOleControl(iface
);
816 return htmldoc_release(This
);
819 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*pCI
)
821 HTMLDocument
*This
= impl_from_IOleControl(iface
);
822 FIXME("(%p)->(%p)\n", This
, pCI
);
826 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*pMsg
)
828 HTMLDocument
*This
= impl_from_IOleControl(iface
);
829 FIXME("(%p)->(%p)\n", This
, pMsg
);
833 HRESULT
get_client_disp_property(IOleClientSite
*client
, DISPID dispid
, VARIANT
*res
)
835 IDispatch
*disp
= NULL
;
836 DISPPARAMS dispparams
= {NULL
, 0};
840 hres
= IOleClientSite_QueryInterface(client
, &IID_IDispatch
, (void**)&disp
);
842 TRACE("Could not get IDispatch\n");
848 hres
= IDispatch_Invoke(disp
, dispid
, &IID_NULL
, LOCALE_SYSTEM_DEFAULT
,
849 DISPATCH_PROPERTYGET
, &dispparams
, res
, NULL
, &err
);
851 IDispatch_Release(disp
);
856 static HRESULT
on_change_dlcontrol(HTMLDocument
*This
)
861 hres
= get_client_disp_property(This
->doc_obj
->client
, DISPID_AMBIENT_DLCONTROL
, &res
);
863 FIXME("unsupported dlcontrol %08x\n", V_I4(&res
));
868 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispID
)
870 HTMLDocument
*This
= impl_from_IOleControl(iface
);
871 IOleClientSite
*client
;
875 client
= This
->doc_obj
->client
;
877 TRACE("client = NULL\n");
882 case DISPID_AMBIENT_USERMODE
:
883 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This
);
884 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERMODE
, &res
);
888 if(V_VT(&res
) == VT_BOOL
) {
890 This
->doc_obj
->usermode
= BROWSEMODE
;
892 FIXME("edit mode is not supported\n");
893 This
->doc_obj
->usermode
= EDITMODE
;
896 FIXME("usermode=%s\n", debugstr_variant(&res
));
899 case DISPID_AMBIENT_DLCONTROL
:
900 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This
);
901 return on_change_dlcontrol(This
);
902 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
903 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This
);
904 on_change_dlcontrol(This
);
905 hres
= get_client_disp_property(client
, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
, &res
);
909 if(V_VT(&res
) == VT_BOOL
) {
911 FIXME("offline connection is not supported\n");
915 FIXME("offlineconnected=%s\n", debugstr_variant(&res
));
918 case DISPID_AMBIENT_SILENT
:
919 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This
);
920 on_change_dlcontrol(This
);
921 hres
= get_client_disp_property(client
, DISPID_AMBIENT_SILENT
, &res
);
925 if(V_VT(&res
) == VT_BOOL
) {
927 FIXME("silent mode is not supported\n");
931 FIXME("silent=%s\n", debugstr_variant(&res
));
934 case DISPID_AMBIENT_USERAGENT
:
935 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This
);
936 hres
= get_client_disp_property(client
, DISPID_AMBIENT_USERAGENT
, &res
);
940 FIXME("not supported AMBIENT_USERAGENT\n");
943 case DISPID_AMBIENT_PALETTE
:
944 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This
);
945 hres
= get_client_disp_property(client
, DISPID_AMBIENT_PALETTE
, &res
);
949 FIXME("not supported AMBIENT_PALETTE\n");
954 FIXME("(%p) unsupported dispID=%d\n", This
, dispID
);
958 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL bFreeze
)
960 HTMLDocument
*This
= impl_from_IOleControl(iface
);
961 FIXME("(%p)->(%x)\n", This
, bFreeze
);
965 static const IOleControlVtbl OleControlVtbl
= {
966 OleControl_QueryInterface
,
969 OleControl_GetControlInfo
,
970 OleControl_OnMnemonic
,
971 OleControl_OnAmbientPropertyChange
,
972 OleControl_FreezeEvents
975 /**********************************************************
976 * IObjectWithSite implementation
979 static inline HTMLDocument
*impl_from_IObjectWithSite(IObjectWithSite
*iface
)
981 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectWithSite_iface
);
984 static HRESULT WINAPI
ObjectWithSite_QueryInterface(IObjectWithSite
*iface
, REFIID riid
, void **ppv
)
986 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
987 return htmldoc_query_interface(This
, riid
, ppv
);
990 static ULONG WINAPI
ObjectWithSite_AddRef(IObjectWithSite
*iface
)
992 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
993 return htmldoc_addref(This
);
996 static ULONG WINAPI
ObjectWithSite_Release(IObjectWithSite
*iface
)
998 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
999 return htmldoc_release(This
);
1002 static HRESULT WINAPI
ObjectWithSite_SetSite(IObjectWithSite
*iface
, IUnknown
*pUnkSite
)
1004 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
1005 FIXME("(%p)->(%p)\n", This
, pUnkSite
);
1009 static HRESULT WINAPI
ObjectWithSite_GetSite(IObjectWithSite
* iface
, REFIID riid
, PVOID
*ppvSite
)
1011 HTMLDocument
*This
= impl_from_IObjectWithSite(iface
);
1012 FIXME("(%p)->(%p)\n", This
, ppvSite
);
1016 static const IObjectWithSiteVtbl ObjectWithSiteVtbl
= {
1017 ObjectWithSite_QueryInterface
,
1018 ObjectWithSite_AddRef
,
1019 ObjectWithSite_Release
,
1020 ObjectWithSite_SetSite
,
1021 ObjectWithSite_GetSite
1024 /**********************************************************
1025 * IOleContainer implementation
1028 static inline HTMLDocument
*impl_from_IOleContainer(IOleContainer
*iface
)
1030 return CONTAINING_RECORD(iface
, HTMLDocument
, IOleContainer_iface
);
1033 static HRESULT WINAPI
OleContainer_QueryInterface(IOleContainer
*iface
, REFIID riid
, void **ppv
)
1035 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1036 return htmldoc_query_interface(This
, riid
, ppv
);
1039 static ULONG WINAPI
OleContainer_AddRef(IOleContainer
*iface
)
1041 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1042 return htmldoc_addref(This
);
1045 static ULONG WINAPI
OleContainer_Release(IOleContainer
*iface
)
1047 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1048 return htmldoc_release(This
);
1051 static HRESULT WINAPI
OleContainer_ParseDisplayName(IOleContainer
*iface
, IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
1052 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
1054 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1055 FIXME("(%p)->(%p %s %p %p)\n", This
, pbc
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
1059 static HRESULT WINAPI
OleContainer_EnumObjects(IOleContainer
*iface
, DWORD grfFlags
, IEnumUnknown
**ppenum
)
1061 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1064 TRACE("(%p)->(%x %p)\n", This
, grfFlags
, ppenum
);
1066 ret
= heap_alloc(sizeof(*ret
));
1068 return E_OUTOFMEMORY
;
1070 ret
->IEnumUnknown_iface
.lpVtbl
= &EnumUnknownVtbl
;
1073 *ppenum
= &ret
->IEnumUnknown_iface
;
1077 static HRESULT WINAPI
OleContainer_LockContainer(IOleContainer
*iface
, BOOL fLock
)
1079 HTMLDocument
*This
= impl_from_IOleContainer(iface
);
1080 FIXME("(%p)->(%x)\n", This
, fLock
);
1084 static const IOleContainerVtbl OleContainerVtbl
= {
1085 OleContainer_QueryInterface
,
1086 OleContainer_AddRef
,
1087 OleContainer_Release
,
1088 OleContainer_ParseDisplayName
,
1089 OleContainer_EnumObjects
,
1090 OleContainer_LockContainer
1093 static inline HTMLDocumentObj
*impl_from_ITargetContainer(ITargetContainer
*iface
)
1095 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, ITargetContainer_iface
);
1098 static HRESULT WINAPI
TargetContainer_QueryInterface(ITargetContainer
*iface
, REFIID riid
, void **ppv
)
1100 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1101 return ICustomDoc_QueryInterface(&This
->ICustomDoc_iface
, riid
, ppv
);
1104 static ULONG WINAPI
TargetContainer_AddRef(ITargetContainer
*iface
)
1106 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1107 return ICustomDoc_AddRef(&This
->ICustomDoc_iface
);
1110 static ULONG WINAPI
TargetContainer_Release(ITargetContainer
*iface
)
1112 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1113 return ICustomDoc_Release(&This
->ICustomDoc_iface
);
1116 static HRESULT WINAPI
TargetContainer_GetFrameUrl(ITargetContainer
*iface
, LPWSTR
*ppszFrameSrc
)
1118 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1119 FIXME("(%p)->(%p)\n", This
, ppszFrameSrc
);
1123 static HRESULT WINAPI
TargetContainer_GetFramesContainer(ITargetContainer
*iface
, IOleContainer
**ppContainer
)
1125 HTMLDocumentObj
*This
= impl_from_ITargetContainer(iface
);
1127 TRACE("(%p)->(%p)\n", This
, ppContainer
);
1129 /* NOTE: we should return wrapped interface here */
1130 IOleContainer_AddRef(&This
->basedoc
.IOleContainer_iface
);
1131 *ppContainer
= &This
->basedoc
.IOleContainer_iface
;
1135 static const ITargetContainerVtbl TargetContainerVtbl
= {
1136 TargetContainer_QueryInterface
,
1137 TargetContainer_AddRef
,
1138 TargetContainer_Release
,
1139 TargetContainer_GetFrameUrl
,
1140 TargetContainer_GetFramesContainer
1143 void TargetContainer_Init(HTMLDocumentObj
*This
)
1145 This
->ITargetContainer_iface
.lpVtbl
= &TargetContainerVtbl
;
1148 /**********************************************************
1149 * IObjectSafety implementation
1152 static inline HTMLDocument
*impl_from_IObjectSafety(IObjectSafety
*iface
)
1154 return CONTAINING_RECORD(iface
, HTMLDocument
, IObjectSafety_iface
);
1157 static HRESULT WINAPI
ObjectSafety_QueryInterface(IObjectSafety
*iface
, REFIID riid
, void **ppv
)
1159 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1160 return htmldoc_query_interface(This
, riid
, ppv
);
1163 static ULONG WINAPI
ObjectSafety_AddRef(IObjectSafety
*iface
)
1165 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1166 return htmldoc_addref(This
);
1169 static ULONG WINAPI
ObjectSafety_Release(IObjectSafety
*iface
)
1171 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1172 return htmldoc_release(This
);
1175 static HRESULT WINAPI
ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety
*iface
,
1176 REFIID riid
, DWORD
*pdwSupportedOptions
, DWORD
*pdwEnabledOptions
)
1178 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1179 FIXME("(%p)->(%s %p %p)\n", This
, debugstr_guid(riid
), pdwSupportedOptions
, pdwEnabledOptions
);
1183 static HRESULT WINAPI
ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety
*iface
,
1184 REFIID riid
, DWORD dwOptionSetMask
, DWORD dwEnabledOptions
)
1186 HTMLDocument
*This
= impl_from_IObjectSafety(iface
);
1187 FIXME("(%p)->(%s %x %x)\n", This
, debugstr_guid(riid
), dwOptionSetMask
, dwEnabledOptions
);
1189 if(IsEqualGUID(&IID_IPersistMoniker
, riid
) &&
1190 dwOptionSetMask
==INTERFACESAFE_FOR_UNTRUSTED_DATA
&&
1191 dwEnabledOptions
==INTERFACESAFE_FOR_UNTRUSTED_DATA
)
1197 static const IObjectSafetyVtbl ObjectSafetyVtbl
= {
1198 ObjectSafety_QueryInterface
,
1199 ObjectSafety_AddRef
,
1200 ObjectSafety_Release
,
1201 ObjectSafety_GetInterfaceSafetyOptions
,
1202 ObjectSafety_SetInterfaceSafetyOptions
1205 void HTMLDocument_LockContainer(HTMLDocumentObj
*This
, BOOL fLock
)
1207 IOleContainer
*container
;
1210 if(!This
->client
|| This
->container_locked
== fLock
)
1213 hres
= IOleClientSite_GetContainer(This
->client
, &container
);
1214 if(SUCCEEDED(hres
)) {
1215 IOleContainer_LockContainer(container
, fLock
);
1216 This
->container_locked
= fLock
;
1217 IOleContainer_Release(container
);
1221 void HTMLDocument_OleObj_Init(HTMLDocument
*This
)
1223 This
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1224 This
->IOleDocument_iface
.lpVtbl
= &OleDocumentVtbl
;
1225 This
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1226 This
->IObjectWithSite_iface
.lpVtbl
= &ObjectWithSiteVtbl
;
1227 This
->IOleContainer_iface
.lpVtbl
= &OleContainerVtbl
;
1228 This
->IObjectSafety_iface
.lpVtbl
= &ObjectSafetyVtbl
;