]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
Remove a whole heap of redundant functions from classes derived from
[lyx.git] / src / frontends / controllers / ControlThesaurus.C
1 /**
2  * \file ControlThesaurus.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13
14 #include "ControlThesaurus.h"
15
16 #include "gettext.h"
17 #include "lyxfind.h"
18
19 #include "frontends/LyXView.h"
20
21
22 using std::string;
23
24
25 ControlThesaurus::ControlThesaurus(Dialog & parent)
26         : Dialog::Controller(parent)
27 {}
28
29
30 bool ControlThesaurus::initialiseParams(string const & data)
31 {
32         oldstr_ = data;
33         return true;
34 }
35
36
37 void ControlThesaurus::clearParams()
38 {
39         oldstr_.erase();
40 }
41
42
43 void ControlThesaurus::replace(string const & newstr)
44 {
45         /* FIXME: this is not suitable ! We need to have a "lock"
46          * on a particular charpos in a paragraph that is broken on
47          * deletion/change !
48          */
49         int const replace_count =
50                 lyx::find::replace(kernel().bufferview(), oldstr_, newstr,
51                                    true /*cs*/, true /*mw*/, true /*fw*/);
52
53         oldstr_ = newstr;
54
55         if (replace_count == 0)
56                 kernel().lyxview().message(_("String not found!"));
57         else
58                 kernel().lyxview().message(_("String has been replaced."));
59 }
60
61
62 Thesaurus::Meanings const &
63 ControlThesaurus::getMeanings(string const & str)
64 {
65         if (str != laststr_)
66                 meanings_ = thesaurus.lookup(str);
67
68         return meanings_;
69 }