Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
17437 craig 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
*/
7
#include "hunspellplugin.h"
8
#include "hunspellpluginimpl.h"
9
#include "scribuscore.h"
17485 craig 10
#include "storyeditor.h"
17437 craig 11
 
12
// See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
13
// do. That documentatation is not duplicated here.
14
// Please don't implement the functionality of your plugin here; do that
15
// in mypluginimpl.h and mypluginimpl.cpp .
16
 
17
HunspellPlugin::HunspellPlugin() : ScActionPlugin()
18
{
19
        // Set action info in languageChange, so we only have to do
20
        // it in one place.
21
        languageChange();
22
}
23
 
24
HunspellPlugin::~HunspellPlugin() {};
25
 
26
void HunspellPlugin::languageChange()
27
{
28
        // Note that we leave the unused members unset. They'll be initialised
29
        // with their default ctors during construction.
30
        // Action name
31
        m_actionInfo.name = "HunspellPlugin";
32
        // Action text for menu, including &accel
17485 craig 33
        m_actionInfo.text = tr("Check Spelling...");
17437 craig 34
        // Menu
35
        m_actionInfo.menu = "Item";
17485 craig 36
        // Story Editor Menu
37
        m_actionInfo.seMenu = "Edit";
17437 craig 38
        // If needed, what item to add the menu item after
39
        //m_actionInfo.menuAfterName = "ColorWheel"
40
        // If needed, the keyboard shortcut for the plugin
41
        m_actionInfo.keySequence = "SHIFT+F7";
42
        // Should the menu item be enabled when the app starts
43
        // (even without a document open) ?
44
        m_actionInfo.enabledOnStartup = false;
17485 craig 45
        m_actionInfo.enabledForStoryEditor = true;
17437 craig 46
        m_actionInfo.notSuitableFor.append(PageItem::Line);
47
        m_actionInfo.notSuitableFor.append(PageItem::Polygon);
48
        m_actionInfo.notSuitableFor.append(PageItem::ImageFrame);
49
        m_actionInfo.notSuitableFor.append(PageItem::PathText);
50
        m_actionInfo.notSuitableFor.append(PageItem::LatexFrame);
51
        m_actionInfo.needsNumObjects = 1;
52
}
53
 
54
const QString HunspellPlugin::fullTrName() const
55
{
56
        return QObject::tr("Hunspell Plugin");
57
}
58
 
59
const ScActionPlugin::AboutData* HunspellPlugin::getAboutData() const
60
{
18088 craig 61
        AboutData* about = new AboutData;
62
        Q_CHECK_PTR(about);
63
        about->authors = QString::fromUtf8("Craig Bradney <cbradney@scribus.info>, The Scribus Team");
64
        about->shortDescription = tr("Hunspell-based spell checker");
65
        about->description = tr("Spell Checker based on the Hunspell libraries");
66
        // about->version
67
        // about->releaseDate
68
        about->copyright = "The Scribus Team";
69
        about->license = "GPL";
70
        return about;
71
 
72
 
17437 craig 73
}
74
 
75
void HunspellPlugin::deleteAboutData(const AboutData* about) const
76
{
77
        Q_ASSERT(about);
78
        delete about;
79
}
80
 
81
bool HunspellPlugin::run(ScribusDoc* doc, QString target)
82
{
83
        HunspellPluginImpl *hunspellPluginImpl = new HunspellPluginImpl();
84
        Q_CHECK_PTR(hunspellPluginImpl);
85
        bool result = hunspellPluginImpl->run(target, doc);
86
        delete hunspellPluginImpl;
87
        return result;
88
}
89
 
17485 craig 90
bool HunspellPlugin::run(QWidget *parent, ScribusDoc *doc, QString target)
91
{
92
        HunspellPluginImpl *hunspellPluginImpl = new HunspellPluginImpl();
93
        Q_CHECK_PTR(hunspellPluginImpl);
94
        if (parent)
95
                hunspellPluginImpl->setRunningForSE(true, dynamic_cast<StoryEditor*>(parent));
96
        bool result = hunspellPluginImpl->run(target, doc);
97
        delete hunspellPluginImpl;
98
        return result;
99
}
100
 
17437 craig 101
// Low level plugin API
102
int hunspellplugin_getPluginAPIVersion()
103
{
104
        return PLUGIN_API_VERSION;
105
}
106
 
107
ScPlugin* hunspellplugin_getPlugin()
108
{
109
        HunspellPlugin* plug = new HunspellPlugin();
110
        Q_CHECK_PTR(plug);
111
        return plug;
112
}
113
 
114
void hunspellplugin_freePlugin(ScPlugin* plugin)
115
{
116
        HunspellPlugin* plug = dynamic_cast<HunspellPlugin*>(plugin);
117
        Q_ASSERT(plug);
118
        delete plug;
119
}