From d25dc606fd1cff0c6416f5834dd967bd0214e76b Mon Sep 17 00:00:00 2001 From: Jesper Kristensen Date: Tue, 29 Nov 2011 20:20:22 +0000 Subject: [PATCH] Bug 688860 - Cannot switch spell check language with multiple compose windows open. r=Standard8 --- editor/ui/dialogs/content/EdSpellCheck.js | 6 ------ .../compose/content/MsgComposeCommands.js | 17 +++++------------ suite/mailnews/compose/MsgComposeCommands.js | 11 +++++------ 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/editor/ui/dialogs/content/EdSpellCheck.js b/editor/ui/dialogs/content/EdSpellCheck.js index 57d6efc066..5b10890e74 100644 --- a/editor/ui/dialogs/content/EdSpellCheck.js +++ b/editor/ui/dialogs/content/EdSpellCheck.js @@ -561,13 +561,7 @@ function ExitSpellChecker() { try { - var curLang = gSpellChecker.GetCurrentDictionary(); gSpellChecker.UninitSpellChecker(); - if ("@mozilla.org/spellchecker;1" in Components.classes) { - var spellChecker = Components.classes["@mozilla.org/spellchecker/engine;1"] - .getService(Components.interfaces.mozISpellCheckingEngine); - spellChecker.dictionary = curLang; - } // now check the document over again with the new dictionary // if we have an inline spellchecker if (("InlineSpellCheckerUI" in window.opener) && diff --git a/mail/components/compose/content/MsgComposeCommands.js b/mail/components/compose/content/MsgComposeCommands.js index 6cb21d55b5..5cccb968b4 100644 --- a/mail/components/compose/content/MsgComposeCommands.js +++ b/mail/components/compose/content/MsgComposeCommands.js @@ -2541,7 +2541,8 @@ function InitLanguageMenu() function OnShowDictionaryMenu(aTarget) { InitLanguageMenu(); - var curLang = getPref("spellchecker.dictionary", true); + var spellChecker = gSpellChecker.mInlineSpellChecker.spellChecker; + var curLang = spellChecker.GetCurrentDictionary(); var languages = aTarget.getElementsByAttribute("value", curLang); if (languages.length > 0) languages[0].setAttribute("checked", true); @@ -2552,18 +2553,10 @@ function ChangeLanguage(event) // We need to change the dictionary language and if we are using inline spell check, // recheck the message - var spellChecker = Components.classes['@mozilla.org/spellchecker/engine;1'] - .getService(mozISpellCheckingEngine); - if (spellChecker.dictionary != event.target.value) + var spellChecker = gSpellChecker.mInlineSpellChecker.spellChecker; + if (spellChecker.GetCurrentDictionary() != event.target.value) { - spellChecker.dictionary = event.target.value; - var str = Components.classes["@mozilla.org/supports-string;1"] - .createInstance(nsISupportsString); - str.data = event.target.value; - var branch = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); - - branch.setComplexValue("spellchecker.dictionary", nsISupportsString, str); + spellChecker.SetCurrentDictionary(event.target.value); // now check the document over again with the new dictionary if (gSpellChecker.enabled) diff --git a/suite/mailnews/compose/MsgComposeCommands.js b/suite/mailnews/compose/MsgComposeCommands.js index 897eddc54b..27f5c235f8 100644 --- a/suite/mailnews/compose/MsgComposeCommands.js +++ b/suite/mailnews/compose/MsgComposeCommands.js @@ -2204,7 +2204,8 @@ function InitLanguageMenu() function OnShowDictionaryMenu(aTarget) { InitLanguageMenu(); - var curLang = GetStringPref("spellchecker.dictionary"); + var spellChecker = gSpellChecker.mInlineSpellChecker.spellChecker; + var curLang = spellChecker.GetCurrentDictionary(); var languages = aTarget.getElementsByAttribute("value", curLang); if (languages.length > 0) languages[0].setAttribute("checked", true); @@ -2215,12 +2216,10 @@ function ChangeLanguage(event) // We need to change the dictionary language and if we are using inline spell check, // recheck the message - var spellChecker = Components.classes["@mozilla.org/spellchecker/engine;1"] - .getService(mozISpellCheckingEngine); - if (spellChecker.dictionary != event.target.value) + var spellChecker = gSpellChecker.mInlineSpellChecker.spellChecker; + if (spellChecker.GetCurrentDictionary() != event.target.value) { - spellChecker.dictionary = event.target.value; - SetStringPref("spellchecker.dictionary", event.target.value); + spellChecker.SetCurrentDictionary(event.target.value); // now check the document and the subject over again with the new dictionary if (InlineSpellCheckerUI.enabled)