diff --git a/mozilla/editor/base/nsComposerCommands.cpp b/mozilla/editor/base/nsComposerCommands.cpp index f2622274767..93f683e3c3f 100644 --- a/mozilla/editor/base/nsComposerCommands.cpp +++ b/mozilla/editor/base/nsComposerCommands.cpp @@ -409,7 +409,8 @@ nsListCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char* aTagNam nsresult rv = aEditorShell->GetListState(&bMixed, &tagStr); if (NS_FAILED(rv)) return rv; - outInList = (0 == nsCRT::strcmp(tagStr, aTagName)); + // Need to use mTagName???? + outInList = (0 == nsCRT::strcmp(tagStr, mTagName)); if (tagStr) nsCRT::free(tagStr); @@ -421,10 +422,10 @@ nsresult nsListCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagName) { PRBool inList; - nsresult rv = GetCurrentState(aEditorShell, aTagName, inList); + // Need to use mTagName???? + nsresult rv = GetCurrentState(aEditorShell, mTagName, inList); if (NS_FAILED(rv)) return rv; - - nsAutoString listType; listType.AssignWithConversion(aTagName); + nsAutoString listType; listType.AssignWithConversion(mTagName); if (inList) rv = aEditorShell->RemoveList(listType.GetUnicode()); @@ -454,7 +455,7 @@ nsListItemCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char* aTa nsresult rv = aEditorShell->GetListItemState(&bMixed, &tagStr); if (NS_FAILED(rv)) return rv; - outInList = (0 == nsCRT::strcmp(tagStr, aTagName)); + outInList = (0 == nsCRT::strcmp(tagStr, mTagName)); if (tagStr) nsCRT::free(tagStr); @@ -472,7 +473,8 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED; PRBool inList; - nsresult rv = GetCurrentState(aEditorShell, aTagName, inList); + // Need to use mTagName???? + nsresult rv = GetCurrentState(aEditorShell, mTagName, inList); if (NS_FAILED(rv)) return rv; if (inList) @@ -494,7 +496,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam } else { - nsAutoString itemType; itemType.AssignWithConversion(aTagName); + nsAutoString itemType; itemType.AssignWithConversion(mTagName); // Set to the requested paragraph type //XXX Note: This actually doesn't work for "LI", // but we currently don't use this for non DL lists anyway. @@ -506,6 +508,43 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam } +#ifdef XP_MAC +#pragma mark - +#endif +NS_IMETHODIMP +nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +{ + nsCOMPtr editorShell = do_QueryInterface(refCon); + *outCmdEnabled = PR_FALSE; + if (editorShell) + { + // It is enabled if we are in any list type + PRBool bMixed; + PRUnichar *tagStr; + nsresult rv = editorShell->GetListState(&bMixed, &tagStr); + if (NS_FAILED(rv)) return rv; + + *outCmdEnabled = (*tagStr != nsnull); + } + + return NS_OK; +} + + +NS_IMETHODIMP +nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +{ + nsCOMPtr editorShell = do_QueryInterface(refCon); + + nsresult rv = NS_OK; + if (editorShell) + // This removes any list type + rv = editorShell->RemoveList(nsnull); + + return rv; +} + + #ifdef XP_MAC #pragma mark - #endif diff --git a/mozilla/editor/base/nsComposerCommands.h b/mozilla/editor/base/nsComposerCommands.h index a9133bb6320..04cb653a639 100644 --- a/mozilla/editor/base/nsComposerCommands.h +++ b/mozilla/editor/base/nsComposerCommands.h @@ -223,6 +223,7 @@ NS_DECL_COMPOSER_COMMAND(nsIndentCommand) NS_DECL_COMPOSER_COMMAND(nsOutdentCommand) NS_DECL_COMPOSER_COMMAND(nsAlignCommand) +NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand) NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand) NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand) NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand) diff --git a/mozilla/editor/base/nsEditorController.cpp b/mozilla/editor/base/nsEditorController.cpp index 9916f18f44e..ab0a9fad8bc 100644 --- a/mozilla/editor/base/nsEditorController.cpp +++ b/mozilla/editor/base/nsEditorController.cpp @@ -324,10 +324,11 @@ nsresult nsComposerController::RegisterComposerCommands(nsIControllerCommandMana NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", "var"); // lists - NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol"); - NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul"); + NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol"); + NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul"); NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", "dt"); NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", "dd"); + NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList"); // format stuff NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState"); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index bc2b28058c3..4e33317e2fe 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -3367,24 +3367,15 @@ nsEditorShell::RemoveList(const PRUnichar *listType) { nsresult err = NS_NOINTERFACE; - nsAutoString aListType(listType); switch (mEditorType) { case eHTMLTextEditorType: - if (aListType.IsEmpty()) - { - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol")); - if(NS_SUCCEEDED(err)) - { - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul")); - if(NS_SUCCEEDED(err)) - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl")); - } - } - else - err = mEditor->RemoveList(aListType); + { + nsAutoString aListType(listType); + err = mEditor->RemoveList(aListType); break; + } case ePlainTextEditorType: default: diff --git a/mozilla/editor/composer/src/nsComposerCommands.cpp b/mozilla/editor/composer/src/nsComposerCommands.cpp index f2622274767..93f683e3c3f 100644 --- a/mozilla/editor/composer/src/nsComposerCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerCommands.cpp @@ -409,7 +409,8 @@ nsListCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char* aTagNam nsresult rv = aEditorShell->GetListState(&bMixed, &tagStr); if (NS_FAILED(rv)) return rv; - outInList = (0 == nsCRT::strcmp(tagStr, aTagName)); + // Need to use mTagName???? + outInList = (0 == nsCRT::strcmp(tagStr, mTagName)); if (tagStr) nsCRT::free(tagStr); @@ -421,10 +422,10 @@ nsresult nsListCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagName) { PRBool inList; - nsresult rv = GetCurrentState(aEditorShell, aTagName, inList); + // Need to use mTagName???? + nsresult rv = GetCurrentState(aEditorShell, mTagName, inList); if (NS_FAILED(rv)) return rv; - - nsAutoString listType; listType.AssignWithConversion(aTagName); + nsAutoString listType; listType.AssignWithConversion(mTagName); if (inList) rv = aEditorShell->RemoveList(listType.GetUnicode()); @@ -454,7 +455,7 @@ nsListItemCommand::GetCurrentState(nsIEditorShell *aEditorShell, const char* aTa nsresult rv = aEditorShell->GetListItemState(&bMixed, &tagStr); if (NS_FAILED(rv)) return rv; - outInList = (0 == nsCRT::strcmp(tagStr, aTagName)); + outInList = (0 == nsCRT::strcmp(tagStr, mTagName)); if (tagStr) nsCRT::free(tagStr); @@ -472,7 +473,8 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam if (!htmlEditor) return NS_ERROR_NOT_INITIALIZED; PRBool inList; - nsresult rv = GetCurrentState(aEditorShell, aTagName, inList); + // Need to use mTagName???? + nsresult rv = GetCurrentState(aEditorShell, mTagName, inList); if (NS_FAILED(rv)) return rv; if (inList) @@ -494,7 +496,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam } else { - nsAutoString itemType; itemType.AssignWithConversion(aTagName); + nsAutoString itemType; itemType.AssignWithConversion(mTagName); // Set to the requested paragraph type //XXX Note: This actually doesn't work for "LI", // but we currently don't use this for non DL lists anyway. @@ -506,6 +508,43 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam } +#ifdef XP_MAC +#pragma mark - +#endif +NS_IMETHODIMP +nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +{ + nsCOMPtr editorShell = do_QueryInterface(refCon); + *outCmdEnabled = PR_FALSE; + if (editorShell) + { + // It is enabled if we are in any list type + PRBool bMixed; + PRUnichar *tagStr; + nsresult rv = editorShell->GetListState(&bMixed, &tagStr); + if (NS_FAILED(rv)) return rv; + + *outCmdEnabled = (*tagStr != nsnull); + } + + return NS_OK; +} + + +NS_IMETHODIMP +nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +{ + nsCOMPtr editorShell = do_QueryInterface(refCon); + + nsresult rv = NS_OK; + if (editorShell) + // This removes any list type + rv = editorShell->RemoveList(nsnull); + + return rv; +} + + #ifdef XP_MAC #pragma mark - #endif diff --git a/mozilla/editor/composer/src/nsComposerCommands.h b/mozilla/editor/composer/src/nsComposerCommands.h index a9133bb6320..04cb653a639 100644 --- a/mozilla/editor/composer/src/nsComposerCommands.h +++ b/mozilla/editor/composer/src/nsComposerCommands.h @@ -223,6 +223,7 @@ NS_DECL_COMPOSER_COMMAND(nsIndentCommand) NS_DECL_COMPOSER_COMMAND(nsOutdentCommand) NS_DECL_COMPOSER_COMMAND(nsAlignCommand) +NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand) NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand) NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand) NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand) diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index bc2b28058c3..4e33317e2fe 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -3367,24 +3367,15 @@ nsEditorShell::RemoveList(const PRUnichar *listType) { nsresult err = NS_NOINTERFACE; - nsAutoString aListType(listType); switch (mEditorType) { case eHTMLTextEditorType: - if (aListType.IsEmpty()) - { - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ol")); - if(NS_SUCCEEDED(err)) - { - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("ul")); - if(NS_SUCCEEDED(err)) - err = mEditor->RemoveList(NS_ConvertASCIItoUCS2("dl")); - } - } - else - err = mEditor->RemoveList(aListType); + { + nsAutoString aListType(listType); + err = mEditor->RemoveList(aListType); break; + } case ePlainTextEditorType: default: diff --git a/mozilla/editor/libeditor/base/nsEditorController.cpp b/mozilla/editor/libeditor/base/nsEditorController.cpp index 9916f18f44e..ab0a9fad8bc 100644 --- a/mozilla/editor/libeditor/base/nsEditorController.cpp +++ b/mozilla/editor/libeditor/base/nsEditorController.cpp @@ -324,10 +324,11 @@ nsresult nsComposerController::RegisterComposerCommands(nsIControllerCommandMana NS_REGISTER_STYLE_COMMAND(nsStyleUpdatingCommand, "cmd_var", "var"); // lists - NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol"); - NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul"); + NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ol", "ol"); + NS_REGISTER_STYLE_COMMAND(nsListCommand, "cmd_ul", "ul"); NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dt", "dt"); NS_REGISTER_STYLE_COMMAND(nsListItemCommand, "cmd_dd", "dd"); + NS_REGISTER_ONE_COMMAND(nsRemoveListCommand, "cmd_removeList"); // format stuff NS_REGISTER_ONE_COMMAND(nsParagraphStateCommand, "cmd_paragraphState");