summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorKitty Barnett <develop@catznip.com>2012-06-04 16:10:32 +0200
committerKitty Barnett <develop@catznip.com>2012-06-04 16:10:32 +0200
commit20210455f5a350b3e8e24515ba7af71db0eece0b (patch)
tree50e0150f86a43dc0488dc7f8615cbbcda9b222bc /indra/llui
parent17605cc894ad458915d958919554345334892eb0 (diff)
STORM-276 Dictionary import functionality and floater
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llspellcheck.cpp45
-rw-r--r--indra/llui/llspellcheck.h5
2 files changed, 43 insertions, 7 deletions
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index bde3b56741..04c8a4fed0 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -88,32 +88,63 @@ S32 LLSpellChecker::getSuggestions(const std::string& word, std::vector<std::str
}
// static
-const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_name)
+const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language)
{
for (LLSD::array_const_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
{
const LLSD& dict_entry = *it;
- if (dict_name == dict_entry["language"].asString())
+ if (dict_language == dict_entry["language"].asString())
return dict_entry;
}
return LLSD();
}
// static
+void LLSpellChecker::setDictionaryData(const LLSD& dict_info)
+{
+ const std::string dict_language = dict_info["language"].asString();
+ if (dict_language.empty())
+ return;
+
+ for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
+ {
+ LLSD& dict_entry = *it;
+ if (dict_language == dict_entry["language"].asString())
+ {
+ dict_entry = dict_info;
+ return;
+ }
+ }
+ sDictMap.append(dict_info);
+ return;
+}
+
+// static
void LLSpellChecker::refreshDictionaryMap()
{
const std::string app_path = getDictionaryAppPath();
const std::string user_path = getDictionaryUserPath();
// 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(sDictMap, user_map)) || (0 == sDictMap.size()) )
+ llifstream user_file(user_path + "dictionaries.xml", std::ios::binary);
+ if ( (!user_file.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, user_file)) || (0 == sDictMap.size()) )
{
- llifstream app_map(app_path + "dictionaries.xml", std::ios::binary);
- if ( (!app_map.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, app_map)) || (0 == sDictMap.size()) )
+ llifstream app_file(app_path + "dictionaries.xml", std::ios::binary);
+ if ( (!app_file.is_open()) || (0 == LLSDSerialize::fromXMLDocument(sDictMap, app_file)) || (0 == sDictMap.size()) )
return;
}
+ // Load user installed dictionary information
+ llifstream custom_file(user_path + "user_dictionaries.xml", std::ios::binary);
+ if (custom_file.is_open())
+ {
+ LLSD custom_dict_map;
+ LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file);
+ for (LLSD::array_const_iterator it = custom_dict_map.beginArray(); it != custom_dict_map.endArray(); ++it)
+ setDictionaryData(*it);
+ custom_file.close();
+ }
+
// Look for installed dictionaries
std::string tmp_app_path, tmp_user_path;
for (LLSD::array_iterator it = sDictMap.beginArray(); it != sDictMap.endArray(); ++it)
@@ -126,6 +157,8 @@ void LLSpellChecker::refreshDictionaryMap()
sdDict["has_custom"] = (!tmp_user_path.empty()) && (gDirUtilp->fileExists(tmp_user_path + DICT_CUSTOM_SUFFIX + ".dic"));
sdDict["has_ignore"] = (!tmp_user_path.empty()) && (gDirUtilp->fileExists(tmp_user_path + DICT_IGNORE_SUFFIX + ".dic"));
}
+
+ sSettingsChangeSignal();
}
void LLSpellChecker::addToCustomDictionary(const std::string& word)
diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h
index d736a7f082..acb121dd19 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -59,12 +59,15 @@ public:
static const std::string getDictionaryAppPath();
static const std::string getDictionaryUserPath();
- static const LLSD getDictionaryData(const std::string& dict_name);
+ static const LLSD getDictionaryData(const std::string& dict_language);
static const LLSD& getDictionaryMap() { return sDictMap; }
static bool getUseSpellCheck();
static void refreshDictionaryMap();
static void setUseSpellCheck(const std::string& dict_name);
+protected:
+ static void setDictionaryData(const LLSD& dict_info);
+public:
typedef boost::signals2::signal<void()> settings_change_signal_t;
static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
protected: