Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

util.cpp File Reference

#include <QBitmap>
#include <QByteArray>
#include <QCheckBox>
#include <QDomElement>
#include <QFile>
#include <QFileInfo>
#include <QImageReader>
#include <QList>
#include <QPixmap>
#include <QWidget>
#include <QDir>
#include <QCryptographicHash>
#include <cmath>
#include <algorithm>
#include "util.h"
#include "scpainter.h"
#include "scconfig.h"
#include "pageitem_textframe.h"
#include "commonstrings.h"
#include "prefsmanager.h"
#include <QProcess>
#include "scmessagebox.h"
#include "scpixmapcache.h"
#include "scpaths.h"
#include <jpeglib.h>
#include <jerror.h>
#include "pageitem.h"
#include "scribus.h"
#include "scribusdoc.h"
#include "scribusview.h"
#include <zlib.h>

Include dependency graph for util.cpp:

Go to the source code of this file.

Defines

#define XMD_H

Functions

void sDebug (QString message)
int System (const QString exename, const QStringList &args, const QString fileStdErr, const QString fileStdOut)
 Synchronously execute a new process, optionally saving its output.
QString getShortPathName (QString longPath)
 On Windows, return short path name, else return longPath;.
int copyFile (QString source, QString target)
int moveFile (QString source, QString target)
QString GetAttr (QDomElement *el, QString at, QString def)
bool loadText (QString filename, QString *Buffer)
 WARNING: loadText is INCORRECT - use loadRawText instead!
bool 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 loadRawBytes (const QString &filename, QByteArray &buf)
QString CompressStr (QString *in)
QByteArray CompressArray (const QByteArray &in)
char * toAscii85 (quint32 value, bool &allZero)
char * toHex (uchar u)
QString String2Hex (QString *in, bool lang)
QByteArray ComputeMD5Sum (QByteArray *in)
QString Path2Relative (QString Path, const QString &baseDir)
QString Relative2Path (QString File, const QString &baseDir)
bool overwrite (QWidget *parent, QString filename)
void WordAndPara (PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN)
void ReOrderText (ScribusDoc *currentDoc, ScribusView *view)
bool compareQStrings (QString s1, QString s2)
 Helper function for sorting in sortQStringList.
QStringList sortQStringList (QStringList aList)
 Returns a sorted list of QStrings - sorted by locale specific rules! Uses compareQStrings() as rule. There is STL used!
QString checkFileExtension (const QString &currName, const QString &extension)
 A quick function to make sure a filename has the correct extension and add it if not.
QString getFileNameByPage (ScribusDoc *currDoc, uint pageNo, QString extension)
 Creates a common name for page exports (SVG, bitmap, EPS). Output format is: documentname-page01.extension.
const QString getStringFromSequence (DocumentSectionType type, uint position)
const QString numberToLetterSequence (uint i)
const QString arabicToRoman (uint i)
void parsePagesString (QString pages, std::vector< int > *pageNs, int sourcePageCount)
int findParagraphStyle (ScribusDoc *doc, const ParagraphStyle &parStyle)
int 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 readLinefromDataStream (QDataStream &s)
void setCurrentComboItem (QComboBox *box, QString text)
QString getDashString (int dashtype, double linewidth)
void getDashArray (int dashtype, double linewidth, QList< double > &m_array)


Define Documentation

#define XMD_H

Definition at line 66 of file util.cpp.


Function Documentation

const QString arabicToRoman ( uint  i  ) 

Definition at line 632 of file util.cpp.

Referenced by getStringFromSequence().

QString 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 compareQStrings ( QString  s1,
QString  s2 
)

Helper function for sorting in sortQStringList.

Author:
10/06/2004 - pv
Parameters:
s1 first string
s2 second string
Return values:
bool t/f related s1>s2

Definition at line 534 of file util.cpp.

Referenced by sortQStringList().

QByteArray CompressArray ( const QByteArray &  in  ) 

QString CompressStr ( QString *  in  ) 

QByteArray ComputeMD5Sum ( QByteArray *  in  ) 

int copyFile ( QString  source,
QString  target 
)

int findParagraphStyle ( ScribusDoc doc,
const QString &  name 
)

Definition at line 818 of file util.cpp.

References StyleSet< STYLE >::count(), and ScribusDoc::paragraphStyles().

int findParagraphStyle ( ScribusDoc doc,
const ParagraphStyle parStyle 
)

QString GetAttr ( QDomElement *  el,
QString  at,
QString  def 
)

Definition at line 175 of file util.cpp.

Referenced by ScPreview::createPreview(), and BibView::ReadOldContents().

void getDashArray ( int  dashtype,
double  linewidth,
QList< double > &  m_array 
)

QString getDashString ( int  dashtype,
double  linewidth 
)

QString 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 getShortPathName ( QString  longPath  ) 

const QString getStringFromSequence ( DocumentSectionType  type,
uint  position 
)

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

bool 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 218 of file util.cpp.

bool loadText ( QString  filename,
QString *  Buffer 
)

int moveFile ( QString  source,
QString  target 
)

const QString numberToLetterSequence ( uint  i  ) 

Definition at line 614 of file util.cpp.

Referenced by getStringFromSequence().

bool overwrite ( QWidget *  parent,
QString  filename 
)

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

QString Path2Relative ( QString  Path,
const QString &  baseDir 
)

QString readLinefromDataStream ( QDataStream &  s  ) 

QString Relative2Path ( QString  File,
const QString &  baseDir 
)

void ReOrderText ( ScribusDoc currentDoc,
ScribusView view 
)

void sDebug ( QString  message  ) 

void setCurrentComboItem ( QComboBox *  box,
QString  text 
)

QStringList 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 String2Hex ( QString *  in,
bool  lang 
)

int 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* toAscii85 ( quint32  value,
bool &  allZero 
)

char* toHex ( uchar  u  ) 

void 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.