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 IMPORTPDF_H
8 #define IMPORTPDF_H
9 
10 #include <QBrush>
11 #include <QBuffer>
12 #include <QColor>
13 #include <QImage>
14 #include <QList>
15 #include <QMultiMap>
16 #include <QObject>
17 #include <QPen>
18 #include <QtGlobal>
19 #include <QSizeF>
20 #include <QString>
21 #include <QTextStream>
22 
23 #include <memory>
24 
25 #include "fpointarray.h"
26 #include "importpdfconfig.h"
27 #include "pluginapi.h"
28 #include "pageitem.h"
29 #include "sccolor.h"
30 
31 class QColor;
32 
33 class MultiProgressDialog;
34 class ScribusDoc;
35 class Selection;
36 class TransactionSettings;
37 
38 class GooString;
39 class PDFDoc;
40 
41 //! \brief PDF importer plugin
42 class PdfPlug : public QObject
43 {
44 	Q_OBJECT
45 
46 public:
47 	/*!
48 	\author Franz Schmid
49 	\date
50 	\brief Create the PDF importer window.
51 	\param fName QString
52 	\param flags combination of loadFlags
53 	\param showProgress if progress must be displayed
54 	\retval EPSPlug plugin
55 	*/
56 	PdfPlug( ScribusDoc* doc, int flags );
57 	~PdfPlug();
58 
59 	/*!
60 	\author Franz Schmid
61 	\date
62 	\brief Perform import.
63 	\param fn QString
64 	\param trSettings undo transaction settings
65 	\param flags combination of loadFlags
66 	\param showProgress if progress must be displayed
67 	\retval bool true if import was ok
68 	 */
69 	bool import(const QString& fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
70 	QImage readThumbnail(const QString& fn);
71 	QImage readPreview(int pgNum, int width, int height, int box);
72 	enum PDF_Box_Type
73 	{
74 		Media_Box	= 0,
75 		Bleed_Box	= 1,
76 		Trim_Box	= 2,
77 		Crop_Box	= 3,
78 		Art_Box		= 4
79 	};
80 
81 private:
82 	bool convert(const QString& fn);
83 	QRectF getCBox(int box, int pgNum);
84 	QString UnicodeParsedString(POPPLER_CONST GooString *s1);
85 	QString UnicodeParsedString(const std::string& s1);
86 
87 	QList<PageItem*> m_elements;
88 
89 	QStringList m_importedColors;
90 
91 	bool m_cancel {false};
92 	bool m_interactive;
93 	bool m_noDialogs;
94 	MultiProgressDialog *m_progressDialog {nullptr};
95 	ScribusDoc* m_Doc {nullptr};
96 	Selection* m_tmpSele {nullptr};
97 	int m_importerFlags;
98 	QString m_baseFile;
99 	PDFDoc *m_pdfDoc {nullptr};
100 
101 public slots:
cancelRequested()102 	void cancelRequested() { m_cancel = true; }
103 };
104 
105 #endif
106