2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-05-02 01:37:38 +04:00
|
|
|
|
|
|
|
#ifndef nsComposerCommands_h_
|
|
|
|
#define nsComposerCommands_h_
|
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
#include "nsIControllerCommand.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED, etc
|
|
|
|
#include "nscore.h" // for nsresult, NS_IMETHOD
|
2000-05-06 03:20:21 +04:00
|
|
|
|
2012-05-18 12:29:40 +04:00
|
|
|
class nsIAtom;
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsICommandParams;
|
|
|
|
class nsIEditor;
|
|
|
|
class nsISupports;
|
|
|
|
class nsString;
|
2002-11-13 02:03:27 +03:00
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
// This is a virtual base class for commands registered with the composer controller.
|
|
|
|
// Note that such commands are instantiated once per composer, so can store state.
|
2002-09-12 23:08:46 +04:00
|
|
|
// Also note that IsCommandEnabled can be called with an editor that may not
|
2000-05-06 03:20:21 +04:00
|
|
|
// have an editor yet (because the document is loading). Most commands will want
|
|
|
|
// to return false in this case.
|
2002-09-12 23:08:46 +04:00
|
|
|
// Don't hold on to any references to the editor or document from
|
2000-05-06 03:20:21 +04:00
|
|
|
// your command. This will cause leaks. Also, be aware that the document the
|
|
|
|
// editor is editing can change under you (if the user Reverts the file, for
|
|
|
|
// instance).
|
|
|
|
class nsBaseComposerCommand : public nsIControllerCommand
|
|
|
|
{
|
2014-06-24 02:40:02 +04:00
|
|
|
protected:
|
|
|
|
virtual ~nsBaseComposerCommand() {}
|
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
public:
|
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
nsBaseComposerCommand();
|
|
|
|
|
2001-04-05 03:48:03 +04:00
|
|
|
// nsISupports
|
2000-05-06 03:20:21 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-06-24 02:40:02 +04:00
|
|
|
|
2001-04-05 03:48:03 +04:00
|
|
|
// nsIControllerCommand. Declared longhand so we can make them pure virtual
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) override = 0;
|
|
|
|
NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandRefCon) override = 0;
|
2000-05-06 03:20:21 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_DECL_COMPOSER_COMMAND(_cmd) \
|
|
|
|
class _cmd : public nsBaseComposerCommand \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND \
|
|
|
|
};
|
2000-05-02 01:37:38 +04:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
// virtual base class for commands that need to save and update Boolean state (like styles etc)
|
2002-09-12 23:08:46 +04:00
|
|
|
class nsBaseStateUpdatingCommand : public nsBaseComposerCommand
|
2000-05-02 01:37:38 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:49:37 +04:00
|
|
|
explicit nsBaseStateUpdatingCommand(nsIAtom* aTagName);
|
2014-06-24 02:40:02 +04:00
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsBaseStateUpdatingCommand();
|
2000-05-02 01:37:38 +04:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// get the current state (on or off) for this style or block format
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) = 0;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// add/remove the style
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult ToggleState(nsIEditor* aEditor) = 0;
|
2002-02-02 08:13:56 +03:00
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
protected:
|
2012-05-18 12:29:40 +04:00
|
|
|
nsIAtom* mTagName;
|
2000-05-02 01:37:38 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
// Shared class for the various style updating commands like bold, italics etc.
|
|
|
|
// Suitable for commands whose state is either 'on' or 'off'.
|
2000-05-02 01:37:38 +04:00
|
|
|
class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:49:37 +04:00
|
|
|
explicit nsStyleUpdatingCommand(nsIAtom* aTagName);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// get the current state (on or off) for this style or block format
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// add/remove the style
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult ToggleState(nsIEditor* aEditor);
|
2000-05-02 01:37:38 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-20 04:18:48 +03:00
|
|
|
class nsInsertTagCommand : public nsBaseComposerCommand
|
|
|
|
{
|
|
|
|
public:
|
2012-06-06 11:42:01 +04:00
|
|
|
explicit nsInsertTagCommand(nsIAtom* aTagName);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-11-20 04:18:48 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsInsertTagCommand();
|
2002-11-20 04:18:48 +03:00
|
|
|
|
2012-06-06 11:42:01 +04:00
|
|
|
nsIAtom* mTagName;
|
2002-11-20 04:18:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
class nsListCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:49:37 +04:00
|
|
|
explicit nsListCommand(nsIAtom* aTagName);
|
2000-05-02 01:37:38 +04:00
|
|
|
|
|
|
|
protected:
|
2002-02-02 08:13:56 +03:00
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// add/remove the style
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult ToggleState(nsIEditor* aEditor);
|
2000-05-02 01:37:38 +04:00
|
|
|
};
|
|
|
|
|
2000-06-06 00:26:40 +04:00
|
|
|
class nsListItemCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
2014-09-01 07:49:37 +04:00
|
|
|
explicit nsListItemCommand(nsIAtom* aTagName);
|
2000-06-06 00:26:40 +04:00
|
|
|
|
|
|
|
protected:
|
2002-02-02 08:13:56 +03:00
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// add/remove the style
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult ToggleState(nsIEditor* aEditor);
|
2000-06-06 00:26:40 +04:00
|
|
|
};
|
2000-05-02 01:37:38 +04:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
// Base class for commands whose state consists of a string (e.g. para format)
|
2002-09-12 23:08:46 +04:00
|
|
|
class nsMultiStateCommand : public nsBaseComposerCommand
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-05-28 18:58:42 +03:00
|
|
|
|
2014-06-24 02:40:02 +04:00
|
|
|
nsMultiStateCommand();
|
2015-05-28 18:58:42 +03:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
2014-06-24 02:40:02 +04:00
|
|
|
virtual ~nsMultiStateCommand();
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
|
2015-05-28 18:58:42 +03:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class nsParagraphStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsParagraphStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsFontFaceStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontFaceStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
};
|
|
|
|
|
2002-11-20 04:18:48 +03:00
|
|
|
class nsFontSizeStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontSizeStateCommand();
|
|
|
|
|
|
|
|
protected:
|
2002-12-03 01:20:12 +03:00
|
|
|
|
2002-11-20 04:18:48 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor,
|
|
|
|
nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
|
|
|
};
|
|
|
|
|
2002-01-09 16:51:37 +03:00
|
|
|
class nsHighlightColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsHighlightColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
2002-01-09 16:51:37 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
class nsFontColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
};
|
|
|
|
|
2000-08-24 05:20:29 +04:00
|
|
|
class nsAlignCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAlignCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
2000-08-24 05:20:29 +04:00
|
|
|
};
|
|
|
|
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
class nsBackgroundColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsBackgroundColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
Fixed lots of nsbeta3+ bugs: 45756, 47654, 41810,47503,48990, 48995,40204, 42740, 46953, 47646, 47696, 48693, 45899. r=sfraser,jfrancis
2000-08-23 04:29:24 +04:00
|
|
|
};
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
|
2003-06-25 12:50:48 +04:00
|
|
|
class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
2012-05-18 12:29:40 +04:00
|
|
|
nsAbsolutePositioningCommand();
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
|
2003-06-25 12:50:48 +04:00
|
|
|
protected:
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
|
2012-05-18 12:29:40 +04:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult ToggleState(nsIEditor* aEditor);
|
2003-06-25 12:50:48 +04:00
|
|
|
};
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-25 03:00:24 +04:00
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
// composer commands
|
|
|
|
|
2000-05-06 03:20:21 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
|
2002-11-13 02:03:27 +03:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
|
2003-04-15 17:53:51 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)
|
2001-10-13 06:27:35 +04:00
|
|
|
//NS_DECL_COMPOSER_COMMAND(nsPrintingCommands)
|
2000-05-02 01:37:38 +04:00
|
|
|
|
2003-06-25 12:50:48 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsDecreaseZIndexCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsIncreaseZIndexCommand)
|
|
|
|
|
2000-05-02 01:37:38 +04:00
|
|
|
// Generic commands
|
|
|
|
|
|
|
|
// File menu
|
2000-05-06 03:20:21 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsNewCommands) // handles 'new' anything
|
2000-05-02 01:37:38 +04:00
|
|
|
|
|
|
|
// Edit menu
|
2002-10-06 05:23:18 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsPasteNoFormattingCommand)
|
2000-05-02 01:37:38 +04:00
|
|
|
|
|
|
|
// Block transformations
|
2000-05-06 03:20:21 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsIndentCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsOutdentCommand)
|
|
|
|
|
2000-06-16 18:21:46 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand)
|
2000-05-06 03:20:21 +04:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand)
|
2000-05-02 01:37:38 +04:00
|
|
|
|
2002-11-13 02:03:27 +03:00
|
|
|
// Insert content commands
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsInsertHTMLCommand)
|
2000-05-02 01:37:38 +04:00
|
|
|
|
|
|
|
#endif // nsComposerCommands_h_
|