} // anon namespace
-#ifndef HUNSPELL_DICT
-# define HUNSPELL_DICT "dict"
-#endif
struct HunspellChecker::Private
{
~Private();
+ const string dictPath(int selector);
+ bool haveLanguageFiles(string const & hpath);
bool haveDictionary(string const & lang, string & hpath);
bool haveDictionary(string const & lang);
Hunspell * addSpeller(string const & lang, string & hpath);
Spellers spellers_;
///
IgnoreList ignored_;
+
+ /// the location below system/user directory
+ /// there the aff+dic files lookup will happen
+ const string dictDirectory(void) const { return "dict"; }
+ int maxLookupSelector(void) const { return 3; }
};
}
-namespace {
-bool haveLanguageFiles(string const & hpath)
+bool HunspellChecker::Private::haveLanguageFiles(string const & hpath)
{
FileName const affix(hpath + ".aff");
FileName const dict(hpath + ".dic");
}
-#define MAX_SELECTOR 3
-string dictPath(int selector)
+const string HunspellChecker::Private::dictPath(int selector)
{
switch (selector) {
case 2:
- return addName(lyx::support::package().system_support().absFileName(),HUNSPELL_DICT);
+ return addName(lyx::support::package().system_support().absFileName(),dictDirectory());
break;
case 1:
- return addName(lyx::support::package().user_support().absFileName(),HUNSPELL_DICT);
+ return addName(lyx::support::package().user_support().absFileName(),dictDirectory());
break;
default:
return lyxrc.hunspelldir_path;
}
}
-}
-
bool HunspellChecker::Private::haveDictionary(string const & lang, string & hpath)
{
bool HunspellChecker::Private::haveDictionary(string const & lang)
{
bool result = false;
- for ( int p = 0; !result && p < MAX_SELECTOR; p++ ) {
+ for ( int p = 0; !result && p < maxLookupSelector(); p++ ) {
string lpath = dictPath(p);
result = haveDictionary(lang, lpath);
}
Hunspell * HunspellChecker::Private::addSpeller(string const & lang)
{
Hunspell * h = 0;
- for ( int p = 0; p < MAX_SELECTOR && 0 == h; p++ ) {
+ for ( int p = 0; p < maxLookupSelector() && 0 == h; p++ ) {
string lpath = dictPath(p);
h = addSpeller(lang, lpath);
}
SpellChecker::Result HunspellChecker::check(WordLangTuple const & wl)
{
if (d->isIgnored(wl))
- return OK;
+ return WORD_OK;
Hunspell * h = d->speller(wl.lang()->code());
if (!h)
- return OK;
+ return WORD_OK;
int info;
string const encoding = h->get_dic_encoding();
string const word_to_check = to_iconv_encoding(wl.word(), encoding);
if (h->spell(word_to_check.c_str(), &info))
- return OK;
+ return WORD_OK;
if (info & SPELL_COMPOUND) {
// FIXME: What to do with that?
}
+void HunspellChecker::advanceChangeNumber()
+{
+ nextChangeNumber();
+}
+
+
void HunspellChecker::insert(WordLangTuple const & wl)
{
string const word_to_check = to_utf8(wl.word());
if (!h)
return;
h->add(word_to_check.c_str());
+ advanceChangeNumber();
}
void HunspellChecker::accept(WordLangTuple const & wl)
{
d->ignored_.push_back(wl);
+ advanceChangeNumber();
}