Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pdflib.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           pdflib.h  -  description
00009                              -------------------
00010     begin                : Sat Jan 19 2002
00011     copyright            : (C) 2002 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #ifndef PDFLIB_H
00025 #define PDFLIB_H
00026 
00027 #include <qvaluelist.h>
00028 #include <qfile.h>
00029 #include <string>
00030 #include <vector>
00031 
00032 class QString;
00033 class QRect;
00034 class QImage;
00035 class PageItem;
00036 class BookMItem;
00037 class BookMView;
00038 class ScribusDoc;
00039 class Page;
00040 class PDFOptions;
00041 class PrefsContext;
00042 class MultiProgressDialog;
00043 class ScText;
00044 
00045 #include "scribusstructs.h"
00046 
00051 class SCRIBUS_API PDFlib : public QObject
00052 {
00053        Q_OBJECT
00054 
00055 public:
00056        explicit PDFlib(ScribusDoc & docu);
00057        ~PDFlib();
00058        bool doExport(const QString& fn, const QString& nam, int Components,
00059                               const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs);
00060 
00061 private:
00062 
00063        bool PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi);
00064        void PDF_Begin_Page(const Page* pag, QPixmap pm = 0);
00065        void PDF_End_Page();
00066        void PDF_TemplatePage(const Page* pag, bool clip = false);
00067        void PDF_ProcessPage(const Page* pag, uint PNr, bool clip = false);
00068        void PDF_End_Doc(const QString& PrintPr = "", const QString& Name = "", int Components = 0);
00069        void closeAndCleanup();
00070 
00071        QByteArray EncodeUTF16(const QString &in);
00072        QString EncStream(const QString & in, int ObjNum);
00073        QByteArray EncStreamArray(const QByteArray & in, int ObjNum);
00074        QString EncString(const QString & in, int ObjNum);
00075        QString EncStringUTF16(const QString & in, int ObjNum);
00076        void CalcOwnerKey(const QString & Owner, const QString & User);
00077        void CalcUserKey(const QString & User, int Permission);
00078        QString FitKey(const QString & pass);
00079        QString setStrokeMulti(struct SingleLine *sl);
00080        QString SetClipPathArray(FPointArray *ite, bool poly = true);
00081        QString SetClipPathImage(PageItem *ite);
00082        QString SetClipPath(PageItem *ite, bool poly = true);
00083        QString SetFarbeGrad(const QString& farbe, int Shade);
00084        QString SetFarbe(const QString& farbe, int Shade);
00085        QString SetFarbe(const ScColor& farbe, int Shade);
00086        QString putColor(const QString& color, int Shade, bool fill);
00087        QString putColorUncached(const QString& color, int Shade, bool fill);
00088        QString PDF_ProcessTableItem(PageItem* ite, const Page* pag);
00089        QString PDF_ProcessItem(PageItem* ite, const Page* pag, uint PNr, bool embedded = false, bool pattern = false);
00090        QString Write_TransparencyGroup(double trans, int blend, QString &data);
00091        QString setTextSt(PageItem *ite, uint PNr, const Page* pag);
00092        void setTextCh(PageItem *ite, uint PNr, double x, double y, uint d,  QString &tmp, QString &tmp2, const ScText * hl, const ParagraphStyle& pstyle, const Page* pag);
00093 
00094        // Provide a couple of PutDoc implementations to ease transition away from
00095        // QString abuse and to provide fast paths for constant strings.
00096        void PutDoc(const QString & in) { outStream.writeRawBytes(in.latin1(), in.length()); }
00097        void PutDoc(const QByteArray & in) { outStream.writeRawBytes(in, in.size()); }
00098        void PutDoc(const char* in) { outStream.writeRawBytes(in, strlen(in)); }
00099        void PutDoc(const std::string & in) { outStream.writeRawBytes(in.c_str(), in.length()); }
00100 
00101        void PutPage(const QString & in) { Inhalt += in; }
00102        void StartObj(int nr);
00103        void WritePDFStream(const QString& cc);
00104        QString PDFEncode(const QString & in);
00105        QByteArray ComputeMD5(const QString& in);
00106        void PDF_Bookmark(PageItem *currItem, double ypos);
00107        QString PDF_Gradient(PageItem *currItem);
00108        QString PDF_DoLinGradient(PageItem *currItem, QValueList<double> Stops, QValueList<double> Trans, const QStringList& Colors, QStringList colorNames, QValueList<int> colorShades);
00109        QString PDF_TransparenzFill(PageItem *currItem);
00110        QString PDF_TransparenzStroke(PageItem *currItem);
00111        void PDF_Annotation(PageItem *ite, uint PNr);
00112        void PDF_Form(const QString& im);
00113        void PDF_xForm(double w, double h, QString im);
00114        QString 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);
00115 
00116        int bytesWritten() { return Spool.at(); }
00117 
00118        QString Inhalt;
00119        ScribusDoc & doc;
00120        const Page * ActPageP;
00121        const PDFOptions & Options;
00122        BookMView* Bvie;
00123        QFile Spool;
00124        int Dokument;
00125        struct Dest
00126        {
00127               QString Name;
00128               int Seite;
00129               QString Act;
00130        };
00131        struct Cata
00132        {
00133               int Outlines;
00134               int PageTree;
00135               int Dest;
00136        }
00137        Catalog;
00138        struct PagT
00139        {
00140               QValueList<int> Kids;
00141               int Count;
00142        }
00143        PageTree;
00144        struct PagL
00145        {
00146               int ObjNum;
00147               int Thumb;
00148               QMap<QString,int> XObjects;
00149               QMap<QString,int> ImgObjects;
00150               QMap<QString,int> FObjects;
00151               QValueList<int> AObjects;
00152               QValueList<int> FormObjects;
00153        }
00154        Seite;
00155        struct OutL
00156        {
00157               int First;
00158               int Last;
00159               int Count;
00160        }
00161        Outlines;
00162        struct Bead
00163        {
00164               int Parent;
00165               int Next;
00166               int Prev;
00167               int Page;
00168               QRect Recht;
00169        };
00170        struct ICCD
00171        {
00172               int ResNum;
00173               QString ResName;
00174               QString ICCArray;
00175        };
00176        struct ShIm
00177        {
00178               int ResNum;
00179               int Width;
00180               int Height;
00181               double aufl;
00182               double sxa;
00183               double sya;
00184               double xa;
00185               double ya;
00186        };
00187        struct OCGInfo
00188        {
00189               int ObjNum;
00190               bool visible;
00191               QString Name;
00192        };
00193        struct SpotC
00194        {
00195               int ResNum;
00196               QString ResName;
00197        };
00198        struct gData
00199        {
00200               int ResNumG;
00201               int ResNumX;
00202               QString ResNamG;
00203               QString ResNamX;
00204               QString data;
00205        };
00206        QMap<QString,ShIm> SharedImages;
00207        QValueList<uint> XRef;
00208        QValueList<Dest> NamedDest;
00209        QValueList<int> Threads;
00210        QValueList<Bead> Beads;
00211        QValueList<int> CalcFields;
00212        QMap<QString,int> Patterns;
00213        QMap<QString,int> Shadings;
00214        QMap<QString,int> Transpar;
00215        QMap<QString,ICCD> ICCProfiles;
00216        QMap<QString, OCGInfo> OCGEntries;
00217        int ObjCounter;
00218        QString ResNam;
00219        int ResCount;
00220        QString NDnam;
00221        QString Datum;
00222        int NDnum;
00223        QMap<QString, QString> UsedFontsP;
00224        QMap<QString, QString> UsedFontsF;
00225        bool CompAvail;
00226        QByteArray KeyGen;
00227        QByteArray OwnerKey;
00228        QByteArray UserKey;
00229        QByteArray FileID;
00230        QByteArray EncryKey;
00231        int Encrypt;
00232        int KeyLen;
00233        QString HTName;
00234        bool BookMinUse;
00235        ColorList colorsToUse;
00236        QMap<QString, SpotC> spotMap;
00237        QMap<QString, SpotC> spotMapReg;
00238        QString spotNam;
00239        int spotCount;
00240        int inPattern;
00241        QTextStream outStream;
00242        QMap<QString, QString> StdFonts;
00243        MultiProgressDialog* progressDialog;
00244        bool abortExport;
00245        bool usingGUI;
00246        double bleedDisplacementX;
00247        double bleedDisplacementY;
00248        QMap<QString, QMap<uint, uint> > Type3Fonts;
00249        
00250 protected slots:
00251        void cancelRequested();
00252 };
00253 
00254 #endif
00255