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 virtual ~SpellChecker() {}
52 /// does the spell check failed
53 static bool misspelled(Result res) {
55 && res != IGNORED_WORD
56 && res != NO_DICTIONARY
57 && res != LEARNED_WORD; }
59 /// check the given word of the given lang code and return the result
60 virtual enum Result check(WordLangTuple const &) = 0;
62 /// Gives suggestions.
63 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
65 /// insert the given word into the personal dictionary
66 virtual void insert(WordLangTuple const &) = 0;
68 /// remove the given word from the personal dictionary
69 virtual void remove(WordLangTuple const &) = 0;
71 /// accept the given word temporarily
72 virtual void accept(WordLangTuple const &) = 0;
74 /// check if dictionary exists
75 virtual bool hasDictionary(Language const *) const = 0;
77 /// how many valid dictionaries were found
78 virtual int numDictionaries() const = 0;
80 /// if speller can spell check whole paragraph return true
81 virtual bool canCheckParagraph() const { return false; }
83 /// count of misspelled words
84 virtual int numMisspelledWords() const { return 0; }
86 /// start position and length of misspelled word at index
87 virtual void misspelledWord(
89 int & start, int & length) const
91 /// index is used here to make the compiler happy
96 /// give an error message on messy exit
97 virtual docstring const error() = 0;
99 /// spell checker state versioning support
100 typedef unsigned long int ChangeNumber ;
101 ChangeNumber changeNumber() const { return change_number_; }
102 void changeNumber(ChangeNumber value) { change_number_ = value; }
103 void nextChangeNumber() { ++change_number_; }
104 virtual void advanceChangeNumber() = 0;
107 ChangeNumber change_number_;
110 /// Access to the singleton SpellChecker.
111 /// Implemented in LyX.cpp
112 SpellChecker * theSpellChecker();
114 /// Set the singleton SpellChecker engine.
115 /// Implemented in LyX.cpp
116 void setSpellChecker();
120 #endif // SPELL_BASE_H