Scribus
Open source desktop publishing at your fingertips
importcgm.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  importcgm.h - description
9  -------------------
10  begin : Wed Dez 23 2009
11  copyright : (C) 2009 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 #ifndef IMPORTCGM_H
16 #define IMPORTCGM_H
17 
18 #include "pluginapi.h"
19 #include "pageitem.h"
20 #include "sccolor.h"
21 #include "fpointarray.h"
22 #include <QList>
23 #include <QTransform>
24 #include <QMultiMap>
25 #include <QtGlobal>
26 #include <QObject>
27 #include <QString>
28 
29 class MultiProgressDialog;
30 class ScribusDoc;
31 class Selection;
33 
35 {
36  public:
37  ScBitReader(QByteArray &data);
38  ~ScBitReader();
39  quint32 getUInt(uint size);
40  void alignToWord();
41  private:
42  int actByte;
43  int actBit;
44  QByteArray buffer;
45 };
46 
48 class CgmPlug : public QObject
49 {
50  Q_OBJECT
51 
52 public:
62  CgmPlug( ScribusDoc* doc, int flags );
63  ~CgmPlug();
64 
75  bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
76  QImage readThumbnail(QString fn);
77 
78 private:
79  void parseHeader(QString fName, double &b, double &h);
80  bool convert(QString fn);
81  void decodeText(QFile &f);
82 
83 /* binary Decoder */
84  void decodeBinary(QDataStream &ts, quint16 elemClass, quint16 elemID, quint16 paramLen);
85  void decodeClass0(QDataStream &ts, quint16 elemID, quint16 paramLen);
86  void decodeClass1(QDataStream &ts, quint16 elemID, quint16 paramLen);
87  void decodeClass2(QDataStream &ts, quint16 elemID, quint16 paramLen);
88  void decodeClass3(QDataStream &ts, quint16 elemID, quint16 paramLen);
89  void decodeClass4(QDataStream &ts, quint16 elemID, quint16 paramLen);
90  void decodeClass5(QDataStream &ts, quint16 elemID, quint16 paramLen);
91  void decodeClass6(QDataStream &ts, quint16 elemID, quint16 paramLen);
92  void decodeClass7(QDataStream &ts, quint16 elemID, quint16 paramLen);
93  void decodeClass8(QDataStream &ts, quint16 elemID, quint16 paramLen);
94  void decodeClass9(QDataStream &ts, quint16 elemID, quint16 paramLen);
95  void getBinaryBezierPath(QDataStream &ts, quint16 paramLen);
96  void getBinaryPath(QDataStream &ts, quint16 paramLen, bool disjoint = false);
97  void getBinaryColorTable(QDataStream &ts, quint16 paramLen);
98  ScColor getBinaryDirectColor(ScBitReader *breader);
99  ScColor getBinaryDirectColor(QDataStream &ts);
100  QString getBinaryIndexedColor(ScBitReader *breader);
101  QString getBinaryIndexedColor(QDataStream &ts);
102  QString getBinaryColor(QDataStream &ts);
103  double getBinaryDistance(QDataStream &ts);
104  QPointF getBinaryCoords(QDataStream &ts, bool raw = false);
105  uint getBinaryUInt(QDataStream &ts, int intP);
106  int getBinaryInt(QDataStream &ts, int intP);
107  double getBinaryReal(QDataStream &ts, int realP, int realM);
108  QString getBinaryText(QDataStream &ts);
109  void alignStreamToWord(QDataStream &ts, uint len);
110 
111 /* core functions */
112  void handleStartMetaFile(QString value);
113  void handleStartPicture(QString value);
114  void handleStartPictureBody(double width, double height);
115  void handleMetaFileDescription(QString value);
116  QString handleColor(ScColor &color, QString proposedName);
117  double convertCoords(double input);
118  QPointF convertCoords(QPointF input);
119  void appendPath(QPainterPath &path1, QPainterPath &path2);
120  PageItem* itemAdd(PageItem::ItemType itemType, PageItem::ItemFrameType frameType, double x, double y, double b, double h, double w, QString fill, QString stroke);
121  void finishItem(PageItem* ite, bool line = true);
122 
123 /* common variables */
124  int metaFileVersion;
125  int vdcType;
126  int vdcInt;
127  int vdcReal;
128  int vdcMantissa;
129  bool vcdFlippedH;
130  bool vcdFlippedV;
131  double vdcWidth;
132  double vdcHeight;
133  double metaFileScale;
134  double metaScale;
135  int metaFileScaleMode;
136  int intPrecision;
137  int realPrecision;
138  int realMantissa;
139  int realFraction;
140  bool realPrecisionSet;
141  int indexPrecision;
142  int colorPrecision;
143  int colorIndexPrecision;
144  uint maxColorIndex;
145  int m_colorModel;
146  int colorMode;
147  int namePrecision;
148  int lineWidthMode;
149  int edgeWidthMode;
150  int markerSizeMode;
151  double viewPortScale;
152  int viewPortScaleMode;
153 
154  int lineBundleIndex;
155  Qt::PenStyle lineType;
156  Qt::PenCapStyle lineCap;
157  Qt::PenJoinStyle lineJoin;
158  double lineWidth;
159  Qt::PenStyle edgeType;
160  Qt::PenCapStyle edgeCap;
161  Qt::PenJoinStyle edgeJoin;
162  double edgeWidth;
163  uint minColor, maxColor;
164  QString lineColor;
165  bool lineVisible;
166  QString edgeColor;
167  QString fillColor;
168  int fillType;
169  int patternIndex;
170  QMap<int, QString> patternTable;
171  double patternScaleX;
172  double patternScaleY;
173  QString backgroundColor;
174  bool backgroundSet;
175  QMap<uint, QString> ColorTableMap;
176  QRectF clipRect;
177  bool useClipRect;
178  bool clipSet;
179  QPainterPath regionPath;
180  bool recordRegion;
181  int currentRegion;
182  QMap<int, QPainterPath> regionMap;
183  QPointF fillRefPoint;
184 
185  QList<PageItem*> Elements;
186  int currentItemNr;
187  QStack<QList<PageItem*> > groupStack;
188  ColorList CustColors;
189  double baseX, baseY;
190  double docWidth;
191  double docHeight;
192  QStringList importedColors;
193 
194  FPointArray Coords;
195  bool interactive;
196  MultiProgressDialog * progressDialog;
197  bool cancel;
198  ScribusDoc* m_Doc;
199  Selection* tmpSel;
200  int importerFlags;
201  int oldDocItemCount;
202  QString baseFile;
203  bool importRunning;
204  bool firstPage;
205  bool vcdSet;
206  bool wasEndPic;
207  bool recordFigure;
208  QPainterPath figurePath;
209  bool figClose;
210  int figDocIndex;
211  int figElemIndex;
212  int figGstIndex;
213  QString figFillColor;
214  QMap<int, QString> fontID_Map;
215  int m_fontIndex;
216  QString textColor;
217  int textSize;
218  int textAlignH;
219  int textScaleMode;
220  QString pictName;
221 
222 public slots:
223  void cancelRequested() { cancel = true; }
224 };
225 
226 #endif
Definition: importcgm.h:34
Definition: sccolor.h:51
Cgm importer plugin.
Definition: importcgm.h:48
CgmPlug(ScribusDoc *doc, int flags)
Create the Cgm importer window.
Definition: importcgm.cpp:102
Definition: sccolor.h:155
the Document Class
Definition: scribusdoc.h:90
ItemFrameType
Frame Type.
Definition: pageitem.h:208
Definition: undomanager.h:52
Binary buffer.
Definition: pdbim.h:93
ItemType
Item Type.
Definition: pageitem.h:174
Definition: pageitem.h:92
Definition: fpointarray.h:42
Definition: selection.h:34