~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/editor/libeditor/base/nsEditorController.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
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.
 
14
 *
 
15
 * The Original Code is Mozilla Communicator client code.
 
16
 *
 
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.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Pierre Phaneuf <pp@ludusdesign.com>
 
24
 *   Ryan Cassin <rcassin@supernova.org>
 
25
 *
 
26
 *
 
27
 * Alternatively, the contents of this file may be used under the terms of
 
28
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
29
 * 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 NPL, 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 NPL, the GPL or the LGPL.
 
38
 *
 
39
 * ***** END LICENSE BLOCK ***** */
 
40
 
 
41
#include "nsString.h"
 
42
#include "nsIComponentManager.h"
 
43
#include "nsEditorController.h"
 
44
#include "nsEditorCommands.h"
 
45
#include "nsIControllerCommandTable.h"
 
46
 
 
47
 
 
48
 
 
49
#define NS_REGISTER_ONE_COMMAND(_cmdClass, _cmdName)                                      \
 
50
  {                                                                                       \
 
51
    _cmdClass* theCmd;                                                                    \
 
52
    NS_NEWXPCOM(theCmd, _cmdClass);                                                       \
 
53
    if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                                           \
 
54
    rv = inCommandTable->RegisterCommand(_cmdName,                                        \
 
55
                                   NS_STATIC_CAST(nsIControllerCommand *, theCmd));       \
 
56
  }
 
57
 
 
58
#define NS_REGISTER_FIRST_COMMAND(_cmdClass, _cmdName)                                    \
 
59
  {                                                                                       \
 
60
    _cmdClass* theCmd;                                                                    \
 
61
    NS_NEWXPCOM(theCmd, _cmdClass);                                                       \
 
62
    if (!theCmd) return NS_ERROR_OUT_OF_MEMORY;                                           \
 
63
    rv = inCommandTable->RegisterCommand(_cmdName,                                        \
 
64
                                   NS_STATIC_CAST(nsIControllerCommand *, theCmd));
 
65
 
 
66
#define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName)                                     \
 
67
    rv = inCommandTable->RegisterCommand(_cmdName,                                        \
 
68
                                   NS_STATIC_CAST(nsIControllerCommand *, theCmd));
 
69
 
 
70
#define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName)                                     \
 
71
    rv = inCommandTable->RegisterCommand(_cmdName,                                        \
 
72
                                   NS_STATIC_CAST(nsIControllerCommand *, theCmd));       \
 
73
  }
 
74
 
 
75
 
 
76
// static
 
77
nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandTable *inCommandTable)
 
78
{
 
79
  nsresult rv;
 
80
 
 
81
  // now register all our commands
 
82
  // These are commands that will be used in text widgets, and in composer
 
83
  
 
84
  NS_REGISTER_ONE_COMMAND(nsUndoCommand, "cmd_undo");
 
85
  NS_REGISTER_ONE_COMMAND(nsRedoCommand, "cmd_redo");
 
86
  NS_REGISTER_ONE_COMMAND(nsClearUndoCommand, "cmd_clearUndo");
 
87
 
 
88
  NS_REGISTER_ONE_COMMAND(nsCutCommand, "cmd_cut");
 
89
  NS_REGISTER_ONE_COMMAND(nsCutOrDeleteCommand, "cmd_cutOrDelete");
 
90
  NS_REGISTER_ONE_COMMAND(nsCopyCommand, "cmd_copy");
 
91
  NS_REGISTER_ONE_COMMAND(nsCopyOrDeleteCommand, "cmd_copyOrDelete");
 
92
  NS_REGISTER_ONE_COMMAND(nsSelectAllCommand, "cmd_selectAll");
 
93
  
 
94
  NS_REGISTER_ONE_COMMAND(nsPasteCommand, "cmd_paste");
 
95
  
 
96
  NS_REGISTER_FIRST_COMMAND(nsDeleteCommand, "cmd_delete");
 
97
  NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharBackward");
 
98
  NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteCharForward");
 
99
  NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordBackward");
 
100
  NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteWordForward");
 
101
  NS_REGISTER_NEXT_COMMAND(nsDeleteCommand, "cmd_deleteToBeginningOfLine");
 
102
  NS_REGISTER_LAST_COMMAND(nsDeleteCommand, "cmd_deleteToEndOfLine");
 
103
 
 
104
  NS_REGISTER_FIRST_COMMAND(nsSelectionMoveCommands, "cmd_scrollTop");
 
105
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollBottom");
 
106
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveTop");
 
107
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_moveBottom");
 
108
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectTop");
 
109
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBottom");
 
110
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_lineNext");
 
111
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_linePrevious");
 
112
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLineNext");
 
113
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectLinePrevious");
 
114
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charPrevious");
 
115
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_charNext");
 
116
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharPrevious");
 
117
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectCharNext");
 
118
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_beginLine");
 
119
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_endLine");
 
120
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectBeginLine");
 
121
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectEndLine");
 
122
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordPrevious");
 
123
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_wordNext");
 
124
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordPrevious");
 
125
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectWordNext");
 
126
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageUp");
 
127
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollPageDown");
 
128
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineUp");
 
129
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_scrollLineDown");
 
130
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageUp");
 
131
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_movePageDown");
 
132
  NS_REGISTER_NEXT_COMMAND(nsSelectionMoveCommands, "cmd_selectPageUp");
 
133
  NS_REGISTER_LAST_COMMAND(nsSelectionMoveCommands, "cmd_selectPageDown");
 
134
    
 
135
  // Insert content
 
136
  NS_REGISTER_ONE_COMMAND(nsInsertPlaintextCommand, "cmd_insertText");
 
137
  NS_REGISTER_ONE_COMMAND(nsPasteQuotationCommand,  "cmd_pasteQuote");
 
138
 
 
139
 
 
140
  return NS_OK;
 
141
}
 
142