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"
46 /// missing dictionary for language
50 SpellChecker() : change_number_(0) {}
52 virtual ~SpellChecker() {}
54 /// does the spell check failed
55 static bool misspelled(Result res) {
57 && res != IGNORED_WORD
58 && res != NO_DICTIONARY
59 && res != LEARNED_WORD; }
61 /// check the given word of the given lang code and return the result
62 virtual enum Result check(WordLangTuple const &) = 0;
64 /// Gives suggestions.
65 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
67 /// Lemmatizing: return stem of word (used by Thesaurus).
68 virtual void stem(WordLangTuple const &, docstring_list & suggestions) = 0;
70 /// insert the given word into the personal dictionary
71 virtual void insert(WordLangTuple const &) = 0;
73 /// remove the given word from the personal dictionary
74 virtual void remove(WordLangTuple const &) = 0;
76 /// accept the given word temporarily
77 virtual void accept(WordLangTuple const &) = 0;
79 /// check if dictionary exists
80 virtual bool hasDictionary(Language const *) const = 0;
82 /// how many valid dictionaries were found
83 virtual int numDictionaries() const = 0;
85 /// if speller can spell check whole paragraph return true
86 virtual bool canCheckParagraph() const { return false; }
88 /// count of misspelled words
89 virtual int numMisspelledWords() const { return 0; }
91 /// start position and length of misspelled word at index
92 virtual void misspelledWord(
94 int & start, int & length) const
96 /// index is used here to make the compiler happy
101 /// give an error message on messy exit
102 virtual docstring const error() = 0;
104 /// spell checker state versioning support
105 typedef unsigned long int ChangeNumber ;
106 ChangeNumber changeNumber() const { return change_number_; }
107 void changeNumber(ChangeNumber value) { change_number_ = value; }
108 void nextChangeNumber() { ++change_number_; }
109 virtual void advanceChangeNumber() = 0;
112 ChangeNumber change_number_;
115 /// Access to the singleton SpellChecker.
116 /// Implemented in LyX.cpp
117 SpellChecker * theSpellChecker();
119 /// Set the singleton SpellChecker engine.
120 /// Implemented in LyX.cpp
121 void setSpellChecker();
125 #endif // SPELL_BASE_H