gecko/editor/composer/nsComposerCommands.h
Birunthan Mohanathas 4ec7a5a23a Bug 1028565 - Part 1: Flatten editor/composer/{public,src}/ directories. r=ehsan
--HG--
rename : editor/composer/src/crashtests/351236-1.html => editor/composer/crashtests/351236-1.html
rename : editor/composer/src/crashtests/407062-1.html => editor/composer/crashtests/407062-1.html
rename : editor/composer/src/crashtests/419563-1.xhtml => editor/composer/crashtests/419563-1.xhtml
rename : editor/composer/src/crashtests/428844-1-inner.xhtml => editor/composer/crashtests/428844-1-inner.xhtml
rename : editor/composer/src/crashtests/428844-1.html => editor/composer/crashtests/428844-1.html
rename : editor/composer/src/crashtests/461049-1.html => editor/composer/crashtests/461049-1.html
rename : editor/composer/src/crashtests/crashtests.list => editor/composer/crashtests/crashtests.list
rename : editor/composer/src/crashtests/removing-editable-xslt-inner.xhtml => editor/composer/crashtests/removing-editable-xslt-inner.xhtml
rename : editor/composer/src/crashtests/removing-editable-xslt.html => editor/composer/crashtests/removing-editable-xslt.html
rename : editor/composer/src/nsComposeTxtSrvFilter.cpp => editor/composer/nsComposeTxtSrvFilter.cpp
rename : editor/composer/src/nsComposeTxtSrvFilter.h => editor/composer/nsComposeTxtSrvFilter.h
rename : editor/composer/src/nsComposerCommands.cpp => editor/composer/nsComposerCommands.cpp
rename : editor/composer/src/nsComposerCommands.h => editor/composer/nsComposerCommands.h
rename : editor/composer/src/nsComposerCommandsUpdater.cpp => editor/composer/nsComposerCommandsUpdater.cpp
rename : editor/composer/src/nsComposerCommandsUpdater.h => editor/composer/nsComposerCommandsUpdater.h
rename : editor/composer/src/nsComposerController.cpp => editor/composer/nsComposerController.cpp
rename : editor/composer/src/nsComposerController.h => editor/composer/nsComposerController.h
rename : editor/composer/src/nsComposerDocumentCommands.cpp => editor/composer/nsComposerDocumentCommands.cpp
rename : editor/composer/src/nsComposerRegistration.cpp => editor/composer/nsComposerRegistration.cpp
rename : editor/composer/src/nsEditingSession.cpp => editor/composer/nsEditingSession.cpp
rename : editor/composer/src/nsEditingSession.h => editor/composer/nsEditingSession.h
rename : editor/composer/src/nsEditorSpellCheck.cpp => editor/composer/nsEditorSpellCheck.cpp
rename : editor/composer/src/nsEditorSpellCheck.h => editor/composer/nsEditorSpellCheck.h
rename : editor/composer/public/nsIEditingSession.idl => editor/composer/nsIEditingSession.idl
rename : editor/composer/src/res/EditorOverride.css => editor/composer/res/EditorOverride.css
rename : editor/composer/src/res/grabber.gif => editor/composer/res/grabber.gif
rename : editor/composer/src/res/table-add-column-after-active.gif => editor/composer/res/table-add-column-after-active.gif
rename : editor/composer/src/res/table-add-column-after-hover.gif => editor/composer/res/table-add-column-after-hover.gif
rename : editor/composer/src/res/table-add-column-after.gif => editor/composer/res/table-add-column-after.gif
rename : editor/composer/src/res/table-add-column-before-active.gif => editor/composer/res/table-add-column-before-active.gif
rename : editor/composer/src/res/table-add-column-before-hover.gif => editor/composer/res/table-add-column-before-hover.gif
rename : editor/composer/src/res/table-add-column-before.gif => editor/composer/res/table-add-column-before.gif
rename : editor/composer/src/res/table-add-row-after-active.gif => editor/composer/res/table-add-row-after-active.gif
rename : editor/composer/src/res/table-add-row-after-hover.gif => editor/composer/res/table-add-row-after-hover.gif
rename : editor/composer/src/res/table-add-row-after.gif => editor/composer/res/table-add-row-after.gif
rename : editor/composer/src/res/table-add-row-before-active.gif => editor/composer/res/table-add-row-before-active.gif
rename : editor/composer/src/res/table-add-row-before-hover.gif => editor/composer/res/table-add-row-before-hover.gif
rename : editor/composer/src/res/table-add-row-before.gif => editor/composer/res/table-add-row-before.gif
rename : editor/composer/src/res/table-remove-column-active.gif => editor/composer/res/table-remove-column-active.gif
rename : editor/composer/src/res/table-remove-column-hover.gif => editor/composer/res/table-remove-column-hover.gif
rename : editor/composer/src/res/table-remove-column.gif => editor/composer/res/table-remove-column.gif
rename : editor/composer/src/res/table-remove-row-active.gif => editor/composer/res/table-remove-row-active.gif
rename : editor/composer/src/res/table-remove-row-hover.gif => editor/composer/res/table-remove-row-hover.gif
rename : editor/composer/src/res/table-remove-row.gif => editor/composer/res/table-remove-row.gif
rename : editor/composer/src/res/text_caret.png => editor/composer/res/text_caret.png
rename : editor/composer/src/res/text_caret@1.5x.png => editor/composer/res/text_caret@1.5x.png
rename : editor/composer/src/res/text_caret@2.25x.png => editor/composer/res/text_caret@2.25x.png
rename : editor/composer/src/res/text_caret@2x.png => editor/composer/res/text_caret@2x.png
rename : editor/composer/src/res/text_caret_tilt_left.png => editor/composer/res/text_caret_tilt_left.png
rename : editor/composer/src/res/text_caret_tilt_left@1.5x.png => editor/composer/res/text_caret_tilt_left@1.5x.png
rename : editor/composer/src/res/text_caret_tilt_left@2.25x.png => editor/composer/res/text_caret_tilt_left@2.25x.png
rename : editor/composer/src/res/text_caret_tilt_left@2x.png => editor/composer/res/text_caret_tilt_left@2x.png
rename : editor/composer/src/res/text_caret_tilt_right.png => editor/composer/res/text_caret_tilt_right.png
rename : editor/composer/src/res/text_caret_tilt_right@1.5x.png => editor/composer/res/text_caret_tilt_right@1.5x.png
rename : editor/composer/src/res/text_caret_tilt_right@2.25x.png => editor/composer/res/text_caret_tilt_right@2.25x.png
rename : editor/composer/src/res/text_caret_tilt_right@2x.png => editor/composer/res/text_caret_tilt_right@2x.png
rename : editor/composer/src/res/text_selection_handle.png => editor/composer/res/text_selection_handle.png
rename : editor/composer/src/res/text_selection_handle@1.5.png => editor/composer/res/text_selection_handle@1.5.png
rename : editor/composer/src/res/text_selection_handle@2.png => editor/composer/res/text_selection_handle@2.png
2014-06-25 15:08:20 -07:00

