]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlSpellchecker.h
some support for pch
[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         /// replace word with replacement
45         void replace(std::string const &);
46
47         /// replace all occurances of word
48         void replaceAll(std::string const &);
49
50         /// insert word in personal dictionary
51         void insert();
52
53         /// ignore all occurances of word
54         void ignoreAll();
55
56         /// check text until next misspelled/unknown word
57         /// returns true when finished
58         void check();
59
60         /// get suggestion
61         std::string const getSuggestion() const;
62
63         /// get word
64         std::string const getWord() const;
65
66         /// returns progress value
67         int getProgress() const { return oldval_; }
68
69         /// returns word count
70         int getCount()  const { return count_; }
71
72 private:
73         /// give error message is spellchecker dies
74         bool checkAlive();
75
76         /// show count of checked words at normal exit
77         void showSummary();
78
79         /// current word being checked and lang code
80         WordLangTuple word_;
81
82         /// values for progress
83         int oldval_;
84         int newvalue_;
85
86         /// word count
87         int count_;
88
89         /// The actual spellchecker object
90         boost::scoped_ptr<SpellBase> speller_;
91 };
92
93 } // namespace frontend
94 } // namespace lyx
95
96 #endif // CONTROLSPELLCHECKER_H