ole32: Handle SetClipboardData failing in OLE clipboard functions.
[wine.git] / dlls / mshtml / oleobj.c
blob3dec3dc62dd599462ae9dea7e544da730da8e680
1 /*
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "shlguid.h"
31 #include "mshtmdid.h"
32 #include "idispids.h"
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 /**********************************************************
41 * IOleObject implementation
44 #define OLEOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleObject, iface)
46 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
48 HTMLDocument *This = OLEOBJ_THIS(iface);
49 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
52 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
54 HTMLDocument *This = OLEOBJ_THIS(iface);
55 return IHTMLDocument2_AddRef(HTMLDOC(This));
58 static ULONG WINAPI OleObject_Release(IOleObject *iface)
60 HTMLDocument *This = OLEOBJ_THIS(iface);
61 return IHTMLDocument2_Release(HTMLDOC(This));
64 static void update_hostinfo(HTMLDocumentObj *This, DOCHOSTUIINFO *hostinfo)
66 nsIScrollable *scrollable;
67 nsresult nsres;
69 if(!This->nscontainer)
70 return;
72 nsres = nsIWebBrowser_QueryInterface(This->nscontainer->webbrowser, &IID_nsIScrollable, (void**)&scrollable);
73 if(NS_SUCCEEDED(nsres)) {
74 nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_Y,
75 (hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO) ? Scrollbar_Never : Scrollbar_Always);
76 if(NS_FAILED(nsres))
77 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres);
79 nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_X,
80 hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO ? Scrollbar_Never : Scrollbar_Auto);
81 if(NS_FAILED(nsres))
82 ERR("Could not set default X scrollbar prefs: %08x\n", nsres);
84 nsIScrollable_Release(scrollable);
85 }else {
86 ERR("Could not get nsIScrollable: %08x\n", nsres);
90 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
92 HTMLDocument *This = OLEOBJ_THIS(iface);
93 IDocHostUIHandler *pDocHostUIHandler = NULL;
94 IOleCommandTarget *cmdtrg = NULL;
95 VARIANT silent;
96 HRESULT hres;
98 TRACE("(%p)->(%p)\n", This, pClientSite);
100 if(pClientSite == This->doc_obj->client)
101 return S_OK;
103 if(This->doc_obj->client) {
104 IOleClientSite_Release(This->doc_obj->client);
105 This->doc_obj->client = NULL;
106 This->doc_obj->usermode = UNKNOWN_USERMODE;
109 if(This->doc_obj->hostui) {
110 IDocHostUIHandler_Release(This->doc_obj->hostui);
111 This->doc_obj->hostui = NULL;
114 memset(&This->doc_obj->hostinfo, 0, sizeof(DOCHOSTUIINFO));
116 if(!pClientSite)
117 return S_OK;
119 hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler);
120 if(SUCCEEDED(hres)) {
121 DOCHOSTUIINFO hostinfo;
122 LPOLESTR key_path = NULL, override_key_path = NULL;
123 IDocHostUIHandler2 *pDocHostUIHandler2;
125 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
126 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
127 hres = IDocHostUIHandler_GetHostInfo(pDocHostUIHandler, &hostinfo);
128 if(SUCCEEDED(hres)) {
129 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
130 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
131 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
132 update_hostinfo(This->doc_obj, &hostinfo);
133 This->doc_obj->hostinfo = hostinfo;
136 if(!This->doc_obj->has_key_path) {
137 hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0);
138 if(hres == S_OK && key_path) {
139 if(key_path[0]) {
140 /* FIXME: use key_path */
141 TRACE("key_path = %s\n", debugstr_w(key_path));
143 CoTaskMemFree(key_path);
146 hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2,
147 (void**)&pDocHostUIHandler2);
148 if(SUCCEEDED(hres)) {
149 hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0);
150 if(hres == S_OK && override_key_path && override_key_path[0]) {
151 if(override_key_path[0]) {
152 /*FIXME: use override_key_path */
153 TRACE("override_key_path = %s\n", debugstr_w(override_key_path));
155 CoTaskMemFree(override_key_path);
157 IDocHostUIHandler2_Release(pDocHostUIHandler2);
160 This->doc_obj->has_key_path = TRUE;
164 /* Native calls here GetWindow. What is it for?
165 * We don't have anything to do with it here (yet). */
166 if(pClientSite) {
167 IOleWindow *pOleWindow = NULL;
168 HWND hwnd;
170 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&pOleWindow);
171 if(SUCCEEDED(hres)) {
172 IOleWindow_GetWindow(pOleWindow, &hwnd);
173 IOleWindow_Release(pOleWindow);
177 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleCommandTarget, (void**)&cmdtrg);
178 if(SUCCEEDED(hres)) {
179 VARIANT var;
180 OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0};
182 IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL);
184 V_VT(&var) = VT_I4;
185 V_I4(&var) = 0;
186 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
187 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
188 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
189 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
191 IOleCommandTarget_Release(cmdtrg);
194 IOleClientSite_AddRef(pClientSite);
195 This->doc_obj->client = pClientSite;
196 This->doc_obj->hostui = pDocHostUIHandler;
198 if(This->doc_obj->usermode == UNKNOWN_USERMODE)
199 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERMODE);
201 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
203 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
204 if(SUCCEEDED(hres)) {
205 if(V_VT(&silent) != VT_BOOL)
206 WARN("V_VT(silent) = %d\n", V_VT(&silent));
207 else if(V_BOOL(&silent))
208 FIXME("silent == true\n");
211 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERAGENT);
212 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_PALETTE);
214 return S_OK;
217 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
219 HTMLDocument *This = OLEOBJ_THIS(iface);
221 TRACE("(%p)->(%p)\n", This, ppClientSite);
223 if(!ppClientSite)
224 return E_INVALIDARG;
226 if(This->doc_obj->client)
227 IOleClientSite_AddRef(This->doc_obj->client);
228 *ppClientSite = This->doc_obj->client;
230 return S_OK;
233 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
235 HTMLDocument *This = OLEOBJ_THIS(iface);
236 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
237 return E_NOTIMPL;
240 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
242 HTMLDocument *This = OLEOBJ_THIS(iface);
244 TRACE("(%p)->(%08x)\n", This, dwSaveOption);
246 if(dwSaveOption == OLECLOSE_PROMPTSAVE)
247 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
249 if(This->doc_obj->in_place_active)
250 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
252 HTMLDocument_LockContainer(This->doc_obj, FALSE);
254 if(This->advise_holder)
255 IOleAdviseHolder_SendOnClose(This->advise_holder);
257 return S_OK;
260 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
262 HTMLDocument *This = OLEOBJ_THIS(iface);
263 FIXME("(%p %d %p)->()\n", This, dwWhichMoniker, pmk);
264 return E_NOTIMPL;
267 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
269 HTMLDocument *This = OLEOBJ_THIS(iface);
270 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
271 return E_NOTIMPL;
274 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
275 DWORD dwReserved)
277 HTMLDocument *This = OLEOBJ_THIS(iface);
278 FIXME("(%p)->(%p %x %d)\n", This, pDataObject, fCreation, dwReserved);
279 return E_NOTIMPL;
282 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
284 HTMLDocument *This = OLEOBJ_THIS(iface);
285 FIXME("(%p)->(%d %p)\n", This, dwReserved, ppDataObject);
286 return E_NOTIMPL;
289 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
290 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
292 HTMLDocument *This = OLEOBJ_THIS(iface);
293 IOleDocumentSite *pDocSite;
294 HRESULT hres;
296 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
298 if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE && iVerb != OLEIVERB_INPLACEACTIVATE) {
299 FIXME("iVerb = %d not supported\n", iVerb);
300 return E_NOTIMPL;
303 if(!pActiveSite)
304 pActiveSite = This->doc_obj->client;
306 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
307 if(SUCCEEDED(hres)) {
308 HTMLDocument_LockContainer(This->doc_obj, TRUE);
310 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
311 hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
312 IOleDocumentSite_Release(pDocSite);
313 }else {
314 hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
315 if(SUCCEEDED(hres)) {
316 if(lprcPosRect) {
317 RECT rect; /* We need to pass rect as not const pointer */
318 rect = *lprcPosRect;
319 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
321 IOleDocumentView_Show(DOCVIEW(This), TRUE);
325 return hres;
328 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
330 HTMLDocument *This = OLEOBJ_THIS(iface);
331 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
332 return E_NOTIMPL;
335 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
337 HTMLDocument *This = OLEOBJ_THIS(iface);
338 FIXME("(%p)\n", This);
339 return E_NOTIMPL;
342 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
344 HTMLDocument *This = OLEOBJ_THIS(iface);
345 FIXME("(%p)\n", This);
346 return E_NOTIMPL;
349 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
351 HTMLDocument *This = OLEOBJ_THIS(iface);
353 TRACE("(%p)->(%p)\n", This, pClsid);
355 if(!pClsid)
356 return E_INVALIDARG;
358 *pClsid = CLSID_HTMLDocument;
359 return S_OK;
362 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
364 HTMLDocument *This = OLEOBJ_THIS(iface);
365 FIXME("(%p)->(%d %p)\n", This, dwFormOfType, pszUserType);
366 return E_NOTIMPL;
369 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
371 HTMLDocument *This = OLEOBJ_THIS(iface);
372 FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
373 return E_NOTIMPL;
376 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
378 HTMLDocument *This = OLEOBJ_THIS(iface);
379 FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
380 return E_NOTIMPL;
383 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
385 HTMLDocument *This = OLEOBJ_THIS(iface);
386 TRACE("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
388 if(!pdwConnection)
389 return E_INVALIDARG;
391 if(!pAdvSink) {
392 *pdwConnection = 0;
393 return E_INVALIDARG;
396 if(!This->advise_holder) {
397 CreateOleAdviseHolder(&This->advise_holder);
398 if(!This->advise_holder)
399 return E_OUTOFMEMORY;
402 return IOleAdviseHolder_Advise(This->advise_holder, pAdvSink, pdwConnection);
405 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
407 HTMLDocument *This = OLEOBJ_THIS(iface);
408 TRACE("(%p)->(%d)\n", This, dwConnection);
410 if(!This->advise_holder)
411 return OLE_E_NOCONNECTION;
413 return IOleAdviseHolder_Unadvise(This->advise_holder, dwConnection);
416 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
418 HTMLDocument *This = OLEOBJ_THIS(iface);
420 if(!This->advise_holder) {
421 *ppenumAdvise = NULL;
422 return S_OK;
425 return IOleAdviseHolder_EnumAdvise(This->advise_holder, ppenumAdvise);
428 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
430 HTMLDocument *This = OLEOBJ_THIS(iface);
431 FIXME("(%p)->(%d %p)\n", This, dwAspect, pdwStatus);
432 return E_NOTIMPL;
435 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
437 HTMLDocument *This = OLEOBJ_THIS(iface);
438 FIXME("(%p)->(%p)\n", This, pLogpal);
439 return E_NOTIMPL;
442 #undef OLEPBJ_THIS
444 static const IOleObjectVtbl OleObjectVtbl = {
445 OleObject_QueryInterface,
446 OleObject_AddRef,
447 OleObject_Release,
448 OleObject_SetClientSite,
449 OleObject_GetClientSite,
450 OleObject_SetHostNames,
451 OleObject_Close,
452 OleObject_SetMoniker,
453 OleObject_GetMoniker,
454 OleObject_InitFromData,
455 OleObject_GetClipboardData,
456 OleObject_DoVerb,
457 OleObject_EnumVerbs,
458 OleObject_Update,
459 OleObject_IsUpToDate,
460 OleObject_GetUserClassID,
461 OleObject_GetUserType,
462 OleObject_SetExtent,
463 OleObject_GetExtent,
464 OleObject_Advise,
465 OleObject_Unadvise,
466 OleObject_EnumAdvise,
467 OleObject_GetMiscStatus,
468 OleObject_SetColorScheme
471 /**********************************************************
472 * IOleDocument implementation
475 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
477 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
479 HTMLDocument *This = OLEDOC_THIS(iface);
480 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
483 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
485 HTMLDocument *This = OLEDOC_THIS(iface);
486 return IHTMLDocument2_AddRef(HTMLDOC(This));
489 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
491 HTMLDocument *This = OLEDOC_THIS(iface);
492 return IHTMLDocument2_Release(HTMLDOC(This));
495 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
496 DWORD dwReserved, IOleDocumentView **ppView)
498 HTMLDocument *This = OLEDOC_THIS(iface);
499 HRESULT hres;
501 TRACE("(%p)->(%p %p %d %p)\n", This, pIPSite, pstm, dwReserved, ppView);
503 if(!ppView)
504 return E_INVALIDARG;
506 /* FIXME:
507 * Windows implementation creates new IOleDocumentView when function is called for the
508 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
509 * if the application uses returned interfaces, passed to ActivateMe or returned by
510 * QueryInterface, so there is no reason to create new interface. This needs more testing.
513 if(pIPSite) {
514 hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
515 if(FAILED(hres))
516 return hres;
519 if(pstm)
520 FIXME("pstm is not supported\n");
522 IOleDocumentView_AddRef(DOCVIEW(This));
523 *ppView = DOCVIEW(This);
524 return S_OK;
527 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
529 HTMLDocument *This = OLEDOC_THIS(iface);
530 FIXME("(%p)->(%p)\n", This, pdwStatus);
531 return E_NOTIMPL;
534 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
535 IOleDocumentView **ppView)
537 HTMLDocument *This = OLEDOC_THIS(iface);
538 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
539 return E_NOTIMPL;
542 #undef OLEDOC_THIS
544 static const IOleDocumentVtbl OleDocumentVtbl = {
545 OleDocument_QueryInterface,
546 OleDocument_AddRef,
547 OleDocument_Release,
548 OleDocument_CreateView,
549 OleDocument_GetDocMiscStatus,
550 OleDocument_EnumViews
553 /**********************************************************
554 * IOleControl implementation
557 #define CONTROL_THIS(iface) DEFINE_THIS(HTMLDocument, OleControl, iface)
559 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
561 HTMLDocument *This = CONTROL_THIS(iface);
562 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
565 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
567 HTMLDocument *This = CONTROL_THIS(iface);
568 return IHTMLDocument2_AddRef(HTMLDOC(This));
571 static ULONG WINAPI OleControl_Release(IOleControl *iface)
573 HTMLDocument *This = CONTROL_THIS(iface);
574 return IHTMLDocument_Release(HTMLDOC(This));
577 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
579 HTMLDocument *This = CONTROL_THIS(iface);
580 FIXME("(%p)->(%p)\n", This, pCI);
581 return E_NOTIMPL;
584 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *pMsg)
586 HTMLDocument *This = CONTROL_THIS(iface);
587 FIXME("(%p)->(%p)\n", This, pMsg);
588 return E_NOTIMPL;
591 HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
593 IDispatch *disp = NULL;
594 DISPPARAMS dispparams = {NULL, 0};
595 UINT err;
596 HRESULT hres;
598 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
599 if(FAILED(hres)) {
600 TRACE("Could not get IDispatch\n");
601 return hres;
604 VariantInit(res);
606 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
607 DISPATCH_PROPERTYGET, &dispparams, res, NULL, &err);
609 IDispatch_Release(disp);
611 return hres;
614 static HRESULT on_change_dlcontrol(HTMLDocument *This)
616 VARIANT res;
617 HRESULT hres;
619 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_DLCONTROL, &res);
620 if(SUCCEEDED(hres))
621 FIXME("unsupported dlcontrol %08x\n", V_I4(&res));
623 return S_OK;
626 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
628 HTMLDocument *This = CONTROL_THIS(iface);
629 IOleClientSite *client;
630 VARIANT res;
631 HRESULT hres;
633 client = This->doc_obj->client;
634 if(!client) {
635 TRACE("client = NULL\n");
636 return S_OK;
639 switch(dispID) {
640 case DISPID_AMBIENT_USERMODE:
641 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This);
642 hres = get_client_disp_property(client, DISPID_AMBIENT_USERMODE, &res);
643 if(FAILED(hres))
644 return S_OK;
646 if(V_VT(&res) == VT_BOOL) {
647 if(V_BOOL(&res)) {
648 This->doc_obj->usermode = BROWSEMODE;
649 }else {
650 FIXME("edit mode is not supported\n");
651 This->doc_obj->usermode = EDITMODE;
653 }else {
654 FIXME("V_VT(res)=%d\n", V_VT(&res));
656 return S_OK;
657 case DISPID_AMBIENT_DLCONTROL:
658 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This);
659 return on_change_dlcontrol(This);
660 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
661 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This);
662 on_change_dlcontrol(This);
663 hres = get_client_disp_property(client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &res);
664 if(FAILED(hres))
665 return S_OK;
667 if(V_VT(&res) == VT_BOOL) {
668 if(V_BOOL(&res)) {
669 FIXME("offline connection is not supported\n");
670 hres = E_FAIL;
672 }else {
673 FIXME("V_VT(res)=%d\n", V_VT(&res));
675 return S_OK;
676 case DISPID_AMBIENT_SILENT:
677 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This);
678 on_change_dlcontrol(This);
679 hres = get_client_disp_property(client, DISPID_AMBIENT_SILENT, &res);
680 if(FAILED(hres))
681 return S_OK;
683 if(V_VT(&res) == VT_BOOL) {
684 if(V_BOOL(&res)) {
685 FIXME("silent mode is not supported\n");
686 hres = E_FAIL;
688 }else {
689 FIXME("V_VT(res)=%d\n", V_VT(&res));
691 return S_OK;
692 case DISPID_AMBIENT_USERAGENT:
693 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This);
694 hres = get_client_disp_property(client, DISPID_AMBIENT_USERAGENT, &res);
695 if(FAILED(hres))
696 return S_OK;
698 FIXME("not supported AMBIENT_USERAGENT\n");
699 hres = E_FAIL;
700 return S_OK;
701 case DISPID_AMBIENT_PALETTE:
702 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This);
703 hres = get_client_disp_property(client, DISPID_AMBIENT_PALETTE, &res);
704 if(FAILED(hres))
705 return S_OK;
707 FIXME("not supported AMBIENT_PALETTE\n");
708 hres = E_FAIL;
709 return S_OK;
712 FIXME("(%p) unsupported dispID=%d\n", This, dispID);
713 return E_FAIL;
716 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
718 HTMLDocument *This = CONTROL_THIS(iface);
719 FIXME("(%p)->(%x)\n", This, bFreeze);
720 return E_NOTIMPL;
723 #undef CONTROL_THIS
725 static const IOleControlVtbl OleControlVtbl = {
726 OleControl_QueryInterface,
727 OleControl_AddRef,
728 OleControl_Release,
729 OleControl_GetControlInfo,
730 OleControl_OnMnemonic,
731 OleControl_OnAmbientPropertyChange,
732 OleControl_FreezeEvents
735 /**********************************************************
736 * IObjectWithSite implementation
739 #define OBJSITE_THIS(iface) DEFINE_THIS(HTMLDocument, ObjectWithSite, iface)
741 static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid, void **ppvObject)
743 HTMLDocument *This = OBJSITE_THIS(iface);
744 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
747 static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
749 HTMLDocument *This = OBJSITE_THIS(iface);
750 return IHTMLDocument2_AddRef(HTMLDOC(This));
753 static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
755 HTMLDocument *This = OBJSITE_THIS(iface);
756 return IHTMLDocument2_Release(HTMLDOC(This));
759 static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
761 HTMLDocument *This = OBJSITE_THIS(iface);
762 FIXME("(%p)->(%p)\n", This, pUnkSite);
763 return E_NOTIMPL;
766 static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite* iface, REFIID riid, PVOID *ppvSite)
768 HTMLDocument *This = OBJSITE_THIS(iface);
769 FIXME("(%p)->(%p)\n", This, ppvSite);
770 return E_NOTIMPL;
773 #undef OBJSITE_THIS
775 static const IObjectWithSiteVtbl ObjectWithSiteVtbl = {
776 ObjectWithSite_QueryInterface,
777 ObjectWithSite_AddRef,
778 ObjectWithSite_Release,
779 ObjectWithSite_SetSite,
780 ObjectWithSite_GetSite
783 void HTMLDocument_LockContainer(HTMLDocumentObj *This, BOOL fLock)
785 IOleContainer *container;
786 HRESULT hres;
788 if(!This->client || This->container_locked == fLock)
789 return;
791 hres = IOleClientSite_GetContainer(This->client, &container);
792 if(SUCCEEDED(hres)) {
793 IOleContainer_LockContainer(container, fLock);
794 This->container_locked = fLock;
795 IOleContainer_Release(container);
799 void HTMLDocument_OleObj_Init(HTMLDocument *This)
801 This->lpOleObjectVtbl = &OleObjectVtbl;
802 This->lpOleDocumentVtbl = &OleDocumentVtbl;
803 This->lpOleControlVtbl = &OleControlVtbl;
804 This->lpObjectWithSiteVtbl = &ObjectWithSiteVtbl;