ssaux for rogermw. Apply patch to bug 169784 to resolve the undo problem
git-svn-id: svn://10.0.0.236/branches/PHT_2002_08_08_BRANCH@130946 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -189,6 +189,12 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const nsAString & aCommandName, nsI
|
||||
// also udpate the command state.
|
||||
UpdateCommandState(aCommandName, refCon);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
|
||||
if (editor)
|
||||
*outCmdEnabled = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -799,6 +805,12 @@ nsIndentCommand::IsCommandEnabled(const nsAString & aCommandName, nsISupports *r
|
||||
if (editor)
|
||||
*outCmdEnabled = PR_TRUE; // can always indent (I guess)
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
|
||||
if (editor)
|
||||
*outCmdEnabled = PR_TRUE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -868,6 +880,17 @@ nsOutdentCommand::IsCommandEnabled(const nsAString & aCommandName, nsISupports *
|
||||
*outCmdEnabled = canOutdent;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
|
||||
if (htmlEditor)
|
||||
{
|
||||
PRBool canIndent, canOutdent;
|
||||
htmlEditor->GetIndentState(&canIndent, &canOutdent);
|
||||
|
||||
*outCmdEnabled = canOutdent;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1643,9 +1666,11 @@ nsRemoveStylesCommand::DoCommand(const nsAString & aCommandName, nsISupports *re
|
||||
NS_IMETHODIMP
|
||||
nsRemoveStylesCommand::DoCommandParams(nsICommandParams *aParams, nsISupports *refCon)
|
||||
{
|
||||
nsString tString;
|
||||
aParams->GetStringValue(COMMAND_NAME,tString);
|
||||
return DoCommand(tString, refCon);
|
||||
nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);
|
||||
if (editor)
|
||||
editor->RemoveAllInlineProperties();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
||||
@@ -243,7 +243,7 @@ nsComposerCommandsUpdater::UpdateDirtyState(PRBool aNowDirty)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommand)
|
||||
nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommandGroup)
|
||||
{
|
||||
if (!mDocShell)
|
||||
{
|
||||
@@ -273,10 +273,49 @@ nsComposerCommandsUpdater::CallUpdateCommands(const nsAString& aCommand)
|
||||
nsCOMPtr<nsPICommandUpdater> commandUpdater = do_QueryInterface(commandManager);
|
||||
if (!commandUpdater) return NS_ERROR_FAILURE;
|
||||
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_bold"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_italic"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_underline"));
|
||||
// this hardcoded list of commands in temporary. This code should
|
||||
// use nsICommandGroup.
|
||||
if (aCommandGroup.Equals(NS_LITERAL_STRING("undo")))
|
||||
{
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_undo"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_redo"));
|
||||
}
|
||||
else if (aCommandGroup.Equals(NS_LITERAL_STRING("select")) ||
|
||||
aCommandGroup.Equals(NS_LITERAL_STRING("style")))
|
||||
{
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_bold"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_italic"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_underline"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_tt"));
|
||||
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_strikethrough"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_superscript"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_subscript"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_nobreak"));
|
||||
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_em"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_strong"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_cite"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_abbr"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_acronym"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_code"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_samp"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_var"));
|
||||
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_increaseFont"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_decreaseFont"));
|
||||
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_paragraphState"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_fontFace"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_fontColor"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_backgroundColor"));
|
||||
commandUpdater->CommandStatusChanged(NS_LITERAL_STRING("cmd_highlight"));
|
||||
}
|
||||
else if (aCommandGroup.Equals(NS_LITERAL_STRING("save")))
|
||||
{
|
||||
// save commands (none in C++)
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -240,3 +240,18 @@ nsresult nsEditorController::GetEditorCommandManager(nsIControllerCommandManager
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsEditorController::GetCommandState(nsICommandParams *aCommandParams)
|
||||
{
|
||||
if (!mCommandRefCon || !mCommandManager)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return mCommandManager->GetCommandState(aCommandParams,mCommandRefCon);
|
||||
}
|
||||
|
||||
/* void doCommand (in DOMString aCommandName, in nsICommandParams aCommandParams); */
|
||||
NS_IMETHODIMP nsEditorController::DoCommand(nsICommandParams *aCommandParams)
|
||||
{
|
||||
if (!mCommandRefCon || !mCommandManager)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return mCommandManager->DoCommandParams(aCommandParams,mCommandRefCon);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ class nsIEditor;
|
||||
// commands in composer. The refCon that gets passed to its commands is an nsIEditor.
|
||||
|
||||
class nsEditorController : public nsIController,
|
||||
public nsICommandController,
|
||||
public nsIEditorController,
|
||||
public nsIInterfaceRequestor
|
||||
{
|
||||
@@ -85,6 +86,9 @@ public:
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
//nsICommandController
|
||||
NS_DECL_NSICOMMANDCONTROLLER
|
||||
|
||||
protected:
|
||||
|
||||
//if editor is null then look to mContent. this is for dual use of window and content
|
||||
|
||||
Reference in New Issue
Block a user