]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSpellchecker.h
make lyx compile
[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 namespace lyx {
20
21 class SpellBase;
22
23 namespace frontend {
24
25 /** A controller for Spellchecker dialogs.
26  */
27 class ControlSpellchecker : public Dialog::Controller {
28 public:
29         enum State {
30                 SPELL_PROGRESSED, //< update progress bar
31                 SPELL_FOUND_WORD //< found a bad word
32         };
33
34         ControlSpellchecker(Dialog &);
35         ~ControlSpellchecker();
36         ///
37         virtual bool initialiseParams(std::string const & data);
38         ///
39         virtual void clearParams();
40         /// Not needed here
41         virtual void dispatchParams() {}
42         ///
43         virtual bool isBufferDependent() const { return true; }
44         ///
45         virtual bool exitEarly() const { return exitEarly_; }
46
47         /// replace word with replacement
48         void replace(docstring const &);
49
50         /// replace all occurances of word
51         void replaceAll(docstring const &);
52
53         /// insert word in personal dictionary
54         void insert();
55
56         /// ignore all occurances of word
57         void ignoreAll();
58
59         /// check text until next misspelled/unknown word
60         /// returns true when finished
61         void check();
62
63         /// get suggestion
64         docstring const getSuggestion() const;
65
66         /// get word
67         docstring const getWord() const;
68
69         /// returns progress value
70         int getProgress() const { return oldval_; }
71
72         /// returns word count
73         int getCount()  const { return count_; }
74
75 private:
76         /// give error message is spellchecker dies
77         bool checkAlive();
78
79         /// show count of checked words at normal exit
80         void showSummary();
81
82 private:
83         /// set to true when spellchecking is finished
84         bool exitEarly_;
85
86         /// current word being checked and lang code
87         WordLangTuple word_;
88
89         /// values for progress
90         int oldval_;
91         int newvalue_;
92
93         /// word count
94         int count_;
95
96         /// The actual spellchecker object
97         boost::scoped_ptr<SpellBase> speller_;
98 };
99
100 } // namespace frontend
101 } // namespace lyx
102
103 #endif // CONTROLSPELLCHECKER_H