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 IMPORTAI_H 8 #define IMPORTAI_H 9 10 #include <QList> 11 #include <QTransform> 12 #include <QObject> 13 #include <QString> 14 15 #include "pluginapi.h" 16 17 #include "fpointarray.h" 18 #include "mesh.h" 19 #include "sccolor.h" 20 #include "text/storytext.h" 21 #include "vgradient.h" 22 23 class MultiProgressDialog; 24 class PageItem; 25 class ScribusDoc; 26 class Selection; 27 class TransactionSettings; 28 29 //! \brief Adobe Illustrator importer plugin 30 class AIPlug : public QObject 31 { 32 Q_OBJECT 33 34 public: 35 /*! 36 \author Franz Schmid 37 \date 38 \brief Create the AI importer window. 39 \param doc a Scribus document reference 40 \param flags combination of loadFlags - see loadFlags in LoadSavePlugin 41 */ 42 AIPlug( ScribusDoc* doc, int flags ); 43 ~AIPlug(); 44 45 /*! 46 \author Franz Schmid 47 \date 48 \brief Perform import. 49 \param fNameIn QString a filename to import 50 \param trSettings undo transaction settings 51 \param flags combination of loadFlags in LoadSavePlugin 52 \param showProgress if progress must be displayed 53 \retval bool true if import was ok 54 */ 55 bool import(const QString& fNameIn, const TransactionSettings& trSettings, int flags, bool showProgress = true); 56 QImage readThumbnail(const QString& fn); 57 bool readColors(const QString& fileName, ColorList & colors); 58 59 private: 60 61 /*! 62 \author Franz Schmid 63 \date 64 \brief Does the conversion. 65 \param infile a filename 66 \param outfile a filename for output 67 \retval bool true if conversion was ok 68 */ 69 bool extractFromPDF(const QString& infile, const QString& outfile); 70 71 bool decompressAIData(QString &fName); 72 bool parseHeader(const QString& fName, double &x, double &y, double &b, double &h); 73 QString removeAIPrefix(QString comment); 74 QString parseColor(QString data); 75 QString parseColorGray(QString data); 76 QString parseColorRGB(QString data); 77 QString parseCustomColor(QString data, double &shade); 78 QString parseCustomColorX(QString data, double &shade, const QString& type); 79 QStringList getStrings(const QString& data); 80 void getCommands(const QString& data, QStringList &commands); 81 void decodeA85(QByteArray &psdata, const QString& tmp); 82 void processData(const QString& data); 83 void processGradientData(const QString& data); 84 void processSymbol(QDataStream &ts, bool sym); 85 void processPattern(QDataStream &ts); 86 void processRaster(QDataStream &ts); 87 void processComment(QDataStream &ts, const QString& comment); 88 bool convert(const QString& fn); 89 90 QList<PageItem*> Elements; 91 QList<PageItem*> PatternElements; 92 QStack<QList<PageItem*> > groupStack; 93 QStack<FPointArray> clipStack; 94 ColorList CustColors; 95 QStringList importedColors; 96 QStringList importedGradients; 97 QStringList importedPatterns; 98 double baseX = 0.0; 99 double baseY = 0.0; 100 double docX = 0.0; 101 double docY = 0.0; 102 double docWidth = 0.0; 103 double docHeight = 0.0; 104 105 double LineW = 1.0; 106 Qt::PenCapStyle CapStyle = Qt::FlatCap; 107 Qt::PenJoinStyle JoinStyle = Qt::MiterJoin; 108 double DashOffset = 0.0; 109 QList<double> DashPattern; 110 double Opacity = 1.0; 111 int blendMode = 0; 112 QString CurrColorFill; 113 QString CurrColorStroke; 114 double CurrStrokeShade = 100.0; 115 double CurrFillShade = 100.0; 116 bool fillRule = false; 117 bool itemLocked = false; 118 119 FPointArray Coords; 120 FPointArray clipCoords; 121 FPointArray currentSpecialPath; 122 FPoint currentPoint; 123 int currentLayer = 0; 124 bool firstLayer = true; 125 bool FirstU = false; 126 bool WasU = false; 127 bool interactive; 128 MultiProgressDialog * progressDialog = nullptr; 129 bool cancel = false; 130 ScribusDoc* m_Doc = nullptr; 131 Selection* tmpSel = nullptr; 132 int importerFlags; 133 QStringList commandList; 134 bool convertedPDF = false; 135 QMap<QString, VGradient> m_gradients; 136 VGradient currentGradient; 137 QString currentGradientName; 138 QTransform currentGradientMatrix; 139 QPointF currentGradientOrigin; 140 double currentGradientAngle = 0.0; 141 double currentGradientLength = 1.0; 142 bool gradientMode = false; 143 bool wasBC = false; 144 bool itemRendered = false; 145 QTransform startMatrix; 146 QTransform endMatrix; 147 bool patternMode = false; 148 QString currentPatternDefName; 149 QString currentPatternName; 150 double patternX1 = 0.0; 151 double patternY1 = 0.0; 152 double patternX2 = 0.0; 153 double patternY2 = 0.0; 154 double currentPatternX = 0.0; 155 double currentPatternY = 0.0; 156 double currentPatternXScale = 1.0; 157 double currentPatternYScale = 1.0; 158 double currentPatternRotation = 0.0; 159 QString currentStrokePatternName; 160 double currentStrokePatternX = 0.0; 161 double currentStrokePatternY = 0.0; 162 double currentStrokePatternXScale = 1.0; 163 double currentStrokePatternYScale = 1.0; 164 double currentStrokePatternRotation = 0.0; 165 bool meshMode = false; 166 int meshXSize = 0; 167 int meshYSize = 0; 168 int currentMeshXPos = 0; 169 int currentMeshYPos = 0; 170 int meshNodeCounter = 0; 171 int meshColorMode = 0; 172 double meshNode1PointX = 0.0; 173 double meshNode1PointY = 0.0; 174 double meshNode1Control1X = 0.0, meshNode1Control1Y = 0.0; 175 double meshNode1Control2X = 0.0, meshNode1Control2Y = 0.0; 176 double meshNode2PointX = 0.0, meshNode2PointY = 0.0; 177 double meshNode2Control1X = 0.0, meshNode2Control1Y = 0.0; 178 double meshNode2Control2X = 0.0, meshNode2Control2Y = 0.0; 179 double meshNode3PointX = 0.0, meshNode3PointY = 0.0; 180 double meshNode3Control1X = 0.0, meshNode3Control1Y = 0.0; 181 double meshNode3Control2X = 0.0, meshNode3Control2Y = 0.0; 182 double meshNode4PointX = 0.0, meshNode4PointY = 0.0; 183 double meshNode4Control1X = 0.0, meshNode4Control1Y = 0.0; 184 double meshNode4Control2X = 0.0, meshNode4Control2Y = 0.0; 185 QString meshColor1, meshColor2, meshColor3, meshColor4; 186 QList<QList<MeshPoint> > meshGradientArray; 187 QString docCreator; 188 QString docDate; 189 QString docTime; 190 QString docOrganisation; 191 QString docTitle; 192 int textMode = 0; 193 QTransform textMatrix; 194 StoryText textData; 195 QString textFont; 196 double textSize = 0.0; 197 double maxWidth = 0.0; 198 double tempW = 0.0; 199 double maxHeight = 0.0; 200 double textKern= 0.0; 201 double textScaleH = 0.0; 202 double textScaleV = 0.0; 203 int startCurrentTextRange = 0; 204 int endCurrentTextRange = 0; 205 QString currentSymbolName; 206 QMap<QString, QPointF> importedSymbols; 207 bool symbolMode = false; 208 bool dataMode = false; 209 bool fObjectMode = false; 210 QString dataString; 211 212 public slots: cancelRequested()213 void cancelRequested() { cancel = true; } 214 }; 215 216 #endif 217