From 49e0c38ee85214eb7d0e7e995d1a380ee2f60720 Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Fri, 3 Feb 2012 19:45:00 +0100
Subject: STORM-276 Added preferences panel

---
 indra/llui/lllineeditor.cpp |  1 +
 indra/llui/llspellcheck.cpp | 12 ++++++------
 indra/llui/llspellcheck.h   | 29 ++++++++++++++++-------------
 indra/llui/lltextbase.cpp   |  1 +
 4 files changed, 24 insertions(+), 19 deletions(-)

(limited to 'indra/llui')

diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index e67753292e..42cfc4cae9 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -617,6 +617,7 @@ bool LLLineEditor::isMisspelledWord(U32 pos) const
 void LLLineEditor::onSpellCheckSettingsChange()
 {
 	// Recheck the spelling on every change
+	mMisspellRanges.clear();
 	mSpellCheckStart = mSpellCheckEnd = -1;
 }
 
diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp
index 433ca02852..65207144f8 100644
--- a/indra/llui/llspellcheck.cpp
+++ b/indra/llui/llspellcheck.cpp
@@ -186,7 +186,7 @@ void LLSpellChecker::addToDictFile(const std::string& dict_path, const std::stri
 	}
 }
 
-void LLSpellChecker::setSecondaryDictionaries(std::list<std::string> dict_list)
+void LLSpellChecker::setSecondaryDictionaries(dict_list_t dict_list)
 {
 	if (!getUseSpellCheck())
 	{
@@ -194,11 +194,11 @@ void LLSpellChecker::setSecondaryDictionaries(std::list<std::string> dict_list)
 	}
 
 	// Check if we're only adding secondary dictionaries, or removing them
-	std::list<std::string> dict_add(llmax(dict_list.size(), mDictSecondary.size())), dict_rem(llmax(dict_list.size(), mDictSecondary.size()));
+	dict_list_t dict_add(llmax(dict_list.size(), mDictSecondary.size())), dict_rem(llmax(dict_list.size(), mDictSecondary.size()));
 	dict_list.sort();
 	mDictSecondary.sort();
-	std::list<std::string>::iterator end_added = std::set_difference(dict_list.begin(), dict_list.end(), mDictSecondary.begin(), mDictSecondary.end(), dict_add.begin());
-	std::list<std::string>::iterator end_removed = std::set_difference(mDictSecondary.begin(), mDictSecondary.end(), dict_list.begin(), dict_list.end(), dict_rem.begin());
+	dict_list_t::iterator end_added = std::set_difference(dict_list.begin(), dict_list.end(), mDictSecondary.begin(), mDictSecondary.end(), dict_add.begin());
+	dict_list_t::iterator end_removed = std::set_difference(mDictSecondary.begin(), mDictSecondary.end(), dict_list.begin(), dict_list.end(), dict_rem.begin());
 
 	if (end_removed != dict_rem.begin())		// We can't remove secondary dictionaries so we need to recreate the Hunspell instance
 	{
@@ -211,7 +211,7 @@ void LLSpellChecker::setSecondaryDictionaries(std::list<std::string> dict_list)
 	{
 		const std::string app_path = getDictionaryAppPath();
 		const std::string user_path = getDictionaryUserPath();
-		for (std::list<std::string>::const_iterator it_added = dict_add.begin(); it_added != end_added; ++it_added)
+		for (dict_list_t::const_iterator it_added = dict_add.begin(); it_added != end_added; ++it_added)
 		{
 			const LLSD dict_entry = getDictionaryData(*it_added);
 			if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
@@ -287,7 +287,7 @@ void LLSpellChecker::initHunspell(const std::string& dict_name)
 			}
 		}
 
-		for (std::list<std::string>::const_iterator it = mDictSecondary.begin(); it != mDictSecondary.end(); ++it)
+		for (dict_list_t::const_iterator it = mDictSecondary.begin(); it != mDictSecondary.end(); ++it)
 		{
 			const LLSD dict_entry = getDictionaryData(*it);
 			if ( (!dict_entry.isDefined()) || (!dict_entry["installed"].asBoolean()) )
diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h
index affdac2907..8351655b49 100644
--- a/indra/llui/llspellcheck.h
+++ b/indra/llui/llspellcheck.h
@@ -44,17 +44,20 @@ public:
 	void addToIgnoreList(const std::string& word);
 	bool checkSpelling(const std::string& word) const;
 	S32  getSuggestions(const std::string& word, std::vector<std::string>& suggestions) const;
-
-public:
-	const LLSD	getDictionaryData(const std::string& dict_name) const;
-	const LLSD&	getDictionaryMap() const { return mDictMap; }
-	void		refreshDictionaryMap();
-	void		setSecondaryDictionaries(std::list<std::string> dictList);
 protected:
-	void		addToDictFile(const std::string& dict_path, const std::string& word);
-	void		initHunspell(const std::string& dict_name);
+	void addToDictFile(const std::string& dict_path, const std::string& word);
+	void initHunspell(const std::string& dict_name);
 
 public:
+	typedef std::list<std::string> dict_list_t;
+
+	const std::string&	getActiveDictionary() const { return mDictName; }
+	const LLSD			getDictionaryData(const std::string& dict_name) const;
+	const LLSD&			getDictionaryMap() const { return mDictMap; }
+	const dict_list_t&	getSecondaryDictionaries() const { return mDictSecondary; }
+	void				refreshDictionaryMap();
+	void				setSecondaryDictionaries(dict_list_t dict_list);
+
 	static const std::string getDictionaryAppPath();
 	static const std::string getDictionaryUserPath();
 	static bool				 getUseSpellCheck();
@@ -64,11 +67,11 @@ public:
 	static boost::signals2::connection setSettingsChangeCallback(const settings_change_signal_t::slot_type& cb);
 
 protected:
-	Hunspell*				 mHunspell;
-	std::string				 mDictName;
-	std::string				 mDictFile;
-	LLSD					 mDictMap;
-	std::list<std::string>	 mDictSecondary;
+	Hunspell*	mHunspell;
+	std::string	mDictName;
+	std::string	mDictFile;
+	LLSD		mDictMap;
+	dict_list_t	mDictSecondary;
 	std::vector<std::string> mIgnoreList;
 
 	static settings_change_signal_t	sSettingsChangeSignal;
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 7eee1d39c4..2231d9b983 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1308,6 +1308,7 @@ bool LLTextBase::isMisspelledWord(U32 pos) const
 void LLTextBase::onSpellCheckSettingsChange()
 {
 	// Recheck the spelling on every change
+	mMisspellRanges.clear();
 	mSpellCheckStart = mSpellCheckEnd = -1;
 }
 
-- 
cgit v1.2.3