r17888 by jghali - #11172: Wrong detection of spelling errors due to special characters

scribus-commit scribus-commit at lists.scribus.net
Tue Nov 20 22:50:07 UTC 2012


Author: jghali
Date: Tue Nov 20 22:50:07 2012
New Revision: 17888

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17888
Log:
#11172: Wrong detection of spelling errors due to special characters

Added:
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldict.h
Modified:
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
    trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
    trunk/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&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 Tue Nov 20 22:50:07 2012
@@ -11,12 +11,14 @@
 
   SET(HUNSPELL_PLUGIN_MOC_CLASSES
 	hunspelldialog.h
+	hunspelldict.h
     hunspellplugin.h
     hunspellpluginimpl.h
   )
 
   SET(HUNSPELL_PLUGIN_SOURCES
 	hunspelldialog.cpp
+	hunspelldict.cpp
 	hunspellplugin.cpp
     hunspellpluginimpl.cpp
   )

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp Tue Nov 20 22:50:07 2012
@@ -30,7 +30,7 @@
 	m_primaryLangIndex=0;
 }
 
-void HunspellDialog::set(QMap<QString, QString>* dictionaryMap, QMap<QString, Hunspell*> *hspellerMap, QList<WordsFound> *wfList)
+void HunspellDialog::set(QMap<QString, QString>* dictionaryMap, QMap<QString, HunspellDict*> *hspellerMap, QList<WordsFound> *wfList)
 {
 	m_dictionaryMap=dictionaryMap;
 	m_hspellerMap=hspellerMap;
@@ -161,14 +161,9 @@
 	if (wfListIndex>=m_wfList->count())
 		wfListIndex=0;
 	QString word=m_wfList->at(wfListIndex).w;
-	if ((*m_hspellerMap)[wordLang]->spell(word.toUtf8().constData())==0)
+	if ((*m_hspellerMap)[wordLang]->spell(word)==0)
 	{
-		char **sugglist = NULL;
-		int suggCount=(*m_hspellerMap)[wordLang]->suggest(&sugglist, word.toUtf8().constData());
-		QStringList replacements;
-		for (int j=0; j < suggCount; ++j)
-			replacements << QString::fromUtf8(sugglist[j]);
-		(*m_hspellerMap)[wordLang]->free_list(&sugglist, suggCount);
+		QStringList replacements = (*m_hspellerMap)[wordLang]->suggest(word);
 		updateSuggestions(replacements);
 	}
 	else

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h Tue Nov 20 22:50:07 2012
@@ -6,9 +6,8 @@
 #include <QStringList>
 #include <QWidget>
 
-#include <hunspell/hunspell.hxx>
-
 #include "pluginapi.h"
+#include "hunspelldict.h"
 #include "hunspellpluginstructs.h"
 #include "scribusdoc.h"
 #include "text/storytext.h"
@@ -22,7 +21,7 @@
 	public:
 		HunspellDialog(QWidget* parent, ScribusDoc *doc, StoryText* iText);
 		~HunspellDialog() {};
-		void set(QMap<QString, QString>* dictionaryMap, QMap<QString, Hunspell*> *hspellerMap, QList<WordsFound>* wfList);
+		void set(QMap<QString, QString>* dictionaryMap, QMap<QString, HunspellDict*> *hspellerMap, QList<WordsFound>* wfList);
 		bool docChanged() {return m_docChanged;}
 		void updateSuggestions(QStringList& newSuggestions);
 
@@ -39,7 +38,7 @@
 		ScribusDoc* m_doc;
 		StoryText* m_iText;
 		QMap<QString, QString>* m_dictionaryMap;
-		QMap<QString, Hunspell*> *m_hspellerMap;
+		QMap<QString, HunspellDict*> *m_hspellerMap;
 		QList<WordsFound>* m_wfList;
 		WordsFound currWF;
 		int wfListIndex;

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&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 Tue Nov 20 22:50:07 2012
@@ -39,7 +39,7 @@
 
 HunspellPluginImpl::~HunspellPluginImpl()
 {
-	foreach (Hunspell* h, hspellerMap)
+	foreach (HunspellDict* h, hspellerMap)
 	{
 		delete h;
 		h = NULL;
@@ -81,8 +81,7 @@
 	while (it != dictionaryMap.end())
 	{
 		//qDebug()<<"hunspell init:"<<it.key()<<it.value();
-		hspellerMap.insert(it.key(), new Hunspell((it.value()+".aff").toLocal8Bit().constData(),
-											 (it.value()+".dic").toLocal8Bit().constData()));
+		hspellerMap.insert(it.key(), new HunspellDict(it.value()+".aff", it.value()+".dic"));
 		++it;
 	}
 	return true;
@@ -166,10 +165,9 @@
 			spellerIndex = i;
 		}
 
-		if (hspellerMap.contains(wordLang) && hspellerMap[wordLang]->spell(word.toUtf8().constData())==0)
-		{
-			//qDebug()<<"hspellerMap.contains(wordLang)"<<hspellerMap.contains(wordLang)<< "hspellerMap[wordLang]->spell(word.toUtf8().constData())"<<hspellerMap[wordLang]->spell(word.toUtf8().constData());
-
+		if (hspellerMap.contains(wordLang) && hspellerMap[wordLang]->spell(word)==0)
+		{
+			//qDebug()<<"hspellerMap.contains(wordLang)"<<hspellerMap.contains(wordLang)<< "hspellerMap[wordLang]->spell(word)"<<hspellerMap[wordLang]->spell(word);
 			struct WordsFound wf;
 			wf.start=wordStart;
 			wf.end=wordEnd;
@@ -177,17 +175,8 @@
 			wf.changed=false;
 			wf.ignore=false;
 			wf.changeOffset=0;
-			wf.lang=wordLang;
-			wf.replacements.clear();
-			char **sugglist = NULL;
-			int suggCount=hspellerMap[wordLang]->suggest(&sugglist, word.toUtf8().constData());
-			//qDebug()<<"suggestion count";
-			for (int j=0; j < suggCount; ++j)
-			{
-				wf.replacements << QString::fromUtf8(sugglist[j]);
-				//qDebug()<<QString::fromUtf8(sugglist[j]);
-			}
-			hspellerMap[wordLang]->free_list(&sugglist, suggCount);
+			wf.lang = wordLang;
+			wf.replacements = hspellerMap[wordLang]->suggest(word);
 			wordsToCorrect.append(wf);
 		}
 		currPos = iText->nextWord(wordStart);

Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&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 Tue Nov 20 22:50:07 2012
@@ -7,7 +7,7 @@
 #ifndef HUNSPELLPLUGINIMPL_H
 #define HUNSPELLPLUGINIMPL_H
 
-#include <hunspell/hunspell.hxx>
+#include "hunspelldict.h"
 #include "hunspellpluginstructs.h"
 
 #include <QObject>
@@ -43,7 +43,7 @@
 		QMap<QString, QString> dictionaryMap;
 		QStringList dictionaryPaths;
 		//int numDicts, numAFFs;
-		QMap<QString, Hunspell*> hspellerMap;
+		QMap<QString, HunspellDict*> hspellerMap;
 		ScribusDoc* m_doc;
 		bool m_runningForSE;
 		StoryEditor* m_SE;

Modified: trunk/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17888&path=/trunk/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj
==============================================================================
--- trunk/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj (original)
+++ trunk/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj Tue Nov 20 22:50:07 2012
@@ -230,6 +230,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspelldict.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspellplugin.cpp"
 				>
 			</File>
@@ -273,6 +277,10 @@
 						Name="moc"
 					/>
 				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspelldict.h"
+				>
 			</File>
 			<File
 				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspellplugin.h"




More information about the scribus-commit mailing list