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"
17 #include "support/lyxtime.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"
49 virtual ~SpellChecker() {}
51 /// does the spell check failed
52 static bool misspelled(Result res) {
54 && res != IGNORED_WORD
55 && res != LEARNED_WORD; }
57 /// check the given word of the given lang code and return the result
58 virtual enum Result check(WordLangTuple const &) = 0;
60 /// Gives suggestions.
61 virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
63 /// insert the given word into the personal dictionary
64 virtual void insert(WordLangTuple const &) = 0;
66 /// remove the given word from the personal dictionary
67 virtual void remove(WordLangTuple const &) = 0;
69 /// accept the given word temporarily
70 virtual void accept(WordLangTuple const &) = 0;
72 /// check if dictionary exists
73 virtual bool hasDictionary(Language const *) const = 0;
75 /// if speller can spell check whole paragraph return true
76 virtual bool canCheckParagraph() const { return false; }
78 /// count of misspelled words
79 virtual int numMisspelledWords() const { return 0; }
81 /// start position and length of misspelled word at index
82 virtual void misspelledWord(
84 int & start, int & length) const
86 /// index is used here to make the compiler happy
91 /// give an error message on messy exit
92 virtual docstring const error() = 0;
94 /// spell checker state versioning support
95 typedef unsigned long int ChangeNumber ;
96 ChangeNumber changeNumber() const { return change_number_; }
97 void changeNumber(ChangeNumber value) { change_number_ = value; }
98 void nextChangeNumber() { ++change_number_; }
99 virtual void advanceChangeNumber() = 0;
102 ChangeNumber change_number_;
105 /// Access to the singleton SpellChecker.
106 /// Implemented in LyX.cpp
107 SpellChecker * theSpellChecker();
109 /// Set the singleton SpellChecker engine.
110 /// Implemented in LyX.cpp
111 void setSpellChecker();
115 #endif // SPELL_BASE_H