Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions
nsAlignCommand Class Reference

#include <nsComposerCommands.h>

Inheritance diagram for nsAlignCommand:
Inheritance graph
[legend]
Collaboration diagram for nsAlignCommand:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsAlignCommand ()
NS_DECL_ISUPPORTS NS_IMETHOD IsCommandEnabled (const char *aCommandName, nsISupports *aCommandRefCon, PRBool *_retval)=0
NS_IMETHOD DoCommand (const char *aCommandName, nsISupports *aCommandRefCon)=0
boolean isCommandEnabled (in string aCommandName, in nsISupports aCommandContext)
 Returns true if the command is currently enabled.
void getCommandStateParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext)
void doCommand (in string aCommandName, in nsISupports aCommandContext)
 Execute the name command.
void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext)

Protected Member Functions

virtual nsresult GetCurrentState (nsIEditor *aEditor, nsICommandParams *aParams)
virtual nsresult SetState (nsIEditor *aEditor, nsString &newState)

Detailed Description

Definition at line 251 of file nsComposerCommands.h.


Constructor & Destructor Documentation

Definition at line 1030 of file nsComposerCommands.cpp.


Member Function Documentation

NS_IMETHOD nsBaseComposerCommand::DoCommand ( const char *  aCommandName,
nsISupports *  aCommandRefCon 
) [pure virtual, inherited]
void nsIControllerCommand::doCommand ( in string  aCommandName,
in nsISupports  aCommandContext 
) [inherited]

Execute the name command.

Parameters:
aCommandNamethe name of the command to execute.
aCommandContexta cookie held by the nsIControllerCommandTable, allowing the command to get some context information. The contents of this cookie are implementation-defined.
void nsIControllerCommand::doCommandParams ( in string  aCommandName,
in nsICommandParams  aParams,
in nsISupports  aCommandContext 
) [inherited]
void nsIControllerCommand::getCommandStateParams ( in string  aCommandName,
in nsICommandParams  aParams,
in nsISupports  aCommandContext 
) [inherited]
nsresult nsAlignCommand::GetCurrentState ( nsIEditor aEditor,
nsICommandParams aParams 
) [protected, virtual]

Implements nsMultiStateCommand.

Definition at line 1036 of file nsComposerCommands.cpp.

{
  NS_ASSERTION(aEditor, "Need an editor here");
  
  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
  if (!htmlEditor) return NS_ERROR_FAILURE;
 
  nsIHTMLEditor::EAlignment firstAlign;
  PRBool outMixed;
  nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
  
  if (NS_FAILED(rv)) 
    return rv;
  
  nsAutoString outStateString;
  switch (firstAlign)
  {
    default:
    case nsIHTMLEditor::eLeft:
      outStateString.AssignLiteral("left");
      break;
      
    case nsIHTMLEditor::eCenter:
      outStateString.AssignLiteral("center");
      break;
      
    case nsIHTMLEditor::eRight:
      outStateString.AssignLiteral("right");
      break;

    case nsIHTMLEditor::eJustify:
      outStateString.AssignLiteral("justify");
      break;
  }
  nsCAutoString tOutStateString;
  tOutStateString.AssignWithConversion(outStateString);
  aParams->SetBooleanValue(STATE_MIXED,outMixed);
  aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
  return NS_OK;
}

Here is the call graph for this function:

boolean nsIControllerCommand::isCommandEnabled ( in string  aCommandName,
in nsISupports  aCommandContext 
) [inherited]

Returns true if the command is currently enabled.

An nsIControllerCommand can implement more than one commands; say, a group of related commands (e.g. delete left/delete right). Because of this, the command name is passed to each method.

Parameters:
aCommandNamethe name of the command for which we want the enabled state.
aCommandContexta cookie held by the nsIControllerCommandTable, allowing the command to get some context information. The contents of this cookie are implementation-defined.
NS_DECL_ISUPPORTS NS_IMETHOD nsBaseComposerCommand::IsCommandEnabled ( const char *  aCommandName,
nsISupports *  aCommandRefCon,
PRBool _retval 
) [pure virtual, inherited]
nsresult nsAlignCommand::SetState ( nsIEditor aEditor,
nsString newState 
) [protected, virtual]

Implements nsMultiStateCommand.

Definition at line 1078 of file nsComposerCommands.cpp.

{
  NS_ASSERTION(aEditor, "Need an editor here");
  
  nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
  if (!htmlEditor) return NS_ERROR_FAILURE;

  return htmlEditor->Align(newState);
}

Here is the call graph for this function:


The documentation for this class was generated from the following files: