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