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

dochost.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2005-2006 Jacek Caban for CodeWeavers
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 "wine/debug.h"
00020 #include "shdocvw.h"
00021 #include "hlink.h"
00022 #include "exdispid.h"
00023 #include "mshtml.h"
00024 #include "initguid.h"
00025 
00026 WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
00027 
00028 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
00029 
00030 #define DOCHOST_DOCCANNAVIGATE  0
00031 
00032 static ATOM doc_view_atom = 0;
00033 
00034 void push_dochost_task(DocHost *This, task_header_t *task, task_proc_t proc, BOOL send)
00035 {
00036     task->proc = proc;
00037 
00038     /* FIXME: Don't use lParam */
00039     if(send)
00040         SendMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task);
00041     else
00042         PostMessageW(This->frame_hwnd, WM_DOCHOSTTASK, 0, (LPARAM)task);
00043 }
00044 
00045 LRESULT process_dochost_task(DocHost *This, LPARAM lparam)
00046 {
00047     task_header_t *task = (task_header_t*)lparam;
00048 
00049     task->proc(This, task);
00050 
00051     heap_free(task);
00052     return 0;
00053 }
00054 
00055 static void notif_complete(DocHost *This, DISPID dispid)
00056 {
00057     DISPPARAMS dispparams;
00058     VARIANTARG params[2];
00059     VARIANT url;
00060 
00061     dispparams.cArgs = 2;
00062     dispparams.cNamedArgs = 0;
00063     dispparams.rgdispidNamedArgs = NULL;
00064     dispparams.rgvarg = params;
00065 
00066     V_VT(params) = (VT_BYREF|VT_VARIANT);
00067     V_BYREF(params) = &url;
00068 
00069     V_VT(params+1) = VT_DISPATCH;
00070     V_DISPATCH(params+1) = This->disp;
00071 
00072     V_VT(&url) = VT_BSTR;
00073     V_BSTR(&url) = SysAllocString(This->url);
00074 
00075     TRACE("%d >>>\n", dispid);
00076     call_sink(This->cps.wbe2, dispid, &dispparams);
00077     TRACE("%d <<<\n", dispid);
00078 
00079     SysFreeString(V_BSTR(&url));
00080     This->busy = VARIANT_FALSE;
00081 }
00082 
00083 static void object_available(DocHost *This)
00084 {
00085     IHlinkTarget *hlink;
00086     HRESULT hres;
00087 
00088     TRACE("(%p)\n", This);
00089 
00090     if(!This->document) {
00091         WARN("document == NULL\n");
00092         return;
00093     }
00094 
00095     hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
00096     if(FAILED(hres)) {
00097         FIXME("Could not get IHlinkTarget interface\n");
00098         return;
00099     }
00100 
00101     hres = IHlinkTarget_Navigate(hlink, 0, NULL);
00102     IHlinkTarget_Release(hlink);
00103     if(FAILED(hres))
00104         FIXME("Navigate failed\n");
00105 }
00106 
00107 static HRESULT get_doc_ready_state(DocHost *This, READYSTATE *ret)
00108 {
00109     DISPPARAMS dp = {NULL,NULL,0,0};
00110     IDispatch *disp;
00111     EXCEPINFO ei;
00112     VARIANT var;
00113     HRESULT hres;
00114 
00115     hres = IUnknown_QueryInterface(This->document, &IID_IDispatch, (void**)&disp);
00116     if(FAILED(hres))
00117         return hres;
00118 
00119     hres = IDispatch_Invoke(disp, DISPID_READYSTATE, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
00120             &dp, &var, &ei, NULL);
00121     IDispatch_Release(disp);
00122     if(FAILED(hres)) {
00123         WARN("Invoke(DISPID_READYSTATE failed: %08x\n", hres);
00124         return hres;
00125     }
00126 
00127     if(V_VT(&var) != VT_I4) {
00128         WARN("V_VT(var) = %d\n", V_VT(&var));
00129         VariantClear(&var);
00130         return E_FAIL;
00131     }
00132 
00133     *ret = V_I4(&var);
00134     return S_OK;
00135 }
00136 
00137 static void advise_prop_notif(DocHost *This, BOOL set)
00138 {
00139     IConnectionPointContainer *cp_container;
00140     IConnectionPoint *cp;
00141     HRESULT hres;
00142 
00143     hres = IUnknown_QueryInterface(This->document, &IID_IConnectionPointContainer, (void**)&cp_container);
00144     if(FAILED(hres))
00145         return;
00146 
00147     hres = IConnectionPointContainer_FindConnectionPoint(cp_container, &IID_IPropertyNotifySink, &cp);
00148     IConnectionPointContainer_Release(cp_container);
00149     if(FAILED(hres))
00150         return;
00151 
00152     if(set)
00153         hres = IConnectionPoint_Advise(cp, (IUnknown*)PROPNOTIF(This), &This->prop_notif_cookie);
00154     else
00155         hres = IConnectionPoint_Unadvise(cp, This->prop_notif_cookie);
00156     IConnectionPoint_Release(cp);
00157 
00158     if(SUCCEEDED(hres))
00159         This->is_prop_notif = set;
00160 }
00161 
00162 void set_doc_state(DocHost *This, READYSTATE doc_state)
00163 {
00164     This->doc_state = doc_state;
00165     if(doc_state > This->ready_state)
00166         This->ready_state = doc_state;
00167 }
00168 
00169 static void update_ready_state(DocHost *This, READYSTATE ready_state)
00170 {
00171     if(ready_state > READYSTATE_LOADING && This->doc_state <= READYSTATE_LOADING)
00172         notif_complete(This, DISPID_NAVIGATECOMPLETE2);
00173 
00174     if(ready_state == READYSTATE_COMPLETE && This->doc_state < READYSTATE_COMPLETE) {
00175         set_doc_state(This, READYSTATE_COMPLETE);
00176         notif_complete(This, DISPID_DOCUMENTCOMPLETE);
00177     }else {
00178         set_doc_state(This, ready_state);
00179     }
00180 }
00181 
00182 typedef struct {
00183     task_header_t header;
00184     IUnknown *doc;
00185     READYSTATE ready_state;
00186 } ready_state_task_t;
00187 
00188 static void ready_state_proc(DocHost *This, task_header_t *_task)
00189 {
00190     ready_state_task_t *task = (ready_state_task_t*)_task;
00191 
00192     if(task->doc == This->document)
00193         update_ready_state(This, task->ready_state);
00194 
00195     IUnknown_Release(task->doc);
00196 }
00197 
00198 static void push_ready_state_task(DocHost *This, READYSTATE ready_state)
00199 {
00200     ready_state_task_t *task = heap_alloc(sizeof(ready_state_task_t));
00201 
00202     IUnknown_AddRef(This->document);
00203     task->doc = This->document;
00204     task->ready_state = ready_state;
00205 
00206     push_dochost_task(This, &task->header, ready_state_proc, FALSE);
00207 }
00208 
00209 static void object_available_proc(DocHost *This, task_header_t *task)
00210 {
00211     object_available(This);
00212 }
00213 
00214 HRESULT dochost_object_available(DocHost *This, IUnknown *doc)
00215 {
00216     READYSTATE ready_state;
00217     task_header_t *task;
00218     IOleObject *oleobj;
00219     HRESULT hres;
00220 
00221     IUnknown_AddRef(doc);
00222     This->document = doc;
00223 
00224     hres = IUnknown_QueryInterface(doc, &IID_IOleObject, (void**)&oleobj);
00225     if(SUCCEEDED(hres)) {
00226         CLSID clsid;
00227 
00228         hres = IOleObject_GetUserClassID(oleobj, &clsid);
00229         if(SUCCEEDED(hres))
00230             TRACE("Got clsid %s\n",
00231                   IsEqualGUID(&clsid, &CLSID_HTMLDocument) ? "CLSID_HTMLDocument" : debugstr_guid(&clsid));
00232 
00233         hres = IOleObject_SetClientSite(oleobj, CLIENTSITE(This));
00234         if(FAILED(hres))
00235             FIXME("SetClientSite failed: %08x\n", hres);
00236 
00237         IOleObject_Release(oleobj);
00238     }else {
00239         FIXME("Could not get IOleObject iface: %08x\n", hres);
00240     }
00241 
00242     /* FIXME: Call SetAdvise */
00243 
00244     task = heap_alloc(sizeof(*task));
00245     push_dochost_task(This, task, object_available_proc, FALSE);
00246 
00247     hres = get_doc_ready_state(This, &ready_state);
00248     if(SUCCEEDED(hres)) {
00249         if(ready_state == READYSTATE_COMPLETE)
00250             push_ready_state_task(This, READYSTATE_COMPLETE);
00251         if(ready_state != READYSTATE_COMPLETE || This->doc_navigate)
00252             advise_prop_notif(This, TRUE);
00253     }
00254 
00255     return S_OK;
00256 }
00257 
00258 static LRESULT resize_document(DocHost *This, LONG width, LONG height)
00259 {
00260     RECT rect = {0, 0, width, height};
00261 
00262     TRACE("(%p)->(%d %d)\n", This, width, height);
00263 
00264     if(This->view)
00265         IOleDocumentView_SetRect(This->view, &rect);
00266 
00267     return 0;
00268 }
00269 
00270 static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
00271 {
00272     DocHost *This;
00273 
00274     static const WCHAR wszTHIS[] = {'T','H','I','S',0};
00275 
00276     if(msg == WM_CREATE) {
00277         This = *(DocHost**)lParam;
00278         SetPropW(hwnd, wszTHIS, This);
00279     }else {
00280         This = GetPropW(hwnd, wszTHIS);
00281     }
00282 
00283     switch(msg) {
00284     case WM_SIZE:
00285         return resize_document(This, LOWORD(lParam), HIWORD(lParam));
00286     }
00287 
00288     return DefWindowProcW(hwnd, msg, wParam, lParam);
00289 }
00290 
00291 void create_doc_view_hwnd(DocHost *This)
00292 {
00293     RECT rect;
00294 
00295     static const WCHAR wszShell_DocObject_View[] =
00296         {'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
00297 
00298     if(!doc_view_atom) {
00299         static WNDCLASSEXW wndclass = {
00300             sizeof(wndclass),
00301             CS_PARENTDC,
00302             doc_view_proc,
00303             0, 0 /* native uses 4*/, NULL, NULL, NULL,
00304             (HBRUSH)(COLOR_WINDOW + 1), NULL,
00305             wszShell_DocObject_View,
00306             NULL
00307         };
00308 
00309         wndclass.hInstance = shdocvw_hinstance;
00310 
00311         doc_view_atom = RegisterClassExW(&wndclass);
00312     }
00313 
00314     This->container_vtbl->GetDocObjRect(This, &rect);
00315     This->hwnd = CreateWindowExW(0, wszShell_DocObject_View,
00316          wszShell_DocObject_View,
00317          WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP,
00318          rect.left, rect.top, rect.right, rect.bottom, This->frame_hwnd,
00319          NULL, shdocvw_hinstance, This);
00320 }
00321 
00322 void deactivate_document(DocHost *This)
00323 {
00324     IOleInPlaceObjectWindowless *winobj;
00325     IOleObject *oleobj = NULL;
00326     IHlinkTarget *hlink = NULL;
00327     HRESULT hres;
00328 
00329     if(This->doc_navigate) {
00330         IUnknown_Release(This->doc_navigate);
00331         This->doc_navigate = NULL;
00332     }
00333 
00334     if(This->is_prop_notif)
00335         advise_prop_notif(This, FALSE);
00336 
00337     if(This->view)
00338         IOleDocumentView_UIActivate(This->view, FALSE);
00339 
00340     hres = IUnknown_QueryInterface(This->document, &IID_IOleInPlaceObjectWindowless,
00341                                    (void**)&winobj);
00342     if(SUCCEEDED(hres)) {
00343         IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
00344         IOleInPlaceObjectWindowless_Release(winobj);
00345     }
00346 
00347     if(This->view) {
00348         IOleDocumentView_Show(This->view, FALSE);
00349         IOleDocumentView_CloseView(This->view, 0);
00350         IOleDocumentView_SetInPlaceSite(This->view, NULL);
00351         IOleDocumentView_Release(This->view);
00352         This->view = NULL;
00353     }
00354 
00355     hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
00356     if(SUCCEEDED(hres))
00357         IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
00358 
00359     hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
00360     if(SUCCEEDED(hres)) {
00361         IHlinkTarget_SetBrowseContext(hlink, NULL);
00362         IHlinkTarget_Release(hlink);
00363     }
00364 
00365     if(oleobj) {
00366         IOleClientSite *client_site = NULL;
00367 
00368         IOleObject_GetClientSite(oleobj, &client_site);
00369         if(client_site) {
00370             if(client_site == CLIENTSITE(This))
00371                 IOleObject_SetClientSite(oleobj, NULL);
00372             IOleClientSite_Release(client_site);
00373         }
00374 
00375         IOleObject_Release(oleobj);
00376     }
00377 
00378     IUnknown_Release(This->document);
00379     This->document = NULL;
00380 }
00381 
00382 void release_dochost_client(DocHost *This)
00383 {
00384     if(This->hwnd) {
00385         DestroyWindow(This->hwnd);
00386         This->hwnd = NULL;
00387     }
00388 
00389     if(This->hostui) {
00390         IDocHostUIHandler_Release(This->hostui);
00391         This->hostui = NULL;
00392     }
00393 
00394     if(This->client_disp) {
00395         IDispatch_Release(This->client_disp);
00396         This->client_disp = NULL;
00397     }
00398 
00399     if(This->frame) {
00400         IOleInPlaceFrame_Release(This->frame);
00401         This->frame = NULL;
00402     }
00403 }
00404 
00405 #define OLECMD_THIS(iface) DEFINE_THIS(DocHost, OleCommandTarget, iface)
00406 
00407 static HRESULT WINAPI ClOleCommandTarget_QueryInterface(IOleCommandTarget *iface,
00408         REFIID riid, void **ppv)
00409 {
00410     DocHost *This = OLECMD_THIS(iface);
00411     return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
00412 }
00413 
00414 static ULONG WINAPI ClOleCommandTarget_AddRef(IOleCommandTarget *iface)
00415 {
00416     DocHost *This = OLECMD_THIS(iface);
00417     return IOleClientSite_AddRef(CLIENTSITE(This));
00418 }
00419 
00420 static ULONG WINAPI ClOleCommandTarget_Release(IOleCommandTarget *iface)
00421 {
00422     DocHost *This = OLECMD_THIS(iface);
00423     return IOleClientSite_Release(CLIENTSITE(This));
00424 }
00425 
00426 static HRESULT WINAPI ClOleCommandTarget_QueryStatus(IOleCommandTarget *iface,
00427         const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
00428 {
00429     DocHost *This = OLECMD_THIS(iface);
00430     ULONG i= 0;
00431     FIXME("(%p)->(%s %u %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds,
00432           pCmdText);
00433     while (prgCmds && (cCmds > i)) {
00434         FIXME("command_%u: %u, 0x%x\n", i, prgCmds[i].cmdID, prgCmds[i].cmdf);
00435         i++;
00436     }
00437     return E_NOTIMPL;
00438 }
00439 
00440 static HRESULT WINAPI ClOleCommandTarget_Exec(IOleCommandTarget *iface,
00441         const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn,
00442         VARIANT *pvaOut)
00443 {
00444     DocHost *This = OLECMD_THIS(iface);
00445 
00446     TRACE("(%p)->(%s %d %d %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID,
00447           nCmdexecopt, debugstr_variant(pvaIn), debugstr_variant(pvaOut));
00448 
00449     if(!pguidCmdGroup) {
00450         switch(nCmdID) {
00451         case OLECMDID_UPDATECOMMANDS:
00452             return This->container_vtbl->exec(This, pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
00453         default:
00454             FIXME("Unimplemented cmdid %d\n", nCmdID);
00455             return E_NOTIMPL;
00456         }
00457         return S_OK;
00458     }
00459 
00460     if(IsEqualGUID(pguidCmdGroup, &CGID_DocHostCmdPriv)) {
00461         switch(nCmdID) {
00462         case DOCHOST_DOCCANNAVIGATE:
00463             if(!pvaIn || V_VT(pvaIn) != VT_UNKNOWN)
00464                 return E_INVALIDARG;
00465 
00466             if(This->doc_navigate)
00467                 IUnknown_Release(This->doc_navigate);
00468             IUnknown_AddRef(V_UNKNOWN(pvaIn));
00469             This->doc_navigate = V_UNKNOWN(pvaIn);
00470             return S_OK;
00471 
00472         default:
00473             FIXME("unsupported command %d of CGID_DocHostCmdPriv\n", nCmdID);
00474             return E_NOTIMPL;
00475         }
00476     }
00477 
00478     FIXME("Unimplemented group %s\n", debugstr_guid(pguidCmdGroup));
00479     return E_NOTIMPL;
00480 }
00481 
00482 #undef OLECMD_THIS
00483 
00484 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
00485     ClOleCommandTarget_QueryInterface,
00486     ClOleCommandTarget_AddRef,
00487     ClOleCommandTarget_Release,
00488     ClOleCommandTarget_QueryStatus,
00489     ClOleCommandTarget_Exec
00490 };
00491 
00492 #define DOCHOSTUI_THIS(iface) DEFINE_THIS(DocHost, DocHostUIHandler, iface)
00493 
00494 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
00495                                                       REFIID riid, void **ppv)
00496 {
00497     DocHost *This = DOCHOSTUI_THIS(iface);
00498     return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
00499 }
00500 
00501 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
00502 {
00503     DocHost *This = DOCHOSTUI_THIS(iface);
00504     return IOleClientSite_AddRef(CLIENTSITE(This));
00505 }
00506 
00507 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
00508 {
00509     DocHost *This = DOCHOSTUI_THIS(iface);
00510     return IOleClientSite_Release(CLIENTSITE(This));
00511 }
00512 
00513 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface,
00514          DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
00515 {
00516     DocHost *This = DOCHOSTUI_THIS(iface);
00517     HRESULT hres;
00518 
00519     TRACE("(%p)->(%d %p %p %p)\n", This, dwID, ppt, pcmdtReserved, pdispReserved);
00520 
00521     if(This->hostui) {
00522         hres = IDocHostUIHandler_ShowContextMenu(This->hostui, dwID, ppt, pcmdtReserved,
00523                                                  pdispReserved);
00524         if(hres == S_OK)
00525             return S_OK;
00526     }
00527 
00528     FIXME("default action not implemented\n");
00529     return E_NOTIMPL;
00530 }
00531 
00532 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface,
00533         DOCHOSTUIINFO *pInfo)
00534 {
00535     DocHost *This = DOCHOSTUI_THIS(iface);
00536     HRESULT hres;
00537 
00538     TRACE("(%p)->(%p)\n", This, pInfo);
00539 
00540     if(This->hostui) {
00541         hres = IDocHostUIHandler_GetHostInfo(This->hostui, pInfo);
00542         if(SUCCEEDED(hres))
00543             return hres;
00544     }
00545 
00546     pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_OPENNEWWIN
00547         | DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
00548         | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
00549     return S_OK;
00550 }
00551 
00552 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
00553         IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
00554         IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
00555 {
00556     DocHost *This = DOCHOSTUI_THIS(iface);
00557     FIXME("(%p)->(%d %p %p %p %p)\n", This, dwID, pActiveObject, pCommandTarget,
00558           pFrame, pDoc);
00559     return E_NOTIMPL;
00560 }
00561 
00562 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
00563 {
00564     DocHost *This = DOCHOSTUI_THIS(iface);
00565     FIXME("(%p)\n", This);
00566     return E_NOTIMPL;
00567 }
00568 
00569 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
00570 {
00571     DocHost *This = DOCHOSTUI_THIS(iface);
00572 
00573     TRACE("(%p)\n", This);
00574 
00575     if(!This->hostui)
00576         return S_FALSE;
00577 
00578     return IDocHostUIHandler_UpdateUI(This->hostui);
00579 }
00580 
00581 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface,
00582                                                       BOOL fEnable)
00583 {
00584     DocHost *This = DOCHOSTUI_THIS(iface);
00585     FIXME("(%p)->(%x)\n", This, fEnable);
00586     return E_NOTIMPL;
00587 }
00588 
00589 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface,
00590                                                            BOOL fActivate)
00591 {
00592     DocHost *This = DOCHOSTUI_THIS(iface);
00593     FIXME("(%p)->(%x)\n", This, fActivate);
00594     return E_NOTIMPL;
00595 }
00596 
00597 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface,
00598                                                              BOOL fActivate)
00599 {
00600     DocHost *This = DOCHOSTUI_THIS(iface);
00601     FIXME("(%p)->(%x)\n", This, fActivate);
00602     return E_NOTIMPL;
00603 }
00604 
00605 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface,
00606         LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
00607 {
00608     DocHost *This = DOCHOSTUI_THIS(iface);
00609     FIXME("(%p)->(%p %p %X)\n", This, prcBorder, pUIWindow, fRameWindow);
00610     return E_NOTIMPL;
00611 }
00612 
00613 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface,
00614         LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
00615 {
00616     DocHost *This = DOCHOSTUI_THIS(iface);
00617     FIXME("(%p)->(%p %p %d)\n", This, lpMsg, pguidCmdGroup, nCmdID);
00618     return E_NOTIMPL;
00619 }
00620 
00621 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
00622         LPOLESTR *pchKey, DWORD dw)
00623 {
00624     DocHost *This = DOCHOSTUI_THIS(iface);
00625 
00626     TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
00627 
00628     if(This->hostui)
00629         return IDocHostUIHandler_GetOptionKeyPath(This->hostui, pchKey, dw);
00630 
00631     return S_OK;
00632 }
00633 
00634 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
00635         IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
00636 {
00637     DocHost *This = DOCHOSTUI_THIS(iface);
00638     FIXME("(%p)\n", This);
00639     return E_NOTIMPL;
00640 }
00641 
00642 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface,
00643         IDispatch **ppDispatch)
00644 {
00645     DocHost *This = DOCHOSTUI_THIS(iface);
00646 
00647     TRACE("(%p)->(%p)\n", This, ppDispatch);
00648 
00649     if(This->hostui)
00650         return IDocHostUIHandler_GetExternal(This->hostui, ppDispatch);
00651 
00652     FIXME("default action not implemented\n");
00653     return E_NOTIMPL;
00654 }
00655 
00656 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface,
00657         DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
00658 {
00659     DocHost *This = DOCHOSTUI_THIS(iface);
00660 
00661     TRACE("(%p)->(%d %s %p)\n", This, dwTranslate, debugstr_w(pchURLIn), ppchURLOut);
00662 
00663     if(This->hostui)
00664         return IDocHostUIHandler_TranslateUrl(This->hostui, dwTranslate,
00665                                               pchURLIn, ppchURLOut);
00666 
00667     return S_FALSE;
00668 }
00669 
00670 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface,
00671         IDataObject *pDO, IDataObject **ppDORet)
00672 {
00673     DocHost *This = DOCHOSTUI_THIS(iface);
00674     FIXME("(%p)->(%p %p)\n", This, pDO, ppDORet);
00675     return E_NOTIMPL;
00676 }
00677 
00678 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
00679         LPOLESTR *pchKey, DWORD dw)
00680 {
00681     DocHost *This = DOCHOSTUI_THIS(iface);
00682     IDocHostUIHandler2 *handler;
00683     HRESULT hres;
00684 
00685     TRACE("(%p)->(%p %d)\n", This, pchKey, dw);
00686 
00687     if(!This->hostui)
00688         return S_OK;
00689 
00690     hres = IDocHostUIHandler_QueryInterface(This->hostui, &IID_IDocHostUIHandler2,
00691                                             (void**)&handler);
00692     if(SUCCEEDED(hres)) {
00693         hres = IDocHostUIHandler2_GetOverrideKeyPath(handler, pchKey, dw);
00694         IDocHostUIHandler2_Release(handler);
00695         return hres;
00696     }
00697 
00698     return S_OK;
00699 }
00700 
00701 #undef DOCHOSTUI_THIS
00702 
00703 static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
00704     DocHostUIHandler_QueryInterface,
00705     DocHostUIHandler_AddRef,
00706     DocHostUIHandler_Release,
00707     DocHostUIHandler_ShowContextMenu,
00708     DocHostUIHandler_GetHostInfo,
00709     DocHostUIHandler_ShowUI,
00710     DocHostUIHandler_HideUI,
00711     DocHostUIHandler_UpdateUI,
00712     DocHostUIHandler_EnableModeless,
00713     DocHostUIHandler_OnDocWindowActivate,
00714     DocHostUIHandler_OnFrameWindowActivate,
00715     DocHostUIHandler_ResizeBorder,
00716     DocHostUIHandler_TranslateAccelerator,
00717     DocHostUIHandler_GetOptionKeyPath,
00718     DocHostUIHandler_GetDropTarget,
00719     DocHostUIHandler_GetExternal,
00720     DocHostUIHandler_TranslateUrl,
00721     DocHostUIHandler_FilterDataObject,
00722     DocHostUIHandler_GetOverrideKeyPath
00723 };
00724 
00725 #define PROPNOTIF_THIS(iface) DEFINE_THIS(DocHost, IPropertyNotifySink, iface)
00726 
00727 static HRESULT WINAPI PropertyNotifySink_QueryInterface(IPropertyNotifySink *iface,
00728         REFIID riid, void **ppv)
00729 {
00730     DocHost *This = PROPNOTIF_THIS(iface);
00731     return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppv);
00732 }
00733 
00734 static ULONG WINAPI PropertyNotifySink_AddRef(IPropertyNotifySink *iface)
00735 {
00736     DocHost *This = PROPNOTIF_THIS(iface);
00737     return IOleClientSite_AddRef(CLIENTSITE(This));
00738 }
00739 
00740 static ULONG WINAPI PropertyNotifySink_Release(IPropertyNotifySink *iface)
00741 {
00742     DocHost *This = PROPNOTIF_THIS(iface);
00743     return IOleClientSite_Release(CLIENTSITE(This));
00744 }
00745 
00746 static HRESULT WINAPI PropertyNotifySink_OnChanged(IPropertyNotifySink *iface, DISPID dispID)
00747 {
00748     DocHost *This = PROPNOTIF_THIS(iface);
00749 
00750     TRACE("(%p)->(%d)\n", This, dispID);
00751 
00752     switch(dispID) {
00753     case DISPID_READYSTATE: {
00754         READYSTATE ready_state;
00755         HRESULT hres;
00756 
00757         hres = get_doc_ready_state(This, &ready_state);
00758         if(FAILED(hres))
00759             return hres;
00760 
00761         if(ready_state == READYSTATE_COMPLETE && !This->doc_navigate)
00762             advise_prop_notif(This, FALSE);
00763 
00764         push_ready_state_task(This, ready_state);
00765         break;
00766     }
00767     default:
00768         FIXME("unimplemented dispid %d\n", dispID);
00769         return E_NOTIMPL;
00770     }
00771 
00772     return S_OK;
00773 }
00774 
00775 static HRESULT WINAPI PropertyNotifySink_OnRequestEdit(IPropertyNotifySink *iface, DISPID dispID)
00776 {
00777     DocHost *This = PROPNOTIF_THIS(iface);
00778     FIXME("(%p)->(%d)\n", This, dispID);
00779     return E_NOTIMPL;
00780 }
00781 
00782 #undef PROPNOTIF_THIS
00783 
00784 static const IPropertyNotifySinkVtbl PropertyNotifySinkVtbl = {
00785     PropertyNotifySink_QueryInterface,
00786     PropertyNotifySink_AddRef,
00787     PropertyNotifySink_Release,
00788     PropertyNotifySink_OnChanged,
00789     PropertyNotifySink_OnRequestEdit
00790 };
00791 
00792 void DocHost_Init(DocHost *This, IDispatch *disp, const IDocHostContainerVtbl* container)
00793 {
00794     This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
00795     This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
00796     This->lpIPropertyNotifySinkVtbl = &PropertyNotifySinkVtbl;
00797 
00798     This->disp = disp;
00799 
00800     This->container_vtbl = container;
00801 
00802     This->client_disp = NULL;
00803 
00804     This->document = NULL;
00805     This->hostui = NULL;
00806     This->frame = NULL;
00807 
00808     This->hwnd = NULL;
00809     This->frame_hwnd = NULL;
00810     This->url = NULL;
00811 
00812     This->silent = VARIANT_FALSE;
00813     This->offline = VARIANT_FALSE;
00814 
00815     This->ready_state = READYSTATE_UNINITIALIZED;
00816     This->is_prop_notif = FALSE;
00817 
00818     DocHost_ClientSite_Init(This);
00819     DocHost_Frame_Init(This);
00820 
00821     ConnectionPointContainer_Init(&This->cps, (IUnknown*)disp);
00822 }
00823 
00824 void DocHost_Release(DocHost *This)
00825 {
00826     release_dochost_client(This);
00827     DocHost_ClientSite_Release(This);
00828 
00829     ConnectionPointContainer_Destroy(&This->cps);
00830 
00831     heap_free(This->url);
00832 }

Generated on Sun May 27 2012 04:26:14 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.