2006-11-24 10:17:54 +01:00
|
|
|
/*
|
2007-06-10 11:52:14 +02:00
|
|
|
* Copyright 2006-2007 Jacek Caban for CodeWeavers
|
2006-11-24 10:17:54 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2007-06-10 11:28:52 +02:00
|
|
|
#include "mshtmcid.h"
|
2013-04-23 12:57:59 +02:00
|
|
|
#include "shlguid.h"
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2007-07-25 00:06:56 +02:00
|
|
|
#include "resource.h"
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2007-06-10 11:30:12 +02:00
|
|
|
#define NSCMD_ALIGN "cmd_align"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_BEGINLINE "cmd_beginLine"
|
2007-06-10 11:30:12 +02:00
|
|
|
#define NSCMD_BOLD "cmd_bold"
|
2007-06-10 11:51:20 +02:00
|
|
|
#define NSCMD_CHARNEXT "cmd_charNext"
|
2007-06-10 11:52:14 +02:00
|
|
|
#define NSCMD_CHARPREVIOUS "cmd_charPrevious"
|
2007-06-11 00:28:48 +02:00
|
|
|
#define NSCMD_COPY "cmd_copy"
|
2007-06-11 00:30:30 +02:00
|
|
|
#define NSCMD_CUT "cmd_cut"
|
2007-06-26 21:14:57 +02:00
|
|
|
#define NSCMD_DELETECHARFORWARD "cmd_deleteCharForward"
|
|
|
|
#define NSCMD_DELETEWORDFORWARD "cmd_deleteWordForward"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_ENDLINE "cmd_endLine"
|
2007-06-10 11:28:52 +02:00
|
|
|
#define NSCMD_FONTCOLOR "cmd_fontColor"
|
|
|
|
#define NSCMD_FONTFACE "cmd_fontFace"
|
2007-06-10 11:31:04 +02:00
|
|
|
#define NSCMD_INDENT "cmd_indent"
|
|
|
|
#define NSCMD_INSERTHR "cmd_insertHR"
|
2007-09-12 11:41:49 +02:00
|
|
|
#define NSCMD_INSERTLINKNOUI "cmd_insertLinkNoUI"
|
2007-06-10 11:30:12 +02:00
|
|
|
#define NSCMD_ITALIC "cmd_italic"
|
2007-06-10 11:50:43 +02:00
|
|
|
#define NSCMD_LINENEXT "cmd_lineNext"
|
2007-06-10 11:49:56 +02:00
|
|
|
#define NSCMD_LINEPREVIOUS "cmd_linePrevious"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_MOVEBOTTOM "cmd_moveBottom"
|
2007-06-10 11:50:43 +02:00
|
|
|
#define NSCMD_MOVEPAGEDOWN "cmd_movePageDown"
|
2007-06-10 11:49:56 +02:00
|
|
|
#define NSCMD_MOVEPAGEUP "cmd_movePageUp"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_MOVETOP "cmd_moveTop"
|
2007-06-10 11:31:04 +02:00
|
|
|
#define NSCMD_OL "cmd_ol"
|
|
|
|
#define NSCMD_OUTDENT "cmd_outdent"
|
2007-06-11 00:29:53 +02:00
|
|
|
#define NSCMD_PASTE "cmd_paste"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_SELECTBEGINLINE "cmd_selectBeginLine"
|
|
|
|
#define NSCMD_SELECTBOTTOM "cmd_selectBottom"
|
2007-06-10 11:51:20 +02:00
|
|
|
#define NSCMD_SELECTCHARNEXT "cmd_selectCharNext"
|
2007-06-10 11:52:14 +02:00
|
|
|
#define NSCMD_SELECTCHARPREVIOUS "cmd_selectCharPrevious"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_SELECTENDLINE "cmd_selectEndLine"
|
2007-06-10 11:50:43 +02:00
|
|
|
#define NSCMD_SELECTLINENEXT "cmd_selectLineNext"
|
2007-06-10 11:49:56 +02:00
|
|
|
#define NSCMD_SELECTLINEPREVIOUS "cmd_selectLinePrevious"
|
2007-06-10 11:50:43 +02:00
|
|
|
#define NSCMD_SELECTPAGEDOWN "cmd_selectPageDown"
|
2007-06-10 11:51:20 +02:00
|
|
|
#define NSCMD_SELECTPAGEUP "cmd_selectPageUp"
|
2007-07-26 02:15:22 +02:00
|
|
|
#define NSCMD_SELECTTOP "cmd_selectTop"
|
2007-06-10 11:51:20 +02:00
|
|
|
#define NSCMD_SELECTWORDNEXT "cmd_selectWordNext"
|
2007-06-10 11:52:14 +02:00
|
|
|
#define NSCMD_SELECTWORDPREVIOUS "cmd_selectWordPrevious"
|
2007-06-10 11:31:04 +02:00
|
|
|
#define NSCMD_UL "cmd_ul"
|
2007-06-10 11:30:12 +02:00
|
|
|
#define NSCMD_UNDERLINE "cmd_underline"
|
2007-06-10 11:51:20 +02:00
|
|
|
#define NSCMD_WORDNEXT "cmd_wordNext"
|
2007-06-10 11:52:14 +02:00
|
|
|
#define NSCMD_WORDPREVIOUS "cmd_wordPrevious"
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
#define NSSTATE_ATTRIBUTE "state_attribute"
|
2007-06-10 11:33:09 +02:00
|
|
|
#define NSSTATE_ALL "state_all"
|
2007-06-10 11:28:52 +02:00
|
|
|
|
2007-06-10 11:30:12 +02:00
|
|
|
#define NSALIGN_CENTER "center"
|
|
|
|
#define NSALIGN_LEFT "left"
|
|
|
|
#define NSALIGN_RIGHT "right"
|
|
|
|
|
2007-06-26 21:14:57 +02:00
|
|
|
#define DOM_VK_LEFT VK_LEFT
|
|
|
|
#define DOM_VK_UP VK_UP
|
|
|
|
#define DOM_VK_RIGHT VK_RIGHT
|
|
|
|
#define DOM_VK_DOWN VK_DOWN
|
|
|
|
#define DOM_VK_DELETE VK_DELETE
|
2007-07-26 02:15:22 +02:00
|
|
|
#define DOM_VK_HOME VK_HOME
|
|
|
|
#define DOM_VK_END VK_END
|
2006-11-30 23:32:05 +01:00
|
|
|
|
2019-03-12 16:10:24 +01:00
|
|
|
void set_dirty(GeckoBrowser *browser, VARIANT_BOOL dirty)
|
2007-11-09 02:23:08 +01:00
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
2019-03-12 16:10:24 +01:00
|
|
|
if(browser->usermode != EDITMODE || !browser->editor)
|
2007-11-09 02:23:08 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if(dirty) {
|
2019-03-12 16:10:24 +01:00
|
|
|
nsres = nsIEditor_IncrementModificationCount(browser->editor, 1);
|
2007-11-09 02:23:08 +01:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("IncrementModificationCount failed: %08lx\n", nsres);
|
2007-11-09 02:23:08 +01:00
|
|
|
}else {
|
2019-03-12 16:10:24 +01:00
|
|
|
nsres = nsIEditor_ResetModificationCount(browser->editor);
|
2007-11-09 02:23:08 +01:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("ResetModificationCount failed: %08lx\n", nsres);
|
2007-11-09 02:23:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static void do_ns_editor_command(GeckoBrowser *This, const char *cmd)
|
2007-06-10 11:49:56 +02:00
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!This->editor_controller)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsres = nsIController_DoCommand(This->editor_controller, cmd);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("DoCommand(%s) failed: %08lx\n", debugstr_a(cmd), nsres);
|
2007-06-10 11:49:56 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static nsresult get_ns_command_state(GeckoBrowser *This, const char *cmd, nsICommandParams *nsparam)
|
2007-06-10 11:28:52 +02:00
|
|
|
{
|
|
|
|
nsICommandManager *cmdmgr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2007-09-26 20:46:37 +02:00
|
|
|
nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsICommandManager, (void**)&cmdmgr);
|
2007-06-10 11:28:52 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsICommandManager: %08lx\n", nsres);
|
2007-06-10 11:28:52 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
nsres = nsICommandManager_GetCommandState(cmdmgr, cmd, This->doc->basedoc.window->window_proxy, nsparam);
|
2007-06-10 11:28:52 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("GetCommandState(%s) failed: %08lx\n", debugstr_a(cmd), nsres);
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
nsICommandManager_Release(cmdmgr);
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static DWORD query_ns_edit_status(HTMLDocumentNode *doc, const char *nscmd)
|
2007-06-10 11:33:09 +02:00
|
|
|
{
|
|
|
|
nsICommandParams *nsparam;
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool b = FALSE;
|
2007-06-10 11:33:09 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
|
2007-06-10 11:33:09 +02:00
|
|
|
return OLECMDF_SUPPORTED;
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
if(nscmd) {
|
2007-06-10 11:33:09 +02:00
|
|
|
nsparam = create_nscommand_params();
|
2019-03-12 16:11:33 +01:00
|
|
|
get_ns_command_state(doc->browser, nscmd, nsparam);
|
2007-06-10 11:33:09 +02:00
|
|
|
|
|
|
|
nsICommandParams_GetBooleanValue(nsparam, NSSTATE_ALL, &b);
|
|
|
|
|
|
|
|
nsICommandParams_Release(nsparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OLECMDF_SUPPORTED | OLECMDF_ENABLED | (b ? OLECMDF_LATCHED : 0);
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static void set_ns_align(HTMLDocumentNode *doc, const char *align_str)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
|
|
|
nsICommandParams *nsparam;
|
|
|
|
|
|
|
|
nsparam = create_nscommand_params();
|
|
|
|
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, align_str);
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_ALIGN, nsparam);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
nsICommandParams_Release(nsparam);
|
|
|
|
}
|
2007-06-10 11:32:27 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static DWORD query_align_status(HTMLDocumentNode *doc, const WCHAR *align)
|
2007-06-10 11:32:27 +02:00
|
|
|
{
|
2010-08-18 13:36:55 +02:00
|
|
|
DWORD ret = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
|
|
|
|
nsAString justify_str;
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool b;
|
2010-08-18 13:36:55 +02:00
|
|
|
nsresult nsres;
|
2007-06-10 11:32:27 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
|
2007-06-10 11:32:27 +02:00
|
|
|
return OLECMDF_SUPPORTED;
|
|
|
|
|
2010-08-18 13:36:55 +02:00
|
|
|
nsAString_Init(&justify_str, align);
|
2019-03-12 16:11:33 +01:00
|
|
|
nsres = nsIDOMHTMLDocument_QueryCommandState(doc->nsdoc, &justify_str, &b);
|
2010-08-18 13:36:55 +02:00
|
|
|
nsAString_Finish(&justify_str);
|
|
|
|
if(NS_SUCCEEDED(nsres) && b)
|
|
|
|
ret |= OLECMDF_LATCHED;
|
|
|
|
|
|
|
|
return ret;
|
2007-06-10 11:32:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static nsISelection *get_ns_selection(HTMLDocumentNode *doc)
|
2006-11-24 10:17:54 +01:00
|
|
|
{
|
|
|
|
nsISelection *nsselection = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsres = nsIDOMWindow_GetSelection(doc->basedoc.window->nswindow, &nsselection);
|
2006-11-24 10:17:54 +01:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("GetSelection failed %08lx\n", nsres);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
return nsselection;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void remove_child_attr(nsIDOMElement *elem, LPCWSTR tag, nsAString *attr_str)
|
|
|
|
{
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool has_children;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 child_cnt, i;
|
2006-11-24 10:17:54 +01:00
|
|
|
nsIDOMNode *child_node;
|
|
|
|
nsIDOMNodeList *node_list;
|
2013-01-23 18:43:55 +01:00
|
|
|
UINT16 node_type;
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
nsIDOMElement_HasChildNodes(elem, &has_children);
|
|
|
|
if(!has_children)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsIDOMElement_GetChildNodes(elem, &node_list);
|
|
|
|
nsIDOMNodeList_GetLength(node_list, &child_cnt);
|
|
|
|
|
|
|
|
for(i=0; i<child_cnt; i++) {
|
|
|
|
nsIDOMNodeList_Item(node_list, i, &child_node);
|
|
|
|
|
|
|
|
nsIDOMNode_GetNodeType(child_node, &node_type);
|
|
|
|
if(node_type == ELEMENT_NODE) {
|
|
|
|
nsIDOMElement *child_elem;
|
|
|
|
nsAString tag_str;
|
|
|
|
const PRUnichar *ctag;
|
|
|
|
|
|
|
|
nsIDOMNode_QueryInterface(child_node, &IID_nsIDOMElement, (void**)&child_elem);
|
|
|
|
|
|
|
|
nsAString_Init(&tag_str, NULL);
|
|
|
|
nsIDOMElement_GetTagName(child_elem, &tag_str);
|
2007-12-17 01:38:30 +01:00
|
|
|
nsAString_GetData(&tag_str, &ctag);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
if(!wcsicmp(ctag, tag))
|
2006-11-24 10:17:54 +01:00
|
|
|
/* FIXME: remove node if there are no more attributes */
|
|
|
|
nsIDOMElement_RemoveAttribute(child_elem, attr_str);
|
|
|
|
|
|
|
|
nsAString_Finish(&tag_str);
|
|
|
|
|
|
|
|
remove_child_attr(child_elem, tag, attr_str);
|
|
|
|
|
2012-07-26 11:37:48 +02:00
|
|
|
nsIDOMElement_Release(child_elem);
|
2006-11-24 10:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMNode_Release(child_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMNodeList_Release(node_list);
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static void get_font_size(HTMLDocumentNode *doc, WCHAR *ret)
|
2006-11-24 10:17:54 +01:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
nsISelection *nsselection = get_ns_selection(doc);
|
2018-02-12 01:28:44 +01:00
|
|
|
nsIDOMElement *elem = NULL;
|
2006-11-24 10:17:54 +01:00
|
|
|
nsIDOMNode *node = NULL, *tmp_node;
|
|
|
|
nsAString tag_str;
|
|
|
|
LPCWSTR tag;
|
2013-01-23 18:43:55 +01:00
|
|
|
UINT16 node_type;
|
2006-11-24 10:17:54 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
*ret = 0;
|
|
|
|
|
|
|
|
if(!nsselection)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsISelection_GetFocusNode(nsselection, &node);
|
|
|
|
nsISelection_Release(nsselection);
|
|
|
|
|
|
|
|
while(node) {
|
|
|
|
nsres = nsIDOMNode_GetNodeType(node, &node_type);
|
|
|
|
if(NS_FAILED(nsres) || node_type == DOCUMENT_NODE)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(node_type == ELEMENT_NODE) {
|
2018-02-12 01:28:44 +01:00
|
|
|
nsIDOMNode_QueryInterface(node, &IID_nsIDOMElement, (void**)&elem);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
nsAString_Init(&tag_str, NULL);
|
2018-02-12 01:28:44 +01:00
|
|
|
nsIDOMElement_GetTagName(elem, &tag_str);
|
2007-12-17 01:38:30 +01:00
|
|
|
nsAString_GetData(&tag_str, &tag);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
if(!wcsicmp(tag, L"font")) {
|
2014-05-27 11:29:11 +02:00
|
|
|
nsAString val_str;
|
|
|
|
const PRUnichar *val;
|
2006-11-24 10:17:54 +01:00
|
|
|
|
2006-11-27 19:20:14 +01:00
|
|
|
TRACE("found font tag %p\n", elem);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
get_elem_attr_value(elem, L"size", &val_str, &val);
|
2006-11-24 10:17:54 +01:00
|
|
|
if(*val) {
|
|
|
|
TRACE("found size %s\n", debugstr_w(val));
|
2019-06-13 08:34:29 +02:00
|
|
|
lstrcpyW(ret, val);
|
2006-11-24 10:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&val_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&tag_str);
|
2018-02-12 01:28:44 +01:00
|
|
|
nsIDOMElement_Release(elem);
|
2006-11-24 10:17:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ret)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_node = node;
|
|
|
|
nsIDOMNode_GetParentNode(node, &node);
|
|
|
|
nsIDOMNode_Release(tmp_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(node)
|
|
|
|
nsIDOMNode_Release(node);
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static void set_font_size(HTMLDocumentNode *doc, LPCWSTR size)
|
2006-11-24 10:17:54 +01:00
|
|
|
{
|
|
|
|
nsISelection *nsselection;
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool collapsed;
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement *elem;
|
2006-11-24 10:17:54 +01:00
|
|
|
nsIDOMRange *range;
|
2013-01-18 14:05:59 +01:00
|
|
|
LONG range_cnt = 0;
|
2006-11-24 10:17:54 +01:00
|
|
|
nsAString size_str;
|
|
|
|
nsAString val_str;
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsselection = get_ns_selection(doc);
|
2006-11-24 10:17:54 +01:00
|
|
|
if(!nsselection)
|
|
|
|
return;
|
|
|
|
|
2007-06-11 17:31:12 +02:00
|
|
|
nsISelection_GetRangeCount(nsselection, &range_cnt);
|
|
|
|
if(range_cnt != 1) {
|
2022-02-15 07:29:41 +01:00
|
|
|
FIXME("range_cnt %ld not supprted\n", range_cnt);
|
2007-06-11 17:31:12 +02:00
|
|
|
if(!range_cnt) {
|
|
|
|
nsISelection_Release(nsselection);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
create_nselem(doc, L"font", &elem);
|
2009-10-19 23:04:50 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
nsAString_InitDepend(&size_str, L"size");
|
2010-01-28 23:55:51 +01:00
|
|
|
nsAString_InitDepend(&val_str, size);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement_SetAttribute(elem, &size_str, &val_str);
|
2010-01-28 23:55:51 +01:00
|
|
|
nsAString_Finish(&val_str);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
nsISelection_GetRangeAt(nsselection, 0, &range);
|
|
|
|
nsISelection_GetIsCollapsed(nsselection, &collapsed);
|
|
|
|
nsISelection_RemoveAllRanges(nsselection);
|
|
|
|
|
|
|
|
nsIDOMRange_SurroundContents(range, (nsIDOMNode*)elem);
|
|
|
|
|
|
|
|
if(collapsed) {
|
|
|
|
nsISelection_Collapse(nsselection, (nsIDOMNode*)elem, 0);
|
|
|
|
}else {
|
2008-04-04 21:23:01 +02:00
|
|
|
/* Remove all size attributes from the range */
|
2020-11-24 23:29:19 +01:00
|
|
|
remove_child_attr(elem, L"font", &size_str);
|
2006-11-24 10:17:54 +01:00
|
|
|
nsISelection_SelectAllChildren(nsselection, (nsIDOMNode*)elem);
|
|
|
|
}
|
|
|
|
|
2008-10-08 20:28:08 +02:00
|
|
|
nsISelection_Release(nsselection);
|
2006-11-24 10:17:54 +01:00
|
|
|
nsIDOMRange_Release(range);
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement_Release(elem);
|
2006-11-24 10:17:54 +01:00
|
|
|
|
|
|
|
nsAString_Finish(&size_str);
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
set_dirty(doc->browser, VARIANT_TRUE);
|
2006-11-24 10:17:54 +01:00
|
|
|
}
|
2006-11-30 23:32:05 +01:00
|
|
|
|
2019-03-12 16:10:39 +01:00
|
|
|
static void handle_arrow_key(HTMLDocumentNode *doc, nsIDOMEvent *event, nsIDOMKeyEvent *key_event, const char * const cmds[4])
|
2007-06-10 11:49:56 +02:00
|
|
|
{
|
|
|
|
int i=0;
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool b;
|
2007-06-10 11:49:56 +02:00
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
nsIDOMKeyEvent_GetCtrlKey(key_event, &b);
|
2007-06-10 11:49:56 +02:00
|
|
|
if(b)
|
|
|
|
i |= 1;
|
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
nsIDOMKeyEvent_GetShiftKey(key_event, &b);
|
2007-06-10 11:49:56 +02:00
|
|
|
if(b)
|
|
|
|
i |= 2;
|
|
|
|
|
2007-06-26 21:14:57 +02:00
|
|
|
if(cmds[i])
|
2019-03-12 16:10:39 +01:00
|
|
|
do_ns_editor_command(doc->browser, cmds[i]);
|
2007-06-10 11:49:56 +02:00
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
nsIDOMEvent_PreventDefault(event);
|
2007-06-10 11:49:56 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 16:10:39 +01:00
|
|
|
void handle_edit_event(HTMLDocumentNode *doc, nsIDOMEvent *event)
|
2006-11-30 23:32:05 +01:00
|
|
|
{
|
|
|
|
nsIDOMKeyEvent *key_event;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 code;
|
2006-11-30 23:32:05 +01:00
|
|
|
|
|
|
|
nsIDOMEvent_QueryInterface(event, &IID_nsIDOMKeyEvent, (void**)&key_event);
|
|
|
|
|
|
|
|
nsIDOMKeyEvent_GetKeyCode(key_event, &code);
|
|
|
|
|
|
|
|
switch(code) {
|
2007-06-10 11:52:14 +02:00
|
|
|
case DOM_VK_LEFT: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-06-10 11:52:14 +02:00
|
|
|
NSCMD_CHARPREVIOUS,
|
|
|
|
NSCMD_WORDPREVIOUS,
|
|
|
|
NSCMD_SELECTCHARPREVIOUS,
|
|
|
|
NSCMD_SELECTWORDPREVIOUS
|
|
|
|
};
|
|
|
|
|
2006-12-04 19:56:58 +01:00
|
|
|
TRACE("left\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2006-11-30 23:32:05 +01:00
|
|
|
break;
|
2007-06-10 11:52:14 +02:00
|
|
|
}
|
2007-06-10 11:51:20 +02:00
|
|
|
case DOM_VK_RIGHT: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-06-10 11:51:20 +02:00
|
|
|
NSCMD_CHARNEXT,
|
|
|
|
NSCMD_WORDNEXT,
|
|
|
|
NSCMD_SELECTCHARNEXT,
|
|
|
|
NSCMD_SELECTWORDNEXT
|
|
|
|
};
|
|
|
|
|
2006-11-30 23:32:05 +01:00
|
|
|
TRACE("right\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-06-10 11:49:56 +02:00
|
|
|
break;
|
2007-06-10 11:51:20 +02:00
|
|
|
}
|
2007-06-10 11:49:56 +02:00
|
|
|
case DOM_VK_UP: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-06-10 11:49:56 +02:00
|
|
|
NSCMD_LINEPREVIOUS,
|
|
|
|
NSCMD_MOVEPAGEUP,
|
|
|
|
NSCMD_SELECTLINEPREVIOUS,
|
|
|
|
NSCMD_SELECTPAGEUP
|
|
|
|
};
|
2007-06-10 11:50:43 +02:00
|
|
|
|
2007-06-10 11:51:20 +02:00
|
|
|
TRACE("up\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-06-10 11:50:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DOM_VK_DOWN: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-06-10 11:50:43 +02:00
|
|
|
NSCMD_LINENEXT,
|
|
|
|
NSCMD_MOVEPAGEDOWN,
|
|
|
|
NSCMD_SELECTLINENEXT,
|
|
|
|
NSCMD_SELECTPAGEDOWN
|
|
|
|
};
|
2007-06-10 11:49:56 +02:00
|
|
|
|
2007-06-10 11:51:20 +02:00
|
|
|
TRACE("down\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-06-10 11:49:56 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-06-26 21:14:57 +02:00
|
|
|
case DOM_VK_DELETE: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-06-26 21:14:57 +02:00
|
|
|
NSCMD_DELETECHARFORWARD,
|
|
|
|
NSCMD_DELETEWORDFORWARD,
|
|
|
|
NULL, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("delete\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-06-26 21:14:57 +02:00
|
|
|
break;
|
2007-07-26 02:15:22 +02:00
|
|
|
}
|
|
|
|
case DOM_VK_HOME: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-07-26 02:15:22 +02:00
|
|
|
NSCMD_BEGINLINE,
|
|
|
|
NSCMD_MOVETOP,
|
|
|
|
NSCMD_SELECTBEGINLINE,
|
|
|
|
NSCMD_SELECTTOP
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("home\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-07-26 02:15:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DOM_VK_END: {
|
2007-07-31 10:48:59 +02:00
|
|
|
static const char * const cmds[] = {
|
2007-07-26 02:15:22 +02:00
|
|
|
NSCMD_ENDLINE,
|
|
|
|
NSCMD_MOVEBOTTOM,
|
|
|
|
NSCMD_SELECTENDLINE,
|
|
|
|
NSCMD_SELECTBOTTOM
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE("end\n");
|
2019-03-12 16:10:39 +01:00
|
|
|
handle_arrow_key(doc, event, key_event, cmds);
|
2007-07-26 02:15:22 +02:00
|
|
|
break;
|
2007-06-26 21:14:57 +02:00
|
|
|
}
|
|
|
|
}
|
2006-11-30 23:32:05 +01:00
|
|
|
|
|
|
|
nsIDOMKeyEvent_Release(key_event);
|
|
|
|
}
|
2007-06-10 11:28:52 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static void set_ns_fontname(HTMLDocumentNode *doc, const char *fontname)
|
2007-06-10 11:44:38 +02:00
|
|
|
{
|
|
|
|
nsICommandParams *nsparam = create_nscommand_params();
|
|
|
|
|
|
|
|
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, fontname);
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_FONTFACE, nsparam);
|
2007-06-10 11:44:38 +02:00
|
|
|
nsICommandParams_Release(nsparam);
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_delete(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-26 21:16:27 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", doc, in, out);
|
2007-06-26 21:16:27 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_editor_command(doc->browser, NSCMD_DELETECHARFORWARD);
|
2007-06-26 21:16:27 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-26 21:16:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_fontname(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:28:52 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", doc, in, out);
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
if(in) {
|
|
|
|
char *stra;
|
|
|
|
|
|
|
|
if(V_VT(in) != VT_BSTR) {
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("Unsupported fontname %s\n", debugstr_variant(out));
|
2007-06-10 11:28:52 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2007-06-10 11:44:38 +02:00
|
|
|
TRACE("%s\n", debugstr_w(V_BSTR(in)));
|
|
|
|
|
2008-03-26 15:32:46 +01:00
|
|
|
stra = heap_strdupWtoA(V_BSTR(in));
|
2019-03-12 16:11:33 +01:00
|
|
|
set_ns_fontname(doc, stra);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(stra);
|
2007-06-10 11:44:38 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(out) {
|
|
|
|
nsICommandParams *nsparam;
|
|
|
|
LPWSTR strw;
|
|
|
|
char *stra;
|
|
|
|
DWORD len;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2007-11-20 01:50:19 +01:00
|
|
|
V_VT(out) = VT_BSTR;
|
|
|
|
V_BSTR(out) = NULL;
|
|
|
|
|
2007-06-10 11:28:52 +02:00
|
|
|
nsparam = create_nscommand_params();
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsres = get_ns_command_state(doc->browser, NSCMD_FONTFACE, nsparam);
|
2007-06-10 11:28:52 +02:00
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
nsICommandParams_GetCStringValue(nsparam, NSSTATE_ATTRIBUTE, &stra);
|
|
|
|
nsICommandParams_Release(nsparam);
|
|
|
|
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, stra, -1, NULL, 0);
|
2007-12-05 21:52:31 +01:00
|
|
|
strw = heap_alloc(len*sizeof(WCHAR));
|
2009-02-04 21:11:31 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, stra, -1, strw, len);
|
2007-06-10 11:28:52 +02:00
|
|
|
nsfree(stra);
|
|
|
|
|
|
|
|
V_BSTR(out) = SysAllocString(strw);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(strw);
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_forecolor(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:28:52 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", doc, in, out);
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
if(in) {
|
|
|
|
if(V_VT(in) == VT_I4) {
|
|
|
|
nsICommandParams *nsparam = create_nscommand_params();
|
|
|
|
char color_str[10];
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
sprintf(color_str, "#%02lx%02lx%02lx",
|
2007-06-10 11:28:52 +02:00
|
|
|
V_I4(in)&0xff, (V_I4(in)>>8)&0xff, (V_I4(in)>>16)&0xff);
|
|
|
|
|
|
|
|
nsICommandParams_SetCStringValue(nsparam, NSSTATE_ATTRIBUTE, color_str);
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_FONTCOLOR, nsparam);
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
nsICommandParams_Release(nsparam);
|
|
|
|
}else {
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unsupported forecolor %s\n", debugstr_variant(in));
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
2007-06-10 11:47:52 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(out) {
|
|
|
|
FIXME("unsupported out\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_fontsize(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:28:52 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", doc, in, out);
|
2007-06-10 11:28:52 +02:00
|
|
|
|
|
|
|
if(out) {
|
|
|
|
WCHAR val[10] = {0};
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
get_font_size(doc, val);
|
2007-06-22 03:06:02 +02:00
|
|
|
V_VT(out) = VT_I4;
|
2019-06-13 08:34:29 +02:00
|
|
|
V_I4(out) = wcstol(val, NULL, 10);
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(in) {
|
|
|
|
switch(V_VT(in)) {
|
|
|
|
case VT_I4: {
|
|
|
|
WCHAR size[10];
|
2020-11-24 23:29:19 +01:00
|
|
|
wsprintfW(size, L"%d", V_I4(in));
|
2019-03-12 16:11:33 +01:00
|
|
|
set_font_size(doc, size);
|
2007-06-10 11:28:52 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VT_BSTR:
|
2019-03-12 16:11:33 +01:00
|
|
|
set_font_size(doc, V_BSTR(in));
|
2007-06-10 11:28:52 +02:00
|
|
|
break;
|
|
|
|
default:
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unsupported fontsize %s\n", debugstr_variant(in));
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
2007-06-10 11:47:52 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:28:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_font(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-09-19 13:35:30 +02:00
|
|
|
{
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", doc, in, out);
|
2007-09-19 13:35:30 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_bold(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_BOLD, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_italic(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_ITALIC, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT query_justify(HTMLDocumentNode *doc, OLECMD *cmd)
|
2007-06-10 11:32:27 +02:00
|
|
|
{
|
|
|
|
switch(cmd->cmdID) {
|
|
|
|
case IDM_JUSTIFYCENTER:
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p) IDM_JUSTIFYCENTER\n", doc);
|
2020-11-24 00:49:06 +01:00
|
|
|
cmd->cmdf = query_align_status(doc, L"justifycenter");
|
2007-06-10 11:32:27 +02:00
|
|
|
break;
|
|
|
|
case IDM_JUSTIFYLEFT:
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p) IDM_JUSTIFYLEFT\n", doc);
|
2007-06-10 11:42:00 +02:00
|
|
|
/* FIXME: We should set OLECMDF_LATCHED only if it's set explicitly. */
|
2019-03-12 16:11:33 +01:00
|
|
|
if(doc->browser->usermode != EDITMODE || doc->basedoc.window->readystate < READYSTATE_INTERACTIVE)
|
2007-06-10 11:42:00 +02:00
|
|
|
cmd->cmdf = OLECMDF_SUPPORTED;
|
|
|
|
else
|
|
|
|
cmd->cmdf = OLECMDF_SUPPORTED | OLECMDF_ENABLED;
|
2007-06-10 11:32:27 +02:00
|
|
|
break;
|
|
|
|
case IDM_JUSTIFYRIGHT:
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p) IDM_JUSTIFYRIGHT\n", doc);
|
2020-11-24 00:49:06 +01:00
|
|
|
cmd->cmdf = query_align_status(doc, L"justifyright");
|
2007-06-10 11:32:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_justifycenter(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
set_ns_align(doc, NSALIGN_CENTER);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_justifyleft(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
set_ns_align(doc, NSALIGN_LEFT);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_justifyright(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:47:52 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
set_ns_align(doc, NSALIGN_RIGHT);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_underline(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:30:12 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:30:12 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_UNDERLINE, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:30:12 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_horizontalline(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:31:04 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_INSERTHR, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_orderlist(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:31:04 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_OL, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_unorderlist(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:31:04 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_UL, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_indent(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:31:04 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_INDENT, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_outdent(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
TRACE("(%p)\n", doc);
|
2007-06-10 11:31:04 +02:00
|
|
|
|
|
|
|
if(in || out)
|
|
|
|
FIXME("unsupported args\n");
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
do_ns_command(doc, NSCMD_OUTDENT, NULL);
|
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_composesettings(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-10 11:31:04 +02:00
|
|
|
{
|
2007-06-11 00:20:30 +02:00
|
|
|
WCHAR *ptr;
|
|
|
|
|
2007-06-10 11:31:04 +02:00
|
|
|
if(out || !in || V_VT(in) != VT_BSTR) {
|
2012-03-28 14:27:20 +02:00
|
|
|
WARN("invalid arg %s\n", debugstr_variant(in));
|
2007-06-10 11:31:04 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p)->(%lx %s)\n", doc, cmdexecopt, debugstr_w(V_BSTR(in)));
|
2007-06-10 11:31:04 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-11 00:20:30 +02:00
|
|
|
|
|
|
|
ptr = V_BSTR(in);
|
|
|
|
if(*ptr == '1')
|
2019-03-12 16:11:33 +01:00
|
|
|
exec_bold(doc, cmdexecopt, NULL, NULL);
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(*++ptr == '1')
|
2019-03-12 16:11:33 +01:00
|
|
|
exec_italic(doc, cmdexecopt, NULL, NULL);
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(*++ptr == '1')
|
2019-03-12 16:11:33 +01:00
|
|
|
exec_underline(doc, cmdexecopt, NULL, NULL);
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
2019-11-12 20:49:03 +01:00
|
|
|
if(is_digit(*++ptr)) {
|
2007-06-11 00:20:30 +02:00
|
|
|
VARIANT v;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_I4;
|
|
|
|
V_I4(&v) = *ptr-'0';
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
exec_fontsize(doc, cmdexecopt, &v, NULL);
|
2007-06-11 00:20:30 +02:00
|
|
|
}
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(*++ptr != ',')
|
|
|
|
FIXME("set font color\n");
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(*++ptr != ',')
|
|
|
|
FIXME("set background color\n");
|
2019-06-13 08:34:29 +02:00
|
|
|
ptr = wcschr(ptr, ',');
|
2007-06-11 00:20:30 +02:00
|
|
|
if(!ptr)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
if(*ptr) {
|
|
|
|
VARIANT v;
|
|
|
|
|
|
|
|
V_VT(&v) = VT_BSTR;
|
|
|
|
V_BSTR(&v) = SysAllocString(ptr);
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
exec_fontname(doc, cmdexecopt, &v, NULL);
|
2007-06-11 00:20:30 +02:00
|
|
|
|
|
|
|
SysFreeString(V_BSTR(&v));
|
|
|
|
}
|
|
|
|
|
2007-06-10 11:31:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
HRESULT editor_exec_copy(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-11 00:28:48 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
|
|
|
do_ns_editor_command(doc->browser, NSCMD_COPY);
|
2007-06-11 00:28:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
HRESULT editor_exec_cut(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-11 00:30:30 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
|
|
|
do_ns_editor_command(doc->browser, NSCMD_CUT);
|
2007-06-11 00:30:30 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
HRESULT editor_exec_paste(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-06-11 00:29:53 +02:00
|
|
|
{
|
2019-03-12 16:11:33 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
|
|
|
do_ns_editor_command(doc->browser, NSCMD_PASTE);
|
2007-06-11 00:29:53 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_setdirty(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-11-09 02:23:08 +01:00
|
|
|
{
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p)->(%08lx %p %p)\n", doc, cmdexecopt, in, out);
|
2007-11-09 02:23:08 +01:00
|
|
|
|
2008-01-10 12:53:38 +01:00
|
|
|
if(!in)
|
2007-11-09 02:23:08 +01:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(V_VT(in) == VT_BOOL)
|
2019-03-12 16:11:33 +01:00
|
|
|
set_dirty(doc->browser, V_BOOL(in));
|
2007-11-09 02:23:08 +01:00
|
|
|
else
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unsupported arg %s\n", debugstr_variant(in));
|
2007-11-09 02:23:08 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT query_edit_status(HTMLDocumentNode *doc, OLECMD *cmd)
|
2007-06-10 11:33:09 +02:00
|
|
|
{
|
|
|
|
switch(cmd->cmdID) {
|
2007-06-26 21:15:54 +02:00
|
|
|
case IDM_DELETE:
|
|
|
|
TRACE("CGID_MSHTML: IDM_DELETE\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-26 21:15:54 +02:00
|
|
|
break;
|
2007-06-10 11:33:09 +02:00
|
|
|
case IDM_FONTNAME:
|
|
|
|
TRACE("CGID_MSHTML: IDM_FONTNAME\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_FONTSIZE:
|
|
|
|
TRACE("CGID_MSHTML: IDM_FONTSIZE\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_BOLD:
|
|
|
|
TRACE("CGID_MSHTML: IDM_BOLD\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NSCMD_BOLD);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_FORECOLOR:
|
|
|
|
TRACE("CGID_MSHTML: IDM_FORECOLOR\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_ITALIC:
|
|
|
|
TRACE("CGID_MSHTML: IDM_ITALIC\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NSCMD_ITALIC);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_UNDERLINE:
|
|
|
|
TRACE("CGID_MSHTML: IDM_UNDERLINE\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NSCMD_UNDERLINE);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_HORIZONTALLINE:
|
|
|
|
TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_ORDERLIST:
|
|
|
|
TRACE("CGID_MSHTML: IDM_ORDERLIST\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NSCMD_OL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_UNORDERLIST:
|
|
|
|
TRACE("CGID_MSHTML: IDM_HORIZONTALLINE\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NSCMD_UL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_INDENT:
|
|
|
|
TRACE("CGID_MSHTML: IDM_INDENT\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
|
|
|
case IDM_OUTDENT:
|
|
|
|
TRACE("CGID_MSHTML: IDM_OUTDENT\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-06-10 11:33:09 +02:00
|
|
|
break;
|
2007-09-12 11:41:49 +02:00
|
|
|
case IDM_HYPERLINK:
|
|
|
|
TRACE("CGID_MSHTML: IDM_HYPERLINK\n");
|
2019-03-12 16:11:33 +01:00
|
|
|
cmd->cmdf = query_ns_edit_status(doc, NULL);
|
2007-09-12 11:41:49 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR CALLBACK hyperlink_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
INT def_idx;
|
|
|
|
HWND hwndCB = GetDlgItem(hwnd, IDC_TYPE);
|
|
|
|
HWND hwndURL = GetDlgItem(hwnd, IDC_URL);
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"(other)");
|
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"file:");
|
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"ftp:");
|
|
|
|
def_idx = SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"http:");
|
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"https:");
|
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"mailto:");
|
|
|
|
SendMessageW(hwndCB, CB_INSERTSTRING, -1, (LPARAM)L"news:");
|
2007-09-12 11:41:49 +02:00
|
|
|
SendMessageW(hwndCB, CB_SETCURSEL, def_idx, 0);
|
|
|
|
|
|
|
|
/* force the updating of the URL edit box */
|
|
|
|
SendMessageW(hwnd, WM_COMMAND, MAKEWPARAM(IDC_TYPE, CBN_SELCHANGE), (LPARAM)hwndCB);
|
|
|
|
|
|
|
|
SetFocus(hwndURL);
|
|
|
|
len = SendMessageW(hwndURL, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
SendMessageW(hwndURL, EM_SETSEL, 0, len);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (wparam)
|
|
|
|
{
|
|
|
|
case MAKEWPARAM(IDCANCEL, BN_CLICKED):
|
|
|
|
EndDialog(hwnd, wparam);
|
|
|
|
return TRUE;
|
|
|
|
case MAKEWPARAM(IDOK, BN_CLICKED):
|
|
|
|
{
|
|
|
|
BSTR *url = (BSTR *)GetWindowLongPtrW(hwnd, DWLP_USER);
|
|
|
|
HWND hwndURL = GetDlgItem(hwnd, IDC_URL);
|
|
|
|
INT len = GetWindowTextLengthW(hwndURL);
|
|
|
|
*url = SysAllocStringLen(NULL, len + 1);
|
|
|
|
GetWindowTextW(hwndURL, *url, len + 1);
|
|
|
|
EndDialog(hwnd, wparam);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
case MAKEWPARAM(IDC_TYPE, CBN_SELCHANGE):
|
|
|
|
{
|
|
|
|
HWND hwndURL = GetDlgItem(hwnd, IDC_URL);
|
|
|
|
INT item;
|
|
|
|
INT len;
|
|
|
|
LPWSTR type;
|
|
|
|
LPWSTR url;
|
|
|
|
LPWSTR p;
|
|
|
|
static const WCHAR wszSlashSlash[] = {'/','/'};
|
|
|
|
|
|
|
|
/* get string of currently selected hyperlink type */
|
|
|
|
item = SendMessageW((HWND)lparam, CB_GETCURSEL, 0, 0);
|
|
|
|
len = SendMessageW((HWND)lparam, CB_GETLBTEXTLEN, item, 0);
|
|
|
|
type = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
|
|
|
SendMessageW((HWND)lparam, CB_GETLBTEXT, item, (LPARAM)type);
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
if (!wcscmp(type, L"(other)"))
|
2007-09-12 11:41:49 +02:00
|
|
|
*type = '\0';
|
|
|
|
|
|
|
|
/* get current URL */
|
|
|
|
len = GetWindowTextLengthW(hwndURL);
|
2019-06-13 08:34:29 +02:00
|
|
|
url = HeapAlloc(GetProcessHeap(), 0, (len + lstrlenW(type) + 3) * sizeof(WCHAR));
|
2007-09-12 11:41:49 +02:00
|
|
|
GetWindowTextW(hwndURL, url, len + 1);
|
|
|
|
|
|
|
|
/* strip off old protocol */
|
2019-06-13 08:34:29 +02:00
|
|
|
p = wcschr(url, ':');
|
2007-09-12 11:41:49 +02:00
|
|
|
if (p && p[1] == '/' && p[2] == '/')
|
|
|
|
p += 3;
|
|
|
|
if (!p) p = url;
|
2019-06-13 08:34:29 +02:00
|
|
|
memmove(url + (*type != '\0' ? lstrlenW(type) + 2 : 0), p, (len + 1 - (p - url)) * sizeof(WCHAR));
|
2007-09-12 11:41:49 +02:00
|
|
|
|
|
|
|
/* add new protocol */
|
|
|
|
if (*type != '\0')
|
|
|
|
{
|
2019-06-13 08:34:29 +02:00
|
|
|
memcpy(url, type, (lstrlenW(type) + 1) * sizeof(WCHAR));
|
2020-11-24 23:29:19 +01:00
|
|
|
if (wcscmp(type, L"mailto:") && wcscmp(type, L"news:"))
|
2019-06-13 08:34:29 +02:00
|
|
|
memcpy(url + lstrlenW(type), wszSlashSlash, sizeof(wszSlashSlash));
|
2007-09-12 11:41:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowTextW(hwndURL, url);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, url);
|
|
|
|
HeapFree(GetProcessHeap(), 0, type);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hwnd, IDCANCEL);
|
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2007-06-10 11:33:09 +02:00
|
|
|
}
|
2007-09-12 11:41:49 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
static HRESULT exec_hyperlink(HTMLDocumentNode *doc, DWORD cmdexecopt, VARIANT *in, VARIANT *out)
|
2007-09-12 11:41:49 +02:00
|
|
|
{
|
2009-10-19 23:05:05 +02:00
|
|
|
nsAString href_str, ns_url;
|
2008-10-08 20:28:19 +02:00
|
|
|
nsIHTMLEditor *html_editor;
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement *anchor_elem;
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool insert_link_at_caret;
|
2008-10-08 20:28:19 +02:00
|
|
|
nsISelection *nsselection;
|
2007-09-12 11:41:49 +02:00
|
|
|
BSTR url = NULL;
|
|
|
|
INT ret;
|
2008-02-18 01:07:24 +01:00
|
|
|
HRESULT hres = E_FAIL;
|
2007-09-12 11:41:49 +02:00
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("%p, 0x%lx, %p, %p\n", doc, cmdexecopt, in, out);
|
2007-09-12 11:41:49 +02:00
|
|
|
|
|
|
|
if (cmdexecopt == OLECMDEXECOPT_DONTPROMPTUSER)
|
|
|
|
{
|
|
|
|
if (!in || V_VT(in) != VT_BSTR)
|
|
|
|
{
|
|
|
|
WARN("invalid arg\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
url = V_BSTR(in);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_HYPERLINK), NULL /* FIXME */, hyperlink_dlgproc, (LPARAM)&url);
|
|
|
|
if (ret != IDOK)
|
|
|
|
return OLECMDERR_E_CANCELED;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
if(!doc->nsdoc) {
|
2008-10-08 20:28:19 +02:00
|
|
|
WARN("NULL nsdoc\n");
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsselection = get_ns_selection(doc);
|
2007-09-12 11:41:49 +02:00
|
|
|
if (!nsselection)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2008-10-08 20:28:19 +02:00
|
|
|
/* create an element for the link */
|
2020-11-24 23:29:19 +01:00
|
|
|
create_nselem(doc, L"a", &anchor_elem);
|
2007-09-12 11:41:49 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
nsAString_InitDepend(&href_str, L"href");
|
2010-01-28 23:55:51 +01:00
|
|
|
nsAString_InitDepend(&ns_url, url);
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement_SetAttribute(anchor_elem, &href_str, &ns_url);
|
2008-10-08 20:28:19 +02:00
|
|
|
nsAString_Finish(&href_str);
|
2007-09-12 11:41:49 +02:00
|
|
|
|
2008-10-08 20:28:19 +02:00
|
|
|
nsISelection_GetIsCollapsed(nsselection, &insert_link_at_caret);
|
|
|
|
|
|
|
|
/* create an element with text of URL */
|
|
|
|
if (insert_link_at_caret) {
|
2014-09-30 10:30:33 +02:00
|
|
|
nsIDOMNode *unused_node;
|
|
|
|
nsIDOMText *text_node;
|
2008-10-08 20:28:19 +02:00
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsIDOMHTMLDocument_CreateTextNode(doc->nsdoc, &ns_url, &text_node);
|
2008-10-08 20:28:19 +02:00
|
|
|
|
|
|
|
/* wrap the <a> tags around the text element */
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement_AppendChild(anchor_elem, (nsIDOMNode*)text_node, &unused_node);
|
2014-09-30 10:30:33 +02:00
|
|
|
nsIDOMText_Release(text_node);
|
2008-10-08 20:28:19 +02:00
|
|
|
nsIDOMNode_Release(unused_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&ns_url);
|
|
|
|
|
2019-03-12 16:11:33 +01:00
|
|
|
nsIEditor_QueryInterface(doc->browser->editor, &IID_nsIHTMLEditor, (void **)&html_editor);
|
2008-10-08 20:28:19 +02:00
|
|
|
if (html_editor) {
|
|
|
|
nsresult nsres;
|
2007-09-12 11:41:49 +02:00
|
|
|
|
2008-10-08 20:28:19 +02:00
|
|
|
if (insert_link_at_caret) {
|
|
|
|
/* add them to the document at the caret position */
|
2019-02-18 21:14:00 +01:00
|
|
|
nsres = nsIHTMLEditor_InsertElementAtSelection(html_editor, anchor_elem, FALSE);
|
2008-10-08 20:28:19 +02:00
|
|
|
nsISelection_SelectAllChildren(nsselection, (nsIDOMNode*)anchor_elem);
|
|
|
|
}else /* add them around the selection using the magic provided to us by nsIHTMLEditor */
|
2019-02-18 21:14:00 +01:00
|
|
|
nsres = nsIHTMLEditor_InsertLinkAroundSelection(html_editor, anchor_elem);
|
2008-02-18 01:07:24 +01:00
|
|
|
|
2008-10-08 20:28:19 +02:00
|
|
|
nsIHTMLEditor_Release(html_editor);
|
2008-02-18 01:07:24 +01:00
|
|
|
hres = NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
|
2007-09-12 11:41:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsISelection_Release(nsselection);
|
2018-02-12 01:30:27 +01:00
|
|
|
nsIDOMElement_Release(anchor_elem);
|
2007-09-12 11:41:49 +02:00
|
|
|
|
|
|
|
if (cmdexecopt != OLECMDEXECOPT_DONTPROMPTUSER)
|
|
|
|
SysFreeString(url);
|
2007-06-10 11:33:09 +02:00
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("-- 0x%08lx\n", hres);
|
2008-02-18 01:07:24 +01:00
|
|
|
return hres;
|
2007-06-10 11:33:09 +02:00
|
|
|
}
|
|
|
|
|
2007-06-10 11:28:52 +02:00
|
|
|
const cmdtable_t editmode_cmds[] = {
|
2007-06-26 21:16:27 +02:00
|
|
|
{IDM_DELETE, query_edit_status, exec_delete},
|
2007-06-10 11:33:09 +02:00
|
|
|
{IDM_FONTNAME, query_edit_status, exec_fontname},
|
|
|
|
{IDM_FONTSIZE, query_edit_status, exec_fontsize},
|
|
|
|
{IDM_FORECOLOR, query_edit_status, exec_forecolor},
|
|
|
|
{IDM_BOLD, query_edit_status, exec_bold},
|
|
|
|
{IDM_ITALIC, query_edit_status, exec_italic},
|
|
|
|
{IDM_JUSTIFYCENTER, query_justify, exec_justifycenter},
|
|
|
|
{IDM_JUSTIFYRIGHT, query_justify, exec_justifyright},
|
|
|
|
{IDM_JUSTIFYLEFT, query_justify, exec_justifyleft},
|
2007-09-19 13:35:30 +02:00
|
|
|
{IDM_FONT, NULL, exec_font},
|
2007-06-10 11:33:09 +02:00
|
|
|
{IDM_UNDERLINE, query_edit_status, exec_underline},
|
|
|
|
{IDM_HORIZONTALLINE, query_edit_status, exec_horizontalline},
|
|
|
|
{IDM_ORDERLIST, query_edit_status, exec_orderlist},
|
|
|
|
{IDM_UNORDERLIST, query_edit_status, exec_unorderlist},
|
|
|
|
{IDM_INDENT, query_edit_status, exec_indent},
|
|
|
|
{IDM_OUTDENT, query_edit_status, exec_outdent},
|
|
|
|
{IDM_COMPOSESETTINGS, NULL, exec_composesettings},
|
2007-09-12 11:41:49 +02:00
|
|
|
{IDM_HYPERLINK, query_edit_status, exec_hyperlink},
|
2007-11-09 02:23:08 +01:00
|
|
|
{IDM_SETDIRTY, NULL, exec_setdirty},
|
2007-06-10 11:28:52 +02:00
|
|
|
{0,NULL,NULL}
|
|
|
|
};
|
2007-06-10 11:44:38 +02:00
|
|
|
|
2019-03-12 16:11:58 +01:00
|
|
|
void init_editor(HTMLDocumentNode *doc)
|
2007-06-10 11:44:38 +02:00
|
|
|
{
|
2019-03-12 16:11:58 +01:00
|
|
|
update_doc(doc->browser->doc, UPDATE_UI);
|
2007-06-10 11:48:36 +02:00
|
|
|
|
2019-03-12 16:11:58 +01:00
|
|
|
set_ns_fontname(doc, "Times New Roman");
|
2007-06-10 11:44:38 +02:00
|
|
|
}
|
2007-09-12 11:42:01 +02:00
|
|
|
|
2019-03-12 16:11:10 +01:00
|
|
|
HRESULT browser_is_dirty(GeckoBrowser *browser)
|
2007-09-12 11:42:01 +02:00
|
|
|
{
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool modified;
|
2007-09-12 11:42:01 +02:00
|
|
|
|
2019-03-12 16:11:10 +01:00
|
|
|
if(browser->usermode != EDITMODE || !browser->editor)
|
2007-09-12 11:42:01 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
2019-03-12 16:11:10 +01:00
|
|
|
nsIEditor_GetDocumentModified(browser->editor, &modified);
|
2007-09-12 11:42:01 +02:00
|
|
|
return modified ? S_OK : S_FALSE;
|
|
|
|
}
|
2013-04-23 12:57:59 +02:00
|
|
|
|
|
|
|
HRESULT setup_edit_mode(HTMLDocumentObj *doc)
|
|
|
|
{
|
|
|
|
IMoniker *mon;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2019-03-12 16:10:24 +01:00
|
|
|
if(doc->nscontainer->usermode == EDITMODE)
|
2013-04-23 12:57:59 +02:00
|
|
|
return S_OK;
|
|
|
|
|
2019-03-12 16:10:24 +01:00
|
|
|
doc->nscontainer->usermode = EDITMODE;
|
2013-04-23 12:57:59 +02:00
|
|
|
|
|
|
|
if(doc->basedoc.window->mon) {
|
|
|
|
CLSID clsid = IID_NULL;
|
|
|
|
hres = IMoniker_GetClassID(doc->basedoc.window->mon, &clsid);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
/* We should use IMoniker::Save here */
|
|
|
|
FIXME("Use CLSID %s\n", debugstr_guid(&clsid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doc->frame)
|
|
|
|
IOleInPlaceFrame_SetStatusText(doc->frame, NULL);
|
|
|
|
|
|
|
|
doc->basedoc.window->readystate = READYSTATE_UNINITIALIZED;
|
|
|
|
|
|
|
|
if(doc->client) {
|
|
|
|
IOleCommandTarget *cmdtrg;
|
|
|
|
|
|
|
|
hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&cmdtrg);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
VARIANT var;
|
|
|
|
|
|
|
|
V_VT(&var) = VT_I4;
|
|
|
|
V_I4(&var) = 0;
|
|
|
|
IOleCommandTarget_Exec(cmdtrg, &CGID_ShellDocView, 37, 0, &var, NULL);
|
|
|
|
|
|
|
|
IOleCommandTarget_Release(cmdtrg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doc->hostui) {
|
|
|
|
DOCHOSTUIINFO hostinfo;
|
|
|
|
|
|
|
|
memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
|
|
|
|
hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
|
|
|
|
hres = IDocHostUIHandler_GetHostInfo(doc->hostui, &hostinfo);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
/* FIXME: use hostinfo */
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
|
2013-04-23 12:57:59 +02:00
|
|
|
hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
|
|
|
|
debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
|
|
|
|
}
|
|
|
|
|
2017-11-22 16:15:48 +01:00
|
|
|
update_doc(doc, UPDATE_UI);
|
2013-04-23 12:57:59 +02:00
|
|
|
|
|
|
|
if(doc->basedoc.window->mon) {
|
|
|
|
/* FIXME: We should find nicer way to do this */
|
2017-11-23 17:36:51 +01:00
|
|
|
remove_target_tasks(doc->task_magic);
|
2013-04-23 12:57:59 +02:00
|
|
|
|
|
|
|
mon = doc->basedoc.window->mon;
|
|
|
|
IMoniker_AddRef(mon);
|
|
|
|
}else {
|
2020-11-24 23:29:19 +01:00
|
|
|
hres = CreateURLMoniker(NULL, L"about:blank", &mon);
|
2013-04-23 12:57:59 +02:00
|
|
|
if(FAILED(hres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
FIXME("CreateURLMoniker failed: %08lx\n", hres);
|
2013-04-23 12:57:59 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IPersistMoniker_Load(&doc->basedoc.IPersistMoniker_iface, TRUE, mon, NULL, 0);
|
|
|
|
IMoniker_Release(mon);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(doc->ui_active) {
|
|
|
|
if(doc->ip_window)
|
|
|
|
call_set_active_object(doc->ip_window, NULL);
|
|
|
|
if(doc->hostui)
|
|
|
|
IDocHostUIHandler_HideUI(doc->hostui);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doc->ui_active) {
|
|
|
|
RECT rcBorderWidths;
|
|
|
|
|
|
|
|
if(doc->hostui)
|
|
|
|
IDocHostUIHandler_ShowUI(doc->hostui, DOCHOSTUITYPE_AUTHOR,
|
|
|
|
&doc->basedoc.IOleInPlaceActiveObject_iface, &doc->basedoc.IOleCommandTarget_iface,
|
|
|
|
doc->frame, doc->ip_window);
|
|
|
|
|
|
|
|
if(doc->ip_window)
|
|
|
|
call_set_active_object(doc->ip_window, &doc->basedoc.IOleInPlaceActiveObject_iface);
|
|
|
|
|
2016-07-30 22:06:02 +02:00
|
|
|
SetRectEmpty(&rcBorderWidths);
|
2013-04-23 12:57:59 +02:00
|
|
|
if(doc->frame)
|
|
|
|
IOleInPlaceFrame_SetBorderSpace(doc->frame, &rcBorderWidths);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|