From 4e418499cafcb0d991bbf209a3f707e8f7541aac Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 18 Aug 2006 23:14:44 +0200 Subject: [PATCH] mshtml: Added IDM_BOLD implementation. --- dlls/mshtml/nsiface.idl | 17 +++++++++++++++ dlls/mshtml/olecmd.c | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 46e0a235eef..5de691636d1 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -109,6 +109,7 @@ typedef nsISupports nsIDOMHTMLOptionsCollection; typedef nsISupports nsIDOMHTMLCollection; typedef nsISupports nsIDOMRange; typedef nsISupports nsIEditor; +typedef nsISupports nsICommandParams; [ object, @@ -1174,6 +1175,22 @@ interface nsIEditingSession : nsISupports nsresult SetEditorOnControllers(nsIDOMWindow *aWindow, nsIEditor *aEditor); } +[ + object, + uuid(080d2001-f91e-11d4-a73c-f9242928207c) +] +interface nsICommandManager : nsISupports +{ + nsresult AddCommandObserver(nsIObserver *aCommandObserver, const char *aCommandToObserve); + nsresult RemoveCommandObserver(nsIObserver *aCommandObserver, const char *aCommandObserved); + nsresult IsCommandSupported(const char *aCommandName, nsIDOMWindow *aTargetWindow, PRBool *_retval); + nsresult IsCommandEnabled(const char *aCommandName, nsIDOMWindow *aTargetWindow, PRBool *_retval); + nsresult GetCommandState(const char *aCommandName, nsIDOMWindow *aTargetWindow, + nsICommandParams *aCommandParams); + nsresult DoCommand(const char *aCommandName, nsICommandParams *aCommandParams, + nsIDOMWindow *aTargetWindow); +} + /* * NOTE: * This is a private Wine interface that is implemented by our implementation diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index a95f5b1b529..ef0de6438d2 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -238,6 +238,46 @@ static HRESULT exec_get_print_template(HTMLDocument *This, DWORD nCmdexecopt, VA return E_NOTIMPL; } +static void do_ns_command(NSContainer *This, const char *cmd) +{ + nsICommandManager *cmdmgr; + nsIInterfaceRequestor *iface_req; + nsresult nsres; + + FIXME("(%p)\n", This); + + nsres = nsIWebBrowser_QueryInterface(This->webbrowser, + &IID_nsIInterfaceRequestor, (void**)&iface_req); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIInterfaceRequestor: %08lx\n", nsres); + return; + } + + nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsICommandManager, + (void**)&cmdmgr); + nsIInterfaceRequestor_Release(iface_req); + if(NS_FAILED(nsres)) { + ERR("Could not get nsICommandManager: %08lx\n", nsres); + return; + } + + nsres = nsICommandManager_DoCommand(cmdmgr, cmd, NULL, NULL); + if(NS_FAILED(nsres)) + ERR("DoCommand(%s) failed: %08lx\n", debugstr_a(cmd), nsres); + + nsICommandManager_Release(cmdmgr); +} + +static HRESULT exec_bold(HTMLDocument *This) +{ + TRACE("(%p)\n", This); + + if(This->nscontainer) + do_ns_command(This->nscontainer, "cmd_bold"); + + return S_OK; +} + static HRESULT exec_browsemode(HTMLDocument *This) { WARN("(%p)\n", This); @@ -504,7 +544,13 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID return OLECMDERR_E_NOTSUPPORTED; }else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) { switch(nCmdID) { + case IDM_BOLD: + if(pvaIn || pvaOut) + FIXME("unsupported arguments\n"); + return exec_bold(This); case IDM_BROWSEMODE: + if(pvaIn || pvaOut) + FIXME("unsupported arguments\n"); return exec_browsemode(This); case IDM_EDITMODE: if(pvaIn || pvaOut)