Commits

Scott Lawrence  committed 050e487

STORM-1889: require all fields when importing spelling dictionary

  • Participants
  • Parent commits c6f13fd
  • Tags DRTVWR-168

Comments (0)

Files changed (2)

File indra/newview/llfloaterspellchecksettings.cpp

 	const std::string dict_aff = mDictionaryDir + gDirUtilp->getDirDelimiter() + mDictionaryBasename + ".aff";
 	std::string dict_language = getChild<LLUICtrl>("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 )
 	{

File indra/newview/skins/default/xui/en/notifications.xml

 
   <notification
    icon="alertmodal.tga"
+   name="SpellingDictImportRequired"
+   type="alertmodal">
+    You must specify a file, a name, and a language.
+    <tag>fail</tag>
+  </notification>
+
+  <notification
+   icon="alertmodal.tga"
    name="SpellingDictIsSecondary"
    type="alertmodal">
 The dictionary [DIC_NAME] does not appear to have an "aff" file; this means that it is a "secondary" dictionary.