Scribus
Open source desktop publishing at your fingertips
importviva.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 : Sun Sep 29 2013
10  copyright : (C) 2013 by Franz Schmid
11  email : Franz.Schmid@altmuehlnet.de
12  ***************************************************************************/
13 #ifndef IMPORTVIVA_H
14 #define IMPORTVIVA_H
15 
16 #include "pluginapi.h"
17 #include "pageitem.h"
18 #include "sccolor.h"
19 #include "sctextstruct.h"
20 #include "text/storytext.h"
21 #include "fpointarray.h"
22 #include "scribusstructs.h"
23 #include <QList>
24 #include <QTransform>
25 #include <QMultiMap>
26 #include <QtGlobal>
27 #include <QObject>
28 #include <QString>
29 #include <QDomDocument>
30 #include <QDomElement>
31 
32 class MultiProgressDialog;
33 class ScribusDoc;
34 class Selection;
36 
38 class VivaPlug : public QObject
39 {
40  Q_OBJECT
41 
42 public:
52  VivaPlug( ScribusDoc* doc, int flags );
53  ~VivaPlug();
54 
65  bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
66  QImage readThumbnail(QString fn);
67  bool readColors(const QString& fileName, ColorList & colors);
68 
69 private:
70  struct triplePoint
71  {
72  FPoint beforePolyPoint;
73  FPoint PolyPoint;
74  FPoint afterPolyPoint;
75  };
76 
77  struct AttributeSet
78  {
79  AttributeValue applyedParStyle;
80  AttributeValue parentStyle;
81  // Character Attributes
82  AttributeValue fontFullName;
83  AttributeValue fontFamily;
84  AttributeValue fontStyle;
85  AttributeValue fontSize;
86  AttributeValue fontColor;
87  AttributeValue fontColorDensity;
88  AttributeValue fontEffect;
89  AttributeValue placement;
90  AttributeValue underline;
91  AttributeValue underlineWidth;
92  AttributeValue underlineOffset;
93  AttributeValue strikethrough;
94  AttributeValue strikethroughWidth;
95  AttributeValue strikethroughOffset;
96  AttributeValue outline;
97  AttributeValue outlineWidth;
98  AttributeValue outlineColor;
99  AttributeValue widthScale;
100  AttributeValue heightScale;
101  AttributeValue spacing;
102  AttributeValue baselineOffset;
103  // Paragraph Attributes
104  AttributeValue justification;
105  AttributeValue gapbefore;
106  AttributeValue gapafter;
107  AttributeValue lineSpacing;
108  AttributeValue indent;
109  AttributeValue firstLineIndent;
110  AttributeValue rightIndent;
111  AttributeValue columnCount;
112  AttributeValue columnGutter;
113  AttributeValue dropCaps;
114  AttributeValue dropCapsLines;
115  AttributeValue dropCapsDist;
116  AttributeValue tabulators;
117  };
118  double parseUnit(const QString &unit);
119  bool convert(QString fn);
120  void parseSettingsXML(const QDomElement& grNode);
121  void parseColorsXML(const QDomElement& grNode);
122  void parsePreferencesXML(const QDomElement& spNode);
123  void parseLayerXML(const QDomElement& spNode);
124  void parseMasterSpreadXML(const QDomElement& spNode);
125  void parseSpreadXML(const QDomElement& spElem);
126  void parseTextChainsXML(const QDomElement& obNode);
127  PageItem* parseObjectXML(const QDomElement& obNode);
128  PageItem *parseObjectDetailsXML(const QDomElement& obNode, int baseType);
129  void parseTextXML(const QDomElement& obNode, StoryText &itemText, int &textColumnCount, double &textColumnGap);
130  void parseAttributeSetXML(const QDomElement& obNode, AttributeSet &attrs);
131  void parseAttributeSetsXML(const QDomElement& obNode);
132  void parseStylesheetsXML(const QDomElement& obNode);
133  void applyParagraphAttrs(ParagraphStyle &newStyle, AttributeSet &pAttrs);
134  void applyCharacterAttrs(CharStyle &tmpCStyle, ParagraphStyle &newStyle, AttributeSet &pAttrs);
135  QString constructFontName(QString fontBaseName, QString fontStyle);
136  QPointF intersectBoundingRect(PageItem *item, QLineF gradientVector);
137 
138  QList<PageItem*> Elements;
139  double baseX, baseY;
140  double docWidth;
141  double docHeight;
142  bool facingPages;
143  bool hasLayers;
144  bool firstLayer;
145  bool firstPage;
146  int pagecount;
147  int mpagecount;
148  QMap<QString, int> mspreadTypes;
149  FPointArray Coords;
150  bool interactive;
151  MultiProgressDialog * progressDialog;
152  bool cancel;
153  ScribusDoc* m_Doc;
154  Selection* tmpSel;
155  int importerFlags;
156  QString baseFile;
157  QDomDocument designMapDom;
158  QStringList importedColors;
159  double topMargin;
160  double leftMargin;
161  double rightMargin;
162  double bottomMargin;
163  QString papersize;
164  QHash<QString, AttributeSet> AttributeSets;
165  QHash<QString, QString> colorTranslate;
166  QStringList importedGradients;
167  QMap<QString, QString> gradientTranslate;
168  QMap<QString, int> gradientTypeMap;
169  QMap<QString, PageItem*> storyMap;
170 
171 public slots:
172  void cancelRequested() { cancel = true; }
173 };
174 
175 #endif
Definition: storytext.h:71
Definition: charstyle.h:78
Definition: paragraphstyle.h:27
Definition: sccolor.h:155
A point with floating point precision.
Definition: fpoint.h:43
VivaPlug(ScribusDoc *doc, int flags)
Create the Viva importer window.
Definition: importviva.cpp:69
the Document Class
Definition: scribusdoc.h:90
Definition: undomanager.h:52
Viva importer plugin.
Definition: importviva.h:38
Definition: pageitem.h:92
Definition: fpointarray.h:42
Definition: scribusstructs.h:349
Definition: selection.h:34