diff --git a/mozilla/editor/composer/src/nsComposerCommands.cpp b/mozilla/editor/composer/src/nsComposerCommands.cpp index 32877cb3be1..93d2b1640b3 100644 --- a/mozilla/editor/composer/src/nsComposerCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerCommands.cpp @@ -189,6 +189,12 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const nsAString & aCommandName, nsI // also udpate the command state. UpdateCommandState(aCommandName, refCon); } + else + { + nsCOMPtr 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 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 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 editor = do_QueryInterface(refCon); + if (editor) + editor->RemoveAllInlineProperties(); + + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp b/mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp index 7e574c8d1b2..1e9eb635f0f 100644 --- a/mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp +++ b/mozilla/editor/composer/src/nsComposerCommandsUpdater.cpp @@ -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 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; } diff --git a/mozilla/editor/libeditor/base/nsEditorController.cpp b/mozilla/editor/libeditor/base/nsEditorController.cpp index 3a607cf232c..a2bffd8dbfd 100644 --- a/mozilla/editor/libeditor/base/nsEditorController.cpp +++ b/mozilla/editor/libeditor/base/nsEditorController.cpp @@ -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); +} + diff --git a/mozilla/editor/libeditor/base/nsEditorController.h b/mozilla/editor/libeditor/base/nsEditorController.h index a86135302f2..5d453f62124 100644 --- a/mozilla/editor/libeditor/base/nsEditorController.h +++ b/mozilla/editor/libeditor/base/nsEditorController.h @@ -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