Jean-Marc Lasgouttes wrote:
Abdelrazak Younes <you...@lyx.org> writes:
And a patch that actually compiles...

This looks reasonable (although the existing autotools code could use a
cleanup). Do you have problems with it?

Could you send a "diff -wu" version in order to hide spacing changes?

Here it is...

Abdel.

Index: src/HunspellSpellChecker.h
===================================================================
--- src/HunspellSpellChecker.h	(revision 0)
+++ src/HunspellSpellChecker.h	(revision 0)
@@ -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
Index: src/HunspellSpellChecker.cpp
===================================================================
--- src/HunspellSpellChecker.cpp	(revision 0)
+++ src/HunspellSpellChecker.cpp	(revision 0)
@@ -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
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 30424)
+++ src/Makefile.am	(working copy)
@@ -52,6 +52,10 @@
 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 @@
 	Box.h \
 	Dimension.cpp \
 	Dimension.h \
+	$(HUNSPELL) \
 	PrinterParams.cpp \
 	PrinterParams.h \
 	Thesaurus.cpp \
Index: config/spell.m4
===================================================================
--- config/spell.m4	(revision 30424)
+++ config/spell.m4	(working copy)
@@ -23,12 +23,40 @@
     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.hxx 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
 
     AM_CONDITIONAL(USE_ASPELL, $lyx_use_aspell)
+
+	lyx_use_hunspell=false
+	CHECK_WITH_HUNSPELL
+
+	AM_CONDITIONAL(USE_HUNSPELL, $lyx_use_hunspell)
     ])

Reply via email to