Subversion Repositories Scribus

Rev

Rev 6106 | Rev 9356 | 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
 
2530 craig 12
#include <qstring.h>
13
#include <qpixmap.h>
14
#include <qimage.h>
15
#include <qstringlist.h>
16
#include <qwidget.h>
17
#include <qmap.h>
18
#include <qpointarray.h>
19
#include <qvaluelist.h>
20
#include <qpoint.h>
21
#include <qdom.h>
22
 
3808 cbradney 23
#include "fpoint.h"
24
#include "fpointarray.h"
25
#include "pagestructs.h"
26
#include "sccolor.h"
2969 craig 27
#include "scribusapi.h"
2530 craig 28
 
29
class ScribusDoc;
30
class QDomElement;
31
class ScribusView;
32
struct CopyPasteBuffer;
33
class PageItem;
34
struct Layer;
35
class Foi;
36
 
2969 craig 37
QColor SCRIBUS_API SetColor(ScribusDoc *currentDoc, QString color, int shad);
38
void SCRIBUS_API GetItemProps(bool newVersion, QDomElement *obj, struct CopyPasteBuffer *OB);
4449 subik 39
/*! \brief Returns a sorted list of QStrings - sorted by locale specific rules!
40
Uses compareQStrings() as rule. There is STL used!
41
\author Petr Vanek
4645 subik 42
\param aList unsorted string list
4449 subik 43
\retval QStringList sorted string list
44
 */
2969 craig 45
QStringList SCRIBUS_API sortQStringList(QStringList aList);
46
void SCRIBUS_API ReOrderText(ScribusDoc *currentDoc, ScribusView *view);
47
void SCRIBUS_API WordAndPara(PageItem *currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN);
48
bool SCRIBUS_API overwrite(QWidget *parent, QString filename);
49
FPoint SCRIBUS_API getMaxClipF(FPointArray* Clip);
50
FPoint SCRIBUS_API getMinClipF(FPointArray* Clip);
51
QString SCRIBUS_API Path2Relative(QString Path);
52
QByteArray SCRIBUS_API ComputeMD5Sum(QByteArray *in);
53
char SCRIBUS_API *toHex( uchar u );
54
QString SCRIBUS_API String2Hex(QString *in, bool lang = true);
55
QString SCRIBUS_API CompressStr(QString *in);
56
void SCRIBUS_API Level2Layer(ScribusDoc *currentDoc, struct Layer *ll, int Level);
2937 cbradney 57
//int Layer2Level(ScribusDoc *currentDoc, int LayerNr);
2969 craig 58
void SCRIBUS_API BezierPoints(QPointArray *ar, QPoint n1, QPoint n2, QPoint n3, QPoint n4);
59
double SCRIBUS_API xy2Deg(double x, double y);
60
QPointArray SCRIBUS_API FlattenPath(FPointArray ina, QValueList<uint> &Segs);
61
QPointArray SCRIBUS_API RegularPolygon(double w, double h, uint c, bool star, double factor, double rota);
62
FPointArray SCRIBUS_API RegularPolygonF(double w, double h, uint c, bool star, double factor, double rota);
63
QPixmap SCRIBUS_API *getSmallPixmap(QColor rgb);
64
QPixmap SCRIBUS_API *getWidePixmap(QColor rgb);
4449 subik 65
/*! \brief Create a cool all-infos pixmaps for the specified color.
66
\param col Scribus color
67
\retval QPixmap image with various icons depending on the col properties.
68
*/
3497 avox 69
QPixmap SCRIBUS_API *getFancyPixmap(ScColor col);
4449 subik 70
/*! \brief Put toPaint pixmap into target at the x, y place.
71
There is handled the alpha channel/transparency too. In the beginning
72
is the target pixmap filled with all_transparent mask. In the case of
73
the painting of tiPaint into x, y place, there is this pixmap enabled
74
in alpha mask too.
75
\param toPaint a pixmap to be painted into target
76
\param target a base pixmap. Some kind of painter.
77
\param x coordinate
78
\param y coordinate
6106 jghali 79
\param useMask if alpha mask should be used
4449 subik 80
*/
6106 jghali 81
void SCRIBUS_API paintAlert(QPixmap &toPaint, QPixmap &target, int x = 0, int y = 0, bool useMask = true);
2969 craig 82
QPixmap SCRIBUS_API loadIcon(QString nam);
83
uint SCRIBUS_API getDouble(QString in, bool raw);
4449 subik 84
//! \brief WARNING: loadText is INCORRECT - use loadRawText instead!
2969 craig 85
bool SCRIBUS_API loadText(QString nam, QString *Buffer);
4449 subik 86
/*! \brief Replacement version of loadText that returns a QCString as an out parameter.
87
The QCString is filled with the contents of the specified file. The return
88
byte string is of unknown encoding; the caller must handle encoding issues.
89
There is no need to preallocate the buffer, and the new data replaces any
90
old contents. */
3646 craig 91
bool SCRIBUS_API loadRawText(const QString & filename, QCString & buf);
2969 craig 92
QString SCRIBUS_API GetAttr(QDomElement *el, QString at, QString def="0");
93
QImage SCRIBUS_API ProofImage(QImage *Im);
4449 subik 94
/**
95
* @brief Synchronously execute a new process, optionally saving its output
96
   *
97
   * Create a new process via QProcess and wait until finished.  Return the
98
   * process exit code. Exit code 1 is returned if the process could not be
99
   * started or terminated abnormally.
100
   *
101
   * Note that the argument list is handled exactly as documented by QProcess.
102
   * In particular, no shell metacharacter expansion is performed (so you can't
103
   * use $HOME for example, and no quoting is required or appropriate), and each
104
   * list entry is one argument.
105
   *
106
   * If output file paths are provided, any existing file will be truncated and
107
   * overwritten.
108
   *
109
   * @param args Arguments, as per QProcess documentation.
110
   * @param fileStdErr Path to save error output to, or "" to discard.
111
   * @param fileStdOut Path to save normal output to, or "" to discard.
112
   * @return Program exit code, or 1 on failure.
113
   *
114
*/
4194 fschmid 115
int SCRIBUS_API System(const QStringList & args, const QString fileStdErr = "", const QString fileStdOut = "");
2969 craig 116
int SCRIBUS_API copyFile(QString source, QString target);
117
int SCRIBUS_API moveFile(QString source, QString target);
4449 subik 118
/*!
119
 \fn QString checkFileExtension(const QString &currName, const QString &extension)
120
 \author Craig Bradney
121
 \brief A quick function to make sure a filename has the correct extension and add it if not
122
 \param currName Current filename
123
 \param extension File extension to ensure exists
124
 */
