diff options
author | Kitty Barnett <develop@catznip.com> | 2012-02-14 21:48:22 +0100 |
---|---|---|
committer | Kitty Barnett <develop@catznip.com> | 2012-02-14 21:48:22 +0100 |
commit | 60e39343b17f29c65e8a60a415f7ed83ff069a12 (patch) | |
tree | 895a454b02b2685bfa91a994d67bb9eea139c1cc /indra/llui/llspellcheck.cpp | |
parent | 2114e88cd1291ef1dba4b79bcdcca4b2d134262f (diff) |
STORM-276 Reworked the spell check preferences to be more robust and less error-prone
Diffstat (limited to 'indra/llui/llspellcheck.cpp')
-rw-r--r-- | indra/llui/llspellcheck.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp index 65207144f8..46df44cdba 100644 --- a/indra/llui/llspellcheck.cpp +++ b/indra/llui/llspellcheck.cpp @@ -41,6 +41,7 @@ static const std::string DICT_DIR = "dictionaries"; static const std::string DICT_CUSTOM_SUFFIX = "_custom"; static const std::string DICT_IGNORE_SUFFIX = "_ignore"; +LLSD LLSpellChecker::sDictMap; LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal; LLSpellChecker::LLSpellChecker() @@ -86,9 +87,10 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str return suggestions.size(); } -const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_name) const +// static +const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_name) { - for (LLSD::array_const_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it) + for (LLSD::array_const_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it) { const LLSD& dict_entry = *it; if (dict_name == dict_entry["language"].asString()) @@ -97,6 +99,7 @@ const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_name) const return LLSD(); } +// static void LLSpellChecker::refreshDictionaryMap() { const std::string app_path = getDictionaryAppPath(); @@ -104,16 +107,16 @@ void LLSpellChecker::refreshDictionaryMap() // Load dictionary information (file name, friendly name, ...) llifstream user_map(user_path + "dictionaries.xml", std::ios::binary); - if ( (!user_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(mDictMap, user_map)) || (0 == mDictMap.size()) ) + if ( (!user_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, user_map)) || (0 == sDictMap.size()) ) { llifstream app_map(app_path + "dictionaries.xml", std::ios::binary); - if ( (!app_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(mDictMap, app_map)) || (0 == mDictMap.size()) ) + if ( (!app_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, app_map)) || (0 == sDictMap.size()) ) return; } // Look for installed dictionaries std::string tmp_app_path, tmp_user_path; - for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it) + for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it) { LLSD& sdDict = *it; tmp_app_path = (sdDict.has("name")) ? app_path + sdDict["name"].asString() : LLStringUtil::null; @@ -343,3 +346,10 @@ void LLSpellChecker::setUseSpellCheck(const std::string& dict_name) LLSpellChecker::instance().initHunspell(dict_name); } } + +// static +void LLSpellChecker::initClass() +{ + if (sDictMap.isUndefined()) + refreshDictionaryMap(); +} |