mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
removed JS support for Okular (requires KJS)
This commit is contained in:
parent
f1d0baea94
commit
e0626560ea
23 changed files with 2 additions and 1725 deletions
|
@ -61,7 +61,6 @@ set(okularcore_SRCS
|
|||
core/pagesize.cpp
|
||||
core/pagetransition.cpp
|
||||
core/rotationjob.cpp
|
||||
core/scripter.cpp
|
||||
core/sound.cpp
|
||||
core/sourcereference.cpp
|
||||
core/textdocumentgenerator.cpp
|
||||
|
@ -71,15 +70,6 @@ set(okularcore_SRCS
|
|||
core/utils.cpp
|
||||
core/view.cpp
|
||||
core/fileprinter.cpp
|
||||
core/script/executor_kjs.cpp
|
||||
core/script/kjs_app.cpp
|
||||
core/script/kjs_console.cpp
|
||||
core/script/kjs_data.cpp
|
||||
core/script/kjs_document.cpp
|
||||
core/script/kjs_fullscreen.cpp
|
||||
core/script/kjs_field.cpp
|
||||
core/script/kjs_spell.cpp
|
||||
core/script/kjs_util.cpp
|
||||
)
|
||||
|
||||
kde4_add_ui_files(okularcore_SRCS
|
||||
|
@ -128,12 +118,7 @@ kde4_add_kcfg_files(okularcore_SRCS conf/settings_core.kcfgc )
|
|||
|
||||
kde4_add_library(okularcore SHARED ${okularcore_SRCS})
|
||||
|
||||
# Special handling for linking okularcore on OSX/Apple
|
||||
IF(APPLE)
|
||||
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
|
||||
ENDIF(APPLE)
|
||||
|
||||
target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBRARY} ${KDE4_KJSAPI_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
|
||||
target_link_libraries(okularcore ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
|
||||
|
||||
if(LibKScreen_FOUND)
|
||||
target_link_libraries(okularcore ${LibKScreen_LIBRARY})
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
#include "page.h"
|
||||
#include "page_p.h"
|
||||
#include "pagecontroller_p.h"
|
||||
#include "scripter.h"
|
||||
#include "settings_core.h"
|
||||
#include "sourcereference.h"
|
||||
#include "sourcereference_p.h"
|
||||
|
@ -2319,16 +2318,6 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
|
|||
AudioPlayer::instance()->d->m_currentDocument = isstdin ? KUrl() : d->m_url;
|
||||
d->m_docSize = document_size;
|
||||
|
||||
const QStringList docScripts = d->m_generator->metaData( "DocumentScripts", "JavaScript" ).toStringList();
|
||||
if ( !docScripts.isEmpty() )
|
||||
{
|
||||
d->m_scripter = new Scripter( d );
|
||||
Q_FOREACH ( const QString &docscript, docScripts )
|
||||
{
|
||||
d->m_scripter->execute( JavaScript, docscript );
|
||||
}
|
||||
}
|
||||
|
||||
return OpenSuccess;
|
||||
}
|
||||
|
||||
|
@ -2353,9 +2342,6 @@ void Document::closeDocument()
|
|||
delete d->m_pageController;
|
||||
d->m_pageController = 0;
|
||||
|
||||
delete d->m_scripter;
|
||||
d->m_scripter = 0;
|
||||
|
||||
// remove requests left in queue
|
||||
d->m_pixmapRequestsMutex.lock();
|
||||
QLinkedList< PixmapRequest * >::const_iterator sIt = d->m_pixmapRequestsStack.constBegin();
|
||||
|
@ -3750,28 +3736,12 @@ void Document::processAction( const Action * action )
|
|||
AudioPlayer::instance()->playSound( linksound->sound(), linksound );
|
||||
} break;
|
||||
|
||||
case Action::Script: {
|
||||
const ScriptAction * linkscript = static_cast< const ScriptAction * >( action );
|
||||
if ( !d->m_scripter )
|
||||
d->m_scripter = new Scripter( d );
|
||||
d->m_scripter->execute( linkscript->scriptType(), linkscript->script() );
|
||||
} break;
|
||||
|
||||
case Action::Movie:
|
||||
emit processMovieAction( static_cast< const MovieAction * >( action ) );
|
||||
break;
|
||||
case Action::Rendition: {
|
||||
const RenditionAction * linkrendition = static_cast< const RenditionAction * >( action );
|
||||
if ( !linkrendition->script().isEmpty() )
|
||||
{
|
||||
if ( !d->m_scripter )
|
||||
d->m_scripter = new Scripter( d );
|
||||
d->m_scripter->execute( linkrendition->scriptType(), linkrendition->script() );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit processRenditionAction( static_cast< const RenditionAction * >( action ) );
|
||||
}
|
||||
emit processRenditionAction( static_cast< const RenditionAction * >( action ) );
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace Okular {
|
|||
class ConfigInterface;
|
||||
class PageController;
|
||||
class SaveInterface;
|
||||
class Scripter;
|
||||
class View;
|
||||
}
|
||||
|
||||
|
@ -93,7 +92,6 @@ class DocumentPrivate
|
|||
m_generatorsLoaded( false ),
|
||||
m_pageController( 0 ),
|
||||
m_closingLoop( 0 ),
|
||||
m_scripter( 0 ),
|
||||
m_archiveData( 0 ),
|
||||
m_fontsCached( false ),
|
||||
m_documentInfo( 0 ),
|
||||
|
@ -251,8 +249,6 @@ class DocumentPrivate
|
|||
PageController *m_pageController;
|
||||
QEventLoop *m_closingLoop;
|
||||
|
||||
Scripter *m_scripter;
|
||||
|
||||
ArchiveData *m_archiveData;
|
||||
QString m_archivedFileName;
|
||||
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "executor_kjs_p.h"
|
||||
|
||||
#include <kjs/kjsinterpreter.h>
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
#include <kjs/kjsarguments.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "../debug_p.h"
|
||||
#include "../document_p.h"
|
||||
|
||||
#include "kjs_app_p.h"
|
||||
#include "kjs_console_p.h"
|
||||
#include "kjs_data_p.h"
|
||||
#include "kjs_document_p.h"
|
||||
#include "kjs_field_p.h"
|
||||
#include "kjs_fullscreen_p.h"
|
||||
#include "kjs_spell_p.h"
|
||||
#include "kjs_util_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
class Okular::ExecutorKJSPrivate
|
||||
{
|
||||
public:
|
||||
ExecutorKJSPrivate( DocumentPrivate *doc )
|
||||
: m_doc( doc )
|
||||
{
|
||||
initTypes();
|
||||
}
|
||||
~ExecutorKJSPrivate()
|
||||
{
|
||||
JSField::clearCachedFields();
|
||||
|
||||
delete m_interpreter;
|
||||
}
|
||||
|
||||
void initTypes();
|
||||
|
||||
DocumentPrivate *m_doc;
|
||||
KJSInterpreter *m_interpreter;
|
||||
KJSGlobalObject m_docObject;
|
||||
};
|
||||
|
||||
void ExecutorKJSPrivate::initTypes()
|
||||
{
|
||||
m_docObject = JSDocument::wrapDocument( m_doc );
|
||||
m_interpreter = new KJSInterpreter( m_docObject );
|
||||
|
||||
KJSContext *ctx = m_interpreter->globalContext();
|
||||
|
||||
JSApp::initType( ctx );
|
||||
JSFullscreen::initType( ctx );
|
||||
JSConsole::initType( ctx );
|
||||
JSData::initType( ctx );
|
||||
JSDocument::initType( ctx );
|
||||
JSField::initType( ctx );
|
||||
JSSpell::initType( ctx );
|
||||
JSUtil::initType( ctx );
|
||||
|
||||
m_docObject.setProperty( ctx, "app", JSApp::object( ctx, m_doc ) );
|
||||
m_docObject.setProperty( ctx, "console", JSConsole::object( ctx ) );
|
||||
m_docObject.setProperty( ctx, "Doc", m_docObject );
|
||||
m_docObject.setProperty( ctx, "spell", JSSpell::object( ctx ) );
|
||||
m_docObject.setProperty( ctx, "util", JSUtil::object( ctx ) );
|
||||
}
|
||||
|
||||
ExecutorKJS::ExecutorKJS( DocumentPrivate *doc )
|
||||
: d( new ExecutorKJSPrivate( doc ) )
|
||||
{
|
||||
}
|
||||
|
||||
ExecutorKJS::~ExecutorKJS()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ExecutorKJS::execute( const QString &script )
|
||||
{
|
||||
#if 0
|
||||
QString script2;
|
||||
QString errMsg;
|
||||
int errLine;
|
||||
if ( !KJSInterpreter::normalizeCode( script, &script2, &errLine, &errMsg ) )
|
||||
{
|
||||
kWarning(OkularDebug) << "Parse error during normalization!";
|
||||
script2 = script;
|
||||
}
|
||||
#endif
|
||||
|
||||
KJSResult result = d->m_interpreter->evaluate( "okular.js", 1,
|
||||
script, &d->m_docObject );
|
||||
KJSContext* ctx = d->m_interpreter->globalContext();
|
||||
if ( result.isException() || ctx->hasException() )
|
||||
{
|
||||
kDebug(OkularDebug) << "JS exception" << result.errorMessage();
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug(OkularDebug) << "result:" << result.value().toString( ctx );
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_EXECUTOR_KJS_P_H
|
||||
#define OKULAR_SCRIPT_EXECUTOR_KJS_P_H
|
||||
|
||||
class QString;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class DocumentPrivate;
|
||||
class ExecutorKJSPrivate;
|
||||
|
||||
class ExecutorKJS
|
||||
{
|
||||
public:
|
||||
ExecutorKJS( DocumentPrivate *doc );
|
||||
~ExecutorKJS();
|
||||
|
||||
void execute( const QString &script );
|
||||
|
||||
private:
|
||||
friend class ExecutorKJSPrivate;
|
||||
ExecutorKJSPrivate* d;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,232 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_app_p.h"
|
||||
|
||||
#include <kjs/kjsarguments.h>
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <kglobal.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "../document_p.h"
|
||||
#include "kjs_fullscreen_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_appProto;
|
||||
|
||||
// the acrobat version we fake
|
||||
static const double fake_acroversion = 8.00;
|
||||
|
||||
static const struct FakePluginInfo {
|
||||
const char *name;
|
||||
bool certified;
|
||||
bool loaded;
|
||||
const char *path;
|
||||
} s_fake_plugins[] = {
|
||||
{ "Annots", true, true, "" },
|
||||
{ "EFS", true, true, "" },
|
||||
{ "EScript", true, true, "" },
|
||||
{ "Forms", true, true, "" },
|
||||
{ "ReadOutLoud", true, true, "" },
|
||||
{ "WebLink", true, true, "" }
|
||||
};
|
||||
static const int s_num_fake_plugins = sizeof( s_fake_plugins ) / sizeof( s_fake_plugins[0] );
|
||||
|
||||
|
||||
static KJSObject appGetFormsVersion( KJSContext *, void * )
|
||||
{
|
||||
// faking a bit...
|
||||
return KJSNumber( fake_acroversion );
|
||||
}
|
||||
|
||||
static KJSObject appGetLanguage( KJSContext *, void * )
|
||||
{
|
||||
QString lang;
|
||||
QString country;
|
||||
QString dummy;
|
||||
KLocale::splitLocale( KGlobal::locale()->language(),
|
||||
lang, country, dummy, dummy );
|
||||
QString acroLang = QString::fromLatin1( "ENU" );
|
||||
if ( lang == QLatin1String( "da" ) )
|
||||
acroLang = QString::fromLatin1( "DAN" ); // Danish
|
||||
else if ( lang == QLatin1String( "de" ) )
|
||||
acroLang = QString::fromLatin1( "DEU" ); // German
|
||||
else if ( lang == QLatin1String( "en" ) )
|
||||
acroLang = QString::fromLatin1( "ENU" ); // English
|
||||
else if ( lang == QLatin1String( "es" ) )
|
||||
acroLang = QString::fromLatin1( "ESP" ); // Spanish
|
||||
else if ( lang == QLatin1String( "fr" ) )
|
||||
acroLang = QString::fromLatin1( "FRA" ); // French
|
||||
else if ( lang == QLatin1String( "it" ) )
|
||||
acroLang = QString::fromLatin1( "ITA" ); // Italian
|
||||
else if ( lang == QLatin1String( "ko" ) )
|
||||
acroLang = QString::fromLatin1( "KOR" ); // Korean
|
||||
else if ( lang == QLatin1String( "ja" ) )
|
||||
acroLang = QString::fromLatin1( "JPN" ); // Japanese
|
||||
else if ( lang == QLatin1String( "nl" ) )
|
||||
acroLang = QString::fromLatin1( "NLD" ); // Dutch
|
||||
else if ( lang == QLatin1String( "pt" ) && country == QLatin1String( "BR" ) )
|
||||
acroLang = QString::fromLatin1( "PTB" ); // Brazilian Portuguese
|
||||
else if ( lang == QLatin1String( "fi" ) )
|
||||
acroLang = QString::fromLatin1( "SUO" ); // Finnish
|
||||
else if ( lang == QLatin1String( "sv" ) )
|
||||
acroLang = QString::fromLatin1( "SVE" ); // Swedish
|
||||
else if ( lang == QLatin1String( "zh" ) && country == QLatin1String( "CN" ) )
|
||||
acroLang = QString::fromLatin1( "CHS" ); // Chinese Simplified
|
||||
else if ( lang == QLatin1String( "zh" ) && country == QLatin1String( "TW" ) )
|
||||
acroLang = QString::fromLatin1( "CHT" ); // Chinese Traditional
|
||||
return KJSString( acroLang );
|
||||
}
|
||||
|
||||
static KJSObject appGetNumPlugins( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( s_num_fake_plugins );
|
||||
}
|
||||
|
||||
static KJSObject appGetPlatform( KJSContext *, void * )
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
return KJSString( QString::fromLatin1( "WIN" ) );
|
||||
#elif defined(Q_OS_MAC)
|
||||
return KJSString( QString::fromLatin1( "MAC" ) );
|
||||
#else
|
||||
return KJSString( QString::fromLatin1( "UNIX" ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
static KJSObject appGetPlugIns( KJSContext *context, void * )
|
||||
{
|
||||
KJSArray plugins( context, s_num_fake_plugins );
|
||||
for ( int i = 0; i < s_num_fake_plugins; ++i )
|
||||
{
|
||||
const FakePluginInfo &info = s_fake_plugins[i];
|
||||
KJSObject plugin;
|
||||
plugin.setProperty( context, "certified", info.certified );
|
||||
plugin.setProperty( context, "loaded", info.loaded );
|
||||
plugin.setProperty( context, "name", info.name );
|
||||
plugin.setProperty( context, "path", info.path );
|
||||
plugin.setProperty( context, "version", fake_acroversion );
|
||||
plugins.setProperty( context, QString::number( i ), plugin );
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
static KJSObject appGetPrintColorProfiles( KJSContext *context, void * )
|
||||
{
|
||||
return KJSArray( context, 0 );
|
||||
}
|
||||
|
||||
static KJSObject appGetPrinterNames( KJSContext *context, void * )
|
||||
{
|
||||
return KJSArray( context, 0 );
|
||||
}
|
||||
|
||||
static KJSObject appGetViewerType( KJSContext *, void * )
|
||||
{
|
||||
// faking a bit...
|
||||
return KJSString( QString::fromLatin1( "Reader" ) );
|
||||
}
|
||||
|
||||
static KJSObject appGetViewerVariation( KJSContext *, void * )
|
||||
{
|
||||
// faking a bit...
|
||||
return KJSString( QString::fromLatin1( "Reader" ) );
|
||||
}
|
||||
|
||||
static KJSObject appGetViewerVersion( KJSContext *, void * )
|
||||
{
|
||||
// faking a bit...
|
||||
return KJSNumber( fake_acroversion );
|
||||
}
|
||||
|
||||
static KJSObject appBeep( KJSContext *context, void *,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
if ( arguments.count() < 1 )
|
||||
{
|
||||
return context->throwException( "Missing beep type" );
|
||||
}
|
||||
QApplication::beep();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
static KJSObject appGetNthPlugInName( KJSContext *context, void *,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
if ( arguments.count() < 1 )
|
||||
{
|
||||
return context->throwException( "Missing plugin index" );
|
||||
}
|
||||
const int nIndex = arguments.at( 0 ).toInt32( context );
|
||||
|
||||
if ( nIndex < 0 || nIndex >= s_num_fake_plugins )
|
||||
return context->throwException( "PlugIn index out of bounds" );
|
||||
|
||||
const FakePluginInfo &info = s_fake_plugins[nIndex];
|
||||
return KJSString( info.name );
|
||||
}
|
||||
|
||||
static KJSObject appGoBack( KJSContext *, void *object,
|
||||
const KJSArguments & )
|
||||
{
|
||||
const DocumentPrivate *doc = reinterpret_cast< DocumentPrivate * >( object );
|
||||
if ( doc->m_parent->historyAtBegin() )
|
||||
return KJSUndefined();
|
||||
|
||||
doc->m_parent->setPrevViewport();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
static KJSObject appGoForward( KJSContext *, void *object,
|
||||
const KJSArguments & )
|
||||
{
|
||||
const DocumentPrivate *doc = reinterpret_cast< DocumentPrivate * >( object );
|
||||
if ( doc->m_parent->historyAtEnd() )
|
||||
return KJSUndefined();
|
||||
|
||||
doc->m_parent->setNextViewport();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
void JSApp::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
g_appProto = new KJSPrototype();
|
||||
|
||||
g_appProto->defineProperty( ctx, "formsVersion", appGetFormsVersion );
|
||||
g_appProto->defineProperty( ctx, "language", appGetLanguage );
|
||||
g_appProto->defineProperty( ctx, "numPlugIns", appGetNumPlugins );
|
||||
g_appProto->defineProperty( ctx, "platform", appGetPlatform );
|
||||
g_appProto->defineProperty( ctx, "plugIns", appGetPlugIns );
|
||||
g_appProto->defineProperty( ctx, "printColorProfiles", appGetPrintColorProfiles );
|
||||
g_appProto->defineProperty( ctx, "printerNames", appGetPrinterNames );
|
||||
g_appProto->defineProperty( ctx, "viewerType", appGetViewerType );
|
||||
g_appProto->defineProperty( ctx, "viewerVariation", appGetViewerVariation );
|
||||
g_appProto->defineProperty( ctx, "viewerVersion", appGetViewerVersion );
|
||||
|
||||
g_appProto->defineFunction( ctx, "beep", appBeep );
|
||||
g_appProto->defineFunction( ctx, "getNthPlugInName", appGetNthPlugInName );
|
||||
g_appProto->defineFunction( ctx, "goBack", appGoBack );
|
||||
g_appProto->defineFunction( ctx, "goForward", appGoForward );
|
||||
}
|
||||
|
||||
KJSObject JSApp::object( KJSContext *ctx, DocumentPrivate *doc )
|
||||
{
|
||||
return g_appProto->constructObject( ctx, doc );
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_APP_P_H
|
||||
#define OKULAR_SCRIPT_KJS_APP_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class DocumentPrivate;
|
||||
|
||||
class JSApp
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject object( KJSContext *ctx, DocumentPrivate *doc );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,150 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_console_p.h"
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
#include <kjs/kjsarguments.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "../debug_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_consoleProto;
|
||||
|
||||
#ifdef OKULAR_JS_CONSOLE
|
||||
|
||||
#include <qlayout.h>
|
||||
#include <qplaintextedit.h>
|
||||
|
||||
#include <kdialog.h>
|
||||
#include <kstandardguiitem.h>
|
||||
|
||||
K_GLOBAL_STATIC( KDialog, g_jsConsoleWindow )
|
||||
static QPlainTextEdit *g_jsConsoleLog = 0;
|
||||
|
||||
static void createConsoleWindow()
|
||||
{
|
||||
if ( g_jsConsoleWindow.exists() )
|
||||
return;
|
||||
|
||||
g_jsConsoleWindow->setButtons( KDialog::Close | KDialog::User1 );
|
||||
g_jsConsoleWindow->setButtonGuiItem( KDialog::User1, KStandardGuiItem::clear() );
|
||||
|
||||
QVBoxLayout *mainLay = new QVBoxLayout( g_jsConsoleWindow->mainWidget() );
|
||||
mainLay->setMargin( 0 );
|
||||
g_jsConsoleLog = new QPlainTextEdit( g_jsConsoleWindow->mainWidget() );
|
||||
g_jsConsoleLog->setReadOnly( true );
|
||||
mainLay->addWidget( g_jsConsoleLog );
|
||||
|
||||
QObject::connect( g_jsConsoleWindow, SIGNAL(closeClicked()),
|
||||
g_jsConsoleWindow, SLOT(close()) );
|
||||
QObject::connect( g_jsConsoleWindow, SIGNAL(user1Clicked()),
|
||||
g_jsConsoleLog, SLOT(clear()) );
|
||||
}
|
||||
|
||||
static void showConsole()
|
||||
{
|
||||
createConsoleWindow();
|
||||
g_jsConsoleWindow->show();
|
||||
}
|
||||
|
||||
static void hideConsole()
|
||||
{
|
||||
if ( !g_jsConsoleWindow.exists() )
|
||||
return;
|
||||
|
||||
g_jsConsoleWindow->hide();
|
||||
}
|
||||
|
||||
static void clearConsole()
|
||||
{
|
||||
if ( !g_jsConsoleWindow.exists() )
|
||||
return;
|
||||
|
||||
g_jsConsoleLog->clear();
|
||||
}
|
||||
|
||||
static void outputToConsole( const QString &message )
|
||||
{
|
||||
showConsole();
|
||||
g_jsConsoleLog->appendPlainText( message );
|
||||
}
|
||||
|
||||
#else /* OKULAR_JS_CONSOLE */
|
||||
|
||||
static void showConsole()
|
||||
{
|
||||
}
|
||||
|
||||
static void hideConsole()
|
||||
{
|
||||
}
|
||||
|
||||
static void clearConsole()
|
||||
{
|
||||
}
|
||||
|
||||
static void outputToConsole( const QString &cMessage )
|
||||
{
|
||||
kDebug(OkularDebug) << "CONSOLE:" << cMessage;
|
||||
}
|
||||
|
||||
#endif /* OKULAR_JS_CONSOLE */
|
||||
|
||||
static KJSObject consoleClear( KJSContext *, void *, const KJSArguments & )
|
||||
{
|
||||
clearConsole();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
static KJSObject consoleHide( KJSContext *, void *, const KJSArguments & )
|
||||
{
|
||||
hideConsole();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
static KJSObject consolePrintln( KJSContext *ctx, void *,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
QString cMessage = arguments.at( 0 ).toString( ctx );
|
||||
outputToConsole( cMessage );
|
||||
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
static KJSObject consoleShow( KJSContext *, void *, const KJSArguments & )
|
||||
{
|
||||
showConsole();
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
void JSConsole::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
g_consoleProto = new KJSPrototype();
|
||||
|
||||
g_consoleProto->defineFunction( ctx, "clear", consoleClear );
|
||||
g_consoleProto->defineFunction( ctx, "hide", consoleHide );
|
||||
g_consoleProto->defineFunction( ctx, "println", consolePrintln );
|
||||
g_consoleProto->defineFunction( ctx, "hide", consoleShow );
|
||||
}
|
||||
|
||||
KJSObject JSConsole::object( KJSContext *ctx )
|
||||
{
|
||||
return g_consoleProto->constructObject( ctx, 0 );
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_CONSOLE_P_H
|
||||
#define OKULAR_SCRIPT_KJS_CONSOLE_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class JSConsole
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject object( KJSContext *ctx );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,90 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_data_p.h"
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
|
||||
#include <qdatetime.h>
|
||||
|
||||
#include "../document.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_dataProto;
|
||||
|
||||
static KJSObject dataGetCreationDate( KJSContext *ctx, void *object )
|
||||
{
|
||||
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
|
||||
|
||||
return KJSDate( ctx, file->creationDate() );
|
||||
}
|
||||
|
||||
static KJSObject dataGetDescription( KJSContext *, void *object )
|
||||
{
|
||||
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
|
||||
|
||||
return KJSString( file->description() );
|
||||
}
|
||||
|
||||
static KJSObject dataGetMIMEType( KJSContext *, void * )
|
||||
{
|
||||
return KJSString( "" );
|
||||
}
|
||||
|
||||
static KJSObject dataGetModDate( KJSContext *ctx, void *object )
|
||||
{
|
||||
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
|
||||
|
||||
return KJSDate( ctx, file->modificationDate() );
|
||||
}
|
||||
|
||||
static KJSObject dataGetName( KJSContext *, void *object )
|
||||
{
|
||||
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
|
||||
|
||||
return KJSString( file->name() );
|
||||
}
|
||||
|
||||
static KJSObject dataGetPath( KJSContext *, void * )
|
||||
{
|
||||
return KJSString( "" );
|
||||
}
|
||||
|
||||
static KJSObject dataGetSize( KJSContext *, void *object )
|
||||
{
|
||||
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
|
||||
return KJSNumber( file->size() );
|
||||
}
|
||||
|
||||
void JSData::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
if ( !g_dataProto )
|
||||
g_dataProto = new KJSPrototype();
|
||||
|
||||
g_dataProto->defineProperty( ctx, "creationDate", dataGetCreationDate );
|
||||
g_dataProto->defineProperty( ctx, "description", dataGetDescription );
|
||||
g_dataProto->defineProperty( ctx, "MIMEType", dataGetMIMEType );
|
||||
g_dataProto->defineProperty( ctx, "modDate", dataGetModDate );
|
||||
g_dataProto->defineProperty( ctx, "name", dataGetName );
|
||||
g_dataProto->defineProperty( ctx, "path", dataGetPath );
|
||||
g_dataProto->defineProperty( ctx, "size", dataGetSize );
|
||||
}
|
||||
|
||||
KJSObject JSData::wrapFile( KJSContext *ctx, EmbeddedFile *f )
|
||||
{
|
||||
return g_dataProto->constructObject( ctx, f );
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_DATA_P_H
|
||||
#define OKULAR_SCRIPT_KJS_DATA_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class EmbeddedFile;
|
||||
|
||||
class JSData
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject wrapFile( KJSContext *ctx, EmbeddedFile *f );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,287 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_document_p.h"
|
||||
|
||||
#include <qwidget.h>
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
#include <kjs/kjsarguments.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../document_p.h"
|
||||
#include "../page.h"
|
||||
#include "../form.h"
|
||||
#include "kjs_data_p.h"
|
||||
#include "kjs_field_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_docProto;
|
||||
|
||||
// Document.numPages
|
||||
static KJSObject docGetNumPages( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSNumber( doc->m_pagesVector.count() );
|
||||
}
|
||||
|
||||
// Document.pageNum (getter)
|
||||
static KJSObject docGetPageNum( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSNumber( doc->m_parent->currentPage() );
|
||||
}
|
||||
|
||||
// Document.pageNum (setter)
|
||||
static void docSetPageNum( KJSContext* ctx, void* object,
|
||||
KJSObject value )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
int page = value.toInt32( ctx );
|
||||
|
||||
if ( page == (int)doc->m_parent->currentPage() )
|
||||
return;
|
||||
|
||||
doc->m_parent->setViewportPage( page );
|
||||
}
|
||||
|
||||
// Document.documentFileName
|
||||
static KJSObject docGetDocumentFileName( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSString( doc->m_url.fileName() );
|
||||
}
|
||||
|
||||
// Document.filesize
|
||||
static KJSObject docGetFilesize( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSNumber( doc->m_docSize );
|
||||
}
|
||||
|
||||
// Document.path
|
||||
static KJSObject docGetPath( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSString( doc->m_url.pathOrUrl() );
|
||||
}
|
||||
|
||||
// Document.URL
|
||||
static KJSObject docGetURL( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
return KJSString( doc->m_url.prettyUrl() );
|
||||
}
|
||||
|
||||
// Document.permStatusReady
|
||||
static KJSObject docGetPermStatusReady( KJSContext *, void * )
|
||||
{
|
||||
return KJSBoolean( true );
|
||||
}
|
||||
|
||||
// Document.dataObjects
|
||||
static KJSObject docGetDataObjects( KJSContext *ctx, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
const QList< EmbeddedFile * > *files = doc->m_generator->embeddedFiles();
|
||||
|
||||
KJSArray dataObjects( ctx, files ? files->count() : 0 );
|
||||
if ( files )
|
||||
{
|
||||
QList< EmbeddedFile * >::ConstIterator it = files->begin(), itEnd = files->end();
|
||||
for ( int i = 0; it != itEnd; ++it, ++i )
|
||||
{
|
||||
KJSObject newdata = JSData::wrapFile( ctx, *it );
|
||||
dataObjects.setProperty( ctx, QString::number( i ), newdata );
|
||||
}
|
||||
}
|
||||
return dataObjects;
|
||||
}
|
||||
|
||||
// Document.external
|
||||
static KJSObject docGetExternal( KJSContext *, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
QWidget *widget = doc->m_widget;
|
||||
|
||||
const bool isShell = ( widget
|
||||
&& widget->parentWidget()
|
||||
&& widget->parentWidget()->objectName() == QLatin1String( "okular::Shell" ) );
|
||||
return KJSBoolean( !isShell );
|
||||
}
|
||||
|
||||
|
||||
static KJSObject docGetInfo( KJSContext *ctx, void *object )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
KJSObject obj;
|
||||
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo();
|
||||
if ( docinfo )
|
||||
{
|
||||
#define KEY_GET( key, property ) \
|
||||
do { \
|
||||
const QString data = docinfo->get( key ); \
|
||||
if ( !data.isEmpty() ) \
|
||||
{ \
|
||||
const KJSString newval( data ); \
|
||||
obj.setProperty( ctx, property, newval ); \
|
||||
obj.setProperty( ctx, QString( property ).toLower(), newval ); \
|
||||
} \
|
||||
} while ( 0 );
|
||||
KEY_GET( "title", "Title" );
|
||||
KEY_GET( "author", "Author" );
|
||||
KEY_GET( "subject", "Subject" );
|
||||
KEY_GET( "keywords", "Keywords" );
|
||||
KEY_GET( "creator", "Creator" );
|
||||
KEY_GET( "producer", "Producer" );
|
||||
#undef KEY_GET
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
#define DOCINFO_GET_METHOD( key, name ) \
|
||||
static KJSObject docGet ## name( KJSContext *, void *object ) \
|
||||
{ \
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object ); \
|
||||
const DocumentInfo *docinfo = doc->m_generator->generateDocumentInfo(); \
|
||||
return KJSString( docinfo->get( key ) ); \
|
||||
}
|
||||
|
||||
DOCINFO_GET_METHOD( "author", Author )
|
||||
DOCINFO_GET_METHOD( "creator", Creator )
|
||||
DOCINFO_GET_METHOD( "keywords", Keywords )
|
||||
DOCINFO_GET_METHOD( "producer", Producer )
|
||||
DOCINFO_GET_METHOD( "title", Title )
|
||||
DOCINFO_GET_METHOD( "subject", Subject )
|
||||
|
||||
#undef DOCINFO_GET_METHOD
|
||||
|
||||
// Document.getField()
|
||||
static KJSObject docGetField( KJSContext *context, void *object,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
QString cName = arguments.at( 0 ).toString( context );
|
||||
|
||||
QVector< Page * >::const_iterator pIt = doc->m_pagesVector.constBegin(), pEnd = doc->m_pagesVector.constEnd();
|
||||
for ( ; pIt != pEnd; ++pIt )
|
||||
{
|
||||
const QLinkedList< Okular::FormField * > pageFields = (*pIt)->formFields();
|
||||
QLinkedList< Okular::FormField * >::const_iterator ffIt = pageFields.constBegin(), ffEnd = pageFields.constEnd();
|
||||
for ( ; ffIt != ffEnd; ++ffIt )
|
||||
{
|
||||
if ( (*ffIt)->name() == cName )
|
||||
{
|
||||
return JSField::wrapField( context, *ffIt, *pIt );
|
||||
}
|
||||
}
|
||||
}
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
// Document.getPageLabel()
|
||||
static KJSObject docGetPageLabel( KJSContext *ctx,void *object,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
int nPage = arguments.at( 0 ).toInt32( ctx );
|
||||
Page *p = doc->m_pagesVector.value( nPage );
|
||||
return KJSString( p ? p->label() : QString() );
|
||||
}
|
||||
|
||||
// Document.getPageRotation()
|
||||
static KJSObject docGetPageRotation( KJSContext *ctx, void *object,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
int nPage = arguments.at( 0 ).toInt32( ctx );
|
||||
Page *p = doc->m_pagesVector.value( nPage );
|
||||
return KJSNumber( p ? p->orientation() * 90 : 0 );
|
||||
}
|
||||
|
||||
// Document.gotoNamedDest()
|
||||
static KJSObject docGotoNamedDest( KJSContext *ctx, void *object,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
|
||||
|
||||
QString dest = arguments.at( 0 ).toString( ctx );
|
||||
|
||||
DocumentViewport viewport( doc->m_generator->metaData( "NamedViewport", dest ).toString() );
|
||||
if ( !viewport.isValid() )
|
||||
return KJSUndefined();
|
||||
|
||||
doc->m_parent->setViewport( viewport );
|
||||
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
// Document.syncAnnotScan()
|
||||
static KJSObject docSyncAnnotScan( KJSContext *, void *,
|
||||
const KJSArguments & )
|
||||
{
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
void JSDocument::initType( KJSContext *ctx )
|
||||
{
|
||||
assert( g_docProto );
|
||||
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
g_docProto->defineProperty( ctx, "numPages", docGetNumPages );
|
||||
g_docProto->defineProperty( ctx, "pageNum", docGetPageNum, docSetPageNum );
|
||||
g_docProto->defineProperty( ctx, "documentFileName", docGetDocumentFileName );
|
||||
g_docProto->defineProperty( ctx, "filesize", docGetFilesize );
|
||||
g_docProto->defineProperty( ctx, "path", docGetPath );
|
||||
g_docProto->defineProperty( ctx, "URL", docGetURL );
|
||||
g_docProto->defineProperty( ctx, "permStatusReady", docGetPermStatusReady );
|
||||
g_docProto->defineProperty( ctx, "dataObjects", docGetDataObjects );
|
||||
g_docProto->defineProperty( ctx, "external", docGetExternal );
|
||||
|
||||
// info properties
|
||||
g_docProto->defineProperty( ctx, "info", docGetInfo );
|
||||
g_docProto->defineProperty( ctx, "author", docGetAuthor );
|
||||
g_docProto->defineProperty( ctx, "creator", docGetCreator );
|
||||
g_docProto->defineProperty( ctx, "keywords", docGetKeywords );
|
||||
g_docProto->defineProperty( ctx, "producer", docGetProducer );
|
||||
g_docProto->defineProperty( ctx, "title", docGetTitle );
|
||||
g_docProto->defineProperty( ctx, "subject", docGetSubject );
|
||||
|
||||
g_docProto->defineFunction( ctx, "getField", docGetField );
|
||||
g_docProto->defineFunction( ctx, "getPageLabel", docGetPageLabel );
|
||||
g_docProto->defineFunction( ctx, "getPageRotation", docGetPageRotation );
|
||||
g_docProto->defineFunction( ctx, "gotoNamedDest", docGotoNamedDest );
|
||||
g_docProto->defineFunction( ctx, "syncAnnotScan", docSyncAnnotScan );
|
||||
}
|
||||
|
||||
KJSGlobalObject JSDocument::wrapDocument( DocumentPrivate *doc )
|
||||
{
|
||||
if ( !g_docProto )
|
||||
g_docProto = new KJSPrototype();
|
||||
return g_docProto->constructGlobalObject( doc );
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_DOCUMENT_P_H
|
||||
#define OKULAR_SCRIPT_KJS_DOCUMENT_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSGlobalObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class DocumentPrivate;
|
||||
|
||||
class JSDocument
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSGlobalObject wrapDocument( DocumentPrivate *doc );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,230 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_field_p.h"
|
||||
|
||||
#include <kjs/kjsinterpreter.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
#include <kjs/kjsarguments.h>
|
||||
|
||||
#include <qhash.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
#include "../debug_p.h"
|
||||
#include "../document_p.h"
|
||||
#include "../form.h"
|
||||
#include "../page.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_fieldProto;
|
||||
|
||||
typedef QHash< FormField *, KJSObject > FormCache;
|
||||
K_GLOBAL_STATIC( FormCache, g_fieldCache )
|
||||
|
||||
// Field.doc
|
||||
static KJSObject fieldGetDoc( KJSContext *context, void * )
|
||||
{
|
||||
return context->interpreter().globalObject();
|
||||
}
|
||||
|
||||
// Field.name
|
||||
static KJSObject fieldGetName( KJSContext *, void *object )
|
||||
{
|
||||
const FormField *field = reinterpret_cast< FormField * >( object );
|
||||
return KJSString( field->name() );
|
||||
}
|
||||
|
||||
// Field.readonly (getter)
|
||||
static KJSObject fieldGetReadOnly( KJSContext *, void *object )
|
||||
{
|
||||
const FormField *field = reinterpret_cast< FormField * >( object );
|
||||
return KJSBoolean( field->isReadOnly() );
|
||||
}
|
||||
|
||||
// Field.readonly (setter)
|
||||
static void fieldSetReadOnly( KJSContext *context, void *object, KJSObject value )
|
||||
{
|
||||
#if 0
|
||||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
bool b = value.toBoolean( context );
|
||||
field->setReadOnly( b );
|
||||
#else
|
||||
Q_UNUSED( context );
|
||||
Q_UNUSED( object );
|
||||
Q_UNUSED( value );
|
||||
kDebug(OkularDebug) << "Not implemented: setting readonly property";
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString fieldGetTypeHelper( const FormField *field )
|
||||
{
|
||||
switch ( field->type() )
|
||||
{
|
||||
case FormField::FormButton:
|
||||
{
|
||||
const FormFieldButton *button = static_cast< const FormFieldButton * >( field );
|
||||
switch ( button->buttonType() )
|
||||
{
|
||||
case FormFieldButton::Push:
|
||||
return "button";
|
||||
case FormFieldButton::CheckBox:
|
||||
return "checkbox";
|
||||
case FormFieldButton::Radio:
|
||||
return "radiobutton";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FormField::FormText:
|
||||
return "text";
|
||||
case FormField::FormChoice:
|
||||
{
|
||||
const FormFieldChoice *choice = static_cast< const FormFieldChoice * >( field );
|
||||
switch ( choice->choiceType() )
|
||||
{
|
||||
case FormFieldChoice::ComboBox:
|
||||
return "combobox";
|
||||
case FormFieldChoice::ListBox:
|
||||
return "listbox";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FormField::FormSignature:
|
||||
return "signature";
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Field.type
|
||||
static KJSObject fieldGetType( KJSContext *, void *object )
|
||||
{
|
||||
const FormField *field = reinterpret_cast< FormField * >( object );
|
||||
|
||||
return KJSString( fieldGetTypeHelper( field ) );
|
||||
}
|
||||
|
||||
// Field.value (getter)
|
||||
static KJSObject fieldGetValue( KJSContext *context, void *object )
|
||||
{
|
||||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
if ( field->isReadOnly() )
|
||||
{
|
||||
KJSObject value = g_fieldCache->value( field );
|
||||
if ( g_fieldCache.exists() && g_fieldCache->contains( field ) )
|
||||
value = g_fieldCache->value( field );
|
||||
else
|
||||
value = KJSString("");
|
||||
kDebug(OkularDebug) << "Getting the value of a readonly field" << field->name() << ":" << value.toString( context );
|
||||
return value;
|
||||
}
|
||||
|
||||
switch ( field->type() )
|
||||
{
|
||||
case FormField::FormButton:
|
||||
{
|
||||
const FormFieldButton *button = static_cast< const FormFieldButton * >( field );
|
||||
Q_UNUSED( button ); // ###
|
||||
break;
|
||||
}
|
||||
case FormField::FormText:
|
||||
{
|
||||
const FormFieldText *text = static_cast< const FormFieldText * >( field );
|
||||
return KJSString( text->text() );
|
||||
}
|
||||
case FormField::FormChoice:
|
||||
{
|
||||
const FormFieldChoice *choice = static_cast< const FormFieldChoice * >( field );
|
||||
Q_UNUSED( choice ); // ###
|
||||
break;
|
||||
}
|
||||
case FormField::FormSignature:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return KJSUndefined();
|
||||
}
|
||||
|
||||
// Field.value (setter)
|
||||
static void fieldSetValue( KJSContext *context, void *object, KJSObject value )
|
||||
{
|
||||
FormField *field = reinterpret_cast< FormField * >( object );
|
||||
|
||||
if ( field->isReadOnly() )
|
||||
{
|
||||
// ### throw exception?
|
||||
kDebug(OkularDebug) << "Trying to change the readonly field" << field->name() << "to" << value.toString( context );
|
||||
g_fieldCache->insert( field, value );
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( field->type() )
|
||||
{
|
||||
case FormField::FormButton:
|
||||
{
|
||||
FormFieldButton *button = static_cast< FormFieldButton * >( field );
|
||||
Q_UNUSED( button ); // ###
|
||||
break;
|
||||
}
|
||||
case FormField::FormText:
|
||||
{
|
||||
FormFieldText *text = static_cast< FormFieldText * >( field );
|
||||
text->setText( value.toString( context ) );
|
||||
break;
|
||||
}
|
||||
case FormField::FormChoice:
|
||||
{
|
||||
FormFieldChoice *choice = static_cast< FormFieldChoice * >( field );
|
||||
Q_UNUSED( choice ); // ###
|
||||
break;
|
||||
}
|
||||
case FormField::FormSignature:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JSField::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
if ( !g_fieldProto )
|
||||
g_fieldProto = new KJSPrototype();
|
||||
|
||||
g_fieldProto->defineProperty( ctx, "doc", fieldGetDoc );
|
||||
g_fieldProto->defineProperty( ctx, "name", fieldGetName );
|
||||
g_fieldProto->defineProperty( ctx, "readonly",
|
||||
fieldGetReadOnly, fieldSetReadOnly );
|
||||
g_fieldProto->defineProperty( ctx, "type", fieldGetType );
|
||||
g_fieldProto->defineProperty( ctx, "value", fieldGetValue, fieldSetValue );
|
||||
}
|
||||
|
||||
KJSObject JSField::wrapField( KJSContext *ctx, FormField *field, Page *page )
|
||||
{
|
||||
// ### cache unique wrapper
|
||||
KJSObject f = g_fieldProto->constructObject( ctx, field );
|
||||
f.setProperty( ctx, "page", page->number() );
|
||||
return f;
|
||||
}
|
||||
|
||||
void JSField::clearCachedFields()
|
||||
{
|
||||
if ( g_fieldCache.exists() )
|
||||
{
|
||||
g_fieldCache->clear();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_FIELD_P_H
|
||||
#define OKULAR_SCRIPT_KJS_FIELD_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class FormField;
|
||||
class Page;
|
||||
|
||||
class JSField
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject wrapField( KJSContext *ctx, FormField *field, Page *page );
|
||||
static void clearCachedFields();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,78 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_fullscreen_p.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
|
||||
#include "settings_core.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_fsProto;
|
||||
|
||||
static KJSObject fsGetLoop( KJSContext *, void * )
|
||||
{
|
||||
return KJSBoolean( SettingsCore::slidesLoop() );
|
||||
}
|
||||
|
||||
static void fsSetLoop( KJSContext *ctx, void *, KJSObject value )
|
||||
{
|
||||
bool loop = value.toBoolean( ctx );
|
||||
SettingsCore::setSlidesLoop( loop );
|
||||
}
|
||||
|
||||
static KJSObject fsGetUseTimer( KJSContext *, void * )
|
||||
{
|
||||
return KJSBoolean( SettingsCore::slidesAdvance() );
|
||||
}
|
||||
|
||||
static void fsSetUseTimer( KJSContext *ctx, void *, KJSObject value )
|
||||
{
|
||||
bool use = value.toBoolean( ctx );
|
||||
SettingsCore::setSlidesAdvance( use );
|
||||
}
|
||||
|
||||
static KJSObject fsGetTimeDelay( KJSContext *, void * )
|
||||
{
|
||||
return KJSNumber( SettingsCore::slidesAdvanceTime() );
|
||||
}
|
||||
|
||||
static void fsSetTimeDelay( KJSContext *ctx, void *, KJSObject value )
|
||||
{
|
||||
int time = static_cast<int>( value.toNumber( ctx ) );
|
||||
SettingsCore::setSlidesAdvanceTime( time );
|
||||
}
|
||||
|
||||
void JSFullscreen::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
if ( !g_fsProto )
|
||||
g_fsProto = new KJSPrototype();
|
||||
|
||||
g_fsProto->defineProperty( ctx, "loop", fsGetLoop, fsSetLoop );
|
||||
g_fsProto->defineProperty( ctx, "useTimer",
|
||||
fsGetUseTimer, fsSetUseTimer );
|
||||
g_fsProto->defineProperty( ctx, "timeDelay",
|
||||
fsGetTimeDelay, fsSetTimeDelay );
|
||||
}
|
||||
|
||||
KJSObject JSFullscreen::object( KJSContext *ctx )
|
||||
{
|
||||
assert( g_fsProto );
|
||||
return g_fsProto->constructObject( ctx );
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_FULLSCREEN_P_H
|
||||
#define OKULAR_SCRIPT_KJS_FULLSCREEN_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class JSFullscreen
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject object( KJSContext *ctx );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,42 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_spell_p.h"
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_spellProto;
|
||||
|
||||
// Spell.available
|
||||
static KJSObject spellGetAvailable( KJSContext *, void * )
|
||||
{
|
||||
return KJSBoolean( false );
|
||||
}
|
||||
|
||||
void JSSpell::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
g_spellProto = new KJSPrototype();
|
||||
g_spellProto->defineProperty( ctx, QString( "available" ), spellGetAvailable );
|
||||
}
|
||||
|
||||
KJSObject JSSpell::object( KJSContext *ctx )
|
||||
{
|
||||
return g_spellProto->constructObject( ctx, 0 );
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_SPELL_P_H
|
||||
#define OKULAR_SCRIPT_KJS_SPELL_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class JSSpell
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject object( KJSContext *ctx );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,74 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "kjs_util_p.h"
|
||||
|
||||
#include <kjs/kjsobject.h>
|
||||
#include <kjs/kjsprototype.h>
|
||||
#include <kjs/kjsarguments.h>
|
||||
|
||||
#include <kurl.h>
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
static KJSPrototype *g_utilProto;
|
||||
|
||||
static KJSObject crackURL( KJSContext *context, void *,
|
||||
const KJSArguments &arguments )
|
||||
{
|
||||
if ( arguments.count() < 1 )
|
||||
{
|
||||
return context->throwException( "Missing URL argument" );
|
||||
}
|
||||
QString cURL = arguments.at( 0 ).toString( context );
|
||||
KUrl url( cURL );
|
||||
if ( !url.isValid() )
|
||||
{
|
||||
return context->throwException( "Invalid URL" );
|
||||
}
|
||||
if ( url.protocol() != QLatin1String( "file" )
|
||||
|| url.protocol() != QLatin1String( "http" )
|
||||
|| url.protocol() != QLatin1String( "https" ) )
|
||||
{
|
||||
return context->throwException( "Protocol not valid: '" + url.protocol() + '\'' );
|
||||
}
|
||||
|
||||
KJSObject obj;
|
||||
obj.setProperty( context, "cScheme", url.protocol() );
|
||||
if ( url.hasUser() )
|
||||
obj.setProperty( context, "cUser", url.user() );
|
||||
if ( url.hasPass() )
|
||||
obj.setProperty( context, "cPassword", url.password() );
|
||||
obj.setProperty( context, "cHost", url.host() );
|
||||
obj.setProperty( context, "nPort", url.port( 80 ) );
|
||||
// TODO cPath (Optional) The path portion of the URL.
|
||||
// TODO cParameters (Optional) The parameter string portion of the URL.
|
||||
if ( url.hasRef() )
|
||||
obj.setProperty( context, "cFragments", url.ref() );
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void JSUtil::initType( KJSContext *ctx )
|
||||
{
|
||||
static bool initialized = false;
|
||||
if ( initialized )
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
g_utilProto = new KJSPrototype();
|
||||
g_utilProto->defineFunction( ctx, "crackURL", crackURL );
|
||||
}
|
||||
|
||||
KJSObject JSUtil::object( KJSContext *ctx )
|
||||
{
|
||||
return g_utilProto->constructObject( ctx, 0 );
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPT_KJS_UTIL_P_H
|
||||
#define OKULAR_SCRIPT_KJS_UTIL_P_H
|
||||
|
||||
class KJSContext;
|
||||
class KJSObject;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class JSUtil
|
||||
{
|
||||
public:
|
||||
static void initType( KJSContext *ctx );
|
||||
static KJSObject object( KJSContext *ctx );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,66 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "scripter.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "debug_p.h"
|
||||
#include "script/executor_kjs_p.h"
|
||||
|
||||
using namespace Okular;
|
||||
|
||||
class Okular::ScripterPrivate
|
||||
{
|
||||
public:
|
||||
ScripterPrivate( DocumentPrivate *doc )
|
||||
: m_doc( doc ), m_kjs( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
~ScripterPrivate()
|
||||
{
|
||||
delete m_kjs;
|
||||
}
|
||||
|
||||
DocumentPrivate *m_doc;
|
||||
ExecutorKJS *m_kjs;
|
||||
};
|
||||
|
||||
Scripter::Scripter( DocumentPrivate *doc )
|
||||
: d( new ScripterPrivate( doc ) )
|
||||
{
|
||||
}
|
||||
|
||||
Scripter::~Scripter()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString Scripter::execute( ScriptType type, const QString &script )
|
||||
{
|
||||
kDebug(OkularDebug) << "executing the script:";
|
||||
#if 0
|
||||
if ( script.length() < 1000 )
|
||||
qDebug() << script;
|
||||
else
|
||||
qDebug() << script.left( 1000 ) << "[...]";
|
||||
#endif
|
||||
switch ( type )
|
||||
{
|
||||
case JavaScript:
|
||||
if ( !d->m_kjs )
|
||||
{
|
||||
d->m_kjs = new ExecutorKJS( d->m_doc );
|
||||
}
|
||||
d->m_kjs->execute( script );
|
||||
break;
|
||||
}
|
||||
return QString();
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef OKULAR_SCRIPTER_H
|
||||
#define OKULAR_SCRIPTER_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
namespace Okular {
|
||||
|
||||
class Document;
|
||||
class DocumentPrivate;
|
||||
class ScripterPrivate;
|
||||
|
||||
class Scripter
|
||||
{
|
||||
friend class Document;
|
||||
friend class DocumentPrivate;
|
||||
|
||||
public:
|
||||
~Scripter();
|
||||
|
||||
QString execute( ScriptType type, const QString &script );
|
||||
|
||||
private:
|
||||
friend class ScripterPrivate;
|
||||
ScripterPrivate* d;
|
||||
|
||||
Scripter( DocumentPrivate *doc );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue