Scribus
Open source desktop publishing at your fingertips
pslib.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  pslib.h - description
9  -------------------
10  begin : Sat May 26 2001
11  copyright : (C) 2001 by Franz Schmid
12  email : Franz.Schmid@altmuehlnet.de
13  ***************************************************************************/
14 
15 /***************************************************************************
16  * *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or *
20  * (at your option) any later version. *
21  * *
22  ***************************************************************************/
23 
24 #ifndef PSLIB_H
25 #define PSLIB_H
26 
27 #include <vector>
28 #include <utility>
29 
30 #include <QDataStream>
31 #include <QFile>
32 #include <QList>
33 #include <QPen>
34 #include <QString>
35 
36 #include "scribusapi.h"
37 #include "scribusstructs.h"
38 #include "colormgmt/sccolormgmtengine.h"
39 #include "tableborder.h"
40 
41 
42 class ScPage;
43 class ScribusDoc;
44 class PageItem;
45 class MultiProgressDialog;
46 class ScImage;
47 class ScLayer;
48 
54 class SCRIBUS_API PSLib : public QObject
55 {
56  Q_OBJECT
57  public:
58 
59  typedef enum
60  {
61  OptimizeCompat = 0,
62  OptimizeSize = 1
63  } Optimization;
64 
65  PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf = false, bool spot = true);
66  virtual ~PSLib() {};
67 
68  void setOptimization (Optimization opt) { optimization = opt; }
69 
70  virtual int CreatePS(ScribusDoc* Doc, PrintOptions &options);
71  virtual const QString& errorMessage(void);
72 
73  virtual void PS_Error(const QString& message);
74  virtual void PS_Error_ImageDataWriteFailure(void);
75  virtual void PS_Error_ImageLoadFailure(const QString& fileName);
76  virtual void PS_Error_MaskLoadFailure(const QString& fileName);
77  virtual void PS_Error_InsufficientMemory(void);
78 
79  virtual bool PS_set_file(QString fn);
80  virtual void PS_set_Info(QString art, QString was);
81  virtual bool PS_begin_doc(ScribusDoc *doc, double x, double y, double width, double height, int numpage, bool doDev, bool sep, bool farb);
82  virtual void PS_begin_page(ScPage* pg, MarginStruct* Ma, bool Clipping);
83  virtual void PS_end_page();
84  virtual void PS_curve(double x1, double y1, double x2, double y2, double x3, double y3);
85  virtual void PS_moveto(double x, double y);
86  virtual void PS_lineto(double x, double y);
87  virtual void PS_closepath();
88  virtual void PS_translate(double x, double y);
89  virtual void PS_scale(double x, double y);
90  virtual void PS_rotate(double x);
91  virtual void PS_clip(bool mu);
92  virtual void PS_save();
93  virtual void PS_restore();
94  virtual void PS_setcmykcolor_fill(double c, double m, double y, double k);
95  virtual void PS_setcmykcolor_dummy();
96  virtual void PS_setcmykcolor_stroke(double c, double m, double y, double k);
97  virtual void PS_setlinewidth(double w);
98  virtual void PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle jo);
99  virtual void PS_setdash(Qt::PenStyle st, double offset, QVector<double> dash);
100  virtual void PS_selectfont(QString f, double s);
101  virtual void PS_fill();
102  virtual void PS_fillspot(QString color, double shade);
103  virtual void PS_stroke();
104  virtual void PS_strokespot(QString color, double shade);
105  virtual void PS_fill_stroke();
106  virtual void PS_newpath();
107  virtual void PS_show(double x, double y);
108  virtual void PS_showSub(uint chr, QString font, double size, bool stroke);
109  virtual void PS_show_xyG(QString font, uint gl, double x, double y, QString colorName, double shade);
110  virtual bool PS_image(PageItem *c, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, QString Name = "");
111  virtual bool PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded);
112  virtual void PS_plate(int nr, QString name = "");
113  virtual void PS_setGray();
114  virtual void PDF_Bookmark(QString text, uint Seite);
115  virtual void PDF_Annotation(PageItem *item, QString text, double x, double y, double b, double h);
116  virtual void PS_close();
117  virtual void PS_insert(QString i);
118  virtual void PS_TemplateStart(QString Name);
119  virtual void PS_TemplateEnd();
120  virtual void PS_UseTemplate(QString Name);
121  virtual bool ProcessItem(ScribusDoc* Doc, ScPage* a, PageItem* c, uint PNr, bool sep, bool farb, bool master, bool embedded = false, bool useTemplate = false);
122  virtual void ProcessPage(ScribusDoc* Doc, ScPage* a, uint PNr, bool sep = false, bool farb = true);
123  virtual bool ProcessMasterPageLayer(ScribusDoc* Doc, ScPage* a, ScLayer& ll, uint PNr, bool sep = false, bool farb = true);
124  virtual bool ProcessPageLayer(ScribusDoc* Doc, ScPage* a, ScLayer& ll, uint PNr, bool sep = false, bool farb = true);
125  virtual void PS_HatchFill(PageItem *currItem);
126  virtual void drawArrow(PageItem *ite, QTransform &arrowTrans, int arrowIndex);
127  virtual void putColor(const QString& color, double shade, bool fill);
128  virtual void putColorNoDraw(const QString& color, double shade);
129  virtual void GetBleeds(ScPage* page, double& left, double& right);
130  virtual void GetBleeds(ScPage* page, double& left, double& right, double& bottom, double& top);
131  virtual void SetClipPath(FPointArray *c, bool poly = true);
132  virtual void SetPathAndClip(FPointArray &c, bool clipRule);
133  virtual void HandleBrushPattern(PageItem *c, QPainterPath &path, ScPage* a, uint PNr, bool sep, bool farb, bool master);
134  virtual void HandleStrokePattern(PageItem *c);
135  virtual void HandleMeshGradient(PageItem* c);
136  virtual void HandlePatchMeshGradient(PageItem* c);
137  virtual void HandleDiamondGradient(PageItem* c);
138  virtual void HandleTensorGradient(PageItem* c);
139  virtual void HandleGradientFillStroke(PageItem *c, bool stroke = true, bool forArrow = false);
140  virtual void SetColor(const QString& color, double shade, int *h, int *s, int *v, int *k);
141  virtual void SetColor(const ScColor& color, double shade, int *h, int *s, int *v, int *k);
142  virtual void setTextSt(ScribusDoc* Doc, PageItem* ite, uint a, ScPage* pg, bool sep, bool farb, bool master);
143  virtual void setTextCh(ScribusDoc* Doc, PageItem* ite, double x, double y, uint a, uint d, QChar chstr, const GlyphLayout* glyphs, const CharStyle& cstyle, const ParagraphStyle& pstyle, ScPage* pg, bool sep, bool farb, bool master);
144  bool psExport;
145 
146  private:
147 
148  void PutStream (const QString& c);
149  void PutStream (const QByteArray& array, bool hexEnc);
150  void PutStream (const char* in, int length, bool hexEnc);
151 
152  bool PutImageToStream(ScImage& image, int plate);
153  bool PutImageToStream(ScImage& image, const QByteArray& mask, int plate);
154 
155  bool PutImageDataToStream(const QByteArray& image);
156  bool PutInterleavedImageMaskToStream(const QByteArray& image, const QByteArray& mask, bool gray);
157 
158  void WriteASCII85Bytes(const QByteArray& array);
159  void WriteASCII85Bytes(const unsigned char* array, int length);
160 
161  void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors);
162 
163  Optimization optimization;
164 
165  QString ToStr(double c);
166  QString IToStr(int c);
167  QString MatrixToStr(double m11, double m12, double m21, double m22, double x, double y);
168  QString PSEncode(QString in);
169  QString ErrorMessage;
170  QString Prolog;
171  QString Header;
172  QString Creator;
173  QString User;
174  QString Titel;
175  QString BBox;
176  QString BBoxH;
177  QString Farben;
178  QString FNamen;
179  QString PDev;
180  QString GrayCalc;
181  bool GraySc;
182  int Seiten;
183  QString FillColor;
184  QString StrokeColor;
185  double LineW;
186  QString Fonts;
187  QString FontDesc;
188  QMap<QString, QString> UsedFonts;
189  QMap<QString, QString> FontSubsetMap;
190  QMap<QString, ScFace::FaceEncoding> GlyphsOfFont;
191  bool isPDF;
192  QFile Spool;
193  QDataStream spoolStream;
194  int Plate;
195  bool DoSep;
196  bool useSpotColors;
197  bool fillRule;
198  ScColorTransform solidTransform;
199  QString currentSpot;
200  ColorList colorsToUse;
201  QString colorDesc;
202  ScribusDoc *m_Doc;
203  QMap<QString, QString> spotMap;
204  MultiProgressDialog* progressDialog;
205  bool usingGUI;
206  bool abortExport;
207  PrintOptions Options;
208  ScPage* ActPage;
209 
210  protected slots:
211  void cancelRequested();
212 };
213 
214 #endif
Definition: sccolor.h:51
Definition: charstyle.h:78
Definition: pslib.h:54
Pagemargins and bleeds.
Definition: margins.h:25
Definition: scpage.h:46
Definition: sccolortransform.h:16
Definition: tableborder.h:86
Definition: scimage.h:36
Definition: paragraphstyle.h:27
Definition: sccolor.h:155
the Document Class
Definition: scribusdoc.h:90
Definition: scribusstructs.h:213
Definition: sclayer.h:17
Definition: pageitem.h:92
Definition: fpointarray.h:42
Definition: sctextstruct.h:54
Main class SCFonts. Subclass of QDict. This class replaces the previous SCFonts typedef...
Definition: scfonts.h:36