std::vector<std::string> lggHunSpell_Wrapper::getAvailDicts() { std::vector<std::string> toReturn; std::vector<std::string> dics = getExtraDicts(); std::vector<std::string> installedDics = getInstalledDicts(); for (int i = 0; i < (int)dics.size(); i++) { bool found = false; for (int j = 0; j < (int)installedDics.size(); j++) { if (0 == LLStringUtil::compareInsensitive(dics[i], installedDics[j])) { found = true;//this dic is already installed } } if (0 == LLStringUtil::compareInsensitive(dics[i], currentBaseDic)) { found = true; } if (0 == LLStringUtil::compareInsensitive(dics[i], "custom")) { found = true; } if (!found) { toReturn.push_back(dics[i]); } } return toReturn; }
void lggHunSpell_Wrapper::setNewDictionary(std::string newDict) { llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl; currentBaseDic = newDict; //expecting a full name comming in newDict = fullName2DictName(newDict); if (myHunspell) { delete myHunspell; } std::string dicaffpath = getCorrectPath(newDict+".aff"); std::string dicdicpath = getCorrectPath(newDict+".dic"); llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl; myHunspell = new Hunspell(dicaffpath.c_str(), dicdicpath.c_str()); llinfos << "Adding custom dictionary " << llendl; createCustomDic(); addDictionary("custom"); std::vector<std::string> toInstall = getInstalledDicts(); for (int i = 0; i < (int)toInstall.size(); i++) { addDictionary(toInstall[i]); } }
void lggHunSpell_Wrapper::removeButton(std::string selection) { if(selection=="")return; std::vector<std::string> newInstalledDics; std::vector<std::string> currentlyInstalled = getInstalledDicts(); for(int i =0;i<(int)currentlyInstalled.size();i++) { if(0!=LLStringUtil::compareInsensitive(selection,currentlyInstalled[i])) newInstalledDics.push_back(fullName2DictName(currentlyInstalled[i])); } gSavedSettings.setString("EmeraldSpellInstalled",VEC2CSV(newInstalledDics)); processSettings(); }
void lggHunSpell_Wrapper::setNewDictionary(std::string newDict) { llinfos << "Setting new base dictionary long name is-> " << newDict.c_str() << llendl; currentBaseDic=newDict; //expecting a full name comming in newDict = fullName2DictName(newDict); if(myHunspell)delete myHunspell; std::string dicaffpath(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", std::string(newDict+".aff")).c_str()); std::string dicdicpath(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "dictionaries", std::string(newDict+".dic")).c_str()); //check to make sure this dictionary exists, if not, make it use one we know does if(!gDirUtilp->fileExists(dicaffpath)) { gSavedSettings.setString("EmeraldSpellBase","English (United States of America)"); LLSD args; args["MESSAGE"] = "Your current dictionary could not be found, please re-download it. Setting dictionary to English..."; LLNotifications::instance().add("GenericAlert", args); setNewDictionary("English (United States of America)"); return; } llinfos << "Setting new base dictionary -> " << dicaffpath.c_str() << llendl; myHunspell = new Hunspell(dicaffpath.c_str(),dicdicpath.c_str()); llinfos << "Adding custom dictionary " << llendl; addDictionary("emerald_custom"); std::vector<std::string> toInstall = getInstalledDicts(); for(int i =0;i<(int)toInstall.size();i++) addDictionary(toInstall[i]); }