r17878 by jghali - fix spellchecker forgetting first word
scribus-commit
scribus-commit at lists.scribus.net
Wed Nov 14 23:46:09 UTC 2012
Author: jghali
Date: Wed Nov 14 23:46:09 2012
New Revision: 17878
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17878
Log:
fix spellchecker forgetting first word
Modified:
trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
Modified: trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17878&path=/trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp Wed Nov 14 23:46:09 2012
@@ -114,15 +114,14 @@
bool HunspellPluginImpl::parseTextFrame(StoryText *iText)
{
- int len=iText->length();
- int currPos=0, wordStart=0;
- while (currPos<len)
- {
- wordStart=iText->nextWord(currPos);
- int wordEnd=iText->endOfWord(wordStart);
- currPos=wordStart;
- QString word=iText->text(wordStart,wordEnd-wordStart);
- QString wordLang=iText->charStyle(wordStart).language();
+ int len = iText->length();
+ int currPos = iText->firstWord(), wordStart;
+ while (currPos < len)
+ {
+ wordStart = currPos;
+ int wordEnd = iText->endOfWord(wordStart);
+ QString word = iText->text(wordStart,wordEnd - wordStart);
+ QString wordLang = iText->charStyle(wordStart).language();
if (wordLang.isEmpty())
{
@@ -155,7 +154,7 @@
else
{
//qDebug()<<"Spelling language to match style language IS installed ("<<wordLang<<")";
- int i=0;
+ int i = 0;
QMap<QString, QString>::iterator it = dictionaryMap.begin();
while (it != dictionaryMap.end())
{
@@ -164,7 +163,7 @@
++i;
++it;
}
- spellerIndex=i;
+ spellerIndex = i;
}
if (hspellerMap.contains(wordLang) && hspellerMap[wordLang]->spell(word.toUtf8().constData())==0)
@@ -172,7 +171,7 @@
//qDebug()<<"hspellerMap.contains(wordLang)"<<hspellerMap.contains(wordLang)<< "hspellerMap[wordLang]->spell(word.toUtf8().constData())"<<hspellerMap[wordLang]->spell(word.toUtf8().constData());
struct WordsFound wf;
- wf.start=currPos;
+ wf.start=wordStart;
wf.end=wordEnd;
wf.w=word;
wf.changed=false;
@@ -191,6 +190,7 @@
hspellerMap[wordLang]->free_list(&sugglist, suggCount);
wordsToCorrect.append(wf);
}
+ currPos = iText->nextWord(wordStart);
}
return true;
}
Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17878&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Wed Nov 14 23:46:09 2012
@@ -1275,6 +1275,7 @@
else
return length();
}
+
int StoryText::prevChar(int pos)
{
if (pos > 0)
@@ -1282,6 +1283,21 @@
else
return 0;
}
+
+int StoryText::firstWord()
+{
+ int len = length();
+ int pos = 0;
+
+ while (pos < len)
+ {
+ if (text(pos).isLetter())
+ break;
+ ++pos;
+ }
+ return pos;
+}
+
int StoryText::nextWord(int pos)
{
int len = length();
@@ -1302,6 +1318,7 @@
}
return pos < len ? pos + 1 : pos;
}
+
int StoryText::prevWord(int pos)
{
pos = qMax(0, pos-1);
Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17878&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Wed Nov 14 23:46:09 2012
@@ -220,6 +220,7 @@
// positioning
int nextChar(int pos);
int prevChar(int pos);
+ int firstWord();
int nextWord(int pos);
int prevWord(int pos);
int endOfWord(int pos) const;
More information about the scribus-commit
mailing list