2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:21:17 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-04-05 23:34:08 +00:00
|
|
|
*
|
2004-04-18 14:21:17 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2001-04-05 23:34:08 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-04-05 23:34:08 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:21:17 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 22:53:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-04-05 23:34:08 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Contributor(s):
|
2001-04-05 23:34:08 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
* Ryan Cassin <rcassin@supernova.org>
|
2002-01-09 13:51:37 +00:00
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
2001-09-25 22:53:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:21:17 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 22:53:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:21:17 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 22:53:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:21:17 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 22:53:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-04-05 23:34:08 +00:00
|
|
|
|
2003-04-10 18:44:03 +00:00
|
|
|
#include "nsIControllerCommandTable.h"
|
2001-04-05 23:34:08 +00:00
|
|
|
#include "nsComposerController.h"
|
|
|
|
#include "nsComposerCommands.h"
|
|
|
|
|
|
|
|
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd; \
|
|
|
|
NS_NEWXPCOM(theCmd, _cmdClass); \
|
|
|
|
if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd; \
|
|
|
|
NS_NEWXPCOM(theCmd, _cmdClass); \
|
|
|
|
if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd));
|
|
|
|
|
|
|
|
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd));
|
|
|
|
|
|
|
|
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_REGISTER_STYLE_COMMAND(_cmdClass, _cmdName, _styleTag) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd = new _cmdClass(_styleTag); \
|
|
|
|
if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \
|
|
|
|
}
|
|
|
|
|
2002-11-20 01:20:19 +00:00
|
|
|
#define NS_REGISTER_TAG_COMMAND(_cmdClass, _cmdName, _tagName) \
|
|
|
|
{ \
|
|
|
|
_cmdClass* theCmd = new _cmdClass(_tagName); \
|
|
|
|
if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
|
2003-04-10 18:44:03 +00:00
|
|
|
rv = inCommandTable->RegisterCommand(_cmdName, \
|
2002-11-20 01:20:19 +00:00
|
|
|
NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \
|
|
|
|
}
|
|
|
|
|
2001-04-05 23:34:08 +00:00
|
|
|
|
|
|
|
// static
|
2002-11-12 23:03:27 +00:00
|
|
|
nsresult
|
|
|
|
nsComposerController::RegisterEditorDocStateCommands(
|
2003-04-10 18:44:03 +00:00
|
|
|
nsIControllerCommandTable *inCommandTable)
|
2002-11-12 23:03:27 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// observer commands for document state
|
2003-04-10 18:44:03 +00:00
|
|
|
NS_REGISTER_FIRST_COMMAND(nsDocumentStateCommand, "obs_documentCreated")
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsDocumentStateCommand, "obs_documentWillBeDestroyed")
|
|
|
|
NS_REGISTER_LAST_COMMAND(nsDocumentStateCommand, "obs_documentLocationChanged")
|
2002-11-12 23:03:27 +00:00
|
|
|
|
|
|
|
// commands that may get or change state
|
2003-04-10 18:44:03 +00:00
|
|
|
NS_REGISTER_FIRST_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentModified")
|
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentUseCSS")
|
2005-06-02 03:11:35 +00:00
|
|
|
NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentReadOnly")
|
|
|
|
NS_REGISTER_LAST_COMMAND(nsSetDocumentStateCommand, "cmd_insertBrOnReturn")
|
2003-04-15 13:53:51 +00:00
|
|
|
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsSetDocumentOptionsCommand, "cmd_setDocumentOptions")
|
|
|
|
|
2002-11-12 23:03:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
nsresult
|
|
|
|
nsComposerController::RegisterHTMLEditorCommands(
|
2003-04-10 18:44:03 +00:00
|
|
|
nsIControllerCommandTable *inCommandTable)
|
2001-04-05 23:34:08 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Edit menu
|
2002-10-06 01:23:18 +00:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
|
2001-04-05 23:34:08 +00:00
|
|
|
|
|
|
|
// indent/outdent
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsIndentCommand, "cmd_indent");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsOutdentCommand, "cmd_outdent");
|
|
|
|
|
|
|
|
// Styles
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_bold", "b");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_italic", "i");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_underline", "u");
|
2001-08-23 00:05:53 +00:00
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_tt", "tt");
|
2001-04-05 23:34:08 +00:00
|
|
|
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strikethrough", "strike");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_superscript", "sup");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_subscript", "sub");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_nobreak", "nobr");
|
|
|
|
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_em", "em");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strong", "strong");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_cite", "cite");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_abbr", "abbr");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_acronym", "acronym");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_code", "code");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_samp", "samp");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", "var");
|
2003-02-19 15:03:49 +00:00
|
|
|
NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_removeLinks", "href");
|
2002-11-20 01:20:19 +00:00
|
|
|
|
2001-04-05 23:34:08 +00:00
|
|
|
// lists
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", "dt");
|
|
|
|
NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", "dd");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList");
|
|
|
|
|
|
|
|
// format stuff
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsFontFaceStateCommand, "cmd_fontFace");
|
2002-11-20 01:20:19 +00:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsFontSizeStateCommand, "cmd_fontSize");
|
2001-04-05 23:34:08 +00:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsFontColorStateCommand, "cmd_fontColor");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsBackgroundColorStateCommand, "cmd_backgroundColor");
|
2002-01-09 13:51:37 +00:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsHighlightColorStateCommand, "cmd_highlight");
|
2001-04-05 23:34:08 +00:00
|
|
|
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsAlignCommand, "cmd_align");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsRemoveStylesCommand, "cmd_removeStyles");
|
|
|
|
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsIncreaseFontSizeCommand, "cmd_increaseFont");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsDecreaseFontSizeCommand, "cmd_decreaseFont");
|
|
|
|
|
2002-11-12 23:03:27 +00:00
|
|
|
// Insert content
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsInsertHTMLCommand, "cmd_insertHTML");
|
2002-11-20 01:20:19 +00:00
|
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", "a");
|
|
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", "img");
|
2002-12-17 19:41:00 +00:00
|
|
|
NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", "hr");
|
2002-07-15 22:04:13 +00:00
|
|
|
|
2003-06-25 08:50:48 +00:00
|
|
|
NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");
|
|
|
|
NS_REGISTER_ONE_COMMAND(nsIncreaseZIndexCommand, "cmd_increaseZIndex");
|
|
|
|
|
2001-04-05 23:34:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|