Scribus
Open source desktop publishing at your fingertips
rawpainter.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 #ifndef RAWPAINTER_H
8 #define RAWPAINTER_H
9 
10 #include <QObject>
11 #include <QString>
12 
13 #include "pluginapi.h"
14 #include "pageitem.h"
15 #include "sccolor.h"
16 #include "fpointarray.h"
17 #include "vgradient.h"
18 #include <QList>
19 #include <QTransform>
20 #include <QMultiMap>
21 #include <QVector>
22 
23 class ScribusDoc;
24 class Selection;
25 
26 #if HAVE_REVENGE
27  #include <librevenge/librevenge.h>
28  #include <librevenge-stream/librevenge-stream.h>
29  #include <librevenge-generators/librevenge-generators.h>
30 
31 struct RawPainterPrivate;
32 
33 class RawPainter : public librevenge::RVNGDrawingInterface
34 {
35 public:
36  RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel, QString fTyp);
37  ~RawPainter();
38 
39  void startDocument(const librevenge::RVNGPropertyList &propList);
40  void endDocument();
41  void setDocumentMetaData(const librevenge::RVNGPropertyList &propList);
42  void defineEmbeddedFont(const librevenge::RVNGPropertyList &propList);
43  void startPage(const librevenge::RVNGPropertyList &propList);
44  void endPage();
45  void startMasterPage(const librevenge::RVNGPropertyList &propList);
46  void endMasterPage();
47  void startLayer(const librevenge::RVNGPropertyList &propList);
48  void endLayer();
49  void startEmbeddedGraphics(const librevenge::RVNGPropertyList &propList);
50  void endEmbeddedGraphics();
51 
52  void openGroup(const librevenge::RVNGPropertyList &propList);
53  void closeGroup();
54 
55  void setStyle(const librevenge::RVNGPropertyList &propList);
56 
57  void drawRectangle(const librevenge::RVNGPropertyList &propList);
58  void drawEllipse(const librevenge::RVNGPropertyList &propList);
59  void drawPolyline(const librevenge::RVNGPropertyList &propList);
60  void drawPolygon(const librevenge::RVNGPropertyList &propList);
61  void drawPath(const librevenge::RVNGPropertyList &propList);
62  void drawGraphicObject(const librevenge::RVNGPropertyList &propList);
63  void drawConnector(const librevenge::RVNGPropertyList &propList);
64  void startTextObject(const librevenge::RVNGPropertyList &propList);
65  void endTextObject();
66 
67  void startTableObject(const librevenge::RVNGPropertyList &propList);
68  void openTableRow(const librevenge::RVNGPropertyList &propList);
69  void closeTableRow();
70  void openTableCell(const librevenge::RVNGPropertyList &propList);
71  void closeTableCell();
72  void insertCoveredTableCell(const librevenge::RVNGPropertyList &propList);
73  void endTableObject();
74 
75  void openOrderedListLevel(const librevenge::RVNGPropertyList &propList);
76  void closeOrderedListLevel();
77 
78  void openUnorderedListLevel(const librevenge::RVNGPropertyList &propList);
79  void closeUnorderedListLevel();
80  void openListElement(const librevenge::RVNGPropertyList &propList);
81  void closeListElement();
82 
83  void defineParagraphStyle(const librevenge::RVNGPropertyList &propList);
84  void openParagraph(const librevenge::RVNGPropertyList &propList);
85  void closeParagraph();
86 
87  void defineCharacterStyle(const librevenge::RVNGPropertyList &propList);
88  void openSpan(const librevenge::RVNGPropertyList &propList);
89  void closeSpan();
90 
91  void openLink(const librevenge::RVNGPropertyList &propList);
92  void closeLink();
93 
94  void insertTab();
95  void insertSpace();
96  void insertText(const librevenge::RVNGString &text);
97  void insertLineBreak();
98  void insertField(const librevenge::RVNGPropertyList &propList);
99  double valueAsPoint(const librevenge::RVNGProperty *prop);
100  QString constructFontName(QString fontBaseName, QString fontStyle);
101  double fromPercentage(const QString &s );
102  QColor parseColorN( const QString &rgbColor );
103  QString parseColor( const QString &s );
104  void insertImage(PageItem* ite, QString imgExt, QByteArray &imageData);
105  void applyFill(PageItem* ite);
106  void applyShadow(PageItem* ite);
107  void applyFlip(PageItem* ite);
108  void recolorItem(PageItem* ite, QString efVal);
109  void applyArrows(PageItem* ite);
110  void finishItem(PageItem* ite);
111 private:
112  RawPainterPrivate *m_pImpl;
113  ScribusDoc* m_Doc;
114  double baseX, baseY;
115  double docWidth;
116  double docHeight;
117  QList<PageItem*> *Elements;
118  QStringList *importedColors;
119  QStringList *importedPatterns;
120  Selection* tmpSel;
121  struct groupEntry
122  {
123  QList<PageItem*> Items;
124  FPointArray clip;
125  };
126  QStack<groupEntry> groupStack;
127  double LineW;
128  QString CurrColorFill;
129  QString CurrColorStroke;
130  double CurrStrokeShade;
131  double CurrFillShade;
132  double CurrStrokeTrans;
133  double CurrFillTrans;
134  FPointArray Coords;
135  bool fillrule;
136  double gradientAngle;
137  bool isGradient;
138  VGradient currentGradient;
139  QString gradColor1Str;
140  QColor gradColor1;
141  double gradColor1Trans;
142  QString gradColor2Str;
143  QColor gradColor2;
144  double gradColor2Trans;
145  QVector<double> dashArray;
146  Qt::PenJoinStyle lineJoin;
147  Qt::PenCapStyle lineEnd;
148  bool firstPage;
149  QString baseLayer;
150  int actPage;
151  librevenge::RVNGPropertyList m_style;
152  PageItem *actTextItem;
153  ParagraphStyle textStyle;
154  CharStyle textCharStyle;
155  double m_linespace;
156  double m_maxFontSize;
157  bool lineSpSet;
158  bool lineSpIsPT;
159  int importerFlags;
160  bool doProcessing;
161  QString fileType;
162 };
163 
164 class RawPainterPres : public librevenge::RVNGRawTextGenerator
165 {
166 public:
167  RawPainterPres(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel, QString fTyp);
168  ~RawPainterPres();
169  void startDocument(const librevenge::RVNGPropertyList &propList);
170  void endDocument();
171  void setDocumentMetaData(const librevenge::RVNGPropertyList &propList);
172  void defineEmbeddedFont(const librevenge::RVNGPropertyList &propList);
173  void definePageStyle(const librevenge::RVNGPropertyList &propList);
174  void openPageSpan(const librevenge::RVNGPropertyList &propList);
175  void closePageSpan();
176  void openHeader(const librevenge::RVNGPropertyList &propList);
177  void closeHeader();
178  void openFooter(const librevenge::RVNGPropertyList &propList);
179  void closeFooter();
180  void defineParagraphStyle(const librevenge::RVNGPropertyList &propList);
181  void openParagraph(const librevenge::RVNGPropertyList &propList);
182  void closeParagraph();
183  void defineCharacterStyle(const librevenge::RVNGPropertyList &propList);
184  void openSpan(const librevenge::RVNGPropertyList &propList);
185  void closeSpan();
186  void openLink(const librevenge::RVNGPropertyList &propList);
187  void closeLink();
188  void defineSectionStyle(const librevenge::RVNGPropertyList &propList);
189  void openSection(const librevenge::RVNGPropertyList &propList);
190  void closeSection();
191  void insertTab();
192  void insertSpace();
193  void insertText(const librevenge::RVNGString &text);
194  void insertLineBreak();
195  void insertField(const librevenge::RVNGPropertyList &propList);
196  void openOrderedListLevel(const librevenge::RVNGPropertyList &propList);
197  void openUnorderedListLevel(const librevenge::RVNGPropertyList &propList);
198  void closeOrderedListLevel();
199  void closeUnorderedListLevel();
200  void openListElement(const librevenge::RVNGPropertyList &propList);
201  void closeListElement();
202  void openFootnote(const librevenge::RVNGPropertyList &propList);
203  void closeFootnote();
204  void openEndnote(const librevenge::RVNGPropertyList &propList);
205  void closeEndnote();
206  void openComment(const librevenge::RVNGPropertyList &propList);
207  void closeComment();
208  void openTextBox(const librevenge::RVNGPropertyList &propList);
209  void closeTextBox();
210  void openTable(const librevenge::RVNGPropertyList &propList);
211  void openTableRow(const librevenge::RVNGPropertyList &propList);
212  void closeTableRow();
213  void openTableCell(const librevenge::RVNGPropertyList &propList);
214  void closeTableCell();
215  void insertCoveredTableCell(const librevenge::RVNGPropertyList &propList);
216  void closeTable();
217  void openFrame(const librevenge::RVNGPropertyList &propList);
218  void closeFrame();
219  void openGroup(const librevenge::RVNGPropertyList &propList);
220  void closeGroup();
221  void defineGraphicStyle(const librevenge::RVNGPropertyList &propList);
222  void drawRectangle(const librevenge::RVNGPropertyList &propList);
223  void drawEllipse(const librevenge::RVNGPropertyList &propList);
224  void drawPolygon(const librevenge::RVNGPropertyList &propList);
225  void drawPolyline(const librevenge::RVNGPropertyList &propList);
226  void drawPath(const librevenge::RVNGPropertyList &propList);
227  void drawConnector(const librevenge::RVNGPropertyList &propList);
228  void insertBinaryObject(const librevenge::RVNGPropertyList &propList);
229  void insertEquation(const librevenge::RVNGPropertyList &propList);
230 private:
231  QList<PageItem*> *mElements;
232  RawPainter *painter;
233  QList<QList<PageItem*> > pageElements;
234  ScribusDoc* mDoc;
235 };
236 
237 #else
238  #include <libwpd-stream/libwpd-stream.h>
239  #include <libwpd/libwpd.h>
240  #include <libwpg/libwpg.h>
241 
242 
244 {
245 public:
246  RawPainter(ScribusDoc* Doc, double x, double y, double w, double h, int iflags, QList<PageItem*> *Elem, QStringList *iColors, QStringList *iPatterns, Selection* tSel, QString fTyp);
247  void startGraphics(const ::WPXPropertyList &propList);
248  void endGraphics();
249  void startLayer(const ::WPXPropertyList &propList);
250  void endLayer();
251  void startEmbeddedGraphics(const ::WPXPropertyList &propList);
252  void endEmbeddedGraphics();
253  void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient);
254  void drawRectangle(const ::WPXPropertyList &propList);
255  void drawEllipse(const ::WPXPropertyList &propList);
256  void drawPolyline(const ::WPXPropertyListVector &vertices);
257  void drawPolygon(const ::WPXPropertyListVector &vertices);
258  void drawPath(const ::WPXPropertyListVector &path);
259  void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData);
260  void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
261  void endTextObject();
262  void startTextLine(const ::WPXPropertyList &propList);
263  void endTextLine();
264  void startTextSpan(const ::WPXPropertyList &propList);
265  void endTextSpan();
266  void insertText(const ::WPXString &str);
267  QString constructFontName(QString fontBaseName, QString fontStyle);
268  double valueAsPoint(const WPXProperty *prop);
269  double fromPercentage(const QString &s );
270  QColor parseColorN( const QString &rgbColor );
271  QString parseColor( const QString &s );
272  void insertImage(PageItem* ite, QString imgExt, QByteArray &imageData);
273  void applyFill(PageItem* ite);
274  void applyShadow(PageItem* ite);
275  void applyFlip(PageItem* ite);
276  void recolorItem(PageItem* ite, QString efVal);
277  void applyArrows(PageItem* ite);
278  void finishItem(PageItem* ite);
279 
280  ScribusDoc* m_Doc;
281  Selection* tmpSel;
282  QList<PageItem*> *Elements;
283  struct groupEntry
284  {
285  QList<PageItem*> Items;
286  FPointArray clip;
287  };
288  QStack<groupEntry> groupStack;
289  QStringList *importedColors;
290  QStringList *importedPatterns;
291  double LineW;
292  QString CurrColorFill;
293  QString CurrColorStroke;
294  double CurrStrokeShade;
295  double CurrFillShade;
296  double CurrStrokeTrans;
297  double CurrFillTrans;
298  FPointArray Coords;
299  bool fillrule;
300  double gradientAngle;
301  bool isGradient;
302  VGradient currentGradient;
303  QString gradColor1Str;
304  QColor gradColor1;
305  double gradColor1Trans;
306  QString gradColor2Str;
307  QColor gradColor2;
308  double gradColor2Trans;
309  QVector<double> dashArray;
310  Qt::PenJoinStyle lineJoin;
311  Qt::PenCapStyle lineEnd;
312  double baseX, baseY;
313  double docWidth;
314  double docHeight;
315  int importerFlags;
316  bool firstPage;
317  QString baseLayer;
318  int actPage;
319  WPXPropertyList m_style;
320  PageItem *actTextItem;
321  ParagraphStyle textStyle;
322  CharStyle textCharStyle;
323  double m_linespace;
324  double m_maxFontSize;
325  bool lineSpSet;
326  bool lineSpIsPT;
327  bool doProcessing;
328  QString fileType;
329 };
330 #endif
331 
332 #endif
Definition: charstyle.h:78
Definition: rawpainter.h:283
Definition: WPGPaintInterface.h:41
Definition: vgradient.h:78
Definition: paragraphstyle.h:27
the Document Class
Definition: scribusdoc.h:90
Definition: rawpainter.h:243
Definition: pageitem.h:92
Definition: fpointarray.h:42
Definition: selection.h:34