From cf6288e2ab8761df4db312568eab1c2a882db182 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 23 Apr 2013 12:57:59 +0200 Subject: [PATCH] mshtml: Moved exec_editmode implementation to a helper function in editor.c. --- dlls/mshtml/editor.c | 102 +++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/olecmd.c | 99 +--------------------------------- 3 files changed, 104 insertions(+), 98 deletions(-) diff --git a/dlls/mshtml/editor.c b/dlls/mshtml/editor.c index 0a58d1f01b..cfab2edef8 100644 --- a/dlls/mshtml/editor.c +++ b/dlls/mshtml/editor.c @@ -26,6 +26,7 @@ #include "winuser.h" #include "ole2.h" #include "mshtmcid.h" +#include "shlguid.h" #include "wine/debug.h" @@ -1263,3 +1264,104 @@ HRESULT editor_is_dirty(HTMLDocument *This) return modified ? S_OK : S_FALSE; } + +HRESULT setup_edit_mode(HTMLDocumentObj *doc) +{ + IMoniker *mon; + HRESULT hres; + + if(doc->usermode == EDITMODE) + return S_OK; + + doc->usermode = EDITMODE; + + if(doc->basedoc.window->mon) { + CLSID clsid = IID_NULL; + hres = IMoniker_GetClassID(doc->basedoc.window->mon, &clsid); + if(SUCCEEDED(hres)) { + /* We should use IMoniker::Save here */ + FIXME("Use CLSID %s\n", debugstr_guid(&clsid)); + } + } + + if(doc->frame) + IOleInPlaceFrame_SetStatusText(doc->frame, NULL); + + doc->basedoc.window->readystate = READYSTATE_UNINITIALIZED; + + if(doc->client) { + IOleCommandTarget *cmdtrg; + + hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg); + if(SUCCEEDED(hres)) { + VARIANT var; + + V_VT(&var) = VT_I4; + V_I4(&var) = 0; + IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); + + IOleCommandTarget_Release(cmdtrg); + } + } + + if(doc->hostui) { + DOCHOSTUIINFO hostinfo; + + memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO)); + hostinfo.cbSize = sizeof(DOCHOSTUIINFO); + hres = IDocHostUIHandler_GetHostInfo(doc->hostui, &hostinfo); + if(SUCCEEDED(hres)) + /* FIXME: use hostinfo */ + TRACE("hostinfo = {%u %08x %08x %s %s}\n", + hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick, + debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS)); + } + + update_doc(&doc->basedoc, UPDATE_UI); + + if(doc->basedoc.window->mon) { + /* FIXME: We should find nicer way to do this */ + remove_target_tasks(doc->basedoc.task_magic); + + mon = doc->basedoc.window->mon; + IMoniker_AddRef(mon); + }else { + static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; + + hres = CreateURLMoniker(NULL, about_blankW, &mon); + if(FAILED(hres)) { + FIXME("CreateURLMoniker failed: %08x\n", hres); + return hres; + } + } + + hres = IPersistMoniker_Load(&doc->basedoc.IPersistMoniker_iface, TRUE, mon, NULL, 0); + IMoniker_Release(mon); + if(FAILED(hres)) + return hres; + + if(doc->ui_active) { + if(doc->ip_window) + call_set_active_object(doc->ip_window, NULL); + if(doc->hostui) + IDocHostUIHandler_HideUI(doc->hostui); + } + + if(doc->ui_active) { + RECT rcBorderWidths; + + if(doc->hostui) + IDocHostUIHandler_ShowUI(doc->hostui, DOCHOSTUITYPE_AUTHOR, + &doc->basedoc.IOleInPlaceActiveObject_iface, &doc->basedoc.IOleCommandTarget_iface, + doc->frame, doc->ip_window); + + if(doc->ip_window) + call_set_active_object(doc->ip_window, &doc->basedoc.IOleInPlaceActiveObject_iface); + + memset(&rcBorderWidths, 0, sizeof(rcBorderWidths)); + if(doc->frame) + IOleInPlaceFrame_SetBorderSpace(doc->frame, &rcBorderWidths); + } + + return S_OK; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index f141bdffa1..c610ef52e6 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -952,6 +952,7 @@ void update_title(HTMLDocumentObj*) DECLSPEC_HIDDEN; HRESULT do_query_service(IUnknown*,REFGUID,REFIID,void**) DECLSPEC_HIDDEN; /* editor */ +HRESULT setup_edit_mode(HTMLDocumentObj*) DECLSPEC_HIDDEN; void init_editor(HTMLDocument*) DECLSPEC_HIDDEN; void handle_edit_event(HTMLDocument*,nsIDOMEvent*) DECLSPEC_HIDDEN; HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index bda06b5580..8d94209b42 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -592,109 +592,12 @@ static HRESULT exec_browsemode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in static HRESULT exec_editmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) { - IMoniker *mon; - HRESULT hres; - TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); if(in || out) FIXME("unsupported args\n"); - if(This->doc_obj->usermode == EDITMODE) - return S_OK; - - This->doc_obj->usermode = EDITMODE; - - if(This->window->mon) { - CLSID clsid = IID_NULL; - hres = IMoniker_GetClassID(This->window->mon, &clsid); - if(SUCCEEDED(hres)) { - /* We should use IMoniker::Save here */ - FIXME("Use CLSID %s\n", debugstr_guid(&clsid)); - } - } - - if(This->doc_obj->frame) - IOleInPlaceFrame_SetStatusText(This->doc_obj->frame, NULL); - - This->window->readystate = READYSTATE_UNINITIALIZED; - - if(This->doc_obj->client) { - IOleCommandTarget *cmdtrg; - - hres = IOleClientSite_QueryInterface(This->doc_obj->client, &IID_IOleCommandTarget, - (void**)&cmdtrg); - if(SUCCEEDED(hres)) { - VARIANT var; - - V_VT(&var) = VT_I4; - V_I4(&var) = 0; - IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL); - - IOleCommandTarget_Release(cmdtrg); - } - } - - if(This->doc_obj->hostui) { - DOCHOSTUIINFO hostinfo; - - memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO)); - hostinfo.cbSize = sizeof(DOCHOSTUIINFO); - hres = IDocHostUIHandler_GetHostInfo(This->doc_obj->hostui, &hostinfo); - if(SUCCEEDED(hres)) - /* FIXME: use hostinfo */ - TRACE("hostinfo = {%u %08x %08x %s %s}\n", - hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick, - debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS)); - } - - update_doc(This, UPDATE_UI); - - if(This->window->mon) { - /* FIXME: We should find nicer way to do this */ - remove_target_tasks(This->task_magic); - - mon = This->window->mon; - IMoniker_AddRef(mon); - }else { - static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; - - hres = CreateURLMoniker(NULL, about_blankW, &mon); - if(FAILED(hres)) { - FIXME("CreateURLMoniker failed: %08x\n", hres); - return hres; - } - } - - hres = IPersistMoniker_Load(&This->IPersistMoniker_iface, TRUE, mon, NULL, 0); - IMoniker_Release(mon); - if(FAILED(hres)) - return hres; - - if(This->doc_obj->ui_active) { - if(This->doc_obj->ip_window) - call_set_active_object(This->doc_obj->ip_window, NULL); - if(This->doc_obj->hostui) - IDocHostUIHandler_HideUI(This->doc_obj->hostui); - } - - if(This->doc_obj->ui_active) { - RECT rcBorderWidths; - - if(This->doc_obj->hostui) - IDocHostUIHandler_ShowUI(This->doc_obj->hostui, DOCHOSTUITYPE_AUTHOR, - &This->IOleInPlaceActiveObject_iface, &This->IOleCommandTarget_iface, - This->doc_obj->frame, This->doc_obj->ip_window); - - if(This->doc_obj->ip_window) - call_set_active_object(This->doc_obj->ip_window, &This->IOleInPlaceActiveObject_iface); - - memset(&rcBorderWidths, 0, sizeof(rcBorderWidths)); - if(This->doc_obj->frame) - IOleInPlaceFrame_SetBorderSpace(This->doc_obj->frame, &rcBorderWidths); - } - - return S_OK; + return setup_edit_mode(This->doc_obj); } static HRESULT exec_htmleditmode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) -- 2.32.0.93.g670b81a890