+struct Thesaurus::Private
+{
+ ~Private()
+ {
+ for (Thesauri::iterator it = thes_.begin();
+ it != thes_.end(); ++it) {
+ delete it->second;
+ }
+ }
+ ///
+ bool thesaurusAvailable(docstring const & lang) const
+ {
+ for (Thesauri::const_iterator it = thes_.begin();
+ it != thes_.end(); ++it) {
+ if (it->first == lang)
+ if (it->second)
+ return true;
+ }
+ return false;
+ }
+
+ /// add a thesaurus to the list
+ bool addThesaurus(docstring const & lang);
+
+ /// the thesauri
+ Thesauri thes_;
+};
+
+bool Thesaurus::Private::addThesaurus(docstring const & lang)
+{
+ string const thes_path = external_path(lyxrc.thesaurusdir_path);
+ LYXERR(Debug::FILES, "thesaurus path: " << thes_path);
+ if (thes_path.empty())
+ return false;
+
+ if (thesaurusAvailable(lang))
+ return true;
+
+ FileNameList const idx_files = FileName(thes_path).dirList("idx");
+ FileNameList const data_files = FileName(thes_path).dirList("dat");
+ string idx;
+ string data;
+
+ for (FileNameList::const_iterator it = idx_files.begin();
+ it != idx_files.end(); ++it) {
+ LYXERR(Debug::FILES, "found thesaurus idx file: " << it->onlyFileName());
+ if (contains(it->onlyFileName(), to_ascii(lang))) {
+ idx = it->absFilename();
+ LYXERR(Debug::FILES, "selected thesaurus idx file: " << idx);
+ break;
+ }
+ }
+
+ for (support::FileNameList::const_iterator it = data_files.begin();
+ it != data_files.end(); ++it) {
+ LYXERR(Debug::FILES, "found thesaurus data file: " << it->onlyFileName());
+ if (contains(it->onlyFileName(), to_ascii(lang))) {
+ data = it->absFilename();
+ LYXERR(Debug::FILES, "selected thesaurus data file: " << data);
+ break;
+ }
+ }
+
+ if (idx.empty() || data.empty())
+ return false;
+
+ char const * af = idx.c_str();
+ char const * df = data.c_str();
+ thes_[lang] = new MyThes(af, df);
+ return true;
+}
+
+
+bool Thesaurus::thesaurusAvailable(docstring const & lang) const