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 SCRIBUSSTRUCTS_H
8 #define SCRIBUSSTRUCTS_H
9 
10 #ifdef HAVE_CONFIG_H
11 #include "scconfig.h"
12 #endif
13 
14 #include <QAction>
15 #include <QByteArray>
16 #include <QDebug>
17 #include <QFlags>
18 #include <QKeySequence>
19 #include <QList>
20 #include <QPolygon>
21 #include <QStack>
22 #include <QString>
23 #include <QMap>
24 #include <QVector>
25 
26 #include <vector>
27 
28 #include "scribusapi.h"
29 
30 #include "annotation.h"
31 #include "colormgmt/sccolormgmtstructs.h"
32 #include "fpointarray.h"
33 #include "margins.h"
34 #include "pageitem.h"
35 #include "sccolorstructs.h"
36 #include "scfonts.h"
37 #include "scimagestructs.h"
38 #include "sctextstruct.h"
39 #include "util_math.h"
40 #include "vgradient.h"
41 
42 struct CopyContentsBuffer
43 {
44 	PageItem::ItemType sourceType;
45 	QString contentsFileName;
46 	double LocalScX;
47 	double LocalScY;
48 	double LocalX;
49 	double LocalY;
50 	double LocalRot;
51 	double ItemX;
52 	double ItemY;
53 	ScImageEffectList effects;
54 	QString inputProfile;
55 	bool   useEmbedded;
56 	eRenderIntent renderingIntent;
57 };
58 
59 struct DocPagesSetup
60 {
61 	DocPagesSetup() = default;
DocPagesSetupDocPagesSetup62 	DocPagesSetup(int pa, int fpl, int fpn, int o, bool atf, double cd, double cc) :
63 		pageArrangement(pa), firstPageLocation(fpl), firstPageNumber(fpn), orientation(o), autoTextFrames(atf),
64 		columnDistance(cd), columnCount(cc) {}
65 	int pageArrangement {0};
66 	int firstPageLocation {0};
67 	int firstPageNumber {0};
68 	int orientation {0};
69 	bool autoTextFrames {false};
70 	double columnDistance {0.0};
71 	double columnCount {1.0};
72 };
73 
74 struct PageSet
75 {
76 	QString Name;
77 	int FirstPage;
78 	int Rows;
79 	int Columns;
80 //	double GapHorizontal;
81 //	double GapVertical;
82 //	double GapBelow;
83 	QStringList pageNames;
84 };
85 
86 struct CMSData
87 {
88 	QString DefaultMonitorProfile;
89 	QString DefaultPrinterProfile;
90 	QString DefaultImageRGBProfile;
91 	QString DefaultImageCMYKProfile;
92 	QString DefaultSolidColorRGBProfile;
93 	QString DefaultSolidColorCMYKProfile;
94 	int ComponentsInput2;
95 	eRenderIntent DefaultIntentImages;
96 	eRenderIntent DefaultIntentColors;
97 	bool CMSinUse;
98 	bool SoftProofOn;
99 	bool SoftProofFullOn;
100 	bool GamutCheck;
101 	bool BlackPoint;
102 };
103 
104 enum
105 {
106 	Gradient_None = 0,
107 	Gradient_LinearLegacy1 = 1,
108 	Gradient_LinearLegacy2 = 2,
109 	Gradient_LinearLegacy3 = 3,
110 	Gradient_LinearLegacy4 = 4,
111 	Gradient_RadialLegacy5 = 5,
112 	Gradient_Linear = 6,
113 	Gradient_Radial = 7,
114 	Gradient_Pattern = 8,
115 	Gradient_4Colors = 9,
116 	Gradient_Diamond = 10,
117 	Gradient_Mesh = 11,
118 	Gradient_PatchMesh = 12,
119 	Gradient_Conical = 13,
120 	Gradient_Hatch = 14
121 };
122 
123 enum
124 {
125 	GradMask_None = 0,
126 	GradMask_Linear = 1,
127 	GradMask_Radial = 2,
128 	GradMask_Pattern = 3,
129 	GradMask_LinearLumAlpha = 4,
130 	GradMask_RadialLumAlpha = 5,
131 	GradMask_PatternLumAlpha = 6,
132 	GradMask_PatternLumAlphaInverted = 7,
133 	GradMask_PatternInverted = 8
134 };
135 
136 struct SingleLine
137 {
138 	double Width;
139 	int Dash;
140 	int LineEnd;
141 	int LineJoin;
142 	QString Color;
143 	int Shade;
144 	// setter necessary for use with serializer/digester
setLineWidthSingleLine145 	void setLineWidth(double value) { Width = value; }
setDashSingleLine146 	void setDash(int value)         { Dash = value; }
setLineEndSingleLine147 	void setLineEnd(int value)      { LineEnd = value; }
setLineJoinSingleLine148 	void setLineJoin(int value)     { LineJoin = value; }
setColorSingleLine149 	void setColor(const QString& name) { Color = name; }
setShadeSingleLine150 	void setShade(int value)        { Shade = value; }
151 	bool operator==(const SingleLine& other) const
152 	{
153 		if (!compareDouble(Width, other.Width) )
154 			return false;
155 		if ((Dash != other.Dash)  || (LineEnd != other.LineEnd) || (LineJoin != other.LineJoin) ||
156 			(Color != other.Color)|| (Shade != other.Shade))
157 			return false;
158 		return true;
159 	}
160 	bool operator!=(const SingleLine& other) const
161 	{
162 		return !(*this == other);
163 	}
164 };
165 
166 struct Bullet  //used by style reader while importing ODT files
167 {
168 	QString name;
169 	QString charStr;
170 	double indent;
171 	double firstLineIndent;
172 	double tabPosition;
173 	CharStyle* style;
BulletBullet174 	Bullet() : indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(nullptr) {}
BulletBullet175 	Bullet(QString n, QString ch) : name(n), charStr(ch), indent(0.0), firstLineIndent(0.0), tabPosition(0.0), style(nullptr) {}
BulletBullet176 	Bullet(QString n, QString ch, double first, double ind, double tab, CharStyle* chStyle)
177 	    { name = n; charStr = ch, firstLineIndent = first; indent = ind; tabPosition = tab; style = chStyle; }
178 };
179 
180 enum class ArrowDirection
181 {
182 	StartArrow = 0,
183 	EndArrow
184 };
185 
186 struct ArrowDesc
187 {
188 	QString name;
189 	bool userArrow;
190 	FPointArray points;
191 };
192 
193 struct PDFPresentationData
194 {
195 	PDFPresentationData() = default;
196 	int pageEffectDuration {1};
197 	int pageViewDuration {1};
198 	int effectType {0};
199 	int Dm {0};
200 	int M {0};
201 	int Di {0};
202 };
203 
204 struct LPIData
205 {
206 	int Frequency {0};
207 	int Angle {0};
208 	int SpotFunc {0};
209 };
210 
211 struct Keys
212 {
213 	QString actionName;
214 	QString cleanMenuText;
215 	QKeySequence keySequence;
216 	int tableRow;
217 	QString menuName;
218 	int menuPos;
219 };
220 
221 enum class PrintLanguage
222 {
223 	PostScript1 = 1,
224 	PostScript2 = 2,
225 	PostScript3 = 3,
226 	WindowsGDI  = 4,
227 	PDF         = 5
228 };
229 typedef QMap<QString, PrintLanguage> PrintLanguageMap;
230 
231 struct PrintOptions
232 {
233 	bool firstUse { true };
234 	bool toFile { false };
235 	bool useAltPrintCommand { false };
236 	bool outputSeparations { false };
237 	bool useSpotColors { true };
238 	bool useColor { true };
239 	bool mirrorH { false };
240 	bool mirrorV { false };
241 	bool doGCR { false };
242 	bool doClip { false };
243 	bool setDevParam { false };
244 	bool useDocBleeds { true };
245 	bool cropMarks { false };
246 	bool bleedMarks { false };
247 	bool registrationMarks { false };
248 	bool colorMarks { false };
249 	bool includePDFMarks { true };
250 	int  copies { 1 };
251 	PrintLanguage prnLanguage { PrintLanguage::PostScript3 };
252 	double markLength { 20.0 };
253 	double markOffset { 0.0 };
254 	MarginStruct bleeds;
255 	std::vector<int> pageNumbers;
256 	QString printerOptions;
257 	QString printer;
258 	QString filename;
259 	QString separationName { "All" };
260 	QStringList allSeparations;
261 	QString printerCommand;
262 	QByteArray devMode; // printer specific options on Windows
263 };
264 
265 typedef QMap<QString,QString> ProfilesL;
266 // typedef QValueVector<SingleLine> multiLine;
267 
268 class multiLine : public QList<SingleLine> {
269 public:
270 	QString shortcut;
271 	bool operator!=(const multiLine& other) const
272 	{
273 		return !(this->operator ==(other));
274 	}
275 };
276 
277 enum PreflightError
278 {
279 	MissingGlyph = 1,
280 	TextOverflow = 2,
281 	ObjectNotOnPage = 3,
282 	MissingImage = 4,
283 	ImageDPITooLow = 5,
284 	Transparency = 6,
285 	PDFAnnotField = 7,
286 	PlacedPDF = 8,
287 	ImageDPITooHigh = 9,
288 	ImageIsGIF = 10,
289 	BlendMode = 11,
290 	WrongFontInAnnotation = 12,
291 	NotCMYKOrSpot = 13,
292 	DeviceColorsAndOutputIntent = 14,
293 	FontNotEmbedded = 15,
294 	EmbeddedFontIsOpenType = 16,
295 	OffConflictLayers = 17,
296 	PartFilledImageFrame = 18,
297 	MarksChanged = 19,
298 	AppliedMasterDifferentSide = 20,
299 	EmptyTextFrame = 21
300 };
301 
302 typedef QMap<PreflightError, int> errorCodes;
303 
304 
305 struct AlignObjs
306 {
307 	int ObjNr;
308 	int Group;
309 	double x1;
310 	double y1;
311 	double x2;
312 	double y2;
313 	double width;
314 	double height;
315 	PageItem* Object;
316 };
317 
318 /*! \brief Human readable orientations */
319 enum PageOrientation
320 {
321 	portraitPage = 0,
322 	landscapePage = 1,
323 	customPage = 30
324 };
325 
326 /**
327 * Flags for ScribusView PageToPixmap()
328 */
329 enum PageToPixmapFlag
330 {
331 	Pixmap_NoFlags = 0,
332 	Pixmap_DrawFrame = 1 << 0,
333 	Pixmap_DrawBackground = 1 << 1,
334 	Pixmap_DrawWhiteBackground = 1 << 2,
335 	Pixmap_DontReloadImages = 1 << 3,
336 };
337 
338 Q_DECLARE_FLAGS(PageToPixmapFlags, PageToPixmapFlag);
339 Q_DECLARE_OPERATORS_FOR_FLAGS(PageToPixmapFlags);
340 
341 enum UpdateRequests
342 {
343 	reqColorsUpdate = 1,
344 	reqCharStylesUpdate = 2,
345 	reqParaStylesUpdate = 4,
346 	reqTextStylesUpdate = 6,
347 	reqArrowStylesUpdate = 8,
348 	reqLineStylesUpdate  = 16,
349 	reqSymbolsUpdate     = 32,
350 	reqDefFontListUpdate = 64,
351 	reqDocFontListUpdate = 128,
352 	reqStyleComboDocUpdate = 256,
353 	reqCmsOptionsUpdate  = 512,
354 	reqCustomShapeUpdate = 1024,
355 	reqInlinePalUpdate   = 2048,
356 	reqMarksUpdate       = 4096,
357 	reqNumUpdate         = 8192,
358 	reqUpdateAll = 65535
359 };
360 
361 //! \brief Common type for guides list
362 typedef QList<double> Guides;
363 
364 //! \brief from ols scribusXml
365 struct Linked
366 {
367 	int Start;
368 	int StPag;
369 };
370 
371 // this is a quick hack to combine runs until I've thought of something better -- AV
372 class LastStyles
373 {
374 public:
375 	CharStyle Style;
376 	int StyleStart;
377 	QString ParaStyle;
LastStyles()378 	LastStyles() {
379 		StyleStart = 0;
380 	}
381 };
382 
383 class AttributeValue
384 {
385 	public:
386 		AttributeValue() = default;
AttributeValue(const QString & val)387 		AttributeValue(const QString& val)
388 		{
389 			if (val.isEmpty())
390 			{
391 				valid = false;
392 				value.clear();
393 			}
394 			else
395 			{
396 				valid = true;
397 				value = val;
398 			}
399 		}
400 		bool valid {false};
401 		QString value;
402 };
403 
404 //TODO: Dict license showing, URL background unzipping, checksumming, pkg mgr platforms warning
405 struct DownloadItem
406 {
407 	QString lang;
408 	QString version;
409 	QString files;
410 	QString extractfiles;
411 	QString url;
412 	QString desc;
413 	QString license;
414 	QString filetype;
415 	QString type;
416 	QString movetofile;
417 	QString source;
418 	bool download;
419 };
420 
421 struct DownloadData
422 {
423 	int id;
424 	QUrl url;
425 	QString name;
426 	QString downloadLocation;
427 	QString destinationLocation;
428 	QString destinationName;
429 	typedef enum {New, Started, Paused, Finished, Successful, Failed} DownloadState;
430 	DownloadState state;
431 };
432 
433 enum
434 {
435 	GS_ALL,
436 	GS_MARGINS,
437 	GS_FRAMES,
438 	GS_GRID,
439 	GS_GUIDES,
440 	GS_BASELINE,
441 	GS_LINKS,
442 	GS_CONTROLS,
443 	GS_RULERMODE,
444 	GS_RULERS,
445 	GS_COLUMNBORDERS,
446 	GS_LAYERMARKERS,
447 	GS_BLEED,
448 	GS_MAX
449 };
450 
451 //Always add new at the end, leave existing and deprecated items in the list
452 enum
453 {
454 	PAL_ALL,
455 	PAL_PROPERTIES,
456 	PAL_OUTLINE,
457 	PAL_SCRAPBOOK,
458 	PAL_LAYER,
459 	PAL_PAGE,
460 	PAL_BOOKMARK,
461 	PAL_7_UNUSED,
462 	PAL_UNDO,
463 	PAL_VERIFIER,
464 	PAL_DOWNLOADS,
465 	PAL_TEXT,
466 	PAL_CONTENT,
467 	PAL_MAX
468 };
469 
470 #endif
471 
472