// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 2001 The LyX Team.
+/**
+ * \file ControlSpellchecker.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ======================================================
+ * \author Edwin Leuven
*
- * \file ControlSpellchecker.h
- * \author Edwin Leuven <leuven@fee.uva.nl>
+ * Full author contact details are available in file CREDITS.
*/
#ifndef CONTROLSPELLCHECKER_H
#define CONTROLSPELLCHECKER_H
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "ControlDialog_impl.h"
+#include "Dialog.h"
+#include "WordLangTuple.h"
+#include <boost/scoped_ptr.hpp>
class SpellBase;
-
+
+namespace lyx {
+namespace frontend {
+
/** A controller for Spellchecker dialogs.
*/
-class ControlSpellchecker : public ControlDialogBD {
+class ControlSpellchecker : public Dialog::Controller {
public:
+ enum State {
+ SPELL_PROGRESSED, //< update progress bar
+ SPELL_FOUND_WORD //< found a bad word
+ };
+
+ ControlSpellchecker(Dialog &);
+ ~ControlSpellchecker();
+ ///
+ virtual bool initialiseParams(std::string const & data);
///
- ControlSpellchecker(LyXView &, Dialogs &);
+ virtual void clearParams();
+ /// Not needed here
+ virtual void dispatchParams() {}
+ ///
+ virtual bool isBufferDependent() const { return true; }
+ ///
+ virtual bool exitEarly() const { return exitEarly_; }
/// replace word with replacement
- void replace(string const &);
+ void replace(std::string const &);
/// replace all occurances of word
- void replaceAll(string const &);
+ void replaceAll(std::string const &);
/// insert word in personal dictionary
void insert();
/// ignore all occurances of word
void ignoreAll();
- /// stop checking
- void stop();
-
/// check text until next misspelled/unknown word
+ /// returns true when finished
void check();
/// get suggestion
- string getSuggestion();
+ std::string const getSuggestion() const;
/// get word
- string getWord();
+ std::string const getWord() const;
/// returns progress value
- int getProgress() {
- return oldval_;
- }
+ int getProgress() const { return oldval_; }
- /// returns exit message
- string getMessage() {
- return message_;
- }
+ /// returns word count
+ int getCount() const { return count_; }
private:
+ /// give error message is spellchecker dies
+ bool checkAlive();
- /// set the params before show or update
- void setParams();
- /// clean-up on hide.
- void clearParams();
+ /// show count of checked words at normal exit
+ void showSummary();
- /// not needed.
- virtual void apply() {}
-
- /// right to left
- bool rtl_;
+private:
+ /// set to true when spellchecking is finished
+ bool exitEarly_;
- /// current word being checked
- string word_;
+ /// current word being checked and lang code
+ WordLangTuple word_;
/// values for progress
- float newval_;
int oldval_;
int newvalue_;
/// word count
int count_;
- /// exit message
- string message_;
-
- /// set to true to stop checking
- bool stop_;
-
/// The actual spellchecker object
- SpellBase * speller_;
-
+ boost::scoped_ptr<SpellBase> speller_;
};
+} // namespace frontend
+} // namespace lyx
+
#endif // CONTROLSPELLCHECKER_H