1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/base/nsEditorCommands.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsIEditorCommand_h_ 1.10 +#define nsIEditorCommand_h_ 1.11 + 1.12 +#include "nsIControllerCommand.h" 1.13 +#include "nsISupportsImpl.h" 1.14 +#include "nscore.h" 1.15 + 1.16 +class nsICommandParams; 1.17 +class nsISupports; 1.18 + 1.19 +// This is a virtual base class for commands registered with the editor controller. 1.20 +// Note that such commands can be shared by more than on editor instance, so 1.21 +// MUST be stateless. Any state must be stored via the refCon (an nsIEditor). 1.22 +class nsBaseEditorCommand : public nsIControllerCommand 1.23 +{ 1.24 +public: 1.25 + 1.26 + nsBaseEditorCommand(); 1.27 + virtual ~nsBaseEditorCommand() {} 1.28 + 1.29 + NS_DECL_ISUPPORTS 1.30 + 1.31 + NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) = 0; 1.32 + NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) = 0; 1.33 + 1.34 +}; 1.35 + 1.36 + 1.37 +#define NS_DECL_EDITOR_COMMAND(_cmd) \ 1.38 +class _cmd : public nsBaseEditorCommand \ 1.39 +{ \ 1.40 +public: \ 1.41 + NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval); \ 1.42 + NS_IMETHOD DoCommand(const char *aCommandName, nsISupports *aCommandRefCon); \ 1.43 + NS_IMETHOD DoCommandParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ 1.44 + NS_IMETHOD GetCommandStateParams(const char *aCommandName,nsICommandParams *aParams, nsISupports *aCommandRefCon); \ 1.45 +}; 1.46 + 1.47 + 1.48 + 1.49 +// basic editor commands 1.50 +NS_DECL_EDITOR_COMMAND(nsUndoCommand) 1.51 +NS_DECL_EDITOR_COMMAND(nsRedoCommand) 1.52 +NS_DECL_EDITOR_COMMAND(nsClearUndoCommand) 1.53 + 1.54 +NS_DECL_EDITOR_COMMAND(nsCutCommand) 1.55 +NS_DECL_EDITOR_COMMAND(nsCutOrDeleteCommand) 1.56 +NS_DECL_EDITOR_COMMAND(nsCopyCommand) 1.57 +NS_DECL_EDITOR_COMMAND(nsCopyOrDeleteCommand) 1.58 +NS_DECL_EDITOR_COMMAND(nsPasteCommand) 1.59 +NS_DECL_EDITOR_COMMAND(nsPasteTransferableCommand) 1.60 +NS_DECL_EDITOR_COMMAND(nsSwitchTextDirectionCommand) 1.61 +NS_DECL_EDITOR_COMMAND(nsDeleteCommand) 1.62 +NS_DECL_EDITOR_COMMAND(nsSelectAllCommand) 1.63 + 1.64 +NS_DECL_EDITOR_COMMAND(nsSelectionMoveCommands) 1.65 + 1.66 +// Insert content commands 1.67 +NS_DECL_EDITOR_COMMAND(nsInsertPlaintextCommand) 1.68 +NS_DECL_EDITOR_COMMAND(nsPasteQuotationCommand) 1.69 + 1.70 + 1.71 +#if 0 1.72 +// template for new command 1.73 +NS_IMETHODIMP 1.74 +nsFooCommand::IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) 1.75 +{ 1.76 + return NS_ERROR_NOT_IMPLEMENTED; 1.77 +} 1.78 + 1.79 + 1.80 +NS_IMETHODIMP 1.81 +nsFooCommand::DoCommand(const char *aCommandName, const nsAString & aCommandParams, nsISupports *aCommandRefCon) 1.82 +{ 1.83 + return NS_ERROR_NOT_IMPLEMENTED; 1.84 +} 1.85 + 1.86 + 1.87 +#endif 1.88 + 1.89 +#endif // nsIEditorCommand_h_