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"
28 * Pure virtual base class of all spellchecker implementations.
33 /// the result from checking a single word
37 /// root of given word was found
39 /// word found through compound formation
43 /// number of other ignored "word"
45 /// number of personal dictionary "word"
47 /// missing dictionary for language
51 SpellChecker() : change_number_(0) {}
53 virtual ~SpellChecker() {}
55 /// does the spell check failed
56 static bool misspelled(Result res) {
58 && res != IGNORED_WORD
59 && res != NO_DICTIONARY
60 && res != LEARNED_WORD; }
62 /// check the given word of the given lang code and return the result
63 virtual enum Result check(WordLangTuple const &,
64 std::vector<WordLangTuple> const &) = 0;
66 /// Gives suggestions.
67 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
69 /// Lemmatizing: return stem of word (used by Thesaurus).
70 virtual void stem(WordLangTuple const &, docstring_list & suggestions) = 0;
72 /// insert the given word into the personal dictionary
73 virtual void insert(WordLangTuple const &) = 0;
75 /// remove the given word from the personal dictionary
76 virtual void remove(WordLangTuple const &) = 0;
78 /// accept the given word temporarily
79 virtual void accept(WordLangTuple const &) = 0;
81 /// check if dictionary exists
82 virtual bool hasDictionary(Language const *) const = 0;
84 /// how many valid dictionaries were found
85 virtual int numDictionaries() const = 0;
87 /// if speller can spell check whole paragraph return true
88 virtual bool canCheckParagraph() const { return false; }
90 /// count of misspelled words
91 virtual int numMisspelledWords() const { return 0; }
93 /// start position and length of misspelled word at index
94 virtual void misspelledWord(
96 int & start, int & length) const
98 /// index is used here to make the compiler happy
103 /// give an error message on messy exit
104 virtual docstring const error() = 0;
106 /// spell checker state versioning support
107 typedef unsigned long int ChangeNumber ;
108 ChangeNumber changeNumber() const { return change_number_; }
109 void changeNumber(ChangeNumber value) { change_number_ = value; }
110 void nextChangeNumber() { ++change_number_; }
111 virtual void advanceChangeNumber() = 0;
114 ChangeNumber change_number_;
117 /// Access to the singleton SpellChecker.
118 /// Implemented in LyX.cpp
119 SpellChecker * theSpellChecker();
121 /// Set the singleton SpellChecker engine.
122 /// Implemented in LyX.cpp
123 void setSpellChecker();
127 #endif // SPELL_BASE_H