r17491 by craig - 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.
scribus-commit
scribus-commit at lists.scribus.net
Thu May 3 16:21:18 UTC 2012
Author: craig
Date: Thu May 3 16:21:18 2012
New Revision: 17491
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17491
Log:
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.
Modified:
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
branches/Version14x/Scribus/scribus/text/storytext.cpp
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17491&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 Thu May 3 16:21:18 2012
@@ -40,7 +40,8 @@
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 @@
else
statusLabel->setText("");
currWF=m_wfList->at(wfListIndex);
+ setLanguageCombo(currWF.lang);
updateSuggestions(currWF.replacements);
int sentencePos=0;
@@ -173,3 +175,19 @@
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);
+}
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17491&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h Thu May 3 16:21:18 2012
@@ -33,6 +33,7 @@
void changeAllWords();
void replaceWord(int i);
void languageComboChanged(int index);
+ void setLanguageCombo(const QString &newLangAbbrev);
private:
ScribusDoc* m_doc;
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17491&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 Thu May 3 16:21:18 2012
@@ -163,16 +163,18 @@
{
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 @@
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 @@
wf.changed=false;
wf.ignore=false;
wf.changeOffset=0;
+ wf.lang=wordLang;
wordsToCorrect.append(wf);
}
}
-// qDebug()<<"Errors found:"<<errorCount;
return true;
}
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17491&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h Thu May 3 16:21:18 2012
@@ -12,6 +12,7 @@
bool changed;
bool ignore;
int changeOffset;
+ QString lang;
};
#endif // HUNSPELLPLUGINSTRUCTS_H
Modified: branches/Version14x/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17491&path=/branches/Version14x/Scribus/scribus/text/storytext.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/text/storytext.cpp (original)
+++ branches/Version14x/Scribus/scribus/text/storytext.cpp Thu May 3 16:21:18 2012
@@ -1125,14 +1125,28 @@
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);
More information about the scribus-commit
mailing list