]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSpellchecker.h
Extracted from r14281
[lyx.git] / src / frontends / controllers / ControlSpellchecker.h
1 // -*- C++ -*-
2 /**
3  * \file ControlSpellchecker.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONTROLSPELLCHECKER_H
13 #define CONTROLSPELLCHECKER_H
14
15 #include "Dialog.h"
16 #include "WordLangTuple.h"
17 #include <boost/scoped_ptr.hpp>
18
19 class SpellBase;
20
21 namespace lyx {
22 namespace frontend {
23
24 /** A controller for Spellchecker dialogs.
25  */
26 class ControlSpellchecker : public Dialog::Controller {
27 public:
28         enum State {
29                 SPELL_PROGRESSED, //< update progress bar
30                 SPELL_FOUND_WORD //< found a bad word
31         };
32
33         ControlSpellchecker(Dialog &);
34         ~ControlSpellchecker();
35         ///
36         virtual bool initialiseParams(std::string const & data);
37         ///
38         virtual void clearParams();
39         /// Not needed here
40         virtual void dispatchParams() {}
41         ///
42         virtual bool isBufferDependent() const { return true; }
43         ///
44         virtual bool exitEarly() const { return exitEarly_; }
45
46         /// replace word with replacement
47         void replace(std::string const &);
48
49         /// replace all occurances of word
50         void replaceAll(std::string const &);
51
52         /// insert word in personal dictionary
53         void insert();
54
55         /// ignore all occurances of word
56         void ignoreAll();
57
58         /// check text until next misspelled/unknown word
59         /// returns true when finished
60         void check();
61
62         /// get suggestion
63         std::string const getSuggestion() const;
64
65         /// get word
66         std::string const getWord() const;
67
68         /// returns progress value
69         int getProgress() const { return oldval_; }
70
71         /// returns word count
72         int getCount()  const { return count_; }
73
74 private:
75         /// give error message is spellchecker dies
76         bool checkAlive();
77
78         /// show count of checked words at normal exit
79         void showSummary();
80
81 private:
82         /// set to true when spellchecking is finished
83         bool exitEarly_;
84
85         /// current word being checked and lang code
86         WordLangTuple word_;
87
88         /// values for progress
89         int oldval_;
90         int newvalue_;
91
92         /// word count
93         int count_;
94
95         /// The actual spellchecker object
96         boost::scoped_ptr<SpellBase> speller_;
97 };
98
99 } // namespace frontend
100 } // namespace lyx
101
102 #endif // CONTROLSPELLCHECKER_H