+ string const langmap = d->languageMap[lang->lang()];
+ bool result = !langmap.empty();
+
+ if (result)
+ return result;
+
+ result = AppleSpeller_hasLanguage(d->speller, lang->code().c_str());
+ if (result) {
+ d->languageMap[lang->lang()] = lang->code();
+ } else {
+ result = AppleSpeller_hasLanguage(d->speller, lang->lang().c_str());
+ if (result)
+ d->languageMap[lang->lang()] = lang->lang();
+ }
+ LYXERR(Debug::GUI, "has dictionary: " << lang->lang() << " = " << result);
+ return result;
+}
+
+
+int AppleSpellChecker::numDictionaries() const
+{
+ int result = 0;
+ map<string, string>::const_iterator it = d->languageMap.begin();
+ map<string, string>::const_iterator et = d->languageMap.end();
+
+ for (; it != et; ++it) {
+ string const langmap = it->second;
+ result += langmap.empty() ? 0 : 1;
+ }
+ return result;
+}
+
+
+int AppleSpellChecker::numMisspelledWords() const
+{
+ return AppleSpeller_numMisspelledWords(d->speller);
+}
+
+
+void AppleSpellChecker::misspelledWord(int index, int & start, int & length) const
+{
+ AppleSpeller_misspelledWord(d->speller, index, &start, &length);