r17877 by jghali - fix spellchecker forgetting first word + not working when gui language not in english
scribus-commit
scribus-commit at lists.scribus.net
Wed Nov 14 23:44:38 UTC 2012
Author: jghali
Date: Wed Nov 14 23:44:38 2012
New Revision: 17877
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17877
Log:
fix spellchecker forgetting first word + not working when gui language not in english
Modified:
branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
branches/Version14x/Scribus/scribus/text/storytext.cpp
branches/Version14x/Scribus/scribus/text/storytext.h
Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17877&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 Wed Nov 14 23:44:38 2012
@@ -113,25 +113,24 @@
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();
- //qDebug()<<wordLang<<LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false, 1)<<LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false, 2);
- QString langAbbrev=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false, 1);
+ 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();
+ //qDebug()<<wordLang<<LanguageManager::instance()->getAbbrevFromLang(wordLang, false, false, 1)<<LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false, 2);
+ QString langAbbrev = LanguageManager::instance()->getAbbrevFromLang(wordLang, false, false, 1);
//A little hack as for some reason our en dictionary from the aspell plugin was not called en_GB or en_US but en, content was en_GB though. Meh.
- if (langAbbrev=="en")
- langAbbrev="en_GB";
- int spellerIndex=0;
+ if (langAbbrev == "en")
+ langAbbrev = "en_GB";
+ int spellerIndex = 0;
if (!dictionaryMap.contains(langAbbrev))
{
//qDebug()<<"Spelling language to match style language not installed ("<<langAbbrev<<")";
- QString langAbbrev2=LanguageManager::instance()->getAbbrevFromLang(wordLang, true, false, 2);
+ QString langAbbrev2=LanguageManager::instance()->getAbbrevFromLang(wordLang, false, false, 2);
if (!langAbbrev2.isEmpty() && dictionaryMap.contains(langAbbrev2))
{
//qDebug()<<"Spelling language swapped to :"<<langAbbrev2;
@@ -154,7 +153,7 @@
if (hspellerMap.contains(langAbbrev) && hspellerMap[langAbbrev]->spell(word.toUtf8().constData())==0)
{
struct WordsFound wf;
- wf.start=currPos;
+ wf.start=wordStart;
wf.end=wordEnd;
wf.w=word;
wf.changed=false;
@@ -169,6 +168,7 @@
hspellerMap[langAbbrev]->free_list(&sugglist, suggCount);
wordsToCorrect.append(wf);
}
+ currPos = iText->nextWord(wordStart);
}
return true;
}
Modified: branches/Version14x/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17877&path=/branches/Version14x/Scribus/scribus/text/storytext.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/text/storytext.cpp (original)
+++ branches/Version14x/Scribus/scribus/text/storytext.cpp Wed Nov 14 23:44:38 2012
@@ -1220,12 +1220,27 @@
else
return length();
}
+
int StoryText::prevChar(int pos)
{
if (pos > 0)
return pos - 1;
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)
Modified: branches/Version14x/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17877&path=/branches/Version14x/Scribus/scribus/text/storytext.h
==============================================================================
--- branches/Version14x/Scribus/scribus/text/storytext.h (original)
+++ branches/Version14x/Scribus/scribus/text/storytext.h Wed Nov 14 23:44:38 2012
@@ -212,6 +212,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