summaryrefslogtreecommitdiffstats
path: root/scribus/plugins
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-04-23 19:19:14 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-04-23 19:19:14 +0000
commitc987c42061d9cbf46176f4eeff70ac745c20b219 (patch)
treebc08c150a61d587da49e8e6179e2875e3685a0d2 /scribus/plugins
parent7fb0e01395e4c4a13bbd4ce9b46c4fbdfbff6bc9 (diff)
downloadscribus-c987c42061d9cbf46176f4eeff70ac745c20b219.tar.gz
scribus-c987c42061d9cbf46176f4eeff70ac745c20b219.tar.xz
scribus-c987c42061d9cbf46176f4eeff70ac745c20b219.zip
hunspell plugin: add replaceWord() and sentence() functions to StoryText
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17469 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins')
-rw-r--r--scribus/plugins/tools/CMakeLists.txt6
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp36
2 files changed, 10 insertions, 32 deletions
diff --git a/scribus/plugins/tools/CMakeLists.txt b/scribus/plugins/tools/CMakeLists.txt
index 10cda84..979354e 100644
--- a/scribus/plugins/tools/CMakeLists.txt
+++ b/scribus/plugins/tools/CMakeLists.txt
@@ -9,7 +9,7 @@ ADD_SUBDIRECTORY(subdivide)
if (HAVE_ASPELL)
ADD_SUBDIRECTORY(spellcheck)
endif (HAVE_ASPELL)
-#if (HAVE_HUNSPELL)
-# ADD_SUBDIRECTORY(hunspellcheck)
-#endif (HAVE_HUNSPELL)
+if (HAVE_HUNSPELL)
+ ADD_SUBDIRECTORY(hunspellcheck)
+endif (HAVE_HUNSPELL)
ADD_SUBDIRECTORY(transform)
diff --git a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
index f0eb3a6..d36b08b 100644
--- a/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
+++ b/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
@@ -64,11 +64,9 @@ void HunspellDialog::goToNextWord(int i)
suggestionsListWidget->clear();
suggestionsListWidget->addItems(currWF.replacements);
suggestionsListWidget->setCurrentRow(0);
- StoryText *iText=&fTC->itemText;
- int sentencePos=qMax(0,iText->prevSentence(currWF.start));
- sentencePos=qMax(sentencePos, iText->nextWord(sentencePos));
- int nextSentencePos=qMin(iText->length(), iText->nextSentence(currWF.end));
- QString sentence=iText->text(sentencePos, nextSentencePos-sentencePos);
+
+ int sentencePos=0;
+ QString sentence(fTC->itemText.sentence(currWF.start, sentencePos));
sentence.insert(currWF.end-sentencePos+currWF.changeOffset,"</b></font>");
sentence.insert(currWF.start-sentencePos+currWF.changeOffset,"<font color=red><b>");
sentenceTextEdit->setText(sentence);
@@ -110,34 +108,14 @@ void HunspellDialog::changeAllWords()
void HunspellDialog::replaceWord(int i)
{
- StoryText *iText=&fTC->itemText;
- currWF=m_wfList->at(i);
- (*m_wfList)[i].changed=true;
- //qDebug()<<"Replacing word"<<i<<m_wfList->value(i).w<<m_wfList->value(i).changed;
+ //qDebug()<<"Replacing word"<<i<m_wfList->at(i).w<<m_wfList->at(i).start;
QString newText(suggestionsListWidget->currentItem()->text());
- if (newText.length()==currWF.w.length())
- {
- for (int j = 0; j < currWF.w.length(); ++j)
- iText->replaceChar(currWF.start+j+currWF.changeOffset, newText[j]);
- }
- else
+ int lengthDiff=fTC->itemText.replaceWord(m_wfList->at(i).start+m_wfList->at(i).changeOffset, newText);
+ if (lengthDiff!=0)
{
- int lengthDiff=newText.length()-currWF.w.length();
- if (newText.length()>currWF.w.length())
- {
- for (int j = 0; j < currWF.w.length(); ++j)
- iText->replaceChar(currWF.start+j+currWF.changeOffset, newText[j]);
- for (int j = currWF.w.length(); j < newText.length(); ++j)
- iText->insertChars(currWF.start+j+currWF.changeOffset, newText.mid(j,1), true);
- }
- else
- {
- for (int j = 0; j < newText.length(); ++j)
- iText->replaceChar(currWF.start+j+currWF.changeOffset, newText[j]);
- iText->removeChars(currWF.start+currWF.changeOffset+newText.length(), -lengthDiff);
- }
for (int k=i; k<m_wfList->count();++k)
(*m_wfList)[k].changeOffset+=lengthDiff;
}
+ (*m_wfList)[i].changed=true;
m_docChanged=true;
}