Module: wine Branch: master Commit: 5f9078040a248a5af5def3072cc942335f12f74e URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=5f9078040a248a5af5def307...
Author: Jacek Caban jacek@codeweavers.com Date: Sun Aug 27 16:01:06 2006 +0200
mshtml: Added IDM_FONTNAME implementation.
---
dlls/mshtml/mshtml_private.h | 1 dlls/mshtml/nsembed.c | 18 ++++++++ dlls/mshtml/olecmd.c | 93 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 0 deletions(-)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 99de822..b9eb7d3 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -312,6 +312,7 @@ PRUint32 nsAString_GetData(const nsAStri void nsAString_Finish(nsAString*);
nsIInputStream *create_nsstream(const char*,PRInt32); +nsICommandParams *create_nscommand_params(void);
BSCallback *create_bscallback(HTMLDocument*,IMoniker*); HRESULT start_binding(BSCallback*); diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 4fabad7..1089164 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -40,6 +40,7 @@ #define NS_WEBBROWSER_CONTRACTID "@mozil #define NS_PROFILE_CONTRACTID "@mozilla.org/profile/manager;1" #define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1" #define NS_STRINGSTREAM_CONTRACTID "@mozilla.org/io/string-input-stream;1" +#define NS_COMMANDPARAMS_CONTRACTID "@mozilla.org/embedcomp/command-params;1"
#define APPSTARTUP_TOPIC "app-startup"
@@ -447,6 +448,23 @@ nsIInputStream *create_nsstream(const ch return (nsIInputStream*)ret; }
+nsICommandParams *create_nscommand_params(void) +{ + nsICommandParams *ret = NULL; + nsresult nsres; + + if(!pCompMgr) + return NULL; + + nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, + NS_COMMANDPARAMS_CONTRACTID, NULL, &IID_nsICommandParams, + (void**)&ret); + if(NS_FAILED(nsres)) + ERR("Could not get nsICommandParams\n"); + + return ret; +} + void close_gecko() { TRACE("()\n"); diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c index 9b17502..81de774 100644 --- a/dlls/mshtml/olecmd.c +++ b/dlls/mshtml/olecmd.c @@ -26,6 +26,7 @@ #define COBJMACROS #include "windef.h" #include "winbase.h" #include "winuser.h" +#include "winnls.h" #include "ole2.h" #include "shlguid.h" #include "mshtmdid.h" @@ -268,6 +269,96 @@ static void do_ns_command(NSContainer *T nsICommandManager_Release(cmdmgr); }
+static nsresult get_ns_command_state(NSContainer *This, const char *cmd, nsICommandParams *nsparam) +{ + nsICommandManager *cmdmgr; + nsIInterfaceRequestor *iface_req; + nsresult nsres; + + nsres = nsIWebBrowser_QueryInterface(This->webbrowser, + &IID_nsIInterfaceRequestor, (void**)&iface_req); + if(NS_FAILED(nsres)) { + ERR("Could not get nsIInterfaceRequestor: %08lx\n", nsres); + return nsres; + } + + 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; + } + + nsres = nsICommandManager_GetCommandState(cmdmgr, cmd, NULL, nsparam); + if(NS_FAILED(nsres)) + ERR("GetCommandState(%s) failed: %08lx\n", debugstr_a(cmd), nsres); + + nsICommandManager_Release(cmdmgr); + return nsres; +} + +static HRESULT exec_fontname(HTMLDocument *This, VARIANT *in, VARIANT *out) +{ + TRACE("(%p)->(%p %p)\n", This, in, out); + + if(!This->nscontainer) + return E_FAIL; + + if(in) { + nsICommandParams *nsparam = create_nscommand_params(); + char *stra; + DWORD len; + + if(V_VT(in) != VT_BSTR) { + FIXME("Unsupported vt=%d\n", V_VT(out)); + return E_INVALIDARG; + } + + len = WideCharToMultiByte(CP_ACP, 0, V_BSTR(in), -1, NULL, 0, NULL, NULL); + stra = mshtml_alloc(len); + WideCharToMultiByte(CP_ACP, 0, V_BSTR(in), -1, stra, -1, NULL, NULL); + nsICommandParams_SetCStringValue(nsparam, "state_attribute", stra); + mshtml_free(stra); + + do_ns_command(This->nscontainer, "cmd_fontFace", nsparam); + + nsICommandParams_Release(nsparam); + } + + if(out) { + nsICommandParams *nsparam; + LPWSTR strw; + char *stra; + DWORD len; + nsresult nsres; + + if(V_VT(out) != VT_BSTR) { + FIXME("Unsupported vt=%d\n", V_VT(out)); + return E_INVALIDARG; + } + + nsparam = create_nscommand_params(); + + nsres = get_ns_command_state(This->nscontainer, "cmd_fontFace", nsparam); + if(NS_FAILED(nsres)) + return S_OK; + + nsICommandParams_GetCStringValue(nsparam, "state_attribute", &stra); + nsICommandParams_Release(nsparam); + + len = MultiByteToWideChar(CP_ACP, 0, stra, -1, NULL, 0); + strw = mshtml_alloc(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, stra, -1, strw, -1); + nsfree(stra); + + V_BSTR(out) = SysAllocString(strw); + mshtml_free(strw); + } + + return S_OK; +} + static HRESULT exec_bold(HTMLDocument *This) { TRACE("(%p)\n", This); @@ -637,6 +728,8 @@ static HRESULT WINAPI OleCommandTarget_E return OLECMDERR_E_NOTSUPPORTED; }else if(IsEqualGUID(&CGID_MSHTML, pguidCmdGroup)) { switch(nCmdID) { + case IDM_FONTNAME: + return exec_fontname(This, pvaIn, pvaOut); case IDM_BOLD: if(pvaIn || pvaOut) FIXME("unsupported arguments\n");