Subversion Repositories Scribus

Rev

Rev 11234 | Rev 11595 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
2530 craig 7
#ifndef _UTIL_H
8
#define _UTIL_H
9
 
4464 cbradney 10
#include <vector>
11
 
10259 jghali 12
#include <QByteArray>
10203 cbradney 13
#include <QColor>
10648 fschmid 14
#include <QComboBox>
10259 jghali 15
#include <QDir>
16
#include <QList>
17
#include <QPainterPath>
18
#include <QPixmap>
10203 cbradney 19
#include <QString>
20
#include <QStringList>
9970 fschmid 21
#include <QTextStream>
2530 craig 22
 
3808 cbradney 23
#include "pagestructs.h"
6125 cbradney 24
#include "style.h"
8337 avox 25
#include "styles/charstyle.h"
26
#include "styles/paragraphstyle.h"
2969 craig 27
#include "scribusapi.h"
2530 craig 28
 
29
class ScribusDoc;
5184 avox 30
class ParagraphStyle;
2530 craig 31
class QDomElement;
6125 cbradney 32
class QWidget;
2530 craig 33
class ScribusView;
34
struct CopyPasteBuffer;
35
class PageItem;
6125 cbradney 36
// class Foi;
2530 craig 37
 
9403 jghali 38
/*! \brief Compare double values by pre-multiplying by 10000 and converting to long if possible.
39
If premultiplication does not allow to store result in a long value, perform a standard comparison.
40
*/
41
bool SCRIBUS_API compareDouble(double a, double b);
42
 
4449 subik 43
/*! \brief Returns a sorted list of QStrings - sorted by locale specific rules!
44
Uses compareQStrings() as rule. There is STL used!
45
\author Petr Vanek
4645 subik 46
\param aList unsorted string list
4449 subik 47
\retval QStringList sorted string list
48
 */
2969 craig 49
QStringList SCRIBUS_API sortQStringList(QStringList aList);
50
void SCRIBUS_API ReOrderText(ScribusDoc *currentDoc, ScribusView *view);
51
void SCRIBUS_API WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
52
bool SCRIBUS_API overwrite(QWidget *parent, QString filename);
53
QByteArray SCRIBUS_API ComputeMD5Sum(QByteArray *in);
10394 cbradney 54
QString SCRIBUS_API Path2Relative(QString Path, const QString& baseDir = QDir::currentPath());
55
QString SCRIBUS_API Relative2Path(QString File, const QString& baseDir = QDir::currentPath());
11107 jghali 56
char SCRIBUS_API *toAscii85( quint32 value, bool& allZero );
2969 craig 57
char SCRIBUS_API *toHex( uchar u );
58
QString SCRIBUS_API String2Hex(QString *in, bool lang = true);
59
QString SCRIBUS_API CompressStr(QString *in);
11317 jghali 60
QByteArray SCRIBUS_API CompressArray(const QByteArray& in);
4449 subik 61
//! \brief WARNING: loadText is INCORRECT - use loadRawText instead!
2969 craig 62
bool SCRIBUS_API loadText(QString nam, QString *Buffer);
4449 subik 63
/*! \brief Replacement version of loadText that returns a QCString as an out parameter.
64
The QCString is filled with the contents of the specified file. The return
65
byte string is of unknown encoding; the caller must handle encoding issues.
66
There is no need to preallocate the buffer, and the new data replaces any
67
old contents. */
9535 fschmid 68
bool SCRIBUS_API loadRawText(const QString & filename, QByteArray & buf);
5234 fschmid 69
bool SCRIBUS_API loadRawBytes(const QString & filename, QByteArray & buf);
2969 craig 70
QString SCRIBUS_API GetAttr(QDomElement *el, QString at, QString def="0");
4449 subik 71
/**
72
* @brief Synchronously execute a new process, optionally saving its output
73
   *
74
   * Create a new process via QProcess and wait until finished.  Return the
75
   * process exit code. Exit code 1 is returned if the process could not be
76
   * started or terminated abnormally.
77
   *
78
   * Note that the argument list is handled exactly as documented by QProcess.
79
   * In particular, no shell metacharacter expansion is performed (so you can't
80
   * use $HOME for example, and no quoting is required or appropriate), and each
81
   * list entry is one argument.
82
   *
83
   * If output file paths are provided, any existing file will be truncated and
84
   * overwritten.
85
   *
86
   * @param args Arguments, as per QProcess documentation.
87
   * @param fileStdErr Path to save error output to, or "" to discard.
88
   * @param fileStdOut Path to save normal output to, or "" to discard.
89
   * @return Program exit code, or 1 on failure.
90
   *
91
*/
10006 cbradney 92
int SCRIBUS_API System(const QString exename, const QStringList & args, const QString fileStdErr = "", const QString fileStdOut = "");
2969 craig 93
int SCRIBUS_API copyFile(QString source, QString target);
94
int SCRIBUS_API moveFile(QString source, QString target);
4449 subik 95
/*!
96
 \fn QString checkFileExtension(const QString &currName, const QString &extension)
97
 \author Craig Bradney
98
 \brief A quick function to make sure a filename has the correct extension and add it if not
99
 \param currName Current filename
100
 \param extension File extension to ensure exists
101
 */
2969 craig 102
QString SCRIBUS_API checkFileExtension(const QString &, const QString &);
4449 subik 103
//! \brief On Windows, return short path name, else return longPath;
2969 craig 104
QString SCRIBUS_API getShortPathName(QString longPath);
4449 subik 105
/*! \brief Creates a common name for page exports (SVG, bitmap, EPS).
106
   Output format is: documentname-page01.extension
107
   \param pageNo number of the exported page (begins from 1)
108
   \param extension "svg" or e.g. "png" etc.
109
   \retval QString standardized filename
110
   \author Petr Vanek
111
 */
5781 cbradney 112
QString SCRIBUS_API getFileNameByPage(ScribusDoc* currDoc, uint pageNo, QString extension);
3240 fschmid 113
void SCRIBUS_API sDebug(QString message);
3757 cbradney 114
const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position);
3784 cbradney 115
const QString SCRIBUS_API arabicToRoman(uint i);
116
const QString SCRIBUS_API numberToLetterSequence(uint i);
117
void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
5184 avox 118
 
119
#ifndef NLS_CONFORMANCE
5581 jghali 120
int SCRIBUS_API findParagraphStyle(ScribusDoc* doc, const ParagraphStyle& parStyle);
6044 tsoots 121
int SCRIBUS_API findParagraphStyle(ScribusDoc* doc, const QString &name);
2530 craig 122
#endif
5184 avox 123
 
5890 subik 124
/*! \brief performance measurements.
125
It prints given message with it current timestamp.
126
Useful for duration holes finding.
127
\author Petr Vanek */
128
void tDebug(QString message);
129
 
10303 cbradney 130
 
9991 fschmid 131
QString SCRIBUS_API readLinefromDataStream(QDataStream &s);
10648 fschmid 132
void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
10988 fschmid 133
QString SCRIBUS_API getDashString(int dashtype, double linewidth);
134
void SCRIBUS_API getDashArray(int dashtype, double linewidth, QList<double> &m_array);
6124 cbradney 135
 
5184 avox 136
#endif