r17455 by craig - Another hunspell backup..., works a bit better now

scribus-commit scribus-commit at lists.scribus.net
Tue Apr 17 21:39:33 UTC 2012


Author: craig
Date: Tue Apr 17 21:39:33 2012
New Revision: 17455

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17455
Log:
Another hunspell backup..., works a bit better now

Modified:
    branches/Version14x/Scribus/scribus/plugins/tools/CMakeLists.txt
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
    branches/Version14x/Scribus/scribus/scpaths.cpp
    branches/Version14x/Scribus/scribus/scpaths.h

Modified: branches/Version14x/Scribus/scribus/plugins/tools/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17455&path=/branches/Version14x/Scribus/scribus/plugins/tools/CMakeLists.txt
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/CMakeLists.txt (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/CMakeLists.txt Tue Apr 17 21:39:33 2012
@@ -9,7 +9,7 @@
 if (HAVE_ASPELL)
   ADD_SUBDIRECTORY(spellcheck)
 endif (HAVE_ASPELL)
-#if (HAVE_HUNSPELL)
-#  ADD_SUBDIRECTORY(hunspellcheck)
-#endif (HAVE_HUNSPELL)
+if (HAVE_HUNSPELL)
+  ADD_SUBDIRECTORY(hunspellcheck)
+endif (HAVE_HUNSPELL)
 ADD_SUBDIRECTORY(transform)

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17455&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 Apr 17 21:39:33 2012
@@ -44,7 +44,12 @@
 	if (i>=0)
 		wfListIndex=i;
 	else
-		++wfListIndex;
+	{
+		do {
+			++wfListIndex;
+		} while (wfListIndex<m_wfList->count() && (m_wfList->at(wfListIndex).changed || m_wfList->at(wfListIndex).ignore));
+		//qDebug()<<"selected word index"<<wfListIndex;
+	}
 	if (wfListIndex>=m_wfList->count())
 	{
 		statusLabel->setText(tr("Spelling check complete"));
@@ -77,14 +82,14 @@
 	//Do we start from 0 or from the instance of the word where we are... 0 for now
 	for(int i=0;i<m_wfList->count();++i)
 		if(m_wfList->at(i).w==wordToIgnore)
-			m_wfList->value(i).ignore=true;
+			(*m_wfList)[i].ignore=true;
 	goToNextWord();
 }
 
 void HunspellDialog::changeWord()
 {
-	//If we have ignored a word, skip to the next.
-	if(m_wfList->at(wfListIndex).ignore && !m_wfList->at(wfListIndex).changed)
+	//If we have ignored a word or its already changed, skip to the next.
+	if(m_wfList->at(wfListIndex).ignore || m_wfList->at(wfListIndex).changed)
 		goToNextWord();
 	replaceWord(wfListIndex);
 	m_docChanged=true;
@@ -99,9 +104,7 @@
 	//Do we start from 0 or from the instance of the word where we are... 0 for now
 	for(int i=0;i<m_wfList->count();++i)
 		if(m_wfList->at(i).w==wordToChange)
-		{
-			m_wfList->value(i).changed=true;
-		}
+			replaceWord(i);
 	m_docChanged=true;
 	goToNextWord();
 }
@@ -110,7 +113,8 @@
 {
 	StoryText *iText=&fTC->itemText;
 	currWF=m_wfList->at(i);
-	m_wfList->value(i).changed=true;
+	(*m_wfList)[i].changed=true;
+	//qDebug()<<"Replacing word"<<i<<m_wfList->value(i).w<<m_wfList->value(i).changed;
 	QString newText(suggestionsListWidget->currentItem()->text());
 	if (newText.length()==currWF.w.length())
 	{

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17455&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 Apr 17 21:39:33 2012
@@ -9,6 +9,7 @@
 #include "pageitem.h"
 #include "pageitem_textframe.h"
 #include "selection.h"
+#include "scpaths.h"
 #include "scribusdoc.h"
 #include "scribus.h"
 #include "text/specialchars.h"
@@ -62,65 +63,12 @@
 
 bool HunspellPluginImpl::findDictionaries()
 {
-	//dictionaryPaths
-	QString macPortsPath("/opt/local/share/hunspell/");
-	QString finkPath("/sw/share/hunspell/");
-	QString osxLibreOfficePath("/Applications/LibreOffice.app/Contents/share/extensions");
-	QString osxUserLibreOfficePath(QDir::homePath()+"/Applications/LibreOffice.app/Contents/share/extensions");
-	QString linuxLocalPath("/usr/local/share/hunspell/");
-	QString linuxPath("/usr/share/hunspell/");
-	QString windowsLOPath("LibreOffice 3.5/share/extensions");
-	QDir d;
-
-#ifdef Q_OS_MAC
-	d.setPath(macPortsPath);
-	if (d.exists())
-	{
-		dictPath=macPortsPath;
-		return true;
-	}
-	d.setPath(finkPath);
-	if (d.exists())
-	{
-		dictPath=finkPath;
-		return true;
-	}
-	d.setPath(osxLibreOfficePath);
-	if (d.exists())
-	{
-		dictPath=osxLibreOfficePath;
-		return true;
-	}
-	d.setPath(osxUserLibreOfficePath);
-	if (d.exists())
-	{
-		dictPath=osxUserLibreOfficePath;
-		return true;
-	}
-	return false;
-#elif defined(Q_WS_X11)
-	d.setPath(linuxPath);
-	if (d.exists())
-	{
-		dictPath=linuxPath;
-		return true;
-	}
-	d.setPath(linuxLocalPath);
-	if (d.exists())
-	{
-		dictPath=linuxLocalPath;
-		return true;
-	}
-#elif defined(Q_OS_WIN32)
-	QString progFiles = getSpecialDir(CSIDL_PROGRAM_FILES);
-	d.setPath(progFiles+windowsLOPath);
-	if (d.exists())
-	{
-		dictPath=progFiles+windowsLOPath;
-		return true;
-	}
-#endif
-	return false;
+	QStringList dirs(ScPaths::instance().spellDirs());
+	if (dirs.count()==0)
+		return false;
+	//for development, just take the first for now
+	dictPath=dirs.first();
+	return true;
 }
 
 bool HunspellPluginImpl::initHunspell()
@@ -128,13 +76,12 @@
 	int errorCount=0;
 	bool dictPathFound=findDictionaries();
 	if (!dictPathFound)
+	{
 		qDebug()<<"No preinstalled dictonary paths found";
+		return false;
+	}
 	else
 		qDebug()<<"Preinstalled dictionary path selected"<<dictPath;
-	//TODO: Find this somehow
-//	QString startPath;
-//	startPath="/Applications/LibreOffice.app/Contents/share/extensions/dict-en/";
-//	dictPath=startPath;
 
 	// Find the dic and aff files in the location
 	QDir dictLocation(dictPath);
@@ -154,7 +101,7 @@
 		if (!QFile::exists(dictPath+dictName+".aff"))
 			dictList.removeAll(dictName);
 	}
-	numDicts=dictList.count();
+	numAFFs=numDicts=dictList.count();
 	qDebug()<<"Number of dictionaries/AFFs found:"<<numDicts<<numAFFs;
 	if (numDicts==0)
 		++errorCount;
@@ -188,8 +135,6 @@
 
 bool HunspellPluginImpl::parseTextFrame(PageItem *frameToCheck)
 {
-	static QString wordBoundaries(" .,:;\"'!?\n");
-
 	StoryText *iText=&frameToCheck->itemText;
 	int len=iText->length();
 	QString text=iText->text(0,len);

Modified: branches/Version14x/Scribus/scribus/scpaths.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17455&path=/branches/Version14x/Scribus/scribus/scpaths.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scpaths.cpp (original)
+++ branches/Version14x/Scribus/scribus/scpaths.cpp Tue Apr 17 21:39:33 2012
@@ -252,6 +252,49 @@
 	return(m_shareDir + "dicts/");
 }
 
+QStringList ScPaths::spellDirs() const
+{
+	//dictionaryPaths
+	QString macPortsPath("/opt/local/share/hunspell/");
+	QString finkPath("/sw/share/hunspell/");
+	QString osxLibreOfficePath("/Applications/LibreOffice.app/Contents/share/extensions");
+	QString osxUserLibreOfficePath(QDir::homePath()+"/Applications/LibreOffice.app/Contents/share/extensions");
+	QString linuxLocalPath("/usr/local/share/hunspell/");
+	QString linuxPath("/usr/share/hunspell/");
+	QString windowsLOPath("LibreOffice 3.5/share/extensions");
+	QDir d;
+	QStringList spellDirs;
+	spellDirs.append(m_shareDir + "dicts/spelling/");
+#ifdef Q_OS_MAC
+	//spellDirs.append(QDir::homePath() + "/Library/Fonts/");
+	d.setPath(macPortsPath);
+	if (d.exists())
+		spellDirs.append(macPortsPath);
+	d.setPath(finkPath);
+	if (d.exists())
+		spellDirs.append(finkPath);
+	d.setPath(osxLibreOfficePath);
+	if (d.exists())
+		spellDirs.append(osxLibreOfficePath);
+	d.setPath(osxUserLibreOfficePath);
+	if (d.exists())
+		spellDirs.append(osxUserLibreOfficePath);
+#elif defined(_WIN32)
+	QString progFiles = getSpecialDir(CSIDL_PROGRAM_FILES);
+	d.setPath(progFiles+windowsLOPath);
+	if (d.exists())
+		spellDirs.append(progFiles+windowsLOPath);
+#elif defined(Q_WS_X11)
+	d.setPath(linuxPath);
+	if (d.exists())
+		spellDirs.append(linuxPath);
+	d.setPath(linuxLocalPath);
+	if (d.exists())
+		spellDirs.append(linuxLocalPath);
+#endif
+	return spellDirs;
+}
+
 QStringList ScPaths::getSystemFontDirs(void)
 {
 	QStringList fontDirs;

Modified: branches/Version14x/Scribus/scribus/scpaths.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17455&path=/branches/Version14x/Scribus/scribus/scpaths.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scpaths.h (original)
+++ branches/Version14x/Scribus/scribus/scpaths.h Tue Apr 17 21:39:33 2012
@@ -53,6 +53,8 @@
 	QString translationDir() const;
 	/** @brief Return path to the dicts directory */
 	QString dictDir() const;
+	/** @brief Return path to the spelling dictionary directory */
+	QStringList spellDirs() const;
 
 	/** @brief Return paths to system font directories*/
 	static QStringList getSystemFontDirs(void);




More information about the scribus-commit mailing list