|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsIEditorCommand_h_ |
|
7 #define nsIEditorCommand_h_ |
|
8 |
|
9 #include "nsIControllerCommand.h" |
|
10 #include "nsISupportsImpl.h" |
|
11 #include "nscore.h" |
|
12 |
|
13 class nsICommandParams; |
|
14 class nsISupports; |
|
15 |
|
16 // This is a virtual base class for commands registered with the editor controller. |
|
17 // Note that such commands can be shared by more than on editor instance, so |
|
18 // MUST be stateless. Any state must be stored via the refCon (an nsIEditor). |
|
19 class nsBaseEditorCommand : public nsIControllerCommand |
|
20 { |
|
21 public: |
|
22 |
|
23 nsBaseEditorCommand(); |
|
24 virtual ~nsBaseEditorCommand() {} |
|
25 |
|
26 NS_DECL_ISUPPORTS |
|
27 |
|
28 NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) = 0; |
|
29 NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) = 0; |
|
30 |
|
31 }; |
|
32 |
|
33 |
|
34 #define NS_DECL_EDITOR_COMMAND(_cmd) \ |
|
35 class _cmd : public nsBaseEditorCommand \ |
|
36 { \ |
|
37 public: \ |
|
38 NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval); \ |
|
39 NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon); \ |
|
40 NS_IMETHOD DoCommandParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ |
|
41 NS_IMETHOD GetCommandStateParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ |
|
42 }; |
|
43 |
|
44 |
|
45 |
|
46 // basic editor commands |
|
47 NS_DECL_EDITOR_COMMAND(nsUndoCommand) |
|
48 NS_DECL_EDITOR_COMMAND(nsRedoCommand) |
|
49 NS_DECL_EDITOR_COMMAND(nsClearUndoCommand) |
|
50 |
|
51 NS_DECL_EDITOR_COMMAND(nsCutCommand) |
|
52 NS_DECL_EDITOR_COMMAND(nsCutOrDeleteCommand) |
|
53 NS_DECL_EDITOR_COMMAND(nsCopyCommand) |
|
54 NS_DECL_EDITOR_COMMAND(nsCopyOrDeleteCommand) |
|
55 NS_DECL_EDITOR_COMMAND(nsPasteCommand) |
|
56 NS_DECL_EDITOR_COMMAND(nsPasteTransferableCommand) |
|
57 NS_DECL_EDITOR_COMMAND(nsSwitchTextDirectionCommand) |
|
58 NS_DECL_EDITOR_COMMAND(nsDeleteCommand) |
|
59 NS_DECL_EDITOR_COMMAND(nsSelectAllCommand) |
|
60 |
|
61 NS_DECL_EDITOR_COMMAND(nsSelectionMoveCommands) |
|
62 |
|
63 // Insert content commands |
|
64 NS_DECL_EDITOR_COMMAND(nsInsertPlaintextCommand) |
|
65 NS_DECL_EDITOR_COMMAND(nsPasteQuotationCommand) |
|
66 |
|
67 |
|
68 #if 0 |
|
69 // template for new command |
|
70 NS_IMETHODIMP |
|
71 nsFooCommand::IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) |
|
72 { |
|
73 return NS_ERROR_NOT_IMPLEMENTED; |
|
74 } |
|
75 |
|
76 |
|
77 NS_IMETHODIMP |
|
78 nsFooCommand::DoCommand(const char *aCommandName, const nsAString & aCommandParams, nsISupports *aCommandRefCon) |
|
79 { |
|
80 return NS_ERROR_NOT_IMPLEMENTED; |
|
81 } |
|
82 |
|
83 |
|
84 #endif |
|
85 |
|
86 #endif // nsIEditorCommand_h_ |