Utility namespace. More...
Enumerations | |
| enum | CharsetContext { PDF, CON, NAME, UTF8 } |
Functions | |
| QString | getTypeName (PropertyType typ) |
| QString | getTypeId (PropertyType typ) |
| QString | getTypeName (IProperty *obj) |
| QString | getTypeName (boost::shared_ptr< IProperty > obj) |
| QString | propertyPreview (boost::shared_ptr< IProperty > obj) |
| QString | getTypeId (IProperty *obj) |
| QString | getTypeId (boost::shared_ptr< IProperty > obj) |
| IndiRef | getRef (IProperty *ref) |
| IndiRef | getRef (boost::shared_ptr< IProperty > ref) |
| bool | isRefValid (boost::shared_ptr< CPdf > pdf, IndiRef ref) |
| bool | isSimple (IProperty *prop) |
| boost::shared_ptr< IProperty > | dereference (boost::shared_ptr< IProperty > obj) |
| bool | isSimple (boost::shared_ptr< IProperty > prop) |
| bool | saveCopy (boost::shared_ptr< CPdf > obj, const QString &name, QString *error) |
| template<typename T > | |
| boost::shared_ptr< IProperty > | _recursiveProperty (boost::shared_ptr< T > obj, const QString &name) |
| boost::shared_ptr< IProperty > | recursiveProperty (boost::shared_ptr< CDict > obj, const QString &name) |
| boost::shared_ptr< IProperty > | recursiveProperty (boost::shared_ptr< CArray > obj, const QString &name) |
| boost::shared_ptr< IProperty > | getObjProperty (boost::shared_ptr< CDict > obj, const QString &name) |
| boost::shared_ptr< IProperty > | getObjProperty (boost::shared_ptr< CArray > obj, const QString &name) |
| QString | annotType (CAnnotation::AnnotType at) |
| QString | annotType (boost::shared_ptr< CAnnotation > anot) |
| QString | annotTypeName (boost::shared_ptr< CAnnotation > anot) |
| boost::shared_ptr< CPdf > | getPdfInstance (QWidget *parent, const QString &filename, CPdf::OpenMode mode, bool askPassword) |
| bool | setPdfPassword (boost::shared_ptr< CPdf > pdf, const QString &pass) |
| QVariant | varFromDoubleArray (double *d, int count) |
| int | varToDoubleArray (const QVariant &v, double *out, int out_size) |
| void | fatalError (const QString &message) |
| QString | htmlEnt (const QString &str) |
| int | findSep (int start, const QString &line, char separator) |
| QStringList | explode (char separator, const QString &line, bool escape) |
| QString | loadFromFile (const QString &name) |
| bool | saveToFile (const QString &name, const QString &content) |
| bool | saveRawToFile (const QString &name, const QByteArray &content) |
| void | printList (const QStringList &l) |
| void | consoleLog (const QString &message, const QString &fileName) |
| void | escapeSlash (QString &line) |
| QString | getUntil (char separator, QString &line, bool escape) |
| void | setDebugLevel (const QString ¶m) |
| QString | countString (int count, QString singular, QString plural) |
| QColor | mixColor (const QColor &oldColor, double weight, const QColor &newColor) |
| void | colorMod (QWidget *widget, QColor fg, double weight_fg, QColor bg, double weight_bg) |
| QStringList | countList (unsigned int count, unsigned int start) |
| QStringList | supportedEncodings () |
| void | setDefaultCharset (const QString &charsetName) |
| QString | convertToUnicode (const std::string &str, CharsetContext ctx) |
| std::string | convertFromUnicode (const QString &str, CharsetContext ctx) |
Variables | |
| QTextCodec * | defCodec = NULL |
Utility namespace.
Utility namespace
Contains various static utility functions, used in GUI
| enum util::CharsetContext |
| boost::shared_ptr<IProperty> util::_recursiveProperty | ( | boost::shared_ptr< T > | obj, | |
| const QString & | name | |||
| ) | [inline] |
recursive CDict/CArray getProperty(...) Will take the name as slash-separated list of childs to traverse to get to target property. References on the way are automatically dereferenced Can throw exception if some property is not found on the way
| obj | CDict/CArray to start the search | |
| name | Path to property |
References debug::DBG_DBG, dereference(), getObjProperty(), guiPrintDbg, Q_OUT, and recursiveProperty().
| QString util::annotType | ( | boost::shared_ptr< CAnnotation > | anot | ) |
Return type identifier of annotation
| anot | Annotation |
| QString util::annotType | ( | CAnnotation::AnnotType | at | ) |
Return type identifier of annotation type
| at | Annotation type |
Referenced by pdfobjects::utils::UniversalAnnotInitializer::getSupportedList(), and gui::QSAnnotation::getType().
| QString util::annotTypeName | ( | boost::shared_ptr< CAnnotation > | anot | ) |
Return human readable, localized type identifier of annotation
| anot | Annotation |
Referenced by gui::QSAnnotation::getTypeName(), and gui::TreeItemAnnotation::reloadSelf().
| void util::colorMod | ( | QWidget * | widget, | |
| QColor | fg, | |||
| double | weight_fg, | |||
| QColor | bg, | |||
| double | weight_bg | |||
| ) |
Modify widget foreground and background color by blending with new colors using given weight
| widget | Widget to modify | |
| fg | new foreground color | |
| weight_fg | weight of new foreground color | |
| bg | new background color | |
| weight_bg | weight of new background color |
Referenced by gui::Property::initLabel(), and gui::Property::modifyColor().
| void util::consoleLog | ( | const QString & | message, | |
| const QString & | fileName | |||
| ) |
Write line to specified logfile
| message | Line to write to logfile | |
| fileName | Name of log file. If this is null or empty string, nothing is done |
Referenced by gui::CommandWindow::addCommand(), gui::CommandWindow::addError(), and gui::CommandWindow::addString().
| std::string util::convertFromUnicode | ( | const QString & | str, | |
| CharsetContext | ctx | |||
| ) |
Return std::string from QString with optional character conversion according to settings
| str | String to convert | |
| ctx | Context of conversion (PDF, console, filename ...) |
Referenced by gui::QSStream::add(), gui::QSDict::add(), gui::QSArray::add(), MenuGenerator::addLocString(), gui::QSPage::addSystemType1Font(), MenuGenerator::check(), gui::TreeItemDict::createChild(), gui::TreeItemCStream::createChild(), gui::Base::createOperator(), gui::Base::createPdfOperatorStack(), gui::TreeItemDict::deepReload(), gui::QSStream::delProperty(), gui::QSDict::delProperty(), gui::QSStream::exist(), gui::QSDict::exist(), gui::PageSpace::findText(), gui::TreeItemDict::getChildType(), gui::TreeItemCStream::getChildType(), gui::QSPage::getFontId(), handleHelp(), handleHelpOptions(), gui::MergeDialog::initFileList(), gui::PropertyModeController::mode(), gui::ConsoleWriterConsole::printCommand(), gui::ConsoleWriterConsole::printErrorLine(), gui::ConsoleWriterConsole::printLine(), gui::QSStream::property(), gui::QSDict::property(), gui::PropertyModeController::PropertyModeController(), gui::TreeItemDict::remove(), gui::TreeItemCStream::remove(), gui::QSIProperty::set(), gui::StringProperty::setValue(), gui::NameProperty::setValue(), gui::TreeItemDict::validChild(), and gui::TreeItemCStream::validChild().
| QString util::convertToUnicode | ( | const std::string & | str, | |
| CharsetContext | ctx | |||
| ) |
Return QString from std::string with optional character conversion according to settings
| str | String to convert | |
| ctx | Context of conversion (PDF, console, filename ...) |
Referenced by gui::TreeItemDict::getChildNames(), gui::TreeItemCStream::getChildNames(), gui::QSStream::getDecoded(), gui::QSPdfOperator::getEncodedText(), gui::QSPage::getFontId(), gui::QSPage::getFontIdsAndNames(), gui::QSPdfOperator::getName(), gui::QSPdfOperator::getText(), gui::QSIProperty::getText(), gui::QSDict::getText(), gui::QSArray::getText(), gui::TreeItemPdfOperator::itemHint(), gui::QSStream::propertyNames(), gui::QSDict::propertyNames(), gui::StringProperty::readValue(), gui::NameProperty::readValue(), gui::TreeItemPdfOperator::reloadSelf(), and gui::QSIProperty::value().
| QStringList util::countList | ( | unsigned int | count, | |
| unsigned int | start | |||
| ) |
Return string list containing 'count' items, numbered from 'start' to 'start+count-1'
| count | number of items in list | |
| start | first item in the list |
Referenced by gui::TreeItemOperatorContainer::getQSObject(), gui::TreeItemAnnotationContainer::getQSObject(), and gui::TreeItemPdf::haveChild().
| QString util::countString | ( | int | count, | |
| QString | singular, | |||
| QString | plural | |||
| ) |
Return correctly localized string telling count of some items. Some languages (for example Czech) have more plural forms (2-4 items / 5 or more items), which is handled here
| count | Count of items | |
| singular | English signular form of the noun, without space before the word | |
| plural | English plural form of the noun |
Referenced by gui::TreeItemPdf::createChild(), and gui::TreeItemPdfOperator::reloadSelf().
| boost::shared_ptr< IProperty > util::dereference | ( | boost::shared_ptr< IProperty > | obj | ) |
Return referenced IProperty for given reference, or the property itself in case property is not a reference Return NULL (empty shared_ptr) on error
| obj | Reference to dereference |
Referenced by _recursiveProperty(), gui::TreeItemRef::getChildType(), and gui::QSIProperty::ref().
| void util::escapeSlash | ( | QString & | line | ) |
Replace two backslashes followed by any character (escaped character) with that character
| line | String in which to remove extra backslashes (in,out) |
| QStringList util::explode | ( | char | separator, | |
| const QString & | line, | |||
| bool | escape | |||
| ) |
splits QString containing elements separated with given character All whitespaces from beginning and end of elements are trimmed
| separator | Separator of elements | |
| line | String containing elements separated with separator | |
| escape | If true, "\\" will be converted to "\" and \(separator) will be converted to (separator) and not treated as separator |
Referenced by gui::QSMenu::addItemDef(), gui::Menu::optimizeItems(), gui::QSMenu::QSMenu(), gui::Settings::restoreSplitter(), gui::Settings::restoreWindow(), and MenuGenerator::setAvail().
| void util::fatalError | ( | const QString & | message | ) |
Prints error message and terminates application
| message | Error message to show |
Referenced by handleParams(), main(), nextParam(), MenuGenerator::setAvail(), and MenuGenerator::translate().
| int util::findSep | ( | int | start, | |
| const QString & | line, | |||
| char | separator | |||
| ) |
Find first occurence of separator in string and return its position, ignoring backslash-escaped separators If separator is not found, -1 is returned
| start | Start searching from this position in string | |
| separator | Separator of string elements | |
| line | String to look for separator |
| boost::shared_ptr< IProperty > util::getObjProperty | ( | boost::shared_ptr< CArray > | obj, | |
| const QString & | name | |||
| ) |
Get property from Array based in QString key
| obj | Array to get property from | |
| name | name of property (must be convertable to number) |
| boost::shared_ptr< IProperty > util::getObjProperty | ( | boost::shared_ptr< CDict > | obj, | |
| const QString & | name | |||
| ) |
Get property from Dict based in QString key
| obj | Dict to get property from | |
| name | name of property |
Referenced by _recursiveProperty().
| boost::shared_ptr< CPdf > util::getPdfInstance | ( | QWidget * | parent, | |
| const QString & | filename, | |||
| CPdf::OpenMode | mode, | |||
| bool | askPassword | |||
| ) |
Get PDF instance - call CPdf::getInstance with appropriate parameters
| parent | parent widget of dialog that may spawn | |
| filename | Name of file for CPdf::getInstance | |
| mode | Open mode for CPdf::getInstance | |
| askPassword | If true, password will be asked for if necessary |
Referenced by gui::SelectPagesDialog::init(), and gui::MergeDialog::initFileList().
| IndiRef util::getRef | ( | boost::shared_ptr< IProperty > | ref | ) |
Get value (reference target) of CRef
| ref | CRef reference object |
| IndiRef util::getRef | ( | IProperty * | ref | ) |
Get value (reference target) of CRef
| ref | CRef reference object |
| QString util::getTypeId | ( | boost::shared_ptr< IProperty > | obj | ) |
Return string identifier of given type
| obj | Object to get type from (IProperty) |
| QString util::getTypeId | ( | IProperty * | obj | ) |
Return string identifier of given type
| obj | Object to get type from (IProperty) |
| QString util::getTypeId | ( | PropertyType | typ | ) |
Return string identifier of given type
| typ | Type of PDF Object |
Referenced by gui::QSIProperty::getType().
| QString util::getTypeName | ( | boost::shared_ptr< IProperty > | obj | ) |
Return human-readable (and possibly localized) name of given object's type
| obj | Object to get type from (IProperty) |
| QString util::getTypeName | ( | IProperty * | obj | ) |
Return human-readable (and possibly localized) name of given object's type
| obj | Object to get type from (IProperty) |
| QString util::getTypeName | ( | PropertyType | typ | ) |
Return human-readable (and possibly localized) name of given type
| typ | Type of PDF Object |
Referenced by gui::AddItemDialog::AddItemDialog(), gui::RefPropertyDialog::check(), gui::PropertyEditor::commitProperty(), gui::TreeItem::create(), gui::TreeItem::init(), gui::TreeItemRef::reloadSelf(), and gui::TreeItemSimple::setObject().
| QString util::getUntil | ( | char | separator, | |
| QString & | line, | |||
| bool | escape | |||
| ) |
Return string from line up to first separator character and remove that string and the separator from the line. If separator is not found, entire string is returned and the line is set to empty string
| separator | Separator of string elements | |
| line | line to get from and remove first element | |
| escape | If true, "\\" will be converted to "\" and \(separator) will be converted to (separator) and not treated as separator |
| QString util::htmlEnt | ( | const QString & | str | ) |
Convert < > and & characters to corresponding html entities (> < &)
| str | String to convert |
Referenced by gui::CommandWindow::addCommand(), gui::CommandWindow::addError(), and gui::CommandWindow::addString().
| bool util::isRefValid | ( | boost::shared_ptr< CPdf > | pdf, | |
| IndiRef | ref | |||
| ) |
Check for validity of reference - if ref is valid reference (have target) in given CPdf
| pdf to check for reference | ||
| ref | Indirect reference to check |
| bool util::isSimple | ( | boost::shared_ptr< IProperty > | prop | ) |
Return true, if this is simple property (editable as item in property editor and have no children), false otherwise
| prop | IProperty to check |
| bool util::isSimple | ( | IProperty * | prop | ) |
Return true, if this is simple property (editable as item in property editor and have no children), false otherwise
| prop | IProperty to check |
Referenced by gui::TreeItemDict::getChildNames(), gui::TreeItemCStream::getChildNames(), and gui::TreeItemArray::getChildNames().
| QString util::loadFromFile | ( | const QString & | name | ) |
Load content of file to string. NULL string is returned if file does not exist or is unreadable. It is assumed that the file is in utf8 encoding
| name | Filename of file to load |
| QColor util::mixColor | ( | const QColor & | oldColor, | |
| double | weight, | |||
| const QColor & | newColor | |||
| ) |
Mix colors from oldColor and newColor according to weight Weight should be between 0 and 1, 1 meaning the color will be "new", 0 meaning the color will be "old", everything else mean linear interpolation between new color (with given weight) and old color (with weight of (1-weight))
| weight | Weight of new color. | |
| oldColor | Old color | |
| newColor | New color |
| void util::printList | ( | const QStringList & | l | ) |
Print stringlist to stdout
| l | String list to print |
| QString util::propertyPreview | ( | boost::shared_ptr< IProperty > | obj | ) |
Return short textual preview of what's in the property
| obj | property for preview |
Referenced by gui::RefPropertyDialog::check().
| boost::shared_ptr< IProperty > util::recursiveProperty | ( | boost::shared_ptr< CArray > | obj, | |
| const QString & | name | |||
| ) |
recursive CDict/CArray getProperty(...) Will take the name as slash-separated list of childs to traverse to get to target property. References on the way are automatically dereferenced Can throw exception if some property is not found on the way
| obj | CDict/CArray to start the search | |
| name | Path to property |
| boost::shared_ptr< IProperty > util::recursiveProperty | ( | boost::shared_ptr< CDict > | obj, | |
| const QString & | name | |||
| ) |
recursive CDict/CArray getProperty(...) Will take the name as slash-separated list of childs to traverse to get to target property. References on the way are automatically dereferenced Can throw exception if some property is not found on the way
| obj | CDict/CArray to start the search | |
| name | Path to property |
Referenced by _recursiveProperty(), gui::QSDict::child(), and gui::QSArray::child().
| bool util::saveCopy | ( | boost::shared_ptr< CPdf > | obj, | |
| const QString & | name, | |||
| QString * | error | |||
| ) |
Save currently active revision in document under different filename
| obj | Pdf document | |
| name | New name | |
| error | String that will receive error message if saving failed. If null, no message will b e received |
failed to open file
Referenced by gui::QSPdf::saveAs().
| bool util::saveRawToFile | ( | const QString & | name, | |
| const QByteArray & | content | |||
| ) |
Save raw bytes into file.
| name | Filename of file to write to. It will be overwritten. | |
| content | Buffer to write. |
| bool util::saveToFile | ( | const QString & | name, | |
| const QString & | content | |||
| ) |
Save string into file with utf8 encoding.
| name | Filename of file to write to. It will be overwritten. | |
| content | String to write. |
| void util::setDebugLevel | ( | const QString & | param | ) |
Set debugging verbosity level. Accept debugging level either as number, or as one of symbolic constants:
PANIC, CRITICAL, ERROR, WARNING, INFO, DEBUG, DBG (=DEBUG)
Constants are case insensitive, starting part of constant is sufficient
Only messages with priority equal or higher to specified level are shown
| param | new debugging level |
Referenced by handleDebug().
| void util::setDefaultCharset | ( | const QString & | charsetName | ) |
set default charset used when reading (and writing) property values
| charsetName | charset name used for all 8bit to/from unicode conversions |
Referenced by main().
| bool util::setPdfPassword | ( | boost::shared_ptr< CPdf > | pdf, | |
| const QString & | pass | |||
| ) |
Try to set PDF password for document.
| CPdf instance | ||
| pass | Password to use |
Referenced by gui::QSPdf::setPassword().
| QStringList util::supportedEncodings | ( | ) |
Return list of supported text encodings (Based on support from QTextCodec in Qt)
| QVariant util::varFromDoubleArray | ( | double * | d, | |
| int | count | |||
| ) |
Convert array of double values to variant
| d | Pointer to array fo doubles | |
| count | number of elements in the array |
Referenced by gui::Base::transformationMatrixMul().
| int util::varToDoubleArray | ( | const QVariant & | v, | |
| double * | out, | |||
| int | out_size | |||
| ) |
Convert variant to array of doubles. If size of variant array is larger than out_size, only part will be converted. If size is smaller, output array will be zero-padded
| v | Variant to convert | |
| out | pointer to array of doubles | |
| out_size | number of elements in output array. |
| QTextCodec* util::defCodec = NULL |
Codec for default charset