2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2000-05-01 21:37:38 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2000-05-01 21:37:38 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2000-05-01 21:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-05-01 21:37:38 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Contributor(s):
|
2002-11-12 23:03:27 +00:00
|
|
|
* Ryan Cassin <rcassin@supernova.org>
|
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
|
|
|
* Charles Manske <cmanske@netscape.com>
|
2001-09-25 22:53:13 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-05-01 21:37:38 +00:00
|
|
|
|
|
|
|
#ifndef nsComposerCommands_h_
|
|
|
|
#define nsComposerCommands_h_
|
|
|
|
|
2000-05-05 23:20:21 +00:00
|
|
|
#include "nsIControllerCommand.h"
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
#include "nsString.h"
|
2000-05-05 23:20:21 +00:00
|
|
|
|
2002-11-12 23:03:27 +00:00
|
|
|
class nsIEditor;
|
|
|
|
|
2000-05-05 23:20:21 +00: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 19:08:46 +00:00
|
|
|
// Also note that IsCommandEnabled can be called with an editor that may not
|
2000-05-05 23:20:21 +00:00
|
|
|
// have an editor yet (because the document is loading). Most commands will want
|
|
|
|
// to return false in this case.
|
2002-09-12 19:08:46 +00:00
|
|
|
// Don't hold on to any references to the editor or document from
|
2000-05-05 23:20:21 +00: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
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsBaseComposerCommand();
|
|
|
|
virtual ~nsBaseComposerCommand() {}
|
|
|
|
|
2001-04-04 23:48:03 +00:00
|
|
|
// nsISupports
|
2000-05-05 23:20:21 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2001-04-04 23:48:03 +00:00
|
|
|
// nsIControllerCommand. Declared longhand so we can make them pure virtual
|
2002-07-15 22:04:13 +00:00
|
|
|
NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0;
|
|
|
|
NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandRefCon) = 0;
|
2000-05-05 23:20:21 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define NS_DECL_COMPOSER_COMMAND(_cmd) \
|
|
|
|
class _cmd : public nsBaseComposerCommand \
|
|
|
|
{ \
|
|
|
|
public: \
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND \
|
|
|
|
};
|
2000-05-01 21:37:38 +00:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-24 23:00:24 +00:00
|
|
|
// virtual base class for commands that need to save and update Boolean state (like styles etc)
|
2002-09-12 19:08:46 +00:00
|
|
|
class nsBaseStateUpdatingCommand : public nsBaseComposerCommand
|
2000-05-01 21:37:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsBaseStateUpdatingCommand(const char* aTagName);
|
|
|
|
virtual ~nsBaseStateUpdatingCommand();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00:00
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) = 0;
|
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName) = 0;
|
|
|
|
|
2000-05-01 21:37:38 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
const char* mTagName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-24 23:00:24 +00: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-01 21:37:38 +00:00
|
|
|
class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsStyleUpdatingCommand(const char* aTagName);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00:00
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
|
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
|
|
|
|
|
2000-05-01 21:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-11-20 01:18:48 +00:00
|
|
|
class nsInsertTagCommand : public nsBaseComposerCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsInsertTagCommand(const char* aTagName);
|
|
|
|
virtual ~nsInsertTagCommand();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
const char* mTagName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-05-01 21:37:38 +00:00
|
|
|
class nsListCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsListCommand(const char* aTagName);
|
|
|
|
|
|
|
|
protected:
|
2002-02-02 05:13:56 +00:00
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
|
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
|
2000-05-01 21:37:38 +00:00
|
|
|
};
|
|
|
|
|
2000-06-05 20:26:40 +00:00
|
|
|
class nsListItemCommand : public nsBaseStateUpdatingCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsListItemCommand(const char* aTagName);
|
|
|
|
|
|
|
|
protected:
|
2002-02-02 05:13:56 +00:00
|
|
|
|
|
|
|
// get the current state (on or off) for this style or block format
|
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
|
|
|
|
|
|
|
|
// add/remove the style
|
|
|
|
virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
|
2000-06-05 20:26:40 +00:00
|
|
|
};
|
2000-05-01 21:37:38 +00:00
|
|
|
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-24 23:00:24 +00:00
|
|
|
// Base class for commands whose state consists of a string (e.g. para format)
|
2002-09-12 19:08:46 +00: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-24 23:00:24 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsMultiStateCommand();
|
|
|
|
virtual ~nsMultiStateCommand();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSICONTROLLERCOMMAND
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-24 23:00:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class nsParagraphStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsParagraphStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00: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-24 23:00:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsFontFaceStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontFaceStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00: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-24 23:00:24 +00:00
|
|
|
};
|
|
|
|
|
2002-11-20 01:18:48 +00:00
|
|
|
class nsFontSizeStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontSizeStateCommand();
|
|
|
|
|
|
|
|
protected:
|
2002-12-02 22:20:12 +00:00
|
|
|
|
2002-11-20 01:18:48 +00:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor,
|
|
|
|
nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
|
|
|
};
|
|
|
|
|
2002-01-09 13:51:37 +00:00
|
|
|
class nsHighlightColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsHighlightColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-07-15 22:04:13 +00:00
|
|
|
NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, PRBool *_retval);
|
2002-02-02 05:13:56 +00:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
2002-01-09 13:51:37 +00: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 00:29:24 +00:00
|
|
|
class nsFontColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFontColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00: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 00:29:24 +00:00
|
|
|
};
|
|
|
|
|
2000-08-24 01:20:29 +00:00
|
|
|
class nsAlignCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsAlignCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00:00
|
|
|
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
|
|
|
|
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
|
2000-08-24 01:20:29 +00: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 00:29:24 +00:00
|
|
|
class nsBackgroundColorStateCommand : public nsMultiStateCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsBackgroundColorStateCommand();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2002-02-02 05:13:56 +00: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 00:29:24 +00:00
|
|
|
};
|
fixes:
14753, 29843, 39864, 40141,
40139, 36679, 39542, 34729,
34855, 37216, 39292, 26447
r=sfraser,cmanske,fm; a=beppe
2000-05-24 23:00:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-05-01 21:37:38 +00:00
|
|
|
// composer commands
|
|
|
|
|
2000-05-05 23:20:21 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
|
2002-11-12 23:03:27 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
|
2003-04-15 13:53:51 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)
|
2001-10-13 02:27:35 +00:00
|
|
|
//NS_DECL_COMPOSER_COMMAND(nsPrintingCommands)
|
2000-05-01 21:37:38 +00:00
|
|
|
|
|
|
|
// Generic commands
|
|
|
|
|
|
|
|
// File menu
|
2000-05-05 23:20:21 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsNewCommands) // handles 'new' anything
|
2000-05-01 21:37:38 +00:00
|
|
|
|
|
|
|
// Edit menu
|
2002-10-06 01:23:18 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsPasteNoFormattingCommand)
|
2000-05-01 21:37:38 +00:00
|
|
|
|
|
|
|
// Block transformations
|
2000-05-05 23:20:21 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsIndentCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsOutdentCommand)
|
|
|
|
|
2000-06-16 14:21:46 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand)
|
2000-05-05 23:20:21 +00:00
|
|
|
NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand)
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand)
|
2000-05-01 21:37:38 +00:00
|
|
|
|
2002-11-12 23:03:27 +00:00
|
|
|
// Insert content commands
|
|
|
|
NS_DECL_COMPOSER_COMMAND(nsInsertHTMLCommand)
|
2000-05-01 21:37:38 +00:00
|
|
|
|
|
|
|
#endif // nsComposerCommands_h_
|