* rename SpellBase to SpellChecker

* make it a pure virtual interface
* delete alive() method as this one is not useful anymore since we killed ispell support.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-03-29 19:49:52 +00:00
parent 882d0a3867
commit 1141ccb997
7 changed files with 23 additions and 87 deletions

View File

@ -108,7 +108,7 @@ src_header_files = Split('''
ServerSocket.h
Session.h
Spacing.h
SpellBase.h
SpellChecker.h
TexRow.h
Text.h
TextClass.h
@ -236,7 +236,6 @@ src_post_files = Split('''
Dimension.cpp
ModuleList.cpp
PrinterParams.cpp
SpellBase.cpp
Thesaurus.cpp
boost.cpp
''')

View File

@ -13,7 +13,7 @@
#ifndef LYX_ASPELL_H
#define LYX_ASPELL_H
#include "SpellBase.h"
#include "SpellChecker.h"
#include <map>
#include <string>
@ -28,7 +28,7 @@ namespace lyx {
class BufferParams;
class ASpell : public SpellBase {
class ASpell : public SpellChecker {
public:
/**
* Initialise the spellchecker with the given buffer params and language.
@ -37,12 +37,6 @@ public:
virtual ~ASpell();
/**
* return true if the spellchecker instance still exists
* Always true for aspell, since there is no separate process
*/
virtual bool alive() { return true; }
/// check the given word and return the result
virtual enum Result check(WordLangTuple const &);

View File

@ -58,7 +58,7 @@ endif
# and in fact libtools seems not able to do that.
lyx_SOURCES = \
main.cpp \
$(ASPELL) SpellBase.cpp \
$(ASPELL) \
BiblioInfo.h \
BiblioInfo.cpp \
Box.cpp \
@ -252,7 +252,7 @@ HEADERFILESCORE = \
Session.h \
sgml.h \
Spacing.h \
SpellBase.h \
SpellChecker.h \
TexRow.h \
TexStream.h \
Text.h \

View File

@ -1,55 +0,0 @@
/**
* \file SpellBase.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author unknown
* \author John Levon
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "SpellBase.h"
#include "support/gettext.h"
#include "support/docstring.h"
using namespace std;
namespace lyx {
bool SpellBase::alive()
{
return false;
}
SpellBase::Result SpellBase::check(WordLangTuple const &)
{
return UNKNOWN_WORD;
}
void SpellBase::insert(WordLangTuple const &)
{}
void SpellBase::accept(WordLangTuple const &)
{}
docstring const SpellBase::nextMiss()
{
return docstring();
}
docstring const SpellBase::error()
{
return _("Native OS API not yet supported.");
}
} // namespace lyx

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
/**
* \file SpellBase.h
* \file SpellChecker.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -25,7 +25,7 @@ class WordLangTuple;
* Base class of all spellchecker implementations.
* The class can be instantiated but will have no functionality.
*/
class SpellBase {
class SpellChecker {
public:
/// the result from checking a single word
@ -44,25 +44,23 @@ public:
IGNORED_WORD
};
virtual ~SpellBase() {}
/// return true if the spellchecker instance still exists
virtual bool alive();
virtual ~SpellChecker() {}
/// check the given word of the given lang code and return the result
virtual enum Result check(WordLangTuple const &);
virtual enum Result check(WordLangTuple const &) = 0;
/// insert the given word into the personal dictionary
virtual void insert(WordLangTuple const &);
virtual void insert(WordLangTuple const &) = 0;
/// accept the given word temporarily
virtual void accept(WordLangTuple const &);
virtual void accept(WordLangTuple const &) = 0;
/// return the next near miss after a SUGGESTED_WORDS result
virtual docstring const nextMiss();
virtual docstring const nextMiss() = 0;
/// give an error message on messy exit
virtual docstring const error();
virtual docstring const error() = 0;
};

View File

@ -36,7 +36,7 @@
# include "ASpell_local.h"
#endif
#include "SpellBase.h"
#include "SpellChecker.h"
#include "frontends/alert.h"
@ -193,7 +193,7 @@ void GuiSpellchecker::partialUpdate(int state)
}
static SpellBase * createSpeller(BufferParams const & bp)
static SpellChecker * createSpeller(BufferParams const & bp)
{
string lang = lyxrc.spellchecker_use_alt_lang
? lyxrc.spellchecker_alt_lang
@ -202,7 +202,7 @@ static SpellBase * createSpeller(BufferParams const & bp)
#if defined(USE_ASPELL)
return new ASpell(bp, lang);
#endif
return new SpellBase;
return 0;
}
@ -265,7 +265,7 @@ void GuiSpellchecker::check()
{
LYXERR(Debug::GUI, "Check the spelling of a word");
SpellBase::Result res = SpellBase::OK;
SpellChecker::Result res = SpellChecker::OK;
Cursor cur = bufferview()->cursor();
while (cur && cur.pos() && isLetter(cur))
@ -282,7 +282,7 @@ void GuiSpellchecker::check()
exitEarly_ = false;
while (res == SpellBase::OK || res == SpellBase::IGNORED_WORD) {
while (res == SpellChecker::OK || res == SpellChecker::IGNORED_WORD) {
word_ = nextWord(cur, start);
// end of document
@ -327,7 +327,7 @@ void GuiSpellchecker::check()
bv->processUpdateFlags(Update::Force | Update::FitCursor);
// set suggestions
if (res != SpellBase::OK && res != SpellBase::IGNORED_WORD) {
if (res != SpellChecker::OK && res != SpellChecker::IGNORED_WORD) {
LYXERR(Debug::GUI, "Found a word needing checking.");
partialUpdate(SPELL_FOUND_WORD);
}
@ -336,7 +336,7 @@ void GuiSpellchecker::check()
bool GuiSpellchecker::checkAlive()
{
if (speller_->alive() && speller_->error().empty())
if (speller_->error().empty())
return true;
docstring message;

View File

@ -23,7 +23,7 @@ class QListWidgetItem;
namespace lyx {
class SpellBase;
class SpellChecker;
namespace frontend {
@ -104,7 +104,7 @@ private:
/// word count
int count_;
/// The actual spellchecker object
SpellBase * speller_;
SpellChecker * speller_;
};
} // namespace frontend