From c26bb55c4f6af84b740a9164f28136c8a376f2aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Sun, 26 Sep 2010 12:13:15 +0200
Subject: [PATCH 01/12] rename AspellPlugin classes to SpellPlugin

---
 .../plugins/tools/spellcheck/aspellplugin.cpp      |   20 +++---
 .../plugins/tools/spellcheck/aspellplugin.h        |    6 +-
 .../plugins/tools/spellcheck/aspellpluginbase.ui   |    4 +-
 .../plugins/tools/spellcheck/aspellpluginimpl.cpp  |   60 ++++++++++----------
 .../plugins/tools/spellcheck/aspellpluginimpl.h    |   10 ++--
 5 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
index 37f0c64..2eca171 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
@@ -13,16 +13,16 @@ for which a new license (GPL+exception) is in place.
 // Please don't implement the functionality of your plugin here; do that
 // in aspellpluginimpl.h and aspellpluginimpl.cpp .
 
-AspellPlugin::AspellPlugin() : ScActionPlugin()
+SpellPlugin::SpellPlugin() : ScActionPlugin()
 {
 	// Set action info in languageChange, so we only have to do
 	// it in one place.
 	languageChange();
 }
 
-AspellPlugin::~AspellPlugin() {};
+SpellPlugin::~SpellPlugin() {};
 
-void AspellPlugin::languageChange()
+void SpellPlugin::languageChange()
 {
 	// Note that we leave the unused members unset. They'll be initialised
 	// with their default ctors during construction.
@@ -51,12 +51,12 @@ void AspellPlugin::languageChange()
 	m_actionInfo.enabledOnStartup = false;
 }
 
-const QString AspellPlugin::fullTrName() const
+const QString SpellPlugin::fullTrName() const
 {
 	return QObject::tr("Spell check (aspell)");
 }
 
-const ScActionPlugin::AboutData* AspellPlugin::getAboutData() const
+const ScActionPlugin::AboutData* SpellPlugin::getAboutData() const
 {
 	AboutData* about = new AboutData;
 	Q_CHECK_PTR(about);
@@ -73,15 +73,15 @@ const ScActionPlugin::AboutData* AspellPlugin::getAboutData() const
 	return about;
 }
 
-void AspellPlugin::deleteAboutData(const AboutData* about) const
+void SpellPlugin::deleteAboutData(const AboutData* about) const
 {
 	Q_ASSERT(about);
 	delete about;
 }
 
