New support files for Hunspell support. Only autotools for now.

Hunspell is not used yet, don't try it.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30527 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-07-12 22:46:01 +00:00
parent 8c2d81bc34
commit 97a33c4f51
4 changed files with 175 additions and 22 deletions

View File

@ -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)
])

View File

@ -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 <config.h>
#include "HunspellSpellChecker.h"
#include "LyXRC.h"
#include "WordLangTuple.h"
#include "support/lassert.h"
#include "support/debug.h"
#include <hunspell/hunspell.hxx>
#include <map>
#include <string>
using namespace std;
namespace lyx {
namespace {
typedef map<std::string, Hunspell *> 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

View File

@ -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

View File

@ -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