gui::Base Class Reference

Script hosting base class. More...

#include <base.h>

Inheritance diagram for gui::Base:
gui::BaseCore gui::BaseConsole gui::BaseGUI

List of all members.

Public Slots

QSAnnotationcreateAnnotation (QVariant rect, const QString &type)
QSIPropertycreateArray ()
QSIPropertycreateBool (bool value)
QSPdfOperatorcreateCompositeOperator (const QString &beginText, const QString &endText)
QSIPropertycreateDict ()
QSPdfOperatorcreateEmptyOperator ()
QSIPropertycreateInt (int value)
QSIPropertyArraycreateIPropertyArray ()
QSIPropertycreateName (const QString &value)
QSPdfOperatorcreateOperator (const QString &text, QSIPropertyArray *parameters)
QSPdfOperatorcreateOperator (const QString &text, QObject *parameters)
QSPdfOperatorStackcreatePdfOperatorStack ()
QSIPropertycreateReal (double value)
QSIPropertycreateRef (int valueNum, int valueGen)
QSIPropertycreateString (const QString &value)
bool delinearize (const QString &inFile, const QString &outFile)
QString error ()
bool exists (const QString &chkFileName)
bool flatten (const QString &inFile, const QString &outFile)
QStringList functions (bool includeSignatures=false)
QString loadFile (const QString &name)
QSPdfloadPdf (const QString &name, bool advancedMode=false, bool askPassword=true)
QStringList objects ()
QString pdftoxml (const QString &inFile, QVariant pagenums, const QString &outFile)
void print (const QString &str)
double rand ()
void run (QString scriptName, bool skipScriptPath=false)
bool saveFile (const QString &name, const QString &content)
bool saveRawFile (const QString &name, const QByteArray &content)
void setDebugLevel (const QString &param)
QString time (const QString &format=QString::null)
int tick ()
QVariant transformationMatrixDiv (const QVariant &oldCTM, const QVariant &newCTM)
QVariant transformationMatrixMul (const QVariant &ma, const QVariant &mb)
QVariant transformationMatrixMul (double a0, double a1, const QVariant &mb)
QString tr (const QString &text, const QString &context=QString::null)
void treeNeedReload ()
QString utf8 (QString original)
QStringList variables ()
QString version ()

Public Member Functions

 Base ()
virtual ~Base ()
int runScriptList (const QStringList &initScripts)
void runScriptsFromPath (const QStringList &initScriptPaths)
void setError (const QString &errorMessage)

Protected Member Functions

virtual boost::shared_ptr
< pdfobjects::CPdf
getBasePdfInstance (const QString &filename, const QString &openMode=QString::null, bool askPassword=true)

Protected Attributes

QString lastErrorMessage

Private Member Functions

bool runFile (const QString &scriptName)

Detailed Description

Script hosting base class.

Class that hosts scripts and contains static script functions.
This class is also responsible for garbage collection of scripting objects and interaction of editor with scripts


Constructor & Destructor Documentation

gui::Base::Base (  ) 

Create new Base class

gui::Base::~Base (  )  [virtual]

Member Function Documentation

QSAnnotation * gui::Base::createAnnotation ( QVariant  rect,
const QString &  type 
) [slot]

Create and initialize new annotation of given type

Parameters:
rect Annotation redctangle
type Type of annotation
Returns:
created Annotation
QSIProperty * gui::Base::createArray (  )  [slot]

Create new IProperty of type Array - an empty array

Returns:
created IProperty
QSIProperty * gui::Base::createBool ( bool  value  )  [slot]

Create new IProperty of type Bool

Parameters:
value Value assigned to this property
Returns:
created IProperty
QSPdfOperator * gui::Base::createCompositeOperator ( const QString &  beginText,
const QString &  endText 
) [slot]

Create new operator of type UnknownCompositePdfOperator

Parameters:
beginText Start operator name text representation.
endText End operator name text representation.
Returns:
new PDF operator
QSIProperty * gui::Base::createDict (  )  [slot]

Create new IProperty of type Dict - an empty dictionary

Returns:
created IProperty
QSPdfOperator * gui::Base::createEmptyOperator (  )  [slot]

Create new empty (NULL) PdfOperator

Returns:
new empty PDF operator
QSIProperty * gui::Base::createInt ( int  value  )  [slot]

Create new IProperty of type Int

Parameters:
value Value assigned to this property
Returns:
created IProperty
QSIPropertyArray * gui::Base::createIPropertyArray (  )  [slot]

Create new array of IProperty items. This array can be used for example as operator parameters

Returns:
new Iproperty array
QSIProperty * gui::Base::createName ( const QString &  value  )  [slot]

Create new IProperty of type Name

Parameters:
value Value assigned to this property
Returns:
created IProperty
QSPdfOperator * gui::Base::createOperator ( const QString &  text,
QObject *  parameters 
) [slot]

QSA-Bugfix version Create new operator of type SimpleGenericOperator

Parameters:
parameters Array with operator parameters
text Operator text
Returns:
new PDF operator

References util::convertFromUnicode(), gui::QSIPropertyArray::copyTo(), pdfobjects::createOperator(), and util::PDF.

QSPdfOperator * gui::Base::createOperator ( const QString &  text,
QSIPropertyArray parameters 
) [slot]

Create new operator of type SimpleGenericOperator

Parameters:
parameters Array with operator parameters
text Operator text
Returns:
new PDF operator
QSPdfOperatorStack * gui::Base::createPdfOperatorStack (  )  [slot]

Create new empty PDF Operator stack

Returns:
new operator stack

References util::convertFromUnicode(), pdfobjects::CObjectFactory< Type >::getInstance(), and util::PDF.

QSIProperty * gui::Base::createReal ( double  value  )  [slot]

Create new IProperty of type Real

Parameters:
value Value assigned to this property
Returns:
created IProperty

References pdfobjects::CDictFactory::getInstance().

QSIProperty * gui::Base::createRef ( int  valueNum,
int  valueGen 
) [slot]

Create new IProperty of type Ref Does not check for validity of reference

See also:
QSPdf::referenceValid
Parameters:
valueNum Number assigned to this reference
valueGen Generation assigned to this reference
Returns:
created IProperty

References pdfobjects::CObjectFactory< Type >::getInstance().

QSIProperty * gui::Base::createString ( const QString &  value  )  [slot]

Create new IProperty of type String

Parameters:
value Value assigned to this property
Returns:
created IProperty
bool gui::Base::delinearize ( const QString &  inFile,
const QString &  outFile 
) [slot]

Try to delinearize PDF, reading from input file and writing delinearized result to output file. Does not check for overwriting output. Return true if delinearization was successful, false in case of failure.
In case of failure the error mesage is available via error()

See also:
error
Parameters:
inFile input file
outFile output file
QString gui::Base::error (  )  [slot]

Return last error message from some operations (like load, save, etc ...) If last command was successfull, it is undefined what this function returns

Returns:
Last error message
bool gui::Base::exists ( const QString &  chkFileName  )  [slot]

Check whether given file exists

Parameters:
chkFileName Name of file to check
Returns:
true if file exists, false otherwise
bool gui::Base::flatten ( const QString &  inFile,
const QString &  outFile 
) [slot]

Try to flatten PDF, reading from input file and writing flattened result to output file. Does not check for overwriting output. Return true if flattening was successful, false in case of failure.
In case of failure the error mesage is available via error()

See also:
error
Parameters:
inFile input file
outFile output file
QStringList gui::Base::functions ( bool  includeSignatures = false  )  [slot]

Return list of all functions that are in current script interpreter. Functions are sorted alphabetically

Parameters:
includeSignatures if true, function signatures will be returned, otherwise only names

References lastErrorMessage.

boost::shared_ptr< pdfobjects::CPdf > gui::Base::getBasePdfInstance ( const QString &  filename,
const QString &  openMode = QString::null,
bool  askPassword = true 
) [protected, virtual]

Open PDF instance. Specific password solicitation (GUI, console) should be implemented in subclasses - BaseGUI ands BaseConsole

Parameters:
filename filename to open
openMode Mode in which to open the file (advanced, readonly and readwrite - default)
askPassword if true, attempt to ask user for password would be made if document is encrypted

Reimplemented in gui::BaseGUI.

QString gui::Base::loadFile ( const QString &  name  )  [slot]
QSPdf * gui::Base::loadPdf ( const QString &  name,
bool  advancedMode = false,
bool  askPassword = true 
) [slot]

Load some PDF file without replacing currently opened file in GUI script should also take care to close the file after he does not need to use it anymore

Parameters:
name Name of file to load
advancedMode Set to true to use Advanced mode whilwe opening the file
askPassword if true, attempt to ask user for password would be made if document is encrypted
Returns:
Loaded document, or NULL if error occured while loading it.
QStringList gui::Base::objects (  )  [slot]

Return list of all objects that are in current script interpreter

QString gui::Base::pdftoxml ( const QString &  inFile,
QVariant  pagenums,
const QString &  outFile 
) [slot]

Convert pdf to xml.

Parameters:
inFile input file
pagenums List of page numbers.
outFile output file
void gui::Base::print ( const QString &  str  )  [slot]

Print given string to console, followed by newline

Parameters:
str String to add

References gui::BaseCore::qs.

double gui::Base::rand (  )  [slot]

Return (pseudo)random value between 0 and 1 inclusive

Referenced by tick().

