Commit 3d3f223a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use QueryCommandState to get align state.

parent 3fbf6bdf
...@@ -180,25 +180,33 @@ static void set_ns_align(HTMLDocument *This, const char *align_str) ...@@ -180,25 +180,33 @@ static void set_ns_align(HTMLDocument *This, const char *align_str)
nsICommandParams_Release(nsparam); nsICommandParams_Release(nsparam);
} }
static DWORD query_align_status(HTMLDocument *This, const char *align_str) static DWORD query_align_status(HTMLDocument *This, const WCHAR *align)
{ {
nsICommandParams *nsparam; DWORD ret = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
char *align = NULL; nsIDOMNSHTMLDocument *nsdoc;
nsAString justify_str;
PRBool b;
nsresult nsres;
if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE) if(This->doc_obj->usermode != EDITMODE || This->window->readystate < READYSTATE_INTERACTIVE)
return OLECMDF_SUPPORTED; return OLECMDF_SUPPORTED;
if(This->doc_obj->nscontainer) {
nsparam = create_nscommand_params();
get_ns_command_state(This->doc_obj->nscontainer, NSCMD_ALIGN, nsparam);
nsICommandParams_GetCStringValue(nsparam, NSSTATE_ATTRIBUTE, &align);
nsICommandParams_Release(nsparam); nsres = nsIDOMHTMLDocument_QueryInterface(This->doc_node->nsdoc, &IID_nsIDOMNSHTMLDocument,
(void**)&nsdoc);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMNSHTMLDocument iface: %08x\n", nsres);
return 0;
} }
return OLECMDF_SUPPORTED | OLECMDF_ENABLED nsAString_Init(&justify_str, align);
| (align && !strcmp(align_str, align) ? OLECMDF_LATCHED : 0); nsres = nsIDOMNSHTMLDocument_QueryCommandState(nsdoc, &justify_str, &b);
nsAString_Finish(&justify_str);
if(NS_SUCCEEDED(nsres) && b)
ret |= OLECMDF_LATCHED;
nsIDOMNSHTMLDocument_Release(nsdoc);
return ret;
} }
...@@ -704,10 +712,13 @@ static HRESULT exec_italic(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VA ...@@ -704,10 +712,13 @@ static HRESULT exec_italic(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VA
static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd) static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd)
{ {
static const PRUnichar justifycenterW[] = {'j','u','s','t','i','f','y','c','e','n','t','e','r',0};
static const PRUnichar justifyrightW[] = {'j','u','s','t','i','f','y','r','i','g','h','t',0};
switch(cmd->cmdID) { switch(cmd->cmdID) {
case IDM_JUSTIFYCENTER: case IDM_JUSTIFYCENTER:
TRACE("(%p) IDM_JUSTIFYCENTER\n", This); TRACE("(%p) IDM_JUSTIFYCENTER\n", This);
cmd->cmdf = query_align_status(This, NSALIGN_CENTER); cmd->cmdf = query_align_status(This, justifycenterW);
break; break;
case IDM_JUSTIFYLEFT: case IDM_JUSTIFYLEFT:
TRACE("(%p) IDM_JUSTIFYLEFT\n", This); TRACE("(%p) IDM_JUSTIFYLEFT\n", This);
...@@ -719,7 +730,7 @@ static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd) ...@@ -719,7 +730,7 @@ static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd)
break; break;
case IDM_JUSTIFYRIGHT: case IDM_JUSTIFYRIGHT:
TRACE("(%p) IDM_JUSTIFYRIGHT\n", This); TRACE("(%p) IDM_JUSTIFYRIGHT\n", This);
cmd->cmdf = query_align_status(This, NSALIGN_RIGHT); cmd->cmdf = query_align_status(This, justifyrightW);
break; break;
} }
......
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