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

scribus-commit scribus-commit at lists.scribus.net
Tue Nov 20 22:49:15 UTC 2012


Author: jghali
Date: Tue Nov 20 22:49:14 2012
New Revision: 17887

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

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

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/CMakeLists.txt Tue Nov 20 22:49:14 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: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp Tue Nov 20 22:49:14 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;
@@ -166,14 +166,9 @@
 		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: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h Tue Nov 20 22:49:14 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: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp Tue Nov 20 22:49:14 2012
@@ -39,7 +39,7 @@
 
 HunspellPluginImpl::~HunspellPluginImpl()
 {
-	foreach (Hunspell* h, hspellerMap)
+	foreach (HunspellDict* h, hspellerMap)
 	{
 		delete h;
 		h = NULL;
@@ -80,8 +80,7 @@
 	QMap<QString, QString>::iterator it = dictionaryMap.begin();
 	while (it != dictionaryMap.end())
 	{
-		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;
@@ -150,7 +149,7 @@
 			}
 			spellerIndex=i;
 		}
-		if (hspellerMap.contains(langAbbrev) && hspellerMap[langAbbrev]->spell(word.toUtf8().constData())==0)
+		if (hspellerMap.contains(langAbbrev) && hspellerMap[langAbbrev]->spell(word)==0)
 		{
 			struct WordsFound wf;
 			wf.start=wordStart;
@@ -159,13 +158,8 @@
 			wf.changed=false;
 			wf.ignore=false;
 			wf.changeOffset=0;
-			wf.lang=langAbbrev;
-			wf.replacements.clear();
-			char **sugglist = NULL;
-			int suggCount=hspellerMap[langAbbrev]->suggest(&sugglist, word.toUtf8().constData());
-			for (int j=0; j < suggCount; ++j)
-				wf.replacements << QString::fromUtf8(sugglist[j]);
-			hspellerMap[langAbbrev]->free_list(&sugglist, suggCount);
+			wf.lang = langAbbrev;
+			wf.replacements = hspellerMap[langAbbrev]->suggest(word);
 			wordsToCorrect.append(wf);
 		}
 		currPos = iText->nextWord(wordStart);

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.h Tue Nov 20 22:49:14 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: branches/Version14x/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17887&path=/branches/Version14x/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj
==============================================================================
--- branches/Version14x/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj (original)
+++ branches/Version14x/Scribus/win32/vc9/hunspellcheck/hunspellcheck.vcproj Tue Nov 20 22:49:14 2012
@@ -424,6 +424,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspelldict.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\plugins\tools\hunspellcheck\hunspellplugin.cpp"
 				>
 			</File>
@@ -467,6 +471,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