]> git.lyx.org Git - lyx.git/blob - src/SpellChecker.h
bac19d116104f39b12af4fc3c0dc5553ed4d415c
[lyx.git] / src / SpellChecker.h
1 // -*- C++ -*-
2 /**
3  * \file SpellChecker.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef SPELL_BASE_H
14 #define SPELL_BASE_H
15
16 #include "support/strfwd.h"
17
18
19 namespace lyx {
20
21 class BufferParams;
22 class Language;
23 class WordLangTuple;
24 class docstring_list;
25
26 /**
27  * Pure virtual base class of all spellchecker implementations.
28  */
29 class SpellChecker {
30 public:
31
32         /// the result from checking a single word
33         enum Result  {
34                 /// word is correct
35                 OK = 1,
36                 /// root of given word was found
37                 ROOT,
38                 /// word found through compound formation
39                 COMPOUND_WORD,
40                 /// word not found
41                 UNKNOWN_WORD,
42                 /// number of other ignored "word"
43                 IGNORED_WORD
44         };
45
46         virtual ~SpellChecker() {}
47
48         /// check the given word of the given lang code and return the result
49         virtual enum Result check(WordLangTuple const &) = 0;
50         
51         /// Gives suggestions.
52         virtual void suggest(WordLangTuple const &, docstring_list & suggestions) = 0;
53
54         /// insert the given word into the personal dictionary
55         virtual void insert(WordLangTuple const &) = 0;
56
57         /// accept the given word temporarily
58         virtual void accept(WordLangTuple const &) = 0;
59
60         /// check if dictionary exists
61         virtual bool hasDictionary(Language const *) const = 0;
62
63         /// give an error message on messy exit
64         virtual docstring const error() = 0;
65 };
66
67 /// Access to the singleton SpellChecker.
68 /// Implemented in LyX.cpp
69 SpellChecker * theSpellChecker();
70
71 /// Set the singleton SpellChecker engine.
72 /// Implemented in LyX.cpp
73 void setSpellChecker();
74
75 } // namespace lyx
76
77 #endif // SPELL_BASE_H