-bool AspellPlugin::run(ScribusDoc* doc, QString target)
+bool SpellPlugin::run(ScribusDoc* doc, QString target)
 {
-	AspellPluginImpl *myPluginImpl = new AspellPluginImpl( doc );
+	SpellPluginImpl *myPluginImpl = new SpellPluginImpl( doc );
 	Q_CHECK_PTR(myPluginImpl);
 	// The spellcheck is disabled when there are no available
 	// dictionaries.
@@ -107,14 +107,14 @@ int x_aspellplugin_getPluginAPIVersion()
 
 ScPlugin* x_aspellplugin_getPlugin()
 {
-	AspellPlugin* plug = new AspellPlugin();
+	SpellPlugin* plug = new SpellPlugin();
 	Q_CHECK_PTR(plug);
 	return plug;
 }
 
 void x_aspellplugin_freePlugin(ScPlugin* plugin)
 {
-	AspellPlugin* plug = dynamic_cast<AspellPlugin*>(plugin);
+	SpellPlugin* plug = dynamic_cast<SpellPlugin*>(plugin);
 	Q_ASSERT(plug);
 	delete plug;
 }
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
index 55d8cd7..bbfbf7c 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
@@ -14,14 +14,14 @@ for which a new license (GPL+exception) is in place.
 That documentatation is not duplicated here.
 Please don't implement the functionality of your plugin here; do that
 in aspellpluginimpl.h and aspellpluginimpl.cpp. */
-class PLUGIN_API AspellPlugin : public ScActionPlugin
+class PLUGIN_API SpellPlugin : public ScActionPlugin
 {
 	Q_OBJECT
 
 	public:
 		//! \brief Standard plugin implementation
-		AspellPlugin();
-		virtual ~AspellPlugin();
+		SpellPlugin();
+		virtual ~SpellPlugin();
 		//! \brief main method to run the plug
 		virtual bool run(ScribusDoc* doc, QString target = QString::null);
 		virtual const QString fullTrName() const;
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginbase.ui b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginbase.ui
index 91f4ffd..fbe02fb 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginbase.ui
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginbase.ui
@@ -1,6 +1,6 @@
 <ui version="4.0" >
- <class>AspellPluginBase</class>
- <widget class="QDialog" name="AspellPluginBase" >
+ <class>SpellPluginBase</class>
+ <widget class="QDialog" name="SpellPluginBase" >
   <property name="geometry" >
    <rect>
     <x>0</x>
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
index cf1585b..3c83d8c 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
@@ -10,15 +10,15 @@ for which a new license (GPL+exception) is in place.
 #include "util.h"
 #include <QMessageBox>
 
-const char* AspellPluginImpl::kDEF_CONTEXT = "AspellPlugin";
-const QString AspellPluginImpl::kDEF_ASPELL_ENTRY =
+const char* SpellPluginImpl::kDEF_CONTEXT = "AspellPlugin";
+const QString SpellPluginImpl::kDEF_ASPELL_ENTRY =
 	QString( "en" ) + Speller::Aspell::Suggest::kDICT_DELIM +
 	QString( "en" ) + Speller::Aspell::Suggest::kDICT_DELIM +
 	QString( "*" ) + Speller::Aspell::Suggest::kDICT_DELIM +
 	QString( "60" );  // I.e., en/en/*/60 corresponding to default English dictionary
 
 // Initialize members here, if any
-AspellPluginImpl::AspellPluginImpl(ScribusDoc* doc, QWidget* parent) :
+SpellPluginImpl::SpellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 	QDialog( parent ),
 	fdoc( doc ),
 	m_docIsChanged(false),
@@ -79,15 +79,15 @@ AspellPluginImpl::AspellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 	}
 	catch( const std::invalid_argument& err )
 	{
-		QString warn = tr( "aspellplugin (AspellPluginImpl::"
-				   "AspellPluginImpl): Error in aspell "
+		QString warn = tr( "aspellplugin (SpellPluginImpl::"
+				   "SpellPluginImpl): Error in aspell "
 				   "speller configuration." );
 		qWarning( "%s", warn.toUtf8().data() );
 	}
 	catch( const std::runtime_error& err )
 	{
-		QString warn = tr( "aspellplugin (AspellPluginImpl::"
-				   "AspellPluginImpl): Error in creating "
+		QString warn = tr( "aspellplugin (SpellPluginImpl::"
+				   "SpellPluginImpl): Error in creating "
 				   "aspell speller." );
 		qWarning( "%s", warn.toUtf8().data() );
 	}
@@ -95,7 +95,7 @@ AspellPluginImpl::AspellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 	parseSelection();
 }
 //__________________________________________________________________________
-AspellPluginImpl::~AspellPluginImpl()
+SpellPluginImpl::~SpellPluginImpl()
 {
 	// Destructor
 	try
@@ -104,14 +104,14 @@ AspellPluginImpl::~AspellPluginImpl()
 	}
 	catch( const std::runtime_error& err )
 	{
-		qWarning( "aspellplugin (AspellPluginImpl::~AspellPlugin"
+		qWarning( "aspellplugin (SpellPluginImpl::~SpellPlugin"
 			  "Impl): Error in saving aspell word lists." );
 	}
 
 	delete fsuggest;
 }
 //__________________________________________________________________________
-void AspellPluginImpl::activateSpellGUI(bool active)
+void SpellPluginImpl::activateSpellGUI(bool active)
 {
 	// Activates spell-checking GUI elements in spell-checking
 	// tab, i.e., everything except combo box at top
@@ -129,7 +129,7 @@ void AspellPluginImpl::activateSpellGUI(bool active)
 	flistDicts->setEnabled( active );
 }
 //__________________________________________________________________________
-void AspellPluginImpl::nextWord()
+void SpellPluginImpl::nextWord()
 {
 	QChar ch;
 	QString wordBoundaries = QString(" .,:;\"'!?\n");
@@ -164,7 +164,7 @@ void AspellPluginImpl::nextWord()
 	fpos = pa;
 }
 //__________________________________________________________________________
-void AspellPluginImpl::checkText()
+void SpellPluginImpl::checkText()
 {
 	// Called from parseXXX(), after filling in the currently
 	// relevant text into 'fcontent'. Handles spell-checking of
@@ -228,7 +228,7 @@ void AspellPluginImpl::checkText()
 	}
 }
 //__________________________________________________________________________
-void AspellPluginImpl::spellCheckDone()
+void SpellPluginImpl::spellCheckDone()
 {
 	// Called once all words in the current text, i.e., in 'fcontent'
 	// have been spell-checked. Pops up an information dialog.
@@ -250,14 +250,14 @@ void AspellPluginImpl::spellCheckDone()
 	close();
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_fcloseBtn_clicked()
+void SpellPluginImpl::on_fcloseBtn_clicked()
 {
 	// Called when the "Close" button is clicked. Makes any pending
 	// replacements and closes the spell-checking window.
 	spellCheckDone();  // Also closes spell-checking window.
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_fchangeBtn_clicked()
+void SpellPluginImpl::on_fchangeBtn_clicked()
 {
 	// Called when the "Change" button is clicked. Replaces the word
 	// being spell-checked with the current word in text edit box.
@@ -292,7 +292,7 @@ void AspellPluginImpl::on_fchangeBtn_clicked()
 	checkText();
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_fchangeAllBtn_clicked()
+void SpellPluginImpl::on_fchangeAllBtn_clicked()
 {
 	// Called when the "Change All" button is clicked. Replaces all
 	// instances of the word being spell-checked with the current word in
@@ -329,7 +329,7 @@ void AspellPluginImpl::on_fchangeAllBtn_clicked()
 	checkText();
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_fskipBtn_clicked()
+void SpellPluginImpl::on_fskipBtn_clicked()
 {
 	// Called when the "Skip" button is clicked. Skips the word currently
 	// being spell-checked.
@@ -338,7 +338,7 @@ void AspellPluginImpl::on_fskipBtn_clicked()
 	checkText();
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_fskipAllBtn_clicked()
+void SpellPluginImpl::on_fskipAllBtn_clicked()
 {
 	// Called when the "Skip All" button is clicked. Puts the word
 	// currently being spell-checked into the list of words to be ignored
@@ -355,7 +355,7 @@ void AspellPluginImpl::on_fskipAllBtn_clicked()
 	{
 		
 		QString warn =
-		  tr( "AspellPluginImpl::on_fskipAllBtn_clicked(): Unable "
+		  tr( "SpellPluginImpl::on_fskipAllBtn_clicked(): Unable "
 		      "to skip all instances of \"" ) + fcontent +
 		  tr(" by adding it to the session list.");
 		qWarning( "%s", warn.toUtf8().data() );
@@ -365,7 +365,7 @@ void AspellPluginImpl::on_fskipAllBtn_clicked()
 	checkText();
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_faddWordBtn_clicked()
+void SpellPluginImpl::on_faddWordBtn_clicked()
 {
 	// Called when the "Add word" button is clicked. Adds word to personal
 	// word list.
@@ -378,13 +378,13 @@ void AspellPluginImpl::on_faddWordBtn_clicked()
 	catch( const std::runtime_error& err )
 	{
 		QString warn =
-			tr( "AspellPluginImpl::on_faddWordBtn_clicked(): "
+			tr( "SpellPluginImpl::on_faddWordBtn_clicked(): "
 			    "Unable to add word to personal list." );
 		qWarning( "%s", warn.toUtf8().data() );
 	}
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_flistReplacements_itemActivated()
+void SpellPluginImpl::on_flistReplacements_itemActivated()
 {
 	// Called when an item in the list of replacements is
 	// selected. Replaces current word in text edit box with the text
@@ -392,7 +392,7 @@ void AspellPluginImpl::on_flistReplacements_itemActivated()
 	fcurrWord->setText( flistReplacements->currentItem()->text() );
 }
 
-bool AspellPluginImpl::handleSpellConfig(const QString & dictFullName)
+bool SpellPluginImpl::handleSpellConfig(const QString & dictFullName)
 {
 	QString entry(dictFullName);
 	QStringList fields = entry.split( Speller::Aspell::Suggest::kDICT_DELIM );
@@ -412,7 +412,7 @@ bool AspellPluginImpl::handleSpellConfig(const QString & dictFullName)
 	return false;
 }
 //__________________________________________________________________________
-void AspellPluginImpl::on_flistDicts_activated()
+void SpellPluginImpl::on_flistDicts_activated()
 {
 	// Called when an item in the list of available aspell dictionaries is
 	// selected, i.e., by double-clicking, or pressing enter. Resets
@@ -436,7 +436,7 @@ void AspellPluginImpl::on_flistDicts_activated()
 	}
 }
 //__________________________________________________________________________
-void AspellPluginImpl::getPreferences()
+void SpellPluginImpl::getPreferences()
 {
 	// Retrieves user preferences from saved settings. Defaults are
 	// supplied 
@@ -449,7 +449,7 @@ void AspellPluginImpl::getPreferences()
 	fentry = fprefs->get( "entry", "");//kDEF_ASPELL_ENTRY );
 }
 //__________________________________________________________________________
-void AspellPluginImpl::setPreferences(const QString& lang,
+void SpellPluginImpl::setPreferences(const QString& lang,
 				      const QString& jargon,
 				      const QString& encoding,
 				      const QString& entry)
@@ -462,12 +462,12 @@ void AspellPluginImpl::setPreferences(const QString& lang,
 	fprefs->set( "entry", entry );
 }
 //__________________________________________________________________________
-void AspellPluginImpl::languageChange()
+void SpellPluginImpl::languageChange()
 {
-	qWarning( "AspellPluginImpl::languageChange(): Not implemented yet" );
+	qWarning( "SpellPluginImpl::languageChange(): Not implemented yet" );
 }
 //__________________________________________________________________________
-void AspellPluginImpl::parseItem()
+void SpellPluginImpl::parseItem()
 {
 	// Parse text in a frame, and spell-check it.
 	// Process only text frames
@@ -478,7 +478,7 @@ void AspellPluginImpl::parseItem()
 	}
 }
 //__________________________________________________________________________
-void AspellPluginImpl::parseSelection()
+void SpellPluginImpl::parseSelection()
 {
 	fcontent.truncate( 0 );  // Start with empty string
 	uint ndocs = fdoc->m_Selection->count();
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
index 25a76bc..608ec10 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
@@ -27,11 +27,11 @@ for which a new license (GPL+exception) is in place.
 #include "suggest.h"              // For aspell interface class
 
 /*!
-\class AspellPluginImpl
+\class SpellPluginImpl
 \author Gora Mohanty <gora@srijan.in>
-\brief Implementation of plugin. GUI part is derived from AspellPluginBase class, as aspellpluginbase.{cpp,h} get overwritten by uic. Interface to aspell uses Speller::Aspell::Suggest
+\brief Implementation of plugin. GUI part is derived from SpellPluginBase class, as aspellpluginbase.{cpp,h} get overwritten by uic. Interface to aspell uses Speller::Aspell::Suggest
  */
-class AspellPluginImpl : public QDialog, private Ui::AspellPluginBase
+class SpellPluginImpl : public QDialog, private Ui::SpellPluginBase
 {
 	Q_OBJECT
 private:
@@ -170,14 +170,14 @@ public:
 	  \param parent: Parent window that this is a child of.
 	  \retval None
 	*/
-	AspellPluginImpl(ScribusDoc* doc, QWidget* parent=NULL);
+	SpellPluginImpl(ScribusDoc* doc, QWidget* parent=NULL);
 	/*!
 	  \author Gora Mohanty <gora@srijan.in>
 	  \brief Destructor for spell-checking plugin implementation.
 	  \param None
 	  \retval None
 	*/
-	~AspellPluginImpl();
+	~SpellPluginImpl();
 
 	/*! \brief Returns a error message for caller.
 	It should disable the plugin then
-- 
1.7.2.3


From edf091ef8ea95fce9f0c0cb51a5f0bea457f84c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Sun, 26 Sep 2010 12:19:06 +0200
Subject: [PATCH 02/12] rename plugin interface functions

---
 .../plugins/tools/spellcheck/aspellplugin.cpp      |    6 +++---
 .../plugins/tools/spellcheck/aspellplugin.h        |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
index 2eca171..67ed464 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
@@ -100,19 +100,19 @@ bool SpellPlugin::run(ScribusDoc* doc, QString target)
 }
 
 // Low level plugin API
-int x_aspellplugin_getPluginAPIVersion()
+int spellplugin_getPluginAPIVersion()
 {
 	return PLUGIN_API_VERSION;
 }
 
-ScPlugin* x_aspellplugin_getPlugin()
+ScPlugin* spellplugin_getPlugin()
 {
 	SpellPlugin* plug = new SpellPlugin();
 	Q_CHECK_PTR(plug);
 	return plug;
 }
 
-void x_aspellplugin_freePlugin(ScPlugin* plugin)
+void spellplugin_freePlugin(ScPlugin* plugin)
 {
 	SpellPlugin* plug = dynamic_cast<SpellPlugin*>(plugin);
 	Q_ASSERT(plug);
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
index bbfbf7c..b773f81 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.h
@@ -33,8 +33,8 @@ class PLUGIN_API SpellPlugin : public ScActionPlugin
 		// Special features (none)
 };
 
-extern "C" PLUGIN_API int x_aspellplugin_getPluginAPIVersion();
-extern "C" PLUGIN_API ScPlugin* x_aspellplugin_getPlugin();
-extern "C" PLUGIN_API void x_aspellplugin_freePlugin(ScPlugin* plugin);
+extern "C" PLUGIN_API int spellplugin_getPluginAPIVersion();
+extern "C" PLUGIN_API ScPlugin* spellplugin_getPlugin();
+extern "C" PLUGIN_API void spellplugin_freePlugin(ScPlugin* plugin);
 
 #endif
-- 
1.7.2.3


From 8308ee6b2929719268e240ec484d0419f7fb57f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 10:16:28 +0200
Subject: [PATCH 03/12] add cmake module for enchant

---
 Scribus/cmake/modules/FindENCHANT.cmake |   44 +++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
 create mode 100644 Scribus/cmake/modules/FindENCHANT.cmake

diff --git a/Scribus/cmake/modules/FindENCHANT.cmake b/Scribus/cmake/modules/FindENCHANT.cmake
new file mode 100644
index 0000000..0b30f32
--- /dev/null
+++ b/Scribus/cmake/modules/FindENCHANT.cmake
@@ -0,0 +1,44 @@
+# - Try to find the Enchant spell checker
+# Once done this will define
+#
+#  ENCHANT_FOUND - system has ENCHANT
+#  ENCHANT_INCLUDE_DIR - the ENCHANT include directory
+#  ENCHANT_LIBRARIES - Link these to use ENCHANT
+#  ENCHANT_DEFINITIONS - Compiler switches required for using ENCHANT
+
+# Copyright (c) 2006, Zack Rusin, <zack@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+if (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
+
+  # in cache already
+  set(ENCHANT_FOUND TRUE)
+
+else (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
+  if (NOT WIN32)
+    # use pkg-config to get the directories and then use these values
+    # in the FIND_PATH() and FIND_LIBRARY() calls
+    find_package(PkgConfig)
+    pkg_check_modules(PC_ENCHANT enchant)
+    set(ENCHANT_DEFINITIONS ${PC_ENCHANT_CFLAGS_OTHER})
+  endif (NOT WIN32)
+
+  find_path(ENCHANT_INCLUDE_DIR 
+            NAMES enchant++.h
+            HINTS ${PC_ENCHANT_INCLUDEDIR}
+                  ${PC_ENCHANT_INCLUDE_DIRS}
+            PATH_SUFFIXES enchant )
+
+  find_library(ENCHANT_LIBRARIES NAMES enchant
+               HINTS ${PC_ENCHANT_LIBDIR}
+                      ${PC_ENCHANT_LIBRARY_DIRS} )
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(ENCHANT  DEFAULT_MSG  ENCHANT_INCLUDE_DIR ENCHANT_LIBRARIES )
+
+  mark_as_advanced(ENCHANT_INCLUDE_DIR ENCHANT_LIBRARIES)
+
+endif (ENCHANT_INCLUDE_DIR AND ENCHANT_LIBRARIES)
-- 
1.7.2.3


From 78688766344c38ffd1fe09b2532ad659fdaee21a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 10:17:27 +0200
Subject: [PATCH 04/12] add check for enchant

---
 Scribus/CMakeLists.txt |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/Scribus/CMakeLists.txt b/Scribus/CMakeLists.txt
index 2cb5c74..570a038 100644
--- a/Scribus/CMakeLists.txt
+++ b/Scribus/CMakeLists.txt
@@ -657,19 +657,31 @@ ELSE(NOT WIN32)
 ENDIF(NOT WIN32)
 #>>FontConfig
 
-#<<ASPELL for Speelling support
-OPTION(WITH_ASPELL "Enable support for spell checking" ON)
-IF (WITH_ASPELL)
+#<<ENCHANT for Spelling support
+IF (WANT_ENCHANT)
+  SET(ENCHANT_DIR ${CMAKE_MODULE_PATH})
+  FIND_PACKAGE(ENCHANT)
+ELSEIF (WANT_ENCHANT)
+  SET (ENCHANT_FOUND FALSE CACHE TYPE BOOL)
+  SET (HAVE_ENCHANT FALSE CACHE TYPE BOOL)
+ENDIF (WANT_ENCHANT)
+
+IF (ENCHANT_FOUND)
+  MESSAGE("Enchant Found OK")
+  SET(HAVE_ENCHANT 1)
+ELSE(ENCHANT_FOUND)
+  MESSAGE("Enchant or its developer libraries NOT found - Trying aspell instead")
+  #<<ASPELL for Spelling support
   FIND_PACKAGE(ASPELL)
   IF (ASPELL_FOUND)
     MESSAGE("ASpell Found OK")
     SET(HAVE_ASPELL 1)
-  ELSE (ASPELL_FOUND)
+  ELSE(ASPELL_FOUND)
     MESSAGE("ASpell or its developer libraries NOT found - Disabling support for spell checking")
-  ENDIF (ASPELL_FOUND)
-ENDIF (WITH_ASPELL)
-#>>ASPELL for Speelling support
-
+  ENDIF(ASPELL_FOUND)
+  #>>ASPELL for Spelling support
+ENDIF(ENCHANT_FOUND)
+#>>ENCHANT for Spelling support
 
 #<<PoDoFo for AI PDF import
 OPTION(WITH_PODOFO "Enable support for PDF embedded in AI" ON)
-- 
1.7.2.3


From d565ddea6c3f3c5fe9046dad6c1aaad6947be4d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 10:39:52 +0200
Subject: [PATCH 05/12] build the spellcheck plugin when enchant or aspell is found

---
 Scribus/scribus/plugins/tools/CMakeLists.txt |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/CMakeLists.txt b/Scribus/scribus/plugins/tools/CMakeLists.txt
index 16805ec..f82644b 100644
--- a/Scribus/scribus/plugins/tools/CMakeLists.txt
+++ b/Scribus/scribus/plugins/tools/CMakeLists.txt
@@ -6,7 +6,7 @@ ADD_SUBDIRECTORY(pathcut)
 ADD_SUBDIRECTORY(pathfinder)
 ADD_SUBDIRECTORY(pathstroker)
 ADD_SUBDIRECTORY(subdivide)
-if (HAVE_ASPELL)
+if (HAVE_ENCHANT OR HAVE_ASPELL)
   ADD_SUBDIRECTORY(spellcheck)
-endif (HAVE_ASPELL)
+endif (HAVE_ENCHANT OR HAVE_ASPELL)
 ADD_SUBDIRECTORY(transform)
-- 
1.7.2.3


From 7e2474b44c58226600e785a7ab7987830be5984a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 11:24:26 +0200
Subject: [PATCH 06/12] rename variables from ASPELL_PLUGIN* to SPELL_PLUGIN* in CMakeLists.txt

---
 .../plugins/tools/spellcheck/CMakeLists.txt        |   28 ++++++++++----------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
index 90f86a5..118359d 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
+++ b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
@@ -5,18 +5,18 @@ IF (ASPELL_FOUND)
   ${ASPELL_INCLUDE_DIR}
   )
 
-  SET(ASPELL_PLUGIN_UI_SRC
+  SET(SPELL_PLUGIN_UI_SRC
     aspellpluginbase.ui
 #  donedlgbase.ui
   )
 
-  SET(ASPELL_PLUGIN_MOC_CLASSES
+  SET(SPELL_PLUGIN_MOC_CLASSES
     aspellplugin.h
     aspellpluginimpl.h
 #  donedlgimpl.h
   )
 
-  SET(ASPELL_PLUGIN_SOURCES
+  SET(SPELL_PLUGIN_SOURCES
     aspellplugin.cpp
     aspellpluginimpl.cpp
 #  donedlgimpl.cpp
@@ -32,27 +32,27 @@ IF (APPLEBUNDLE)
 # INSTALL(CODE "FILE(MAKE_DIRECTORY ${ENV}${CMAKE_INSTALL_PREFIX}/${ASPELLRELATIVEDICTDIR})")
 ENDIF (APPLEBUNDLE)
 
-  SET(SCRIBUS_ASPELL_PLUGIN "x_aspellplugin")
+  SET(SCRIBUS_SPELL_PLUGIN "spellplugin")
 
-  QT4_WRAP_UI(ASPELL_PLUGIN_UI_SOURCES ${ASPELL_PLUGIN_UI_SRC} )
-  QT4_WRAP_CPP(ASPELL_PLUGIN_MOC_SOURCES ${ASPELL_PLUGIN_MOC_CLASSES})
+  QT4_WRAP_UI(SPELL_PLUGIN_UI_SOURCES ${SPELL_PLUGIN_UI_SRC} )
+  QT4_WRAP_CPP(SPELL_PLUGIN_MOC_SOURCES ${SPELL_PLUGIN_MOC_CLASSES})
 
-  ADD_LIBRARY(${SCRIBUS_ASPELL_PLUGIN} MODULE
-    ${ASPELL_PLUGIN_SOURCES}
-    ${ASPELL_PLUGIN_MOC_SOURCES}
-    ${ASPELL_PLUGIN_UI_SOURCES}
+  ADD_LIBRARY(${SCRIBUS_SPELL_PLUGIN} MODULE
+    ${SPELL_PLUGIN_SOURCES}
+    ${SPELL_PLUGIN_MOC_SOURCES}
+    ${SPELL_PLUGIN_UI_SOURCES}
   )
 
-  TARGET_LINK_LIBRARIES(${SCRIBUS_ASPELL_PLUGIN} ${ASPELL_LIBRARIES} ${PLUGIN_LIBRARIES})
+  TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ASPELL_LIBRARIES} ${PLUGIN_LIBRARIES})
 
-  INSTALL(TARGETS ${SCRIBUS_ASPELL_PLUGIN}
+  INSTALL(TARGETS ${SCRIBUS_SPELL_PLUGIN}
     LIBRARY
     DESTINATION ${PLUGINDIR}
     PERMISSIONS ${PLUGIN_PERMISSIONS}
   )
 
-  ADD_DEPENDENCIES(${SCRIBUS_ASPELL_PLUGIN} ${EXE_NAME})
+  ADD_DEPENDENCIES(${SCRIBUS_SPELL_PLUGIN} ${EXE_NAME})
 
-# SET_TARGET_PROPERTIES(${SCRIBUS_ASPELL_PLUGIN} PROPERTIES VERSION "0.0.1")
+# SET_TARGET_PROPERTIES(${SCRIBUS_SPELL_PLUGIN} PROPERTIES VERSION "0.0.1")
 ENDIF (ASPELL_FOUND)
 
-- 
1.7.2.3


From f7f71f7c027d15bec8d9676ae2464311e9f6bb99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 11:28:22 +0200
Subject: [PATCH 07/12] add enchant support into spellcheck/CMakeLists.txt

The majority of CMakeLists.txt is common to both and it differs only in
the include paths and linked libraries that are specific to each spellchecker..
---
 .../plugins/tools/spellcheck/CMakeLists.txt        |   24 ++++++++++++++++---
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
index 118359d..cd6d442 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
+++ b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
@@ -1,8 +1,6 @@
-IF (ASPELL_FOUND)
   INCLUDE_DIRECTORIES(
   ${CMAKE_SOURCE_DIR}
   ${CMAKE_SOURCE_DIR}/scribus
-  ${ASPELL_INCLUDE_DIR}
   )
 
   SET(SPELL_PLUGIN_UI_SRC
@@ -43,7 +41,7 @@ ENDIF (APPLEBUNDLE)
     ${SPELL_PLUGIN_UI_SOURCES}
   )
 
-  TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ASPELL_LIBRARIES} ${PLUGIN_LIBRARIES})
+  TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${PLUGIN_LIBRARIES})
 
   INSTALL(TARGETS ${SCRIBUS_SPELL_PLUGIN}
     LIBRARY
@@ -54,5 +52,23 @@ ENDIF (APPLEBUNDLE)
   ADD_DEPENDENCIES(${SCRIBUS_SPELL_PLUGIN} ${EXE_NAME})
 
 # SET_TARGET_PROPERTIES(${SCRIBUS_SPELL_PLUGIN} PROPERTIES VERSION "0.0.1")
-ENDIF (ASPELL_FOUND)
 
+IF (ENCHANT_FOUND)
+  INCLUDE_DIRECTORIES(
+  ${ENCHANT_INCLUDE_DIR}
+  )
+
+  TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ENCHANT_LIBRARIES})
+
+  ADD_DEFINITIONS("-DUSE_ENCHANT")
+
+ELSEIF (ASPELL_FOUND)
+  INCLUDE_DIRECTORIES(
+  ${ASPELL_INCLUDE_DIR}
+  )
+
+  TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ASPELL_LIBRARIES})
+
+  ADD_DEFINITIONS("-DUSE_ASPELL")
+
+ENDIF ()
-- 
1.7.2.3


From 071874e70199c22f5a601909780fdedbd9a83ad7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 12:00:51 +0200
Subject: [PATCH 08/12] rename the Aspell namespace to Spell

---
 .../plugins/tools/spellcheck/aspellpluginimpl.cpp  |   26 ++++----
 .../plugins/tools/spellcheck/aspellpluginimpl.h    |    6 +-
 .../scribus/plugins/tools/spellcheck/suggest.cpp   |   74 ++++++++++----------
 Scribus/scribus/plugins/tools/spellcheck/suggest.h |    6 +-
 4 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
index 3c83d8c..1d2cc95 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
@@ -12,9 +12,9 @@ for which a new license (GPL+exception) is in place.
 
 const char* SpellPluginImpl::kDEF_CONTEXT = "AspellPlugin";
 const QString SpellPluginImpl::kDEF_ASPELL_ENTRY =
-	QString( "en" ) + Speller::Aspell::Suggest::kDICT_DELIM +
-	QString( "en" ) + Speller::Aspell::Suggest::kDICT_DELIM +
-	QString( "*" ) + Speller::Aspell::Suggest::kDICT_DELIM +
+	QString( "en" ) + Speller::Spell::Suggest::kDICT_DELIM +
+	QString( "en" ) + Speller::Spell::Suggest::kDICT_DELIM +
+	QString( "*" ) + Speller::Spell::Suggest::kDICT_DELIM +
 	QString( "60" );  // I.e., en/en/*/60 corresponding to default English dictionary
 
 // Initialize members here, if any
@@ -44,7 +44,7 @@ SpellPluginImpl::SpellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 
 		// Create speller, and get list of available aspell
 		// dictionaries.
-		fsuggest = new Speller::Aspell::Suggest( flang.toUtf8().data(), fjargon.toUtf8().data(), fencoding.toUtf8().data() );
+		fsuggest = new Speller::Spell::Suggest( flang.toUtf8().data(), fjargon.toUtf8().data(), fencoding.toUtf8().data() );
 		Q_CHECK_PTR( fsuggest );
 
 		// Get list of available aspell dictionaries
@@ -395,18 +395,18 @@ void SpellPluginImpl::on_flistReplacements_itemActivated()
 bool SpellPluginImpl::handleSpellConfig(const QString & dictFullName)
 {
 	QString entry(dictFullName);
-	QStringList fields = entry.split( Speller::Aspell::Suggest::kDICT_DELIM );
+	QStringList fields = entry.split( Speller::Spell::Suggest::kDICT_DELIM );
 	// Ensure that we have at least the right no.of fields.
 	if( fields.size() == 4 )
 	{
 		QString value =
-		fields[0] + Speller::Aspell::Suggest::kDICT_DELIM +
-		fields[1] + Speller::Aspell::Suggest::kDICT_DELIM +
-		fields[2] + Speller::Aspell::Suggest::kDICT_DELIM +
+		fields[0] + Speller::Spell::Suggest::kDICT_DELIM +
+		fields[1] + Speller::Spell::Suggest::kDICT_DELIM +
+		fields[2] + Speller::Spell::Suggest::kDICT_DELIM +
 		fields[3];
 		fsuggest->resetConfig( fields[1].toAscii().data(), fields[2].toAscii().data() );
 		// FIXME: Handle encodings other than UTF-8.
-		setPreferences( fields[1], fields[2], Speller::Aspell::Suggest::kDEF_ENCODING, value );
+		setPreferences( fields[1], fields[2], Speller::Spell::Suggest::kDEF_ENCODING, value );
 		return true;
 	}
 	return false;
@@ -440,10 +440,10 @@ void SpellPluginImpl::getPreferences()
 {
 	// Retrieves user preferences from saved settings. Defaults are
 	// supplied 
-	flang =	fprefs->get( "lang", Speller::Aspell::Suggest::kDEF_LANG );
-	fjargon = fprefs->get( "jargon", Speller::Aspell::Suggest::kDEF_JARGON );
+	flang =	fprefs->get( "lang", Speller::Spell::Suggest::kDEF_LANG );
+	fjargon = fprefs->get( "jargon", Speller::Spell::Suggest::kDEF_JARGON );
 	// FIXME: Handle encodings other than UTF-8.
-	fencoding = fprefs->get( "encoding", Speller::Aspell::Suggest::kDEF_ENCODING );
+	fencoding = fprefs->get( "encoding", Speller::Spell::Suggest::kDEF_ENCODING );
 	// Don't use kDEF_ASPELL_ENTRY here. It's checked
 	// against system locale later when there is no preferences for it.
 	fentry = fprefs->get( "entry", "");//kDEF_ASPELL_ENTRY );
@@ -456,7 +456,7 @@ void SpellPluginImpl::setPreferences(const QString& lang,
 {
 	// Saves user preferences using Scribus preferences manager.
 	fprefs->set( "lang", lang );
-	QString val = jargon == Speller::Aspell::Suggest::kEMPTY ? "" : jargon;
+	QString val = jargon == Speller::Spell::Suggest::kEMPTY ? "" : jargon;
 	fprefs->set( "jargon", val );
 	fprefs->set( "encoding", encoding );
 	fprefs->set( "entry", entry );
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
index 608ec10..5afa343 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
@@ -29,7 +29,7 @@ for which a new license (GPL+exception) is in place.
 /*!
 \class SpellPluginImpl
 \author Gora Mohanty <gora@srijan.in>
-\brief Implementation of plugin. GUI part is derived from SpellPluginBase class, as aspellpluginbase.{cpp,h} get overwritten by uic. Interface to aspell uses Speller::Aspell::Suggest
+\brief Implementation of plugin. GUI part is derived from SpellPluginBase class, as aspellpluginbase.{cpp,h} get overwritten by uic. Interface to aspell uses Speller::Spell::Suggest
  */
 class SpellPluginImpl : public QDialog, private Ui::SpellPluginBase
 {
@@ -40,7 +40,7 @@ private:
 	/*! Formatted string for aspell dictionary entry: Form of <name>--<lang>--<jargon>--<size> */
 	static const QString kDEF_ASPELL_ENTRY;
 	/*! \brief Aspell interface object. */
-	Speller::Aspell::Suggest* fsuggest;
+	Speller::Spell::Suggest* fsuggest;
 	/*! \brief Scribus preferences object. */
 	PrefsContext* fprefs;
 	/*! \brief Language for aspell dictionary. */
@@ -117,7 +117,7 @@ protected:
 	*/
 	void setPreferences(const QString& lang,
 			    const QString& jargon,
-			    const QString& encoding=Speller::Aspell::Suggest::kDEF_ENCODING,
+			    const QString& encoding=Speller::Spell::Suggest::kDEF_ENCODING,
 			    const QString& entry=kDEF_ASPELL_ENTRY);
 	/*!
 	  \author Gora Mohanty <gora@srijan.in>
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
index d0dd1aa..53273af 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
@@ -11,38 +11,38 @@
 /*!
 \brief Delimiter between different components of formatted strings for aspell dictionary entries.
  */
-const char* Speller::Aspell::Suggest::kDICT_DELIM = "/";
-const char* Speller::Aspell::Suggest::kEMPTY = "*";
-const char* Speller::Aspell::Suggest::kDEF_LANG = "en";
-const char* Speller::Aspell::Suggest::kDEF_JARGON = "";  // I.e., no jargon
-const char* Speller::Aspell::Suggest::kDEF_ENCODING = "utf-8";
+const char* Speller::Spell::Suggest::kDICT_DELIM = "/";
+const char* Speller::Spell::Suggest::kEMPTY = "*";
+const char* Speller::Spell::Suggest::kDEF_LANG = "en";
+const char* Speller::Spell::Suggest::kDEF_JARGON = "";  // I.e., no jargon
+const char* Speller::Spell::Suggest::kDEF_ENCODING = "utf-8";
 
-void Speller::Aspell::Suggest::checkError() throw( std::runtime_error )
+void Speller::Spell::Suggest::checkError() throw( std::runtime_error )
 {
 	if( aspell_speller_error_number( fspeller ) != 0 )
 	{
 		std::string err_msg =
-			std::string( "(Aspell::Speller::Suggest::checkError): "
+			std::string( "(Spell::Speller::Suggest::checkError): "
 				     "aspell speller error " ) +
 			aspell_speller_error_message( fspeller );
 		throw std::runtime_error( err_msg );
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::checkConfigError()
+void Speller::Spell::Suggest::checkConfigError()
 	throw( std::runtime_error )
 {
 	if( aspell_config_error_number( fconfig ) != 0 )
 	{
 		std::string err_msg =
-			std::string( "(Aspell::Speller::Suggest::checkConfig"
+			std::string( "(Spell::Speller::Suggest::checkConfig"
 				     "Error): aspell speller error " ) +
 			aspell_config_error_message( fconfig );
 		throw std::runtime_error( err_msg );
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::init(const std::string& lang,
+void Speller::Spell::Suggest::init(const std::string& lang,
 				    const std::string& jargon,
 				    const std::string& encoding)
 	throw( std::invalid_argument, std::runtime_error )
@@ -67,7 +67,7 @@ void Speller::Aspell::Suggest::init(const std::string& lang,
 	if( aspell_error_number( ret ) != 0 )
 	{
 		delete_aspell_can_have_error( ret );
-		throw std::runtime_error( "(Aspell::Speller::Suggest::init"
+		throw std::runtime_error( "(Spell::Speller::Suggest::init"
 					  "): Error in creating speller." );
 	}
 	else
@@ -77,7 +77,7 @@ void Speller::Aspell::Suggest::init(const std::string& lang,
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::listDicts(std::vector<AspellDictInfo>& vals)
+void Speller::Spell::Suggest::listDicts(std::vector<AspellDictInfo>& vals)
 {
 	AspellDictInfoList* dlist = get_aspell_dict_info_list( fconfig );
 	AspellDictInfoEnumeration* dinfo_enum =
@@ -90,7 +90,7 @@ void Speller::Aspell::Suggest::listDicts(std::vector<AspellDictInfo>& vals)
 	delete_aspell_dict_info_enumeration( dinfo_enum );
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::listDicts(std::vector<std::string>& vals)
+void Speller::Spell::Suggest::listDicts(std::vector<std::string>& vals)
 {
 	std::vector<AspellDictInfo> entries;
 	listDicts( entries );
@@ -108,7 +108,7 @@ void Speller::Aspell::Suggest::listDicts(std::vector<std::string>& vals)
 }
 //__________________________________________________________________________
 void
-Speller::Aspell::Suggest::printWordList(const AspellWordList* wlist,
+Speller::Spell::Suggest::printWordList(const AspellWordList* wlist,
 					char delim)
 	throw( std::invalid_argument )
 {
@@ -129,7 +129,7 @@ Speller::Aspell::Suggest::printWordList(const AspellWordList* wlist,
 	delete_aspell_string_enumeration( enum_list );
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::setConfig() throw( std::invalid_argument )
+void Speller::Spell::Suggest::setConfig() throw( std::invalid_argument )
 {
 	try
 	{
@@ -150,7 +150,7 @@ void Speller::Aspell::Suggest::setConfig() throw( std::invalid_argument )
 }
 //__________________________________________________________________________
 void
-Speller::Aspell::Suggest::storeWordList(const AspellWordList* wlist,
+Speller::Spell::Suggest::storeWordList(const AspellWordList* wlist,
 					std::vector<std::string>& replacement)
 	throw( std::invalid_argument )
 {
@@ -171,7 +171,7 @@ Speller::Aspell::Suggest::storeWordList(const AspellWordList* wlist,
 	delete_aspell_string_enumeration( enum_list );
 }
 //__________________________________________________________________________
-Speller::Aspell::Suggest::Suggest(const std::string& lang,
+Speller::Spell::Suggest::Suggest(const std::string& lang,
 				  const std::string& jargon,
 				  const std::string& encoding)
 	throw( std::invalid_argument, std::runtime_error )
@@ -191,7 +191,7 @@ Speller::Aspell::Suggest::Suggest(const std::string& lang,
 	}
 }
 //__________________________________________________________________________
-Speller::Aspell::Suggest::Suggest(const AspellDictInfo* dinfo,
+Speller::Spell::Suggest::Suggest(const AspellDictInfo* dinfo,
 				  const std::string& encoding)
 	throw( std::invalid_argument, std::runtime_error )
 {
@@ -209,7 +209,7 @@ Speller::Aspell::Suggest::Suggest(const AspellDictInfo* dinfo,
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::addPersonalList(const std::string& word)
+void Speller::Spell::Suggest::addPersonalList(const std::string& word)
 	throw( std::runtime_error )
 {
 	//  A std::runtime_error exception is thrown if
@@ -228,7 +228,7 @@ void Speller::Aspell::Suggest::addPersonalList(const std::string& word)
 	}
 }
 //__________________________________________________________________________
-bool Speller::Aspell::Suggest::checkWord(const std::string& word)
+bool Speller::Spell::Suggest::checkWord(const std::string& word)
 {
 	bool status = true;
 
@@ -239,7 +239,7 @@ bool Speller::Aspell::Suggest::checkWord(const std::string& word)
 	return status;
 }
 //__________________________________________________________________________
-bool Speller::Aspell::Suggest::checkWord(const std::string& word,
+bool Speller::Spell::Suggest::checkWord(const std::string& word,
 					 std::vector<std::string>& replacement,
 					 bool always)
 	throw( std::invalid_argument )
@@ -285,7 +285,7 @@ bool Speller::Aspell::Suggest::checkWord(const std::string& word,
 	return status;
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::clearSessionList() throw( std::runtime_error )
+void Speller::Spell::Suggest::clearSessionList() throw( std::runtime_error )
 {
 	aspell_speller_clear_session( fspeller );
 	try
@@ -298,12 +298,12 @@ void Speller::Aspell::Suggest::clearSessionList() throw( std::runtime_error )
 	}  
 }
 //__________________________________________________________________________
-std::string Speller::Aspell::Suggest::getConfigOpt(const std::string& opt)
+std::string Speller::Spell::Suggest::getConfigOpt(const std::string& opt)
 {
 	return std::string( aspell_config_retrieve( fconfig, opt.c_str() ) );
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::getConfigOpt(const std::string& opt,
+void Speller::Spell::Suggest::getConfigOpt(const std::string& opt,
 					    std::vector<std::string>& vals)
 {
 	// Stores current setting of configuration option, 'opt', which
@@ -323,7 +323,7 @@ void Speller::Aspell::Suggest::getConfigOpt(const std::string& opt,
 	delete_aspell_string_list( list );
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::ignoreWord(const std::string& word)
+void Speller::Spell::Suggest::ignoreWord(const std::string& word)
 	throw( std::runtime_error )
 {
 	// FIXME: Return value should be something meaningful from
@@ -339,7 +339,7 @@ void Speller::Aspell::Suggest::ignoreWord(const std::string& word)
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::printMainList() throw( std::invalid_argument )
+void Speller::Spell::Suggest::printMainList() throw( std::invalid_argument )
 {
 	const AspellWordList* wlist =
 		aspell_speller_main_word_list( fspeller );
@@ -353,7 +353,7 @@ void Speller::Aspell::Suggest::printMainList() throw( std::invalid_argument )
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::printPersonalList()
+void Speller::Spell::Suggest::printPersonalList()
 	throw( std::invalid_argument )
 {
 	const AspellWordList* wlist =
@@ -368,7 +368,7 @@ void Speller::Aspell::Suggest::printPersonalList()
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::printSessionList()
+void Speller::Spell::Suggest::printSessionList()
 	throw( std::invalid_argument )
 {
 	const AspellWordList* wlist =
@@ -383,7 +383,7 @@ void Speller::Aspell::Suggest::printSessionList()
 	}
 }
 //__________________________________________________________________________
-bool Speller::Aspell::Suggest::printSuggestions(const std::string& word,
+bool Speller::Spell::Suggest::printSuggestions(const std::string& word,
 						bool always)
 	throw( std::invalid_argument )
 {
@@ -427,7 +427,7 @@ bool Speller::Aspell::Suggest::printSuggestions(const std::string& word,
 	return status;  
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::resetConfig()
+void Speller::Spell::Suggest::resetConfig()
 	throw( std::invalid_argument, std::runtime_error )
 {
 	delete_aspell_config( fconfig );
@@ -445,7 +445,7 @@ void Speller::Aspell::Suggest::resetConfig()
 	if( aspell_error_number( ret ) != 0 )
 	{
 		delete_aspell_can_have_error( ret );
-		throw std::runtime_error( "(Aspell::Speller::Suggest::Reset"
+		throw std::runtime_error( "(Spell::Speller::Suggest::Reset"
 					  "Config): Error in creating "
 					  "speller." );
 	}
@@ -459,7 +459,7 @@ void Speller::Aspell::Suggest::resetConfig()
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::resetConfig(const std::string& lang,
+void Speller::Spell::Suggest::resetConfig(const std::string& lang,
 					   const std::string& jargon,
 					   const std::string& encoding)
 	throw( std::invalid_argument, std::runtime_error )
@@ -483,7 +483,7 @@ void Speller::Aspell::Suggest::resetConfig(const std::string& lang,
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::saveLists() throw( std::runtime_error )
+void Speller::Spell::Suggest::saveLists() throw( std::runtime_error )
 {
 	// Saves all word lists.
 	aspell_speller_save_all_word_lists( fspeller );
@@ -497,7 +497,7 @@ void Speller::Aspell::Suggest::saveLists() throw( std::runtime_error )
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::setConfigOpt(const std::string& opt,
+void Speller::Spell::Suggest::setConfigOpt(const std::string& opt,
 					    const std::string& val)
 	throw( std::invalid_argument )
 {
@@ -513,7 +513,7 @@ void Speller::Aspell::Suggest::setConfigOpt(const std::string& opt,
 }
 //__________________________________________________________________________
 void
-Speller::Aspell::Suggest::StoreMainList(std::vector<std::string>& replacement)
+Speller::Spell::Suggest::StoreMainList(std::vector<std::string>& replacement)
 	throw( std::invalid_argument )
 {
 	const AspellWordList* wlist =
@@ -528,7 +528,7 @@ Speller::Aspell::Suggest::StoreMainList(std::vector<std::string>& replacement)
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::StorePersonalList(std::vector<std::string>& replacement) throw( std::invalid_argument )
+void Speller::Spell::Suggest::StorePersonalList(std::vector<std::string>& replacement) throw( std::invalid_argument )
 {
 	// Stores personal word list. A std::invalid_argument
 	// exception is thrown in case of error.
@@ -544,7 +544,7 @@ void Speller::Aspell::Suggest::StorePersonalList(std::vector<std::string>& repla
 	}
 }
 //__________________________________________________________________________
-void Speller::Aspell::Suggest::StoreSessionList(std::vector<std::string>& replacement) throw( std::invalid_argument )
+void Speller::Spell::Suggest::StoreSessionList(std::vector<std::string>& replacement) throw( std::invalid_argument )
 {
 	// Stores session word list. A std::invalid_argument exception
 	// is thrown in case of error.
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.h b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
index 6683cfc..2c740cf 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
@@ -21,9 +21,9 @@
 \brief Nested namespaces to allow different interfaces to different spell-checking engines.
  */
 namespace Speller {
-  namespace Aspell {
+  namespace Spell {
 /*!
-\class Speller::Aspell::Suggest
+\class Speller::Spell::Suggest
 \author Gora Mohanty <gora@srijan.in>
 \brief Class for interfacing with aspell. Should work with any aspell version
 from 0.60 onwards
@@ -322,7 +322,7 @@ from 0.60 onwards
 	    void StoreSessionList(std::vector<std::string>& replacement)
 		    throw( std::invalid_argument );
     };  // class Suggest
-  }  // namespace Aspell
+  }  // namespace Spell
 }  // namespace Speller
 #endif  // #ifndef SUGGEST_H
 //@@@@@@@@@@@@@@@@@@@@@@@@@ END OF FILE @@@@@@@@@@@@@@@@@@@@@@@@@
-- 
1.7.2.3


From 03c83f3e3631773db4c7df26bd86cef7ed9a5f04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 27 Sep 2010 13:08:42 +0200
Subject: [PATCH 09/12] use SPELL_CHECKER_STR or "speller" instead of "aspell"

---
 .../plugins/tools/spellcheck/CMakeLists.txt        |    4 +-
 .../plugins/tools/spellcheck/aspellplugin.cpp      |    6 ++--
 .../plugins/tools/spellcheck/aspellpluginimpl.cpp  |   26 ++++++++++----------
 .../scribus/plugins/tools/spellcheck/suggest.cpp   |    4 +-
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
index cd6d442..2e131be 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
+++ b/Scribus/scribus/plugins/tools/spellcheck/CMakeLists.txt
@@ -60,7 +60,7 @@ IF (ENCHANT_FOUND)
 
   TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ENCHANT_LIBRARIES})
 
-  ADD_DEFINITIONS("-DUSE_ENCHANT")
+  ADD_DEFINITIONS("-DUSE_ENCHANT -DSPELL_CHECKER_STR=\\\"enchant\\\"")
 
 ELSEIF (ASPELL_FOUND)
   INCLUDE_DIRECTORIES(
@@ -69,6 +69,6 @@ ELSEIF (ASPELL_FOUND)
 
   TARGET_LINK_LIBRARIES(${SCRIBUS_SPELL_PLUGIN} ${ASPELL_LIBRARIES})
 
-  ADD_DEFINITIONS("-DUSE_ASPELL")
+  ADD_DEFINITIONS("-DUSE_ASPELL -DSPELL_CHECKER_STR=\\\"aspell\\\"")
 
 ENDIF ()
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
index 67ed464..98999a3 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellplugin.cpp
@@ -53,7 +53,7 @@ void SpellPlugin::languageChange()
 
 const QString SpellPlugin::fullTrName() const
 {
-	return QObject::tr("Spell check (aspell)");
+	return QObject::tr("Spell check (" SPELL_CHECKER_STR ")");
 }
 
 const ScActionPlugin::AboutData* SpellPlugin::getAboutData() const
@@ -63,8 +63,8 @@ const ScActionPlugin::AboutData* SpellPlugin::getAboutData() const
 	about->authors = "Gora Mohanty <gora@srijan.in>";
 	about->shortDescription = tr( "Spell-checking support" );
 	about->description =
-	  tr( "Adds support for spell-checking via aspell. Languages "
-	      "can be chosen from among the installed aspell "
+	  tr( "Adds support for spell-checking via " SPELL_CHECKER_STR ". Languages "
+	      "can be chosen from among the installed " SPELL_CHECKER_STR " "
 	      "dictionaries, and spell-checking can be done on the "
 	      "fly, or on selected text." );
 	about->version = tr( "0.1" );
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
index 1d2cc95..03da044 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
@@ -34,20 +34,20 @@ SpellPluginImpl::SpellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 	// Get stored language, jargon, encoding settings
 	fprefs = PrefsManager::instance()->prefsFile->getPluginContext( kDEF_CONTEXT );
 	getPreferences();
-	QString text = tr( "Loaded " ) + (fentry == kDEF_ASPELL_ENTRY ? tr( "default " ) : "") + fentry + tr( " aspell dictionary." );
+	QString text = tr( "Loaded " ) + (fentry == kDEF_ASPELL_ENTRY ? tr( "default " ) : "") + fentry + tr( " " SPELL_CHECKER_STR " dictionary." );
 	doc->scMW()->setStatusBarInfoText( text );
 	try
 	{
-		// Deactivate GUI elements in spell-checking tab until an
-		// aspell dictionary is chosen.
+		// Deactivate GUI elements in speller tab until an
+		// speller dictionary is chosen.
 		activateSpellGUI(false);
 
-		// Create speller, and get list of available aspell
+		// Create speller, and get list of available speller
 		// dictionaries.
 		fsuggest = new Speller::Spell::Suggest( flang.toUtf8().data(), fjargon.toUtf8().data(), fencoding.toUtf8().data() );
 		Q_CHECK_PTR( fsuggest );
 
-		// Get list of available aspell dictionaries
+		// Get list of available speller dictionaries
 		std::vector<std::string> entries;
 		fsuggest->listDicts( entries );
 		for( std::vector<std::string>::const_iterator i = entries.begin(); i != entries.end(); ++i )
@@ -79,16 +79,16 @@ SpellPluginImpl::SpellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 	}
 	catch( const std::invalid_argument& err )
 	{
-		QString warn = tr( "aspellplugin (SpellPluginImpl::"
-				   "SpellPluginImpl): Error in aspell "
+		QString warn = tr( "spellplugin (SpellPluginImpl::"
+				   "SpellPluginImpl): Error in "
 				   "speller configuration." );
 		qWarning( "%s", warn.toUtf8().data() );
 	}
 	catch( const std::runtime_error& err )
 	{
-		QString warn = tr( "aspellplugin (SpellPluginImpl::"
+		QString warn = tr( "spellplugin (SpellPluginImpl::"
 				   "SpellPluginImpl): Error in creating "
-				   "aspell speller." );
+				   "speller." );
 		qWarning( "%s", warn.toUtf8().data() );
 	}
 	activateSpellGUI(true);
@@ -104,8 +104,8 @@ SpellPluginImpl::~SpellPluginImpl()
 	}
 	catch( const std::runtime_error& err )
 	{
-		qWarning( "aspellplugin (SpellPluginImpl::~SpellPlugin"
-			  "Impl): Error in saving aspell word lists." );
+		qWarning( "spellplugin (SpellPluginImpl::~SpellPlugin"
+			  "Impl): Error in saving speller word lists." );
 	}
 
 	delete fsuggest;
@@ -414,9 +414,9 @@ bool SpellPluginImpl::handleSpellConfig(const QString & dictFullName)
 //__________________________________________________________________________
 void SpellPluginImpl::on_flistDicts_activated()
 {
-	// Called when an item in the list of available aspell dictionaries is
+	// Called when an item in the list of available speller dictionaries is
 	// selected, i.e., by double-clicking, or pressing enter. Resets
-	// aspell configuration to use the selected dictionary.
+	// speller configuration to use the selected dictionary.
 	if (handleSpellConfig(flistDicts->currentText()))
 	{
 		// PV - 7523: In the spell checker, the only option to change
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
index 53273af..875f1d0 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
@@ -23,7 +23,7 @@ void Speller::Spell::Suggest::checkError() throw( std::runtime_error )
 	{
 		std::string err_msg =
 			std::string( "(Spell::Speller::Suggest::checkError): "
-				     "aspell speller error " ) +
+				     "speller error " ) +
 			aspell_speller_error_message( fspeller );
 		throw std::runtime_error( err_msg );
 	}
@@ -36,7 +36,7 @@ void Speller::Spell::Suggest::checkConfigError()
 	{
 		std::string err_msg =
 			std::string( "(Spell::Speller::Suggest::checkConfig"
-				     "Error): aspell speller error " ) +
+				     "Error): speller error " ) +
 			aspell_config_error_message( fconfig );
 		throw std::runtime_error( err_msg );
 	}
-- 
1.7.2.3


From fe2be01d79927ed1dc8f4468b93cb4ef6c5b91a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 4 Oct 2010 16:25:25 +0200
Subject: [PATCH 10/12] remove unused getConfigOpt() methods

---
 .../scribus/plugins/tools/spellcheck/suggest.cpp   |   25 --------------------
 Scribus/scribus/plugins/tools/spellcheck/suggest.h |   16 ------------
 2 files changed, 0 insertions(+), 41 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
index 875f1d0..f25919e 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
@@ -298,31 +298,6 @@ void Speller::Spell::Suggest::clearSessionList() throw( std::runtime_error )
 	}  
 }
 //__________________________________________________________________________
-std::string Speller::Spell::Suggest::getConfigOpt(const std::string& opt)
-{
-	return std::string( aspell_config_retrieve( fconfig, opt.c_str() ) );
-}
-//__________________________________________________________________________
-void Speller::Spell::Suggest::getConfigOpt(const std::string& opt,
-					    std::vector<std::string>& vals)
-{
-	// Stores current setting of configuration option, 'opt', which
-	// has a value of list type, in 'vals'.
-	AspellStringList* list = new_aspell_string_list();
-	AspellMutableContainer* lst0 =
-		aspell_string_list_to_mutable_container( list );
-	aspell_config_retrieve_list( fconfig, opt.c_str(), lst0 );
-	AspellStringEnumeration* enum_list =
-		aspell_string_list_elements( list );
-	const char* next;
-	while( (next = aspell_string_enumeration_next( enum_list )) )
-	{
-		vals.push_back( next );
-	}
-	delete_aspell_string_enumeration( enum_list );
-	delete_aspell_string_list( list );
-}
-//__________________________________________________________________________
 void Speller::Spell::Suggest::ignoreWord(const std::string& word)
 	throw( std::runtime_error )
 {
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.h b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
index 2c740cf..46ea987 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
@@ -181,22 +181,6 @@ from 0.60 onwards
 	    void clearSessionList() throw( std::runtime_error );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Gets value of configuration option, 'opt'.
-	      \param opt: Name of option whose setting is to be retrieved.
-	      \retval Value of option setting.
-	    */
-	    std::string getConfigOpt(const std::string& opt);
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Gets value of list type configuration option, 'opt'.
-	      \param opt: Name of option whose setting is to be retrieved.
-	      \param vals: Vector for storing values for the list type object.
-	      \retval None.
-	    */
-	    void getConfigOpt(const std::string& opt,
-			      std::vector<std::string>& vals);
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Ignores 'word' for current session.
 	      \param word: Word to be ignored.
 	      \retval None.
-- 
1.7.2.3


From b20209a292e6ce14e187ba0e560657ee21af4622 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 4 Oct 2010 18:51:07 +0200
Subject: [PATCH 11/12] make some methods private

---
 Scribus/scribus/plugins/tools/spellcheck/suggest.h |  172 ++++++++++----------
 1 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.h b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
index 46ea987..5664e75 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
@@ -82,6 +82,16 @@ from 0.60 onwards
 			       char delim='\n') throw(std::invalid_argument);
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Sets configuration option, 'opt' to value 'val'.
+	      \param opt: Option to be set.
+	      \param val: Value of option to be set.
+	      \retval None
+	      \exception std::invalid_argument if option value is incorrect
+	    */
+	    void setConfigOpt(const std::string& opt, const std::string& val)
+		    throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Sets aspell speller configuration, as per current set of parameters.
 	      \param None 
 	      \retval None
@@ -90,6 +100,16 @@ from 0.60 onwards
 	    void setConfig() throw( std::invalid_argument );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Resets aspell configuration, as per current set of parameters.
+	      \param None
+	      \retval None
+	      \exception std::invalid_argument from setConfig().
+	      \exception std::runtime_error for error in recreating speller.
+	    */
+	    void resetConfig()
+		    throw( std::invalid_argument, std::runtime_error );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Stores list of words in 'replacement'.
 	      \param wlist: Pointer to start of word list.
 	      \param replacement: Vector to hold suggested replacement words.
@@ -99,6 +119,72 @@ from 0.60 onwards
 	    void storeWordList(const AspellWordList* wlist,
 			       std::vector<std::string>& replacement)
 		    throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Obtains list of available aspell dictionaries.
+	      \param vals: Array of aspell dictionary info structs
+	      \retval None
+	    */
+	    void listDicts(std::vector<AspellDictInfo>& vals);
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Clears the current session word list.
+	      \param None
+	      \retval None
+	      \exception std::runtime_error for error in clearing list.
+	    */
+	    void clearSessionList() throw( std::runtime_error );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Prints main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from printWordList().
+	    */
+	    void printMainList() throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Prints personal word list.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from printWordList().
+	    */
+	    void printPersonalList() throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Prints session word list.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from printWordList().
+	    */
+	    void printSessionList() throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Stores main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from storeWordList().
+	    */
+	    void StoreMainList(std::vector<std::string>& replacement)
+		    throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Stores personal word list.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from storeWordList().
+	    */
+	    void StorePersonalList(std::vector<std::string>& replacement)
+		    throw( std::invalid_argument );
+	    /*!
+	      \author Gora Mohanty <gora@srijan.in>
+	      \brief Stores session word list.
+	      \param None
+	      \retval None.
+	      \exception std::invalid_argument from storeWordList().
+	    */
+	    void StoreSessionList(std::vector<std::string>& replacement)
+		    throw( std::invalid_argument );
 
     public:
 	    /*!
@@ -173,14 +259,6 @@ from 0.60 onwards
 			   bool always=true) throw( std::invalid_argument );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Clears the current session word list.
-	      \param None
-	      \retval None
-	      \exception std::runtime_error for error in clearing list.
-	    */
-	    void clearSessionList() throw( std::runtime_error );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Ignores 'word' for current session.
 	      \param word: Word to be ignored.
 	      \retval None.
@@ -191,43 +269,12 @@ from 0.60 onwards
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Obtains list of available aspell dictionaries.
-	      \param vals: Array of aspell dictionary info structs
-	      \retval None
-	    */
-	    void listDicts(std::vector<AspellDictInfo>& vals);
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Obtains list of available aspell dictionaries.
 	      \param vals: Array of formatted strings for aspell dictionary entries. Each has format <name>--<lang>--<jargon>--<size>
 	      \retval None
 	    */
 	    void listDicts(std::vector<std::string>& vals);
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Prints main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from printWordList().
-	    */
-	    void printMainList() throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Prints personal word list.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from printWordList().
-	    */
-	    void printPersonalList() throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Prints session word list.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from printWordList().
-	    */
-	    void printSessionList() throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Spell-checks word, and prints suggested replacements.
 	      \param word: Word to be checked.
 	      \param always: If true, replacements are always printed, else only if word is mis-spelt.
@@ -238,16 +285,6 @@ from 0.60 onwards
 		    throw( std::invalid_argument );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Resets aspell configuration, as per current set of parameters.
-	      \param None
-	      \retval None
-	      \exception std::invalid_argument from setConfig().
-	      \exception std::runtime_error for error in recreating speller.
-	    */
-	    void resetConfig()
-		    throw( std::invalid_argument, std::runtime_error );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Resets aspell configuration, as per current set of parameters, after resetting lang, jargon, and encoding.
 	      \param lang: Language of aspell dictionary.
 	      \param jargon: Jargon for aspell dictionary.
@@ -268,43 +305,6 @@ from 0.60 onwards
 	      \exception std::runtime_error for error in saving lists.
 	    */
 	    void saveLists() throw( std::runtime_error );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Sets configuration option, 'opt' to value 'val'.
-	      \param opt: Option to be set.
-	      \param val: Value of option to be set.
-	      \retval None
-	      \exception std::invalid_argument if option value is incorrect
-	    */
-	    void setConfigOpt(const std::string& opt, const std::string& val)
-		    throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Stores main word list. WARNING: This causes a crash due to a bug in aspell, as of aspell version 0.60.3.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from storeWordList().
-	    */
-	    void StoreMainList(std::vector<std::string>& replacement)
-		    throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Stores personal word list.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from storeWordList().
-	    */
-	    void StorePersonalList(std::vector<std::string>& replacement)
-		    throw( std::invalid_argument );
-	    /*!
-	      \author Gora Mohanty <gora@srijan.in>
-	      \brief Stores session word list.
-	      \param None
-	      \retval None.
-	      \exception std::invalid_argument from storeWordList().
-	    */
-	    void StoreSessionList(std::vector<std::string>& replacement)
-		    throw( std::invalid_argument );
     };  // class Suggest
   }  // namespace Spell
 }  // namespace Speller
-- 
1.7.2.3


From d0a145ebd58ef42692582c215a028c538c19160b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 4 Oct 2010 23:50:19 +0200
Subject: [PATCH 12/12] add enchant support to the spellcheck plugin

---
 .../plugins/tools/spellcheck/aspellpluginimpl.cpp  |   31 +++-
 .../plugins/tools/spellcheck/aspellpluginimpl.h    |   11 +-
 .../scribus/plugins/tools/spellcheck/suggest.cpp   |  169 ++++++++++++++------
 Scribus/scribus/plugins/tools/spellcheck/suggest.h |   60 ++++++-
 4 files changed, 206 insertions(+), 65 deletions(-)

diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
index 03da044..570f175 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.cpp
@@ -44,7 +44,11 @@ SpellPluginImpl::SpellPluginImpl(ScribusDoc* doc, QWidget* parent) :
 
 		// Create speller, and get list of available speller
 		// dictionaries.
-		fsuggest = new Speller::Spell::Suggest( flang.toUtf8().data(), fjargon.toUtf8().data(), fencoding.toUtf8().data() );
+		fsuggest = new Speller::Spell::Suggest( flang.toUtf8().data()
+#if defined(USE_ASPELL)
+			, fjargon.toUtf8().data(), fencoding.toUtf8().data()
+#endif
+		);
 		Q_CHECK_PTR( fsuggest );
 
 		// Get list of available speller dictionaries
@@ -396,6 +400,15 @@ bool SpellPluginImpl::handleSpellConfig(const QString & dictFullName)
 {
 	QString entry(dictFullName);
 	QStringList fields = entry.split( Speller::Spell::Suggest::kDICT_DELIM );
+#if defined(USE_ENCHANT)
+	// Ensure that we have sufficient fields.
+	if( fields.size() > 2 )
+	{
+		fsuggest->resetConfig( fields[1].toAscii().data() );
+		setPreferences( fields[1] );
+		return true;
+	}
+#elif defined(USE_ASPELL)
 	// Ensure that we have at least the right no.of fields.
 	if( fields.size() == 4 )
 	{
@@ -409,6 +422,7 @@ bool SpellPluginImpl::handleSpellConfig(const QString & dictFullName)
 		setPreferences( fields[1], fields[2], Speller::Spell::Suggest::kDEF_ENCODING, value );
 		return true;
 	}
+#endif
 	return false;
 }
 //__________________________________________________________________________
@@ -441,25 +455,32 @@ void SpellPluginImpl::getPreferences()
 	// Retrieves user preferences from saved settings. Defaults are
 	// supplied 
 	flang =	fprefs->get( "lang", Speller::Spell::Suggest::kDEF_LANG );
+#if defined(USE_ASPELL)
 	fjargon = fprefs->get( "jargon", Speller::Spell::Suggest::kDEF_JARGON );
 	// FIXME: Handle encodings other than UTF-8.
 	fencoding = fprefs->get( "encoding", Speller::Spell::Suggest::kDEF_ENCODING );
 	// Don't use kDEF_ASPELL_ENTRY here. It's checked
 	// against system locale later when there is no preferences for it.
 	fentry = fprefs->get( "entry", "");//kDEF_ASPELL_ENTRY );
+#endif
 }
 //__________________________________________________________________________
-void SpellPluginImpl::setPreferences(const QString& lang,
-				      const QString& jargon,
-				      const QString& encoding,
-				      const QString& entry)
+void SpellPluginImpl::setPreferences(const QString& lang
+#if defined(USE_ASPELL)
+				      , const QString& jargon
+				      , const QString& encoding
+				      , const QString& entry
+#endif
+)
 {
 	// Saves user preferences using Scribus preferences manager.
 	fprefs->set( "lang", lang );
+#if defined(USE_ASPELL)
 	QString val = jargon == Speller::Spell::Suggest::kEMPTY ? "" : jargon;
 	fprefs->set( "jargon", val );
 	fprefs->set( "encoding", encoding );
 	fprefs->set( "entry", entry );
+#endif
 }
 //__________________________________________________________________________
 void SpellPluginImpl::languageChange()
diff --git a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
index 5afa343..e0017a3 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/aspellpluginimpl.h
@@ -115,10 +115,13 @@ protected:
 	  \param encoding: Encoding for aspell dictionary
 	  \retval None
 	*/
-	void setPreferences(const QString& lang,
-			    const QString& jargon,
-			    const QString& encoding=Speller::Spell::Suggest::kDEF_ENCODING,
-			    const QString& entry=kDEF_ASPELL_ENTRY);
+	void setPreferences(const QString& lang
+#if defined(USE_ASPELL)
+			    , const QString& jargon
+			    , const QString& encoding=Speller::Spell::Suggest::kDEF_ENCODING
+			    , const QString& entry=kDEF_ASPELL_ENTRY
+#endif
+	);
 	/*!
 	  \author Gora Mohanty <gora@srijan.in>
 	  \brief Retrieve saved user preferences: language, jargon, encoding.
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
index f25919e..74a0282 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.cpp
@@ -8,15 +8,24 @@
 #include "suggest.h"
 #include "scpaths.h"
 #include <QFileInfo>
+#include <algorithm>
+#if defined(USE_ENCHANT)
+#include <enchant++.h>
+#endif
 /*!
 \brief Delimiter between different components of formatted strings for aspell dictionary entries.
  */
 const char* Speller::Spell::Suggest::kDICT_DELIM = "/";
 const char* Speller::Spell::Suggest::kEMPTY = "*";
+#if defined(USE_ENCHANT)
+const char* Speller::Spell::Suggest::kDEF_LANG = "en_US";
+#elif defined(USE_ASPELL)
 const char* Speller::Spell::Suggest::kDEF_LANG = "en";
 const char* Speller::Spell::Suggest::kDEF_JARGON = "";  // I.e., no jargon
 const char* Speller::Spell::Suggest::kDEF_ENCODING = "utf-8";
+#endif
 
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::checkError() throw( std::runtime_error )
 {
 	if( aspell_speller_error_number( fspeller ) != 0 )
@@ -41,14 +50,21 @@ void Speller::Spell::Suggest::checkConfigError()
 		throw std::runtime_error( err_msg );
 	}
 }
+#endif
 //__________________________________________________________________________
-void Speller::Spell::Suggest::init(const std::string& lang,
-				    const std::string& jargon,
-				    const std::string& encoding)
+void Speller::Spell::Suggest::init(const std::string& lang
+#if defined(USE_ASPELL)
+				    , const std::string& jargon
+				    , const std::string& encoding
+#endif
+	)
 	throw( std::invalid_argument, std::runtime_error )
 {
 	// Save aspell configuration values
 	flang = lang;
+#if defined(USE_ENCHANT)
+
+#elif defined(USE_ASPELL)
 	fjargon = jargon;
 	fencoding = encoding;
 
@@ -75,8 +91,10 @@ void Speller::Spell::Suggest::init(const std::string& lang,
 		fspeller = to_aspell_speller( ret );
 		fconfig = aspell_speller_config( fspeller );
 	}
+#endif
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::listDicts(std::vector<AspellDictInfo>& vals)
 {
 	AspellDictInfoList* dlist = get_aspell_dict_info_list( fconfig );
@@ -89,9 +107,27 @@ void Speller::Spell::Suggest::listDicts(std::vector<AspellDictInfo>& vals)
 	}
 	delete_aspell_dict_info_enumeration( dinfo_enum );
 }
+#endif
+
+#if defined(USE_ENCHANT)
+void EnchantDictDescribe(const char * const lang_tag,
+	const char * const ,
+	const char * const ,
+	const char * const ,
+	void * user_data)
+{
+	std::vector<std::string> *detected = (std::vector<std::string>*)user_data;
+	detected->push_back(std::string(lang_tag));
+}
+#endif
+
 //__________________________________________________________________________
 void Speller::Spell::Suggest::listDicts(std::vector<std::string>& vals)
 {
+#if defined(USE_ENCHANT)
+	enchant::Broker::instance()->list_dicts(EnchantDictDescribe, &vals);
+	std::sort(vals.begin(), vals.end());
+#elif defined(USE_ASPELL)
 	std::vector<AspellDictInfo> entries;
 	listDicts( entries );
 	for( std::vector<AspellDictInfo>::const_iterator i = entries.begin();
@@ -105,13 +141,24 @@ void Speller::Spell::Suggest::listDicts(std::vector<std::string>& vals)
 			  << i->size;
                 vals.push_back( fmt_entry.str() );
         }
+#endif
 }
 //__________________________________________________________________________
 void
-Speller::Spell::Suggest::printWordList(const AspellWordList* wlist,
+Speller::Spell::Suggest::printWordList(
+#if defined(USE_ENCHANT)
+					const std::vector<std::string> & wlist,
+#elif defined(USE_ASPELL)
+					const AspellWordList* wlist,
+#endif
 					char delim)
 	throw( std::invalid_argument )
 {
+#if defined(USE_ENCHANT)
+	std::vector<std::string>::const_iterator aEnd = wlist.end();
+	for (std::vector<std::string>::const_iterator aI = wlist.begin(); aI != aEnd; ++aI)
+		std::cout << *aI << delim;
+#elif defined(USE_ASPELL)
 	if( ! wlist )
 	{
 		throw std::invalid_argument( "(Aspell.Speller.Suggest.print"
@@ -127,8 +174,10 @@ Speller::Spell::Suggest::printWordList(const AspellWordList* wlist,
 		std::cout << next << delim;
 	}
 	delete_aspell_string_enumeration( enum_list );
+#endif
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::setConfig() throw( std::invalid_argument )
 {
 	try
@@ -170,16 +219,24 @@ Speller::Spell::Suggest::storeWordList(const AspellWordList* wlist,
 	}
 	delete_aspell_string_enumeration( enum_list );
 }
+#endif
 //__________________________________________________________________________
-Speller::Spell::Suggest::Suggest(const std::string& lang,
-				  const std::string& jargon,
-				  const std::string& encoding)
+Speller::Spell::Suggest::Suggest(const std::string& lang
+#if defined(USE_ASPELL)
+				  , const std::string& jargon
+				  , const std::string& encoding
+#endif
+	)
 	throw( std::invalid_argument, std::runtime_error )
 {
 	// Default constructor
 	try
 	{
-		init( lang, jargon, encoding );
+		init( lang
+#if defined(USE_ASPELL)
+		    , jargon, encoding
+#endif
+		);
 	}
 	catch( const std::invalid_argument& err )
 	{
@@ -191,6 +248,7 @@ Speller::Spell::Suggest::Suggest(const std::string& lang,
 	}
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 Speller::Spell::Suggest::Suggest(const AspellDictInfo* dinfo,
 				  const std::string& encoding)
 	throw( std::invalid_argument, std::runtime_error )
@@ -208,10 +266,22 @@ Speller::Spell::Suggest::Suggest(const AspellDictInfo* dinfo,
 		throw err;
 	}
 }
+#endif
+
+Speller::Spell::Suggest::~Suggest()
+{
+#if defined(USE_ENCHANT)
+	delete fspeller;
+#endif
+}
 //__________________________________________________________________________
 void Speller::Spell::Suggest::addPersonalList(const std::string& word)
 	throw( std::runtime_error )
 {
+#if defined(USE_ENCHANT)
+	if (fspeller)
+		fspeller->add(word);
+#elif defined(USE_APELL)
 	//  A std::runtime_error exception is thrown if
 	// an error occcurs.
 
@@ -226,16 +296,22 @@ void Speller::Spell::Suggest::addPersonalList(const std::string& word)
 	{
 		throw err;
 	}
+#endif
 }
 //__________________________________________________________________________
 bool Speller::Spell::Suggest::checkWord(const std::string& word)
 {
 	bool status = true;
 
+#if defined(USE_ENCHANT)
+	if (fspeller)
+		status = fspeller->check(word);
+#elif defined(USE_ASPELL)
 	if( aspell_speller_check( fspeller, word.c_str(), -1 ) == 0 )
 	{
 		status = false;
 	}
+#endif
 	return status;
 }
 //__________________________________________________________________________
@@ -252,8 +328,12 @@ bool Speller::Spell::Suggest::checkWord(const std::string& word,
 	// 'word'is spelt incorrectly.
 	bool status = checkWord( word );
 
-	if( always )
+	if( !status || always )
 	{
+#if defined(USE_ENCHANT)
+		if (fspeller)
+			fspeller->suggest(word, replacement);
+#elif defined(USE_ASPELL)
 		const AspellWordList* wlist =
 			aspell_speller_suggest( fspeller, word.c_str(), -1 );
 		try
@@ -264,27 +344,12 @@ bool Speller::Spell::Suggest::checkWord(const std::string& word,
 		{
 			throw err;
 		}
-	}
-	else
-	{
-		if( ! status )
-		{
-			const AspellWordList* wlist =
-				aspell_speller_suggest( fspeller, word.c_str(),
-							-1 );
-			try
-			{
-				storeWordList( wlist, replacement );
-			}
-			catch( const std::invalid_argument& err )
-			{
-				throw err;
-			}
-		}
+#endif
 	}
 	return status;
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::clearSessionList() throw( std::runtime_error )
 {
 	aspell_speller_clear_session( fspeller );
@@ -297,10 +362,15 @@ void Speller::Spell::Suggest::clearSessionList() throw( std::runtime_error )
 		throw err;
 	}  
 }
+#endif
 //__________________________________________________________________________
 void Speller::Spell::Suggest::ignoreWord(const std::string& word)
 	throw( std::runtime_error )
 {
+#if defined(USE_ENCHANT)
+	if (fspeller)
+		fspeller->add_to_session(word);
+#elif defined(USE_ASPELL)
 	// FIXME: Return value should be something meaningful from
 	// aspell_speller_add_to_session.
 	aspell_speller_add_to_session( fspeller, word.c_str(), -1 );
@@ -312,8 +382,10 @@ void Speller::Spell::Suggest::ignoreWord(const std::string& word)
 	{
 		throw err;
 	}
+#endif
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::printMainList() throw( std::invalid_argument )
 {
 	const AspellWordList* wlist =
@@ -357,6 +429,7 @@ void Speller::Spell::Suggest::printSessionList()
 		throw err;
 	}
 }
+#endif
 //__________________________________________________________________________
 bool Speller::Spell::Suggest::printSuggestions(const std::string& word,
 						bool always)
@@ -369,8 +442,12 @@ bool Speller::Spell::Suggest::printSuggestions(const std::string& word,
 	// false, only prints the list if 'word' is incorrect.
 	bool status = checkWord( word );
 
-	if( always )
+	if( !status || always )
 	{
+#if defined(USE_ENCHANT)
+		if (fspeller)
+			printWordList( fspeller->suggest(word) );
+#elif defined(USE_ASPELL)
 		const AspellWordList* wlist =
 			aspell_speller_suggest( fspeller, word.c_str(), -1 );
 		try
@@ -381,23 +458,7 @@ bool Speller::Spell::Suggest::printSuggestions(const std::string& word,
 		{
 			throw err;
 		}
-	}
-	else
-	{
-		if( ! status )
-		{
-			const AspellWordList* wlist =
-				aspell_speller_suggest( fspeller, word.c_str(),
-							-1 );
-			try
-			{
-				printWordList( wlist );
-			}
-			catch( const std::invalid_argument& err )
-			{
-				throw err;
-			}
-		}
+#endif
 	}
 	return status;  
 }
@@ -405,6 +466,10 @@ bool Speller::Spell::Suggest::printSuggestions(const std::string& word,
 void Speller::Spell::Suggest::resetConfig()
 	throw( std::invalid_argument, std::runtime_error )
 {
+#if defined(USE_ENCHANT)
+	delete fspeller;
+	fspeller = enchant::Broker::instance()->request_dict(flang);
+#elif defined(USE_ASPELL)
 	delete_aspell_config( fconfig );
 	fconfig = new_aspell_config();
 	try
@@ -432,17 +497,23 @@ void Speller::Spell::Suggest::resetConfig()
 		delete_aspell_config( fconfig );
 		fconfig = aspell_speller_config( fspeller );
 	}
+#endif
 }
 //__________________________________________________________________________
-void Speller::Spell::Suggest::resetConfig(const std::string& lang,
-					   const std::string& jargon,
-					   const std::string& encoding)
+void Speller::Spell::Suggest::resetConfig(const std::string& lang
+#if defined(USE_ASPELL)
+					   , const std::string& jargon
+					   , const std::string& encoding
+#endif
+	)
 	throw( std::invalid_argument, std::runtime_error )
 {
 	// Save new aspell configuration values
 	flang = lang;
+#if defined(USE_ASPELL)
 	fjargon = jargon;
 	fencoding = encoding;
+#endif
 
 	try
 	{
@@ -460,6 +531,7 @@ void Speller::Spell::Suggest::resetConfig(const std::string& lang,
 //__________________________________________________________________________
 void Speller::Spell::Suggest::saveLists() throw( std::runtime_error )
 {
+#if defined(USE_ASPELL)
 	// Saves all word lists.
 	aspell_speller_save_all_word_lists( fspeller );
 	try
@@ -470,8 +542,10 @@ void Speller::Spell::Suggest::saveLists() throw( std::runtime_error )
 	{
 		throw err;
 	}
+#endif
 }
 //__________________________________________________________________________
+#if defined(USE_ASPELL)
 void Speller::Spell::Suggest::setConfigOpt(const std::string& opt,
 					    const std::string& val)
 	throw( std::invalid_argument )
@@ -534,5 +608,6 @@ void Speller::Spell::Suggest::StoreSessionList(std::vector<std::string>& replace
 		throw err;
 	}
 }
+#endif
 //__________________________________________________________________________
 //@@@@@@@@@@@@@@@@@@@@@@@@@ END OF FILE @@@@@@@@@@@@@@@@@@@@@@@@@
diff --git a/Scribus/scribus/plugins/tools/spellcheck/suggest.h b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
index 5664e75..7e25b1e 100644
--- a/Scribus/scribus/plugins/tools/spellcheck/suggest.h
+++ b/Scribus/scribus/plugins/tools/spellcheck/suggest.h
@@ -14,8 +14,15 @@
 #include <string>             // Used in function arguments, errors 
 #include <vector>             // Used in function arguments
 #include <iostream>           // Printing to std::cout
+#if defined(USE_ENCHANT)
+// enchant definitions
+namespace enchant {
+    class Dict;
+}
+#elif defined(USE_ASPELL)
 // aspell include files
 #include <aspell.h>
+#endif
 
 /*!
 \brief Nested namespaces to allow different interfaces to different spell-checking engines.
@@ -30,6 +37,12 @@ from 0.60 onwards
  */
     class Suggest {
     private:
+#if defined(USE_ENCHANT)
+	    /*! \brief Enchant speller object. */
+	    enchant::Dict* fspeller;
+	    /*! \brief Language for aspell dictionary. */
+	    std::string    flang;
+#elif defined(USE_ASPELL)
 	    /*! \brief Aspell configuration object. */
 	    AspellConfig*  fconfig;
 	    /*! \brief Aspell speller object. */
@@ -40,7 +53,9 @@ from 0.60 onwards
             std::string    fjargon;
 	    /*! \brief Character encoding for words. */
 	    std::string    fencoding;
+#endif
 
+#if defined(USE_ASPELL)
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Checks aspell speller for an error condition.
@@ -57,6 +72,7 @@ from 0.60 onwards
 	      \exception std::runtime_error if an error condition exists
 	    */
 	    void checkConfigError() throw( std::runtime_error );
+#endif
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Initializes aspell: called from constructors.
@@ -67,8 +83,12 @@ from 0.60 onwards
 	      \exception std::invalid_argument from setConfig().
 	      \exception std::runtime_error for error in creating speller.
 	    */
-	    void init(const std::string& lang, const std::string& jargon,
-		    const std::string& encoding)
+	    void init(const std::string& lang
+#if defined(USE_ASPELL)
+		    , const std::string& jargon
+		    , const std::string& encoding
+#endif
+		    )
 		    throw( std::invalid_argument, std::runtime_error );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
@@ -78,8 +98,14 @@ from 0.60 onwards
 	      \retval None
 	      \exception std::invalid_argument if 'wlist' is null
 	    */
-	    void printWordList(const AspellWordList* wlist,
+	    void printWordList(
+#if defined(USE_ENCHANT)
+			       const std::vector<std::string> & wlist,
+#elif defined(USE_ASPELL)
+			       const AspellWordList* wlist,
+#endif
 			       char delim='\n') throw(std::invalid_argument);
+#if defined(USE_ASPELL)
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Sets configuration option, 'opt' to value 'val'.
@@ -90,6 +116,7 @@ from 0.60 onwards
 	    */
 	    void setConfigOpt(const std::string& opt, const std::string& val)
 		    throw( std::invalid_argument );
+#endif
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Sets aspell speller configuration, as per current set of parameters.
@@ -116,6 +143,7 @@ from 0.60 onwards
 	      \retval None
 	      \exception std::invalid_argument if 'wlist' is null
 	    */
+#if defined(USE_ASPELL)
 	    void storeWordList(const AspellWordList* wlist,
 			       std::vector<std::string>& replacement)
 		    throw( std::invalid_argument );
@@ -185,6 +213,7 @@ from 0.60 onwards
 	    */
 	    void StoreSessionList(std::vector<std::string>& replacement)
 		    throw( std::invalid_argument );
+#endif
 
     public:
 	    /*!
@@ -197,10 +226,12 @@ from 0.60 onwards
 	    static const char* kEMPTY;
 	    /*! \brief Default language for aspell dictionary. */
 	    static const char* kDEF_LANG;
+#if defined(USE_ASPELL)
 	    /*! \brief Default jargon for aspell dictionary. */
 	    static const char* kDEF_JARGON;
 	    /*! \brief Default character encoding for words. */
 	    static const char* kDEF_ENCODING;
+#endif
 
 	    // Defaults are for standard aspell English dictionary. Use
 	    // "iso8859-1" for Basic Latin. See aspell lang.dat file for
@@ -215,10 +246,14 @@ from 0.60 onwards
 	      \exception std::invalid_argument from setConfig().
 	      \exception std::runtime_error for error in creating speller.
 	    */
-	    Suggest(const std::string& lang=kDEF_LANG,
-		    const std::string& jargon=kDEF_JARGON,
-		    const std::string& encoding=kDEF_ENCODING)
+	    Suggest(const std::string& lang=kDEF_LANG
+#if defined(USE_ASPELL)
+		    , const std::string& jargon=kDEF_JARGON
+		    , const std::string& encoding=kDEF_ENCODING
+#endif
+		    )
 		    throw( std::invalid_argument, std::runtime_error );
+#if defined(USE_ASPELL)
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Constructor for spell-checking class.
@@ -231,6 +266,10 @@ from 0.60 onwards
 	    Suggest(const AspellDictInfo* dinfo,
 		    const std::string& encoding=kDEF_ENCODING)
 		    throw( std::invalid_argument, std::runtime_error );
+#endif
+
+	    ~Suggest();
+
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
 	      \brief Adds 'word' to personal list.
@@ -293,9 +332,12 @@ from 0.60 onwards
 	      \exception std::invalid_argument from setConfig().
 	      \exception std::runtime_error for error in recreating speller.
 	    */
-	    void resetConfig(const std::string& lang,
-			     const std::string& jargon,
-			     const std::string& encoding=kDEF_ENCODING)
+	    void resetConfig(const std::string& lang
+#if defined(USE_ASPELL)
+			     , const std::string& jargon
+			     , const std::string& encoding=kDEF_ENCODING
+#endif
+		    )
 		    throw( std::invalid_argument, std::runtime_error );
 	    /*!
 	      \author Gora Mohanty <gora@srijan.in>
-- 
1.7.2.3

