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 SCRIBUS12FORMAT_H
8 #define SCRIBUS12FORMAT_H
9 
10 #include "pluginapi.h"
11 #include "loadsaveplugin.h"
12 #include "scfonts.h"
13 #include "scribusstructs.h"
14 #include "styles/styleset.h"
15 
16 #include <QDomElement>
17 #include <QMap>
18 #include <QHash>
19 #include <QString>
20 #include <QList>
21 
22 class LastStyles;
23 
24 class PLUGIN_API Scribus12Format : public LoadSavePlugin
25 {
26 	Q_OBJECT
27 
28 	public:
29 		// Standard plugin implementation
30 		Scribus12Format();
31 		virtual ~Scribus12Format();
32 		QString fullTrName() const override;
33 		const AboutData* getAboutData() const override;
34 		void deleteAboutData(const AboutData* about) const override;
35 		void languageChange() override;
36 		//Not the same as readSLA. This one only reads max 4k of the file for speed.
37 		bool fileSupported(QIODevice* file, const QString & fileName=QString()) const override;
38 
39 		bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0) override;
40 		bool saveFile(const QString & fileName, const FileFormat & fmt) override;
addToMainWindowMenu(ScribusMainWindow *)41 		void addToMainWindowMenu(ScribusMainWindow *) override {};
42 
43 		// Special features - .sla page extraction support
44 		bool loadPage(const QString & fileName, int pageNumber, bool Mpage, const QString& renamedPageName=QString()) override;
45 		bool readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles) override;
46 		bool readLineStyles(const QString& fileName, QHash<QString, multiLine> *Sty) override;
47 		bool readColors(const QString& fileName, ColorList & colors) override;
48 		bool readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames) override;
49 		void getReplacedFontData(bool& getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces) override;
50 
51 	private:
52 		void registerFormats();
53 		//Scribus Doc vars, not plugin vars
54 		void GetItemText(QDomElement *it, ScribusDoc *doc, bool VorLFound, bool impo, PageItem* obj, LastStyles* last);
55 		void GetStyle(QDomElement *pg, ParagraphStyle *vg, StyleSet<ParagraphStyle> *tempParagraphStyles, ScribusDoc* doc, bool fl);
56 		QString readSLA(const QString & fileName);
57 		/**
58 		 * @brief Paste an item to the document.
59 		 * The bulk of a paste item process runs here for want of a better place, but its a better place
60 		 * than the view where it used to be.
61 		 * TODO Once the pageitem restructure is done, this is probably unnecessary but it removes the
62 		 * unnecessary part from the view for now which is overloaded with non ScrollView code.
63 		 */
64 		//TODO: void PasteItem(struct CopyPasteBuffer *Buffer, bool loading, bool drag = false);
65 		QMap<int,int> groupRemap;
66 		QMap<long long,int> itemRemap;
67 		QMap<int,long long> itemNext;
68 		QMap<uint,QString> DoVorl;
69 		QList<PDFPresentationData> EffVal;
70 		uint VorlC;
71 		struct CopyPasteBuffer
72 		{
73 			PageItem::ItemType PType;
74 			double Xpos;
75 			double Ypos;
76 			double Width;
77 			double Height;
78 			double RadRect;
79 			int FrameType;
80 			bool ClipEdited;
81 			double Pwidth;
82 			QString Pcolor;
83 			QString Pcolor2;
84 			double Shade;
85 			double Shade2;
86 			int FillRule;
87 			QString GrColor;
88 			QString GrColor2;
89 			int GrShade;
90 			int GrShade2;
91 			VGradient fill_gradient;
92 			int GrType;
93 			QString pattern;
94 			double patternScaleX;
95 			double patternScaleY;
96 			double patternOffsetX;
97 			double patternOffsetY;
98 			double patternRotation;
99 			double patternSkewX;
100 			double patternSkewY;
101 			bool patternMirrorX;
102 			bool patternMirrorY;
103 			double GrStartX;
104 			double GrStartY;
105 			double GrEndX;
106 			double GrEndY;
107 			double GrFocalX;
108 			double GrFocalY;
109 			double GrScale;
110 			double GrSkew;
111 			VGradient stroke_gradient;
112 			int GrTypeStroke;
113 			double GrStrokeStartX;
114 			double GrStrokeStartY;
115 			double GrStrokeEndX;
116 			double GrStrokeEndY;
117 			double GrStrokeFocalX;
118 			double GrStrokeFocalY;
119 			double GrStrokeScale;
120 			double GrStrokeSkew;
121 			int GrMask;
122 			double GrMaskStartX;
123 			double GrMaskStartY;
124 			double GrMaskEndX;
125 			double GrMaskEndY;
126 			double GrMaskFocalX;
127 			double GrMaskFocalY;
128 			double GrMaskScale;
129 			double GrMaskSkew;
130 			double patternMaskScaleX;
131 			double patternMaskScaleY;
132 			double patternMaskOffsetX;
133 			double patternMaskOffsetY;
134 			double patternMaskRotation;
135 			double patternMaskSkewX;
136 			double patternMaskSkewY;
137 			bool patternMaskMirrorX;
138 			bool patternMaskMirrorY;
139 			double GrCol1transp;
140 			double GrCol2transp;
141 			double GrCol3transp;
142 			double GrCol4transp;
143 			int GrCol1Shade;
144 			int GrCol2Shade;
145 			int GrCol3Shade;
146 			int GrCol4Shade;
147 			QString patternMaskVal;
148 			VGradient mask_gradient;
149 			FPoint GrControl1;
150 			FPoint GrControl2;
151 			FPoint GrControl3;
152 			FPoint GrControl4;
153 			FPoint GrControl5;
154 			QString GrColorP1;
155 			QString GrColorP2;
156 			QString GrColorP3;
157 			QString GrColorP4;
158 			QList<QList<MeshPoint> > meshGradientArray;
159 			int mGArrayRows;
160 			int mGArrayCols;
161 			QString TxtStroke;
162 			QString TxtFill;
163 			int ShTxtStroke;
164 			int ShTxtFill;
165 			int TxtScale;
166 			int TxtScaleV;
167 			int TxTStyle;
168 			int TxTBase;
169 			int TxtShadowX;
170 			int TxtShadowY;
171 			int TxtOutline;
172 			int TxtUnderPos;
173 			int TxtUnderWidth;
174 			int TxtStrikePos;
175 			int TxtStrikeWidth;
176 			double Rot;
177 			int PLineArt;
178 			int PLineJoin;
179 			int PLineEnd;
180 			double LineSp;
181 			int LineSpMode;
182 			int ExtraV;
183 			double LocalScX;
184 			double LocalScY;
185 			double LocalX;
186 			double LocalY;
187 			double LocalRot;
188 			bool PicArt;
189 			bool flippedH;
190 			bool flippedV;
191 			bool isPrintable;
192 			bool isBookmark;
193 			bool m_isAnnotation;
194 			Annotation m_annotation;
195 			QString itemName;
196 			double Extra;
197 			double TExtra;
198 			double BExtra;
199 			double RExtra;
200 			FirstLineOffsetPolicy firstLineOffsetP;
201 			QString Pfile;
202 			QString Pfile2;
203 			QString Pfile3;
204 			QString ImageProfile;
205 			QString EmbeddedProfile;
206 			eRenderIntent ImageIntent;
207 			bool UseEmbedded;
208 			bool OverrideCompressionMethod;
209 			int CompressionMethodIndex;
210 			bool OverrideCompressionQuality;
211 			int CompressionQualityIndex;
212 			QString itemText;
213 			QPolygon Clip;
214 			FPointArray PoLine;
215 			FPointArray ContourLine;
216 			bool PoShow;
217 			double BaseOffs;
218 			int textPathType;
219 			bool textPathFlipped;
220 			int TextflowMode;
221 			int textAlignment;
222 			QString IFont;
223 			int ISize;
224 			QStack<int> Groups;
225 			double groupHeight;
226 			double groupWidth;
227 			int  LayerID;
228 			bool ScaleType;
229 			bool AspectRatio;
230 			bool Locked;
231 			bool LockRes;
232 			double Transparency;
233 			double TranspStroke;
234 			int TransBlend;
235 			int TransBlendS;
236 			bool Reverse;
237 			QString NamedLStyle;
238 			QString Language;
239 			QString guiLanguage;
240 			int Cols;
241 			double ColGap;
242 			QList<ParagraphStyle::TabRecord> TabValues;
243 			QVector<double> DashValues;
244 			double DashOffset;
245 			bool isTableItem;
246 			bool TopLine;
247 			bool LeftLine;
248 			bool RightLine;
249 			bool BottomLine;
250 			int LeftLinkID;
251 			int RightLinkID;
252 			int TopLinkID;
253 			int BottomLinkID;
254 			int startArrowIndex;
255 			int endArrowIndex;
256 			int startArrowScale;
257 			int endArrowScale;
258 			ObjAttrVector pageItemAttributes;
259 		};
260 		void PasteItem(struct CopyPasteBuffer *Buffer, bool drag = false, bool noResize = true);
261 		void GetItemProps(QDomElement *obj, struct CopyPasteBuffer *OB, const QString& baseDir, bool newVersion);
262 
263 };
264 
265 extern "C" PLUGIN_API int scribus12format_getPluginAPIVersion();
266 extern "C" PLUGIN_API ScPlugin* scribus12format_getPlugin();
267 extern "C" PLUGIN_API void scribus12format_freePlugin(ScPlugin* plugin);
268 
269 #endif
270