]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlThesaurus.C
fix crash due to invalidated iterator
[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 #include "ControlThesaurus.h"
14
15 #include "lyxfind.h"
16 #include "funcrequest.h"
17
18 using std::string;
19
20 namespace lyx {
21 namespace frontend {
22
23 ControlThesaurus::ControlThesaurus(Dialog & parent)
24         : Dialog::Controller(parent)
25 {}
26
27
28 bool ControlThesaurus::initialiseParams(string const & data)
29 {
30         oldstr_ = data;
31         return true;
32 }
33
34
35 void ControlThesaurus::clearParams()
36 {
37         oldstr_.erase();
38 }
39
40
41 void ControlThesaurus::replace(string const & newstr)
42 {
43         /* FIXME: this is not suitable ! We need to have a "lock"
44          * on a particular charpos in a paragraph that is broken on
45          * deletion/change !
46          */
47         string const data =
48                 find::replace2string(oldstr_, newstr,
49                                      true,  // case sensitive
50                                      true,  // match word
51                                      false, // all words
52                                      true); // forward
53         kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
54 }
55
56
57 Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
58 {
59         if (str != laststr_)
60                 meanings_ = thesaurus.lookup(str);
61         return meanings_;
62 }
63
64 } // namespace frontend
65 } // namespace lyx