void gui::Base::run ( QString  scriptName,
bool  skipScriptPath = false 
) [slot]

Runs script from given file Not to be called directly, only from script (via slot), as this does not prepare correct script variables before execution File is looked for in the script path, unless absolute filename is given. If the file is not found in script path, it is looked for in current directory

Parameters:
scriptName name of file with QT Script to run
skipScriptPath Do not look into script path, just try current directory

Referenced by gui::PdfEditWindow::eval(), gui::ConsoleWindow::run(), and gui::ConsoleWindow::runFile().

bool gui::Base::runFile ( const QString &  scriptName  )  [private]

Runs script from given file in current interpreter

Parameters:
scriptName name of file with QT Script to run
Returns:
true if success, false if error (file not exist, etc ...)

References gui::BaseCore::conPrintError(), debug::DBG_INFO, gui::BaseCore::errorMessage(), guiPrintDbg, Q_OUT, and tr().

int gui::Base::runScriptList ( const QStringList &  initScripts  ) 

Try to run each file from given list as script (if it exists)

Parameters:
initScripts List of script files that will be attempted to run
Returns:
number of script files actually run.

Referenced by gui::BaseConsole::runInitScript().

void gui::Base::runScriptsFromPath ( const QStringList &  initScriptPaths  ) 

Try to run each script file (*.qs) present in one of the directories from given list If same file is present in multiple directories, only that from later directory is run Scripts are run in alphabetical order.

Parameters:
initScriptPaths List of directories with script files

References gui::BaseCore::conPrintError(), debug::DBG_INFO, gui::BaseCore::errorMessage(), guiPrintDbg, Q_OUT, and tr().

Referenced by gui::BaseConsole::runInitScript().

bool gui::Base::saveFile ( const QString &  name,
const QString &  content 
) [slot]

bool gui::Base::saveRawFile ( const QString &  name,
const QByteArray &  content 
) [slot]

void gui::Base::setDebugLevel ( const QString &  param  )  [slot]

Set new debug verbosity level

Parameters:
param New debug verbosity level
See also:
util::setDebugLevel
void gui::Base::setError ( const QString &  errorMessage  ) 

Set error message that will be returned by error() function

See also:
error
Parameters:
errorMessage String containing the error message

Referenced by gui::PdfEditWindow::setFileName().

int gui::Base::tick (  )  [slot]

Return current tick counter (msecs since some arbitrary point in time, usually aplication start. Reference point will not change while running the application, but can (and probably will) change across different application runs May overflow in time)

References rand().

QString gui::Base::time ( const QString &  format = QString::null  )  [slot]

Return current date and time

Parameters:
format Date/time format
QString gui::Base::tr ( const QString &  text,
const QString &  context = QString::null 
) [slot]

call QObject::tr to translate specific string

Parameters:
text text to translate to current locale
context Optional context identifier for localized text
Returns:
translated text

Referenced by runFile(), gui::BaseConsole::runInitScript(), runScriptsFromPath(), and utf8().

QVariant gui::Base::transformationMatrixDiv ( const QVariant &  oldCTM,
const QVariant &  newCTM 
) [slot]

Solve equation oldCTM * requiredCTM = newCTM (find inverse transformation). Return requiredCTM. NULL is returned if no such matrix exists All transformation matrixes are represented as array of 6 doubles.

QVariant gui::Base::transformationMatrixMul ( double  a0,
double  a1,
const QVariant &  mb 
) [slot]

Multiply vector[2] by transformation matrix ( [a0,a1] * mb, transform vector with matrix mb )

Parameters:
a0 first vector coordinate
a1 second vector coordinate
mb transformation matrix

References util::varFromDoubleArray().

QVariant gui::Base::transformationMatrixMul ( const QVariant &  ma,
const QVariant &  mb 
) [slot]

Multiply transformation matrix or vector[2] by another transformation matrix ( a * b )

Parameters:
ma first operand
mb second operand
void gui::Base::treeNeedReload (  )  [slot]

Call after some action causes changes in the treeview that cannot be handled by observers. This will cause tree to be reloaded after the script finishes.

QString gui::Base::utf8 ( QString  original  )  [slot]

Convert string as it is read by QFile/QSFile/File in QSA to Unicode, asuming the string was utf8

Parameters:
original Original string
Returns:
converted string

References tr().

QStringList gui::Base::variables (  )  [slot]

Return sorted list of all variables that are in current script interpreter

QString gui::Base::version (  )  [slot]

Return version of editor as string

Returns:
Version of editor (major.minor.release or major.minor.relase-suffix)

Member Data Documentation

QString gui::Base::lastErrorMessage [protected]

Last error message from exception in load/save, etc ...

Referenced by functions().


The documentation for this class was generated from the following files: