+ FileName base(basepath);
+ bool have_dict = base.isDirectory();
+
+ if (have_dict) {
+ FileName data(addPath(base.absFileName(), datapath));
+ FileName dict(addPath(base.absFileName(), dictpath));
+ have_dict = dict.isDirectory() && data.isDirectory();
+ if (have_dict) {
+ LYXERR(Debug::FILES, "aspell dict-dir: " << dict);
+ LYXERR(Debug::FILES, "aspell data-dir: " << data);
+ aspell_config_replace(config, "dict-dir", dict.absFileName().c_str());
+ aspell_config_replace(config, "data-dir", data.absFileName().c_str());
+ have_dict = isValidDictionary(config, lang, variety);
+ }
+ }
+ return have_dict;
+}
+
+
+AspellConfig * AspellChecker::Private::getConfig(string const & lang, string const & variety)
+{
+ AspellConfig * config = new_aspell_config();
+ bool have_dict = false;
+ string const sysdir = lyx::support::package().system_support().absFileName();
+ string const userdir = lyx::support::package().user_support().absFileName();
+
+ LYXERR(Debug::FILES, "aspell user dir: " << userdir);
+ have_dict = checkAspellData(config, userdir, dataDirectory(), dictDirectory(), lang, variety);
+ if (!have_dict) {
+ LYXERR(Debug::FILES, "aspell sysdir dir: " << sysdir);
+ have_dict = checkAspellData(config, sysdir, dataDirectory(), dictDirectory(), lang, variety);
+ }
+ if (!have_dict) {
+ // check for package data of OS installation
+ checkAspellData(config, osPackageBase(), osPackageDataDirectory(), osPackageDictDirectory(), lang, variety);
+ }
+ return config;
+}
+
+
+void AspellChecker::Private::addToSession(AspellCanHaveError * speller, docstring const & word)
+{
+ string const word_to_add = toAspellWord(word);
+ if (1 != aspell_speller_add_to_session(to_aspell_speller(speller), word_to_add.c_str(), -1))
+ LYXERR(Debug::GUI, "aspell add to session: " << aspell_error_message(speller));
+}
+
+
+void AspellChecker::Private::initSessionDictionary(
+ Speller const & speller,
+ PersonalWordList * pd)
+{
+ AspellSpeller * aspell = to_aspell_speller(speller.e_speller);
+ aspell_speller_clear_session(aspell);
+ docstring_list::const_iterator it = pd->begin();
+ docstring_list::const_iterator et = pd->end();
+ for (; it != et; ++it) {
+ addToSession(speller.e_speller, *it);
+ }
+ it = speller.ignored_words_.begin();
+ et = speller.ignored_words_.end();
+ for (; it != et; ++it) {
+ addToSession(speller.e_speller, *it);
+ }
+}
+
+
+AspellSpeller * AspellChecker::Private::addSpeller(Language const * lang)
+{
+ Speller m;
+ string const code = lang->code();
+ string const variety = lang->variety();
+ m.config = getConfig(code, variety);