summaryrefslogtreecommitdiff
path: root/indra/llui/llspellcheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llspellcheck.cpp')
-rw-r--r--indra/llui/llspellcheck.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 7f64743e99..ebd8ca0923 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -44,14 +44,11 @@ static const std::string DICT_FILE_IGNORE = "user_ignore.dic";
static const std::string DICT_FILE_MAIN = "dictionaries.xml";
static const std::string DICT_FILE_USER = "user_dictionaries.xml";
-LLSD LLSpellChecker::sDictMap;
LLSpellChecker::settings_change_signal_t LLSpellChecker::sSettingsChangeSignal;
LLSpellChecker::LLSpellChecker()
: mHunspell(NULL)
{
- // Load initial dictionary information
- refreshDictionaryMap();
}
LLSpellChecker::~LLSpellChecker()
@@ -59,6 +56,12 @@ LLSpellChecker::~LLSpellChecker()
delete mHunspell;
}
+void LLSpellChecker::initSingleton()
+{
+ // Load initial dictionary information
+ refreshDictionaryMap();
+}
+
bool LLSpellChecker::checkSpelling(const std::string& word) const
{
if ( (!mHunspell) || (word.length() < 3) || (0 != mHunspell->spell(word.c_str())) )
@@ -94,10 +97,9 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
return suggestions.size();
}
-// static
const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
{
- for (LLSD::array_const_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+ for (LLSD::array_const_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
{
const LLSD& dict_entry = *it;
if (dict_language == dict_entry["language"].asString())
@@ -108,14 +110,12 @@ const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
return LLSD();
}
-// static
bool LLSpellChecker::hasDictionary(const std::string& dict_language, bool check_installed)
{
const LLSD dict_info = getDictionaryData(dict_language);
return dict_info.has("language") && ( (!check_installed) || (dict_info["installed"].asBoolean()) );
}
-// static
void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
{
const std::string dict_language = dict_info["language"].asString();
@@ -124,7 +124,7 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
return;
}
- for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+ for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
{
LLSD& dict_entry = *it;
if (dict_language == dict_entry["language"].asString())
@@ -133,7 +133,7 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
return;
}
}
- sDictMap.append(dict_info);
+ mDictMap.append(dict_info);
return;
}
@@ -147,14 +147,14 @@ void LLSpellChecker::refreshDictionaryMap()
std::string user_filename(user_path + DICT_FILE_MAIN);
llifstream user_file(user_filename.c_str(), std::ios::binary);
if ( (!user_file.is_open())
- || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, user_file))
- || (0 == sDictMap.size()) )
+ || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(mDictMap, user_file))
+ || (0 == mDictMap.size()) )
{
std::string app_filename(app_path + DICT_FILE_MAIN);
llifstream app_file(app_filename.c_str(), std::ios::binary);
if ( (!app_file.is_open())
- || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(sDictMap, app_file))
- || (0 == sDictMap.size()) )
+ || (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXMLDocument(mDictMap, app_file))
+ || (0 == mDictMap.size()) )
{
return;
}
@@ -178,7 +178,7 @@ void LLSpellChecker::refreshDictionaryMap()
// Look for installed dictionaries
std::string tmp_app_path, tmp_user_path;
- for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+ for (LLSD::array_iterator it = mDictMap.beginArray(); it != mDictMap.endArray(); ++it)
{
LLSD& sdDict = *it;
tmp_app_path = (sdDict.has("name")) ? app_path + sdDict["name"].asString() : LLStringUtil::null;
@@ -416,7 +416,6 @@ bool LLSpellChecker::getUseSpellCheck()
return (LLSpellChecker::instanceExists()) && (LLSpellChecker::instance().mHunspell);
}
-// static
bool LLSpellChecker::canRemoveDictionary(const std::string& dict_language)
{
// Only user-installed inactive dictionaries can be removed
@@ -426,7 +425,6 @@ bool LLSpellChecker::canRemoveDictionary(const std::string& dict_language)
( (!getUseSpellCheck()) || (!LLSpellChecker::instance().isActiveDictionary(dict_language)) );
}
-// static
void LLSpellChecker::removeDictionary(const std::string& dict_language)
{
if (!canRemoveDictionary(dict_language))
@@ -499,12 +497,3 @@ void LLSpellChecker::setUseSpellCheck(const std::string& dict_language)
LLSpellChecker::instance().initHunspell(dict_language);
}
}
-
-// static
-void LLSpellChecker::initClass()
-{
- if (sDictMap.isUndefined())
- {
- refreshDictionaryMap();
- }
-}