summaryrefslogtreecommitdiffstats
path: root/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-04-30 21:42:55 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-04-30 21:42:55 +0000
commit03f92217ee2336adcbf9b1343ea03edac490ade5 (patch)
tree54300e6b248f5b341d8de29649d4175edfae5742 /scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
parent8f5f4c57942487fafbeced90e981810b20c809b5 (diff)
downloadscribus-03f92217ee2336adcbf9b1343ea03edac490ade5.tar.gz
scribus-03f92217ee2336adcbf9b1343ea03edac490ade5.tar.xz
scribus-03f92217ee2336adcbf9b1343ea03edac490ade5.zip
Update hunspell plugin, plugin manager to allow SE to see plugins, scplugin to have SE plugin attributes
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17485 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp')
-rw-r--r--scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp54
1 files changed, 45 insertions, 9 deletions
diff --git a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
index 1b169e7..8fff975 100644
--- a/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
+++ b/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
@@ -12,6 +12,7 @@ for which a new license (GPL+exception) is in place.
#include "scpaths.h"
#include "scribusdoc.h"
#include "scribus.h"
+#include "storyeditor.h"
#include "text/specialchars.h"
#include "util.h"
@@ -31,6 +32,8 @@ HunspellPluginImpl::HunspellPluginImpl() : QObject(0)
{
hspellers=NULL;
numDicts=0;
+ m_runningForSE=false;
+ m_SE=NULL;
}
HunspellPluginImpl::~HunspellPluginImpl()
@@ -55,7 +58,17 @@ bool HunspellPluginImpl::run(const QString & target, ScribusDoc* doc)
qDebug()<<"Hunspell Init Ok:"<<initOk;
if (!initOk)
return false;
- bool spellCheckOk=checkWithHunspell();
+ bool spellCheckOk=false;
+ if (m_runningForSE)
+ {
+ //qDebug()<<"Running for StoryEditor";
+ spellCheckOk=checkWithHunspellSE();
+ }
+ else
+ {
+ //qDebug()<<"Running for ScribusMainWindow";
+ spellCheckOk=checkWithHunspell();
+ }
if (!spellCheckOk)
return false;
return true;
@@ -126,19 +139,26 @@ bool HunspellPluginImpl::checkWithHunspell()
for( int i = 0; i < m_doc->m_Selection->count(); ++i )
{
frameToCheck = m_doc->m_Selection->itemAt(i);
- parseTextFrame(frameToCheck);
- openGUIForTextFrame(frameToCheck);
+ StoryText *iText=&frameToCheck->itemText;
+ parseTextFrame(iText);
+ openGUIForTextFrame(iText);
m_doc->view()->DrawNew();
}
return true;
}
-bool HunspellPluginImpl::parseTextFrame(PageItem *frameToCheck)
+bool HunspellPluginImpl::checkWithHunspellSE()
+{
+ StoryText *iText=&(m_SE->Editor->StyledText);
+ parseTextFrame(iText);
+ openGUIForStoryEditor(iText);
+ m_SE->Editor->updateAll();
+ return true;
+}
+
+bool HunspellPluginImpl::parseTextFrame(StoryText *iText)
{
- StoryText *iText=&frameToCheck->itemText;
int len=iText->length();
- QString text=iText->text(0,len);
-// qDebug()<<text;
int wordCount=0,wordNo=0,errorCount=0;
int currPos=0;
while (currPos<len)
@@ -185,9 +205,9 @@ bool HunspellPluginImpl::parseTextFrame(PageItem *frameToCheck)
return true;
}
-bool HunspellPluginImpl::openGUIForTextFrame(PageItem *frameToCheck)
+bool HunspellPluginImpl::openGUIForTextFrame(StoryText *iText)
{
- HunspellDialog hsDialog(m_doc->scMW(), m_doc, frameToCheck);
+ HunspellDialog hsDialog(m_doc->scMW(), m_doc, iText);
hsDialog.set(&dictEntries, hspellers, &wordsToCorrect);
hsDialog.exec();
if (hsDialog.docChanged())
@@ -195,3 +215,19 @@ bool HunspellPluginImpl::openGUIForTextFrame(PageItem *frameToCheck)
return true;
}
+bool HunspellPluginImpl::openGUIForStoryEditor(StoryText *iText)
+{
+ m_SE->setSpellActive(true);
+ HunspellDialog hsDialog(m_SE, m_doc, iText);
+ hsDialog.set(&dictEntries, hspellers, &wordsToCorrect);
+ hsDialog.exec();
+ m_SE->setSpellActive(false);
+ return true;
+}
+
+void HunspellPluginImpl::setRunningForSE(bool rfSE, StoryEditor *sE)
+{
+ m_runningForSE=rfSE;
+ m_SE=sE;
+}
+