Subversion Repositories Scribus

Rev

Rev 16598 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11087 fschmid 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
13805 jghali 7
 
11087 fschmid 8
#include "aspellplugin.h"
9
#include "aspellpluginimpl.h"
13805 jghali 10
#include "scraction.h"
11
#include "scribus.h"
12
#include "scribusdoc.h"
13
#include "pageitem.h"
11087 fschmid 14
 
16546 jghali 15
#include <QMessageBox>
16
 
11087 fschmid 17
// See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
18
// do. That documentatation is not duplicated here.
19
// Please don't implement the functionality of your plugin here; do that
20
// in aspellpluginimpl.h and aspellpluginimpl.cpp .
21
 
22
AspellPlugin::AspellPlugin() : ScActionPlugin()
23
{
24
        // Set action info in languageChange, so we only have to do
25
        // it in one place.
26
        languageChange();
27
}
28
 
29
AspellPlugin::~AspellPlugin() {};
30
 
31
void AspellPlugin::languageChange()
32
{
33
        // Note that we leave the unused members unset. They'll be initialised
34
        // with their default ctors during construction.
35
        // Action name
36
        m_actionInfo.name = "AspellPlugin";
37
        // Action text for menu, including &accel
12240 cbradney 38
        m_actionInfo.text = tr("Spell Checker");
11087 fschmid 39
        // Menu
18070 fschmid 40
        m_actionInfo.menu = "Extras";
11087 fschmid 41
        m_actionInfo.notSuitableFor.append(PageItem::Line);
42
        m_actionInfo.notSuitableFor.append(PageItem::LatexFrame);
43
        m_actionInfo.notSuitableFor.append(PageItem::Polygon);
44
        m_actionInfo.notSuitableFor.append(PageItem::PolyLine);
45
        m_actionInfo.notSuitableFor.append(PageItem::ImageFrame);
18070 fschmid 46
        m_actionInfo.notSuitableFor.append(PageItem::Symbol);
47
        m_actionInfo.notSuitableFor.append(PageItem::RegularPolygon);
48
        m_actionInfo.notSuitableFor.append(PageItem::Arc);
49
        m_actionInfo.notSuitableFor.append(PageItem::Spiral);
11087 fschmid 50
        m_actionInfo.forAppMode.append(modeNormal);
11090 fschmid 51
        m_actionInfo.needsNumObjects = 1;
11087 fschmid 52
        // If needed, what item to add the menu item after
53
        //m_actionInfo.menuAfterName = "ColorWheel"
54
        // If needed, the keyboard shortcut for the plugin
55
        // GM: gedit, OpenOffice use F7 for spell-checking. There
56
        //seems to be no standard for KDE apps, other than the
57
        //suggestion of CTRL+ALT+S in the KClipSpellApplet.
58
        m_actionInfo.keySequence = "F7";
59
        // Should the menu item be enabled when the app starts
60
        // (even without a document open) ?
12240 cbradney 61
        m_actionInfo.enabledOnStartup = false;
11087 fschmid 62
}
63
 
64
const QString AspellPlugin::fullTrName() const
65
{
14832 cbradney 66
        return QObject::tr("Spell check (Aspell)");
11087 fschmid 67
}
68
 
69
const ScActionPlugin::AboutData* AspellPlugin::getAboutData() const
70
{
71
        AboutData* about = new AboutData;
72
        Q_CHECK_PTR(about);
73
        about->authors = "Gora Mohanty <gora@srijan.in>";
74
        about->shortDescription = tr( "Spell-checking support" );
75
        about->description =
14832 cbradney 76
          tr( "Adds support for spell-checking via Aspell. Languages "
77
              "can be chosen from among the installed Aspell "
11087 fschmid 78
              "dictionaries, and spell-checking can be done on the "
79
              "fly, or on selected text." );
80
        about->version = tr( "0.1" );
81
        about->copyright = QString::fromUtf8( "Copyright \xa9 Gora Mohanty <gora@srijan.in>" );
82
        about->license = "LGPL";
83
        return about;
84
}
85
 
86
void AspellPlugin::deleteAboutData(const AboutData* about) const
87
{
88
        Q_ASSERT(about);
89
        delete about;
90
}
91
 
92
bool AspellPlugin::run(ScribusDoc* doc, QString target)
93
{
16598 craig 94
        AspellPluginImpl *aspellPluginImpl = new AspellPluginImpl( doc );
95
        Q_CHECK_PTR(aspellPluginImpl);
12896 subik 96
        // The spellcheck is disabled when there are no available
97
        // dictionaries.
16598 craig 98
        if (aspellPluginImpl->errorMessage().isEmpty())
99
                aspellPluginImpl->exec();
12896 subik 100
        else
101
        {
102
                doc->scMW()->scrActions[m_actionInfo.name]->setEnabled(false);
103
                doc->scMW()->scrActions[m_actionInfo.name]->setVisible(false);
16598 craig 104
                QMessageBox::warning(doc->scMW(), tr("Aspell Plugin Error"), aspellPluginImpl->errorMessage());
12896 subik 105
        }
16598 craig 106
        delete aspellPluginImpl;
11087 fschmid 107
        return true;
108
}
109
 
110
// Low level plugin API
12091 fschmid 111
int x_aspellplugin_getPluginAPIVersion()
11087 fschmid 112
{
113
        return PLUGIN_API_VERSION;
114
}
115
 
12091 fschmid 116
ScPlugin* x_aspellplugin_getPlugin()
11087 fschmid 117
{
118
        AspellPlugin* plug = new AspellPlugin();
119
        Q_CHECK_PTR(plug);
120
        return plug;
121
}
122
 
12091 fschmid 123
void x_aspellplugin_freePlugin(ScPlugin* plugin)
11087 fschmid 124
{
125
        AspellPlugin* plug = dynamic_cast<AspellPlugin*>(plugin);
126
        Q_ASSERT(plug);
127
        delete plug;
128
}