2 * Copyright 2006-2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 #define NSCMD_ALIGN "cmd_align"
41 #define NSCMD_BOLD "cmd_bold"
42 #define NSCMD_CHARNEXT "cmd_charNext"
43 #define NSCMD_CHARPREVIOUS "cmd_charPrevious"
44 #define NSCMD_COPY "cmd_copy"
45 #define NSCMD_CUT "cmd_cut"
46 #define NSCMD_FONTCOLOR "cmd_fontColor"
47 #define NSCMD_FONTFACE "cmd_fontFace"
48 #define NSCMD_INDENT "cmd_indent"
49 #define NSCMD_INSERTHR "cmd_insertHR"
50 #define NSCMD_ITALIC "cmd_italic"
51 #define NSCMD_LINENEXT "cmd_lineNext"
52 #define NSCMD_LINEPREVIOUS "cmd_linePrevious"
53 #define NSCMD_MOVEPAGEDOWN "cmd_movePageDown"
54 #define NSCMD_MOVEPAGEUP "cmd_movePageUp"
55 #define NSCMD_OL "cmd_ol"
56 #define NSCMD_OUTDENT "cmd_outdent"
57 #define NSCMD_PASTE "cmd_paste"
58 #define NSCMD_SELECTCHARNEXT "cmd_selectCharNext"
59 #define NSCMD_SELECTCHARPREVIOUS "cmd_selectCharPrevious"
60 #define NSCMD_SELECTLINENEXT "cmd_selectLineNext"
61 #define NSCMD_SELECTLINEPREVIOUS "cmd_selectLinePrevious"
62 #define NSCMD_SELECTPAGEDOWN "cmd_selectPageDown"
63 #define NSCMD_SELECTPAGEUP "cmd_selectPageUp"
64 #define NSCMD_SELECTWORDNEXT "cmd_selectWordNext"
65 #define NSCMD_SELECTWORDPREVIOUS "cmd_selectWordPrevious"
66 #define NSCMD_UL "cmd_ul"
67 #define NSCMD_UNDERLINE "cmd_underline"
68 #define NSCMD_WORDNEXT "cmd_wordNext"
69 #define NSCMD_WORDPREVIOUS "cmd_wordPrevious"
71 #define NSSTATE_ATTRIBUTE "state_attribute"
72 #define NSSTATE_ALL "state_all"
74 #define NSALIGN_CENTER "center"
75 #define NSALIGN_LEFT "left"
76 #define NSALIGN_RIGHT "right"
78 #define DOM_VK_LEFT VK_LEFT
79 #define DOM_VK_UP VK_UP
80 #define DOM_VK_RIGHT VK_RIGHT
81 #define DOM_VK_DOWN VK_DOWN
83 static const WCHAR wszFont[] = {'f','o','n','t',0};
84 static const WCHAR wszSize[] = {'s','i','z','e',0};
86 static void do_ns_command(NSContainer *This, const char *cmd, nsICommandParams *nsparam)
88 nsICommandManager *cmdmgr;
89 nsIInterfaceRequestor *iface_req;
92 TRACE("(%p)\n", This);
94 nsres = nsIWebBrowser_QueryInterface(This->webbrowser,
95 &IID_nsIInterfaceRequestor, (void**)&iface_req);
96 if(NS_FAILED(nsres)) {
97 ERR("Could not get nsIInterfaceRequestor: %08x\n", nsres);
101 nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsICommandManager,
103 nsIInterfaceRequestor_Release(iface_req);
104 if(NS_FAILED(nsres)) {
105 ERR("Could not get nsICommandManager: %08x\n", nsres);
109 nsres = nsICommandManager_DoCommand(cmdmgr, cmd, nsparam, NULL);
111 ERR("DoCommand(%s) failed: %08x\n", debugstr_a(cmd), nsres);
113 nsICommandManager_Release(cmdmgr);
116 static void do_ns_editor_command(NSContainer *This, const char *cmd)
120 if(!This->editor_controller)
123 nsres = nsIController_DoCommand(This->editor_controller, cmd);
125 ERR("DoCommand(%s) failed: %08x\n", debugstr_a(cmd), nsres);
128 static nsresult get_ns_command_state(NSContainer *This, const char *cmd, nsICommandParams *nsparam)
130 nsICommandManager *cmdmgr;
131 nsIInterfaceRequestor *iface_req;
134 nsres = nsIWebBrowser_QueryInterface(This->webbrowser,
135 &IID_nsIInterfaceRequestor, (void**)&iface_req);
136 if(NS_FAILED(nsres)) {
137 ERR("Could not get nsIInterfaceRequestor: %08x\n", nsres);
141 nsres = nsIInterfaceRequestor_GetInterface(iface_req, &IID_nsICommandManager,
143 nsIInterfaceRequestor_Release(iface_req);
144 if(NS_FAILED(nsres)) {
145 ERR("Could not get nsICommandManager: %08x\n", nsres);
149 nsres = nsICommandManager_GetCommandState(cmdmgr, cmd, NULL, nsparam);
151 ERR("GetCommandState(%s) failed: %08x\n", debugstr_a(cmd), nsres);
153 nsICommandManager_Release(cmdmgr);
157 static DWORD query_ns_edit_status(HTMLDocument *This, const char *nscmd)
159 nsICommandParams *nsparam;
162 if(This->usermode != EDITMODE || This->readystate < READYSTATE_INTERACTIVE)
163 return OLECMDF_SUPPORTED;
165 if(This->nscontainer && nscmd) {
166 nsparam = create_nscommand_params();
167 get_ns_command_state(This->nscontainer, nscmd, nsparam);
169 nsICommandParams_GetBooleanValue(nsparam, NSSTATE_ALL, &b);
171 nsICommandParams_Release(nsparam);
174 return OLECMDF_SUPPORTED | OLECMDF_ENABLED | (b ? OLECMDF_LATCHED : 0);
177 static void set_ns_align(HTMLDocument *This, const char *align_str)
179 nsICommandParams *nsparam;
181 if(!This->nscontainer)
184 nsparam = create_nscommand_params();
185 nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, align_str);
187 do_ns_command(This->nscontainer, NSCMD_ALIGN, nsparam);
189 nsICommandParams_Release(nsparam);
192 static DWORD query_align_status(HTMLDocument *This, const char *align_str)
194 nsICommandParams *nsparam;
197 if(This->usermode != EDITMODE || This->readystate < READYSTATE_INTERACTIVE)
198 return OLECMDF_SUPPORTED;
200 if(This->nscontainer) {
201 nsparam = create_nscommand_params();
202 get_ns_command_state(This->nscontainer, NSCMD_ALIGN, nsparam);
204 nsICommandParams_GetCStringValue(nsparam, NSSTATE_ATTRIBUTE, &align);
206 nsICommandParams_Release(nsparam);
209 return OLECMDF_SUPPORTED | OLECMDF_ENABLED
210 | (align && !strcmp(align_str, align) ? OLECMDF_LATCHED : 0);
214 static nsISelection *get_ns_selection(HTMLDocument *This)
216 nsIDOMWindow *dom_window;
217 nsISelection *nsselection = NULL;
220 if(!This->nscontainer)
223 nsres = nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
227 nsIDOMWindow_GetSelection(dom_window, &nsselection);
228 nsIDOMWindow_Release(dom_window);
234 static void remove_child_attr(nsIDOMElement *elem, LPCWSTR tag, nsAString *attr_str)
237 PRUint32 child_cnt, i;
238 nsIDOMNode *child_node;
239 nsIDOMNodeList *node_list;
242 nsIDOMElement_HasChildNodes(elem, &has_children);
246 nsIDOMElement_GetChildNodes(elem, &node_list);
247 nsIDOMNodeList_GetLength(node_list, &child_cnt);
249 for(i=0; i<child_cnt; i++) {
250 nsIDOMNodeList_Item(node_list, i, &child_node);
252 nsIDOMNode_GetNodeType(child_node, &node_type);
253 if(node_type == ELEMENT_NODE) {
254 nsIDOMElement *child_elem;
256 const PRUnichar *ctag;
258 nsIDOMNode_QueryInterface(child_node, &IID_nsIDOMElement, (void**)&child_elem);
260 nsAString_Init(&tag_str, NULL);
261 nsIDOMElement_GetTagName(child_elem, &tag_str);
262 nsAString_GetData(&tag_str, &ctag, NULL);
264 if(!strcmpiW(ctag, tag))
265 /* FIXME: remove node if there are no more attributes */
266 nsIDOMElement_RemoveAttribute(child_elem, attr_str);
268 nsAString_Finish(&tag_str);
270 remove_child_attr(child_elem, tag, attr_str);
272 nsIDOMNode_Release(child_elem);
275 nsIDOMNode_Release(child_node);
278 nsIDOMNodeList_Release(node_list);
281 static void get_font_size(HTMLDocument *This, WCHAR *ret)
283 nsISelection *nsselection = get_ns_selection(This);
284 nsIDOMElement *elem = NULL;
285 nsIDOMNode *node = NULL, *tmp_node;
296 nsISelection_GetFocusNode(nsselection, &node);
297 nsISelection_Release(nsselection);
300 nsres = nsIDOMNode_GetNodeType(node, &node_type);
301 if(NS_FAILED(nsres) || node_type == DOCUMENT_NODE)
304 if(node_type == ELEMENT_NODE) {
305 nsIDOMNode_QueryInterface(node, &IID_nsIDOMElement, (void**)&elem);
307 nsAString_Init(&tag_str, NULL);
308 nsIDOMElement_GetTagName(elem, &tag_str);
309 nsAString_GetData(&tag_str, &tag, NULL);
311 if(!strcmpiW(tag, wszFont)) {
312 nsAString size_str, val_str;
315 TRACE("found font tag %p\n", elem);
317 nsAString_Init(&size_str, wszSize);
318 nsAString_Init(&val_str, NULL);
320 nsIDOMElement_GetAttribute(elem, &size_str, &val_str);
321 nsAString_GetData(&val_str, &val, NULL);
324 TRACE("found size %s\n", debugstr_w(val));
328 nsAString_Finish(&size_str);
329 nsAString_Finish(&val_str);
332 nsAString_Finish(&tag_str);
334 nsIDOMElement_Release(elem);
341 nsIDOMNode_GetParentNode(node, &node);
342 nsIDOMNode_Release(tmp_node);
346 nsIDOMNode_Release(node);
349 static void set_font_size(HTMLDocument *This, LPCWSTR size)
351 nsISelection *nsselection;
353 nsIDOMDocument *nsdoc;
356 PRInt32 range_cnt = 0;
362 nsselection = get_ns_selection(This);
367 nsISelection_GetRangeCount(nsselection, &range_cnt);
369 FIXME("range_cnt %d not supprted\n", range_cnt);
371 nsISelection_Release(nsselection);
376 nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
380 nsAString_Init(&font_str, wszFont);
381 nsAString_Init(&size_str, wszSize);
382 nsAString_Init(&val_str, size);
384 nsIDOMDocument_CreateElement(nsdoc, &font_str, &elem);
385 nsIDOMElement_SetAttribute(elem, &size_str, &val_str);
387 nsISelection_GetRangeAt(nsselection, 0, &range);
388 nsISelection_GetIsCollapsed(nsselection, &collapsed);
389 nsISelection_RemoveAllRanges(nsselection);
391 nsIDOMRange_SurroundContents(range, (nsIDOMNode*)elem);
394 nsISelection_Collapse(nsselection, (nsIDOMNode*)elem, 0);
396 /* Remove all size attrbutes from the range */
397 remove_child_attr(elem, wszFont, &size_str);
398 nsISelection_SelectAllChildren(nsselection, (nsIDOMNode*)elem);
401 nsIDOMRange_Release(range);
402 nsIDOMElement_Release(elem);
404 nsAString_Finish(&font_str);
405 nsAString_Finish(&size_str);
406 nsAString_Finish(&val_str);
408 nsISelection_Release(nsselection);
409 nsIDOMDocument_Release(nsdoc);
412 static BOOL is_visible_text_node(nsIDOMNode *node)
414 nsIDOMCharacterData *char_data;
419 nsIDOMNode_QueryInterface(node, &IID_nsIDOMCharacterData, (void**)&char_data);
421 nsIDOMCharacterData_GetLength(char_data, &len);
423 nsAString_Init(&data_str, NULL);
424 nsIDOMCharacterData_GetData(char_data, &data_str);
425 nsAString_GetData(&data_str, &data, NULL);
429 for(ptr=data+1; ptr && isspaceW(*ptr); ptr++)
433 nsAString_Finish(&data_str);
435 nsIDOMCharacterData_Release(char_data);
440 static nsIDOMNode *get_child_text_node(nsIDOMNode *node, BOOL first)
442 nsIDOMNode *iter, *iter2;
445 nsIDOMNode_GetFirstChild(node, &iter);
447 nsIDOMNode_GetLastChild(node, &iter);
452 nsIDOMNode_GetNodeType(iter, &node_type);
455 if(is_visible_text_node(iter))
458 iter2 = get_child_text_node(iter, first);
460 nsIDOMNode_Release(iter);
466 nsIDOMNode_GetNextSibling(iter, &iter2);
468 nsIDOMNode_GetPreviousSibling(iter, &iter2);
470 nsIDOMNode_Release(iter);
477 static void handle_arrow_key(HTMLDocument *This, nsIDOMKeyEvent *event, const char **cmds)
482 nsIDOMKeyEvent_GetCtrlKey(event, &b);
486 nsIDOMKeyEvent_GetShiftKey(event, &b);
490 do_ns_editor_command(This->nscontainer, cmds[i]);
492 nsIDOMKeyEvent_PreventDefault(event);
495 void handle_edit_event(HTMLDocument *This, nsIDOMEvent *event)
497 nsIDOMKeyEvent *key_event;
500 nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
502 nsIDOMKeyEvent_GetKeyCode(key_event, &code);
506 static const char *cmds[] = {
509 NSCMD_SELECTCHARPREVIOUS,
510 NSCMD_SELECTWORDPREVIOUS
514 handle_arrow_key(This, key_event, cmds);
518 static const char *cmds[] = {
521 NSCMD_SELECTCHARNEXT,
526 handle_arrow_key(This, key_event, cmds);
530 static const char *cmds[] = {
533 NSCMD_SELECTLINEPREVIOUS,
538 handle_arrow_key(This, key_event, cmds);
542 static const char *cmds[] = {
545 NSCMD_SELECTLINENEXT,
550 handle_arrow_key(This, key_event, cmds);
555 nsIDOMKeyEvent_Release(key_event);
558 static void set_ns_fontname(NSContainer *This, const char *fontname)
560 nsICommandParams *nsparam = create_nscommand_params();
562 nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, fontname);
563 do_ns_command(This, NSCMD_FONTFACE, nsparam);
564 nsICommandParams_Release(nsparam);
567 static HRESULT exec_fontname(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
569 TRACE("(%p)->(%p %p)\n", This, in, out);
571 if(!This->nscontainer) {
572 update_doc(This, UPDATE_UI);
580 if(V_VT(in) != VT_BSTR) {
581 FIXME("Unsupported vt=%d\n", V_VT(out));
585 TRACE("%s\n", debugstr_w(V_BSTR(in)));
587 len = WideCharToMultiByte(CP_ACP, 0, V_BSTR(in), -1, NULL, 0, NULL, NULL);
588 stra = mshtml_alloc(len);
589 WideCharToMultiByte(CP_ACP, 0, V_BSTR(in), -1, stra, -1, NULL, NULL);
591 set_ns_fontname(This->nscontainer, stra);
595 update_doc(This, UPDATE_UI);
599 nsICommandParams *nsparam;
605 nsparam = create_nscommand_params();
607 nsres = get_ns_command_state(This->nscontainer, NSCMD_FONTFACE, nsparam);
611 nsICommandParams_GetCStringValue(nsparam, NSSTATE_ATTRIBUTE, &stra);
612 nsICommandParams_Release(nsparam);
614 len = MultiByteToWideChar(CP_ACP, 0, stra, -1, NULL, 0);
615 strw = mshtml_alloc(len*sizeof(WCHAR));
616 MultiByteToWideChar(CP_ACP, 0, stra, -1, strw, -1);
620 V_BSTR(out) = SysAllocString(strw);
627 static HRESULT exec_forecolor(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
629 TRACE("(%p)->(%p %p)\n", This, in, out);
632 if(V_VT(in) == VT_I4) {
633 nsICommandParams *nsparam = create_nscommand_params();
636 sprintf(color_str, "#%02x%02x%02x",
637 V_I4(in)&0xff, (V_I4(in)>>8)&0xff, (V_I4(in)>>16)&0xff);
639 nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, color_str);
640 do_ns_command(This->nscontainer, NSCMD_FONTCOLOR, nsparam);
642 nsICommandParams_Release(nsparam);
644 FIXME("unsupported in vt=%d\n", V_VT(in));
647 update_doc(This, UPDATE_UI);
651 FIXME("unsupported out\n");
658 static HRESULT exec_fontsize(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
660 TRACE("(%p)->(%p %p)\n", This, in, out);
665 get_font_size(This, val);
667 V_I4(out) = strtolW(val, NULL, 10);
674 static const WCHAR format[] = {'%','d',0};
675 wsprintfW(size, format, V_I4(in));
676 set_font_size(This, size);
680 set_font_size(This, V_BSTR(in));
683 FIXME("unsupported vt %d\n", V_VT(in));
686 update_doc(This, UPDATE_UI);
692 static HRESULT exec_bold(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
694 TRACE("(%p)\n", This);
697 FIXME("unsupported args\n");
699 if(This->nscontainer)
700 do_ns_command(This->nscontainer, NSCMD_BOLD, NULL);
702 update_doc(This, UPDATE_UI);
706 static HRESULT exec_italic(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
708 TRACE("(%p)\n", This);
711 FIXME("unsupported args\n");
713 if(This->nscontainer)
714 do_ns_command(This->nscontainer, NSCMD_ITALIC, NULL);
716 update_doc(This, UPDATE_UI);
720 static HRESULT query_justify(HTMLDocument *This, OLECMD *cmd)
723 case IDM_JUSTIFYCENTER:
724 TRACE("(%p) IDM_JUSTIFYCENTER\n", This);
725 cmd->cmdf = query_align_status(This, NSALIGN_CENTER);
727 case IDM_JUSTIFYLEFT:
728 TRACE("(%p) IDM_JUSTIFYLEFT\n", This);
729 /* FIXME: We should set OLECMDF_LATCHED only if it's set explicitly. */
730 if(This->usermode != EDITMODE || This->readystate < READYSTATE_INTERACTIVE)
731 cmd->cmdf = OLECMDF_SUPPORTED;
733 cmd->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
735 case IDM_JUSTIFYRIGHT:
736 TRACE("(%p) IDM_JUSTIFYRIGHT\n", This);
737 cmd->cmdf = query_align_status(This, NSALIGN_RIGHT);
744 static HRESULT exec_justifycenter(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
746 TRACE("(%p)\n", This);
749 FIXME("unsupported args\n");
751 set_ns_align(This, NSALIGN_CENTER);
752 update_doc(This, UPDATE_UI);
756 static HRESULT exec_justifyleft(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
758 TRACE("(%p)\n", This);
761 FIXME("unsupported args\n");
763 set_ns_align(This, NSALIGN_LEFT);
764 update_doc(This, UPDATE_UI);
768 static HRESULT exec_justifyright(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
770 TRACE("(%p)\n", This);
773 FIXME("unsupported args\n");
775 set_ns_align(This, NSALIGN_RIGHT);
776 update_doc(This, UPDATE_UI);
780 static HRESULT exec_underline(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
782 TRACE("(%p)\n", This);
785 FIXME("unsupported args\n");
787 if(This->nscontainer)
788 do_ns_command(This->nscontainer, NSCMD_UNDERLINE, NULL);
790 update_doc(This, UPDATE_UI);
794 static HRESULT exec_horizontalline(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
796 TRACE("(%p)\n", This);
799 FIXME("unsupported args\n");
801 if(This->nscontainer)
802 do_ns_command(This->nscontainer, NSCMD_INSERTHR, NULL);
804 update_doc(This, UPDATE_UI);
808 static HRESULT exec_orderlist(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
810 TRACE("(%p)\n", This);
813 FIXME("unsupported args\n");
815 if(This->nscontainer)
816 do_ns_command(This->nscontainer, NSCMD_OL, NULL);
818 update_doc(This, UPDATE_UI);
822 static HRESULT exec_unorderlist(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
824 TRACE("(%p)\n", This);
827 FIXME("unsupported args\n");
829 if(This->nscontainer)
830 do_ns_command(This->nscontainer, NSCMD_UL, NULL);
832 update_doc(This, UPDATE_UI);
836 static HRESULT exec_indent(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
838 TRACE("(%p)\n", This);
841 FIXME("unsupported args\n");
843 if(This->nscontainer)
844 do_ns_command(This->nscontainer, NSCMD_INDENT, NULL);
846 update_doc(This, UPDATE_UI);
850 static HRESULT exec_outdent(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
852 TRACE("(%p)\n", This);
855 FIXME("unsupported args\n");
857 if(This->nscontainer)
858 do_ns_command(This->nscontainer, NSCMD_OUTDENT, NULL);
860 update_doc(This, UPDATE_UI);
864 static HRESULT exec_composesettings(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
868 if(out || !in || V_VT(in) != VT_BSTR) {
869 WARN("invalid arg\n");
873 TRACE("(%p)->(%x %s)\n", This, cmdexecopt, debugstr_w(V_BSTR(in)));
875 update_doc(This, UPDATE_UI);
879 exec_bold(This, cmdexecopt, NULL, NULL);
880 ptr = strchrW(ptr, ',');
885 exec_italic(This, cmdexecopt, NULL, NULL);
886 ptr = strchrW(ptr, ',');
891 exec_underline(This, cmdexecopt, NULL, NULL);
892 ptr = strchrW(ptr, ',');
896 if(isdigitW(*++ptr)) {
902 exec_fontsize(This, cmdexecopt, &v, NULL);
904 ptr = strchrW(ptr, ',');
909 FIXME("set font color\n");
910 ptr = strchrW(ptr, ',');
915 FIXME("set background color\n");
916 ptr = strchrW(ptr, ',');
925 V_BSTR(&v) = SysAllocString(ptr);
927 exec_fontname(This, cmdexecopt, &v, NULL);
929 SysFreeString(V_BSTR(&v));
935 HRESULT editor_exec_copy(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
937 update_doc(This, UPDATE_UI);
939 if(!This->nscontainer)
942 do_ns_editor_command(This->nscontainer, NSCMD_COPY);
946 HRESULT editor_exec_cut(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
948 update_doc(This, UPDATE_UI);
950 if(!This->nscontainer)
953 do_ns_editor_command(This->nscontainer, NSCMD_CUT);
957 HRESULT editor_exec_paste(HTMLDocument *This, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
959 update_doc(This, UPDATE_UI);
961 if(!This->nscontainer)
964 do_ns_editor_command(This->nscontainer, NSCMD_PASTE);
968 static HRESULT query_edit_status(HTMLDocument *This, OLECMD *cmd)
972 TRACE("CGID_MSHTML: IDM_FONTNAME\n");
973 cmd->cmdf = query_ns_edit_status(This, NULL);
976 TRACE("CGID_MSHTML: IDM_FONTSIZE\n");
977 cmd->cmdf = query_ns_edit_status(This, NULL);
980 TRACE("CGID_MSHTML: IDM_BOLD\n");
981 cmd->cmdf = query_ns_edit_status(This, NSCMD_BOLD);
984 TRACE("CGID_MSHTML: IDM_FORECOLOR\n");
985 cmd->cmdf = query_ns_edit_status(This, NULL);
988 TRACE("CGID_MSHTML: IDM_ITALIC\n");
989 cmd->cmdf = query_ns_edit_status(This, NSCMD_ITALIC);
992 TRACE("CGID_MSHTML: IDM_UNDERLINE\n");
993 cmd->cmdf = query_ns_edit_status(This, NSCMD_UNDERLINE);
995 case IDM_HORIZONTALLINE:
996 TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
997 cmd->cmdf = query_ns_edit_status(This, NULL);
1000 TRACE("CGID_MSHTML: IDM_ORDERLIST\n");
1001 cmd->cmdf = query_ns_edit_status(This, NSCMD_OL);
1003 case IDM_UNORDERLIST:
1004 TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
1005 cmd->cmdf = query_ns_edit_status(This, NSCMD_UL);
1008 TRACE("CGID_MSHTML: IDM_INDENT\n");
1009 cmd->cmdf = query_ns_edit_status(This, NULL);
1012 TRACE("CGID_MSHTML: IDM_OUTDENT\n");
1013 cmd->cmdf = query_ns_edit_status(This, NULL);
1020 const cmdtable_t editmode_cmds[] = {
1021 {IDM_FONTNAME, query_edit_status, exec_fontname},
1022 {IDM_FONTSIZE, query_edit_status, exec_fontsize},
1023 {IDM_FORECOLOR, query_edit_status, exec_forecolor},
1024 {IDM_BOLD, query_edit_status, exec_bold},
1025 {IDM_ITALIC, query_edit_status, exec_italic},
1026 {IDM_JUSTIFYCENTER, query_justify, exec_justifycenter},
1027 {IDM_JUSTIFYRIGHT, query_justify, exec_justifyright},
1028 {IDM_JUSTIFYLEFT, query_justify, exec_justifyleft},
1029 {IDM_UNDERLINE, query_edit_status, exec_underline},
1030 {IDM_HORIZONTALLINE, query_edit_status, exec_horizontalline},
1031 {IDM_ORDERLIST, query_edit_status, exec_orderlist},
1032 {IDM_UNORDERLIST, query_edit_status, exec_unorderlist},
1033 {IDM_INDENT, query_edit_status, exec_indent},
1034 {IDM_OUTDENT, query_edit_status, exec_outdent},
1035 {IDM_COMPOSESETTINGS, NULL, exec_composesettings},
1039 void init_editor(HTMLDocument *This)
1041 update_doc(This, UPDATE_UI);
1043 if(!This->nscontainer)
1046 set_ns_fontname(This->nscontainer, "Times New Roman");