Subversion Repositories Scribus

Rev

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