Bug 448909 - Need more controls WHATWG Video tag (followup patch). r=mconnor
[wine-gecko.git] / editor / composer / src / nsComposerController.cpp
blob48f7437e330a3864543a9ff1a8ee6a819f9ef8d7
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Pierre Phaneuf <pp@ludusdesign.com>
24 * Ryan Cassin <rcassin@supernova.org>
25 * Daniel Glazman <glazman@netscape.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #include "nsIControllerCommandTable.h"
42 #include "nsComposerController.h"
43 #include "nsComposerCommands.h"
45 #define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName) \
46 { \
47 _cmdClass* theCmd; \
48 NS_NEWXPCOM(theCmd, _cmdClass); \
49 if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
50 rv = inCommandTable->RegisterCommand(_cmdName, \
51 static_cast<nsIControllerCommand *>(theCmd)); \
54 #define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName) \
55 { \
56 _cmdClass* theCmd; \
57 NS_NEWXPCOM(theCmd, _cmdClass); \
58 if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
59 rv = inCommandTable->RegisterCommand(_cmdName, \
60 static_cast<nsIControllerCommand *>(theCmd));
62 #define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \
63 rv = inCommandTable->RegisterCommand(_cmdName, \
64 static_cast<nsIControllerCommand *>(theCmd));
66 #define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \
67 rv = inCommandTable->RegisterCommand(_cmdName, \
68 static_cast<nsIControllerCommand *>(theCmd)); \
71 #define NS_REGISTER_STYLE_COMMAND(_cmdClass, _cmdName, _styleTag) \
72 { \
73 _cmdClass* theCmd = new _cmdClass(_styleTag); \
74 if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
75 rv = inCommandTable->RegisterCommand(_cmdName, \
76 static_cast<nsIControllerCommand *>(theCmd)); \
79 #define NS_REGISTER_TAG_COMMAND(_cmdClass, _cmdName, _tagName) \
80 { \
81 _cmdClass* theCmd = new _cmdClass(_tagName); \
82 if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \
83 rv = inCommandTable->RegisterCommand(_cmdName, \
84 static_cast<nsIControllerCommand *>(theCmd)); \
88 // static
89 nsresult
90 nsComposerController::RegisterEditorDocStateCommands(
91 nsIControllerCommandTable *inCommandTable)
93 nsresult rv;
95 // observer commands for document state
96 NS_REGISTER_FIRST_COMMAND(nsDocumentStateCommand, "obs_documentCreated")
97 NS_REGISTER_NEXT_COMMAND(nsDocumentStateCommand, "obs_documentWillBeDestroyed")
98 NS_REGISTER_LAST_COMMAND(nsDocumentStateCommand, "obs_documentLocationChanged")
100 // commands that may get or change state
101 NS_REGISTER_FIRST_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentModified")
102 NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentUseCSS")
103 NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_setDocumentReadOnly")
104 NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_insertBrOnReturn")
105 NS_REGISTER_NEXT_COMMAND(nsSetDocumentStateCommand, "cmd_enableObjectResizing")
106 NS_REGISTER_LAST_COMMAND(nsSetDocumentStateCommand, "cmd_enableInlineTableEditing")
108 NS_REGISTER_ONE_COMMAND(nsSetDocumentOptionsCommand, "cmd_setDocumentOptions")
110 return NS_OK;
113 // static
114 nsresult
115 nsComposerController::RegisterHTMLEditorCommands(
116 nsIControllerCommandTable *inCommandTable)
118 nsresult rv;
120 // Edit menu
121 NS_REGISTER_ONE_COMMAND(nsPasteNoFormattingCommand, "cmd_pasteNoFormatting");
123 // indent/outdent
124 NS_REGISTER_ONE_COMMAND(nsIndentCommand, "cmd_indent");
125 NS_REGISTER_ONE_COMMAND(nsOutdentCommand, "cmd_outdent");
127 // Styles
128 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_bold", "b");
129 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_italic", "i");
130 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_underline", "u");
131 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_tt", "tt");
133 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strikethrough", "strike");
134 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_superscript", "sup");
135 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_subscript", "sub");
136 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_nobreak", "nobr");
138 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_em", "em");
139 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_strong", "strong");
140 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_cite", "cite");
141 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_abbr", "abbr");
142 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_acronym", "acronym");
143 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_code", "code");
144 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_samp", "samp");
145 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", "var");
146 NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_removeLinks", "href");
148 // lists
149 NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol");
150 NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul");
151 NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", "dt");
152 NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", "dd");
153 NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList");
155 // format stuff
156 NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState");
157 NS_REGISTER_ONE_COMMAND(nsFontFaceStateCommand, "cmd_fontFace");
158 NS_REGISTER_ONE_COMMAND(nsFontSizeStateCommand, "cmd_fontSize");
159 NS_REGISTER_ONE_COMMAND(nsFontColorStateCommand, "cmd_fontColor");
160 NS_REGISTER_ONE_COMMAND(nsBackgroundColorStateCommand, "cmd_backgroundColor");
161 NS_REGISTER_ONE_COMMAND(nsHighlightColorStateCommand, "cmd_highlight");
163 NS_REGISTER_ONE_COMMAND(nsAlignCommand, "cmd_align");
164 NS_REGISTER_ONE_COMMAND(nsRemoveStylesCommand, "cmd_removeStyles");
166 NS_REGISTER_ONE_COMMAND(nsIncreaseFontSizeCommand, "cmd_increaseFont");
167 NS_REGISTER_ONE_COMMAND(nsDecreaseFontSizeCommand, "cmd_decreaseFont");
169 // Insert content
170 NS_REGISTER_ONE_COMMAND(nsInsertHTMLCommand, "cmd_insertHTML");
171 NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertLinkNoUI", "a");
172 NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertImageNoUI", "img");
173 NS_REGISTER_TAG_COMMAND(nsInsertTagCommand, "cmd_insertHR", "hr");
175 NS_REGISTER_ONE_COMMAND(nsAbsolutePositioningCommand, "cmd_absPos");
176 NS_REGISTER_ONE_COMMAND(nsDecreaseZIndexCommand, "cmd_decreaseZIndex");
177 NS_REGISTER_ONE_COMMAND(nsIncreaseZIndexCommand, "cmd_increaseZIndex");
179 return NS_OK;