~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kspread/plugins/scripting/ScriptingPart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <kross/core/manager.h>
40
40
 
41
41
typedef KGenericFactory< ScriptingPart > KSpreadScriptingFactory;
42
 
K_EXPORT_COMPONENT_FACTORY( krossmodulekspread, KSpreadScriptingFactory( "krossmodulekspread" ) )
 
42
K_EXPORT_COMPONENT_FACTORY(krossmodulekspread, KSpreadScriptingFactory("krossmodulekspread"))
43
43
 
44
44
/// \internal d-pointer class.
45
45
class ScriptingPart::Private
46
46
{
47
 
        public:
 
47
public:
48
48
};
49
49
 
50
50
ScriptingPart::ScriptingPart(QObject* parent, const QStringList& list)
51
 
    : KoScriptingPart(new ScriptingModule(parent), list)
52
 
    , d(new Private())
 
51
        : KoScriptingPart(new ScriptingModule(parent), list)
 
52
        , d(new Private())
53
53
{
54
54
    setComponentData(ScriptingPart::componentData());
55
 
    setXMLFile(KStandardDirs::locate("data","kspread/kpartplugins/scripting.rc"), true);
56
 
    kDebug() <<"Scripting plugin. Class:" << metaObject()->className() <<", Parent:" << parent->metaObject()->className();
 
55
    setXMLFile(KStandardDirs::locate("data", "kspread/kpartplugins/scripting.rc"), true);
 
56
    kDebug() << "Scripting plugin. Class:" << metaObject()->className() << ", Parent:" << parent->metaObject()->className();
57
57
 
58
58
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
59
 
    if( args ) {
 
59
    if (args) {
60
60
        QStringList errors;
61
61
        foreach(QString ba, args->getOptionList("scriptfile")) {
62
62
            QUrl url(ba);
63
63
            QFileInfo fi(url.path());
64
64
            const QString file = fi.absoluteFilePath();
65
 
            if( ! fi.exists() ) {
 
65
            if (! fi.exists()) {
66
66
                errors << i18n("Scriptfile \"%1\" does not exist.", file);
67
67
                continue;
68
68
            }
69
 
            if( ! fi.isExecutable() ) {
 
69
            if (! fi.isExecutable()) {
70
70
                errors << i18n("Scriptfile \"%1\" is not executable. Please set the executable-attribute on that file.", file);
71
71
                continue;
72
72
            }
76
76
                tmpDirs.append("/tmp/");
77
77
                tmpDirs.append("/var/tmp/");
78
78
                bool inTemp = false;
79
 
                foreach(QString tmpDir, tmpDirs)
80
 
                    if( file.startsWith(tmpDir) ) {
 
79
                foreach(QString tmpDir, tmpDirs) {
 
80
                    if (file.startsWith(tmpDir)) {
81
81
                        inTemp = true;
82
82
                        break;
83
83
                    }
84
 
                if( inTemp ) {
 
84
                }
 
85
                if (inTemp) {
85
86
                    errors << i18n("Scriptfile \"%1\" is in a temporary directory. Execution denied.", file);
86
87
                    continue;
87
88
                }
88
89
            }
89
 
            if( ! Kross::Manager::self().executeScriptFile(url) )
 
90
            if (! Kross::Manager::self().executeScriptFile(url))
90
91
                errors << i18n("Failed to execute scriptfile \"%1\"", file);
91
92
        }
92
 
        if( errors.count() > 0 )
 
93
        if (errors.count() > 0)
93
94
            KMessageBox::errorList(module()->view(), i18n("Errors on execution of scripts."), errors);
94
95
    }
95
96
}