r17550 by craig - Update hunspell to remove old downloader test code and bring part of new API to trunk

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 8 21:34:00 UTC 2012


Author: craig
Date: Fri Jun  8 21:34:00 2012
New Revision: 17550

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17550
Log:
Update hunspell to remove old downloader test code and bring part of new API to trunk

Modified:
    trunk/Scribus/scribus/langmgr.cpp
    trunk/Scribus/scribus/langmgr.h
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellplugin.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h

Modified: trunk/Scribus/scribus/langmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/langmgr.cpp
==============================================================================
--- trunk/Scribus/scribus/langmgr.cpp (original)
+++ trunk/Scribus/scribus/langmgr.cpp Fri Jun  8 21:34:00 2012
@@ -304,6 +304,40 @@
 	return retSeq;
 }
 
+bool LanguageManager::findDictionaries(QStringList &sl)
+{
+	sl=ScPaths::instance().spellDirs();
+	if (sl.count()==0)
+		return false;
+	return true;
+}
+
+void LanguageManager::findDictionarySets(QStringList &dictionaryPaths, QMap<QString, QString> &dictionaryMap)
+{
+	for (int i=0; i<dictionaryPaths.count(); ++i)
+	{
+		// Find the dic and aff files in the location
+		QDir dictLocation(dictionaryPaths.at(i));
+		QStringList dictFilters("*.dic");
+		QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
+		dictList.replaceInStrings(".dic","");
+
+		//Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
+		QString dictName;
+		foreach(dictName, dictList)
+		{
+			if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
+				dictList.removeAll(dictName);
+			else
+			{
+				if (!dictionaryMap.contains(dictName))
+					dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
+			}
+		}
+//		qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
+	}
+}
+
 LanguageManager::~LanguageManager()
 {
 	langList.clear();

Modified: trunk/Scribus/scribus/langmgr.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/langmgr.h
==============================================================================
--- trunk/Scribus/scribus/langmgr.h (original)
+++ trunk/Scribus/scribus/langmgr.h Fri Jun  8 21:34:00 2012
@@ -50,6 +50,8 @@
 	void fillInstalledStringList(QStringList *stringListToFill, bool addDefaults);
 	void printInstalledList();
 	QString numericSequence(QString seq);
+	bool findDictionaries(QStringList& sl);
+	void findDictionarySets(QStringList& dictionaryPaths, QMap<QString, QString>& dictionaryMap);
 	
 	void addHyphLang(const QString& lang, const QString& filename);
 	const QString getHyphFilename(const QString& lang, bool langIsAbbreviated = true);

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt Fri Jun  8 21:34:00 2012
@@ -13,14 +13,12 @@
 	hunspelldialog.h
     hunspellplugin.h
     hunspellpluginimpl.h
-	hunspelldownloader.h
   )
 
   SET(HUNSPELL_PLUGIN_SOURCES
 	hunspelldialog.cpp
 	hunspellplugin.cpp
     hunspellpluginimpl.cpp
-	hunspelldownloader.cpp
   )
 
   SET(SCRIBUS_HUNSPELL_PLUGIN "hunspellplugin")

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellplugin.cpp Fri Jun  8 21:34:00 2012
@@ -8,7 +8,6 @@
 #include "hunspellpluginimpl.h"
 #include "scribuscore.h"
 #include "ui/storyeditor.h"
-#include "hunspelldownloader.h"
 
 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
 // do. That documentatation is not duplicated here.
@@ -20,9 +19,6 @@
 	// Set action info in languageChange, so we only have to do
 	// it in one place.
 	languageChange();
-
-	HunspellDownloader hd;
-	hd.downloadDictionaryXML();
 }
 
 HunspellPlugin::~HunspellPlugin() {};

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp Fri Jun  8 21:34:00 2012
@@ -32,7 +32,7 @@
 HunspellPluginImpl::HunspellPluginImpl() : QObject(0)
 {
 	//hspellers=NULL;
-	numDicts=0;
+//	numDicts=0;
 	m_runningForSE=false;
 	m_SE=NULL;
 }
@@ -45,7 +45,7 @@
 		h = NULL;
 	}
 	hspellerMap.clear();
-	numDicts = 0;
+//	numDicts = 0;
 }
 
 bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
@@ -62,45 +62,17 @@
 	return spellCheckOk;
 }
 
-bool HunspellPluginImpl::findDictionaries()
-{
-	dictionaryPaths=ScPaths::instance().spellDirs();
-	if (dictionaryPaths.count()==0)
-		return false;
-	return true;
-}
-
 bool HunspellPluginImpl::initHunspell()
 {
-	bool dictPathFound=findDictionaries();
+	bool dictPathFound=LanguageManager::instance()->findDictionaries(dictionaryPaths);
 	if (!dictPathFound)
 	{
 		qDebug()<<"No preinstalled dictonary paths found";
 		return false;
 	}
-	for (int i=0; i<dictionaryPaths.count(); ++i)
-	{
-		// Find the dic and aff files in the location
-		QDir dictLocation(dictionaryPaths.at(i));
-		QStringList dictFilters("*.dic");
-		QStringList dictList(dictLocation.entryList(dictFilters, QDir::Files, QDir::Name));
-		dictList.replaceInStrings(".dic","");
-
-		//Ensure we have aff+dic file pairs, remove any hyphenation dictionaries from the list
-		QString dictName;
-		foreach(dictName, dictList)
-		{
-			if (!QFile::exists(dictionaryPaths.at(i)+dictName+".aff"))
-				dictList.removeAll(dictName);
-			else
-			{
-				if (!dictionaryMap.contains(dictName))
-					dictionaryMap.insert(dictName, dictionaryPaths.at(i)+dictName);
-			}
-		}
-		qDebug()<<"Number of dictionaries/AFFs found in"<<dictionaryPaths.at(i)<<":"<<dictList.count();
-	}
-	numDicts=dictionaryMap.count();
+	dictionaryMap.clear();
+	LanguageManager::instance()->findDictionarySets(dictionaryPaths, dictionaryMap);
+//	numDicts=dictionaryMap.count();
 	if (dictionaryMap.count()==0)
 		return false;
 
@@ -150,7 +122,6 @@
 		currPos=wordStart;
 		QString word=iText->text(wordStart,wordEnd-wordStart);
 		QString wordLang=iText->charStyle(wordStart).language();
-		//qDebug()<<word<<wordLang;
 		wordLang=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false);
 		//A little hack as for some reason our en dictionary from the aspell plugin was not called en_GB or en_US but en, content was en_GB though. Meh.
 		if (wordLang=="en")

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17550&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h Fri Jun  8 21:34:00 2012
@@ -30,7 +30,6 @@
 		HunspellPluginImpl();
 		~HunspellPluginImpl();
 		bool run(const QString & target, ScribusDoc* doc=0);
-		bool findDictionaries();
 		bool initHunspell();
 		bool checkWithHunspell();
 		bool checkWithHunspellSE();
@@ -43,7 +42,7 @@
 	protected:
 		QMap<QString, QString> dictionaryMap;
 		QStringList dictionaryPaths;
-		int numDicts, numAFFs;
+		//int numDicts, numAFFs;
 		QMap<QString, Hunspell*> hspellerMap;
 		ScribusDoc* m_doc;
 		bool m_runningForSE;




More information about the scribus-commit mailing list