util.h File Reference
#include <vector>#include <QByteArray>#include <QColor>#include <QComboBox>#include <QDir>#include <QList>#include <QPainterPath>#include <QPixmap>#include <QString>#include <QStringList>#include <QTextStream>#include "pagestructs.h"#include "style.h"#include "styles/charstyle.h"#include "styles/paragraphstyle.h"#include "scribusapi.h"

Go to the source code of this file.
Functions | |
| bool SCRIBUS_API | compareDouble (double a, double b) |
| Compare double values by pre-multiplying by 10000 and converting to long if possible. If premultiplication does not allow to store result in a long value, perform a standard comparison. | |
| QStringList SCRIBUS_API | sortQStringList (QStringList aList) |
| Returns a sorted list of QStrings - sorted by locale specific rules! Uses compareQStrings() as rule. There is STL used! | |
| void SCRIBUS_API | ReOrderText (ScribusDoc *currentDoc, ScribusView *view) |
| void SCRIBUS_API | WordAndPara (PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN) |
| bool SCRIBUS_API | overwrite (QWidget *parent, QString filename) |
| QByteArray SCRIBUS_API | ComputeMD5Sum (QByteArray *in) |
| QString SCRIBUS_API | Path2Relative (QString Path, const QString &baseDir=QDir::currentPath()) |
| QString SCRIBUS_API | Relative2Path (QString File, const QString &baseDir=QDir::currentPath()) |
| char SCRIBUS_API * | toAscii85 (quint32 value, bool &allZero) |
| char SCRIBUS_API * | toHex (uchar u) |
| QString SCRIBUS_API | String2Hex (QString *in, bool lang=true) |
| QString SCRIBUS_API | CompressStr (QString *in) |
| QByteArray SCRIBUS_API | CompressArray (const QByteArray &in) |
| bool SCRIBUS_API | loadText (QString nam, QString *Buffer) |
| WARNING: loadText is INCORRECT - use loadRawText instead! | |
| bool SCRIBUS_API | loadRawText (const QString &filename, QByteArray &buf) |
| Replacement version of loadText that returns a QCString as an out parameter. The QCString is filled with the contents of the specified file. The return byte string is of unknown encoding; the caller must handle encoding issues. There is no need to preallocate the buffer, and the new data replaces any old contents. | |
| bool SCRIBUS_API | loadRawBytes (const QString &filename, QByteArray &buf) |
| QString SCRIBUS_API | GetAttr (QDomElement *el, QString at, QString def="0") |
| int SCRIBUS_API | System (const QString exename, const QStringList &args, const QString fileStdErr="", const QString fileStdOut="") |
| Synchronously execute a new process, optionally saving its output. | |
| int SCRIBUS_API | copyFile (QString source, QString target) |
| int SCRIBUS_API | moveFile (QString source, QString target) |
| QString SCRIBUS_API | checkFileExtension (const QString &, const QString &) |
| A quick function to make sure a filename has the correct extension and add it if not. | |
| QString SCRIBUS_API | getShortPathName (QString longPath) |
| On Windows, return short path name, else return longPath;. | |
| QString SCRIBUS_API | getFileNameByPage (ScribusDoc *currDoc, uint pageNo, QString extension) |
| Creates a common name for page exports (SVG, bitmap, EPS). Output format is: documentname-page01.extension. | |
| void SCRIBUS_API | sDebug (QString message) |
| const QString SCRIBUS_API | getStringFromSequence (DocumentSectionType type, uint position) |
| const QString SCRIBUS_API | arabicToRoman (uint i) |
| const QString SCRIBUS_API | numberToLetterSequence (uint i) |
| void SCRIBUS_API | parsePagesString (QString pages, std::vector< int > *pageNs, int sourcePageCount) |
| int SCRIBUS_API | findParagraphStyle (ScribusDoc *doc, const ParagraphStyle &parStyle) |
| int SCRIBUS_API | findParagraphStyle (ScribusDoc *doc, const QString &name) |
| void | tDebug (QString message) |
| performance measurements. It prints given message with it current timestamp. Useful for duration holes finding. | |
| QString SCRIBUS_API | readLinefromDataStream (QDataStream &s) |
| void SCRIBUS_API | setCurrentComboItem (QComboBox *box, QString text) |
| QString SCRIBUS_API | getDashString (int dashtype, double linewidth) |
| void SCRIBUS_API | getDashArray (int dashtype, double linewidth, QList< double > &m_array) |
Function Documentation
| const QString SCRIBUS_API arabicToRoman | ( | uint | i | ) |
| QString SCRIBUS_API checkFileExtension | ( | const QString & | currName, | |
| const QString & | extension | |||
| ) |
A quick function to make sure a filename has the correct extension and add it if not.
- Parameters:
-
currName Current filename extension File extension to ensure exists
Definition at line 554 of file util.cpp.
Referenced by PDFExportDialog::fileNameChanged().
| bool SCRIBUS_API compareDouble | ( | double | a, | |
| double | b | |||
| ) |
Compare double values by pre-multiplying by 10000 and converting to long if possible. If premultiplication does not allow to store result in a long value, perform a standard comparison.
Definition at line 299 of file util_math.cpp.
| QByteArray SCRIBUS_API CompressArray | ( | const QByteArray & | in | ) |
Definition at line 303 of file util.cpp.
References uLong().
Referenced by PDFLibCore::PDF_Begin_Doc(), PDFLibCore::PDF_Begin_Page(), PDFLibCore::PDF_End_Doc(), and PDFLibCore::PDF_Image().
| QString SCRIBUS_API CompressStr | ( | QString * | in | ) |
Definition at line 262 of file util.cpp.
References uLong().
Referenced by PDFLibCore::PDF_Begin_Doc(), PDFLibCore::PDF_DoLinGradient(), PDFLibCore::PDF_Gradient(), PDFLibCore::PDF_ProcessPage(), PDFLibCore::PDF_TemplatePage(), PDFLibCore::Write_TransparencyGroup(), and PDFLibCore::WritePDFStream().
| QByteArray SCRIBUS_API ComputeMD5Sum | ( | QByteArray * | in | ) |
Definition at line 372 of file util.cpp.
Referenced by PDFLibCore::CalcOwnerKey(), PDFLibCore::CalcUserKey(), PDFLibCore::ComputeMD5(), PDFLibCore::EncodeArrayToStream(), PDFLibCore::EncStream(), PDFLibCore::EncStreamArray(), PDFLibCore::EncString(), and PDFLibCore::EncStringUTF16().
| int SCRIBUS_API copyFile | ( | QString | source, | |
| QString | target | |||
| ) |
Definition at line 131 of file util.cpp.
Referenced by BibView::checkAndChange(), CollectForOutput::collectFile(), CollectForOutput::collectFonts(), CollectForOutput::collectProfiles(), Biblio::copyObj(), PrefsManager::copyOldPreferences(), and moveFile().
| int SCRIBUS_API findParagraphStyle | ( | ScribusDoc * | doc, | |
| const QString & | name | |||
| ) |
Definition at line 818 of file util.cpp.
References StyleSet< STYLE >::count(), and ScribusDoc::paragraphStyles().
| int SCRIBUS_API findParagraphStyle | ( | ScribusDoc * | doc, | |
| const ParagraphStyle & | parStyle | |||
| ) |
Definition at line 798 of file util.cpp.
References StyleSet< STYLE >::count(), Style::name(), and ScribusDoc::paragraphStyles().
Referenced by SearchReplace::clear(), SearchReplace::readPrefs(), SearchReplace::SearchReplace(), and Scribus13Format::WriteObjects().
| QString SCRIBUS_API GetAttr | ( | QDomElement * | el, | |
| QString | at, | |||
| QString | def = "0" | |||
| ) |
Definition at line 175 of file util.cpp.
Referenced by ScPreview::createPreview(), and BibView::ReadOldContents().
| void SCRIBUS_API getDashArray | ( | int | dashtype, | |
| double | linewidth, | |||
| QList< double > & | m_array | |||
| ) |
Definition at line 994 of file util.cpp.
References getDashString().
Referenced by LineCombo::createIcon(), ScPainter::drawVPath(), PropertiesPalette::NewLSty(), LineFormatItemDelegate::redraw(), PathStrokerPlugin::run(), ScPainterEx_GDIPlus::setPen(), ScPainterEx_GDI::setPen(), ScPainter::setPen(), and SMLineStyle::updatePreview().
| QString SCRIBUS_API getDashString | ( | int | dashtype, | |
| double | linewidth | |||
| ) |
Definition at line 869 of file util.cpp.
Referenced by getDashArray(), SVGExPlug::GetMultiStroke(), PDFLibCore::PDF_ProcessItem(), PDFLibCore::PDF_ProcessTableItem(), PDFLibCore::PDF_TemplatePage(), SVGExPlug::ProcessPage(), and PSLib::PS_setdash().
| QString SCRIBUS_API getFileNameByPage | ( | ScribusDoc * | currDoc, | |
| uint | pageNo, | |||
| QString | extension | |||
| ) |
Creates a common name for page exports (SVG, bitmap, EPS). Output format is: documentname-page01.extension.
- Parameters:
-
pageNo number of the exported page (begins from 1) extension "svg" or e.g. "png" etc.
- Return values:
-
QString standardized filename
Definition at line 570 of file util.cpp.
References ScribusDoc::DocName, ScribusDoc::FirstPnum, and tr().
Referenced by ExportBitmap::getFileName(), and SVGExportPlugin::run().
| QString SCRIBUS_API getShortPathName | ( | QString | longPath | ) |
On Windows, return short path name, else return longPath;.
Definition at line 112 of file util.cpp.
Referenced by callGS(), EPSPlug::convert(), convertPS2PS(), AIPlug::decompressAIData(), getGSVersion(), EPSPlug::Image(), AIPlug::import(), PPreview::RenderPreview(), PPreview::RenderPreviewSep(), testGSAvailability(), and testGSDeviceAvailability().
| const QString SCRIBUS_API getStringFromSequence | ( | DocumentSectionType | type, | |
| uint | position | |||
| ) |
Definition at line 584 of file util.cpp.
References arabicToRoman(), numberToLetterSequence(), Type_1_2_3, Type_a_b_c, Type_A_B_C, Type_i_ii_iii, Type_I_II_III, and Type_None.
Referenced by ScribusDoc::getSectionPageNumberForPageIndex().
| bool SCRIBUS_API loadRawBytes | ( | const QString & | filename, | |
| QByteArray & | buf | |||
| ) |
Definition at line 240 of file util.cpp.
Referenced by PDFLibCore::PDF_Begin_Doc(), PDFLibCore::PDF_End_Doc(), and PDFLibCore::PDF_Image().
| bool SCRIBUS_API loadRawText | ( | const QString & | filename, | |
| QByteArray & | buf | |||
| ) |
Replacement version of loadText that returns a QCString as an out parameter. The QCString is filled with the contents of the specified file. The return byte string is of unknown encoding; the caller must handle encoding issues. There is no need to preallocate the buffer, and the new data replaces any old contents.
Definition at line 114 of file desaxe_test.cpp.
Referenced by Biblio::adjustReferences(), Biblio::copyObj(), Scribus13Format::fileSupported(), Scribus134Format::fileSupported(), Scribus12Format::fileSupported(), ColorSetManager::initialiseDefaultPrefs(), ScribusMainWindow::initScMW(), ColorManager::loadDefaults(), TxtIm::loadText(), main(), PSLib::PS_image(), PSLib::PS_ImageData(), BibView::ReadContents(), ScriXmlDoc::ReadElem(), ScriXmlDoc::ReadElemHeader(), BibView::ReadOldContents(), Scribus13Format::readSLA(), Scribus134Format::readSLA(), Scribus12Format::readSLA(), Serializer::readWithEncoding(), BibView::SaveContents(), CMYKChoose::SelSwatch(), and BibView::startDrag().
| bool SCRIBUS_API loadText | ( | QString | nam, | |
| QString * | Buffer | |||
| ) |
| int SCRIBUS_API moveFile | ( | QString | source, | |
| QString | target | |||
| ) |
Definition at line 164 of file util.cpp.
References copyFile().
Referenced by AIPlug::decompressAIData(), ScPrintEngine_PS::print(), Printer_print(), PrefsManager::setupPreferencesLocation(), and ScribusWin::slotAutoSave().
| const QString SCRIBUS_API numberToLetterSequence | ( | uint | i | ) |
| bool SCRIBUS_API overwrite | ( | QWidget * | parent, | |
| QString | filename | |||
| ) |
Definition at line 411 of file util.cpp.
References tr().
Referenced by CollectForOutput::collectDocument(), PDFExportDialog::DoExport(), ScribusMainWindow::doPrint(), CurveWidget::doSave(), TabKeyboardShortcutsWidget::exportKeySet(), ScPrintEngine_GDI::print(), ScribusMainWindow::slotFileSaveAs(), and CharSelect::uniSaveButton_clicked().
| void SCRIBUS_API parsePagesString | ( | QString | pages, | |
| std::vector< int > * | pageNs, | |||
| int | sourcePageCount | |||
| ) |
Definition at line 740 of file util.cpp.
Referenced by ScribusDoc::itemAddUserFrame(), PixmapExportPlugin::run(), ScribusMainWindow::slotPageImport(), and ScribusMainWindow::slotReallyPrint().
| QString SCRIBUS_API Path2Relative | ( | QString | Path, | |
| const QString & | baseDir = QDir::currentPath() | |||
| ) |
Definition at line 380 of file util.cpp.
Referenced by PageItemXMLAttributes(), PDFLibCore::PDF_Annotation(), Annotation::saxx(), ScriXmlDoc::SetItemProps(), and Scribus134Format::SetItemProps().
| QString SCRIBUS_API readLinefromDataStream | ( | QDataStream & | s | ) |
Definition at line 838 of file util.cpp.
Referenced by AIPlug::convert(), PrinterUtil::getPrinterNames(), EPSPlug::import(), ColorManager::importColors(), ScImgDataLoader_PS::loadEmbeddedProfile(), ScImgDataLoader_PS::loadPhotoshopBinary(), ScImgDataLoader_PS::parseData(), AIPlug::parseHeader(), PDFLibCore::PDF_Image(), AIPlug::processComment(), AIPlug::processPattern(), AIPlug::processRaster(), and ScImgDataLoader_PS::scanForFonts().
| QString SCRIBUS_API Relative2Path | ( | QString | File, | |
| const QString & | baseDir = QDir::currentPath() | |||
| ) |
Definition at line 386 of file util.cpp.
Referenced by Scribus12Format::GetItemProps(), Scribus13Format::PasteItem(), and Scribus134Format::PasteItem().
| void SCRIBUS_API ReOrderText | ( | ScribusDoc * | currentDoc, | |
| ScribusView * | view | |||
| ) |
Definition at line 502 of file util.cpp.
References PageItem::DrawObj(), ScribusDoc::Items, PageItem::itemType, PageItem::layout(), ScribusDoc::MasterItems, PageItem::PathText, ScribusDoc::RePos, ScribusView::scale(), and ScribusView::setScale().
| void SCRIBUS_API sDebug | ( | QString | message | ) |
Definition at line 87 of file util.cpp.
Referenced by SCFonts::AddScalableFont(), StoryEditor::buildGUI(), ScFace_ttf::EmbedFont(), FtFace::ftFace(), FtFace::FtFace(), ScribusCore::getCMSProfilesDir(), FtFace::glyphKerning(), FtFace::load(), FtFace::loadGlyph(), HelpBrowser::loadMenu(), ScFace_ttf::RawData(), FtFace::RawData(), ScrPopupMenu::repopulateLocalMenu(), and FPointArray::resize().
| void SCRIBUS_API setCurrentComboItem | ( | QComboBox * | box, | |
| QString | text | |||
| ) |
Definition at line 860 of file util.cpp.
Referenced by AspellPluginImpl::AspellPluginImpl(), CheckDocument::buildErrorList(), SearchReplace::clear(), ColorManager::ColorManager(), Annot::DecodeNum(), TabCheckDoc::delProf(), ExportForm::ExportForm(), ExtImageProps::ExtImageProps(), FontComboH::familySelected(), FontReplaceDialog::FontReplaceDialog(), PageSelector::GotoPg(), TOCIndexPrefs::init(), InsPage::InsPage(), PageSelector::languageChange(), ColorManager::loadDefaults(), ScribusMainWindow::loadDoc(), Scribus12Format::loadFile(), MissingFont::MissingFont(), SearchReplace::readPrefs(), FontPrefs::rebuildDialog(), TabPDFOptions::restoreDefaults(), TabGeneral::restoreDefaults(), TabDocument::restoreDefaults(), TabCheckDoc::restoreDefaults(), HySettings::restoreDefaults(), ColorManager::saveDefaults(), tfDia::saveTextChanged(), SearchReplace::SearchReplace(), EffectsDialog::selectEffect(), TOCIndexPrefs::selectToC(), ExtImageProps::selLayer(), PrintDialog::SelPrinter(), FontComboH::setCurrentFont(), SMColorCombo::setCurrentText(), CharSelect::setDoc(), Tabruler::setFillChar(), SToolBFont::SetFont(), CharStyleComboBox::setFormat(), ParaStyleComboBox::setFormat(), ScribusView::setLayerMenuText(), PageSelector::setMaximum(), Tabruler::setTabFillChar(), TOCIndexPrefs::setupItemAttrs(), SMCStyleWidget::showLanguage(), SMLineStyleWidget::slotEditNewLine(), tfFilter::tfFilter(), and FontPrefs::UpdateFliste().
| QStringList SCRIBUS_API sortQStringList | ( | QStringList | aList | ) |
Returns a sorted list of QStrings - sorted by locale specific rules! Uses compareQStrings() as rule. There is STL used!
- Parameters:
-
aList unsorted string list
- Return values:
-
QStringList sorted string list
Definition at line 541 of file util.cpp.
References compareQStrings().
Referenced by SMCStyleWidget::fillLangCombo(), and PropertiesPalette::fillLangCombo().
| QString SCRIBUS_API String2Hex | ( | QString * | in, | |
| bool | lang = true | |||
| ) |
Definition at line 354 of file util.cpp.
References toHex().
Referenced by PDFLibCore::EncString(), PDFLibCore::EncStringUTF16(), PDFLibCore::PDF_Begin_Doc(), and PDFLibCore::PDF_End_Doc().
| int SCRIBUS_API System | ( | const QString | exename, | |
| const QStringList & | args, | |||
| const QString | fileStdErr = "", |
|||
| const QString | fileStdOut = "" | |||
| ) |
Synchronously execute a new process, optionally saving its output.
Create a new process via QProcess and wait until finished. Return the process exit code. Exit code 1 is returned if the process could not be started or terminated abnormally.
Note that the argument list is handled exactly as documented by QProcess. In particular, no shell metacharacter expansion is performed (so you can't use $HOME for example, and no quoting is required or appropriate), and each list entry is one argument.
If output file paths are provided, any existing file will be truncated and overwritten.
- Parameters:
-
args Arguments, as per QProcess documentation. fileStdErr Path to save error output to, or "" to discard. fileStdOut Path to save normal output to, or "" to discard.
- Returns:
- Program exit code, or 1 on failure.
Definition at line 92 of file util.cpp.
Referenced by callGS(), EPSPlug::convert(), convertPS2PS(), EPSPlug::Image(), UrlLauncher::launchUrlExt(), PPreview::RenderPreview(), and PPreview::RenderPreviewSep().
| void tDebug | ( | QString | message | ) |
| char SCRIBUS_API* toAscii85 | ( | quint32 | value, | |
| bool & | allZero | |||
| ) |
Definition at line 319 of file util.cpp.
Referenced by ScASCII85EncodeFilter::closeFilter(), ScPainterEx_Ps2::writeCMYKImageToStream_Ascii85(), ScASCII85EncodeFilter::writeData(), and ScPainterEx_Ps2::writeRGBImageToStream_Ascii85().
| char SCRIBUS_API* toHex | ( | uchar | u | ) |
Definition at line 336 of file util.cpp.
Referenced by PDFLibCore::setTextCh(), String2Hex(), ScPainterEx_Ps2::writeCMYKImageToStream_AsciiHex(), ScPainterEx_Ps2::writeMaskToStream(), PDFLibCore::WritePDFString(), and ScPainterEx_Ps2::writeRGBImageToStream_AsciiHex().
| void SCRIBUS_API WordAndPara | ( | PageItem * | currItem, | |
| int * | w, | |||
| int * | p, | |||
| int * | c, | |||
| int * | wN, | |||
| int * | pN, | |||
| int * | cN | |||
| ) |
Definition at line 427 of file util.cpp.
References PageItem::firstInFrame(), PageItem::frameOverflows(), PageItem::itemText, PageItem::lastInFrame(), StoryText::length(), PageItem::nextInChain(), SpecialChars::PARSEP, PageItem::prevInChain(), and StoryText::text().
Referenced by PageItem_TextFrame::createInfoGroup(), and PageItem_PathText::createInfoGroup().
