]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlSpellchecker.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlSpellchecker.C
index c3019bda99f8ce8de2552411fa1b975623a88777..19c1acf035b26061234b2db86803c1b817fae122 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <config.h>
 
-
 #include "ControlSpellchecker.h"
 #include "ViewBase.h"
 #include "buffer.h"
 #include "ispell.h"
 #ifdef USE_PSPELL
 # include "pspell.h"
+#else
+#ifdef USE_ASPELL
+# include "aspell_local.h"
+#endif
 #endif
 
+#include "support/tostr.h"
+
 #include "frontends/Alert.h"
 
-#include "BoostFormat.h"
+using namespace lyx::support;
 
 using std::endl;
 
+
 ControlSpellchecker::ControlSpellchecker(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          newval_(0.0), oldval_(0), newvalue_(0), count_(0)
@@ -55,6 +61,30 @@ void ControlSpellchecker::clearParams()
        endSession();
 }
 
+namespace {
+
+SpellBase * getSpeller(BufferParams const & bp)
+{
+       string lang = (lyxrc.isp_use_alt_lang)
+                     ? lyxrc.isp_alt_lang
+                     : bp.language->code();
+
+#ifdef USE_ASPELL
+       if (lyxrc.use_spell_lib)
+               return new ASpell(bp, lang);
+#endif
+#ifdef USE_PSPELL
+       if (lyxrc.use_spell_lib)
+               return new PSpell(bp, lang);
+#endif
+
+       lang = (lyxrc.isp_use_alt_lang) ?
+               lyxrc.isp_alt_lang : bp.language->lang();
+
+       return new ISpell(bp, lang);
+}
+
+}
 
 void ControlSpellchecker::startSession()
 {
@@ -66,23 +96,7 @@ void ControlSpellchecker::startSession()
                return;
        }
 
-       // create spell object
-       string tmp;
-#ifdef USE_PSPELL
-       if (lyxrc.use_pspell) {
-               tmp = (lyxrc.isp_use_alt_lang) ?
-                       lyxrc.isp_alt_lang : buffer()->params.language->code();
-
-               speller_.reset(new PSpell(buffer()->params, tmp));
-       } else {
-#endif
-               tmp = (lyxrc.isp_use_alt_lang) ?
-                       lyxrc.isp_alt_lang : buffer()->params.language->lang();
-
-               speller_.reset(new ISpell(buffer()->params, tmp));
-#ifdef USE_PSPELL
-       }
-#endif
+       speller_.reset(getSpeller(buffer()->params));
 
        // reset values to initial
        newval_ = 0.0;
@@ -103,7 +117,7 @@ void ControlSpellchecker::startSession()
                message = _("The spell-checker could not be started.\n"
                         "Maybe it is mis-configured.");
 
-       Alert::alert(_("The spell-checker has failed"), message);
+       Alert::error(_("The spell-checker has failed"), message);
        speller_.reset(0);
 }
 
@@ -196,7 +210,7 @@ bool ControlSpellchecker::checkAlive()
        view().hide();
        speller_.reset(0);
 
-       Alert::alert(_("The spell-checker has failed"), message);
+       Alert::error(_("The spell-checker has failed"), message);
        return false;
 }
 
@@ -209,25 +223,13 @@ void ControlSpellchecker::showSummary()
        }
 
        string message;
-
-#if USE_BOOST_FORMAT
-       if (count_ != 1) {
-               boost::format fmter("%1$d words checked.");
-               fmter % count_;
-               message += fmter.str();
-       } else {
-               message += _("One word checked.");
-       }
-#else
-       if (count_ != 1) {
-               message += tostr(count_) + " words checked";
-       } else {
+       if (count_ != 1)
+               message = bformat(_("%1$s words checked."), tostr(count_));
+       else
                message = _("One word checked.");
-       }
-#endif
 
        view().hide();
-       Alert::alert(_("Spell-checking is complete"), message);
+       Alert::information(_("Spell-checking is complete"), message);
 }
 
 
@@ -271,5 +273,3 @@ void ControlSpellchecker::ignoreAll()
        speller_->accept(word_);
        check();
 }
-
-