ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

oleobj.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2005 Jacek Caban
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #include "config.h"
00020 
00021 #include <stdarg.h>
00022 #include <stdio.h>
00023 
00024 #define COBJMACROS
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "winuser.h"
00029 #include "ole2.h"
00030 #include "shlguid.h"
00031 #include "mshtmdid.h"
00032 #include "idispids.h"
00033 
00034 #include "wine/debug.h"
00035 
00036 #include "mshtml_private.h"
00037 #include "initguid.h"
00038 
00039 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
00040 
00041 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
00042 #define DOCHOST_DOCCANNAVIGATE  0
00043 
00044 /**********************************************************
00045  * IOleObject implementation
00046  */
00047 
00048 #define OLEOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleObject, iface)
00049 
00050 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
00051 {
00052     HTMLDocument *This = OLEOBJ_THIS(iface);
00053     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
00054 }
00055 
00056 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
00057 {
00058     HTMLDocument *This = OLEOBJ_THIS(iface);
00059     return IHTMLDocument2_AddRef(HTMLDOC(This));
00060 }
00061 
00062 static ULONG WINAPI OleObject_Release(IOleObject *iface)
00063 {
00064     HTMLDocument *This = OLEOBJ_THIS(iface);
00065     return IHTMLDocument2_Release(HTMLDOC(This));
00066 }
00067 
00068 static void update_hostinfo(HTMLDocumentObj *This, DOCHOSTUIINFO *hostinfo)
00069 {
00070     nsIScrollable *scrollable;
00071     nsresult nsres;
00072 
00073     if(!This->nscontainer)
00074         return;
00075 
00076     nsres = nsIWebBrowser_QueryInterface(This->nscontainer->webbrowser, &IID_nsIScrollable, (void**)&scrollable);
00077     if(NS_SUCCEEDED(nsres)) {
00078         nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_Y,
00079                 (hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO) ? Scrollbar_Never : Scrollbar_Always);
00080         if(NS_FAILED(nsres))
00081             ERR("Could not set default Y scrollbar prefs: %08x\n", nsres);
00082 
00083         nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_X,
00084                 hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO ? Scrollbar_Never : Scrollbar_Auto);
00085         if(NS_FAILED(nsres))
00086             ERR("Could not set default X scrollbar prefs: %08x\n", nsres);
00087 
00088         nsIScrollable_Release(scrollable);
00089     }else {
00090         ERR("Could not get nsIScrollable: %08x\n", nsres);
00091     }
00092 }
00093 
00094 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
00095 {
00096     HTMLDocument *This = OLEOBJ_THIS(iface);
00097     IDocHostUIHandler *pDocHostUIHandler = NULL;
00098     IOleCommandTarget *cmdtrg = NULL;
00099     IOleWindow *ole_window;
00100     BOOL hostui_setup;
00101     VARIANT silent;
00102     HWND hwnd;
00103     HRESULT hres;
00104 
00105     TRACE("(%p)->(%p)\n", This, pClientSite);
00106 
00107     if(pClientSite == This->doc_obj->client)
00108         return S_OK;
00109 
00110     if(This->doc_obj->client) {
00111         IOleClientSite_Release(This->doc_obj->client);
00112         This->doc_obj->client = NULL;
00113         This->doc_obj->usermode = UNKNOWN_USERMODE;
00114     }
00115 
00116     if(This->doc_obj->hostui) {
00117         IDocHostUIHandler_Release(This->doc_obj->hostui);
00118         This->doc_obj->hostui = NULL;
00119     }
00120 
00121     memset(&This->doc_obj->hostinfo, 0, sizeof(DOCHOSTUIINFO));
00122 
00123     if(!pClientSite)
00124         return S_OK;
00125 
00126     IOleClientSite_AddRef(pClientSite);
00127     This->doc_obj->client = pClientSite;
00128 
00129     hostui_setup = This->doc_obj->hostui_setup;
00130 
00131     hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler);
00132     if(SUCCEEDED(hres)) {
00133         DOCHOSTUIINFO hostinfo;
00134         LPOLESTR key_path = NULL, override_key_path = NULL;
00135         IDocHostUIHandler2 *pDocHostUIHandler2;
00136 
00137         This->doc_obj->hostui = pDocHostUIHandler;
00138 
00139         memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
00140         hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
00141         hres = IDocHostUIHandler_GetHostInfo(pDocHostUIHandler, &hostinfo);
00142         if(SUCCEEDED(hres)) {
00143             TRACE("hostinfo = {%u %08x %08x %s %s}\n",
00144                     hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
00145                     debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
00146             update_hostinfo(This->doc_obj, &hostinfo);
00147             This->doc_obj->hostinfo = hostinfo;
00148         }
00149 
00150         if(!hostui_setup) {
00151             hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0);
00152             if(hres == S_OK && key_path) {
00153                 if(key_path[0]) {
00154                     /* FIXME: use key_path */
00155                     TRACE("key_path = %s\n", debugstr_w(key_path));
00156                 }
00157                 CoTaskMemFree(key_path);
00158             }
00159 
00160             hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2,
00161                     (void**)&pDocHostUIHandler2);
00162             if(SUCCEEDED(hres)) {
00163                 hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0);
00164                 if(hres == S_OK && override_key_path && override_key_path[0]) {
00165                     if(override_key_path[0]) {
00166                         /*FIXME: use override_key_path */
00167                         TRACE("override_key_path = %s\n", debugstr_w(override_key_path));
00168                     }
00169                     CoTaskMemFree(override_key_path);
00170                 }
00171                 IDocHostUIHandler2_Release(pDocHostUIHandler2);
00172             }
00173 
00174             This->doc_obj->hostui_setup = TRUE;
00175         }
00176     }else {
00177         This->doc_obj->hostui = NULL;
00178     }
00179 
00180     /* Native calls here GetWindow. What is it for?
00181      * We don't have anything to do with it here (yet). */
00182     hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&ole_window);
00183     if(SUCCEEDED(hres)) {
00184         IOleWindow_GetWindow(ole_window, &hwnd);
00185         IOleWindow_Release(ole_window);
00186     }
00187 
00188     hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleCommandTarget, (void**)&cmdtrg);
00189     if(SUCCEEDED(hres)) {
00190         VARIANT var;
00191         OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0};
00192 
00193         if(!hostui_setup) {
00194             V_VT(&var) = VT_UNKNOWN;
00195             V_UNKNOWN(&var) = (IUnknown*)HTMLWINDOW2(This->window);
00196             IOleCommandTarget_Exec(cmdtrg, &CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0, &var, NULL);
00197         }
00198 
00199         IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL);
00200 
00201         V_VT(&var) = VT_I4;
00202         V_I4(&var) = 0;
00203         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
00204                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
00205         IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 
00206                 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
00207 
00208         IOleCommandTarget_Release(cmdtrg);
00209     }
00210 
00211     if(This->doc_obj->usermode == UNKNOWN_USERMODE)
00212         IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERMODE);
00213 
00214     IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_OFFLINEIFNOTCONNECTED); 
00215 
00216     hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
00217     if(SUCCEEDED(hres)) {
00218         if(V_VT(&silent) != VT_BOOL)
00219             WARN("V_VT(silent) = %d\n", V_VT(&silent));
00220         else if(V_BOOL(&silent))
00221             FIXME("silent == true\n");
00222     }
00223 
00224     IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERAGENT);
00225     IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_PALETTE);
00226 
00227     return S_OK;
00228 }
00229 
00230 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
00231 {
00232     HTMLDocument *This = OLEOBJ_THIS(iface);
00233 
00234     TRACE("(%p)->(%p)\n", This, ppClientSite);
00235 
00236     if(!ppClientSite)
00237         return E_INVALIDARG;
00238 
00239     if(This->doc_obj->client)
00240         IOleClientSite_AddRef(This->doc_obj->client);
00241     *ppClientSite = This->doc_obj->client;
00242 
00243     return S_OK;
00244 }
00245 
00246 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
00247 {
00248     HTMLDocument *This = OLEOBJ_THIS(iface);
00249     FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
00250     return E_NOTIMPL;
00251 }
00252 
00253 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
00254 {
00255     HTMLDocument *This = OLEOBJ_THIS(iface);
00256 
00257     TRACE("(%p)->(%08x)\n", This, dwSaveOption);
00258 
00259     if(dwSaveOption == OLECLOSE_PROMPTSAVE)
00260         FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
00261 
00262     if(This->doc_obj->in_place_active)
00263         IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
00264 
00265     HTMLDocument_LockContainer(This->doc_obj, FALSE);
00266 
00267     if(This->advise_holder)
00268         IOleAdviseHolder_SendOnClose(This->advise_holder);
00269     
00270     return S_OK;
00271 }
00272 
00273 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
00274 {
00275     HTMLDocument *This = OLEOBJ_THIS(iface);
00276     FIXME("(%p %d %p)->()\n", This, dwWhichMoniker, pmk);
00277     return E_NOTIMPL;
00278 }
00279 
00280 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
00281 {
00282     HTMLDocument *This = OLEOBJ_THIS(iface);
00283     FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
00284     return E_NOTIMPL;
00285 }
00286 
00287 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
00288                                         DWORD dwReserved)
00289 {
00290     HTMLDocument *This = OLEOBJ_THIS(iface);
00291     FIXME("(%p)->(%p %x %d)\n", This, pDataObject, fCreation, dwReserved);
00292     return E_NOTIMPL;
00293 }
00294 
00295 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
00296 {
00297     HTMLDocument *This = OLEOBJ_THIS(iface);
00298     FIXME("(%p)->(%d %p)\n", This, dwReserved, ppDataObject);
00299     return E_NOTIMPL;
00300 }
00301 
00302 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
00303                                         LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
00304 {
00305     HTMLDocument *This = OLEOBJ_THIS(iface);
00306     IOleDocumentSite *pDocSite;
00307     HRESULT hres;
00308 
00309     TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
00310 
00311     if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE && iVerb != OLEIVERB_INPLACEACTIVATE) { 
00312         FIXME("iVerb = %d not supported\n", iVerb);
00313         return E_NOTIMPL;
00314     }
00315 
00316     if(!pActiveSite)
00317         pActiveSite = This->doc_obj->client;
00318 
00319     hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
00320     if(SUCCEEDED(hres)) {
00321         HTMLDocument_LockContainer(This->doc_obj, TRUE);
00322 
00323         /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
00324         hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
00325         IOleDocumentSite_Release(pDocSite);
00326     }else {
00327         hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
00328         if(SUCCEEDED(hres)) {
00329             if(lprcPosRect) {
00330                 RECT rect; /* We need to pass rect as not const pointer */
00331                 rect = *lprcPosRect;
00332                 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
00333             }
00334             IOleDocumentView_Show(DOCVIEW(This), TRUE);
00335         }
00336     }
00337 
00338     return hres;
00339 }
00340 
00341 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
00342 {
00343     HTMLDocument *This = OLEOBJ_THIS(iface);
00344     FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
00345     return E_NOTIMPL;
00346 }
00347 
00348 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
00349 {
00350     HTMLDocument *This = OLEOBJ_THIS(iface);
00351     FIXME("(%p)\n", This);
00352     return E_NOTIMPL;
00353 }
00354 
00355 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
00356 {
00357     HTMLDocument *This = OLEOBJ_THIS(iface);
00358     FIXME("(%p)\n", This);
00359     return E_NOTIMPL;
00360 }
00361 
00362 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
00363 {
00364     HTMLDocument *This = OLEOBJ_THIS(iface);
00365 
00366     TRACE("(%p)->(%p)\n", This, pClsid);
00367 
00368     if(!pClsid)
00369         return E_INVALIDARG;
00370 
00371     *pClsid = CLSID_HTMLDocument;
00372     return S_OK;
00373 }
00374 
00375 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
00376 {
00377     HTMLDocument *This = OLEOBJ_THIS(iface);
00378     FIXME("(%p)->(%d %p)\n", This, dwFormOfType, pszUserType);
00379     return E_NOTIMPL;
00380 }
00381 
00382 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
00383 {
00384     HTMLDocument *This = OLEOBJ_THIS(iface);
00385     FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
00386     return E_NOTIMPL;
00387 }
00388 
00389 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
00390 {
00391     HTMLDocument *This = OLEOBJ_THIS(iface);
00392     FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
00393     return E_NOTIMPL;
00394 }
00395 
00396 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
00397 {
00398     HTMLDocument *This = OLEOBJ_THIS(iface);
00399     TRACE("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
00400 
00401     if(!pdwConnection)
00402         return E_INVALIDARG;
00403 
00404     if(!pAdvSink) {
00405         *pdwConnection = 0;
00406         return E_INVALIDARG;
00407     }
00408 
00409     if(!This->advise_holder) {
00410         CreateOleAdviseHolder(&This->advise_holder);
00411         if(!This->advise_holder)
00412             return E_OUTOFMEMORY;
00413     }
00414 
00415     return IOleAdviseHolder_Advise(This->advise_holder, pAdvSink, pdwConnection);
00416 }
00417 
00418 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
00419 {
00420     HTMLDocument *This = OLEOBJ_THIS(iface);
00421     TRACE("(%p)->(%d)\n", This, dwConnection);
00422 
00423     if(!This->advise_holder)
00424         return OLE_E_NOCONNECTION;
00425 
00426     return IOleAdviseHolder_Unadvise(This->advise_holder, dwConnection);
00427 }
00428 
00429 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
00430 {
00431     HTMLDocument *This = OLEOBJ_THIS(iface);
00432 
00433     if(!This->advise_holder) {
00434         *ppenumAdvise = NULL;
00435         return S_OK;
00436     }
00437 
00438     return IOleAdviseHolder_EnumAdvise(This->advise_holder, ppenumAdvise);
00439 }
00440 
00441 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
00442 {
00443     HTMLDocument *This = OLEOBJ_THIS(iface);
00444     FIXME("(%p)->(%d %p)\n", This, dwAspect, pdwStatus);
00445     return E_NOTIMPL;
00446 }
00447 
00448 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
00449 {
00450     HTMLDocument *This = OLEOBJ_THIS(iface);
00451     FIXME("(%p)->(%p)\n", This, pLogpal);
00452     return E_NOTIMPL;
00453 }
00454 
00455 #undef OLEPBJ_THIS
00456 
00457 static const IOleObjectVtbl OleObjectVtbl = {
00458     OleObject_QueryInterface,
00459     OleObject_AddRef,
00460     OleObject_Release,
00461     OleObject_SetClientSite,
00462     OleObject_GetClientSite,
00463     OleObject_SetHostNames,
00464     OleObject_Close,
00465     OleObject_SetMoniker,
00466     OleObject_GetMoniker,
00467     OleObject_InitFromData,
00468     OleObject_GetClipboardData,
00469     OleObject_DoVerb,
00470     OleObject_EnumVerbs,
00471     OleObject_Update,
00472     OleObject_IsUpToDate,
00473     OleObject_GetUserClassID,
00474     OleObject_GetUserType,
00475     OleObject_SetExtent,
00476     OleObject_GetExtent,
00477     OleObject_Advise,
00478     OleObject_Unadvise,
00479     OleObject_EnumAdvise,
00480     OleObject_GetMiscStatus,
00481     OleObject_SetColorScheme
00482 };
00483 
00484 /**********************************************************
00485  * IOleDocument implementation
00486  */
00487 
00488 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
00489 
00490 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
00491 {
00492     HTMLDocument *This = OLEDOC_THIS(iface);
00493     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
00494 }
00495 
00496 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
00497 {
00498     HTMLDocument *This = OLEDOC_THIS(iface);
00499     return IHTMLDocument2_AddRef(HTMLDOC(This));
00500 }
00501 
00502 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
00503 {
00504     HTMLDocument *This = OLEDOC_THIS(iface);
00505     return IHTMLDocument2_Release(HTMLDOC(This));
00506 }
00507 
00508 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
00509                                    DWORD dwReserved, IOleDocumentView **ppView)
00510 {
00511     HTMLDocument *This = OLEDOC_THIS(iface);
00512     HRESULT hres;
00513 
00514     TRACE("(%p)->(%p %p %d %p)\n", This, pIPSite, pstm, dwReserved, ppView);
00515 
00516     if(!ppView)
00517         return E_INVALIDARG;
00518 
00519     /* FIXME:
00520      * Windows implementation creates new IOleDocumentView when function is called for the
00521      * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
00522      * if the application uses returned interfaces, passed to ActivateMe or returned by
00523      * QueryInterface, so there is no reason to create new interface. This needs more testing.
00524      */
00525 
00526     if(pIPSite) {
00527         hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
00528         if(FAILED(hres))
00529             return hres;
00530     }
00531 
00532     if(pstm)
00533         FIXME("pstm is not supported\n");
00534 
00535     IOleDocumentView_AddRef(DOCVIEW(This));
00536     *ppView = DOCVIEW(This);
00537     return S_OK;
00538 }
00539 
00540 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
00541 {
00542     HTMLDocument *This = OLEDOC_THIS(iface);
00543     FIXME("(%p)->(%p)\n", This, pdwStatus);
00544     return E_NOTIMPL;
00545 }
00546 
00547 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
00548                                    IOleDocumentView **ppView)
00549 {
00550     HTMLDocument *This = OLEDOC_THIS(iface);
00551     FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
00552     return E_NOTIMPL;
00553 }
00554 
00555 #undef OLEDOC_THIS
00556 
00557 static const IOleDocumentVtbl OleDocumentVtbl = {
00558     OleDocument_QueryInterface,
00559     OleDocument_AddRef,
00560     OleDocument_Release,
00561     OleDocument_CreateView,
00562     OleDocument_GetDocMiscStatus,
00563     OleDocument_EnumViews
00564 };
00565 
00566 /**********************************************************
00567  * IOleControl implementation
00568  */
00569 
00570 #define CONTROL_THIS(iface) DEFINE_THIS(HTMLDocument, OleControl, iface)
00571 
00572 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
00573 {
00574     HTMLDocument *This = CONTROL_THIS(iface);
00575     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
00576 }
00577 
00578 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
00579 {
00580     HTMLDocument *This = CONTROL_THIS(iface);
00581     return IHTMLDocument2_AddRef(HTMLDOC(This));
00582 }
00583 
00584 static ULONG WINAPI OleControl_Release(IOleControl *iface)
00585 {
00586     HTMLDocument *This = CONTROL_THIS(iface);
00587     return IHTMLDocument_Release(HTMLDOC(This));
00588 }
00589 
00590 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
00591 {
00592     HTMLDocument *This = CONTROL_THIS(iface);
00593     FIXME("(%p)->(%p)\n", This, pCI);
00594     return E_NOTIMPL;
00595 }
00596 
00597 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *pMsg)
00598 {
00599     HTMLDocument *This = CONTROL_THIS(iface);
00600     FIXME("(%p)->(%p)\n", This, pMsg);
00601     return E_NOTIMPL;
00602 }
00603 
00604 HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
00605 {
00606     IDispatch *disp = NULL;
00607     DISPPARAMS dispparams = {NULL, 0};
00608     UINT err;
00609     HRESULT hres;
00610 
00611     hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
00612     if(FAILED(hres)) {
00613         TRACE("Could not get IDispatch\n");
00614         return hres;
00615     }
00616 
00617     VariantInit(res);
00618 
00619     hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
00620             DISPATCH_PROPERTYGET, &dispparams, res, NULL, &err);
00621 
00622     IDispatch_Release(disp);
00623 
00624     return hres;
00625 }
00626 
00627 static HRESULT on_change_dlcontrol(HTMLDocument *This)
00628 {
00629     VARIANT res;
00630     HRESULT hres;
00631     
00632     hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_DLCONTROL, &res);
00633     if(SUCCEEDED(hres))
00634         FIXME("unsupported dlcontrol %08x\n", V_I4(&res));
00635 
00636     return S_OK;
00637 }
00638 
00639 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
00640 {
00641     HTMLDocument *This = CONTROL_THIS(iface);
00642     IOleClientSite *client;
00643     VARIANT res;
00644     HRESULT hres;
00645 
00646     client = This->doc_obj->client;
00647     if(!client) {
00648         TRACE("client = NULL\n");
00649         return S_OK;
00650     }
00651 
00652     switch(dispID) {
00653     case DISPID_AMBIENT_USERMODE:
00654         TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This);
00655         hres = get_client_disp_property(client, DISPID_AMBIENT_USERMODE, &res);
00656         if(FAILED(hres))
00657             return S_OK;
00658 
00659         if(V_VT(&res) == VT_BOOL) {
00660             if(V_BOOL(&res)) {
00661                 This->doc_obj->usermode = BROWSEMODE;
00662             }else {
00663                 FIXME("edit mode is not supported\n");
00664                 This->doc_obj->usermode = EDITMODE;
00665             }
00666         }else {
00667             FIXME("V_VT(res)=%d\n", V_VT(&res));
00668         }
00669         return S_OK;
00670     case DISPID_AMBIENT_DLCONTROL:
00671         TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This);
00672         return on_change_dlcontrol(This);
00673     case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
00674         TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This);
00675         on_change_dlcontrol(This);
00676         hres = get_client_disp_property(client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &res);
00677         if(FAILED(hres))
00678             return S_OK;
00679 
00680         if(V_VT(&res) == VT_BOOL) {
00681             if(V_BOOL(&res)) {
00682                 FIXME("offline connection is not supported\n");
00683                 hres = E_FAIL;
00684             }
00685         }else {
00686             FIXME("V_VT(res)=%d\n", V_VT(&res));
00687         }
00688         return S_OK;
00689     case DISPID_AMBIENT_SILENT:
00690         TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This);
00691         on_change_dlcontrol(This);
00692         hres = get_client_disp_property(client, DISPID_AMBIENT_SILENT, &res);
00693         if(FAILED(hres))
00694             return S_OK;
00695 
00696         if(V_VT(&res) == VT_BOOL) {
00697             if(V_BOOL(&res)) {
00698                 FIXME("silent mode is not supported\n");
00699                 hres = E_FAIL;
00700             }
00701         }else {
00702             FIXME("V_VT(res)=%d\n", V_VT(&res));
00703         }
00704         return S_OK;
00705     case DISPID_AMBIENT_USERAGENT:
00706         TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This);
00707         hres = get_client_disp_property(client, DISPID_AMBIENT_USERAGENT, &res);
00708         if(FAILED(hres))
00709             return S_OK;
00710 
00711         FIXME("not supported AMBIENT_USERAGENT\n");
00712         hres = E_FAIL;
00713         return S_OK;
00714     case DISPID_AMBIENT_PALETTE:
00715         TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This);
00716         hres = get_client_disp_property(client, DISPID_AMBIENT_PALETTE, &res);
00717         if(FAILED(hres))
00718             return S_OK;
00719 
00720         FIXME("not supported AMBIENT_PALETTE\n");
00721         hres = E_FAIL;
00722         return S_OK;
00723     }
00724 
00725     FIXME("(%p) unsupported dispID=%d\n", This, dispID);
00726     return E_FAIL;
00727 }
00728 
00729 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
00730 {
00731     HTMLDocument *This = CONTROL_THIS(iface);
00732     FIXME("(%p)->(%x)\n", This, bFreeze);
00733     return E_NOTIMPL;
00734 }
00735 
00736 #undef CONTROL_THIS
00737 
00738 static const IOleControlVtbl OleControlVtbl = {
00739     OleControl_QueryInterface,
00740     OleControl_AddRef,
00741     OleControl_Release,
00742     OleControl_GetControlInfo,
00743     OleControl_OnMnemonic,
00744     OleControl_OnAmbientPropertyChange,
00745     OleControl_FreezeEvents
00746 };
00747 
00748 /**********************************************************
00749  * IObjectWithSite implementation
00750  */
00751 
00752 #define OBJSITE_THIS(iface) DEFINE_THIS(HTMLDocument, ObjectWithSite, iface)
00753 
00754 static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid, void **ppvObject)
00755 {
00756     HTMLDocument *This = OBJSITE_THIS(iface);
00757     return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
00758 }
00759 
00760 static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
00761 {
00762     HTMLDocument *This = OBJSITE_THIS(iface);
00763     return IHTMLDocument2_AddRef(HTMLDOC(This));
00764 }
00765 
00766 static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
00767 {
00768     HTMLDocument *This = OBJSITE_THIS(iface);
00769     return IHTMLDocument2_Release(HTMLDOC(This));
00770 }
00771 
00772 static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
00773 {
00774     HTMLDocument *This = OBJSITE_THIS(iface);
00775     FIXME("(%p)->(%p)\n", This, pUnkSite);
00776     return E_NOTIMPL;
00777 }
00778 
00779 static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite* iface, REFIID riid, PVOID *ppvSite)
00780 {
00781     HTMLDocument *This = OBJSITE_THIS(iface);
00782     FIXME("(%p)->(%p)\n", This, ppvSite);
00783     return E_NOTIMPL;
00784 }
00785 
00786 #undef OBJSITE_THIS
00787 
00788 static const IObjectWithSiteVtbl ObjectWithSiteVtbl = {
00789     ObjectWithSite_QueryInterface,
00790     ObjectWithSite_AddRef,
00791     ObjectWithSite_Release,
00792     ObjectWithSite_SetSite,
00793     ObjectWithSite_GetSite
00794 };
00795 
00796 void HTMLDocument_LockContainer(HTMLDocumentObj *This, BOOL fLock)
00797 {
00798     IOleContainer *container;
00799     HRESULT hres;
00800 
00801     if(!This->client || This->container_locked == fLock)
00802         return;
00803 
00804     hres = IOleClientSite_GetContainer(This->client, &container);
00805     if(SUCCEEDED(hres)) {
00806         IOleContainer_LockContainer(container, fLock);
00807         This->container_locked = fLock;
00808         IOleContainer_Release(container);
00809     }
00810 }
00811 
00812 void HTMLDocument_OleObj_Init(HTMLDocument *This)
00813 {
00814     This->lpOleObjectVtbl = &OleObjectVtbl;
00815     This->lpOleDocumentVtbl = &OleDocumentVtbl;
00816     This->lpOleControlVtbl = &OleControlVtbl;
00817     This->lpObjectWithSiteVtbl = &ObjectWithSiteVtbl;
00818 }

Generated on Sun May 27 2012 04:25:06 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.