]> git.lyx.org Git - lyx.git/blobdiff - src/AspellChecker.cpp
(finishing patch -- question was restored, but there were still problems)
[lyx.git] / src / AspellChecker.cpp
index 77c4b5bc85c3343dc105f15f431b28768176b263..0b277923d69064c987801b01c2bc9dbba3d397a1 100644 (file)
@@ -224,7 +224,7 @@ AspellSpeller * AspellChecker::Private::addSpeller(string const & lang,
        }
 
        spellers_[spellerID(lang, variety)] = m;
-       return 0 == m.config ? 0 : to_aspell_speller(m.e_speller);
+       return m.e_speller ? to_aspell_speller(m.e_speller) : 0;
 }
 
 
@@ -266,17 +266,23 @@ SpellChecker::Result AspellChecker::check(WordLangTuple const & word)
                d->speller(word.lang()->code(), word.lang()->variety());
 
        if (!m)
-               return OK;
+               return WORD_OK;
 
        if (word.word().empty())
                // MSVC compiled Aspell doesn't like it.
-               return OK;
+               return WORD_OK;
 
-       const char * word_str = to_utf8(word.word()).c_str();
-       int const word_ok = aspell_speller_check(m, word_str, -1);
+       string const word_str = to_utf8(word.word());
+       int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
        LASSERT(word_ok != -1, /**/);
 
-       return (word_ok) ? OK : UNKNOWN_WORD;
+       return (word_ok) ? WORD_OK : UNKNOWN_WORD;
+}
+
+
+void AspellChecker::advanceChangeNumber()
+{
+       nextChangeNumber();
 }
 
 
@@ -287,6 +293,7 @@ void AspellChecker::insert(WordLangTuple const & word)
        if (it != d->spellers_.end()) {
                AspellSpeller * speller = to_aspell_speller(it->second.e_speller);
                aspell_speller_add_to_personal(speller, to_utf8(word.word()).c_str(), -1);
+               advanceChangeNumber();
        }
 }
 
@@ -298,6 +305,7 @@ void AspellChecker::accept(WordLangTuple const & word)
        if (it != d->spellers_.end()) {
                AspellSpeller * speller = to_aspell_speller(it->second.e_speller);
                aspell_speller_add_to_session(speller, to_utf8(word.word()).c_str(), -1);
+               advanceChangeNumber();
        }
 }
 
@@ -338,7 +346,7 @@ bool AspellChecker::hasDictionary(Language const * lang) const
 
        if (lang) {
                for (; it != end && !have; ++it) {
-                       have = d->isValidDictionary(it->second.config, lang->code(), lang->variety());
+                       have = it->second.config && d->isValidDictionary(it->second.config, lang->code(), lang->variety());
                }
                if (!have) {
                        AspellConfig * config = d->getConfig(lang->code(), lang->variety());