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 #ifndef IMPORTPCT_H
8 #define IMPORTPCT_H
9 
10 
11 #include "pluginapi.h"
12 #include "pageitem.h"
13 #include "sccolor.h"
14 #include "fpointarray.h"
15 #include <QList>
16 #include <QTransform>
17 #include <QMultiMap>
18 #include <QtGlobal>
19 #include <QObject>
20 #include <QString>
21 #include <QRect>
22 
23 class MultiProgressDialog;
24 class ScribusDoc;
25 class Selection;
26 class TransactionSettings;
27 
28 //! \brief Pct (Mac Pict) importer plugin
29 class PctPlug : public QObject
30 {
31 	Q_OBJECT
32 
33 public:
34 	/*!
35 	\author Franz Schmid
36 	\date
37 	\brief Create the Pct importer window.
38 	\param fName QString
39 	\param flags combination of loadFlags
40 	\param showProgress if progress must be displayed
41 	\retval EPSPlug plugin
42 	*/
43 	PctPlug( ScribusDoc* doc, int flags );
44 	~PctPlug();
45 
46 	/*!
47 	\author Franz Schmid
48 	\date
49 	\brief Perform import.
50 	\param fn QString
51 	\param trSettings undo transaction settings
52 	\param flags combination of loadFlags
53 	\param showProgress if progress must be displayed
54 	\retval bool true if import was ok
55 	 */
56 	bool import(const QString& fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
57 	QImage readThumbnail(const QString& fn);
58 
59 private:
60 	void parseHeader(const QString& fName, double &x, double &y, double &b, double &h);
61 	bool convert(const QString& fn);
62 	void parsePict(QDataStream &ts);
63 	void alignStreamToWord(QDataStream &ts, uint len);
64 	void handleColor(QDataStream &ts, bool back);
65 	void handleColorRGB(QDataStream &ts, bool back);
66 	void handlePenPattern(QDataStream &ts);
67 	void handlePolygon(QDataStream &ts, quint16 opCode);
68 	void handleShape(QDataStream &ts, quint16 opCode);
69 	void handleSameShape(QDataStream &ts, quint16 opCode);
70 	void handleFontName(QDataStream &ts);
71 	void handleTextSize(QDataStream &ts);
72 	void handleTextFont(QDataStream &ts);
73 	void handleTextStyle(QDataStream &ts);
74 	void handleLongText(QDataStream &ts);
75 	void handleDHText(QDataStream &ts);
76 	void handleDVText(QDataStream &ts);
77 	void handleDHVText(QDataStream &ts);
78 	void createTextPath(const QByteArray& textString);
79 	void handlePenSize(QDataStream &ts);
80 	void handleOvalSize(QDataStream &ts);
81 	void handleShortLine(QDataStream &ts);
82 	void handleShortLineFrom(QDataStream &ts);
83 	void handleLine(QDataStream &ts);
84 	void handleLineFrom(QDataStream &ts);
85 	void handlePixmap(QDataStream &ts, quint16 opCode);
86 	void handleQuickTime(QDataStream &ts, quint16 opCode);
87 	void handleComment(QDataStream &ts, bool longComment);
88 	QRect readRect(QDataStream &ts);
89 	QByteArray decodeRLE(QByteArray &in, quint16 bytesPerLine, int twoByte);
90 	void setFillPattern(PageItem* ite);
91 	void handleLineModeEnd();
92 	void finishItem(PageItem* ite);
93 
94 	QList<PageItem*> Elements;
95 	int currentItemNr;
96 	QStack<QList<PageItem*> > groupStack;
97 	ColorList CustColors;
98 	double baseX, baseY;
99 	double offsetX, offsetY;
100 	double docWidth;
101 	double docHeight;
102 	double resX, resY;
103 
104 	double LineW;
105 	QString CurrColorFill;
106 	QColor backColor;
107 	QString CurrColorStroke;
108 	QColor foreColor;
109 	double CurrStrokeShade;
110 	double CurrFillShade;
111 	bool patternMode;
112 	QByteArray patternData;
113 	QMap<QString, QString> patternMap;
114 	QRect currRect;
115 	int currRectItemNr;
116 	int currRectType;
117 	QRect lastImageRect;
118 	QStringList importedColors;
119 	QStringList importedPatterns;
120 	QPoint ovalSize;
121 	QMap<int, QString> fontMap;
122 	int currentTextSize;
123 	int currentFontID;
124 	int currentFontStyle;
125 	FPointArray lastCoords;
126 	QByteArray imageData;
127 
128 	FPointArray Coords;
129 	QPoint currentPoint;
130 	QPoint currentPointT;
131 	bool lineMode;
132 	bool postscriptMode;
133 	bool textIsPostScript;
134 	bool interactive;
135 	MultiProgressDialog * progressDialog;
136 	bool cancel;
137 	ScribusDoc* m_Doc;
138 	Selection* tmpSel;
139 	int importerFlags;
140 	QString baseFile;
141 	int pctVersion;
142 	bool skipOpcode;
143 
144 public slots:
cancelRequested()145 	void cancelRequested() { cancel = true; }
146 };
147 
148 #endif
149