From 87819d60bf3e5b5de4ff1486c4c07011a069347e Mon Sep 17 00:00:00 2001 From: craig Date: Thu, 3 May 2012 16:21:18 +0000 Subject: Bump hunspell some more. Word language now recorded from the char style and the words are checked against that dictionary if it exists. Fix (or break?) StoryText::nextWord. git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17491 11d20701-8431-0410-a711-e3c959e3b870 --- .../plugins/tools/hunspellcheck/hunspelldialog.cpp | 20 +++++++++++++++++++- scribus/plugins/tools/hunspellcheck/hunspelldialog.h | 1 + .../tools/hunspellcheck/hunspellpluginimpl.cpp | 12 +++++++----- .../tools/hunspellcheck/hunspellpluginstructs.h | 1 + scribus/text/storytext.cpp | 20 +++++++++++++++++--- 5 files changed, 45 insertions(+), 9 deletions(-) (limited to 'scribus') diff --git a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp index b10a56f..6c9087a 100644 --- a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp +++ b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp @@ -40,7 +40,8 @@ void HunspellDialog::set(QMap* dictionaryMap, Hunspell **hspel QMap::iterator it = m_dictionaryMap->begin(); while (it != dictionaryMap->end()) { - languagesComboBox->addItem(LanguageManager::instance()->getLangFromAbbrev(it.key(), true)); + QString lang=LanguageManager::instance()->getLangFromAbbrev(it.key(), true); + languagesComboBox->addItem(!lang.isEmpty() ? lang : it.key()); ++it; } languagesComboBox->setCurrentIndex(0); @@ -86,6 +87,7 @@ void HunspellDialog::goToNextWord(int i) else statusLabel->setText(""); currWF=m_wfList->at(wfListIndex); + setLanguageCombo(currWF.lang); updateSuggestions(currWF.replacements); int sentencePos=0; @@ -173,3 +175,19 @@ void HunspellDialog::languageComboChanged(int index) goToNextWord(); } } + +void HunspellDialog::setLanguageCombo(const QString &newLangAbbrev) +{ + QMap::iterator it = m_dictionaryMap->begin(); + int i=0; + while (it != m_dictionaryMap->end()) + { + if (it.key()==newLangAbbrev) + break; + ++i; + ++it; + } + bool b=languagesComboBox->blockSignals(true); + languagesComboBox->setCurrentIndex(i); + languagesComboBox->blockSignals(b); +} diff --git a/scribus/plugins/tools/hunspellcheck/hunspelldialog.h b/scribus/plugins/tools/hunspellcheck/hunspelldialog.h index 178fbc2..245df6e 100644 --- a/scribus/plugins/tools/hunspellcheck/hunspelldialog.h +++ b/scribus/plugins/tools/hunspellcheck/hunspelldialog.h @@ -33,6 +33,7 @@ class PLUGIN_API HunspellDialog : public QDialog, private Ui::HunspellDialogBase void changeAllWords(); void replaceWord(int i); void languageComboChanged(int index); + void setLanguageCombo(const QString &newLangAbbrev); private: ScribusDoc* m_doc; diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp index ee4ed23..cbbd675 100644 --- a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp +++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp @@ -163,16 +163,18 @@ bool HunspellPluginImpl::parseTextFrame(StoryText *iText) { int len=iText->length(); int wordCount=0,wordNo=0,errorCount=0; - int currPos=0; + int currPos=0, wordPos=0; while (currPosnextWord(currPos); + wordPos=iText->nextWord(currPos); currPos=wordPos; int eoWord=wordPos; while(eoWord < len) { - if (iText->text(eoWord).isLetterOrNumber()) + if (iText->text(eoWord).isLetter()) + { ++eoWord; + } else break; } @@ -203,7 +205,7 @@ bool HunspellPluginImpl::parseTextFrame(StoryText *iText) QStringList replacements; if (hspellers[spellerIndex]->spell(word.toUtf8().constData())==0) { -// qDebug()<suggest(&sugglist, word.toUtf8().constData()); @@ -222,10 +224,10 @@ bool HunspellPluginImpl::parseTextFrame(StoryText *iText) wf.changed=false; wf.ignore=false; wf.changeOffset=0; + wf.lang=wordLang; wordsToCorrect.append(wf); } } -// qDebug()<<"Errors found:"<