Subversion Repositories Scribus

Rev

Rev 11313 | Rev 11333 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 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
*/
3133 fschmid 7
 
10054 craig 8
#ifndef PDFLIBCORE_H
9
#define PDFLIBCORE_H
3133 fschmid 10
 
10223 cbradney 11
#include <QFile>
8559 subik 12
#include <QDataStream>
8501 cbradney 13
#include <QPixmap>
9803 fschmid 14
#include <QList>
4265 craig 15
#include <string>
3699 cbradney 16
#include <vector>
3133 fschmid 17
 
18
class QString;
19
class QRect;
20
class QImage;
21
class PageItem;
22
class BookMItem;
23
class BookMView;
24
class ScribusDoc;
25
class Page;
26
class PDFOptions;
3252 craig 27
class PrefsContext;
4028 cbradney 28
class MultiProgressDialog;
5291 avox 29
class ScText;
3699 cbradney 30
 
3133 fschmid 31
#include "scribusstructs.h"
32
 
33
/**
10054 craig 34
 * PDFLibCore provides Scribus's implementation of PDF export functionality.
35
 *
36
 * This is not public API and is not exported in Scribus's symbol table on supporting
37
 * platforms. Do not include this header, use pdflib.h instead. Including this header
38
 * from anywhere except pdflib.cpp may cause linker errors and other problems,
39
 * and is totally pointless since all the interfaces that are publically
40
 * visible are presented by PDFlib anyway.
41
 *
42
 *@author Franz Schmid
43
 */
3133 fschmid 44
 
10054 craig 45
class PDFLibCore : public QObject
3133 fschmid 46
{
47
        Q_OBJECT
48
 
49
public:
10054 craig 50
        explicit PDFLibCore(ScribusDoc & docu);
51
        ~PDFLibCore();
4264 craig 52
        bool doExport(const QString& fn, const QString& nam, int Components,
53
                                  const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs);
4223 craig 54
 
11060 jghali 55
        const QString& errorMessage(void) const;
56
 
4223 craig 57
private:
58
 
5387 avox 59
        bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi);
4241 craig 60
        void PDF_Begin_Page(const Page* pag, QPixmap pm = 0);
3133 fschmid 61
        void PDF_End_Page();
11060 jghali 62
        bool PDF_TemplatePage(const Page* pag, bool clip = false);
63
        bool PDF_ProcessPage(const Page* pag, uint PNr, bool clip = false);
3829 cbradney 64
        void PDF_End_Doc(const QString& PrintPr = "", const QString& Name = "", int Components = 0);
4028 cbradney 65
        void closeAndCleanup();
3133 fschmid 66
 
11060 jghali 67
        void PDF_Error(const QString& errorMsg);
68
        void PDF_Error_ImageLoadFailure(const QString& fileName);
69
        void PDF_Error_InsufficientMemory(void);
70
 
7328 fschmid 71
        QByteArray EncodeUTF16(const QString &in);
11060 jghali 72
        QString    EncStream(const QString & in, int ObjNum);
5234 fschmid 73
        QByteArray EncStreamArray(const QByteArray & in, int ObjNum);
11060 jghali 74
        QString    EncString(const QString & in, int ObjNum);
75
        QString    EncStringUTF16(const QString & in, int ObjNum);
76
 
77
        void    CalcOwnerKey(const QString & Owner, const QString & User);
78
        void    CalcUserKey(const QString & User, int Permission);
4229 craig 79
        QString FitKey(const QString & pass);
11060 jghali 80
 
8559 subik 81
        QString setStrokeMulti(struct SingleLine *sl);
3133 fschmid 82
        QString SetClipPathArray(FPointArray *ite, bool poly = true);
83
        QString SetClipPathImage(PageItem *ite);
84
        QString SetClipPath(PageItem *ite, bool poly = true);
9920 fschmid 85
        QString SetFarbeGrad(const QString& farbe, double Shade);
86
        QString SetFarbe(const QString& farbe, double Shade);
87
        QString SetFarbe(const ScColor& farbe, double Shade);
88
        QString putColor(const QString& color, double Shade, bool fill);
4229 craig 89
        QString putColorUncached(const QString& color, int Shade, bool fill);
6562 fschmid 90
        QString Write_TransparencyGroup(double trans, int blend, QString &data);
4241 craig 91
        QString setTextSt(PageItem *ite, uint PNr, const Page* pag);
11060 jghali 92
        bool    setTextCh(PageItem *ite, uint PNr, double x, double y, uint d,  QString &tmp, QString &tmp2, const ScText * hl, const ParagraphStyle& pstyle, const Page* pag);
4229 craig 93
 
94
        // Provide a couple of PutDoc implementations to ease transition away from
95
        // QString abuse and to provide fast paths for constant strings.
10397 cbradney 96
        void PutDoc(const QString & in) { outStream.writeRawData(in.toLatin1(), in.length()); }
8559 subik 97
        void PutDoc(const QByteArray & in) { outStream.writeRawData(in, in.size()); }
98
        void PutDoc(const char* in) { outStream.writeRawData(in, strlen(in)); }
99
        void PutDoc(const std::string & in) { outStream.writeRawData(in.c_str(), in.length()); }
4229 craig 100
 
11060 jghali 101
        void       PutPage(const QString & in) { Content += in; }
102
        void       StartObj(int nr);
103
        void       WritePDFStream(const QString& cc);
11313 jghali 104
        void       WritePDFString(const QString& cc);
11060 jghali 105
        QString    PDFEncode(const QString & in);
