aspellplugin.cpp
Go to the documentation of this file.00001 /* 00002 For general Scribus (>=1.3.2) copyright and licensing information please refer 00003 to the COPYING file provided with the program. Following this notice may exist 00004 a copyright and/or license notice that predates the release of Scribus 1.3.2 00005 for which a new license (GPL+exception) is in place. 00006 */ 00007 #include "aspellplugin.h" 00008 #include "aspellpluginimpl.h" 00009 00010 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods 00011 // do. That documentatation is not duplicated here. 00012 // Please don't implement the functionality of your plugin here; do that 00013 // in aspellpluginimpl.h and aspellpluginimpl.cpp . 00014 00015 AspellPlugin::AspellPlugin() : ScActionPlugin() 00016 { 00017 // Set action info in languageChange, so we only have to do 00018 // it in one place. 00019 languageChange(); 00020 } 00021 00022 AspellPlugin::~AspellPlugin() {}; 00023 00024 void AspellPlugin::languageChange() 00025 { 00026 // Note that we leave the unused members unset. They'll be initialised 00027 // with their default ctors during construction. 00028 // Action name 00029 m_actionInfo.name = "AspellPlugin"; 00030 // Action text for menu, including &accel 00031 m_actionInfo.text = tr("Spell-Checker"); 00032 // Menu 00033 m_actionInfo.menu = "Item"; 00034 m_actionInfo.notSuitableFor.append(PageItem::Line); 00035 m_actionInfo.notSuitableFor.append(PageItem::LatexFrame); 00036 m_actionInfo.notSuitableFor.append(PageItem::Polygon); 00037 m_actionInfo.notSuitableFor.append(PageItem::PolyLine); 00038 m_actionInfo.notSuitableFor.append(PageItem::ImageFrame); 00039 m_actionInfo.forAppMode.append(modeNormal); 00040 m_actionInfo.needsNumObjects = 1; 00041 // If needed, what item to add the menu item after 00042 //m_actionInfo.menuAfterName = "ColorWheel" 00043 // If needed, the keyboard shortcut for the plugin 00044 // GM: gedit, OpenOffice use F7 for spell-checking. There 00045 //seems to be no standard for KDE apps, other than the 00046 //suggestion of CTRL+ALT+S in the KClipSpellApplet. 00047 m_actionInfo.keySequence = "F7"; 00048 // Should the menu item be enabled when the app starts 00049 // (even without a document open) ? 00050 m_actionInfo.enabledOnStartup = true; 00051 } 00052 00053 const QString AspellPlugin::fullTrName() const 00054 { 00055 return QObject::tr("Spell check (aspell)"); 00056 } 00057 00058 const ScActionPlugin::AboutData* AspellPlugin::getAboutData() const 00059 { 00060 AboutData* about = new AboutData; 00061 Q_CHECK_PTR(about); 00062 about->authors = "Gora Mohanty <gora@srijan.in>"; 00063 about->shortDescription = tr( "Spell-checking support" ); 00064 about->description = 00065 tr( "Adds support for spell-checking via aspell. Languages " 00066 "can be chosen from among the installed aspell " 00067 "dictionaries, and spell-checking can be done on the " 00068 "fly, or on selected text." ); 00069 about->version = tr( "0.1" ); 00070 about->copyright = QString::fromUtf8( "Copyright \xa9 Gora Mohanty <gora@srijan.in>" ); 00071 about->license = "LGPL"; 00072 return about; 00073 } 00074 00075 void AspellPlugin::deleteAboutData(const AboutData* about) const 00076 { 00077 Q_ASSERT(about); 00078 delete about; 00079 } 00080 00081 bool AspellPlugin::run(ScribusDoc* doc, QString target) 00082 { 00083 AspellPluginImpl *myPluginImpl = new AspellPluginImpl( doc ); 00084 Q_CHECK_PTR(myPluginImpl); 00085 myPluginImpl->exec(); 00086 delete myPluginImpl; 00087 return true; 00088 } 00089 00090 // Low level plugin API 00091 int aspellplugin_getPluginAPIVersion() 00092 { 00093 return PLUGIN_API_VERSION; 00094 } 00095 00096 ScPlugin* aspellplugin_getPlugin() 00097 { 00098 AspellPlugin* plug = new AspellPlugin(); 00099 Q_CHECK_PTR(plug); 00100 return plug; 00101 } 00102 00103 void aspellplugin_freePlugin(ScPlugin* plugin) 00104 { 00105 AspellPlugin* plug = dynamic_cast<AspellPlugin*>(plugin); 00106 Q_ASSERT(plug); 00107 delete plug; 00108 }
