compile
[kdegraphics.git] / okular / core / scripter.cpp
blob328503525ecbf22a3cf3f92e992f37d0e9187304
1 /***************************************************************************
2 * Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #include "scripter.h"
12 #include <kdebug.h>
14 #include "debug_p.h"
15 #include "script/executor_kjs_p.h"
17 using namespace Okular;
19 class Okular::ScripterPrivate
21 public:
22 ScripterPrivate( DocumentPrivate *doc )
23 : m_doc( doc ), m_kjs( 0 )
27 ~ScripterPrivate()
29 delete m_kjs;
32 DocumentPrivate *m_doc;
33 ExecutorKJS *m_kjs;
36 Scripter::Scripter( DocumentPrivate *doc )
37 : d( new ScripterPrivate( doc ) )
41 Scripter::~Scripter()
43 delete d;
46 QString Scripter::execute( ScriptType type, const QString &script )
48 kDebug(OkularDebug) << "executing the script:";
49 #if 0
50 if ( script.length() < 1000 )
51 qDebug() << script;
52 else
53 qDebug() << script.left( 1000 ) << "[...]";
54 #endif
55 switch ( type )
57 case JavaScript:
58 if ( !d->m_kjs )
60 d->m_kjs = new ExecutorKJS( d->m_doc );
62 d->m_kjs->execute( script );
63 break;
65 return QString();