michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIEditorCommand_h_ michael@0: #define nsIEditorCommand_h_ michael@0: michael@0: #include "nsIControllerCommand.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nscore.h" michael@0: michael@0: class nsICommandParams; michael@0: class nsISupports; michael@0: michael@0: // This is a virtual base class for commands registered with the editor controller. michael@0: // Note that such commands can be shared by more than on editor instance, so michael@0: // MUST be stateless. Any state must be stored via the refCon (an nsIEditor). michael@0: class nsBaseEditorCommand : public nsIControllerCommand michael@0: { michael@0: public: michael@0: michael@0: nsBaseEditorCommand(); michael@0: virtual ~nsBaseEditorCommand() {} michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) = 0; michael@0: NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) = 0; michael@0: michael@0: }; michael@0: michael@0: michael@0: #define NS_DECL_EDITOR_COMMAND(_cmd) \ michael@0: class _cmd : public nsBaseEditorCommand \ michael@0: { \ michael@0: public: \ michael@0: NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval); \ michael@0: NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon); \ michael@0: NS_IMETHOD DoCommandParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ michael@0: NS_IMETHOD GetCommandStateParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ michael@0: }; michael@0: michael@0: michael@0: michael@0: // basic editor commands michael@0: NS_DECL_EDITOR_COMMAND(nsUndoCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsRedoCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsClearUndoCommand) michael@0: michael@0: NS_DECL_EDITOR_COMMAND(nsCutCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsCutOrDeleteCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsCopyCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsCopyOrDeleteCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsPasteCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsPasteTransferableCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsSwitchTextDirectionCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsDeleteCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsSelectAllCommand) michael@0: michael@0: NS_DECL_EDITOR_COMMAND(nsSelectionMoveCommands) michael@0: michael@0: // Insert content commands michael@0: NS_DECL_EDITOR_COMMAND(nsInsertPlaintextCommand) michael@0: NS_DECL_EDITOR_COMMAND(nsPasteQuotationCommand) michael@0: michael@0: michael@0: #if 0 michael@0: // template for new command michael@0: NS_IMETHODIMP michael@0: nsFooCommand::IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) michael@0: { michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: } michael@0: michael@0: michael@0: NS_IMETHODIMP michael@0: nsFooCommand::DoCommand(const char *aCommandName, const nsAString & aCommandParams, nsISupports *aCommandRefCon) michael@0: { michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: } michael@0: michael@0: michael@0: #endif michael@0: michael@0: #endif // nsIEditorCommand_h_