2969 craig 125
QString SCRIBUS_API checkFileExtension(const QString &, const QString &);
4449 subik 126
//! \brief On Windows, return short path name, else return longPath;
2969 craig 127
QString SCRIBUS_API getShortPathName(QString longPath);
4449 subik 128
/*! \brief Creates a common name for page exports (SVG, bitmap, EPS).
129
   Output format is: documentname-page01.extension
130
   \param pageNo number of the exported page (begins from 1)
131
   \param extension "svg" or e.g. "png" etc.
132
   \retval QString standardized filename
133
   \author Petr Vanek
134
 */
2969 craig 135
QString SCRIBUS_API getFileNameByPage(uint pageNo, QString extension);
3240 fschmid 136
void SCRIBUS_API sDebug(QString message);
3689 cbradney 137
inline double SCRIBUS_API square(double);
138
inline double SCRIBUS_API distance(double, double);
4754 cbradney 139
/*! \brief Constrains an angle of rotation to 45 degree intervals
140
   Will make code simpler and reduce interval or provide as a parameter
141
   \param double angle Angle in degrees
142
   \retval double Constrained angle
143
 */
144
double SCRIBUS_API constrainAngle(double angle);
6603 jghali 145
/*! \brief Get the rotation angle (in radian) from a transformation matrix
146
   Will make code simpler and reduce interval or provide as a parameter
147
   \param matrix the transformation matrix
148
   \param def the value that should be return if matrix is not a rotation matrix
149
   \retval double the rotation angle
150
 */
151
double SCRIBUS_API getRotationFromMatrix(QWMatrix& matrix, double def);
3757 cbradney 152
const QString SCRIBUS_API getStringFromSequence(DocumentSectionType type, uint position);
3784 cbradney 153
const QString SCRIBUS_API arabicToRoman(uint i);
154
const QString SCRIBUS_API numberToLetterSequence(uint i);
155
void SCRIBUS_API parsePagesString(QString pages, std::vector<int>* pageNs, int sourcePageCount);
2530 craig 156
#endif