From 5b0901b712dd38818759e80e0b94a24b6e91b161 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 2 Sep 2011 09:03:38 -0400 Subject: [PATCH] Keep changeset 9ef862cbcc5e backed out on the reverted tree --- editor/composer/src/nsEditorSpellCheck.cpp | 36 ++++------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/editor/composer/src/nsEditorSpellCheck.cpp b/editor/composer/src/nsEditorSpellCheck.cpp index ff641d3ce43..ad4bc1675ec 100644 --- a/editor/composer/src/nsEditorSpellCheck.cpp +++ b/editor/composer/src/nsEditorSpellCheck.cpp @@ -729,9 +729,8 @@ nsEditorSpellCheck::UpdateCurrentDictionary() } // otherwise, get language from preferences - nsAutoString preferedDict(Preferences::GetLocalizedString("spellchecker.dictionary")); if (dictName.IsEmpty()) { - dictName.Assign(preferedDict); + dictName.Assign(Preferences::GetLocalizedString("spellchecker.dictionary")); } if (dictName.IsEmpty()) @@ -756,50 +755,27 @@ nsEditorSpellCheck::UpdateCurrentDictionary() rv = SetCurrentDictionary(dictName); if (NS_FAILED(rv)) { // required dictionary was not available. Try to get a dictionary - // matching at least language part of dictName: - + // matching at least language part of dictName: If required dictionary is + // "aa-bb", we try "aa", then we try any available dictionary aa-XX nsAutoString langCode; PRInt32 dashIdx = dictName.FindChar('-'); if (dashIdx != -1) { langCode.Assign(Substring(dictName, 0, dashIdx)); + // try to use langCode + rv = SetCurrentDictionary(langCode); } else { langCode.Assign(dictName); } - - nsDefaultStringComparator comparator; - - // try dictionary.spellchecker preference if it starts with langCode (and - // if we haven't tried it already) - if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) && - nsStyleUtil::DashMatchCompare(preferedDict, langCode, comparator)) { - rv = SetCurrentDictionary(preferedDict); - } - - // Otherwise, try langCode (if we haven't tried it already) - if (NS_FAILED(rv)) { - if (!dictName.Equals(langCode) && !preferedDict.Equals(langCode)) { - rv = SetCurrentDictionary(preferedDict); - } - } - - // Otherwise, try any available dictionary aa-XX if (NS_FAILED(rv)) { // loop over avaible dictionaries; if we find one with required // language, use it nsTArray dictList; rv = mSpellChecker->GetDictionaryList(&dictList); NS_ENSURE_SUCCESS(rv, rv); + nsDefaultStringComparator comparator; PRInt32 i, count = dictList.Length(); for (i = 0; i < count; i++) { nsAutoString dictStr(dictList.ElementAt(i)); - - if (dictStr.Equals(dictName) || - dictStr.Equals(preferedDict) || - dictStr.Equals(langCode)) { - // We have already tried it - continue; - } - if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) && NS_SUCCEEDED(SetCurrentDictionary(dictStr))) { break;