diff options
| author | craig <craig@11d20701-8431-0410-a711-e3c959e3b870> | 2012-04-17 21:39:33 +0000 |
|---|---|---|
| committer | craig <craig@11d20701-8431-0410-a711-e3c959e3b870> | 2012-04-17 21:39:33 +0000 |
| commit | fb98f5e1d6e4142ae1b7302ced455d8afb9d2cbb (patch) | |
| tree | 17500d33db6868ae1e709de8a29cf4ba185bdb71 /scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp | |
| parent | f8eca7a98d8f52cbfc8cb9ced9d59ad9cc2622cc (diff) | |
| download | scribus-fb98f5e1d6e4142ae1b7302ced455d8afb9d2cbb.tar.gz scribus-fb98f5e1d6e4142ae1b7302ced455d8afb9d2cbb.tar.xz scribus-fb98f5e1d6e4142ae1b7302ced455d8afb9d2cbb.zip | |
Another hunspell backup..., works a bit better now
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17455 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp')
| -rw-r--r-- | scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp | 77 |
1 files changed, 11 insertions, 66 deletions
diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp index 7d3c7da..61abd38 100644 --- a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp +++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp @@ -9,6 +9,7 @@ for which a new license (GPL+exception) is in place. #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::run(const QString & target, ScribusDoc* doc) 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 @@ bool HunspellPluginImpl::initHunspell() 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 @@ bool HunspellPluginImpl::initHunspell() 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::checkWithHunspell() bool HunspellPluginImpl::parseTextFrame(PageItem *frameToCheck) { - static QString wordBoundaries(" .,:;\"'!?\n"); - StoryText *iText=&frameToCheck->itemText; int len=iText->length(); QString text=iText->text(0,len); |
