Core scripting functions. More...
#include <basecore.h>
Public Member Functions | |
| BaseCore () | |
| virtual | ~BaseCore () |
| void | setConWriter (ConsoleWriter *_con) |
| void | conPrintError (const QString &line) |
| void | conPrintLine (const QString &line) |
| void | runScript (const QString &script) |
| void | call (const QString &name, const QString &arguments="") |
| void | importDocument (boost::shared_ptr< pdfobjects::CPdf > pdf) |
| void | destroyDocument () |
| QSPdf * | getQSPdf () const |
| void | stopScript () |
| void | addGC (QSCObject *o) |
| void | removeGC (QSCObject *o) |
| void | errorNullPointer (const QString &className, const QString &methodName) |
| void | errorBadParameter (const QString &className, const QString &methodName, int paramNum, const QObject *param, const QString &expected) |
| void | errorException (const QString &className, const QString &methodName, const QString &exceptionInfo) |
| void | addTreeItemToList (QSTreeItem *theWrap) |
| void | removeTreeItemFromList (QSTreeItem *theWrap) |
| QSInterpreter * | interpreter () |
Protected Member Functions | |
| virtual void | preRun (const QString &script, bool callback=false) |
| virtual void | postRun () |
| virtual void | removeScriptingObjects () |
| virtual void | addScriptingObjects () |
| void | deleteVariable (const QString &varName) |
| void | errorMessage () |
| void | clearError () |
Protected Attributes | |
| QSProject * | qp |
| QSInterpreter * | qs |
| QSImporter * | import |
| TreeBindingMap | treeWrap |
| QSPdf * | qpdf |
| bool | treeReloadFlag |
Private Slots | |
| void | scriptError (const QString &message, const QString &scriptName, int lineNumber) |
Private Member Functions | |
| void | cleanup () |
Private Attributes | |
| Q_PtrDict< QSCObject > | baseObjects |
| ConsoleWriter * | con |
| QString | errMessage |
| QString | errScript |
| int | errLineNumber |
Core scripting functions.
Core of Class that host scripts and is responsible for garbage collection of scripting objects and core scriptiong functionality
| gui::BaseCore::BaseCore | ( | ) |
Create new BaseCore class
| gui::BaseCore::~BaseCore | ( | ) | [virtual] |
destructor
| void gui::BaseCore::addGC | ( | QSCObject * | o | ) |
Add QSCObject to list of object to delete when file in editor window is closed
| o | Object to add to cleanup-list |
Referenced by gui::QSCObject::QSCObject().
| void gui::BaseCore::addScriptingObjects | ( | ) | [protected, virtual] |
Create objects that should be available to scripting from current CPdf and related objects
Reimplemented in gui::BaseGUI.
| void gui::BaseCore::addTreeItemToList | ( | QSTreeItem * | theWrap | ) |
Add tree item wrapper to list of managed wrappers
Called from treeitem wrapper contructor
| theWrap | Tree item wrapper |
Referenced by gui::QSTreeItem::QSTreeItem().
| void gui::BaseCore::call | ( | const QString & | name, | |
| const QString & | arguments = "" | |||
| ) |
Call a callback function (without return value) in a script
| name | Function name | |
| arguments | Function arguments, separated by comma. Strings must be properly quoted |
some error occured
Referenced by gui::PdfEditWindow::pageDeleteSelection(), gui::PdfEditWindow::setSelection(), and gui::ConsoleWindow::~ConsoleWindow().
| void gui::BaseCore::cleanup | ( | ) | [private] |
Delete all objects in cleanup list
| void gui::BaseCore::clearError | ( | ) | [protected] |
Clear internal error state Usually called after printing the error, so to avoid seeing the same error again
| void gui::BaseCore::conPrintError | ( | const QString & | line | ) |
Print one error line to console, followed by newline
| line | Error line to print |
Referenced by gui::Base::runFile(), gui::BaseConsole::runInitScript(), and gui::Base::runScriptsFromPath().
| void gui::BaseCore::conPrintLine | ( | const QString & | line | ) |
Print one line to console, followed by newline
| line | Line to print |
| void gui::BaseCore::deleteVariable | ( | const QString & | varName | ) | [protected] |
"Remove" defined variable from scripting context
| varName | name of variable; |
| void gui::BaseCore::destroyDocument | ( | ) |
destroy document - destroy it also in scripting
| void gui::BaseCore::errorBadParameter | ( | const QString & | className, | |
| const QString & | methodName, | |||
| int | paramNum, | |||
| const QObject * | param, | |||
| const QString & | expected | |||
| ) |
Script error invoked when script function was executed with bad parameter
| className | Name of class, in which this error occured | |
| methodName | Name of method, in which this error occured | |
| paramNum | number of bad parameter | |
| param | Pointer to the QObject that was given as parameter | |
| expected | What was expected to see as parameter |
Referenced by gui::QSCObject::qobject_cast().
| void gui::BaseCore::errorException | ( | const QString & | className, | |
| const QString & | methodName, | |||
| const QString & | exceptionInfo | |||
| ) |
Script error invoked when script encounter an exception
| className | Name of class, in which this exception occured | |
| methodName | Name of method, in which this exception occured | |
| exceptionInfo | Extra exception information |
Referenced by gui::QSPage::addAnnotation(), gui::QSPage::addSystemType1Font(), gui::QSPage::appendContentStream(), gui::QSPdf::getFirstPage(), gui::QSPdf::getLastPage(), gui::QSPdf::getNextPage(), gui::QSPdf::getPage(), gui::QSPdf::getPrevPage(), gui::QSPdf::insertPage(), gui::QSPage::moveAbove(), gui::QSPage::moveBelow(), gui::QSPage::prependContentStream(), gui::QSPdfOperator::pushBack(), gui::QSTreeItem::remove(), gui::QSPdfOperator::remove(), gui::QSAnnotation::remove(), gui::QSPdf::removePage(), gui::QSPdf::save(), gui::QSPdf::saveAs(), gui::QSIProperty::set(), gui::QSPage::setMediabox(), gui::QSPdfOperator::setNext(), gui::QSPdfOperator::setPrev(), and gui::QSPage::setTransformMatrix().
| void gui::BaseCore::errorMessage | ( | ) | [protected] |
If there was some error since last call of this function or since last clearing the error message, display it. Clear the error message before returning.
Referenced by gui::Base::runFile(), and gui::Base::runScriptsFromPath().
| void gui::BaseCore::errorNullPointer | ( | const QString & | className, | |
| const QString & | methodName | |||
| ) |
Script error invoked when script tried to access a NULL pointer
| className | Name of class, in which this error occured | |
| methodName | Name of method, in which this error occured |
Referenced by gui::QSCObject::nullPtr().
| QSPdf * gui::BaseCore::getQSPdf | ( | ) | const |
Return QSA wrapper of current PDF document, or NULL if the wrapper is invalid or not present
| void gui::BaseCore::importDocument | ( | boost::shared_ptr< pdfobjects::CPdf > | ) |
Import currently edited document into scripting QSPDF wrapper will be created around the pdf document
| PDF to import under name "document" into scripting |
| QSInterpreter * gui::BaseCore::interpreter | ( | ) |
Return interpreter instance used to launch scripts in this context
| void gui::BaseCore::postRun | ( | ) | [protected, virtual] |
Function to be run after the script is executed BaseCore::postRun should be called in overrriden function if overiding with own function
Reimplemented in gui::BaseGUI.
| void gui::BaseCore::preRun | ( | const QString & | script, | |
| bool | callback = false | |||
| ) | [protected, virtual] |
Function to be run before the script is executed BaseCore::preRun should be called in overrriden function if overiding with own function
| script | Script code; | |
| callback | is it callback from script? |
Reimplemented in gui::BaseGUI.
| void gui::BaseCore::removeGC | ( | QSCObject * | o | ) |
Remove QSCObject from list of object to delete when file in editor window is closed
| o | Object to remove from cleanup-list |
Referenced by gui::QSCObject::~QSCObject().
| void gui::BaseCore::removeScriptingObjects | ( | ) | [protected, virtual] |
Removes objects added with addScriptingObjects
Reimplemented in gui::BaseGUI.
| void gui::BaseCore::removeTreeItemFromList | ( | QSTreeItem * | theWrap | ) |
Remove tree item wrapper from list of managed wrappers
Called from treeitem wrapper contructor
| theWrap | Tree item wrapper |
Referenced by gui::QSTreeItem::~QSTreeItem().
| void gui::BaseCore::runScript | ( | const QString & | script | ) |
Runs given script code
| script | QT Script code to run |
Referenced by gui::ConsoleWindow::eval().
| void gui::BaseCore::scriptError | ( | const QString & | message, | |
| const QString & | scriptName, | |||
| int | lineNumber | |||
| ) | [private, slot] |
Slot called on error in any script
| message | Error message | |
| scriptName | Name of script in which the error occured | |
| lineNumber |
| void gui::BaseCore::setConWriter | ( | ConsoleWriter * | _con | ) |
Set new console writer for this class. NULL mean no console writer, effectively turning off console output
| _con | Console writer |
| void gui::BaseCore::stopScript | ( | ) |
if any script is running, stop it
Q_PtrDict<QSCObject> gui::BaseCore::baseObjects [private] |
All Scripting objects created under this base. Will be used for purpose of garbage collection
ConsoleWriter* gui::BaseCore::con [private] |
Console writer handler
int gui::BaseCore::errLineNumber [private] |
Script line number for last-seen error message
QString gui::BaseCore::errMessage [private] |
Last-seen error message from script
QString gui::BaseCore::errScript [private] |
Script filename for last-seen error message
QSImporter* gui::BaseCore::import [protected] |
QSObject Importer
QSProject* gui::BaseCore::qp [protected] |
QSA Scripting Project
QSPdf* gui::BaseCore::qpdf [protected] |
QObject wrapper around CPdf (document) that is exposed to scripting. Lifetime of this class is the same as lifetime of document
QSInterpreter* gui::BaseCore::qs [protected] |
QSA Interpreter - taken from project
Referenced by gui::Base::print().
bool gui::BaseCore::treeReloadFlag [protected] |
Flag specifying if the tree have changed while running script to the degree it need to be reloaded
Referenced by gui::BaseGUI::removeScriptingObjects(), and gui::Base::~Base().
TreeBindingMap gui::BaseCore::treeWrap [protected] |
map containing trees to disable if necessary
Referenced by gui::Base::~Base().