summaryrefslogtreecommitdiffstats
path: root/scribus
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-05-03 16:21:18 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-05-03 16:21:18 +0000
commit87819d60bf3e5b5de4ff1486c4c07011a069347e (patch)
treeb5f2c55223e072eb914cc07d6dc9f10cfb77e20f /scribus
parent020a92a1d225b2a84feb5dfbb8aa126801571d26 (diff)
downloadscribus-87819d60bf3e5b5de4ff1486c4c07011a069347e.tar.gz
scribus-87819d60bf3e5b5de4ff1486c4c07011a069347e.tar.xz
scribus-87819d60bf3e5b5de4ff1486c4c07011a069347e.zip
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
Diffstat (limited to 'scribus')
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp20
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspelldialog.h1
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp12
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h1
-rw-r--r--scribus/text/storytext.cpp20
5 files changed, 45 insertions, 9 deletions
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<QString, QString>* dictionaryMap, Hunspell **hspel
QMap<QString, QString>::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<QString, QString>::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 (currPos<len)
{
- int wordPos=iText->nextWord(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()<<word;
+// qDebug()<<word<<wordLang;
++errorCount;
char **sugglist = NULL;
int suggCount=hspellers[spellerIndex]->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:"<<errorCount;
return true;
}
diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h b/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
index 5b2c8ce..9471583 100644
--- a/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
+++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
@@ -12,6 +12,7 @@ struct WordsFound {
bool changed;
bool ignore;
int changeOffset;
+ QString lang;
};
#endif // HUNSPELLPLUGINSTRUCTS_H
diff --git a/scribus/text/storytext.cpp b/scribus/text/storytext.cpp
index dc4cace..531744a 100644
--- a/scribus/text/storytext.cpp
+++ b/scribus/text/storytext.cpp
@@ -1125,14 +1125,28 @@ int StoryText::prevChar(int pos)
else
return 0;
}
+
int StoryText::nextWord(int pos)
{
int len = length();
- pos = qMin(len, pos+1);
- while (pos < len && wordBoundaries.indexOf(text(pos)) < 0)
- ++pos;
+ if (text(pos).isLetter())
+ pos = qMin(len, pos+1);
+ else
+ pos = qMin(len, pos);
+
+ // while (pos < len && wordBoundaries.indexOf(text(pos)) < 0)
+ // ++pos;
+
+ while (pos < len)
+ {
+ if(text(pos).isLetter())
+ ++pos;
+ else
+ break;
+ }
return pos < len ? pos + 1 : pos;
}
+
int StoryText::prevWord(int pos)
{
pos = qMax(0, pos-1);