3829 cbradney 106
        QByteArray ComputeMD5(const QString& in);
11060 jghali 107
 
108
        bool    PDF_ProcessItem(QString& output, PageItem* ite, const Page* pag, uint PNr, bool embedded = false, bool pattern = false);
109
        QString PDF_ProcessTableItem(PageItem* ite, const Page* pag);
110
        void    PDF_Bookmark(PageItem *currItem, double ypos);
111
        bool    PDF_Gradient(QString& output, PageItem *currItem);
9803 fschmid 112
        QString PDF_DoLinGradient(PageItem *currItem, QList<double> Stops, QList<double> Trans, const QStringList& Colors, QStringList colorNames, QList<int> colorShades);
5748 fschmid 113
        QString PDF_TransparenzFill(PageItem *currItem);
114
        QString PDF_TransparenzStroke(PageItem *currItem);
11060 jghali 115
        bool    PDF_Annotation(PageItem *ite, uint PNr);
116
        void    PDF_Form(const QString& im);
117
        void    PDF_xForm(double w, double h, QString im);
118
        bool    PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, int Intent = 1, QString* output = NULL);
4223 craig 119
 
10427 cbradney 120
        int bytesWritten() { return Spool.pos(); }
4229 craig 121
 
11060 jghali 122
 
123
        QString Content;
124
        QString ErrorMessage;
4264 craig 125
        ScribusDoc & doc;
126
        const Page * ActPageP;
127
        const PDFOptions & Options;
3133 fschmid 128
        BookMView* Bvie;
129
        QFile Spool;
130
        int Dokument;
131
        struct Dest
132
        {
133
                QString Name;
134
                int Seite;
135
                QString Act;
136
        };
137
        struct Cata
138
        {
139
                int Outlines;
140
                int PageTree;
141
                int Dest;
142
        }
143
        Catalog;
144
        struct PagT
145
        {
9803 fschmid 146
                QList<int> Kids;
3133 fschmid 147
                int Count;
148
        }
149
        PageTree;
150
        struct PagL
151
        {
152
                int ObjNum;
153
                int Thumb;
154
                QMap<QString,int> XObjects;
155
                QMap<QString,int> ImgObjects;
156
                QMap<QString,int> FObjects;
9803 fschmid 157
                QList<int> AObjects;
158
                QList<int> FormObjects;
3133 fschmid 159
        }
160
        Seite;
161
        struct OutL
162
        {
163
                int First;
164
                int Last;
165
                int Count;
166
        }
167
        Outlines;
168
        struct Bead
169
        {
170
                int Parent;
171
                int Next;
172
                int Prev;
173
                int Page;
174
                QRect Recht;
175
        };
176
        struct ICCD
177
        {
178
                int ResNum;
179
                QString ResName;
180
                QString ICCArray;
181
        };
182
        struct ShIm
183
        {
184
                int ResNum;
185
                int Width;
186
                int Height;
187
                double aufl;
188
                double sxa;
189
                double sya;
190
                double xa;
191
                double ya;
192
        };
193
        struct OCGInfo
194
        {
195
                int ObjNum;
196
                bool visible;
197
                QString Name;
198
        };
199
        struct SpotC
200
        {
201
                int ResNum;
202
                QString ResName;
203
        };
6562 fschmid 204
        struct gData
205
        {
206
                int ResNumG;
207
                int ResNumX;
208
                QString ResNamG;
209
                QString ResNamX;
210
                QString data;
211
        };
3133 fschmid 212
        QMap<QString,ShIm> SharedImages;
9803 fschmid 213
        QList<uint> XRef;
214
        QList<Dest> NamedDest;
215
        QList<int> Threads;
216
        QList<Bead> Beads;
217
        QList<int> CalcFields;
6378 fschmid 218
        QMap<QString,int> Patterns;
3133 fschmid 219
        QMap<QString,int> Shadings;
220
        QMap<QString,int> Transpar;
221
        QMap<QString,ICCD> ICCProfiles;
222
        QMap<QString, OCGInfo> OCGEntries;
223
        int ObjCounter;
224
        QString ResNam;
225
        int ResCount;
226
        QString NDnam;
227
        QString Datum;
228
        int NDnum;
229
        QMap<QString, QString> UsedFontsP;
8454 fschmid 230
        QMap<QString, QString> UsedFontsF;
3133 fschmid 231
        QByteArray KeyGen;
232
        QByteArray OwnerKey;
233
        QByteArray UserKey;
234
        QByteArray FileID;
235
        QByteArray EncryKey;
236
        int Encrypt;
237
        int KeyLen;
238
        QString HTName;
239
        bool BookMinUse;
240
        ColorList colorsToUse;
241
        QMap<QString, SpotC> spotMap;
6925 fschmid 242
        QMap<QString, SpotC> spotMapReg;
3133 fschmid 243
        QString spotNam;
244
        int spotCount;
6407 fschmid 245
        int inPattern;
8559 subik 246
        QDataStream outStream;
4017 fschmid 247
        QMap<QString, QString> StdFonts;
4028 cbradney 248
        MultiProgressDialog* progressDialog;
4223 craig 249
        bool abortExport;
4028 cbradney 250
        bool usingGUI;
8171 fschmid 251
        double bleedDisplacementX;
252
        double bleedDisplacementY;
8469 fschmid 253
        QMap<QString, QMap<uint, uint> > Type3Fonts;
4028 cbradney 254
 
255
protected slots:
256
        void cancelRequested();
3133 fschmid 257
};
258
 
259
#endif
260