From 53222ef517b97249df1e1a6db2e29c0d86b2e773 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Thu, 31 May 2012 02:56:42 +0200 Subject: STORM-276 Match preferences look to that of the auto-replace functionality in STORM-1738 --- indra/newview/llfloaterspellchecksettings.cpp | 179 ++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 indra/newview/llfloaterspellchecksettings.cpp (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp new file mode 100644 index 0000000000..ff5afc8169 --- /dev/null +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -0,0 +1,179 @@ +/** + * @file llfloaterspellchecksettings.h + * @brief Spell checker settings floater + * +* $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llcombobox.h" +#include "llfloaterspellchecksettings.h" +#include "llscrolllistctrl.h" +#include "llspellcheck.h" +#include "llviewercontrol.h" + +#include + +LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) + : LLFloater(key) +{ +} + +BOOL LLFloaterSpellCheckerSettings::postBuild(void) +{ + gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onClickDictMove, this, "spellcheck_active_list", "spellcheck_available_list")); + getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onClickDictMove, this, "spellcheck_available_list", "spellcheck_active_list")); + getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onOK, this)); + getChild("spellcheck_cancel")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onCancel, this)); + + return true; +} + +void LLFloaterSpellCheckerSettings::onCancel() +{ + closeFloater(false); +} + +void LLFloaterSpellCheckerSettings::onClickDictMove(const std::string& from, const std::string& to) +{ + LLScrollListCtrl* from_ctrl = findChild(from); + LLScrollListCtrl* to_ctrl = findChild(to); + + LLSD row; + row["columns"][0]["column"] = "name"; + row["columns"][0]["font"]["name"] = "SANSSERIF_SMALL"; + row["columns"][0]["font"]["style"] = "NORMAL"; + + std::vector sel_items = from_ctrl->getAllSelected(); + for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) + { + row["columns"][0]["value"] = (*sel_it)->getColumn(0)->getValue(); + to_ctrl->addElement(row); + } + from_ctrl->deleteSelectedItems(); +} + +void LLFloaterSpellCheckerSettings::onOK() +{ + std::list list_dict; + + LLComboBox* dict_combo = findChild("spellcheck_main_combo"); + const std::string dict_name = dict_combo->getSelectedItemLabel(); + if (!dict_name.empty()) + { + list_dict.push_back(dict_name); + + LLScrollListCtrl* list_ctrl = findChild("spellcheck_active_list"); + std::vector list_items = list_ctrl->getAllData(); + for (std::vector::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it) + list_dict.push_back((*item_it)->getColumn(0)->getValue().asString()); + } + gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ",")); + + closeFloater(false); +} + +void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) +{ + refreshDictionaryLists(true); +} + +void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) +{ + bool enabled = gSavedSettings.getBOOL("SpellCheck"); + getChild("spellcheck_moveleft_btn")->setEnabled(enabled); + getChild("spellcheck_moveright_btn")->setEnabled(enabled); + + // Populate the dictionary combobox + LLComboBox* dict_combo = findChild("spellcheck_main_combo"); + std::string dict_cur = dict_combo->getSelectedItemLabel(); + if ((dict_cur.empty() || from_settings) && (LLSpellChecker::getUseSpellCheck())) + dict_cur = LLSpellChecker::instance().getActiveDictionary(); + dict_combo->clearRows(); + dict_combo->setEnabled(enabled); + + const LLSD& dict_map = LLSpellChecker::getDictionaryMap(); + if (dict_map.size()) + { + for (LLSD::array_const_iterator dict_it = dict_map.beginArray(); dict_it != dict_map.endArray(); ++dict_it) + { + const LLSD& dict = *dict_it; + if ( (dict["installed"].asBoolean()) && (dict["is_primary"].asBoolean()) && (dict.has("language")) ) + dict_combo->add(dict["language"].asString()); + } + if (!dict_combo->selectByValue(dict_cur)) + dict_combo->clear(); + } + + // Populate the available and active dictionary list + LLScrollListCtrl* avail_ctrl = findChild("spellcheck_available_list"); + LLScrollListCtrl* active_ctrl = findChild("spellcheck_active_list"); + + LLSpellChecker::dict_list_t active_list; + if ( ((!avail_ctrl->getItemCount()) && (!active_ctrl->getItemCount())) || (from_settings) ) + { + if (LLSpellChecker::getUseSpellCheck()) + active_list = LLSpellChecker::instance().getSecondaryDictionaries(); + } + else + { + std::vector active_items = active_ctrl->getAllData(); + for (std::vector::const_iterator item_it = active_items.begin(); item_it != active_items.end(); ++item_it) + { + std::string dict = (*item_it)->getColumn(0)->getValue().asString(); + if (dict_cur != dict) + active_list.push_back(dict); + } + } + + LLSD row; + row["columns"][0]["column"] = "name"; + row["columns"][0]["font"]["name"] = "SANSSERIF_SMALL"; + row["columns"][0]["font"]["style"] = "NORMAL"; + + active_ctrl->clearRows(); + active_ctrl->setEnabled(enabled); + active_ctrl->sortByColumnIndex(0, true); + for (LLSpellChecker::dict_list_t::const_iterator it = active_list.begin(); it != active_list.end(); ++it) + { + row["columns"][0]["value"] = *it; + active_ctrl->addElement(row); + } + active_list.push_back(dict_cur); + + avail_ctrl->clearRows(); + avail_ctrl->setEnabled(enabled); + avail_ctrl->sortByColumnIndex(0, true); + for (LLSD::array_const_iterator dict_it = dict_map.beginArray(); dict_it != dict_map.endArray(); ++dict_it) + { + const LLSD& dict = *dict_it; + if ( (dict["installed"].asBoolean()) && (dict.has("language")) && + (active_list.end() == std::find(active_list.begin(), active_list.end(), dict["language"].asString())) ) + { + row["columns"][0]["value"] = dict["language"].asString(); + avail_ctrl->addElement(row); + } + } +} -- cgit v1.2.3 From 20210455f5a350b3e8e24515ba7af71db0eece0b Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 4 Jun 2012 16:10:32 +0200 Subject: STORM-276 Dictionary import functionality and floater --- indra/newview/llfloaterspellchecksettings.cpp | 127 ++++++++++++++++++++++++-- 1 file changed, 120 insertions(+), 7 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index ff5afc8169..8bf480c4df 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -27,13 +27,19 @@ #include "llviewerprecompiledheaders.h" #include "llcombobox.h" +#include "llfilepicker.h" +#include "llfloaterreg.h" #include "llfloaterspellchecksettings.h" #include "llscrolllistctrl.h" +#include "llsdserialize.h" #include "llspellcheck.h" #include "llviewercontrol.h" #include +///---------------------------------------------------------------------------- +/// Class LLFloaterSpellCheckerSettings +///---------------------------------------------------------------------------- LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) : LLFloater(key) { @@ -42,21 +48,28 @@ LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) BOOL LLFloaterSpellCheckerSettings::postBuild(void) { gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + LLSpellChecker::setSettingsChangeCallback(boost::bind(&LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange, this)); + getChild("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this)); getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); - getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onClickDictMove, this, "spellcheck_active_list", "spellcheck_available_list")); - getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onClickDictMove, this, "spellcheck_available_list", "spellcheck_active_list")); - getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onOK, this)); - getChild("spellcheck_cancel")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onCancel, this)); + getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); + getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); + getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnOK, this)); + getChild("spellcheck_cancel")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnCancel, this)); return true; } -void LLFloaterSpellCheckerSettings::onCancel() +void LLFloaterSpellCheckerSettings::onBtnCancel() { closeFloater(false); } -void LLFloaterSpellCheckerSettings::onClickDictMove(const std::string& from, const std::string& to) +void LLFloaterSpellCheckerSettings::onBtnImport() +{ + LLFloaterReg::showInstance("prefs_spellchecker_import"); +} + +void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std::string& to) { LLScrollListCtrl* from_ctrl = findChild(from); LLScrollListCtrl* to_ctrl = findChild(to); @@ -75,7 +88,7 @@ void LLFloaterSpellCheckerSettings::onClickDictMove(const std::string& from, con from_ctrl->deleteSelectedItems(); } -void LLFloaterSpellCheckerSettings::onOK() +void LLFloaterSpellCheckerSettings::onBtnOK() { std::list list_dict; @@ -100,6 +113,11 @@ void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) refreshDictionaryLists(true); } +void LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange() +{ + refreshDictionaryLists(true); +} + void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) { bool enabled = gSavedSettings.getBOOL("SpellCheck"); @@ -177,3 +195,98 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) } } } + +///---------------------------------------------------------------------------- +/// Class LLFloaterSpellCheckerImport +///---------------------------------------------------------------------------- +LLFloaterSpellCheckerImport::LLFloaterSpellCheckerImport(const LLSD& key) + : LLFloater(key) +{ +} + +BOOL LLFloaterSpellCheckerImport::postBuild(void) +{ + getChild("dictionary_path_browse")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnBrowse, this)); + getChild("ok_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnOK, this)); + getChild("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnCancel, this)); + + return true; +} + +void LLFloaterSpellCheckerImport::onBtnBrowse() +{ + LLFilePicker& file_picker = LLFilePicker::instance(); + if (!file_picker.getOpenFile(LLFilePicker::FFLOAD_DICTIONARY)) + { + return; + } + + const std::string filepath = file_picker.getFirstFile(); + getChild("dictionary_path")->setValue(filepath); + + mDictionaryDir = gDirUtilp->getDirName(filepath); + mDictionaryBasename = gDirUtilp->getBaseFileName(filepath, true); + getChild("dictionary_name")->setValue(mDictionaryBasename); +} + +void LLFloaterSpellCheckerImport::onBtnCancel() +{ + closeFloater(false); +} + +void LLFloaterSpellCheckerImport::onBtnOK() +{ + const std::string dict_dic = mDictionaryDir + gDirUtilp->getDirDelimiter() + mDictionaryBasename + ".dic"; + const std::string dict_aff = mDictionaryDir + gDirUtilp->getDirDelimiter() + mDictionaryBasename + ".aff"; + std::string dict_language = getChild("dictionary_language")->getValue().asString(); + LLStringUtil::trim(dict_language); + if ( (dict_language.empty()) || (!gDirUtilp->fileExists(dict_dic)) || + (mDictionaryDir.empty()) || (mDictionaryBasename.empty()) ) + { + return; + } + + LLSD custom_dict_info; + custom_dict_info["is_primary"] = (bool)gDirUtilp->fileExists(dict_aff); + custom_dict_info["name"] = mDictionaryBasename; + custom_dict_info["language"] = dict_language; + + LLSD custom_dict_map; + llifstream custom_file_in(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml"); + if (custom_file_in.is_open()) + { + LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file_in); + custom_file_in.close(); + } + + LLSD::array_iterator it = custom_dict_map.beginArray(); + for (; it != custom_dict_map.endArray(); ++it) + { + LLSD& dict_info = *it; + if (dict_info["name"].asString() == mDictionaryBasename) + { + dict_info = custom_dict_info; + break; + } + } + if (custom_dict_map.endArray() == it) + { + custom_dict_map.append(custom_dict_info); + } + + llofstream custom_file_out(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml", std::ios::trunc); + if (custom_file_out.is_open()) + { + LLSDSerialize::toPrettyXML(custom_dict_map, custom_file_out); + custom_file_out.close(); + } + + LLFile::rename(dict_dic, LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".dic"); + if (gDirUtilp->fileExists(dict_aff)) + { + LLFile::rename(dict_aff, LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".aff"); + } + LLSpellChecker::refreshDictionaryMap(); + + closeFloater(false); +} -- cgit v1.2.3 From 80b1a2c0a8f7b4444dc1588ba5f71bbb69b40acd Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 11 Jun 2012 13:39:45 +0200 Subject: STORM-276 Insert braces around if/for/while loops --- indra/newview/llfloaterspellchecksettings.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 8bf480c4df..d801d0c8af 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -101,7 +101,9 @@ void LLFloaterSpellCheckerSettings::onBtnOK() LLScrollListCtrl* list_ctrl = findChild("spellcheck_active_list"); std::vector list_items = list_ctrl->getAllData(); for (std::vector::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it) + { list_dict.push_back((*item_it)->getColumn(0)->getValue().asString()); + } } gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ",")); @@ -128,7 +130,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) LLComboBox* dict_combo = findChild("spellcheck_main_combo"); std::string dict_cur = dict_combo->getSelectedItemLabel(); if ((dict_cur.empty() || from_settings) && (LLSpellChecker::getUseSpellCheck())) + { dict_cur = LLSpellChecker::instance().getActiveDictionary(); + } dict_combo->clearRows(); dict_combo->setEnabled(enabled); @@ -139,10 +143,14 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) { const LLSD& dict = *dict_it; if ( (dict["installed"].asBoolean()) && (dict["is_primary"].asBoolean()) && (dict.has("language")) ) + { dict_combo->add(dict["language"].asString()); + } } if (!dict_combo->selectByValue(dict_cur)) + { dict_combo->clear(); + } } // Populate the available and active dictionary list @@ -153,7 +161,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) if ( ((!avail_ctrl->getItemCount()) && (!active_ctrl->getItemCount())) || (from_settings) ) { if (LLSpellChecker::getUseSpellCheck()) + { active_list = LLSpellChecker::instance().getSecondaryDictionaries(); + } } else { @@ -162,7 +172,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) { std::string dict = (*item_it)->getColumn(0)->getValue().asString(); if (dict_cur != dict) + { active_list.push_back(dict); + } } } -- cgit v1.2.3 From 53bd3ada86faf8c470989c809c2baeb3a3e7770c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 11 Jun 2012 16:04:24 +0200 Subject: STORM-276 Distinguish between default dictionaries and user-installed dictionaries --- indra/newview/llfloaterspellchecksettings.cpp | 36 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index d801d0c8af..0b4f08c327 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -33,6 +33,7 @@ #include "llscrolllistctrl.h" #include "llsdserialize.h" #include "llspellcheck.h" +#include "lltrans.h" #include "llviewercontrol.h" #include @@ -47,10 +48,10 @@ LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) BOOL LLFloaterSpellCheckerSettings::postBuild(void) { - gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); LLSpellChecker::setSettingsChangeCallback(boost::bind(&LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange, this)); getChild("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this)); - getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnOK, this)); @@ -82,6 +83,7 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std std::vector sel_items = from_ctrl->getAllSelected(); for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) { + row["value"] = (*sel_it)->getValue(); row["columns"][0]["value"] = (*sel_it)->getColumn(0)->getValue(); to_ctrl->addElement(row); } @@ -102,7 +104,11 @@ void LLFloaterSpellCheckerSettings::onBtnOK() std::vector list_items = list_ctrl->getAllData(); for (std::vector::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it) { - list_dict.push_back((*item_it)->getColumn(0)->getValue().asString()); + const std::string language = (*item_it)->getValue().asString(); + if (LLSpellChecker::hasDictionary(language, true)) + { + list_dict.push_back(language); + } } } gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ",")); @@ -112,15 +118,15 @@ void LLFloaterSpellCheckerSettings::onBtnOK() void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) { - refreshDictionaryLists(true); + refreshDictionaries(true); } void LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange() { - refreshDictionaryLists(true); + refreshDictionaries(true); } -void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) +void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) { bool enabled = gSavedSettings.getBOOL("SpellCheck"); getChild("spellcheck_moveleft_btn")->setEnabled(enabled); @@ -170,7 +176,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) std::vector active_items = active_ctrl->getAllData(); for (std::vector::const_iterator item_it = active_items.begin(); item_it != active_items.end(); ++item_it) { - std::string dict = (*item_it)->getColumn(0)->getValue().asString(); + std::string dict = (*item_it)->getValue().asString(); if (dict_cur != dict) { active_list.push_back(dict); @@ -185,27 +191,31 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) active_ctrl->clearRows(); active_ctrl->setEnabled(enabled); - active_ctrl->sortByColumnIndex(0, true); for (LLSpellChecker::dict_list_t::const_iterator it = active_list.begin(); it != active_list.end(); ++it) { - row["columns"][0]["value"] = *it; + const std::string language = *it; + const LLSD dict = LLSpellChecker::getDictionaryData(language); + row["value"] = language; + row["columns"][0]["value"] = (!dict["user_installed"].asBoolean()) ? language : language + " " + LLTrans::getString("UserDictionary"); active_ctrl->addElement(row); } + active_ctrl->sortByColumnIndex(0, true); active_list.push_back(dict_cur); avail_ctrl->clearRows(); avail_ctrl->setEnabled(enabled); - avail_ctrl->sortByColumnIndex(0, true); for (LLSD::array_const_iterator dict_it = dict_map.beginArray(); dict_it != dict_map.endArray(); ++dict_it) { const LLSD& dict = *dict_it; - if ( (dict["installed"].asBoolean()) && (dict.has("language")) && - (active_list.end() == std::find(active_list.begin(), active_list.end(), dict["language"].asString())) ) + const std::string language = dict["language"].asString(); + if ( (dict["installed"].asBoolean()) && (active_list.end() == std::find(active_list.begin(), active_list.end(), language)) ) { - row["columns"][0]["value"] = dict["language"].asString(); + row["value"] = language; + row["columns"][0]["value"] = (!dict["user_installed"].asBoolean()) ? language : language + " " + LLTrans::getString("UserDictionary"); avail_ctrl->addElement(row); } } + avail_ctrl->sortByColumnIndex(0, true); } ///---------------------------------------------------------------------------- -- cgit v1.2.3 From d96d3d525677ae5bebab1908394854b8fb79cdfb Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 11 Jun 2012 17:37:06 +0200 Subject: STORM-276 Added the ability to remove (user-installed) dictionaries --- indra/newview/llfloaterspellchecksettings.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 0b4f08c327..059a28fbcd 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -46,10 +46,24 @@ LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) { } +void LLFloaterSpellCheckerSettings::draw() +{ + LLFloater::draw(); + + std::vector sel_items = getChild("spellcheck_available_list")->getAllSelected(); + bool enable_remove = !sel_items.empty(); + for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) + { + enable_remove &= LLSpellChecker::canRemoveDictionary((*sel_it)->getValue().asString()); + } + getChild("spellcheck_remove_btn")->setEnabled(enable_remove); +} + BOOL LLFloaterSpellCheckerSettings::postBuild(void) { gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); LLSpellChecker::setSettingsChangeCallback(boost::bind(&LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange, this)); + getChild("spellcheck_remove_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnRemove, this)); getChild("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this)); getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); @@ -121,6 +135,15 @@ void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) refreshDictionaries(true); } +void LLFloaterSpellCheckerSettings::onBtnRemove() +{ + std::vector sel_items = getChild("spellcheck_available_list")->getAllSelected(); + for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) + { + LLSpellChecker::instance().removeDictionary((*sel_it)->getValue().asString()); + } +} + void LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange() { refreshDictionaries(true); @@ -137,7 +160,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) std::string dict_cur = dict_combo->getSelectedItemLabel(); if ((dict_cur.empty() || from_settings) && (LLSpellChecker::getUseSpellCheck())) { - dict_cur = LLSpellChecker::instance().getActiveDictionary(); + dict_cur = LLSpellChecker::instance().getPrimaryDictionary(); } dict_combo->clearRows(); dict_combo->setEnabled(enabled); -- cgit v1.2.3 From 64a34c13703155679a9cba3057b785ff8d55a070 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 12 Jun 2012 06:50:22 -0400 Subject: minor ui tweaks from review --- indra/newview/llfloaterspellchecksettings.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 059a28fbcd..d350637790 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -68,17 +68,10 @@ BOOL LLFloaterSpellCheckerSettings::postBuild(void) getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); - getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnOK, this)); - getChild("spellcheck_cancel")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnCancel, this)); return true; } -void LLFloaterSpellCheckerSettings::onBtnCancel() -{ - closeFloater(false); -} - void LLFloaterSpellCheckerSettings::onBtnImport() { LLFloaterReg::showInstance("prefs_spellchecker_import"); @@ -104,8 +97,14 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std from_ctrl->deleteSelectedItems(); } -void LLFloaterSpellCheckerSettings::onBtnOK() +void LLFloaterSpellCheckerSettings::onClose(bool app_quitting) { + if (app_quitting) + { + // don't save anything + return; + } + std::list list_dict; LLComboBox* dict_combo = findChild("spellcheck_main_combo"); @@ -126,8 +125,6 @@ void LLFloaterSpellCheckerSettings::onBtnOK() } } gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ",")); - - closeFloater(false); } void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) @@ -254,7 +251,7 @@ BOOL LLFloaterSpellCheckerImport::postBuild(void) getChild("dictionary_path_browse")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnBrowse, this)); getChild("ok_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnOK, this)); getChild("cancel_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerImport::onBtnCancel, this)); - + center(); return true; } -- cgit v1.2.3 From fc1f30a05b14d80786f7fd41b30640092fc5683d Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 14 Jun 2012 19:51:59 -0400 Subject: STORM-1882: keep dictionary selected when moving, allowing deletion when moved to Available --- indra/newview/llfloaterspellchecksettings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index d350637790..95934d46a8 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -88,11 +88,13 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std row["columns"][0]["font"]["style"] = "NORMAL"; std::vector sel_items = from_ctrl->getAllSelected(); - for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) + std::vector::const_iterator sel_it; + for ( sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) { row["value"] = (*sel_it)->getValue(); row["columns"][0]["value"] = (*sel_it)->getColumn(0)->getValue(); to_ctrl->addElement(row); + to_ctrl->setSelectedByValue( (*sel_it)->getValue(), true ); } from_ctrl->deleteSelectedItems(); } -- cgit v1.2.3 From c8f21753fa4cc88e3ad58f9e117c231d6f5388c0 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 14 Jun 2012 20:18:16 -0400 Subject: STORM-1881: close dictionary import dialog if parent spell checking prefs dialog is closed --- indra/newview/llfloaterspellchecksettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 95934d46a8..5116ec50a6 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -106,6 +106,7 @@ void LLFloaterSpellCheckerSettings::onClose(bool app_quitting) // don't save anything return; } + LLFloaterReg::hideInstance("prefs_spellchecker_import"); std::list list_dict; -- cgit v1.2.3 From 02f0f87f95c7f47a93d20de9478bf0b2d5c6e4e6 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 14 Jun 2012 21:21:42 -0400 Subject: STORM-1880: copy imported dictionary files rather than moving them --- indra/newview/llfloaterspellchecksettings.cpp | 124 +++++++++++++++++++------- 1 file changed, 93 insertions(+), 31 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 5116ec50a6..758ac23b4c 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -35,6 +35,7 @@ #include "llspellcheck.h" #include "lltrans.h" #include "llviewercontrol.h" +#include "llnotificationsutil.h" #include @@ -291,47 +292,108 @@ void LLFloaterSpellCheckerImport::onBtnOK() return; } - LLSD custom_dict_info; - custom_dict_info["is_primary"] = (bool)gDirUtilp->fileExists(dict_aff); - custom_dict_info["name"] = mDictionaryBasename; - custom_dict_info["language"] = dict_language; - - LLSD custom_dict_map; - llifstream custom_file_in(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml"); - if (custom_file_in.is_open()) + bool imported = false; + std::string settings_dic = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".dic"; + if ( copyFile( dict_dic, settings_dic ) ) { - LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file_in); - custom_file_in.close(); - } - - LLSD::array_iterator it = custom_dict_map.beginArray(); - for (; it != custom_dict_map.endArray(); ++it) - { - LLSD& dict_info = *it; - if (dict_info["name"].asString() == mDictionaryBasename) + if (gDirUtilp->fileExists(dict_aff)) + { + std::string settings_aff = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".aff"; + if (copyFile( dict_aff, settings_aff )) + { + imported = true; + } + else + { + LLSD args = LLSD::emptyMap(); + args["FROM_NAME"] = dict_aff; + args["TO_NAME"] = settings_aff; + LLNotificationsUtil::add("SpellingDictImportFailed", args); + } + } + else { - dict_info = custom_dict_info; - break; + imported = true; } } - if (custom_dict_map.endArray() == it) + else { - custom_dict_map.append(custom_dict_info); + LLSD args = LLSD::emptyMap(); + args["FROM_NAME"] = dict_dic; + args["TO_NAME"] = settings_dic; + LLNotificationsUtil::add("SpellingDictImportFailed", args); } - llofstream custom_file_out(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml", std::ios::trunc); - if (custom_file_out.is_open()) + if ( imported ) { - LLSDSerialize::toPrettyXML(custom_dict_map, custom_file_out); - custom_file_out.close(); - } + LLSD custom_dict_info; + custom_dict_info["is_primary"] = (bool)gDirUtilp->fileExists(dict_aff); + custom_dict_info["name"] = mDictionaryBasename; + custom_dict_info["language"] = dict_language; + + LLSD custom_dict_map; + llifstream custom_file_in(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml"); + if (custom_file_in.is_open()) + { + LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file_in); + custom_file_in.close(); + } + + LLSD::array_iterator it = custom_dict_map.beginArray(); + for (; it != custom_dict_map.endArray(); ++it) + { + LLSD& dict_info = *it; + if (dict_info["name"].asString() == mDictionaryBasename) + { + dict_info = custom_dict_info; + break; + } + } + if (custom_dict_map.endArray() == it) + { + custom_dict_map.append(custom_dict_info); + } - LLFile::rename(dict_dic, LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".dic"); - if (gDirUtilp->fileExists(dict_aff)) - { - LLFile::rename(dict_aff, LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".aff"); + llofstream custom_file_out(LLSpellChecker::getDictionaryUserPath() + "user_dictionaries.xml", std::ios::trunc); + if (custom_file_out.is_open()) + { + LLSDSerialize::toPrettyXML(custom_dict_map, custom_file_out); + custom_file_out.close(); + } + + LLSpellChecker::refreshDictionaryMap(); } - LLSpellChecker::refreshDictionaryMap(); closeFloater(false); } + +bool LLFloaterSpellCheckerImport::copyFile(const std::string from, const std::string to) +{ + bool copied = false; + LLFILE* in = LLFile::fopen(from, "rb"); /* Flawfinder: ignore */ + if (in) + { + LLFILE* out = LLFile::fopen(to, "wb"); /* Flawfinder: ignore */ + if (out) + { + char buf[16384]; /* Flawfinder: ignore */ + size_t readbytes; + bool write_ok = true; + while(write_ok && (readbytes = fread(buf, 1, 16384, in))) /* Flawfinder: ignore */ + { + if (fwrite(buf, 1, readbytes, out) != readbytes) + { + LL_WARNS("SpellCheck") << "Short write" << LL_ENDL; + write_ok = false; + } + } + if ( write_ok ) + { + copied = true; + } + fclose(out); + } + } + fclose(in); + return copied; +} -- cgit v1.2.3 From c3cb28ec67435a161f4d53b8191ed5f87c17f99d Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 15 Jun 2012 09:16:49 -0400 Subject: minor cosmetic changes to spelling floater --- indra/newview/llfloaterspellchecksettings.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 758ac23b4c..8e4e5bb744 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -69,7 +69,7 @@ BOOL LLFloaterSpellCheckerSettings::postBuild(void) getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); - + center(); return true; } @@ -85,8 +85,6 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std LLSD row; row["columns"][0]["column"] = "name"; - row["columns"][0]["font"]["name"] = "SANSSERIF_SMALL"; - row["columns"][0]["font"]["style"] = "NORMAL"; std::vector sel_items = from_ctrl->getAllSelected(); std::vector::const_iterator sel_it; @@ -164,7 +162,6 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) dict_cur = LLSpellChecker::instance().getPrimaryDictionary(); } dict_combo->clearRows(); - dict_combo->setEnabled(enabled); const LLSD& dict_map = LLSpellChecker::getDictionaryMap(); if (dict_map.size()) @@ -182,6 +179,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) dict_combo->clear(); } } + dict_combo->setEnabled(enabled); // Populate the available and active dictionary list LLScrollListCtrl* avail_ctrl = findChild("spellcheck_available_list"); @@ -210,8 +208,6 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) LLSD row; row["columns"][0]["column"] = "name"; - row["columns"][0]["font"]["name"] = "SANSSERIF_SMALL"; - row["columns"][0]["font"]["style"] = "NORMAL"; active_ctrl->clearRows(); active_ctrl->setEnabled(enabled); -- cgit v1.2.3 From bdb0f4f4853472bdba94ed7a6a70653de6290e0c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 15 Jun 2012 17:11:58 +0200 Subject: STORM-276 FIXED Main dictionary combobox in spell check settings floater doesn't sort dictionaries by name --- indra/newview/llfloaterspellchecksettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 8e4e5bb744..22eaa566fe 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -179,6 +179,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) dict_combo->clear(); } } + dict_combo->sortByName(); dict_combo->setEnabled(enabled); // Populate the available and active dictionary list -- cgit v1.2.3 From 3f7ed8b888b5725912e38f19e36c4c5e1583ea7c Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 15 Jun 2012 12:36:03 -0400 Subject: STORM-1883: add alert when a secondary dictionary is imported --- indra/newview/llfloaterspellchecksettings.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 22eaa566fe..d7fbc94631 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -310,6 +310,10 @@ void LLFloaterSpellCheckerImport::onBtnOK() } else { + LLSD args = LLSD::emptyMap(); + args["DIC_NAME"] = dict_dic; + LLNotificationsUtil::add("SpellingDictIsSecondary", args); + imported = true; } } -- cgit v1.2.3 From f15fc05fd2076674b1c955ac0f8914c8ed411a50 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Fri, 15 Jun 2012 20:47:02 +0200 Subject: STORM-276 Ease-of-use importing of Open Office dictionary extensions --- indra/newview/llfloaterspellchecksettings.cpp | 87 ++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index d7fbc94631..c62577bc94 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -264,7 +264,18 @@ void LLFloaterSpellCheckerImport::onBtnBrowse() return; } - const std::string filepath = file_picker.getFirstFile(); + std::string filepath = file_picker.getFirstFile(); + + const std::string extension = gDirUtilp->getExtension(filepath); + if ("xcu" == extension) + { + filepath = parseXcuFile(filepath); + if (filepath.empty()) + { + return; + } + } + getChild("dictionary_path")->setValue(filepath); mDictionaryDir = gDirUtilp->getDirName(filepath); @@ -398,3 +409,77 @@ bool LLFloaterSpellCheckerImport::copyFile(const std::string from, const std::st fclose(in); return copied; } + +std::string LLFloaterSpellCheckerImport::parseXcuFile(const std::string& file_path) const +{ + LLXMLNodePtr xml_root; + if ( (!LLUICtrlFactory::getLayeredXMLNode(file_path, xml_root)) || (xml_root.isNull()) ) + { + return LLStringUtil::null; + } + + // Bury down to the "Dictionaries" parent node + LLXMLNode* dict_node = NULL; + for (LLXMLNode* outer_node = xml_root->getFirstChild(); outer_node && !dict_node; outer_node = outer_node->getNextSibling()) + { + std::string temp; + if ( (outer_node->getAttributeString("oor:name", temp)) && ("ServiceManager" == temp) ) + { + for (LLXMLNode* inner_node = outer_node->getFirstChild(); inner_node && !dict_node; inner_node = inner_node->getNextSibling()) + { + if ( (inner_node->getAttributeString("oor:name", temp)) && ("Dictionaries" == temp) ) + { + dict_node = inner_node; + break; + } + } + } + } + + if (dict_node) + { + // Iterate over all child nodes until we find one that has a DICT_SPELL node + for (LLXMLNode* outer_node = dict_node->getFirstChild(); outer_node; outer_node = outer_node->getNextSibling()) + { + std::string temp; + LLXMLNodePtr location_node, format_node; + for (LLXMLNode* inner_node = outer_node->getFirstChild(); inner_node; inner_node = inner_node->getNextSibling()) + { + if (inner_node->getAttributeString("oor:name", temp)) + { + if ("Locations" == temp) + { + inner_node->getChild("value", location_node, false); + } + else if ("Format" == temp) + { + inner_node->getChild("value", format_node, false); + } + } + } + if ( (format_node.isNull()) || ("DICT_SPELL" != format_node->getValue()) || (location_node.isNull()) ) + { + continue; + } + + // Found a list of file locations, return the .dic (if present) + std::list location_list; + boost::split(location_list, location_node->getValue(), boost::is_any_of(std::string(" "))); + for (std::list::iterator it = location_list.begin(); it != location_list.end(); ++it) + { + std::string& location = *it; + if ("\\" != gDirUtilp->getDirDelimiter()) + LLStringUtil::replaceString(location, "\\", gDirUtilp->getDirDelimiter()); + else + LLStringUtil::replaceString(location, "/", gDirUtilp->getDirDelimiter()); + LLStringUtil::replaceString(location, "%origin%", gDirUtilp->getDirName(file_path)); + if ("dic" == gDirUtilp->getExtension(location)) + { + return location; + } + } + } + } + + return LLStringUtil::null; +} -- cgit v1.2.3 From 5dceb6b06c8493d0bf0e21ead14539185bd4b4a8 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Wed, 20 Jun 2012 21:52:42 -0400 Subject: STORM-1889: require all fields when importing spelling dictionary --- indra/newview/llfloaterspellchecksettings.cpp | 56 +++++++++++++++------------ 1 file changed, 31 insertions(+), 25 deletions(-) (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index c62577bc94..5ecdd11918 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -294,47 +294,53 @@ void LLFloaterSpellCheckerImport::onBtnOK() const std::string dict_aff = mDictionaryDir + gDirUtilp->getDirDelimiter() + mDictionaryBasename + ".aff"; std::string dict_language = getChild("dictionary_language")->getValue().asString(); LLStringUtil::trim(dict_language); - if ( (dict_language.empty()) || (!gDirUtilp->fileExists(dict_dic)) || - (mDictionaryDir.empty()) || (mDictionaryBasename.empty()) ) - { - return; - } bool imported = false; - std::string settings_dic = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".dic"; - if ( copyFile( dict_dic, settings_dic ) ) + if ( dict_language.empty() + || mDictionaryDir.empty() + || mDictionaryBasename.empty() + || ! gDirUtilp->fileExists(dict_dic) + ) { - if (gDirUtilp->fileExists(dict_aff)) + LLNotificationsUtil::add("SpellingDictImportRequired"); + } + else + { + std::string settings_dic = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".dic"; + if ( copyFile( dict_dic, settings_dic ) ) { - std::string settings_aff = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".aff"; - if (copyFile( dict_aff, settings_aff )) + if (gDirUtilp->fileExists(dict_aff)) { - imported = true; + std::string settings_aff = LLSpellChecker::getDictionaryUserPath() + mDictionaryBasename + ".aff"; + if (copyFile( dict_aff, settings_aff )) + { + imported = true; + } + else + { + LLSD args = LLSD::emptyMap(); + args["FROM_NAME"] = dict_aff; + args["TO_NAME"] = settings_aff; + LLNotificationsUtil::add("SpellingDictImportFailed", args); + } } else { LLSD args = LLSD::emptyMap(); - args["FROM_NAME"] = dict_aff; - args["TO_NAME"] = settings_aff; - LLNotificationsUtil::add("SpellingDictImportFailed", args); + args["DIC_NAME"] = dict_dic; + LLNotificationsUtil::add("SpellingDictIsSecondary", args); + + imported = true; } } else { LLSD args = LLSD::emptyMap(); - args["DIC_NAME"] = dict_dic; - LLNotificationsUtil::add("SpellingDictIsSecondary", args); - - imported = true; + args["FROM_NAME"] = dict_dic; + args["TO_NAME"] = settings_dic; + LLNotificationsUtil::add("SpellingDictImportFailed", args); } } - else - { - LLSD args = LLSD::emptyMap(); - args["FROM_NAME"] = dict_dic; - args["TO_NAME"] = settings_dic; - LLNotificationsUtil::add("SpellingDictImportFailed", args); - } if ( imported ) { -- cgit v1.2.3 From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/newview/llfloaterspellchecksettings.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/newview/llfloaterspellchecksettings.cpp (limited to 'indra/newview/llfloaterspellchecksettings.cpp') diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp old mode 100644 new mode 100755 -- cgit v1.2.3