4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
16 #include "support/strfwd.h"
27 * Pure virtual base class of all spellchecker implementations.
32 /// the result from checking a single word
36 /// root of given word was found
38 /// word found through compound formation
42 /// number of other ignored "word"
44 /// number of personal dictionary "word"
48 virtual ~SpellChecker() {}
50 /// does the spell check failed
51 static bool misspelled(Result res) {
52 return res != SpellChecker::WORD_OK
53 && res != SpellChecker::IGNORED_WORD
54 && res != SpellChecker::LEARNED_WORD; }
56 /// check the given word of the given lang code and return the result
57 virtual enum Result check(WordLangTuple const &) = 0;
59 /// Gives suggestions.
60 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
62 /// insert the given word into the personal dictionary
63 virtual void insert(WordLangTuple const &) = 0;
65 /// remove the given word from the personal dictionary
66 virtual void remove(WordLangTuple const &) = 0;
68 /// accept the given word temporarily
69 virtual void accept(WordLangTuple const &) = 0;
71 /// check if dictionary exists
72 virtual bool hasDictionary(Language const *) const = 0;
74 /// if speller can spell check whole paragraph return true
75 virtual bool canCheckParagraph() const { return false; }
77 /// count of misspelled words
78 virtual int numMisspelledWords() const { return 0; }
80 /// start position and length of misspelled word at index
81 virtual void misspelledWord(
83 int & start, int & length) const
85 /// index is used here to make the compiler happy
90 /// give an error message on messy exit
91 virtual docstring const error() = 0;
94 /// Access to the singleton SpellChecker.
95 /// Implemented in LyX.cpp
96 SpellChecker * theSpellChecker();
98 /// Set the singleton SpellChecker engine.
99 /// Implemented in LyX.cpp
100 void setSpellChecker();
104 #endif // SPELL_BASE_H