Script hosting base class. More...
#include <base.h>
Public Slots | |
| QSAnnotation * | createAnnotation (QVariant rect, const QString &type) |
| QSIProperty * | createArray () |
| QSIProperty * | createBool (bool value) |
| QSPdfOperator * | createCompositeOperator (const QString &beginText, const QString &endText) |
| QSIProperty * | createDict () |
| QSPdfOperator * | createEmptyOperator () |
| QSIProperty * | createInt (int value) |
| QSIPropertyArray * | createIPropertyArray () |
| QSIProperty * | createName (const QString &value) |
| QSPdfOperator * | createOperator (const QString &text, QSIPropertyArray *parameters) |
| QSPdfOperator * | createOperator (const QString &text, QObject *parameters) |
| QSPdfOperatorStack * | createPdfOperatorStack () |
| QSIProperty * | createReal (double value) |
| QSIProperty * | createRef (int valueNum, int valueGen) |
| QSIProperty * | createString (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) |
| QSPdf * | loadPdf (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 ¶m) |
| 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) |
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
| gui::Base::Base | ( | ) |
Create new Base class
| gui::Base::~Base | ( | ) | [virtual] |
destructor
References gui::BaseCore::treeReloadFlag, and gui::BaseCore::treeWrap.
| QSAnnotation * gui::Base::createAnnotation | ( | QVariant | rect, | |
| const QString & | type | |||
| ) | [slot] |
Create and initialize new annotation of given type
| rect | Annotation redctangle | |
| type | Type of annotation |
| QSIProperty * gui::Base::createArray | ( | ) | [slot] |
Create new IProperty of type Array - an empty array
| QSIProperty * gui::Base::createBool | ( | bool | value | ) | [slot] |
Create new IProperty of type Bool
| value | Value assigned to this property |
| QSPdfOperator * gui::Base::createCompositeOperator | ( | const QString & | beginText, | |
| const QString & | endText | |||
| ) | [slot] |
Create new operator of type UnknownCompositePdfOperator
| beginText | Start operator name text representation. | |
| endText | End operator name text representation. |
| QSIProperty * gui::Base::createDict | ( | ) | [slot] |
Create new IProperty of type Dict - an empty dictionary
| QSPdfOperator * gui::Base::createEmptyOperator | ( | ) | [slot] |
Create new empty (NULL) PdfOperator
| QSIProperty * gui::Base::createInt | ( | int | value | ) | [slot] |
Create new IProperty of type Int
| value | Value assigned to this property |
| QSIPropertyArray * gui::Base::createIPropertyArray | ( | ) | [slot] |
Create new array of IProperty items. This array can be used for example as operator parameters
| QSIProperty * gui::Base::createName | ( | const QString & | value | ) | [slot] |
Create new IProperty of type Name
| value | Value assigned to this property |
| QSPdfOperator * gui::Base::createOperator | ( | const QString & | text, | |
| QObject * | parameters | |||
| ) | [slot] |
QSA-Bugfix version Create new operator of type SimpleGenericOperator
| parameters | Array with operator parameters | |
| text | Operator text |
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 | Array with operator parameters | |
| text | Operator text |
| QSPdfOperatorStack * gui::Base::createPdfOperatorStack | ( | ) | [slot] |
Create new empty PDF 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
| value | Value assigned to this property |
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
| valueNum | Number assigned to this reference | |
| valueGen | Generation assigned to this reference |
References pdfobjects::CObjectFactory< Type >::getInstance().
| QSIProperty * gui::Base::createString | ( | const QString & | value | ) | [slot] |
Create new IProperty of type String
| value | Value assigned to this property |
| 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()
| 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
| bool gui::Base::exists | ( | const QString & | chkFileName | ) | [slot] |
Check whether given file exists
| chkFileName | Name of file to check |
| 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()
| 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
| 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
| 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] |
References pdfobjects::CPdf::ReadWrite.
| 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
| 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 |
| 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.
| 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
| 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
| 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
| scriptName | name of file with QT Script to run |
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)
| initScripts | List of script files that will be attempted to 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.
| 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
| param | New debug verbosity level |
| void gui::Base::setError | ( | const QString & | errorMessage | ) |
Set error message that will be returned by error() function
| 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
| format | Date/time format |
| QString gui::Base::tr | ( | const QString & | text, | |
| const QString & | context = QString::null | |||
| ) | [slot] |
call QObject::tr to translate specific string
| text | text to translate to current locale | |
| context | Optional context identifier for localized 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 )
| 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 )
| 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
| original | Original 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
QString gui::Base::lastErrorMessage [protected] |
Last error message from exception in load/save, etc ...
Referenced by functions().