summaryrefslogtreecommitdiffstats
path: root/scribus/plugins/tools/spellcheck/aspellplugin.cpp
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
commit7ed83b6c6666eb8b6b104c211ae7e52907350372 (patch)
tree4430b556abac0ad660a0aacf1887d77f85d8be02 /scribus/plugins/tools/spellcheck/aspellplugin.cpp
downloadscribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.gz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.xz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.zip
Branch 1.3.5 tree to 1.4.x tree, goodbye 1.3.x
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17163 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/plugins/tools/spellcheck/aspellplugin.cpp')
-rw-r--r--scribus/plugins/tools/spellcheck/aspellplugin.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/scribus/plugins/tools/spellcheck/aspellplugin.cpp b/scribus/plugins/tools/spellcheck/aspellplugin.cpp
new file mode 100644
index 0000000..3e51199
--- /dev/null
+++ b/scribus/plugins/tools/spellcheck/aspellplugin.cpp
@@ -0,0 +1,121 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#include "scraction.h"
+#include "aspellplugin.h"
+#include "aspellpluginimpl.h"
+
+// See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
+// do. That documentatation is not duplicated here.
+// Please don't implement the functionality of your plugin here; do that
+// in aspellpluginimpl.h and aspellpluginimpl.cpp .
+
+AspellPlugin::AspellPlugin() : ScActionPlugin()
+{
+ // Set action info in languageChange, so we only have to do
+ // it in one place.
+ languageChange();
+}
+
+AspellPlugin::~AspellPlugin() {};
+
+void AspellPlugin::languageChange()
+{
+ // Note that we leave the unused members unset. They'll be initialised
+ // with their default ctors during construction.
+ // Action name
+ m_actionInfo.name = "AspellPlugin";
+ // Action text for menu, including &accel
+ m_actionInfo.text = tr("Spell Checker");
+ // Menu
+ m_actionInfo.menu = "Item";
+ m_actionInfo.notSuitableFor.append(PageItem::Line);
+ m_actionInfo.notSuitableFor.append(PageItem::LatexFrame);
+ m_actionInfo.notSuitableFor.append(PageItem::Polygon);
+ m_actionInfo.notSuitableFor.append(PageItem::PolyLine);
+ m_actionInfo.notSuitableFor.append(PageItem::ImageFrame);
+ m_actionInfo.forAppMode.append(modeNormal);
+ m_actionInfo.needsNumObjects = 1;
+ // If needed, what item to add the menu item after
+ //m_actionInfo.menuAfterName = "ColorWheel"
+ // If needed, the keyboard shortcut for the plugin
+ // GM: gedit, OpenOffice use F7 for spell-checking. There
+ //seems to be no standard for KDE apps, other than the
+ //suggestion of CTRL+ALT+S in the KClipSpellApplet.
+ m_actionInfo.keySequence = "F7";
+ // Should the menu item be enabled when the app starts
+ // (even without a document open) ?
+ m_actionInfo.enabledOnStartup = false;
+}
+
+const QString AspellPlugin::fullTrName() const
+{
+ return QObject::tr("Spell check (aspell)");
+}
+
+const ScActionPlugin::AboutData* AspellPlugin::getAboutData() const
+{
+ AboutData* about = new AboutData;
+ Q_CHECK_PTR(about);
+ about->authors = "Gora Mohanty <gora@srijan.in>";
+ about->shortDescription = tr( "Spell-checking support" );
+ about->description =
+ tr( "Adds support for spell-checking via aspell. Languages "
+ "can be chosen from among the installed aspell "
+ "dictionaries, and spell-checking can be done on the "
+ "fly, or on selected text." );
+ about->version = tr( "0.1" );
+ about->copyright = QString::fromUtf8( "Copyright \xa9 Gora Mohanty <gora@srijan.in>" );
+ about->license = "LGPL";
+ return about;
+}
+
+void AspellPlugin::deleteAboutData(const AboutData* about) const
+{
+ Q_ASSERT(about);
+ delete about;
+}
+
+bool AspellPlugin::run(ScribusDoc* doc, QString target)
+{
+ AspellPluginImpl *aspellPluginImpl = new AspellPluginImpl( doc );
+ Q_CHECK_PTR(aspellPluginImpl);
+ // The spellcheck is disabled when there are no available
+ // dictionaries.
+ if (aspellPluginImpl->errorMessage().isEmpty())
+ {
+// qDebug()<<"Running aspell plugin";
+ aspellPluginImpl->exec();
+ }
+ else
+ {
+ doc->scMW()->scrActions[m_actionInfo.name]->setEnabled(false);
+ doc->scMW()->scrActions[m_actionInfo.name]->setVisible(false);
+ QMessageBox::warning(doc->scMW(), tr("Aspell Plugin Error"), aspellPluginImpl->errorMessage());
+ }
+ delete aspellPluginImpl;
+ return true;
+}
+
+// Low level plugin API
+int x_aspellplugin_getPluginAPIVersion()
+{
+ return PLUGIN_API_VERSION;
+}
+
+ScPlugin* x_aspellplugin_getPlugin()
+{
+ AspellPlugin* plug = new AspellPlugin();
+ Q_CHECK_PTR(plug);
+ return plug;
+}
+
+void x_aspellplugin_freePlugin(ScPlugin* plugin)
+{
+ AspellPlugin* plug = dynamic_cast<AspellPlugin*>(plugin);
+ Q_ASSERT(plug);
+ delete plug;
+}