Scribus
Open source desktop publishing at your fingertips
importpages.h
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 /***************************************************************************
8  -------------------
9  begin : Mon Dez 30 2013
10  copyright : (C) 2013 by Franz Schmid
11  email : Franz.Schmid@altmuehlnet.de
12  ***************************************************************************/
13 #ifndef IMPORTPAGES_H
14 #define IMPORTPAGES_H
15 
16 #if 0
17 
18 #include <QObject>
19 #include <QString>
20 
21 #include "pluginapi.h"
22 #include "pageitem.h"
23 #include "sccolor.h"
24 #include "fpointarray.h"
25 #include "vgradient.h"
26 #include <QList>
27 #include <QTransform>
28 #include <QMultiMap>
29 #include <QVector>
30 
31 class MultiProgressDialog;
32 class ScribusDoc;
33 class Selection;
35 
37 class PagesPlug : public QObject
38 {
39  Q_OBJECT
40 
41 public:
51  PagesPlug( ScribusDoc* doc, int flags );
52  ~PagesPlug();
53 
64  bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
65  QImage readThumbnail(QString fn);
66 
67 private:
68  bool convert(QString fn);
69 
70  QList<PageItem*> Elements;
71  double baseX, baseY;
72  double docWidth;
73  double docHeight;
74 
75  QStringList importedColors;
76  QStringList importedPatterns;
77 
78  bool interactive;
79  MultiProgressDialog * progressDialog;
80  bool cancel;
81  ScribusDoc* m_Doc;
82  Selection* tmpSel;
83  int importerFlags;
84 
85 public slots:
86  void cancelRequested() { cancel = true; }
87 };
88 #else
89 
90 #include "pluginapi.h"
91 #include "pageitem.h"
92 #include "sccolor.h"
93 #include "fpointarray.h"
94 #include "scribusstructs.h"
95 #include <QList>
96 #include <QTransform>
97 #include <QMultiMap>
98 #include <QtGlobal>
99 #include <QObject>
100 #include <QString>
101 #include <QDomDocument>
102 #include <QDomElement>
103 
104 class MultiProgressDialog;
105 class ScribusDoc;
106 class Selection;
107 class TransactionSettings;
108 class ScZipHandler;
109 
110 class PagesPlug : public QObject
111 {
112  Q_OBJECT
113 
114 public:
124  PagesPlug( ScribusDoc* doc, int flags );
125  ~PagesPlug();
126 
137  bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
138  QImage readThumbnail(QString fn);
139 
140 private:
141  struct ObjStyle
142  {
143  AttributeValue parentStyle;
144  AttributeValue CurrColorFill;
145  AttributeValue CurrColorStroke;
146  AttributeValue fillOpacity;
147  AttributeValue strokeOpacity;
148  AttributeValue opacity;
149  AttributeValue LineW;
150  AttributeValue CapStyle;
151  AttributeValue JoinStyle;
152  };
153  struct ChrStyle
154  {
155  AttributeValue parentStyle;
156  AttributeValue fontName;
157  AttributeValue fontSize;
158  AttributeValue fontColor;
159  };
160  struct ParStyle
161  {
162  AttributeValue parentStyle;
163  AttributeValue fontName;
164  AttributeValue fontSize;
165  AttributeValue fontColor;
166  AttributeValue justification;
167  };
168  struct LayoutStyle
169  {
170  AttributeValue parentStyle;
171  AttributeValue Extra;
172  AttributeValue TExtra;
173  AttributeValue BExtra;
174  AttributeValue RExtra;
175  AttributeValue TextColumnCount;
176  AttributeValue TextColumnGutter;
177  };
178 
179  struct ObjState
180  {
181  QPainterPath currentPath;
182  bool currentPathClosed;
183  QPainterPath clipPath;
184  QTransform transform;
185  QString CurrColorFill;
186  double fillOpacity;
187  QString CurrColorStroke;
188  double strokeOpacity;
189  double LineW;
190  VGradient currentGradient;
191  QPointF gradientStart;
192  QPointF gradientEnd;
193  QPointF gradientFocus;
194  double gradientScale;
195  int fillGradientTyp;
196  QString imagePath;
197  QString patternName;
198  VGradient gradientMask;
199  QPointF maskStart;
200  QPointF maskEnd;
201  QPointF maskFocus;
202  double maskScale;
203  int maskTyp;
204  QString patternMask;
205  VGradient gradientStroke;
206  QPointF strokeStart;
207  QPointF strokeEnd;
208  QPointF strokeFocus;
209  double strokeScale;
210  int strokeTyp;
211  QString patternStroke;
212  int itemType;
213  Qt::PenCapStyle CapStyle;
214  Qt::PenJoinStyle JoinStyle;
215  QVector<double> DashPattern;
216  double DashOffset;
217  double xPos;
218  double yPos;
219  double width;
220  double height;
221  double rotation;
222  QString styleRef;
223  QString layoutStyleRef;
224  };
225  struct StyleSheet
226  {
227  QHash<QString, ObjStyle> m_objStyles;
228  QHash<QString, ParStyle> m_parStyles;
229  QHash<QString, ChrStyle> m_chrStyles;
230  QHash<QString, LayoutStyle> m_layoutStyles;
231  };
232 
233  bool convert(QString fn);
234  bool parseDocReference(QString designMap, bool compressed);
235  void parseStyleSheets(QDomElement &drawPag);
236  void parsePageReference(QDomElement &drawPag);
237  PageItem *parseObjReference(QDomElement &draw);
238  void applyParagraphAttrs(ParagraphStyle &newStyle, CharStyle &tmpCStyle, QString pAttrs);
239  void applyCharAttrs(CharStyle &tmpCStyle, QString pAttrs);
240  void finishItem(PageItem* item, ObjState &obState);
241  QList<PageItem*> Elements;
242  double baseX, baseY;
243  double docWidth;
244  double docHeight;
245  bool interactive;
246  ScribusDoc* m_Doc;
247  Selection* tmpSel;
248  int importerFlags;
249  MultiProgressDialog * progressDialog;
250  bool cancel;
251  QStringList importedColors;
252  QStringList importedPatterns;
253  bool firstPage;
254  int pagecount;
255  int mpagecount;
256  double topMargin;
257  double leftMargin;
258  double rightMargin;
259  double bottomMargin;
260  double pgCols;
261  double pgGap;
262  QString papersize;
263  QHash<int, QString> imageResources;
264  QHash<QString, StyleSheet> m_StyleSheets;
265  QString m_currentStyleSheet;
266 
267  PageItem* addClip(PageItem* retObj, ObjState &obState);
268 
269  FPointArray Coords;
270  QHash<QString, QPainterPath> pathResources;
271  ScZipHandler *uz;
272 
273 public slots:
274  void cancelRequested() { cancel = true; }
275 };
276 #endif
277 #endif
Definition: charstyle.h:78
Definition: vgradient.h:78
Definition: paragraphstyle.h:27
the Document Class
Definition: scribusdoc.h:90
PagesPlug(ScribusDoc *doc, int flags)
Create the importer window.
Definition: importpages.cpp:456
Definition: undomanager.h:52
Definition: pageitem.h:92
Definition: scribus_zip.h:28
Definition: fpointarray.h:42
Definition: importpages.h:110
Definition: scribusstructs.h:349
Definition: selection.h:34