LCOV - code coverage report
Current view: directory - editor/composer/src - nsComposerCommands.h (source / functions) Found Hit Coverage
Test: app.info Lines: 25 0 0.0 %
Date: 2012-06-02 Functions: 63 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998-2000
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Ryan Cassin      <rcassin@supernova.org>
      24                 :  *   Daniel Glazman   <glazman@netscape.com>
      25                 :  *   Charles Manske   <cmanske@netscape.com>
      26                 :  *
      27                 :  * Alternatively, the contents of this file may be used under the terms of
      28                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      29                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      30                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      31                 :  * of those above. If you wish to allow use of your version of this file only
      32                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      33                 :  * use your version of this file under the terms of the MPL, indicate your
      34                 :  * decision by deleting the provisions above and replace them with the notice
      35                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      36                 :  * the provisions above, a recipient may use your version of this file under
      37                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      38                 :  *
      39                 :  * ***** END LICENSE BLOCK ***** */
      40                 : 
      41                 : #ifndef nsComposerCommands_h_
      42                 : #define nsComposerCommands_h_
      43                 : 
      44                 : #include "nsIControllerCommand.h"
      45                 : #include "nsString.h"
      46                 : 
      47                 : class nsIEditor;
      48                 : 
      49                 : // This is a virtual base class for commands registered with the composer controller.
      50                 : // Note that such commands are instantiated once per composer, so can store state.
      51                 : // Also note that IsCommandEnabled can be called with an editor that may not
      52                 : // have an editor yet (because the document is loading). Most commands will want
      53                 : // to return false in this case.
      54                 : // Don't hold on to any references to the editor or document from
      55                 : // your command. This will cause leaks. Also, be aware that the document the
      56                 : // editor is editing can change under you (if the user Reverts the file, for
      57                 : // instance).
      58                 : class nsBaseComposerCommand : public nsIControllerCommand
      59                 : {
      60                 : public:
      61                 : 
      62                 :               nsBaseComposerCommand();
      63               0 :   virtual     ~nsBaseComposerCommand() {}
      64                 :     
      65                 :   // nsISupports
      66                 :   NS_DECL_ISUPPORTS
      67                 :     
      68                 :   // nsIControllerCommand. Declared longhand so we can make them pure virtual
      69                 :   NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *_retval) = 0;
      70                 :   NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandRefCon) = 0;
      71                 : 
      72                 : };
      73                 : 
      74                 : 
      75                 : #define NS_DECL_COMPOSER_COMMAND(_cmd)                  \
      76                 : class _cmd : public nsBaseComposerCommand               \
      77                 : {                                                       \
      78                 : public:                                                 \
      79                 :   NS_DECL_NSICONTROLLERCOMMAND                          \
      80                 : };
      81                 : 
      82                 : // virtual base class for commands that need to save and update Boolean state (like styles etc)
      83                 : class nsBaseStateUpdatingCommand : public nsBaseComposerCommand
      84                 : {
      85                 : public:
      86                 : 
      87                 :               nsBaseStateUpdatingCommand(const char* aTagName);
      88                 :   virtual     ~nsBaseStateUpdatingCommand();
      89                 :     
      90                 :   NS_DECL_ISUPPORTS_INHERITED
      91                 : 
      92                 :   NS_DECL_NSICONTROLLERCOMMAND
      93                 : 
      94                 : protected:
      95                 : 
      96                 :   // get the current state (on or off) for this style or block format
      97                 :   virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) = 0;
      98                 :   
      99                 :   // add/remove the style
     100                 :   virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName) = 0;
     101                 : 
     102                 : protected:
     103                 : 
     104                 :   const char* mTagName;
     105                 : };
     106                 : 
     107                 : 
     108                 : // Shared class for the various style updating commands like bold, italics etc.
     109                 : // Suitable for commands whose state is either 'on' or 'off'.
     110                 : class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
     111               0 : {
     112                 : public:
     113                 : 
     114                 :             nsStyleUpdatingCommand(const char* aTagName);
     115                 :            
     116                 : protected:
     117                 : 
     118                 :   // get the current state (on or off) for this style or block format
     119                 :   virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
     120                 :   
     121                 :   // add/remove the style
     122                 :   virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
     123                 :   
     124                 : };
     125                 : 
     126                 : 
     127                 : class nsInsertTagCommand : public nsBaseComposerCommand
     128                 : {
     129                 : public:
     130                 : 
     131                 :               nsInsertTagCommand(const char* aTagName);
     132                 :   virtual     ~nsInsertTagCommand();
     133                 :     
     134                 :   NS_DECL_ISUPPORTS_INHERITED
     135                 : 
     136                 :   NS_DECL_NSICONTROLLERCOMMAND
     137                 : 
     138                 : protected:
     139                 : 
     140                 :   const char* mTagName;
     141                 : };
     142                 : 
     143                 : 
     144                 : class nsListCommand : public nsBaseStateUpdatingCommand
     145               0 : {
     146                 : public:
     147                 : 
     148                 :             nsListCommand(const char* aTagName);
     149                 : 
     150                 : protected:
     151                 : 
     152                 :   // get the current state (on or off) for this style or block format
     153                 :   virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
     154                 :   
     155                 :   // add/remove the style
     156                 :   virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
     157                 : };
     158                 : 
     159                 : class nsListItemCommand : public nsBaseStateUpdatingCommand
     160               0 : {
     161                 : public:
     162                 : 
     163                 :             nsListItemCommand(const char* aTagName);
     164                 : 
     165                 : protected:
     166                 : 
     167                 :   // get the current state (on or off) for this style or block format
     168                 :   virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
     169                 :   
     170                 :   // add/remove the style
     171                 :   virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
     172                 : };
     173                 : 
     174                 : // Base class for commands whose state consists of a string (e.g. para format)
     175                 : class nsMultiStateCommand : public nsBaseComposerCommand
     176                 : {
     177                 : public:
     178                 :   
     179                 :                    nsMultiStateCommand();
     180                 :   virtual          ~nsMultiStateCommand();
     181                 :   
     182                 :   NS_DECL_ISUPPORTS_INHERITED
     183                 :   NS_DECL_NSICONTROLLERCOMMAND
     184                 : 
     185                 : protected:
     186                 : 
     187                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
     188                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
     189                 :   
     190                 : };
     191                 : 
     192                 : 
     193                 : class nsParagraphStateCommand : public nsMultiStateCommand
     194               0 : {
     195                 : public:
     196                 :                    nsParagraphStateCommand();
     197                 : 
     198                 : protected:
     199                 : 
     200                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     201                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     202                 : };
     203                 : 
     204                 : class nsFontFaceStateCommand : public nsMultiStateCommand
     205               0 : {
     206                 : public:
     207                 :                    nsFontFaceStateCommand();
     208                 : 
     209                 : protected:
     210                 : 
     211                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     212                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     213                 : };
     214                 : 
     215                 : class nsFontSizeStateCommand : public nsMultiStateCommand
     216               0 : {
     217                 : public:
     218                 :                    nsFontSizeStateCommand();
     219                 : 
     220                 : protected:
     221                 : 
     222                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor,
     223                 :                                    nsICommandParams* aParams);
     224                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     225                 : };
     226                 : 
     227                 : class nsHighlightColorStateCommand : public nsMultiStateCommand
     228               0 : {
     229                 : public:
     230                 :                    nsHighlightColorStateCommand();
     231                 : 
     232                 : protected:
     233                 : 
     234                 :   NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
     235                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     236                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     237                 : 
     238                 : };
     239                 : 
     240                 : class nsFontColorStateCommand : public nsMultiStateCommand
     241               0 : {
     242                 : public:
     243                 :                    nsFontColorStateCommand();
     244                 : 
     245                 : protected:
     246                 : 
     247                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     248                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     249                 : };
     250                 : 
     251                 : class nsAlignCommand : public nsMultiStateCommand
     252               0 : {
     253                 : public:
     254                 :                    nsAlignCommand();
     255                 : 
     256                 : protected:
     257                 : 
     258                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     259                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     260                 : };
     261                 : 
     262                 : class nsBackgroundColorStateCommand : public nsMultiStateCommand
     263               0 : {
     264                 : public:
     265                 :                    nsBackgroundColorStateCommand();
     266                 : 
     267                 : protected:
     268                 : 
     269                 :   virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
     270                 :   virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
     271                 : };
     272                 : 
     273                 : class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand
     274               0 : {
     275                 : public:
     276                 :                    nsAbsolutePositioningCommand();
     277                 : 
     278                 : protected:
     279                 : 
     280                 :   NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *_retval);
     281                 :   virtual nsresult  GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
     282                 :   virtual nsresult  ToggleState(nsIEditor *aEditor, const char* aTagName);
     283                 : };
     284                 : 
     285                 : // composer commands
     286                 : 
     287                 : NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
     288               0 : NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
     289               0 : NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
     290               0 : NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)
     291                 : //NS_DECL_COMPOSER_COMMAND(nsPrintingCommands)
     292                 : 
     293               0 : NS_DECL_COMPOSER_COMMAND(nsDecreaseZIndexCommand)
     294               0 : NS_DECL_COMPOSER_COMMAND(nsIncreaseZIndexCommand)
     295                 : 
     296                 : // Generic commands
     297                 : 
     298                 : // File menu
     299                 : NS_DECL_COMPOSER_COMMAND(nsNewCommands)   // handles 'new' anything
     300                 : 
     301                 : // Edit menu
     302               0 : NS_DECL_COMPOSER_COMMAND(nsPasteNoFormattingCommand)
     303                 : 
     304                 : // Block transformations
     305               0 : NS_DECL_COMPOSER_COMMAND(nsIndentCommand)
     306               0 : NS_DECL_COMPOSER_COMMAND(nsOutdentCommand)
     307                 : 
     308               0 : NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand)
     309               0 : NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand)
     310               0 : NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand)
     311               0 : NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand)
     312                 : 
     313                 : // Insert content commands
     314               0 : NS_DECL_COMPOSER_COMMAND(nsInsertHTMLCommand)
     315                 : 
     316                 : #endif // nsComposerCommands_h_

Generated by: LCOV version 1.7