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 /// number of document dictionary "word"
48 DOCUMENT_LEARNED_WORD,
49 /// missing dictionary for language
53 SpellChecker() : change_number_(0) {}
55 virtual ~SpellChecker() {}
57 /// does the spell check failed
58 static bool misspelled(Result res) {
60 && res != IGNORED_WORD
61 && res != NO_DICTIONARY
62 && res != LEARNED_WORD
63 && res != DOCUMENT_LEARNED_WORD; }
65 /// check the given word of the given lang code and return the result
66 virtual enum Result check(WordLangTuple const &,
67 std::vector<WordLangTuple> const &) = 0;
69 /// Gives suggestions.
70 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
72 /// Lemmatizing: return stem of word (used by Thesaurus).
73 virtual void stem(WordLangTuple const &, docstring_list & suggestions) = 0;
75 /// insert the given word into the personal dictionary
76 virtual void insert(WordLangTuple const &) = 0;
78 /// remove the given word from the personal dictionary
79 virtual void remove(WordLangTuple const &) = 0;
81 /// accept the given word temporarily
82 virtual void accept(WordLangTuple const &) = 0;
84 /// check if dictionary exists
85 virtual bool hasDictionary(Language const *) const = 0;
87 /// how many valid dictionaries were found
88 virtual int numDictionaries() const = 0;
90 /// if speller can spell check whole paragraph return true
91 virtual bool canCheckParagraph() const { return false; }
93 /// count of misspelled words
94 virtual int numMisspelledWords() const { return 0; }
96 /// start position and length of misspelled word at index
97 virtual void misspelledWord(
99 int & start, int & length) const
101 /// index is used here to make the compiler happy
106 /// give an error message on messy exit
107 virtual docstring const error() = 0;
109 /// spell checker state versioning support
110 typedef unsigned long int ChangeNumber ;
111 ChangeNumber changeNumber() const { return change_number_; }
112 void changeNumber(ChangeNumber value) { change_number_ = value; }
113 void nextChangeNumber() { ++change_number_; }
114 virtual void advanceChangeNumber() = 0;
117 ChangeNumber change_number_;
120 /// Access to the singleton SpellChecker.
121 /// Implemented in LyX.cpp
122 SpellChecker * theSpellChecker();
124 /// Set the singleton SpellChecker engine.
125 /// Implemented in LyX.cpp
126 void setSpellChecker();
130 #endif // SPELL_BASE_H