Commit 5f907804 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IDM_FONTNAME implementation.

parent 80225d53
......@@ -312,6 +312,7 @@ PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
void nsAString_Finish(nsAString*);
nsIInputStream *create_nsstream(const char*,PRInt32);
nsICommandParams *create_nscommand_params(void);
BSCallback *create_bscallback(HTMLDocument*,IMoniker*);
HRESULT start_binding(BSCallback*);
......
......@@ -40,6 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#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 char *data, PRInt32 data_len)
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");
......
......@@ -26,6 +26,7 @@
#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 *This, const char *cmd, nsICommandParams *
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_Exec(IOleCommandTarget *iface, const GUID
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment