diff --git a/config/spell.m4 b/config/spell.m4 index c2033fb4a0..bcb6f0a6fd 100644 --- a/config/spell.m4 +++ b/config/spell.m4 @@ -2,33 +2,61 @@ # Only checks for "new" aspell, > 0.50 AC_DEFUN([CHECK_WITH_ASPELL], [ - lyx_use_aspell=true - AC_ARG_WITH(aspell, AC_HELP_STRING([--with-aspell],[use ASpell libraries])) - test "$with_aspell" = "no" && lyx_use_aspell=false + lyx_use_aspell=true + AC_ARG_WITH(aspell, AC_HELP_STRING([--with-aspell],[use ASpell libraries])) + test "$with_aspell" = "no" && lyx_use_aspell=false - if $lyx_use_aspell ; then - AC_CHECK_HEADERS(aspell.h aspell/aspell.h, - [lyx_use_aspell=true; break;], - [lyx_use_aspell=false]) + if $lyx_use_aspell ; then + AC_CHECK_HEADERS(aspell.h, + [lyx_use_aspell=true; break;], + [lyx_use_aspell=false]) AC_CHECK_LIB(aspell, new_aspell_config, LIBS="-laspell $LIBS", lyx_use_aspell=false) AC_MSG_CHECKING([whether to use aspell]) if $lyx_use_aspell ; then - AC_MSG_RESULT(yes) - AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library]) - lyx_flags="$lyx_flags use-aspell" + AC_MSG_RESULT(yes) + AC_DEFINE(USE_ASPELL, 1, [Define as 1 to use the aspell library]) + lyx_flags="$lyx_flags use-aspell" else - AC_MSG_RESULT(no) + AC_MSG_RESULT(no) fi - fi - ]) + fi + ]) +# Macro to add for using hunspell spellchecker libraries! -*- sh -*- +AC_DEFUN([CHECK_WITH_HUNSPELL], +[ + lyx_use_hunspell=true + AC_ARG_WITH(hunspell, AC_HELP_STRING([--with-hunspell],[use Hunspell libraries])) + test "$with_hunspell" = "no" && lyx_use_hunspell=false -### Check if we want spell libraries, prefer new aspell + if $lyx_use_hunspell ; then + AC_CHECK_HEADERS(hunspell/hunspell.hxx, + [lyx_use_hunspell=true; break;], + [lyx_use_hunspell=false]) + AC_CHECK_LIB(hunspell, main, LIBS="-lhunspell $LIBS", lyx_use_hunspell=false) + + AC_MSG_CHECKING([whether to use hunspell]) + if $lyx_use_hunspell ; then + AC_MSG_RESULT(yes) + AC_DEFINE(USE_HUNSPELL, 1, [Define as 1 to use the hunspell library]) + lyx_flags="$lyx_flags use-hunspell" + else + AC_MSG_RESULT(no) + fi + fi + ]) + +### Check if we want spell libraries, prefer new aspell or hunspell AC_DEFUN([LYX_CHECK_SPELL_ENGINES], [ - lyx_use_aspell=false - CHECK_WITH_ASPELL + lyx_use_aspell=false + CHECK_WITH_ASPELL - AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell) - ]) + AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell) + + lyx_use_hunspell=false + CHECK_WITH_HUNSPELL + + AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell) + ]) diff --git a/src/HunspellSpellChecker.cpp b/src/HunspellSpellChecker.cpp new file mode 100644 index 0000000000..9fb1bd0c94 --- /dev/null +++ b/src/HunspellSpellChecker.cpp @@ -0,0 +1,80 @@ +/** + * \file HunspellSpellChecker.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Abdelrazak Younes + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "HunspellSpellChecker.h" + +#include "LyXRC.h" +#include "WordLangTuple.h" + +#include "support/lassert.h" +#include "support/debug.h" + +#include + +#include +#include + +using namespace std; + +namespace lyx { + +namespace { +typedef map Spellers; +} + +class HunspellSpellChecker::Private +{ + /// the spellers + Spellers spellers_; +}; + + +HunspellSpellChecker::HunspellSpellChecker(): d(new Private) +{ +} + + +HunspellSpellChecker::~HunspellSpellChecker() +{ + delete d; +} + + +SpellChecker::Result HunspellSpellChecker::check(WordLangTuple const & word) +{ + return OK; +} + + +void HunspellSpellChecker::insert(WordLangTuple const & word) +{ +} + + +void HunspellSpellChecker::accept(WordLangTuple const & word) +{ +} + + +docstring const HunspellSpellChecker::nextMiss() +{ + return docstring(); +} + + +docstring const HunspellSpellChecker::error() +{ + return docstring(); +} + + +} // namespace lyx diff --git a/src/HunspellSpellChecker.h b/src/HunspellSpellChecker.h new file mode 100644 index 0000000000..aca9f2dd65 --- /dev/null +++ b/src/HunspellSpellChecker.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +/** + * \file HunspellSpellChecker.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Abdelrazak Younes + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef LYX_HUNSPELL_H +#define LYX_HUNSPELL_H + +#include "SpellChecker.h" + +namespace lyx { + + +class HunspellSpellChecker : public SpellChecker +{ +public: + HunspellSpellChecker(); + ~HunspellSpellChecker(); + + SpellChecker::Result check(WordLangTuple const &); + void insert(WordLangTuple const &); + void accept(WordLangTuple const &); + docstring const nextMiss(); + docstring const error(); + +private: + struct Private; + Private * d; +}; + + +} // namespace lyx + +#endif // LYX_Hunspell_H diff --git a/src/Makefile.am b/src/Makefile.am index 736544e585..f1c9a5cbe4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ EXTRA_DIST = Section.h \ pch.h OTHERLIBS = $(BOOST_LIBS) $(INTLLIBS) $(MYTHES_LIBS) $(AIKSAURUS_LIBS) \ - @LIBS@ $(SOCKET_LIBS) $(LIBSHLWAPI) $(LIBPSAPI) + @LIBS@ $(SOCKET_LIBS) $(LIBSHLWAPI) $(LIBPSAPI) noinst_LIBRARIES = liblyxcore.a bin_PROGRAMS = lyx @@ -36,7 +36,7 @@ lyx_LDADD = \ support/liblyxsupport.a \ $(OTHERLIBS) \ $(QT4_LDFLAGS) \ - $(QT4_LIB) + $(QT4_LIB) if LYX_WIN_RESOURCE .rc.o: @@ -52,6 +52,10 @@ if USE_ASPELL ASPELL = ASpell.cpp ASpell_local.h endif +if USE_HUNSPELL +HUNSPELL = HunspellSpellChecker.cpp HunspellSpellChecker.h +endif + # These four objects are linked as object files as they are not # referenced within the core and therefore are not picked up # by the linker without looping over libs. We do not want that, @@ -65,6 +69,7 @@ lyx_SOURCES = \ Box.h \ Dimension.cpp \ Dimension.h \ + $(HUNSPELL) \ PrinterParams.cpp \ PrinterParams.h \ Thesaurus.cpp \ @@ -457,7 +462,7 @@ HEADERFILESMATHED = \ mathed/ReplaceData.h \ mathed/MathStream.h \ mathed/MathSupport.h \ - mathed/TextPainter.h + mathed/TextPainter.h lyxmathed.cpp: @echo -e '$(SOURCEFILESMATHED:%=\n#include "%")\n' > $@ @@ -471,7 +476,7 @@ liblyxmathed_a_SOURCES = lyxmathed.cpp $(HEADERFILESMATHED) else -liblyxmathed_a_SOURCES = $(SOURCEFILESMATHED) $(HEADERFILESMATHED) +liblyxmathed_a_SOURCES = $(SOURCEFILESMATHED) $(HEADERFILESMATHED) endif