282 lines
7.8 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#ifndef nsComposerCommands_h_
#define nsComposerCommands_h_
#include "nsIControllerCommand.h"
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED, etc
#include "nscore.h" // for nsresult, NS_IMETHOD
class nsIAtom;
class nsICommandParams;
class nsIEditor;
class nsISupports;
class nsString;
// 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.
// Also note that IsCommandEnabled can be called with an editor that may not
// have an editor yet (because the document is loading). Most commands will want
// to return false in this case.
// Don't hold on to any references to the editor or document from
// 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
{
protected:
virtual ~nsBaseComposerCommand() {}
public:
nsBaseComposerCommand();
// nsISupports
NS_DECL_ISUPPORTS
// nsIControllerCommand. Declared longhand so we can make them pure virtual
NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) = 0;
NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandRefCon) = 0;
};
#define NS_DECL_COMPOSER_COMMAND(_cmd) \
class _cmd : public nsBaseComposerCommand \
{ \
public: \
NS_DECL_NSICONTROLLERCOMMAND \
};
// virtual base class for commands that need to save and update Boolean state (like styles etc)
class nsBaseStateUpdatingCommand : public nsBaseComposerCommand
{
public:
nsBaseStateUpdatingCommand(nsIAtom* aTagName);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSICONTROLLERCOMMAND
protected:
virtual ~nsBaseStateUpdatingCommand();
// get the current state (on or off) for this style or block format
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams) = 0;
// add/remove the style
virtual nsresult ToggleState(nsIEditor* aEditor) = 0;
protected:
nsIAtom* mTagName;
};
// Shared class for the various style updating commands like bold, italics etc.
// Suitable for commands whose state is either 'on' or 'off'.
class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
{
public:
nsStyleUpdatingCommand(nsIAtom* aTagName);
protected:
// get the current state (on or off) for this style or block format
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
// add/remove the style
virtual nsresult ToggleState(nsIEditor* aEditor);
};
class nsInsertTagCommand : public nsBaseComposerCommand
{
public:
explicit nsInsertTagCommand(nsIAtom* aTagName);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSICONTROLLERCOMMAND
protected:
virtual ~nsInsertTagCommand();
nsIAtom* mTagName;
};
class nsListCommand : public nsBaseStateUpdatingCommand
{
public:
nsListCommand(nsIAtom* aTagName);
protected:
// get the current state (on or off) for this style or block format
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
// add/remove the style
virtual nsresult ToggleState(nsIEditor* aEditor);
};
class nsListItemCommand : public nsBaseStateUpdatingCommand
{
public:
nsListItemCommand(nsIAtom* aTagName);
protected:
// get the current state (on or off) for this style or block format
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
// add/remove the style
virtual nsresult ToggleState(nsIEditor* aEditor);
};
// Base class for commands whose state consists of a string (e.g. para format)
class nsMultiStateCommand : public nsBaseComposerCommand
{
public:
nsMultiStateCommand();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSICONTROLLERCOMMAND
protected:
virtual ~nsMultiStateCommand();
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
};
class nsParagraphStateCommand : public nsMultiStateCommand
{
public:
nsParagraphStateCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsFontFaceStateCommand : public nsMultiStateCommand
{
public:
nsFontFaceStateCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsFontSizeStateCommand : public nsMultiStateCommand
{
public:
nsFontSizeStateCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor,
nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsHighlightColorStateCommand : public nsMultiStateCommand
{
public:
nsHighlightColorStateCommand();
protected:
NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsFontColorStateCommand : public nsMultiStateCommand
{
public:
nsFontColorStateCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsAlignCommand : public nsMultiStateCommand
{
public:
nsAlignCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsBackgroundColorStateCommand : public nsMultiStateCommand
{
public:
nsBackgroundColorStateCommand();
protected:
virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
};
class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand
{
public:
nsAbsolutePositioningCommand();
protected:
NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
virtual nsresult GetCurrentState(nsIEditor* aEditor, nsICommandParams* aParams);
virtual nsresult ToggleState(nsIEditor* aEditor);
};
// composer commands
NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)
//NS_DECL_COMPOSER_COMMAND(nsPrintingCommands)
NS_DECL_COMPOSER_COMMAND(nsDecreaseZIndexCommand)
NS_DECL_COMPOSER_COMMAND(nsIncreaseZIndexCommand)
// Generic commands
// File menu
NS_DECL_COMPOSER_COMMAND(nsNewCommands) // handles 'new' anything
// Edit menu
NS_DECL_COMPOSER_COMMAND(nsPasteNoFormattingCommand)
// Block transformations
NS_DECL_COMPOSER_COMMAND(nsIndentCommand)
NS_DECL_COMPOSER_COMMAND(nsOutdentCommand)
NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand)
NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand)
NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand)
NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand)
// Insert content commands
NS_DECL_COMPOSER_COMMAND(nsInsertHTMLCommand)
#endif // nsComposerCommands_h_