Rev 21743 | Rev 22435 | 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 | |
13765 | jghali | 18 | class QImage; |
19 | class QRect; |
||
3133 | fschmid | 20 | class QString; |
13765 | jghali | 21 | class QTextCodec; |
3133 | fschmid | 22 | class PageItem; |
23 | class BookMItem; |
||
24 | class BookMView; |
||
25 | class ScribusDoc; |
||
26 | class Page; |
||
27 | class PDFOptions; |
||
3252 | craig | 28 | class PrefsContext; |
4028 | cbradney | 29 | class MultiProgressDialog; |
5291 | avox | 30 | class ScText; |
3699 | cbradney | 31 | |
19035 | jghali | 32 | #include "pdfoptions.h" |
3133 | fschmid | 33 | #include "scribusstructs.h" |
12892 | fschmid | 34 | #include "scimagestructs.h" |
3133 | fschmid | 35 | |
12080 | avox | 36 | #ifdef HAVE_PODOFO |
37 | #include <podofo/podofo.h> |
||
38 | #endif |
||
39 | |||
40 | |||
3133 | fschmid | 41 | /** |
10054 | craig | 42 | * PDFLibCore provides Scribus's implementation of PDF export functionality. |
43 | * |
||
44 | * This is not public API and is not exported in Scribus's symbol table on supporting |
||
45 | * platforms. Do not include this header, use pdflib.h instead. Including this header |
||
46 | * from anywhere except pdflib.cpp may cause linker errors and other problems, |
||
47 | * and is totally pointless since all the interfaces that are publically |
||
48 | * visible are presented by PDFlib anyway. |
||
49 | * |
||
50 | *@author Franz Schmid |
||
51 | */ |
||
3133 | fschmid | 52 | |
10054 | craig | 53 | class PDFLibCore : public QObject |
3133 | fschmid | 54 | { |
55 | Q_OBJECT |
||
56 | |||
57 | public: |
||
10054 | craig | 58 | explicit PDFLibCore(ScribusDoc & docu); |
59 | ~PDFLibCore(); |
||
4264 | craig | 60 | bool doExport(const QString& fn, const QString& nam, int Components, |
61 | const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs); |
||
4223 | craig | 62 | |
11060 | jghali | 63 | const QString& errorMessage(void) const; |
11441 | jghali | 64 | bool exportAborted(void) const; |
11060 | jghali | 65 | |
4223 | craig | 66 | private: |
12080 | avox | 67 | struct ShIm |
68 | { |
||
69 | int ResNum; |
||
70 | int Width; |
||
71 | int Height; |
||
13948 | fschmid | 72 | int Page; |
12080 | avox | 73 | double reso; |
74 | double sxa; |
||
75 | double sya; |
||
76 | double xa; |
||
77 | double ya; |
||
12845 | fschmid | 78 | double origXsc; |
79 | double origYsc; |
||
12892 | fschmid | 80 | QMap<int, ImageLoadRequest> RequestProps; |
12080 | avox | 81 | }; |
19033 | jghali | 82 | |
83 | bool PDF_IsPDFX(); |
||
84 | bool PDF_IsPDFX(PDFOptions::PDFVersion ver); |
||
12080 | avox | 85 | |
5387 | avox | 86 | bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi); |
4241 | craig | 87 | void PDF_Begin_Page(const Page* pag, QPixmap pm = 0); |
15445 | craig | 88 | void PDF_End_Page(int physPage); |
11060 | jghali | 89 | bool PDF_TemplatePage(const Page* pag, bool clip = false); |
90 | bool PDF_ProcessPage(const Page* pag, uint PNr, bool clip = false); |
||
12387 | jghali | 91 | bool PDF_End_Doc(const QString& PrintPr = "", const QString& Name = "", int Components = 0); |
92 | bool closeAndCleanup(); |
||
3133 | fschmid | 93 | |
11060 | jghali | 94 | void PDF_Error(const QString& errorMsg); |
12387 | jghali | 95 | void PDF_Error_WriteFailure(void); |
11060 | jghali | 96 | void PDF_Error_ImageLoadFailure(const QString& fileName); |
11599 | jghali | 97 | void PDF_Error_ImageWriteFailure(const QString& fileName); |
11389 | jghali | 98 | void PDF_Error_MaskLoadFailure(const QString& fileName); |
11060 | jghali | 99 | void PDF_Error_InsufficientMemory(void); |
100 | |||
21743 | jghali | 101 | int fromPDFDocEncoding(int code); |
102 | |||
7328 | fschmid | 103 | QByteArray EncodeUTF16(const QString &in); |
11060 | jghali | 104 | QString EncStream(const QString & in, int ObjNum); |
105 | QString EncString(const QString & in, int ObjNum); |
||
106 | QString EncStringUTF16(const QString & in, int ObjNum); |
||
107 | |||
11445 | jghali | 108 | bool EncodeArrayToStream(const QByteArray& in, int ObjNum); |
109 | |||
12732 | fschmid | 110 | int WriteImageToStream(ScImage& image, int ObjNum, bool cmyk, bool gray, bool precal); |
111 | int WriteJPEGImageToStream(ScImage& image, const QString& fn, int ObjNum, bool cmyk, bool gray, bool sameFile, bool precal); |
||
112 | int WriteFlateImageToStream(ScImage& image, int ObjNum, bool cmyk, bool gray, bool precal); |
||
11599 | jghali | 113 | |
11060 | jghali | 114 | void CalcOwnerKey(const QString & Owner, const QString & User); |
115 | void CalcUserKey(const QString & User, int Permission); |
||
4229 | craig | 116 | QString FitKey(const QString & pass); |
11060 | jghali | 117 | |
8559 | subik | 118 | QString setStrokeMulti(struct SingleLine *sl); |
3133 | fschmid | 119 | QString SetClipPathArray(FPointArray *ite, bool poly = true); |
120 | QString SetClipPathImage(PageItem *ite); |
||
121 | QString SetClipPath(PageItem *ite, bool poly = true); |
||
11333 | jghali | 122 | QString SetColor(const QString& farbe, double Shade); |
123 | QString SetColor(const ScColor& farbe, double Shade); |
||
124 | QString SetGradientColor(const QString& farbe, double Shade); |
||
9920 | fschmid | 125 | QString putColor(const QString& color, double Shade, bool fill); |
4229 | craig | 126 | QString putColorUncached(const QString& color, int Shade, bool fill); |
6562 | fschmid | 127 | QString Write_TransparencyGroup(double trans, int blend, QString &data); |
4241 | craig | 128 | QString setTextSt(PageItem *ite, uint PNr, const Page* pag); |
11060 | jghali | 129 | 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); |
13815 | jghali | 130 | void getBleeds(const Page* page, double &left, double &right); |
131 | void getBleeds(const Page* page, double &left, double &right, double &bottom, double& top); |
||
4229 | craig | 132 | |
133 | // Provide a couple of PutDoc implementations to ease transition away from |
||
134 | // QString abuse and to provide fast paths for constant strings. |
||
10397 | cbradney | 135 | void PutDoc(const QString & in) { outStream.writeRawData(in.toLatin1(), in.length()); } |
8559 | subik | 136 | void PutDoc(const QByteArray & in) { outStream.writeRawData(in, in.size()); } |
137 | void PutDoc(const char* in) { outStream.writeRawData(in, strlen(in)); } |
||
138 | void PutDoc(const std::string & in) { outStream.writeRawData(in.c_str(), in.length()); } |
||
4229 | craig | 139 | |
11060 | jghali | 140 | void PutPage(const QString & in) { Content += in; } |
141 | void StartObj(int nr); |
||
12080 | avox | 142 | uint newObject() { return ObjCounter++; } |
143 | uint WritePDFStream(const QString& cc); |
||
22388 | jghali | 144 | uint WritePDFStream(const QString& cc, uint objNum); |
12080 | avox | 145 | uint WritePDFString(const QString& cc); |
22388 | jghali | 146 | uint WritePDFString(const QString& cc, uint objNum); |
12080 | avox | 147 | void writeXObject(uint objNr, QString dictionary, QByteArray stream); |
148 | uint writeObject(QString type, QString dictionary); |
||
149 | uint writeGState(QString dictionary) { return writeObject("/ExtGState", dictionary); } |
||
12429 | fschmid | 150 | uint writeActions(const Annotation&, uint annotationObj); |
12080 | avox | 151 | // QString PDFEncode(const QString & in); |
3829 | cbradney | 152 | QByteArray ComputeMD5(const QString& in); |
11599 | jghali | 153 | QByteArray ComputeRC4Key(int ObjNum); |
20009 | jghali | 154 | |
155 | bool PDF_ItemIsOnPage(PageItem* item, const Page* page, const QList<PageItem*>& itemList); |
||
156 | |||
11060 | jghali | 157 | bool PDF_ProcessItem(QString& output, PageItem* ite, const Page* pag, uint PNr, bool embedded = false, bool pattern = false); |
158 | QString PDF_ProcessTableItem(PageItem* ite, const Page* pag); |
||
13302 | fschmid | 159 | QString drawArrow(PageItem *ite, QMatrix &arrowTrans, int arrowIndex); |
11060 | jghali | 160 | void PDF_Bookmark(PageItem *currItem, double ypos); |
161 | bool PDF_Gradient(QString& output, PageItem *currItem); |
||
9803 | fschmid | 162 | QString PDF_DoLinGradient(PageItem *currItem, QList<double> Stops, QList<double> Trans, const QStringList& Colors, QStringList colorNames, QList<int> colorShades); |
5748 | fschmid | 163 | QString PDF_TransparenzFill(PageItem *currItem); |
164 | QString PDF_TransparenzStroke(PageItem *currItem); |
||
11060 | jghali | 165 | bool PDF_Annotation(PageItem *ite, uint PNr); |
166 | void PDF_Form(const QString& im); |
||
12080 | avox | 167 | void PDF_xForm(uint objNr, double w, double h, QString im); |
15706 | jghali | 168 | 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, eRenderIntent Intent = Intent_Relative_Colorimetric, QString* output = NULL); |
12080 | avox | 169 | bool PDF_EmbeddedPDF(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, int Intent, ShIm& imgInfo, QString* output = NULL); |
170 | #if HAVE_PODOFO |
||
171 | void copyPoDoFoObject(const PoDoFo::PdfObject* obj, uint scObjID, QMap<PoDoFo::PdfReference, uint>& importedObjects); |
||
172 | void copyPoDoFoDirect(const PoDoFo::PdfVariant* obj, QList<PoDoFo::PdfReference>& referencedObjects, QMap<PoDoFo::PdfReference, uint>& importedObjects); |
||
173 | #endif |
||
174 | |||
10427 | cbradney | 175 | int bytesWritten() { return Spool.pos(); } |
4229 | craig | 176 | |
11060 | jghali | 177 | |
178 | QString Content; |
||
179 | QString ErrorMessage; |
||
4264 | craig | 180 | ScribusDoc & doc; |
181 | const Page * ActPageP; |
||
182 | const PDFOptions & Options; |
||
3133 | fschmid | 183 | BookMView* Bvie; |
184 | QFile Spool; |
||
185 | int Dokument; |
||
186 | struct Dest |
||
187 | { |
||
188 | QString Name; |
||
189 | int Seite; |
||
190 | QString Act; |
||
191 | }; |
||
192 | struct Cata |
||
193 | { |
||
194 | int Outlines; |
||
195 | int PageTree; |
||
196 | int Dest; |
||
197 | } |
||
198 | Catalog; |
||
199 | struct PagT |
||
200 | { |
||
13750 | jghali | 201 | QMap<int, int> Kids; |
3133 | fschmid | 202 | int Count; |
203 | } |
||
204 | PageTree; |
||
205 | struct PagL |
||
206 | { |
||
207 | int ObjNum; |
||
208 | int Thumb; |
||
209 | QMap<QString,int> XObjects; |
||
210 | QMap<QString,int> ImgObjects; |
||
211 | QMap<QString,int> FObjects; |
||
9803 | fschmid | 212 | QList<int> AObjects; |
213 | QList<int> FormObjects; |
||
3133 | fschmid | 214 | } |
215 | Seite; |
||
216 | struct OutL |
||
217 | { |
||
218 | int First; |
||
219 | int Last; |
||
220 | int Count; |
||
221 | } |
||
222 | Outlines; |
||
223 | struct Bead |
||
224 | { |
||
225 | int Parent; |
||
226 | int Next; |
||
227 | int Prev; |
||
228 | int Page; |
||
229 | QRect Recht; |
||
230 | }; |
||
231 | struct ICCD |
||
232 | { |
||
233 | int ResNum; |
||
12732 | fschmid | 234 | int components; |
3133 | fschmid | 235 | QString ResName; |
236 | QString ICCArray; |
||
237 | }; |
||
238 | struct OCGInfo |
||
239 | { |
||
240 | int ObjNum; |
||
241 | bool visible; |
||
242 | QString Name; |
||
243 | }; |
||
244 | struct SpotC |
||
245 | { |
||
246 | int ResNum; |
||
247 | QString ResName; |
||
248 | }; |
||
6562 | fschmid | 249 | struct gData |
250 | { |
||
251 | int ResNumG; |
||
252 | int ResNumX; |
||
253 | QString ResNamG; |
||
254 | QString ResNamX; |
||
255 | QString data; |
||
256 | }; |
||
3133 | fschmid | 257 | QMap<QString,ShIm> SharedImages; |
9803 | fschmid | 258 | QList<uint> XRef; |
259 | QList<Dest> NamedDest; |
||
260 | QList<int> Threads; |
||
261 | QList<Bead> Beads; |
||
262 | QList<int> CalcFields; |
||
6378 | fschmid | 263 | QMap<QString,int> Patterns; |
3133 | fschmid | 264 | QMap<QString,int> Shadings; |
265 | QMap<QString,int> Transpar; |
||
266 | QMap<QString,ICCD> ICCProfiles; |
||
11908 | fschmid | 267 | QHash<QString, OCGInfo> OCGEntries; |
13765 | jghali | 268 | QTextCodec* ucs2Codec; |
3133 | fschmid | 269 | int ObjCounter; |
270 | QString ResNam; |
||
271 | int ResCount; |
||
272 | QString NDnam; |
||
273 | QString Datum; |
||
274 | int NDnum; |
||
275 | QMap<QString, QString> UsedFontsP; |
||
8454 | fschmid | 276 | QMap<QString, QString> UsedFontsF; |
3133 | fschmid | 277 | QByteArray KeyGen; |
278 | QByteArray OwnerKey; |
||
279 | QByteArray UserKey; |
||
280 | QByteArray FileID; |
||
281 | QByteArray EncryKey; |
||
282 | int Encrypt; |
||
283 | int KeyLen; |
||
284 | QString HTName; |
||
285 | bool BookMinUse; |
||
286 | ColorList colorsToUse; |
||
287 | QMap<QString, SpotC> spotMap; |
||
6925 | fschmid | 288 | QMap<QString, SpotC> spotMapReg; |
3133 | fschmid | 289 | QString spotNam; |
290 | int spotCount; |
||
6407 | fschmid | 291 | int inPattern; |
8559 | subik | 292 | QDataStream outStream; |
4017 | fschmid | 293 | QMap<QString, QString> StdFonts; |
4028 | cbradney | 294 | MultiProgressDialog* progressDialog; |
4223 | craig | 295 | bool abortExport; |
4028 | cbradney | 296 | bool usingGUI; |
8171 | fschmid | 297 | double bleedDisplacementX; |
298 | double bleedDisplacementY; |
||
8469 | fschmid | 299 | QMap<QString, QMap<uint, uint> > Type3Fonts; |
4028 | cbradney | 300 | |
301 | protected slots: |
||
302 | void cancelRequested(); |
||
3133 | fschmid | 303 | }; |
304 | |||
305 | #endif |
||
306 | |||
13815 | jghali | 307 |