Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

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"

Include dependency graph for util.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  ) 

Definition at line 632 of file util.cpp.

Referenced by getStringFromSequence().

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.

Author:
Craig Bradney
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  ) 

QString SCRIBUS_API CompressStr ( QString *  in  ) 

QByteArray SCRIBUS_API ComputeMD5Sum ( QByteArray *  in  ) 

int SCRIBUS_API copyFile ( QString  source,
QString  target 
)

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 
)

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 
)

QString SCRIBUS_API getDashString ( int  dashtype,
double  linewidth 
)

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
Author:
Petr Vanek

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  ) 

const QString SCRIBUS_API getStringFromSequence ( DocumentSectionType  type,
uint  position 
)

bool SCRIBUS_API loadRawBytes ( const QString &  filename,
QByteArray &  buf 
)

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 
)

WARNING: loadText is INCORRECT - use loadRawText instead!

Definition at line 186 of file util.cpp.

int SCRIBUS_API moveFile ( QString  source,
QString  target 
)

const QString SCRIBUS_API numberToLetterSequence ( uint  i  ) 

Definition at line 614 of file util.cpp.

Referenced by getStringFromSequence().

bool SCRIBUS_API overwrite ( QWidget *  parent,
QString  filename 
)

void SCRIBUS_API parsePagesString ( QString  pages,
std::vector< int > *  pageNs,
int  sourcePageCount 
)

QString SCRIBUS_API Path2Relative ( QString  Path,
const QString &  baseDir = QDir::currentPath() 
)

QString SCRIBUS_API readLinefromDataStream ( QDataStream &  s  ) 

QString SCRIBUS_API Relative2Path ( QString  File,
const QString &  baseDir = QDir::currentPath() 
)

void SCRIBUS_API ReOrderText ( ScribusDoc currentDoc,
ScribusView view 
)

void SCRIBUS_API sDebug ( QString  message  ) 

void SCRIBUS_API setCurrentComboItem ( QComboBox *  box,
QString  text 
)

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!

Author:
Petr Vanek
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 
)

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  ) 

performance measurements. It prints given message with it current timestamp. Useful for duration holes finding.

Author:
Petr Vanek

Definition at line 831 of file util.cpp.

char SCRIBUS_API* toAscii85 ( quint32  value,
bool &  allZero 
)

char SCRIBUS_API* toHex ( uchar  u  ) 

void SCRIBUS_API WordAndPara ( PageItem currItem,
int *  w,
int *  p,
int *  c,
int *  wN,
int *  pN,
int *  cN 
)

Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.