]> git.lyx.org Git - lyx.git/blobdiff - src/AspellChecker.cpp
A little more lv cleanup.
[lyx.git] / src / AspellChecker.cpp
index 55441516d7d71e32a37e5dfb663d4f776ce0fe5a..a0560bf3c2d28dbea04d897762276211886bbed1 100644 (file)
@@ -161,7 +161,7 @@ SpellChecker::Result AspellChecker::check(WordLangTuple const & word)
 {
   
        AspellSpeller * m =
-               d->speller(word.lang_code(), word.lang_variety());
+               d->speller(word.lang()->code(), word.lang()->variety());
 
        if (!m)
                return OK;
@@ -180,7 +180,7 @@ SpellChecker::Result AspellChecker::check(WordLangTuple const & word)
 void AspellChecker::insert(WordLangTuple const & word)
 {
        Spellers::iterator it = d->spellers_.find(
-               d->spellerID(word.lang_code(), word.lang_variety()));
+               d->spellerID(word.lang()->code(), word.lang()->variety()));
        if (it != d->spellers_.end())
                aspell_speller_add_to_personal(it->second.speller, to_utf8(word.word()).c_str(), -1);
 }
@@ -189,7 +189,7 @@ void AspellChecker::insert(WordLangTuple const & word)
 void AspellChecker::accept(WordLangTuple const & word)
 {
        Spellers::iterator it = d->spellers_.find(
-               d->spellerID(word.lang_code(), word.lang_variety()));
+               d->spellerID(word.lang()->code(), word.lang()->variety()));
        if (it != d->spellers_.end())
                aspell_speller_add_to_session(it->second.speller, to_utf8(word.word()).c_str(), -1);
 }
@@ -200,7 +200,7 @@ void AspellChecker::suggest(WordLangTuple const & wl,
 {
        suggestions.clear();
        AspellSpeller * m =
-               d->speller(wl.lang_code(), wl.lang_variety());
+               d->speller(wl.lang()->code(), wl.lang()->variety());
 
        if (!m)
                return;
@@ -223,6 +223,42 @@ void AspellChecker::suggest(WordLangTuple const & wl,
 }
 
 
+bool AspellChecker::hasDictionary(Language const * lang) const
+{
+       if (!lang)
+               return false;
+       // code taken from aspell's list-dicts example
+       AspellConfig * config;
+       AspellDictInfoList * dlist;
+       AspellDictInfoEnumeration * dels;
+       const AspellDictInfo * entry;
+
+       config = new_aspell_config();
+
+       /* the returned pointer should _not_ need to be deleted */
+       dlist = get_aspell_dict_info_list(config);
+
+       /* config is no longer needed */
+       delete_aspell_config(config);
+
+       dels = aspell_dict_info_list_elements(dlist);
+
+       bool have = false;
+       while ((entry = aspell_dict_info_enumeration_next(dels)) != 0)
+       {
+               if (entry->code == lang->code()
+                   && (lang->variety().empty() || entry->jargon == lang->variety())) {
+                       have = true;
+                       break;
+               }
+       }
+
+       delete_aspell_dict_info_enumeration(dels);
+
+       return have;
+}
+
+
 docstring const AspellChecker::error()
 {
        char const * err = 0;