]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlThesaurus.C
fix crash due to invalidated iterator
[lyx.git] / src / frontends / controllers / ControlThesaurus.C
index 182b9c0bb1643b2dbbe34e218e42d8735fc029a0..f99770f071409a4eb84bfbb4a39ca6020c8c1a0c 100644 (file)
@@ -5,29 +5,36 @@
  *
  * \author John Levon
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-
 #include "ControlThesaurus.h"
 
-#include "gettext.h"
 #include "lyxfind.h"
+#include "funcrequest.h"
 
-#include "frontends/LyXView.h"
+using std::string;
 
+namespace lyx {
+namespace frontend {
 
-ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
-       : ControlDialogBD(lv, d)
+ControlThesaurus::ControlThesaurus(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-void ControlThesaurus::showEntry(string const & entry)
+bool ControlThesaurus::initialiseParams(string const & data)
+{
+       oldstr_ = data;
+       return true;
+}
+
+
+void ControlThesaurus::clearParams()
 {
-       oldstr_ = entry;
-       show();
+       oldstr_.erase();
 }
 
 
@@ -37,16 +44,13 @@ void ControlThesaurus::replace(string const & newstr)
         * on a particular charpos in a paragraph that is broken on
         * deletion/change !
         */
-       int const replace_count =
-               lyxfind::LyXReplace(bufferview(), oldstr_, newstr,
-                                   true, true, true, false, true);
-
-       oldstr_ = newstr;
-
-       if (replace_count == 0)
-               lv_.message(_("String not found!"));
-       else
-               lv_.message(_("String has been replaced."));
+       string const data =
+               find::replace2string(oldstr_, newstr,
+                                    true,  // case sensitive
+                                    true,  // match word
+                                    false, // all words
+                                    true); // forward
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
 }
 
 
@@ -54,6 +58,8 @@ Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
 {
        if (str != laststr_)
                meanings_ = thesaurus.lookup(str);
-
        return meanings_;
 }
+
+} // namespace frontend
+} // namespace lyx