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 */
7 /***************************************************************************
8 							 -------------------
9 	begin                : Mon Dez 30 2013
10 	copyright            : (C) 2013 by Franz Schmid
11 	email                : Franz.Schmid@altmuehlnet.de
12  ***************************************************************************/
13 #ifndef IMPORTPAGES_H
14 #define IMPORTPAGES_H
15 
16 #if 0
17 
18 #include <QObject>
19 #include <QString>
20 
21 #include "pluginapi.h"
22 #include "pageitem.h"
23 #include "sccolor.h"
24 #include "fpointarray.h"
25 #include "vgradient.h"
26 #include <QList>
27 #include <QTransform>
28 #include <QMultiMap>
29 #include <QVector>
30 
31 class MultiProgressDialog;
32 class ScribusDoc;
33 class Selection;
34 class TransactionSettings;
35 
36 //! \brief FH importer plugin
37 class PagesPlug : public QObject
38 {
39 	Q_OBJECT
40 
41 public:
42 	/*!
43 	\author Franz Schmid
44 	\date
45 	\brief Create the Fh importer window.
46 	\param fName QString
47 	\param flags combination of loadFlags
48 	\param showProgress if progress must be displayed
49 	\retval EPSPlug plugin
50 	*/
51 	PagesPlug( ScribusDoc* doc, int flags );
52 	~PagesPlug();
53 
54 	/*!
55 	\author Franz Schmid
56 	\date
57 	\brief Perform import.
58 	\param fn QString
59 	\param trSettings undo transaction settings
60 	\param flags combination of loadFlags
61 	\param showProgress if progress must be displayed
62 	\retval bool true if import was ok
63 	 */
64 	bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
65 	QImage readThumbnail(QString fn);
66 
67 private:
68 	bool convert(QString fn);
69 
70 	QList<PageItem*> Elements;
71 	double baseX, baseY;
72 	double docWidth;
73 	double docHeight;
74 
75 	QStringList importedColors;
76 	QStringList importedPatterns;
77 
78 	bool interactive;
79 	MultiProgressDialog * progressDialog;
80 	bool cancel;
81 	ScribusDoc* m_Doc;
82 	Selection* tmpSel;
83 	int importerFlags;
84 
85 public slots:
86 	void cancelRequested() { cancel = true; }
87 };
88 #else
89 
90 #include "pluginapi.h"
91 #include "pageitem.h"
92 #include "sccolor.h"
93 #include "fpointarray.h"
94 #include "scribusstructs.h"
95 #include <QList>
96 #include <QTransform>
97 #include <QMultiMap>
98 #include <QtGlobal>
99 #include <QObject>
100 #include <QString>
101 #include <QDomDocument>
102 #include <QDomElement>
103 
104 class MultiProgressDialog;
105 class ScribusDoc;
106 class Selection;
107 class TransactionSettings;
108 class ScZipHandler;
109 
110 class PagesPlug : public QObject
111 {
112 	Q_OBJECT
113 
114 public:
115 	/*!
116 	\author Franz Schmid
117 	\date
118 	\brief Create the importer window.
119 	\param fName QString
120 	\param flags combination of loadFlags
121 	\param showProgress if progress must be displayed
122 	\retval EPSPlug plugin
123 	*/
124 	PagesPlug( ScribusDoc* doc, int flags );
125 	~PagesPlug();
126 
127 	/*!
128 	\author Franz Schmid
129 	\date
130 	\brief Perform import.
131 	\param fn QString
132 	\param trSettings undo transaction settings
133 	\param flags combination of loadFlags
134 	\param showProgress if progress must be displayed
135 	\retval bool true if import was ok
136 	 */
137 	bool import(const QString& fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
138 	QImage readThumbnail(const QString& fn);
139 
140 private:
141 	struct ObjStyle
142 	{
143 		AttributeValue parentStyle;
144 		AttributeValue CurrColorFill;
145 		AttributeValue CurrColorStroke;
146 		AttributeValue fillOpacity;
147 		AttributeValue strokeOpacity;
148 		AttributeValue opacity;
149 		AttributeValue LineW;
150 		AttributeValue CapStyle;
151 		AttributeValue JoinStyle;
152 	};
153 	struct ChrStyle
154 	{
155 		AttributeValue parentStyle;
156 		AttributeValue fontName;
157 		AttributeValue fontSize;
158 		AttributeValue fontColor;
159 		AttributeValue backColor;
160 	};
161 	struct ParStyle
162 	{
163 		AttributeValue parentStyle;
164 		AttributeValue fontName;
165 		AttributeValue fontSize;
166 		AttributeValue fontColor;
167 		AttributeValue justification;
168 	};
169 	struct LayoutStyle
170 	{
171 		AttributeValue parentStyle;
172 		AttributeValue Extra;
173 		AttributeValue TExtra;
174 		AttributeValue BExtra;
175 		AttributeValue RExtra;
176 		AttributeValue TextColumnCount;
177 		AttributeValue TextColumnGutter;
178 	};
179 
180 	struct ObjState
181 	{
182 		QPainterPath currentPath;
183 		bool currentPathClosed {false};
184 		QPainterPath clipPath;
185 		QTransform transform;
186 		QString CurrColorFill {CommonStrings::None};
187 		double fillOpacity {0.0};
188 		QString CurrColorStroke {CommonStrings::None};
189 		double strokeOpacity {0.0};
190 		double LineW {1.0};
191 		VGradient currentGradient;
192 		QPointF gradientStart;
193 		QPointF gradientEnd;
194 		QPointF gradientFocus;
195 		double gradientScale {1.0};
196 		int fillGradientTyp {0};
197 		QString imagePath;
198 		QString patternName;
199 		VGradient gradientMask;
200 		QPointF maskStart;
201 		QPointF maskEnd;
202 		QPointF maskFocus;
203 		double maskScale;
204 		int maskTyp {0};
205 		QString patternMask;
206 		VGradient gradientStroke;
207 		QPointF strokeStart;
208 		QPointF strokeEnd;
209 		QPointF strokeFocus;
210 		double strokeScale;
211 		int strokeTyp {0};
212 		QString patternStroke;
213 		int itemType {0};
214 		Qt::PenCapStyle CapStyle {Qt::FlatCap};
215 		Qt::PenJoinStyle JoinStyle {Qt::MiterJoin};
216 		QVector<double> DashPattern;
217 		double DashOffset {0.0};
218 		double xPos {0.0};
219 		double yPos {0.0};
220 		double width {0.0};
221 		double height {0.0};
222 		double rotation {0.0};
223 		QString styleRef;
224 		QString layoutStyleRef;
225 	};
226 	struct StyleSheet
227 	{
228 		QHash<QString, ObjStyle> m_objStyles;
229 		QHash<QString, ParStyle> m_parStyles;
230 		QHash<QString, ChrStyle> m_chrStyles;
231 		QHash<QString, LayoutStyle> m_layoutStyles;
232 	};
233 
234 	bool convert(const QString& fn);
235 	bool parseDocReference(const QString& designMap, bool compressed);
236 	void parseStyleSheets(QDomElement &drawPag);
237 	void parsePageReference(QDomElement &drawPag);
238 	PageItem *parseObjReference(QDomElement &draw);
239 	void applyParagraphAttrs(ParagraphStyle &newStyle, CharStyle &tmpCStyle, const QString& pAttrs);
240 	void applyCharAttrs(CharStyle &tmpCStyle, const QString& pAttrs);
241 	void finishItem(PageItem* item, ObjState &obState);
242 	QList<PageItem*> Elements;
243 	double baseX, baseY;
244 	double docWidth;
245 	double docHeight;
246 	bool interactive;
247 	ScribusDoc* m_Doc;
248 	Selection* tmpSel;
249 	int importerFlags;
250 	MultiProgressDialog * progressDialog;
251 	bool cancel;
252 	QStringList importedColors;
253 	QStringList importedPatterns;
254 	bool firstPage;
255 	int pagecount;
256 	int mpagecount;
257 	double topMargin;
258 	double leftMargin;
259 	double rightMargin;
260 	double bottomMargin;
261 	double pgCols;
262 	double pgGap;
263 	QString papersize;
264 	QHash<int, QString> imageResources;
265 	QHash<QString, StyleSheet> m_StyleSheets;
266 	QString m_currentStyleSheet;
267 
268 	PageItem* addClip(PageItem* retObj, ObjState &obState);
269 
270 	FPointArray Coords;
271 	QHash<QString, QPainterPath> pathResources;
272 	ScZipHandler *uz;
273 
274 public slots:
cancelRequested()275 	void cancelRequested() { cancel = true; }
276 };
277 #endif
278 #endif
279