From: Jacek Caban Subject: [PATCH 1/2] mshtml: Added support for IDM_PASTE command in browser mode. Message-Id: <54888AB7.2070607@codeweavers.com> Date: Wed, 10 Dec 2014 19:02:31 +0100 try2: Included required nsiface.idl changes. --- dlls/mshtml/nsiface.idl | 23 +++++++++++++++++++++++ dlls/mshtml/olecmd.c | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 3bb5020..1d8e263 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -3548,6 +3548,29 @@ interface nsIHTMLEditor : nsISupports [ object, + uuid(b8100c90-73be-11d2-92a5-00105a1b0d64), + local +] +interface nsIClipboardCommands : nsISupports +{ + nsresult CanCutSelection(bool *_retval); + nsresult CanCopySelection(bool *_retval); + nsresult CanCopyLinkLocation(bool *_retval); + nsresult CanCopyImageLocation(bool *_retval); + nsresult CanCopyImageContents(bool *_retval); + nsresult CanPaste(bool *_retval); + nsresult CutSelection(); + nsresult CopySelection(); + nsresult CopyLinkLocation(); + nsresult CopyImageLocation(); + nsresult CopyImageContents(); + nsresult Paste(); + nsresult SelectAll(); + nsresult SelectNone(); +} + +[ + object, uuid(edb99640-8378-4106-8673-e701a086eb1c), local ] diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index eea3aa2..a49949d 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -62,6 +62,28 @@ void do_ns_command(HTMLDocument *This, const char *cmd, nsICommandParams *nspara nsICommandManager_Release(cmdmgr); } +static nsIClipboardCommands *get_clipboard_commands(HTMLDocument *doc) +{ + nsIClipboardCommands *clipboard_commands; + nsIDocShell *doc_shell; + nsresult nsres; + + nsres = get_nsinterface((nsISupports*)doc->window->nswindow, &IID_nsIDocShell, (void**)&doc_shell); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIDocShell interface\n"); + return NULL; + } + + nsres = nsIDocShell_QueryInterface(doc_shell, &IID_nsIClipboardCommands, (void**)&clipboard_commands); + nsIDocShell_Release(doc_shell); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIClipboardCommands interface\n"); + return NULL; + } + + return clipboard_commands; +} + /********************************************************** * IOleCommandTarget implementation */ @@ -569,13 +591,26 @@ static HRESULT query_mshtml_paste(HTMLDocument *This, OLECMD *cmd) static HRESULT exec_mshtml_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out) { + nsIClipboardCommands *clipboard_commands; + nsresult nsres; + TRACE("(%p)->(%08x %p %p)\n", This, cmdexecopt, in, out); if(This->doc_obj->usermode == EDITMODE) return editor_exec_paste(This, cmdexecopt, in, out); - FIXME("Unimplemented in browse mode\n"); - return E_NOTIMPL; + clipboard_commands = get_clipboard_commands(This); + if(!clipboard_commands) + return E_UNEXPECTED; + + nsres = nsIClipboardCommands_Paste(clipboard_commands); + nsIClipboardCommands_Release(clipboard_commands); + if(NS_FAILED(nsres)) { + ERR("Paste failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT exec_browsemode(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)