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 | |
| 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')
| -rw-r--r-- | scribus/plugins/tools/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp | 20 | ||||
| -rw-r--r-- | scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp | 77 |
3 files changed, 26 insertions, 77 deletions
diff --git a/scribus/plugins/tools/CMakeLists.txt b/scribus/plugins/tools/CMakeLists.txt index 10cda84..979354e 100644 --- a/scribus/plugins/tools/CMakeLists.txt +++ b/scribus/plugins/tools/CMakeLists.txt @@ -9,7 +9,7 @@ ADD_SUBDIRECTORY(subdivide) 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) diff --git a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp index 4d589e3..5a22666 100644 --- a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp +++ b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp @@ -44,7 +44,12 @@ void HunspellDialog::goToNextWord(int i) 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 @@ void HunspellDialog::ignoreAllWords() //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 @@ void HunspellDialog::changeAllWords() //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 @@ void HunspellDialog::replaceWord(int i) { 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()) { 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); |
