summaryrefslogtreecommitdiffstats
path: root/scribus/plugins/import/ai/importai.h
blob: 473330989cd7d75c2be1c6abb27f55a63870fa0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#ifndef IMPORTAI_H
#define IMPORTAI_H

#include "qglobal.h"
#include "qobject.h"
#include "qstring.h"

#include "pluginapi.h"
#include "pageitem.h"
#include "sccolor.h"
#include "fpointarray.h"
#include "vgradient.h"
#include <QList>
#include <QMatrix>
// #include <QPainterPath>

class MultiProgressDialog;
class ScribusDoc;
class Selection;
class TransactionSettings;

//! \brief Adobe Illustrator importer plugin
class AIPlug : public QObject
{
	Q_OBJECT

public:
	/*!
	\author Franz Schmid
	\date
	\brief Create the AI importer window.
	\param doc a Scribus document reference
	\param flags combination of loadFlags - see loadFlags in LoadSavePlugin
	*/
	AIPlug( ScribusDoc* doc, int flags );
	~AIPlug();

	/*!
	\author Franz Schmid
	\date
	\brief Perform import.
	\param fNameIn QString a filename to import
	\param trSettings undo transaction settings
	\param flags combination of loadFlags in LoadSavePlugin
	\param showProgress if progress must be displayed
	\retval bool true if import was ok
	 */
	bool import(QString fNameIn, const TransactionSettings& trSettings, int flags, bool showProgress = true);

private:
	
	/*!
	\author Franz Schmid
	\date
	\brief Does the conversion.
	\param infile a filename
	\param outfile a filename for output
	\retval bool true if conversion was ok
	 */
	bool extractFromPDF(QString infile, QString outfile);

	bool decompressAIData(QString &fName);
	bool parseHeader(QString fName, double &x, double &y, double &b, double &h);
	QString removeAIPrefix(QString comment);
	QString parseColor(QString data);
	QString parseColorGray(QString data);
	QString parseColorRGB(QString data);
	QString parseCustomColor(QString data, double &shade);
	QString parseCustomColorX(QString data, double &shade, QString type);
	QStringList getStrings(QString data);
	void getCommands(QString data, QStringList &commands);
	void processData(QString data);
	void processGradientData(QString data);
	void processPattern(QDataStream &ts);
	void processRaster(QDataStream &ts);
	void processComment(QDataStream &ts, QString comment);
	bool convert(QString fn);
	
	QList<PageItem*> Elements;
	QList<PageItem*> PatternElements;
	QStack<QList<PageItem*> > groupStack;
	ColorList CustColors;
	double baseX, baseY;
	double docX;
	double docY;
	double docWidth;
	double docHeight;

	double LineW;
	Qt::PenCapStyle CapStyle;
	Qt::PenJoinStyle JoinStyle;
	double DashOffset;
	QList<double> DashPattern;
	double Opacity;
	int blendMode;
	QString CurrColorFill;
	QString CurrColorStroke;
	double CurrStrokeShade;
	double CurrFillShade;
	bool fillRule;
	bool itemLocked;

	FPointArray Coords;
	FPointArray clipCoords;
	FPoint currentPoint;
	int currentLayer;
	bool firstLayer;
	bool FirstU, WasU, ClosedPath;
	bool interactive;
	MultiProgressDialog * progressDialog;
	bool cancel;
	ScribusDoc* m_Doc;
	Selection* tmpSel;
	int importerFlags;
	QStringList commandList;
	bool convertedPDF;
	QMap<QString, VGradient> m_gradients;
	VGradient currentGradient;
	QString currentGradientName;
	QMatrix currentGradientMatrix;
	QPointF currentGradientOrigin;
	double currentGradientAngle;
	double currentGradientLenght;
	bool gradientMode;
	bool wasBC;
	bool itemRendered;
	QMatrix startMatrix;
	QMatrix endMatrix;
	bool patternMode;
	QString currentPatternDefName;
	QString currentPatternName;
	double patternX1;
	double patternY1;
	double patternX2;
	double patternY2;
	double currentPatternX;
	double currentPatternY;
	double currentPatternXScale;
	double currentPatternYScale;
	double currentPatternRotation;
	bool meshMode;
	int meshXSize, meshYSize;
	int currentMeshXPos, currentMeshYPos;
	int meshNodeCounter;
	int meshColorMode;
	double meshNode1PointX, meshNode1PointY;
	double meshNode1Control1X, meshNode1Control1Y;
	double meshNode1Control2X, meshNode1Control2Y;
	double meshNode2PointX, meshNode2PointY;
	double meshNode2Control1X, meshNode2Control1Y;
	double meshNode2Control2X, meshNode2Control2Y;
	double meshNode3PointX, meshNode3PointY;
	double meshNode3Control1X, meshNode3Control1Y;
	double meshNode3Control2X, meshNode3Control2Y;
	double meshNode4PointX, meshNode4PointY;
	double meshNode4Control1X, meshNode4Control1Y;
	double meshNode4Control2X, meshNode4Control2Y;
	double accumColorC, accumColorM, accumColorY, accumColorK;
//	QPainterPath meshBoundingPath;
	QString docCreator;
	QString docDate;
	QString docTime;
	QString docOrganisation;
	QString docTitle;
	int textMode;
	QMatrix textMatrix;
	StoryText textData;
	QString textFont;
	double textSize;
	double maxWidth;
	double tempW;
	double maxHeight;
	double textKern;
	double textScaleH;
	double textScaleV;
	int startCurrentTextRange;
	int endCurrentTextRange;

public slots:
	void cancelRequested() { cancel = true; }
};

#endif