summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-06-27 22:14:52 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-06-27 22:14:52 +0300
commit2752e342f63fc74c49e19317885280fb279ae2fa (patch)
treea06ab0368051431509d199216bc0eab7381d9acd /indra/llui
parent03f81254055c487623211aeae330d02980781f67 (diff)
DRTVWR-493 LLSpellcheck doesn't need separate init
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llspellcheck.cpp31
-rw-r--r--indra/llui/llspellcheck.h21
2 files changed, 17 insertions, 35 deletions
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 7f64743e99..296ea09079 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -44,7 +44,6 @@ 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()
@@ -94,10 +93,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 +106,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 +120,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 +129,7 @@ void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
return;
}
}
- sDictMap.append(dict_info);
+ mDictMap.append(dict_info);
return;
}
@@ -147,14 +143,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 +174,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 +412,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 +421,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 +493,3 @@ void LLSpellChecker::setUseSpellCheck(const std::string& dict_language)
LLSpellChecker::instance().initHunspell(dict_language);
}
}
-
-// static
-void LLSpellChecker::initClass()
-{
- if (sDictMap.isUndefined())
- {
- refreshDictionaryMap();
- }
-}
diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h
index acac589e43..f1964cc091 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -34,10 +34,9 @@
class Hunspell;
-class LLSpellChecker : public LLSingleton<LLSpellChecker>, public LLInitClass<LLSpellChecker>
+class LLSpellChecker : public LLSingleton<LLSpellChecker>
{
LLSINGLETON(LLSpellChecker);
- friend class LLInitClass<LLSpellChecker>;
~LLSpellChecker();
public:
@@ -57,26 +56,24 @@ public:
bool isActiveDictionary(const std::string& dict_language) const;
void setSecondaryDictionaries(dict_list_t dict_list);
- static bool canRemoveDictionary(const std::string& dict_language);
+ bool canRemoveDictionary(const std::string& dict_language);
static const std::string getDictionaryAppPath();
static const std::string getDictionaryUserPath();
- static const LLSD getDictionaryData(const std::string& dict_language);
- static const LLSD& getDictionaryMap() { return sDictMap; }
+ const LLSD getDictionaryData(const std::string& dict_language);
+ const LLSD& getDictionaryMap() { return mDictMap; }
static bool getUseSpellCheck();
- static bool hasDictionary(const std::string& dict_language, bool check_installed = false);
- static void refreshDictionaryMap();
- static void removeDictionary(const std::string& dict_language);
+ bool hasDictionary(const std::string& dict_language, bool check_installed = false);
+ void refreshDictionaryMap();
+ void removeDictionary(const std::string& dict_language);
static void setUseSpellCheck(const std::string& dict_language);
protected:
static LLSD loadUserDictionaryMap();
- static void setDictionaryData(const LLSD& dict_info);
+ void setDictionaryData(const LLSD& dict_info);
static void saveUserDictionaryMap(const LLSD& dict_map);
public:
typedef boost::signals2::signal<void()> settings_change_signal_t;
static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
-protected:
- static void initClass();
protected:
Hunspell* mHunspell;
@@ -84,8 +81,8 @@ protected:
std::string mDictFile;
dict_list_t mDictSecondary;
std::vector<std::string> mIgnoreList;
+ LLSD mDictMap;
- static LLSD sDictMap;
static settings_change_signal_t sSettingsChangeSignal;
};