Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pdflib.cpp
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.cpp  -  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 #include "pdflib.h"
00025 #include "pdflib.moc"
00026 
00027 #include "scconfig.h"
00028 
00029 #include <string>
00030 #include <qstring.h>
00031 #include <qrect.h>
00032 #include <qimage.h>
00033 #include <qregexp.h>
00034 #include <qdatetime.h>
00035 #include <qfileinfo.h>
00036 #include <qtextstream.h>
00037 #include <qdir.h>
00038 #include <cstdlib>
00039 #include <cmath>
00040 #include <qptrstack.h>
00041 #ifdef HAVE_UNISTD_H
00042 #include <unistd.h>
00043 #endif
00044 #include "rc4.h"
00045 
00046 #include "commonstrings.h"
00047 #include "page.h"
00048 #include "pageitem.h"
00049 #include "bookmwin.h"
00050 #include "scpaths.h"
00051 #include "scribus.h"
00052 #include "scribuscore.h"
00053 #include "scribusdoc.h"
00054 #include "multiprogressdialog.h"
00055 #include "bookpalette.h"
00056 #include "scfonts.h"
00057 #include "util.h"
00058 #include "prefsmanager.h"
00059 #include "prefscontext.h"
00060 #include "pdfoptions.h"
00061 #include "sccolor.h"
00062 #include "scpattern.h"
00063 #include "sccolorengine.h"
00064 
00065 #include "text/nlsconfig.h"
00066 
00067 using namespace std;
00068 
00069 #include <tiffio.h>
00070 
00071 
00072 PDFlib::PDFlib(ScribusDoc & docu)
00073        : QObject(&docu),
00074        doc(docu),
00075        ActPageP(0),
00076        Options(doc.PDF_Options),
00077        Bvie(0),
00078        ObjCounter(7),
00079        ResNam("RE"),
00080        ResCount(0),
00081        NDnam("LI"),
00082        NDnum(0),
00083        KeyGen(32),
00084        OwnerKey(32),
00085        UserKey(32),
00086        FileID(16),
00087        EncryKey(5),
00088        Encrypt(0),
00089        KeyLen(5),
00090        colorsToUse(),
00091        spotNam("Spot"),
00092        spotCount(0),
00093        progressDialog(0),
00094        abortExport(false),
00095        usingGUI(ScCore->usingGUI())
00096 {
00097        Catalog.Outlines = 2;
00098        Catalog.PageTree = 3;
00099        Catalog.Dest = 4;
00100        PageTree.Count = 0;
00101        Outlines.First = 0;
00102        Outlines.Last = 0;
00103        Outlines.Count = 0;
00104        Seite.ObjNum = 0;
00105        Seite.Thumb = 0;
00106        CompAvail = true;
00107        int kg_array[] = {0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa,
00108                        0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe,
00109                        0x64, 0x53, 0x69, 0x7a};
00110        for (int a = 0; a < 32; ++a)
00111               KeyGen[a] = kg_array[a];
00112        if (usingGUI)
00113        {
00114               progressDialog = new MultiProgressDialog( tr("Saving PDF"), CommonStrings::tr_Cancel, doc.scMW(), "pdfexportprogress");
00115               Q_CHECK_PTR(progressDialog);
00116               QStringList barNames, barTexts;
00117               barNames << "EMP" << "EP" << "ECPI";
00118               barTexts << tr("Exporting Master Page:") << tr("Exporting Page:") << tr("Exporting Items on Current Page:");
00119               QValueList<bool> barsNumeric;
00120               barsNumeric << true << true << false;
00121               progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
00122               connect(progressDialog->buttonCancel, SIGNAL(clicked()), this, SLOT(cancelRequested()));
00123        }
00124 }
00125 
00126 PDFlib::~PDFlib()
00127 {
00128        delete progressDialog;
00129 }
00130 
00131 static inline QString FToStr(double c)
00132 {
00133        return QString::number(c, 'f', 5);
00134 };
00135 
00136 bool PDFlib::doExport(const QString& fn, const QString& nam, int Components,
00137                                      const std::vector<int> & pageNs, const QMap<int,QPixmap> & thumbs)
00138 {
00139        QPixmap pm;
00140        bool ret = false;
00141        int pc_exportpages=0;
00142        int pc_exportmasterpages=0;
00143        if (usingGUI)
00144               progressDialog->show();
00145        QMap<QString, QMap<uint, FPointArray> > usedFonts;
00146        usedFonts.clear();
00147        doc.getUsedFonts(usedFonts);
00148        if (PDF_Begin_Doc(fn, PrefsManager::instance()->appPrefs.AvailFonts, usedFonts, doc.scMW()->bookmarkPalette->BView))
00149        {
00150               QMap<int, int> pageNsMpa;
00151               for (uint a = 0; a < pageNs.size(); ++a)
00152               {
00153                      pageNsMpa.insert(doc.MasterNames[doc.Pages->at(pageNs[a]-1)->MPageNam], 0);
00154               }
00155               if (usingGUI)
00156               {
00157                      progressDialog->setOverallTotalSteps(pageNsMpa.count()+pageNs.size());
00158                      progressDialog->setTotalSteps("EMP", pageNsMpa.count());
00159                      progressDialog->setTotalSteps("EP", pageNs.size());
00160                      progressDialog->setOverallProgress(0);
00161                      progressDialog->setProgress("EMP", 0);
00162                      progressDialog->setProgress("EP", 0);
00163               }
00164               for (uint ap = 0; ap < doc.MasterPages.count() && !abortExport; ++ap)
00165               {
00166                      if (doc.MasterItems.count() != 0)
00167                      {
00168                             if (pageNsMpa.contains(ap))
00169                             {
00170                                    qApp->processEvents();
00171                                    PDF_TemplatePage(doc.MasterPages.at(ap));
00172                                    ++pc_exportmasterpages;
00173                             }
00174                      }
00175 
00176                      if (usingGUI)
00177                      {
00178                             progressDialog->setProgress("EMP", pc_exportmasterpages);
00179                             progressDialog->setOverallProgress(pc_exportmasterpages+pc_exportpages);
00180                      }
00181               }
00182               for (uint a = 0; a < pageNs.size() && !abortExport; ++a)
00183               {
00184                      if (doc.PDF_Options.Thumbnails)
00185                             pm = thumbs[pageNs[a]];
00186                      qApp->processEvents();
00187                      if (abortExport) break;
00188                      PDF_Begin_Page(doc.Pages->at(pageNs[a]-1), pm);
00189                      qApp->processEvents();
00190                      if (abortExport) break;
00191                      PDF_ProcessPage(doc.Pages->at(pageNs[a]-1), pageNs[a]-1, doc.PDF_Options.doClip);
00192                      qApp->processEvents();
00193                      if (abortExport) break;
00194                      PDF_End_Page();
00195                      pc_exportpages++;
00196                      if (usingGUI)
00197                      {
00198                             progressDialog->setProgress("EP", pc_exportpages);
00199                             progressDialog->setOverallProgress(pc_exportmasterpages+pc_exportpages);
00200                      }
00201               }
00202               ret = true;//Even when aborting we return true. Dont want that "couldnt write msg"
00203               if (!abortExport)
00204               {
00205                      if (doc.PDF_Options.Version == PDFOptions::PDFVersion_X3)
00206                             PDF_End_Doc(ScCore->PrinterProfiles[doc.PDF_Options.PrintProf], nam, Components);
00207                      else
00208                             PDF_End_Doc();
00209               }
00210               else
00211                      closeAndCleanup();
00212        }
00213        if (usingGUI)
00214               progressDialog->close();
00215        return ret;
00216 }
00217 
00218 void PDFlib::StartObj(int nr)
00219 {
00220        XRef.append(bytesWritten());
00221        PutDoc(QString::number(nr)+ " 0 obj\n");
00222 }
00223 
00224 // Encode a string for inclusion in a
00225 // PDF (literal) .
00226 QString PDFlib::PDFEncode(const QString & in)
00227 {
00228        QString tmp("");
00229        for (uint d = 0; d < in.length(); ++d)
00230        {
00231               QChar cc(in.at(d));
00232               if ((cc == '(') || (cc == ')') || (cc == '\\'))
00233                      tmp += '\\';
00234               tmp += cc;
00235        }
00236        return tmp;
00237 }
00238 
00239 QByteArray PDFlib::EncodeUTF16(const QString &in)
00240 {
00241        QString tmp("");
00242        for (uint d = 0; d < in.length(); ++d)
00243        {
00244               QChar cc(in.at(d));
00245               if ((cc == '(') || (cc == ')') || (cc == '\\'))
00246                      tmp += '\\';
00247               tmp += cc;
00248        }
00249        QTextCodec *codec = QTextCodec::codecForName("ISO-10646-UCS-2");
00250        QCString cres = codec->fromUnicode( tmp );
00251        uchar sw;
00252        for(uint d = 0; d < cres.size()-1; d += 2)
00253        {
00254               sw = cres[d];
00255               cres[d] = cres[d+1];
00256               cres[d+1] = sw;
00257        }
00258        return cres;
00259 }
00260 
00261 QString PDFlib::EncStream(const QString & in, int ObjNum)
00262 {
00263        if (in.length() < 1)
00264               return QString("");
00265        else if (!Options.Encrypt)
00266               return in;
00267        rc4_context_t rc4;
00268        int dlen = 0;
00269        QString tmp(in);
00270        QByteArray us(tmp.length());
00271        QByteArray ou(tmp.length());
00272        for (uint a = 0; a < tmp.length(); ++a)
00273               us[a] = uchar(QChar(tmp.at(a)));
00274        QByteArray data(10);
00275        if (KeyLen > 5)
00276               data.resize(21);
00277        for (int cd = 0; cd < KeyLen; ++cd)
00278        {
00279               data[cd] = EncryKey[cd];
00280               dlen++;
00281        }
00282        data[dlen++] = ObjNum;
00283        data[dlen++] = ObjNum >> 8;
00284        data[dlen++] = ObjNum >> 16;
00285        data[dlen++] = 0;
00286        data[dlen++] = 0;
00287        QByteArray step1(16);
00288        step1 = ComputeMD5Sum(&data);
00289        rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16));
00290        rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length());
00291        QString uk = "";
00292        for (uint cl = 0; cl < tmp.length(); ++cl)
00293               uk += QChar(ou[cl]);
00294        return uk;
00295 }
00296 
00297 QByteArray PDFlib::EncStreamArray(const QByteArray & in, int ObjNum)
00298 {
00299        if (in.size() < 1)
00300               return QByteArray();
00301        else if (!Options.Encrypt)
00302               return in;
00303        rc4_context_t rc4;
00304        int dlen = 0;
00305        QByteArray out(in.size());
00306        QByteArray data(10);
00307        if (KeyLen > 5)
00308               data.resize(21);
00309        for (int cd = 0; cd < KeyLen; ++cd)
00310        {
00311               data[cd] = EncryKey[cd];
00312               dlen++;
00313        }
00314        data[dlen++] = ObjNum;
00315        data[dlen++] = ObjNum >> 8;
00316        data[dlen++] = ObjNum >> 16;
00317        data[dlen++] = 0;
00318        data[dlen++] = 0;
00319        QByteArray step1(16);
00320        step1 = ComputeMD5Sum(&data);
00321        rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16));
00322        rc4_encrypt(&rc4, reinterpret_cast<uchar*>(in.data()), reinterpret_cast<uchar*>(out.data()), in.size());
00323        return out;
00324 }
00325 
00326 QString PDFlib::EncString(const QString & in, int ObjNum)
00327 {
00328        if (!Options.Encrypt)
00329               return in;
00330        rc4_context_t rc4;
00331        QString tmp;
00332        int dlen = 0;
00333        if (in.length() < 3)
00334               return "<>";
00335        tmp = in.mid(1, in.length()-2);
00336        QByteArray us(tmp.length());
00337        QByteArray ou(tmp.length());
00338        for (uint a = 0; a < tmp.length(); ++a)
00339               us[a] = static_cast<uchar>(QChar(tmp.at(a)));
00340        QByteArray data(10);
00341        if (KeyLen > 5)
00342               data.resize(21);
00343        for (int cd = 0; cd < KeyLen; ++cd)
00344        {
00345               data[cd] = EncryKey[cd];
00346               dlen++;
00347        }
00348        data[dlen++] = ObjNum;
00349        data[dlen++] = ObjNum >> 8;
00350        data[dlen++] = ObjNum >> 16;
00351        data[dlen++] = 0;
00352        data[dlen++] = 0;
00353        QByteArray step1(16);
00354        step1 = ComputeMD5Sum(&data);
00355        rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16));
00356        rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length());
00357        QString uk = "";
00358        for (uint cl = 0; cl < tmp.length(); ++cl)
00359               uk += QChar(ou[cl]);
00360        tmp = "<"+String2Hex(&uk, false)+">";
00361        return tmp;
00362 }
00363 
00364 QString PDFlib::EncStringUTF16(const QString & in, int ObjNum)
00365 {
00366        if (in.length() < 3)
00367               return "<>";
00368        if (!Options.Encrypt)
00369        {
00370               QString tmp = in.mid(1, in.length()-2);
00371               QByteArray us = EncodeUTF16(tmp);
00372               QString uk = "";
00373               for (uint cl = 0; cl < us.size(); ++cl)
00374                      uk += QChar(us[cl]);
00375               return "<"+String2Hex(&uk, false)+">";
00376        }
00377        rc4_context_t rc4;
00378        QString tmp;
00379        int dlen = 0;
00380        tmp = in.mid(1, in.length()-2);
00381        QByteArray us = EncodeUTF16(tmp);
00382        QByteArray ou(us.size());
00383        QByteArray data(10);
00384        if (KeyLen > 5)
00385               data.resize(21);
00386        for (int cd = 0; cd < KeyLen; ++cd)
00387        {
00388               data[cd] = EncryKey[cd];
00389               dlen++;
00390        }
00391        data[dlen++] = ObjNum;
00392        data[dlen++] = ObjNum >> 8;
00393        data[dlen++] = ObjNum >> 16;
00394        data[dlen++] = 0;
00395        data[dlen++] = 0;
00396        QByteArray step1(16);
00397        step1 = ComputeMD5Sum(&data);
00398        rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16));
00399        rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), ou.size());
00400        QString uk = "";
00401        for (uint cl = 0; cl < ou.size(); ++cl)
00402               uk += QChar(ou[cl]);
00403        tmp = "<"+String2Hex(&uk, false)+">";
00404        return tmp;
00405 }
00406 
00407 QString PDFlib::FitKey(const QString & pass)
00408 {
00409        QString pw(pass);
00410        if (pw.length() < 32)
00411        {
00412               uint l = pw.length();
00413               for (uint a = 0; a < 32 - l; ++a)
00414                      pw += QChar(KeyGen[a]);
00415        }
00416        else
00417               pw = pw.left(32);
00418        return pw;
00419 }
00420 
00421 void PDFlib::CalcOwnerKey(const QString & Owner, const QString & User)
00422 {
00423        rc4_context_t rc4;
00424        QString pw(FitKey(User));
00425        QString pw2(FitKey(Owner.isEmpty() ? User : Owner));
00426        QByteArray step1(16);
00427        step1 = ComputeMD5(pw2);
00428        if (KeyLen > 5)
00429        {
00430               for (int kl = 0; kl < 50; ++kl)
00431                      step1 = ComputeMD5Sum(&step1);
00432        }
00433        QByteArray us(32);
00434        QByteArray enk(16);
00435        if (KeyLen > 5)
00436        {
00437               for (uint a2 = 0; a2 < 32; ++a2)
00438                      OwnerKey[a2] = static_cast<uchar>(QChar(pw.at(a2)));
00439               for (int rl = 0; rl < 20; rl++)
00440               {
00441                      for (int j = 0; j < 16; j ++)
00442                             enk[j] = step1[j] ^ rl;
00443                      rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16);
00444                      rc4_encrypt(&rc4, reinterpret_cast<uchar*>(OwnerKey.data()),
00445                                     reinterpret_cast<uchar*>(OwnerKey.data()), 32);
00446               }
00447        }
00448        else
00449        {
00450               for (uint a = 0; a < 32; ++a)
00451                      us[a] = static_cast<uchar>(QChar(pw.at(a)));
00452               rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5);
00453               rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()),
00454                                    reinterpret_cast<uchar*>(OwnerKey.data()), 32);
00455        }
00456 }
00457 
00458 void PDFlib::CalcUserKey(const QString & User, int Permission)
00459 {
00460        rc4_context_t rc4;
00461        QString pw(FitKey(User));
00462        QByteArray step1(16);
00463        QByteArray perm(4);
00464        uint perm_value = static_cast<uint>(Permission);
00465        perm[0] = perm_value;
00466        perm[1] = perm_value >> 8;
00467        perm[2] = perm_value >> 16;
00468        perm[3] = perm_value >> 24;
00469        for (uint a = 0; a < 32; ++a)
00470               pw += QChar(OwnerKey[a]);
00471        for (uint a1 = 0; a1 < 4; ++a1)
00472               pw += QChar(perm[a1]);
00473        for (uint a3 = 0; a3 < 16; ++a3)
00474               pw += QChar(FileID[a3]);
00475        step1 = ComputeMD5(pw);
00476        if (KeyLen > 5)
00477        {
00478               for (int kl = 0; kl < 50; ++kl)
00479                      step1 = ComputeMD5Sum(&step1);
00480               EncryKey.resize(16);
00481        }
00482        for (int a2 = 0; a2 < KeyLen; ++a2)
00483               EncryKey[a2] = step1[a2];
00484        if (KeyLen > 5)
00485        {
00486               QString pr2("");
00487               for (int kl3 = 0; kl3 < 32; ++kl3)
00488                      pr2 += QChar(KeyGen[kl3]);
00489               for (uint a4 = 0; a4 < 16; ++a4)
00490                      pr2 += QChar(FileID[a4]);
00491               step1 = ComputeMD5(pr2);
00492               QByteArray enk(16);
00493               for (uint a3 = 0; a3 < 16; ++a3)
00494                      UserKey[a3] = step1[a3];
00495               for (int rl = 0; rl < 20; rl++)
00496               {
00497                      for (int j = 0; j < 16; j ++)
00498                             enk[j] = EncryKey[j] ^ rl;
00499                      rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16);
00500                      rc4_encrypt(&rc4, reinterpret_cast<uchar*>(UserKey.data()), reinterpret_cast<uchar*>(UserKey.data()), 16);
00501               }
00502        }
00503        else
00504        {
00505               rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5);
00506               rc4_encrypt(&rc4, reinterpret_cast<uchar*>(KeyGen.data()), reinterpret_cast<uchar*>(UserKey.data()), 32);
00507        }
00508 }
00509 
00510 QByteArray PDFlib::ComputeMD5(const QString& in)
00511 {
00512        uint inlen=in.length();
00513        QByteArray TBytes(inlen);
00514        for (uint a = 0; a < inlen; ++a)
00515               TBytes[a] = static_cast<uchar>(QChar(in.at(a)));
00516        return ComputeMD5Sum(&TBytes);
00517 }
00518 
00519 bool PDFlib::PDF_Begin_Doc(const QString& fn, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, BookMView* vi)
00520 {
00521        Spool.setName(fn);
00522        if (!Spool.open(IO_WriteOnly))
00523               return false;
00524        outStream.setDevice(&Spool);
00525        QString tmp;
00526        QString ok = "";
00527        QString uk = "";
00528        QFileInfo fd;
00529        QString fext;
00530        int a;
00531        inPattern = 0;
00532        Bvie = vi;
00533        BookMinUse = false;
00534        UsedFontsP.clear();
00535        UsedFontsF.clear();
00536        if ((Options.Version == 15) && (Options.useLayers))
00537               ObjCounter = 10;
00538        else
00539               ObjCounter = 9;
00540        switch (Options.Version)
00541        {
00542               case 12:
00543               case 13:
00544                      PutDoc("%PDF-1.3\n");
00545                      break;
00546               case 14:
00547                      PutDoc("%PDF-1.4\n");
00548                      break;
00549               case 15:
00550                      PutDoc("%PDF-1.5\n");
00551                      break;
00552        }
00553        if (Options.Version == 12)
00554               ObjCounter++;
00555        PutDoc("%\xc7\xec\x8f\xa2\n");
00556        StartObj(1);
00557        PutDoc("<<\n/Type /Catalog\n/Outlines 3 0 R\n/Pages 4 0 R\n/Dests 5 0 R\n/AcroForm 6 0 R\n/Names 7 0 R\n/Threads 8 0 R\n");
00558        if ((Options.Version == 15) && (Options.useLayers))
00559               PutDoc("/OCProperties 9 0 R\n");
00560        if (Options.Version == 12)
00561               PutDoc("/OutputIntents [ "+QString::number(ObjCounter-1)+" 0 R ]\n");
00562        PutDoc("/PageLayout ");
00563        switch (Options.PageLayout)
00564        {
00565               case PDFOptions::SinglePage:
00566                      PutDoc("/SinglePage\n");
00567                      break;
00568               case PDFOptions::OneColumn:
00569                      PutDoc("/OneColumn\n");
00570                      break;
00571               case PDFOptions::TwoColumnLeft:
00572                      PutDoc("/TwoColumnLeft\n");
00573                      break;
00574               case PDFOptions::TwoColumnRight:
00575                      PutDoc("/TwoColumnRight\n");
00576                      break;
00577        }
00578        if (Options.displayBookmarks)
00579               PutDoc("/PageMode /UseOutlines\n");
00580        else if (Options.displayFullscreen)
00581               PutDoc("/PageMode /FullScreen\n");
00582        else if (Options.displayThumbs)
00583               PutDoc("/PageMode /UseThumbs\n");
00584        else if ((Options.Version == 15) && (Options.displayLayers))
00585                      PutDoc("/PageMode /UseOC\n");
00586        if (!Options.openAction.isEmpty())
00587        {
00588               PutDoc("/OpenAction << /S /JavaScript /JS (this."+Options.openAction+"\\(\\)) >>\n");
00589        }
00590        PutDoc("/ViewerPreferences\n<<\n/PageDirection ");
00591        PutDoc( Options.Binding == 0 ? "/L2R\n" : "/R2L\n");
00592        if (Options.hideToolBar)
00593               PutDoc("/HideToolbar true\n");
00594        if (Options.hideMenuBar)
00595               PutDoc("/HideMenubar true\n");
00596        if (Options.fitWindow)
00597               PutDoc("/FitWindow true\n");
00598        PutDoc(" >>\n>>\nendobj\n");
00599        QString IDg(Datum);
00600        IDg += Options.Datei;
00601        IDg += "Scribus "+QString(VERSION);
00602        IDg += "Scribus PDF Library "+QString(VERSION);
00603        IDg += doc.documentInfo.getTitle();
00604        IDg += doc.documentInfo.getAuthor();
00605        IDg += "/False";
00606        FileID = ComputeMD5(IDg);
00607        if (Options.Encrypt)
00608        {
00609               if ((Options.Version == 14) || (Options.Version == 15))
00610                      KeyLen = 16;
00611               else
00612                      KeyLen = 5;
00613               CalcOwnerKey(Options.PassOwner, Options.PassUser);
00614               CalcUserKey(Options.PassUser, Options.Permissions);
00615               for (uint cl2 = 0; cl2 < 32; ++cl2)
00616                      ok += QChar(OwnerKey[cl2]);
00617               if (KeyLen > 5)
00618               {
00619                      for (uint cl3 = 0; cl3 < 16; ++cl3)
00620                             uk += QChar(UserKey[cl3]);
00621                      for (uint cl3r = 0; cl3r < 16; ++cl3r)
00622                             uk += QChar(KeyGen[cl3r]);
00623               }
00624               else
00625               {
00626                      for (uint cl = 0; cl < 32; ++cl)
00627                             uk += QChar(UserKey[cl]);
00628               }
00629        }
00630        QDate d = QDate::currentDate();
00631        Datum = "D:";
00632        tmp.sprintf("%4d", d.year());
00633        tmp.replace(QRegExp(" "), "0");
00634        Datum += tmp;
00635        tmp.sprintf("%2d", d.month());
00636        tmp.replace(QRegExp(" "), "0");
00637        Datum += tmp;
00638        tmp.sprintf("%2d", d.day());
00639        tmp.replace(QRegExp(" "), "0");
00640        Datum += tmp;
00641        tmp = QTime::currentTime().toString();
00642        tmp.replace(QRegExp(":"), "");
00643        Datum += tmp;
00644        StartObj(2);
00645        PutDoc("<<\n/Creator "+EncString("(Scribus "+QString(VERSION)+")",2)+"\n");
00646        PutDoc("/Producer "+EncString("(Scribus PDF Library "+QString(VERSION)+")",2)+"\n");
00647        QString docTitle = doc.documentInfo.getTitle();
00648        if ((Options.Version == 12) && (docTitle.isEmpty()))
00649               PutDoc("/Title "+EncStringUTF16("("+doc.DocName+")",2)+"\n");
00650        else
00651               PutDoc("/Title "+EncStringUTF16("("+doc.documentInfo.getTitle()+")",2)+"\n");
00652        PutDoc("/Author "+EncStringUTF16("("+doc.documentInfo.getAuthor()+")",2)+"\n");
00653        PutDoc("/Keywords "+EncStringUTF16("("+doc.documentInfo.getKeywords()+")",2)+"\n");
00654        PutDoc("/CreationDate "+EncString("("+Datum+")",2)+"\n");
00655        PutDoc("/ModDate "+EncString("("+Datum+")",2)+"\n");
00656        if (Options.Version == 12)
00657               PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n");
00658        PutDoc("/Trapped /False\n>>\nendobj\n");
00659        for (int t = 0; t < 6; ++t)
00660               XRef.append(bytesWritten());
00661        if ((Options.Version == 15) && (Options.useLayers))
00662               XRef.append(bytesWritten());
00663        if (Options.Version == 12)
00664               XRef.append(bytesWritten());
00665        if (Options.Encrypt)
00666        {
00667               StartObj(ObjCounter);
00668               Encrypt = ObjCounter;
00669               ObjCounter++;
00670               PutDoc("<<\n/Filter /Standard\n");
00671               PutDoc( KeyLen > 5 ? "/R 3\n/V 2\n/Length 128\n" : "/R 2\n/V 1\n");
00672               PutDoc("/O <"+String2Hex(&ok)+">\n");
00673               PutDoc("/U <"+String2Hex(&uk)+">\n");
00674               PutDoc("/P "+QString::number(Options.Permissions)+"\n>>\nendobj\n");
00675        }
00676        QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
00677        ReallyUsed.clear();
00678        PageItem* pgit;
00679        QMap<int, QString> ind2PDFabr;
00680        const QString tmpf[] = {"/Courier", "/Courier-Bold", "/Courier-Oblique", "/Courier-BoldOblique",
00681                                                                                     "/Helvetica", "/Helvetica-Bold", "/Helvetica-Oblique", "/Helvetica-BoldOblique",
00682                                                                                     "/Times-Roman", "/Times-Bold", "/Times-Italic", "/Times-BoldItalic",
00683                                                                                     "/ZapfDingbats", "/Symbol"};
00684        size_t ar = sizeof(tmpf) / sizeof(*tmpf);
00685        for (uint ax = 0; ax < ar; ++ax)
00686               ind2PDFabr[ax] = tmpf[ax];
00687        for (uint c = 0; c < doc.FrameItems.count(); ++c)
00688        {
00689               pgit = doc.FrameItems.at(c);
00690               if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText))
00691               {
00692                      if (pgit->isAnnotation())
00693                      {
00694                             if (pgit->annotation().Type() == 4)
00695                                    StdFonts.insert("/ZapfDingbats", "");
00696                             StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], "");
00697                             ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
00698                      }
00699                      for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
00700                      {
00701                             ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
00702                      }
00703               }
00704        }
00705        for (uint c = 0; c < doc.MasterItems.count(); ++c)
00706        {
00707               pgit = doc.MasterItems.at(c);
00708               if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText))
00709               {
00710                      if (pgit->isAnnotation())
00711                      {
00712                             if (pgit->annotation().Type() == 4)
00713                                    StdFonts.insert("/ZapfDingbats", "");
00714                             StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], "");
00715                             ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
00716                      }
00717                      for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
00718                      {
00719                             ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
00720                      }
00721               }
00722        }
00723        for (uint d = 0; d < doc.Items->count(); ++d)
00724        {
00725               pgit = doc.Items->at(d);
00726               if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText))
00727               {
00728                      if (pgit->isAnnotation())
00729                      {
00730                             if (pgit->annotation().Type() == 4)
00731                                    StdFonts.insert("/ZapfDingbats", "");
00732                             StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], "");
00733                             ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
00734                      }
00735                      for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
00736                      {
00737                             ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
00738                      }
00739               }
00740        }
00741        if (Options.docInfoMarks)
00742        {
00743               StdFonts.insert("/Helvetica", "");
00744        }
00745        QStringList patterns = doc.getUsedPatterns();
00746        for (uint c = 0; c < patterns.count(); ++c)
00747        {
00748               ScPattern pa = doc.docPatterns[patterns[c]];
00749               for (uint o = 0; o < pa.items.count(); o++)
00750               {
00751                      pgit = pa.items.at(o);
00752                      if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText))
00753                      {
00754                             if (pgit->isAnnotation())
00755                             {
00756                                    if (pgit->annotation().Type() == 4)
00757                                           StdFonts.insert("/ZapfDingbats", "");
00758                                    StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], "");
00759                                    ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
00760                             }
00761                             for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
00762                             {
00763                                    ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
00764                             }
00765                      }
00766               }
00767        }
00768        a = 0;
00769        QMap<QString, QString>::Iterator itStd;
00770        for (itStd = StdFonts.begin(); itStd != StdFonts.end(); ++itStd)
00771        {
00772               StartObj(ObjCounter);
00773               PutDoc("<<\n/Type /Font\n/Subtype /Type1\n");
00774               PutDoc("/Name /FoStd"+QString::number(a)+"\n");
00775               PutDoc("/BaseFont "+itStd.key()+"\n");
00776               if (itStd.key() != "/ZapfDingbats")
00777               {
00778                      PutDoc("/Encoding << \n");
00779                      PutDoc("/Differences [ \n");
00780                      PutDoc("24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde\n");
00781                      PutDoc("39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright\n");
00782                      PutDoc("/minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron\n");
00783                      PutDoc("/Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot\n");
00784                      PutDoc("/.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine\n");
00785                      PutDoc("188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex\n");
00786                      PutDoc("/Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
00787                      PutDoc("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla\n");
00788                      PutDoc("/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
00789                      PutDoc("/divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis\n");
00790                      PutDoc("] >>\n");
00791               }
00792               PutDoc(">>\nendobj\n");
00793               Seite.FObjects["FoStd"+QString::number(a)] = ObjCounter;
00794               itStd.data() = "FoStd"+QString::number(a);
00795               ObjCounter++;
00796               a++;
00797        }
00798        QMap<QString,QMap<uint, FPointArray> >::Iterator it;
00799        a = 0;
00800        for (it = ReallyUsed.begin(); it != ReallyUsed.end(); ++it)
00801        {
00802               ScFace::FontFormat fformat = AllFonts[it.key()].format();
00803               if ((!AllFonts[it.key()].hasNames()) || (Options.SubsetList.contains(it.key())))
00804               {
00805                      if (AllFonts[it.key()].hasNames())
00806                      {
00807                             UsedFontsP.insert(it.key(), "/Fo"+QString::number(a));
00808                             uint SubFonts = 0;
00809                             uint glyphCount = 0;
00810                             double minx = 99999.9;
00811                             double miny = 99999.9;
00812                             double maxx = -99999.9;
00813                             double maxy = -99999.9;
00814                             QValueList<uint> glyphWidths;
00815                             QStringList charProcs;
00816                             QString encoding = "<< /Type /Encoding\n/Differences [ 0\n";
00817                             QString fon("");
00818                             QMap<uint, uint> glyphMapping;
00819                             QMap<uint,std::pair<QChar,QString> > gl;
00820                             AllFonts[it.key()].glyphNames(gl);
00821                             QMap<uint,FPointArray>& RealGlyphs(it.data());
00822                             QMap<uint,FPointArray>::Iterator ig;
00823                             for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
00824                             {
00825                                    FPoint np, np1, np2;
00826                                    bool nPath = true;
00827                                    fon = "";
00828                                    if (ig.data().size() > 3)
00829                                    {
00830                                           FPointArray gly = ig.data();
00831                                           QWMatrix mat;
00832                                           mat.scale(100.0, -100.0);
00833                                           gly.map(mat);
00834                                           gly.translate(0, 1000);
00835                                           for (uint poi = 0; poi < gly.size()-3; poi += 4)
00836                                           {
00837                                                  if (gly.point(poi).x() > 900000)
00838                                                  {
00839                                                         fon += "h\n";
00840                                                         nPath = true;
00841                                                         continue;
00842                                                  }
00843                                                  if (nPath)
00844                                                  {
00845                                                         np = gly.point(poi);
00846                                                         fon += FToStr(np.x())+" "+FToStr(np.y())+" m\n";
00847                                                         nPath = false;
00848                                                  }
00849                                                  np = gly.point(poi+1);
00850                                                  np1 = gly.point(poi+3);
00851                                                  np2 = gly.point(poi+2);
00852                                                  fon += FToStr(np.x()) + " " + FToStr(np.y()) + " " + FToStr(np1.x()) + " " + FToStr(np1.y()) + " " + FToStr(np2.x()) + " " + FToStr(np2.y()) + " c\n";
00853                                           }
00854                                           fon += "h f*\n";
00855                                           np = getMinClipF(&gly);
00856                                           np1 = getMaxClipF(&gly);
00857                                    }
00858                                    else
00859                                    {
00860                                           fon = "h";
00861                                           np = FPoint(0, 0);
00862                                           np1 = FPoint(0, 0);
00863                                    }
00864                                    fon.prepend(QString::number(qRound(np1.x())) + " 0 "+QString::number(qRound(np.x()))+" "+QString::number(qRound(np.y()))+" "+QString::number(qRound(np1.x()))+ " "+QString::number(qRound(np1.y()))+" d1\n");
00865                                    minx = QMIN(minx, np.x());
00866                                    miny = QMIN(miny, np.y());
00867                                    maxx = QMAX(maxx, np1.x());
00868                                    maxy = QMAX(maxy, np1.y());
00869                                    glyphWidths.append(qRound(np1.x()));
00870                                    charProcs.append("/"+gl[ig.key()].second+" "+QString::number(ObjCounter)+" 0 R\n");
00871                                    encoding += "/"+gl[ig.key()].second+" ";
00872                                    glyphMapping.insert(ig.key(), glyphCount + SubFonts * 256);
00873                                    StartObj(ObjCounter);
00874                                    ObjCounter++;
00875                                    if ((Options.Compress) && (CompAvail))
00876                                           fon = CompressStr(&fon);
00877                                    PutDoc("<< /Length "+QString::number(fon.length()+1));
00878                                    if ((Options.Compress) && (CompAvail))
00879                                           PutDoc("\n/Filter /FlateDecode");
00880                                    PutDoc("\n>>\nstream\n"+EncStream(fon, ObjCounter-1)+"\nendstream\nendobj\n");
00881                                    glyphCount++;
00882                                    if ((glyphCount > 256) || (glyphCount == RealGlyphs.count()))
00883                                    {
00884                                           StartObj(ObjCounter);
00885                                           ObjCounter++;
00886                                           PutDoc("[ ");
00887                                           for (uint ww = 0; ww < glyphWidths.count(); ++ww)
00888                                           {
00889                                                  PutDoc(QString::number(qRound(glyphWidths[ww]))+" ");
00890                                           }
00891                                           PutDoc("]\nendobj\n");
00892                                           StartObj(ObjCounter);
00893                                           ObjCounter++;
00894                                           PutDoc("<<\n");
00895                                           for (uint ww = 0; ww < charProcs.count(); ++ww)
00896                                           {
00897                                                  PutDoc(charProcs[ww]);
00898                                           }
00899                                           PutDoc(">>\nendobj\n");
00900                                           StartObj(ObjCounter);
00901                                           ObjCounter++;
00902                                           PutDoc(encoding);
00903                                           PutDoc("]\n");
00904                                           PutDoc(">>\nendobj\n");
00905                                           StartObj(ObjCounter);
00906                                           PutDoc("<<\n/Type /Font\n/Subtype /Type3\n");
00907                                           PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(SubFonts)+"\n");
00908                                           PutDoc("/FirstChar 0\n");
00909                                           PutDoc("/LastChar "+QString::number(glyphCount-1)+"\n");
00910                                           PutDoc("/Widths "+QString::number(ObjCounter-3)+" 0 R\n");
00911                                           PutDoc("/CharProcs "+QString::number(ObjCounter-2)+" 0 R\n");
00912                                           PutDoc("/FontBBox ["+QString::number(qRound(minx))+" "+QString::number(qRound(miny))+" "+QString::number(qRound(maxx))+ " "+QString::number(qRound(maxy))+"]\n");
00913                                           PutDoc("/FontMatrix [0.001 0 0 0.001 0 0]\n");
00914                                           PutDoc("/Encoding "+QString::number(ObjCounter-1)+" 0 R\n");
00915                                           PutDoc(">>\nendobj\n");
00916                                           Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(SubFonts)] = ObjCounter;
00917                                           ObjCounter++;
00918                                           charProcs.clear();
00919                                           glyphWidths.clear();
00920 //                                        glyphMapping.clear();
00921                                           glyphCount = 0;
00922                                           SubFonts = 0;
00923                                           minx = 99999.9;
00924                                           miny = 99999.9;
00925                                           maxx = -99999.9;
00926                                           maxy = -99999.9;
00927                                           encoding = "<< /Type /Encoding\n/Differences [ 0\n";
00928                                    }
00929                             }
00930                             Type3Fonts.insert("/Fo"+QString::number(a), glyphMapping);
00931                      }
00932                      else
00933                      {
00934                             QString fon("");
00935                             QMap<uint,FPointArray>& RealGlyphs(it.data());
00936                             QMap<uint,FPointArray>::Iterator ig;
00937                             for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
00938                             {
00939                                    FPoint np, np1, np2;
00940                                    bool nPath = true;
00941                                    fon = "";
00942                                    if (ig.data().size() > 3)
00943                                    {
00944                                           FPointArray gly = ig.data();
00945                                           QWMatrix mat;
00946                                           mat.scale(0.1, 0.1);
00947                                           gly.map(mat);
00948                                           for (uint poi = 0; poi < gly.size()-3; poi += 4)
00949                                           {
00950                                                  if (gly.point(poi).x() > 900000)
00951                                                  {
00952                                                         fon += "h\n";
00953                                                         nPath = true;
00954                                                         continue;
00955                                                  }
00956                                                  if (nPath)
00957                                                  {
00958                                                         np = gly.point(poi);
00959                                                         fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
00960                                                         nPath = false;
00961                                                  }
00962                                                  np = gly.point(poi+1);
00963                                                  np1 = gly.point(poi+3);
00964                                                  np2 = gly.point(poi+2);
00965                                                  fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " +
00966                                                         FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " +
00967                                                         FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n";
00968                                           }
00969                                           fon += "h f*\n";
00970                                           np = getMinClipF(&gly);
00971                                           np1 = getMaxClipF(&gly);
00972                                    }
00973                                    else
00974                                    {
00975                                           fon = "h";
00976                                           np = FPoint(0, 0);
00977                                           np1 = FPoint(0, 0);
00978                                    }
00979                                    StartObj(ObjCounter);
00980                                    ObjCounter++;
00981                                    PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
00982                                    PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n");
00983                                    PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
00984                                    PutDoc(">>\n");
00985                                    if ((Options.Compress) && (CompAvail))
00986                                           fon = CompressStr(&fon);
00987                                    PutDoc("/Length "+QString::number(fon.length()+1));
00988                                    if ((Options.Compress) && (CompAvail))
00989                                           PutDoc("\n/Filter /FlateDecode");
00990                                    PutDoc(" >>\nstream\n"+EncStream(fon, ObjCounter-1)+"\nendstream\nendobj\n");
00991                                    Seite.XObjects[AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(ig.key())] = ObjCounter-1;
00992                             }
00993                      }
00994               }
00995               else
00996               {
00997                      UsedFontsP.insert(it.key(), "/Fo"+QString::number(a));
00998                      if ((fformat == ScFace::PFB) && (Options.EmbedList.contains(it.key())))
00999                      {
01000                             QString fon("");
01001                             StartObj(ObjCounter);
01002                             QByteArray bb;
01003                             AllFonts[it.key()].RawData(bb);
01004                             uint posi;
01005                             for (posi = 6; posi < bb.size(); ++posi)
01006                             {
01007                                    if ((bb[posi] == static_cast<char>(0x80)) && (static_cast<int>(bb[posi+1]) == 2))
01008                                           break;
01009                                    fon += QChar(bb[posi]);
01010                             }
01011                             int len1 = fon.length();
01012                             uint ulen;
01013                             ulen = bb[posi+2] & 0xff;
01014                             ulen |= (bb[posi+3] << 8) & 0xff00;
01015                             ulen |= (bb[posi+4] << 16) & 0xff0000;
01016                             ulen |= (bb[posi+5] << 24) & 0xff000000;
01017                             if (ulen > bb.size())
01018                                    ulen = bb.size()-7;
01019                             posi += 6;
01020                             for (uint j = 0; j < ulen; ++j)
01021                                    fon += QChar(bb[posi++]);
01022                             posi += 6;
01023                             int len2 = fon.length()-len1;
01024                             for (uint j = posi; j < bb.size(); ++j)
01025                             {
01026                                    if ((bb[j] == static_cast<char>(0x80)) && (static_cast<int>(bb[j+1]) == 3))
01027                                           break;
01028                                    if (bb[j] == '\r')
01029                                           fon += "\n";
01030                                    else
01031                                           fon += QChar(bb[j]);
01032                             }
01033                             int len3 = fon.length()-len2-len1;
01034                             if ((Options.Compress) && (CompAvail))
01035                                    fon = CompressStr(&fon);
01036                             PutDoc("<<\n/Length "+QString::number(fon.length()+1)+"\n");
01037                             PutDoc("/Length1 "+QString::number(len1)+"\n");
01038                             PutDoc("/Length2 "+QString::number(len2)+"\n");
01039                             PutDoc("/Length3 "+QString::number(len3)+"\n");
01040                             if ((Options.Compress) && (CompAvail))
01041                                    PutDoc("/Filter /FlateDecode\n");
01042                             PutDoc(">>\nstream\n"+EncStream(fon,ObjCounter)+"\nendstream\nendobj\n");
01043                             ObjCounter++;
01044                      }
01045                      if ((fformat == ScFace::PFA) && (Options.EmbedList.contains(it.key())))
01046                      {
01047                             QString fon("");
01048                             QString fon2("");
01049                             QString tm("");
01050                             uint value;
01051                             bool ok = true;
01052                             StartObj(ObjCounter);
01053                             AllFonts[it.key()].EmbedFont(fon);
01054                             int len1 = fon.find("eexec")+5;
01055                             fon2 = fon.left(len1)+"\n";
01056                             int len2 = fon.find("0000000000000000000000000");
01057                             if (len2 == -1)
01058                                    len2 = fon.length()+1;
01059                             int count = 0;
01060                             for (int xx = len1; xx < len2-1; ++xx)
01061                             {
01062                                    tm = fon.at(xx);
01063                                    if ((tm == QChar(13)) || (tm == QChar(10)))
01064                                           continue;
01065                                    xx++;
01066                                    count++;
01067                                    tm += fon.at(xx);
01068                                    value = tm.toUInt(&ok, 16);
01069                                    fon2 += QChar(value);
01070                             }
01071                             fon2 += fon.mid(len2);
01072                             if ((Options.Compress) && (CompAvail))
01073                                    fon2 = CompressStr(&fon2);
01074                             PutDoc("<<\n/Length "+QString::number(fon2.length()+1)+"\n");
01075                             PutDoc("/Length1 "+QString::number(len1+1)+"\n");
01076                             PutDoc("/Length2 "+QString::number(count)+"\n");
01077                             PutDoc(static_cast<int>(fon.length()-len2) == -1 ? QString("/Length3 0\n") : "/Length3 "+QString::number(fon.length()-len2)+"\n");
01078                             if ((Options.Compress) && (CompAvail))
01079                                    PutDoc("/Filter /FlateDecode\n");
01080                             PutDoc(">>\nstream\n"+EncStream(fon2, ObjCounter)+"\nendstream\nendobj\n");
01081                             ObjCounter++;
01082                      }
01083                      if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key())))
01084                      {
01085                             QString fon("");
01086                             StartObj(ObjCounter);
01087                             QByteArray bb;
01088                             AllFonts[it.key()].RawData(bb);
01089                             //AV: += and append() dont't work because they stop at '\0' :-(
01090                             for (unsigned int i=0; i < bb.size(); i++)
01091                                    fon += QChar(bb[i]);
01092                             int len = fon.length();
01093                             if ((Options.Compress) && (CompAvail))
01094                                    fon = CompressStr(&fon);
01095                             //qDebug(QString("sfnt data: size=%1 before=%2 compressed=%3").arg(bb.size()).arg(len).arg(fon.length()));
01096                             PutDoc("<<\n/Length "+QString::number(fon.length()+1)+"\n");
01097                             PutDoc("/Length1 "+QString::number(len)+"\n");
01098                             if ((Options.Compress) && (CompAvail))
01099                                    PutDoc("/Filter /FlateDecode\n");
01100                             PutDoc(">>\nstream\n"+EncStream(fon, ObjCounter)+"\nendstream\nendobj\n");
01101                             ObjCounter++;
01102                      }
01103                      StartObj(ObjCounter);
01104                      // TODO: think about QByteArray ScFace::getFontDescriptor() -- AV
01105                      PutDoc("<<\n/Type /FontDescriptor\n");
01106                      PutDoc("/FontName /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
01107                      PutDoc("/FontBBox [ "+AllFonts[it.key()].FontBBoxAsString()+" ]\n");
01108                      PutDoc("/Flags ");
01109                      //FIXME: isItalic() should be queried from ScFace, not from Qt -- AV
01110                      //QFontInfo fo = QFontInfo(it.data());
01111                      int pfl = 0;
01112                      if (AllFonts[it.key()].isFixedPitch())
01113                             pfl = pfl ^ 1;
01114                      //if (fo.italic())
01115                      if (AllFonts[it.key()].ItalicAngleAsString() != "0")
01116                             pfl = pfl ^ 64;
01117 //                   pfl = pfl ^ 4;
01118                      pfl = pfl ^ 32;
01119                      PutDoc(QString::number(pfl)+"\n");
01120                      PutDoc("/Ascent "+AllFonts[it.key()].ascentAsString()+"\n");
01121                      PutDoc("/Descent "+AllFonts[it.key()].descentAsString()+"\n");
01122                      PutDoc("/CapHeight "+AllFonts[it.key()].capHeightAsString()+"\n");
01123                      PutDoc("/ItalicAngle "+AllFonts[it.key()].ItalicAngleAsString()+"\n");
01124 //                   PutDoc("/Ascent "+QString::number(static_cast<int>(AllFonts[it.key()].ascent()))+"\n");
01125 //                   PutDoc("/Descent "+QString::number(static_cast<int>(AllFonts[it.key()].descent()))+"\n");
01126 //                   PutDoc("/CapHeight "+QString::number(static_cast<int>(AllFonts[it.key()].capHeight()))+"\n");
01127 //                   PutDoc("/ItalicAngle "+AllFonts[it.key()].italicAngle()+"\n");
01128 //                   PutDoc("/StemV "+ AllFonts[it.key()].stemV() + "\n");
01129                      PutDoc("/StemV 1\n");
01130                      if ((fformat == ScFace::SFNT || fformat == ScFace::TTCF) && (Options.EmbedList.contains(it.key())))
01131                             PutDoc("/FontFile2 "+QString::number(ObjCounter-1)+" 0 R\n");
01132                      if ((fformat == ScFace::PFB) && (Options.EmbedList.contains(it.key())))
01133                             PutDoc("/FontFile "+QString::number(ObjCounter-1)+" 0 R\n");
01134                      if ((fformat == ScFace::PFA) && (Options.EmbedList.contains(it.key())))
01135                             PutDoc("/FontFile "+QString::number(ObjCounter-1)+" 0 R\n");
01136                      PutDoc(">>\nendobj\n");
01137                      ObjCounter++;
01138 /*                   if (!FT_Has_PS_Glyph_Names(AllFonts[it.key()])
01139                      {
01140                             StartObj(ObjCounter);
01141                             int chCount = 31;
01142                             PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ");
01143                             for (int ww = 31; ww < 256; ++ww)
01144                             {
01145                                    PutDoc(QString::number(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]*
01146                                                  1000))+" ");
01147                                    if (itg == gl.end())
01148                                           break;
01149                                    ++itg;
01150                                    chCount++;
01151                             }
01152                             PutDoc("]\nendobj\n");
01153                             ObjCounter++;
01154                             // put widths object
01155                             // encoding dictionary w/ base encoding w/o differences
01156                             StartObj(ObjCounter);
01157                             PutDoc("<<\n/Type /Font\n/Subtype ");
01158                             PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
01159                             PutDoc("/Name /Fo"+QString::number(a)+"\n");
01160                             PutDoc("/BaseFont /"+AllFonts[it.key()]->psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\<\>\\(\\)\\%]"), "" )+"\n");
01161                             //cf. widths:
01162                             PutDoc("/FirstChar 0\n");
01163                             PutDoc("/LastChar "+QString::number(chCount-1)+"\n");
01164                             PutDoc("/Widths "+QString::number(ObjCounter-1)+" 0 R\n");
01165                             PutDoc("/FontDescriptor "+QString::number(ObjCounter-2)+" 0 R\n");
01166                             PutDoc(">>\nendobj\n");
01167                             Seite.FObjects["Fo"+QString::number(a)] = ObjCounter;
01168                             ObjCounter++;
01169                      }
01170                      else */
01171 //                   {
01172                             QMap<uint,std::pair<QChar,QString> > gl;
01173                             AllFonts[it.key()].glyphNames(gl);
01174                             int nglyphs = 0;
01175                             QMap<uint,std::pair<QChar,QString> >::Iterator gli;
01176                             for (gli = gl.begin(); gli != gl.end(); ++gli)
01177                             {
01178                                    if (gli.key() > static_cast<uint>(nglyphs))
01179                                           nglyphs = gli.key();
01180                             }
01181                             ++nglyphs;
01182 //                          qDebug(QString("pdflib: nglyphs %1 max %2").arg(nglyphs).arg(AllFonts[it.key()].maxGlyph()));
01183                             uint FontDes = ObjCounter - 1;
01184                             uint Fcc = nglyphs / 224;
01185                             if ((nglyphs % 224) != 0)
01186                                    Fcc += 1;
01187                             for (uint Fc = 0; Fc < Fcc; ++Fc)
01188                             {
01189                                    StartObj(ObjCounter);
01190                                    int chCount = 32;
01191                                    PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
01192                                    for (int ww = 32; ww < 256; ++ww)
01193                                    {
01194                                           uint glyph = 224 * Fc + ww - 32;
01195                                           if (gl.contains(glyph))
01196                                                  PutDoc(QString::number(static_cast<int>(AllFonts[it.key()].glyphWidth(glyph)* 1000))+" ");
01197                                           else
01198                                                  PutDoc("0 ");
01199                                           chCount++;
01200                                           if (signed(glyph) == nglyphs-1)
01201                                                  break;
01202                                    }
01203                                    PutDoc("]\nendobj\n");
01204                                    ObjCounter++;
01205                                    StartObj(ObjCounter);
01206                                    ObjCounter++;
01207                                    QStringList toUnicodeMaps;
01208                                    QValueList<int> toUnicodeMapsCount;
01209                                    QString toUnicodeMap = "";
01210                                    int toUnicodeMapCounter = 0;
01211                                    PutDoc("<< /Type /Encoding\n");
01212                                    PutDoc("/Differences [ \n");
01213                                    int crc = 0;
01214                                    bool startOfSeq = true;
01215                                    for (int ww2 = 32; ww2 < 256; ++ww2)
01216                                    {
01217                                           uint glyph = 224 * Fc + ww2 - 32;
01218                                           if (gl[glyph].second != "")
01219                                           {
01220                                                  if (startOfSeq)
01221                                                  {
01222                                                         PutDoc(QString::number(ww2)+" ");
01223                                                         startOfSeq = false;
01224                                                  }
01225                                                  PutDoc("/"+gl[glyph].second+" ");
01226                                                  QString tmp, tmp2;
01227                                                  tmp.sprintf("%02X", ww2);
01228                                                  tmp2.sprintf("%04X", gl[glyph].first.unicode());
01229                                                  toUnicodeMap += QString("<%1> <%2>\n").arg(tmp).arg((tmp2));
01230                                                  toUnicodeMapCounter++;
01231                                                  if (toUnicodeMapCounter == 100)
01232                                                  {
01233                                                         toUnicodeMaps.append(toUnicodeMap);
01234                                                         toUnicodeMapsCount.append(toUnicodeMapCounter);
01235                                                         toUnicodeMap = "";
01236                                                         toUnicodeMapCounter = 0;
01237                                                  }
01238                                                  crc++;
01239                                           }
01240                                           else
01241                                           {
01242                                                  startOfSeq = true;
01243                                           }
01244                                           if (signed(glyph) == nglyphs-1)
01245                                                  break;
01246                                           if (crc > 8)
01247                                           {
01248                                                  PutDoc("\n");
01249                                                  crc = 0;
01250                                           }
01251                                    }
01252                                    if (toUnicodeMapCounter != 0)
01253                                    {
01254                                           toUnicodeMaps.append(toUnicodeMap);
01255                                           toUnicodeMapsCount.append(toUnicodeMapCounter);
01256                                    }
01257                                    PutDoc("]\n");
01258                                    PutDoc(">>\nendobj\n");
01259                                    QString toUnicodeMapStream = "";
01260                                    toUnicodeMapStream += "/CIDInit /ProcSet findresource begin\n";
01261                                    toUnicodeMapStream += "12 dict begin\n";
01262                                    toUnicodeMapStream += "begincmap\n";
01263                                    toUnicodeMapStream += "/CIDSystemInfo <<\n";
01264                                    toUnicodeMapStream += "/Registry (Adobe)\n";
01265                                    toUnicodeMapStream += "/Ordering (UCS)\n";
01266                                    toUnicodeMapStream += "/Supplement 0\n";
01267                                    toUnicodeMapStream += ">> def\n";
01268                                    toUnicodeMapStream += "/CMapName /Adobe-Identity-UCS def\n";
01269                                    toUnicodeMapStream += "/CMapType 2 def\n";
01270                                    toUnicodeMapStream += "1 begincodespacerange\n";
01271                                    toUnicodeMapStream += "<0000> <FFFF>\n";
01272                                    toUnicodeMapStream += "endcodespacerange\n";
01273                                    for (uint uniC = 0; uniC < toUnicodeMaps.count(); uniC++)
01274                                    {
01275                                           toUnicodeMapStream += QString("%1 beginbfchar\n").arg(toUnicodeMapsCount[uniC]);
01276                                           toUnicodeMapStream += toUnicodeMaps[uniC];
01277                                           toUnicodeMapStream += "endbfchar\n";
01278                                    }
01279                                    toUnicodeMapStream += "endcmap\n";
01280                                    toUnicodeMapStream += "CMapName currentdict /CMap defineresource pop\n";
01281                                    toUnicodeMapStream += "end\n";
01282                                    toUnicodeMapStream += "end\n";
01283                                    WritePDFStream(toUnicodeMapStream);
01284                                    StartObj(ObjCounter);
01285                                    PutDoc("<<\n/Type /Font\n/Subtype ");
01286                                    PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
01287                                    PutDoc("/Name /Fo"+QString::number(a)+"S"+QString::number(Fc)+"\n");
01288                                    PutDoc("/BaseFont /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
01289                                    PutDoc("/FirstChar 0\n");
01290                                    PutDoc("/LastChar "+QString::number(chCount-1)+"\n");
01291                                    PutDoc("/Widths "+QString::number(ObjCounter-3)+" 0 R\n");
01292                                    PutDoc("/Encoding "+QString::number(ObjCounter-2)+" 0 R\n");
01293                                    PutDoc("/ToUnicode "+QString::number(ObjCounter-1)+" 0 R\n");
01294                                    PutDoc("/FontDescriptor "+QString::number(FontDes)+" 0 R\n");
01295                                    PutDoc(">>\nendobj\n");
01296                                    Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(Fc)] = ObjCounter;
01297                                    ObjCounter++;
01298                             } // for(Fc)
01299                             StartObj(ObjCounter);
01300                             PutDoc("[ 0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 ");
01301                             for (int ww = 32; ww < 256; ++ww)
01302                             {
01303                                    uint glyph = AllFonts[it.key()].char2CMap(QChar(ww));
01304                                    if (gl.contains(glyph))
01305                                           PutDoc(QString::number(static_cast<int>(AllFonts[it.key()].glyphWidth(glyph)* 1000))+" ");
01306                                    else
01307                                           PutDoc("0 ");
01308                             }
01309                             PutDoc("]\nendobj\n");
01310                             ObjCounter++;
01311                             StartObj(ObjCounter);
01312                             PutDoc("<<\n/Type /Font\n/Subtype ");
01313                             PutDoc((fformat == ScFace::SFNT || fformat == ScFace::TTCF) ? "/TrueType\n" : "/Type1\n");
01314 //                          if (fformat == ScFace::SFNT || fformat == ScFace::TTCF)
01315 //                          {
01316 //                                 PutDoc("/TrueType\n");
01317                                    PutDoc("/Name /Fo"+QString::number(a)+"Form"+"\n");
01318                                    Seite.FObjects["Fo"+QString::number(a)+"Form"] = ObjCounter;
01319                                    UsedFontsF.insert(it.key(), "/Fo"+QString::number(a)+"Form");
01320 /*                          }
01321                             else
01322                             {
01323                                    PutDoc("/Type1\n");
01324                                    PutDoc("/Name /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\<\>\\(\\)\\%]"), "_" )+"\n");
01325                                    Seite.FObjects[AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\<\>\\(\\)\\%]"), "_" )] = ObjCounter;
01326                                    UsedFontsF.insert(it.key(), "/"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\<\>\\(\\)\\%]"), "_" ));
01327                             } */
01328                             PutDoc("/BaseFont /"+AllFonts[it.key()].psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n");
01329                             PutDoc("/Encoding << \n");
01330                             PutDoc("/Differences [ \n");
01331                             PutDoc("24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde\n");
01332                             PutDoc("39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright\n");
01333                             PutDoc("/minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /Lslash /OE /Scaron\n");
01334                             PutDoc("/Ydieresis /Zcaron /dotlessi /lslash /oe /scaron /zcaron 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot\n");
01335                             PutDoc("/.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine\n");
01336                             PutDoc("188 /onequarter /onehalf /threequarters 192 /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute /Ecircumflex\n");
01337                             PutDoc("/Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
01338                             PutDoc("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla\n");
01339                             PutDoc("/egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
01340                             PutDoc("/divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis\n");
01341                             PutDoc("] >>\n");
01342                             PutDoc("/FirstChar 0\n");
01343                             PutDoc("/LastChar 255\n");
01344                             PutDoc("/Widths "+QString::number(ObjCounter-1)+" 0 R\n");
01345                             PutDoc("/FontDescriptor "+QString::number(FontDes)+" 0 R\n");
01346                             PutDoc(">>\nendobj\n");
01347                             ObjCounter++;
01348 //                   } // FT_Has_PS_Glyph_Names
01349               }
01350               a++;
01351        }
01352        if (Options.UseLPI)
01353        {
01354               StartObj(ObjCounter);
01355               PutDoc("<<\n/Type /Halftone\n/HalftoneType 5\n");
01356               QMap<QString,LPIData>::const_iterator itlp;
01357               for (itlp = Options.LPISettings.constBegin(); itlp != Options.LPISettings.constEnd(); ++itlp)
01358               {
01359                      PutDoc("/"+itlp.key()+"\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency ");
01360                      PutDoc(QString::number(itlp.data().Frequency)+"\n/Angle "+QString::number(itlp.data().Angle)+"\n/SpotFunction ");
01361                      QString func ("");
01362                      switch (itlp.data().SpotFunc)
01363                      {
01364                             case 0:
01365                                    func = "/SimpleDot";
01366                                    break;
01367                             case 1:
01368                                    func = "/Line";
01369                                    break;
01370                             case 2:
01371                                    func = "/Round";
01372                                    break;
01373                             case 3:
01374                                    func = "/Ellipse";
01375                                    break;
01376                             default:
01377                                    func = "/SimpleDot";
01378                                    break;
01379                      }
01380                      PutDoc(func+"\n>>\n");
01381               }
01382               PutDoc("/Default\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency 50\n/Angle 45\n/SpotFunction /Round\n>>\n");
01383               PutDoc(">>\nendobj\n");
01384               ObjCounter++;
01385               StartObj(ObjCounter);
01386               HTName = ResNam+QString::number(ResCount);
01387               Transpar[HTName] = ObjCounter;
01388               PutDoc("<< /Type /ExtGState\n/HT "+QString::number(ObjCounter-1)+" 0 R\n>>\nendobj\n");
01389               ResCount++;
01390               ObjCounter++;
01391        }
01392        if ((doc.HasCMS) && (Options.UseProfiles))
01393        {
01394               StartObj(ObjCounter);
01395               ObjCounter++;
01396               QByteArray dataP;
01397               struct ICCD dataD;
01398               loadRawBytes(ScCore->InputProfiles[Options.SolidProf], dataP);
01399               PutDoc("<<\n");
01400               if ((Options.Compress) && (CompAvail))
01401               {
01402                      PutDoc("/Filter /FlateDecode\n");
01403                      dataP = CompressArray(&dataP);
01404               }
01405               PutDoc("/Length "+QString::number(dataP.size()+1)+"\n");
01406               PutDoc("/N "+QString::number(Options.SComp)+"\n");
01407               PutDoc(">>\nstream\n");
01408               PutDoc(EncStreamArray(dataP, ObjCounter-1));
01409               PutDoc("\nendstream\nendobj\n");
01410               StartObj(ObjCounter);
01411               dataD.ResName = ResNam+QString::number(ResCount);
01412               dataD.ICCArray = "[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]";
01413               dataD.ResNum = ObjCounter;
01414               ICCProfiles[Options.SolidProf] = dataD;
01415               PutDoc("[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]\n");
01416               PutDoc("endobj\n");
01417               ResCount++;
01418               ObjCounter++;
01419        }
01420        if (((Options.isGrayscale == false) && (Options.UseRGB == false)) && (Options.UseSpotColors))
01421        {
01422               doc.getUsedColors(colorsToUse);
01423               ColorList::Iterator itf;
01424               for (itf = colorsToUse.begin(); itf != colorsToUse.end(); ++itf)
01425               {
01426                      if ((colorsToUse[itf.key()].isSpotColor()) || (colorsToUse[itf.key()].isRegistrationColor()))
01427                      {
01428                             CMYKColor cmykValues;
01429                             int cc, cm, cy, ck;
01430                             struct SpotC spotD;
01431                             ScColorEngine::getCMYKValues(colorsToUse[itf.key()], &doc, cmykValues);
01432                             cmykValues.getValues(cc, cm, cy, ck);
01433                             QString colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255)+"\nmul exch dup ";
01434                             colorDesc += FToStr(static_cast<double>(cm) / 255)+"\nmul exch dup ";
01435                             colorDesc += FToStr(static_cast<double>(cy) / 255)+"\nmul exch ";
01436                             colorDesc += FToStr(static_cast<double>(ck) / 255)+" mul }";
01437                             StartObj(ObjCounter);
01438                             ObjCounter++;
01439                             PutDoc("<<\n/FunctionType 4\n");
01440                             PutDoc("/Domain [0.0 1.0]\n");
01441                             PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n");
01442                             PutDoc("/Length "+QString::number(colorDesc.length()+1)+"\n");
01443                             PutDoc(">>\nstream\n"+EncStream(colorDesc, ObjCounter-1)+"\nendstream\nendobj\n");
01444                             StartObj(ObjCounter);
01445                             PutDoc("[ /Separation /");
01446                             if (colorsToUse[itf.key()].isRegistrationColor())
01447                                    PutDoc("All");
01448                             else
01449                                    PutDoc(itf.key().simplifyWhiteSpace().replace("#", "#23").replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "#20" ));
01450                             PutDoc(" /DeviceCMYK "+QString::number(ObjCounter-1)+" 0 R ]\nendobj\n");
01451                             spotD.ResName = spotNam+QString::number(spotCount);
01452                             spotD.ResNum = ObjCounter;
01453                             spotMap.insert(itf.key(), spotD);
01454                             spotCount++;
01455                             ObjCounter++;
01456                      }
01457               }
01458        }
01459        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks) || (Options.docInfoMarks))
01460        {
01461               struct SpotC spotD;
01462               StartObj(ObjCounter);
01463               PutDoc("[ /Separation /All /DeviceCMYK\n");
01464               PutDoc("<<\n/FunctionType 2\n");
01465               PutDoc("/Domain [0.0 1.0]\n");
01466               PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n");
01467               PutDoc("/C0 [0 0 0 0] \n");
01468               PutDoc("/C1 [1 1 1 1] \n");
01469               PutDoc("/N 1\n");
01470               PutDoc(">>\n]\nendobj\n");
01471               spotD.ResName = spotNam+QString::number(spotCount);
01472               spotD.ResNum = ObjCounter;
01473               spotMapReg.insert("Register", spotD);
01474               spotCount++;
01475               ObjCounter++;
01476        }
01477        if ((Options.Version == 15) && (Options.useLayers))
01478        {
01479               struct Layer ll;
01480               struct OCGInfo ocg;
01481               ll.isPrintable = false;
01482               ll.LNr = 0;
01483               int Lnr = 0;
01484               QString ocgNam("oc");
01485               uint docLayersCount=doc.Layers.count();
01486               for (uint la = 0; la < docLayersCount; ++la)
01487               {
01488                      QString tmp("");
01489                      Level2Layer(&doc, &ll, Lnr);
01490                      ocg.Name = ocgNam+tmp.setNum(ll.LNr);
01491                      ocg.ObjNum = ObjCounter;
01492                      ocg.visible = ll.isViewable;
01493                      OCGEntries.insert(ll.Name, ocg);
01494                      StartObj(ObjCounter);
01495                      ObjCounter++;
01496                      PutDoc("<<\n");
01497                      PutDoc("/Type /OCG\n");
01498                      PutDoc("/Name ");
01499                      PutDoc(EncStringUTF16("("+ll.Name+")", ObjCounter-1));
01500                      PutDoc("\n");
01501                      PutDoc(">>\nendobj\n");
01502                      Lnr++;
01503               }
01504        }
01505        return true;
01506 }
01507 
01508 void PDFlib::PDF_TemplatePage(const Page* pag, bool )
01509 {
01510        QString tmp;
01511        ActPageP = pag;
01512        PageItem* ite;
01513        QPtrList<PageItem> PItems;
01514        int Lnr = 0;
01515        struct Layer ll;
01516        ll.isPrintable = false;
01517        ll.LNr = 0;
01518        Inhalt = "";
01519        Seite.AObjects.clear();
01520        for (uint la = 0; la < doc.Layers.count(); ++la)
01521        {
01522               Level2Layer(&doc, &ll, Lnr);
01523               PItems = doc.MasterItems;
01524               if (ll.isPrintable)
01525               {
01526                      if ((Options.Version == 15) && (Options.useLayers))
01527                             PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n");
01528                      for (uint a = 0; a < PItems.count(); ++a)
01529                      {
01530                             Inhalt = "";
01531                             ite =PItems.at(a);
01532                             if (ite->LayerNr != ll.LNr)
01533                                    continue;
01534                             double x = pag->xOffset();
01535                             double y = pag->yOffset();
01536                             double w = pag->width();
01537                             double h1 = pag->height();
01538                             double ilw=ite->lineWidth();
01539                             double x2 = ite->BoundingX - ilw / 2.0;
01540                             double y2 = ite->BoundingY - ilw / 2.0;
01541                             double w2 = ite->BoundingW + ilw;
01542                             double h2 = ite->BoundingH + ilw;
01543                             if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
01544                                    continue;
01545                             if (ite->ChangedMasterItem)
01546                                    continue;
01547                             if ((!pag->pageName().isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1))
01548                                    continue;
01549                             PutPage("q\n");
01550                             if ((ite->doOverprint) && (!Options.doOverprint) && (!Options.UseRGB))
01551                             {
01552                                    StartObj(ObjCounter);
01553                                    QString ShName = ResNam+QString::number(ResCount);
01554                                    Transpar[ShName] = ObjCounter;
01555                                    ResCount++;
01556                                    ObjCounter++;
01557                                    PutDoc("<< /Type /ExtGState\n");
01558                                    PutDoc("/OP true\n");
01559                                    PutDoc("/op true\n");
01560                                    PutDoc("/OPM 1\n");
01561                                    PutDoc(">>\nendobj\n");
01562                                    PutPage("/"+ShName+" gs\n");
01563                             }
01564 /* Bookmarks on Master Pages do not make any sense */
01565 //                          if ((ite->isBookmark) && (Options.Bookmarks))
01566 //                                 PDF_Bookmark(ite, pag->height() - (ite->yPos() - pag->yOffset()));
01567                             if (!ite->printEnabled() || ((ite->itemType() == PageItem::TextFrame) && (!pag->pageName().isEmpty())))
01568                             {
01569                                    PutPage("Q\n");
01570                                    continue;
01571                             }
01572                             if (ite->fillColor() != CommonStrings::None)
01573                                    PutPage(putColor(ite->fillColor(), ite->fillShade(), true));
01574                             if (ite->lineColor() != CommonStrings::None)
01575                                    PutPage(putColor(ite->lineColor(), ite->lineShade(), false));
01576                             Inhalt += FToStr(fabs(ite->lineWidth()))+" w\n";
01577                             if (ite->DashValues.count() != 0)
01578                             {
01579                                    PutPage("[ ");
01580                                    QValueList<double>::iterator it;
01581                                    for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it )
01582                                    {
01583                                           int da = static_cast<int>(*it);
01584                                           if (da != 0)
01585                                                  PutPage(QString::number(da)+" ");
01586                                    }
01587                                    PutPage("] "+QString::number(static_cast<int>(ite->DashOffset))+" d\n");
01588                             }
01589                             else
01590                             {
01591                                    QString Dt = FToStr(QMAX(2*fabs(ite->lineWidth()), 1));
01592                                    QString Da = FToStr(QMAX(6*fabs(ite->lineWidth()), 1));
01593                                    switch (ite->PLineArt)
01594                                    {
01595                                           case Qt::SolidLine:
01596                                                  PutPage("[] 0 d\n");
01597                                                  break;
01598                                           case Qt::DashLine:
01599                                                  PutPage("["+Da+" "+Dt+"] 0 d\n");
01600                                                  break;
01601                                           case Qt::DotLine:
01602                                                  PutPage("["+Dt+"] 0 d\n");
01603                                                  break;
01604                                           case Qt::DashDotLine:
01605                                                  PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n");
01606                                                  break;
01607                                           case Qt::DashDotDotLine:
01608                                                  PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n");
01609                                                  break;
01610                                           default:
01611                                                  PutPage("[] 0 d\n");
01612                                                  break;
01613                                    }
01614                             }
01615                             switch (ite->PLineEnd)
01616                             {
01617                                    case Qt::FlatCap:
01618                                           PutPage("0 J\n");
01619                                           break;
01620                                    case Qt::SquareCap:
01621                                           PutPage("2 J\n");
01622                                           break;
01623                                    case Qt::RoundCap:
01624                                           PutPage("1 J\n");
01625                                           break;
01626                                    default:
01627                                           PutPage("0 J\n");
01628                                           break;
01629                             }
01630                             switch (ite->PLineJoin)
01631                             {
01632                                    case Qt::MiterJoin:
01633                                           PutPage("0 j\n");
01634                                           break;
01635                                    case Qt::BevelJoin:
01636                                           PutPage("2 j\n");
01637                                           break;
01638                                    case Qt::RoundJoin:
01639                                           PutPage("1 j\n");
01640                                           break;
01641                                    default:
01642                                           PutPage("0 j\n");
01643                                           break;
01644                             }
01645                             PutPage("1 0 0 1 "+FToStr(ite->xPos() - pag->xOffset())+" "+FToStr(pag->height() - (ite->yPos()  - pag->yOffset()))+" cm\n");
01646                             if (ite->rotation() != 0)
01647                             {
01648                                    double sr = sin(-ite->rotation()* M_PI / 180.0);
01649                                    double cr = cos(-ite->rotation()* M_PI / 180.0);
01650                                    if ((cr * cr) < 0.000001)
01651                                           cr = 0;
01652                                    if ((sr * sr) < 0.000001)
01653                                           sr = 0;
01654                                    PutPage(FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n");
01655                             }
01656                             switch (ite->itemType())
01657                             {
01658                                    case PageItem::ImageFrame:
01659                                           if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
01660                                                  PutPage(PDF_TransparenzFill(ite));
01661                                           if ((ite->fillColor() != CommonStrings::None) || (ite->GrType != 0))
01662                                           {
01663                                                  if (ite->GrType != 0)
01664                                                         PutPage(PDF_Gradient(ite));
01665                                                  else
01666                                                  {
01667                                                         PutPage(SetClipPath(ite));
01668                                                         PutPage("h\nf*\n");
01669                                                  }
01670                                           }
01671                                           PutPage("q\n");
01672                                           if (ite->imageClip.size() != 0)
01673                                           {
01674                                                  PutPage(SetClipPathImage(ite));
01675                                                  PutPage("h\nW*\nn\n");
01676                                           }
01677                                           PutPage(SetClipPath(ite));
01678                                           PutPage("h\nW*\nn\n");
01679                                           if (ite->imageFlippedH())
01680                                                  PutPage("-1 0 0 1 "+FToStr(ite->width())+" 0 cm\n");
01681                                           if (ite->imageFlippedV())
01682                                                  PutPage("1 0 0 -1 0 "+FToStr(-ite->height())+" cm\n");
01683                                           if ((ite->PicAvail) && (!ite->Pfile.isEmpty()))
01684                                                  PutPage(PDF_Image(ite, ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), false, ite->IProfile, ite->UseEmbedded, ite->IRender));
01685                                           PutPage("Q\n");
01686                                           if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
01687                                           {
01688                                                  if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
01689                                                         PutPage(PDF_TransparenzStroke(ite));
01690                                                  if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
01691                                                  {
01692                                                         PutPage(SetClipPath(ite));
01693                                                         PutPage("h\nS\n");
01694                                                  }
01695                                                  else
01696                                                  {
01697                                                         multiLine ml = doc.MLineStyles[ite->NamedLStyle];
01698                                                         for (int it = ml.size()-1; it > -1; it--)
01699                                                         {
01700                                                                if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
01701                                                                {
01702                                                                       PutPage(setStrokeMulti(&ml[it]));
01703                                                                       PutPage(SetClipPath(ite));
01704                                                                       PutPage("h\nS\n");
01705                                                                }
01706                                                         }
01707                                                  }
01708                                           }
01709                                           break;
01710                                    case PageItem::TextFrame:
01711                                           break;
01712                                    case PageItem::Line:
01713                                           if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
01714                                                  PutPage(PDF_TransparenzStroke(ite));
01715                                           if (ite->NamedLStyle.isEmpty())
01716                                           {
01717                                                  PutPage("0 0 m\n");
01718                                                  PutPage(FToStr(ite->width())+" 0 l\n");
01719                                                  PutPage("S\n");
01720                                           }
01721                                           else
01722                                           {
01723                                                  multiLine ml = doc.MLineStyles[ite->NamedLStyle];
01724                                                  for (int it = ml.size()-1; it > -1; it--)
01725                                                  {
01726                                                                if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
01727                                                                {
01728                                                                       PutPage(setStrokeMulti(&ml[it]));
01729                                                                       PutPage("0 0 m\n");
01730                                                                       PutPage(FToStr(ite->width())+" 0 l\n");
01731                                                                       PutPage("S\n");
01732                                                                }
01733                                                  }
01734                                           }
01735                                           if (ite->startArrowIndex() != 0)
01736                                           {
01737                                                  QWMatrix arrowTrans;
01738                                                  FPointArray arrow = (*doc.arrowStyles.at(ite->startArrowIndex()-1)).points.copy();
01739                                                  arrowTrans.translate(0, 0);
01740                                                  arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
01741                                                  arrowTrans.scale(-1,1);
01742                                                  arrow.map(arrowTrans);
01743                                                  if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
01744                                                  {
01745                                                         StartObj(ObjCounter);
01746                                                         QString ShName = ResNam+QString::number(ResCount);
01747                                                         Transpar[ShName] = ObjCounter;
01748                                                         ResCount++;
01749                                                         ObjCounter++;
01750                                                         PutDoc("<< /Type /ExtGState\n");
01751                                                         PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
01752                                                         PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
01753                                                         PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
01754                                                         PutDoc("/BM /Normal\n>>\nendobj\n");
01755                                                         PutPage("/"+ShName+" gs\n");
01756                                                  }
01757                                                  PutPage(putColor(ite->lineColor(), ite->lineShade(), true));
01758                                                  PutPage(SetClipPathArray(&arrow));
01759                                                  PutPage("h\nf*\n");
01760                                           }
01761                                           if (ite->endArrowIndex() != 0)
01762                                           {
01763                                                  QWMatrix arrowTrans;
01764                                                  FPointArray arrow = (*doc.arrowStyles.at(ite->endArrowIndex()-1)).points.copy();
01765                                                  arrowTrans.translate(ite->width(), 0);
01766                                                  arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
01767                                                  arrow.map(arrowTrans);
01768                                                  if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
01769                                                  {
01770                                                         StartObj(ObjCounter);
01771                                                         QString ShName = ResNam+QString::number(ResCount);
01772                                                         Transpar[ShName] = ObjCounter;
01773                                                         ResCount++;
01774                                                         ObjCounter++;
01775                                                         PutDoc("<< /Type /ExtGState\n");
01776                                                         PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
01777                                                         PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
01778                                                         PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
01779                                                         PutDoc("/BM /Normal\n>>\nendobj\n");
01780                                                         PutPage("/"+ShName+" gs\n");
01781                                                  }
01782                                                  PutPage(putColor(ite->lineColor(), ite->lineShade(), true));
01783                                                  PutPage(SetClipPathArray(&arrow));
01784                                                  PutPage("h\nf*\n");
01785                                           }
01786                                           break;
01787                                    case PageItem::ItemType1:
01788                                    case PageItem::ItemType3:
01789                                    case PageItem::Polygon:
01790                                           if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
01791                                                  PutPage(PDF_TransparenzFill(ite));
01792                                           if (ite->GrType != 0)
01793                                                  PutPage(PDF_Gradient(ite));
01794                                           else
01795                                           {
01796                                                  if (ite->fillColor() != CommonStrings::None)
01797                                                  {
01798                                                         PutPage(SetClipPath(ite));
01799                                                         PutPage("h\nf*\n");
01800                                                  }
01801                                           }
01802                                           if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
01803                                           {
01804                                                  if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
01805                                                         PutPage(PDF_TransparenzStroke(ite));
01806                                                  if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
01807                                                  {
01808                                                         PutPage(SetClipPath(ite));
01809                                                         PutPage("h\nS\n");
01810                                                  }
01811                                                  else
01812                                                  {
01813                                                         multiLine ml = doc.MLineStyles[ite->NamedLStyle];
01814                                                         for (int it = ml.size()-1; it > -1; it--)
01815                                                         {
01816                                                                if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
01817                                                                {
01818                                                                       PutPage(setStrokeMulti(&ml[it]));
01819                                                                       PutPage(SetClipPath(ite));
01820                                                                       PutPage("h\nS\n");
01821                                                                }
01822                                                         }
01823                                                  }
01824                                           }
01825                                           break;
01826                                    case PageItem::PolyLine:
01827                                           if (ite->PoLine.size() > 4) // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
01828                                           {
01829                                                  if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
01830                                                         PutPage(PDF_TransparenzFill(ite));
01831                                                  if (ite->GrType != 0)
01832                                                         PutPage(PDF_Gradient(ite));
01833                                                  else
01834                                                  {
01835                                                         if (ite->fillColor() != CommonStrings::None)
01836                                                         {
01837                                                                PutPage(SetClipPath(ite));
01838                                                                PutPage("h\nf*\n");
01839                                                         }
01840                                                  }
01841                                           }
01842                                           if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
01843                                           {
01844                                                  if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
01845                                                         PutPage(PDF_TransparenzStroke(ite));
01846                                                  if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
01847                                                  {
01848                                                         PutPage(SetClipPath(ite, false));
01849                                                         PutPage("S\n");
01850                                                  }
01851                                                  else
01852                                                  {
01853                                                         multiLine ml = doc.MLineStyles[ite->NamedLStyle];
01854                                                         for (int it = ml.size()-1; it > -1; it--)
01855                                                         {
01856                                                                if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
01857                                                                {
01858                                                                       PutPage(setStrokeMulti(&ml[it]));
01859                                                                       PutPage(SetClipPath(ite, false));
01860                                                                       PutPage("S\n");
01861                                                                }
01862                                                         }
01863                                                  }
01864                                           }
01865                                           if (ite->startArrowIndex() != 0)
01866                                           {
01867                                                  FPoint Start = ite->PoLine.point(0);
01868                                                  for (uint xx = 1; xx < ite->PoLine.size(); xx += 2)
01869                                                  {
01870                                                         FPoint Vector = ite->PoLine.point(xx);
01871                                                         if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
01872                                                         {
01873                                                                double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
01874                                                                QWMatrix arrowTrans;
01875                                                                FPointArray arrow = (*doc.arrowStyles.at(ite->startArrowIndex()-1)).points.copy();
01876                                                                arrowTrans.translate(Start.x(), Start.y());
01877                                                                arrowTrans.rotate(r);
01878                                                                arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
01879                                                                arrow.map(arrowTrans);
01880                                                                if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
01881                                                                {
01882                                                                       StartObj(ObjCounter);
01883                                                                       QString ShName = ResNam+QString::number(ResCount);
01884                                                                       Transpar[ShName] = ObjCounter;
01885                                                                       ResCount++;
01886                                                                       ObjCounter++;
01887                                                                       PutDoc("<< /Type /ExtGState\n");
01888                                                                       PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
01889                                                                       PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
01890                                                                       PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
01891                                                                       PutDoc("/BM /Normal\n>>\nendobj\n");
01892                                                                       PutPage("/"+ShName+" gs\n");
01893                                                                }
01894                                                                PutPage(putColor(ite->lineColor(), ite->lineShade(), true));
01895                                                                PutPage(SetClipPathArray(&arrow));
01896                                                                PutPage("h\nf*\n");
01897                                                                break;
01898                                                         }
01899                                                  }
01900                                           }
01901                                           if (ite->endArrowIndex() != 0)
01902                                           {
01903                                                  FPoint End = ite->PoLine.point(ite->PoLine.size()-2);
01904                                                  for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2)
01905                                                  {
01906                                                         FPoint Vector = ite->PoLine.point(xx);
01907                                                         if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
01908                                                         {
01909                                                                double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
01910                                                                QWMatrix arrowTrans;
01911                                                                FPointArray arrow = (*doc.arrowStyles.at(ite->endArrowIndex()-1)).points.copy();
01912                                                                arrowTrans.translate(End.x(), End.y());
01913                                                                arrowTrans.rotate(r);
01914                                                                arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
01915                                                                arrow.map(arrowTrans);
01916                                                                if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
01917                                                                {
01918                                                                       StartObj(ObjCounter);
01919                                                                       QString ShName = ResNam+QString::number(ResCount);
01920                                                                       Transpar[ShName] = ObjCounter;
01921                                                                       ResCount++;
01922                                                                       ObjCounter++;
01923                                                                       PutDoc("<< /Type /ExtGState\n");
01924                                                                       PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
01925                                                                       PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
01926                                                                       PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
01927                                                                       PutDoc("/BM /Normal\n>>\nendobj\n");
01928                                                                       PutPage("/"+ShName+" gs\n");
01929                                                                }
01930                                                                PutPage(putColor(ite->lineColor(), ite->lineShade(), true));
01931                                                                PutPage(SetClipPathArray(&arrow));
01932                                                                PutPage("h\nf*\n");
01933                                                                break;
01934                                                         }
01935                                                  }
01936                                           }
01937                                           break;
01938                                    case PageItem::PathText:
01939                                           if (ite->PoShow)
01940                                           {
01941                                                  if (ite->PoLine.size() > 3)
01942                                                  {
01943                                                         PutPage("q\n");
01944                                                         if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
01945                                                         {
01946                                                                if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
01947                                                                       PutPage(PDF_TransparenzStroke(ite));
01948                                                                if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
01949                                                                {
01950                                                                       PutPage(SetClipPath(ite, false));
01951                                                                       PutPage("S\n");
01952                                                                }
01953                                                                else
01954                                                                {
01955                                                                       multiLine ml = doc.MLineStyles[ite->NamedLStyle];
01956                                                                       for (int it = ml.size()-1; it > -1; it--)
01957                                                                       {
01958                                                                              if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
01959                                                                              {
01960                                                                                     PutPage(setStrokeMulti(&ml[it]));
01961                                                                                     PutPage(SetClipPath(ite, false));
01962                                                                                     PutPage("S\n");
01963                                                                              }
01964                                                                       }
01965                                                                }
01966                                                         }
01967                                                         PutPage("Q\n");
01968                                                  }
01969                                           }
01970                                           if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
01971                                                  PutPage(PDF_TransparenzFill(ite));
01972                                           PutPage(setTextSt(ite, pag->pageNr(), pag));
01973                                           break;
01974                                    case PageItem::Multiple:
01975                                           Q_ASSERT(false);
01976                                           break;
01977                                    }
01978                             PutPage("Q\n");
01979                             StartObj(ObjCounter);
01980                             ObjCounter++;
01981                             PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
01982                             PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n");
01983                             PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
01984                             if (Seite.ImgObjects.count() != 0)
01985                             {
01986                                    PutDoc("/XObject <<\n");
01987                                    QMap<QString,int>::Iterator it;
01988                                    for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
01989                                           PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
01990                                    PutDoc(">>\n");
01991                             }
01992                             if (Seite.FObjects.count() != 0)
01993                             {
01994                                    PutDoc("/Font << \n");
01995                                    QMap<QString,int>::Iterator it2;
01996                                    for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
01997                                           PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
01998                                    PutDoc(">>\n");
01999                             }
02000                             if (Shadings.count() != 0)
02001                             {
02002                                    PutDoc("/Shading << \n");
02003                                    QMap<QString,int>::Iterator it3;
02004                                    for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
02005                                           PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
02006                                    PutDoc(">>\n");
02007                             }
02008                             if (Patterns.count() != 0)
02009                             {
02010                                    PutDoc("/Pattern << \n");
02011                                    QMap<QString,int>::Iterator it3p;
02012                                    for (it3p = Patterns.begin(); it3p != Patterns.end(); ++it3p)
02013                                           PutDoc("/"+it3p.key()+" "+QString::number(it3p.data())+" 0 R\n");
02014                                    PutDoc(">>\n");
02015                             }
02016                             if (Transpar.count() != 0)
02017                             {
02018                                    PutDoc("/ExtGState << \n");
02019                                    QMap<QString,int>::Iterator it3t;
02020                                    for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
02021                                           PutDoc("/"+it3t.key()+" "+QString::number(it3t.data())+" 0 R\n");
02022                                    PutDoc(">>\n");
02023                             }
02024                             if ((ICCProfiles.count() != 0) || (spotMap.count() != 0))
02025                             {
02026                                    PutDoc("/ColorSpace << \n");
02027                                    QMap<QString,ICCD>::Iterator it3c;
02028                                    if (ICCProfiles.count() != 0)
02029                                    {
02030                                           for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
02031                                                  PutDoc("/"+it3c.data().ResName+" "+QString::number(it3c.data().ResNum)+" 0 R\n");
02032                                    }
02033                                    QMap<QString,SpotC>::Iterator it3sc;
02034                                    if (spotMap.count() != 0)
02035                                    {
02036                                    for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
02037                                           PutDoc("/"+it3sc.data().ResName+" "+QString::number(it3sc.data().ResNum)+" 0 R\n");
02038                                    }
02039                                    PutDoc(">>\n");
02040                             }
02041                             PutDoc(">>\n");
02042                             if ((Options.Compress) && (CompAvail))
02043                                    Inhalt = CompressStr(&Inhalt);
02044                             PutDoc("/Length "+QString::number(Inhalt.length()+1));
02045                             if ((Options.Compress) && (CompAvail))
02046                                    PutDoc("\n/Filter /FlateDecode");
02047                             PutDoc(" >>\nstream\n"+EncStream(Inhalt, ObjCounter-1)+"\nendstream\nendobj\n");
02048                             QString name = pag->pageName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + QString::number(ite->ItemNr);
02049                             Seite.XObjects[name] = ObjCounter-1;
02050                             }
02051                             if ((Options.Version == 15) && (Options.useLayers))
02052                                    PutPage("EMC\n");
02053                      }
02054               Lnr++;
02055        }
02056 }
02057 
02058 void PDFlib::PDF_Begin_Page(const Page* pag, QPixmap pm)
02059 {
02060        QString tmp;
02061        ActPageP = pag;
02062        Inhalt = "";
02063        Seite.AObjects.clear();
02064        if (Options.Thumbnails)
02065        {
02066               ScImage img(pm.convertToImage());
02067               QByteArray array = img.ImageToArray();
02068               if ((Options.Compress) && (CompAvail))
02069                      array = CompressArray(&array);
02070               StartObj(ObjCounter);
02071               PutDoc("<<\n/Width "+QString::number(img.width())+"\n");
02072               PutDoc("/Height "+QString::number(img.height())+"\n");
02073               PutDoc("/ColorSpace /DeviceRGB\n/BitsPerComponent 8\n");
02074               
02075               PutDoc("/Length "+QString::number(array.size()+1)+"\n");
02076               if ((Options.Compress) && (CompAvail))
02077                      PutDoc("/Filter /FlateDecode\n");
02078               PutDoc(">>\nstream\n");
02079               PutDoc(EncStreamArray(array, ObjCounter));
02080               PutDoc("\nendstream\nendobj\n");
02081               Seite.Thumb = ObjCounter;
02082               ObjCounter++;
02083        }
02084 }
02085 
02086 void PDFlib::PDF_End_Page()
02087 {
02088        uint PgNr =  ActPageP->pageNr();
02089        double markOffs = 0.0;
02090        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks) || (Options.docInfoMarks))
02091               markOffs = 20.0 + Options.markOffset;
02092        double bleedRight;
02093        double bleedLeft;
02094        if (doc.pageSets[doc.currentPageLayout].Columns == 1)
02095        {
02096               bleedRight = Options.bleeds.Right;
02097               bleedLeft = Options.bleeds.Left;
02098        }
02099        else
02100        {
02101               if (doc.locationOfPage(ActPageP->pageNr()) == LeftPage)
02102               {
02103                      bleedRight = Options.bleeds.Left;
02104                      bleedLeft = Options.bleeds.Right;
02105               }
02106               else if (doc.locationOfPage(ActPageP->pageNr()) == RightPage)
02107               {
02108                      bleedRight = Options.bleeds.Right;
02109                      bleedLeft = Options.bleeds.Left;
02110               }
02111               else
02112               {
02113                      bleedRight = Options.bleeds.Left;
02114                      bleedLeft = Options.bleeds.Left;
02115               }
02116        }
02117        double maxBoxX = ActPageP->width()+bleedLeft+bleedRight+markOffs*2.0;
02118        double maxBoxY = ActPageP->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
02119        PutPage("Q\n");
02120        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks) || (Options.docInfoMarks))
02121        {
02122               PutPage("0.5 w 0 j 0 J [] 0 d\n");
02123               PutPage("/"+spotMapReg["Register"].ResName+" CS 1 SCN\n");
02124               if (Options.cropMarks)
02125               {
02126               // Bottom Left
02127                      PutPage("0 "+FToStr(markOffs+Options.bleeds.Bottom)+" m\n");
02128                      PutPage(FToStr(20.0)+" "+FToStr(markOffs+Options.bleeds.Bottom)+" l\n");
02129                      PutPage("S\n");
02130                      PutPage(FToStr(markOffs+bleedLeft)+" 0 m\n");
02131                      PutPage(FToStr(markOffs+bleedLeft)+" 20 l\n");
02132                      PutPage("S\n");
02133               // Top Left
02134                      PutPage("0 "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
02135                      PutPage(FToStr(20.0)+" "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+" l\n");
02136                      PutPage("S\n");
02137                      PutPage(FToStr(markOffs+bleedLeft)+" "+FToStr(maxBoxY)+" m\n");
02138                      PutPage(FToStr(markOffs+bleedLeft)+" "+FToStr(maxBoxY-20.0)+" l\n");
02139                      PutPage("S\n");
02140               // Bottom Right
02141                      PutPage(FToStr(maxBoxX)+" "+FToStr(markOffs+Options.bleeds.Bottom)+" m\n");
02142                      PutPage(FToStr(maxBoxX-20.0)+" "+FToStr(markOffs+Options.bleeds.Bottom)+" l\n");
02143                      PutPage("S\n");
02144                      PutPage(FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(0.0)+" m\n");
02145                      PutPage(FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(20.0)+" l\n");
02146                      PutPage("S\n");
02147               // Top Right
02148                      PutPage(FToStr(maxBoxX)+" "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
02149                      PutPage(FToStr(maxBoxX-20.0)+" "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+" l\n");
02150                      PutPage("S\n");
02151                      PutPage(FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(maxBoxY)+" m\n");
02152                      PutPage(FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(maxBoxY-20.0)+" l\n");
02153                      PutPage("S\n");
02154               }
02155               if (Options.bleedMarks)
02156               {
02157                      PutPage("q\n");
02158                      PutPage("[3 1 1 1] 0 d\n");
02159               // Bottom Left
02160                      PutPage("0 "+FToStr(markOffs)+" m\n");
02161                      PutPage(FToStr(20.0)+" "+FToStr(markOffs)+" l\n");
02162                      PutPage("S\n");
02163                      PutPage(FToStr(markOffs)+" 0 m\n");
02164                      PutPage(FToStr(markOffs)+" 20 l\n");
02165                      PutPage("S\n");
02166               // Top Left
02167                      PutPage("0 "+FToStr(maxBoxY-markOffs)+" m\n");
02168                      PutPage(FToStr(20.0)+" "+FToStr(maxBoxY-markOffs)+" l\n");
02169                      PutPage("S\n");
02170                      PutPage(FToStr(markOffs)+" "+FToStr(maxBoxY)+" m\n");
02171                      PutPage(FToStr(markOffs)+" "+FToStr(maxBoxY-20.0)+" l\n");
02172                      PutPage("S\n");
02173               // Bottom Right
02174                      PutPage(FToStr(maxBoxX)+" "+FToStr(markOffs)+" m\n");
02175                      PutPage(FToStr(maxBoxX-20.0)+" "+FToStr(markOffs)+" l\n");
02176                      PutPage("S\n");
02177                      PutPage(FToStr(maxBoxX-markOffs)+" "+FToStr(0.0)+" m\n");
02178                      PutPage(FToStr(maxBoxX-markOffs)+" "+FToStr(20.0)+" l\n");
02179                      PutPage("S\n");
02180               // Top Right
02181                      PutPage(FToStr(maxBoxX)+" "+FToStr(maxBoxY-markOffs)+" m\n");
02182                      PutPage(FToStr(maxBoxX-20.0)+" "+FToStr(maxBoxY-markOffs)+" l\n");
02183                      PutPage("S\n");
02184                      PutPage(FToStr(maxBoxX-markOffs)+" "+FToStr(maxBoxY)+" m\n");
02185                      PutPage(FToStr(maxBoxX-markOffs)+" "+FToStr(maxBoxY-20.0)+" l\n");
02186                      PutPage("S\n");
02187                      PutPage("Q\n");
02188               }
02189               if (Options.registrationMarks)
02190               {
02191                      QString regCross = "0 7 m\n14 7 l\nh\n7 0 m\n7 14 l\nh\n13 7 m\n13 10.31383 10.31383 13 7 13 c\n3.68629 13 1 10.31383 1 7 c\n1 3.68629 3.68629 1 7 1 c\n";
02192                      regCross += "10.31383 1 13 3.68629 13 7 c\nh\n10.5 7 m\n10.5 8.93307 8.93307 10.5 7 10.5 c\n5.067 10.5 3.5 8.93307 3.5 7 c\n";
02193                      regCross += "3.5 5.067 5.067 3.5 7 3.5 c\n8.93307 3.5 10.5 5.067 10.5 7 c\nh\nS\n";
02194                      PutPage("q\n");
02195                      PutPage("1 0 0 1 "+FToStr(maxBoxX / 2.0 - 7.0)+" 3 cm\n");
02196                      PutPage(regCross);
02197                      PutPage("Q\n");
02198                      PutPage("q\n");
02199                      PutPage("1 0 0 1 3 "+FToStr(maxBoxY / 2.0 + 7.0)+" cm\n");
02200                      PutPage(regCross);
02201                      PutPage("Q\n");
02202                      PutPage("q\n");
02203                      PutPage("1 0 0 1 "+FToStr(maxBoxX / 2.0 - 7.0)+" "+FToStr(maxBoxY - 17.0)+" cm\n");
02204                      PutPage(regCross);
02205                      PutPage("Q\n");
02206                      PutPage("q\n");
02207                      PutPage("1 0 0 1 "+FToStr(maxBoxX - 17.0)+" "+FToStr(maxBoxY / 2.0 + 7.0)+" cm\n");
02208                      PutPage(regCross);
02209                      PutPage("Q\n");
02210               }
02211               if (Options.colorMarks)
02212               {
02213                      double startX = markOffs+bleedLeft+6.0;
02214                      double startY = maxBoxY - 18.0;
02215                      PutPage("0 0 0 1 K\n");
02216                      double col = 1.0;
02217                      for (int bl = 0; bl < 11; bl++)
02218                      {
02219                             PutPage("0 0 0 "+FToStr(col)+" k\n");
02220                             PutPage(FToStr(startX+bl*14.0)+" "+FToStr(startY)+" 14 14 re B\n");
02221                             col -= 0.1;
02222                      }
02223                      if (!Options.isGrayscale)
02224                      {
02225                             startX = maxBoxX-bleedRight-markOffs-20.0;
02226                             PutPage("0 0 0 0.5 k\n");
02227                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02228                             startX -= 14.0;
02229                             PutPage("0 0 0.5 0 k\n");
02230                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02231                             startX -= 14.0;
02232                             PutPage("0 0.5 0 0 k\n");
02233                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02234                             startX -= 14.0;
02235                             PutPage("0.5 0 0 0 k\n");
02236                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02237                             startX -= 14.0;
02238                             PutPage("1 1 0 0 k\n");
02239                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02240                             startX -= 14.0;
02241                             PutPage("1 0 1 0 k\n");
02242                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02243                             startX -= 14.0;
02244                             PutPage("0 1 1 0 k\n");
02245                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02246                             startX -= 14.0;
02247                             PutPage("0 0 0 1 k\n");
02248                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02249                             startX -= 14.0;
02250                             PutPage("0 0 1 0 k\n");
02251                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02252                             startX -= 14.0;
02253                             PutPage("0 1 0 0 k\n");
02254                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02255                             startX -= 14.0;
02256                             PutPage("1 0 0 0 k\n");
02257                             PutPage(FToStr(startX)+" "+FToStr(startY)+" 14 14 re B\n");
02258                      }
02259               }
02260               if (Options.docInfoMarks)
02261               {
02262                      QString tmp = "";
02263                      double startX = markOffs+bleedLeft+10.0;
02264                      QString docTitle = doc.documentInfo.getTitle();
02265                      if (docTitle.isEmpty())
02266                      {
02267                             QFileInfo fi(doc.DocName);
02268                             docTitle = fi.fileName();
02269                      }
02270                      docTitle += "  "+ tr("Page:")+" "+tmp.setNum(PgNr+1);
02271                      PutPage("/"+spotMapReg["Register"].ResName+" cs 1 scn\n");
02272                      PutPage("q\n");
02273                      PutPage("1 0 0 1 "+FToStr(startX)+" 6 cm\n");
02274                      PutPage("BT\n");
02275                      PutPage("/"+StdFonts["/Helvetica"]+" 7 Tf\n");
02276                      PutPage(EncString("("+docTitle+")",ObjCounter)+" Tj\nET\n");
02277                      PutPage("Q\n");
02278                      PutPage("q\n");
02279                      PutPage("1 0 0 1 "+FToStr(maxBoxX / 2.0 + 20.0)+" 6 cm\n");
02280                      PutPage("BT\n");
02281                      PutPage("/"+StdFonts["/Helvetica"]+" 7 Tf\n");
02282                      QDate d = QDate::currentDate();
02283                      PutPage(EncString("("+ tr("Date:")+" "+d.toString(Qt::TextDate)+")",ObjCounter)+" Tj\nET\n");
02284                      PutPage("Q\n");
02285               }
02286        }
02287        Seite.ObjNum = ObjCounter;
02288        WritePDFStream(Inhalt);
02289        int Gobj = 0;
02290        if (Options.Version >= 14)
02291        {
02292               StartObj(ObjCounter);
02293               Gobj = ObjCounter;
02294               ObjCounter++;
02295               PutDoc("<< /S /Transparency\n");
02296               if (Options.UseRGB)
02297                      PutDoc("/CS /DeviceRGB\n");
02298               else
02299               {
02300                      if (Options.isGrayscale)
02301                             PutDoc("/CS /DeviceGray\n");
02302                      else
02303                      {
02304                             if ((doc.HasCMS) && (Options.UseProfiles))
02305                                    PutDoc("/CS "+ICCProfiles[Options.SolidProf].ICCArray+"\n");
02306                             else
02307                                    PutDoc("/CS /DeviceCMYK\n");
02308                      }
02309               }
02310               PutDoc(">>\nendobj\n");
02311        }
02312        StartObj(ObjCounter);
02313        PutDoc("<<\n/Type /Page\n/Parent 4 0 R\n");
02314        PutDoc("/MediaBox [0 0 "+FToStr(maxBoxX)+" "+FToStr(maxBoxY)+"]\n");
02315        PutDoc("/BleedBox ["+FToStr(markOffs)+" "+FToStr(markOffs)+" "+FToStr(maxBoxX-markOffs)+" "+FToStr(maxBoxY-markOffs)+"]\n");
02316        PutDoc("/CropBox [0 0 "+FToStr(maxBoxX)+" "+FToStr(maxBoxY)+"]\n");
02317        PutDoc("/TrimBox ["+FToStr(bleedLeft+markOffs)+" "+FToStr(Options.bleeds.Bottom+markOffs)+" "+FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+"]\n");
02318        PutDoc("/ArtBox ["+FToStr(bleedLeft+markOffs)+" "+FToStr(Options.bleeds.Bottom+markOffs)+" "+FToStr(maxBoxX-bleedRight-markOffs)+" "+FToStr(maxBoxY-Options.bleeds.Top-markOffs)+"]\n");
02319        PutDoc("/Rotate "+QString::number(Options.RotateDeg)+"\n");
02320        PutDoc("/Contents "+QString::number(Seite.ObjNum)+" 0 R\n");
02321        if (Options.Version >= 14) // && (Transpar.count() != 0))
02322               PutDoc("/Group "+QString::number(Gobj)+" 0 R\n");
02323        if (Options.Thumbnails)
02324               PutDoc("/Thumb "+QString::number(Seite.Thumb)+" 0 R\n");
02325        if (Seite.AObjects.count() != 0)
02326        {
02327               PutDoc("/Annots [ ");
02328               for (uint b = 0; b < Seite.AObjects.count(); ++b)
02329                      PutDoc(QString::number(Seite.AObjects[b])+" 0 R ");
02330               PutDoc("]\n");
02331        }
02332        if (Options.PresentMode)
02333        {
02334               if (Options.PresentVals[PgNr].pageViewDuration > 0)
02335                      PutDoc("/Dur "+QString::number(Options.PresentVals[PgNr].pageViewDuration)+"\n");
02336               if (Options.PresentVals[PgNr].effectType != 0)
02337               {
02338                      PutDoc("/Trans << /Type /Trans\n");
02339                      PutDoc("/D "+QString::number(Options.PresentVals[PgNr].pageEffectDuration)+"\n");
02340                      switch (Options.PresentVals[PgNr].effectType)
02341                      {
02342                             case 1:
02343                                    PutDoc("/S /Blinds\n");
02344                                    PutDoc(Options.PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n");
02345                                    break;
02346                             case 2:
02347                                    PutDoc("/S /Box\n");
02348                                    PutDoc(Options.PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n");
02349                                    break;
02350                             case 3:
02351                                    PutDoc("/S /Dissolve\n");
02352                                    break;
02353                             case 4:
02354                                    PutDoc("/S /Glitter\n");
02355                                    PutDoc("/Di ");
02356                                    switch (Options.PresentVals[PgNr].Di)
02357                                    {
02358                                           case 0:
02359                                                  PutDoc("0");
02360                                                  break;
02361                                           case 1:
02362                                                  PutDoc("270");
02363                                                  break;
02364                                           case 4:
02365                                                  PutDoc("315");
02366                                                  break;
02367                                           default:
02368                                                  PutDoc("0");
02369                                                  break;
02370                                    }
02371                                    PutDoc("\n");
02372                                    break;
02373                             case 5:
02374                                    PutDoc("/S /Split\n");
02375                                    PutDoc(Options.PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n");
02376                                    PutDoc(Options.PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n");
02377                                    break;
02378                             case 6:
02379                                    PutDoc("/S /Wipe\n");
02380                                    PutDoc("/Di ");
02381                                    switch (Options.PresentVals[PgNr].Di)
02382                                    {
02383                                           case 0:
02384                                                  PutDoc("0");
02385                                                  break;
02386                                           case 1:
02387                                                  PutDoc("270");
02388                                                  break;
02389                                           case 2:
02390                                                  PutDoc("90");
02391                                                  break;
02392                                           case 3:
02393                                                  PutDoc("180");
02394                                                  break;
02395                                           default:
02396                                                  PutDoc("0");
02397                                                  break;
02398                                    }
02399                                    PutDoc("\n");
02400                                    break;
02401                      }
02402                      PutDoc(">>\n");
02403               }
02404        }
02405        PutDoc(">>\nendobj\n");
02406        PageTree.Count++;
02407        PageTree.Kids.append(ObjCounter);
02408        ObjCounter++;
02409 }
02410 
02411 void PDFlib::PDF_ProcessPage(const Page* pag, uint PNr, bool clip)
02412 {
02413        QPtrStack<PageItem> groupStack;
02414        QPtrStack<PageItem> groupStackS;
02415        QValueStack<QString> groupDataStack;
02416        QString tmp;
02417        ActPageP = pag;
02418        PageItem* ite;
02419        QPtrList<PageItem> PItems;
02420        int Lnr = 0;
02421        struct Layer ll;
02422        ll.isPrintable = false;
02423        ll.LNr = 0;
02424        if (Options.UseLPI)
02425               PutPage("/"+HTName+" gs\n");
02426        double bleedRight = 0.0;
02427        double bleedLeft = 0.0;
02428        double markOffs = 0.0;
02429        bleedDisplacementX = 0.0;
02430        bleedDisplacementY = 0.0;
02431        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks) || (Options.docInfoMarks))
02432               markOffs = 20.0 + Options.markOffset;
02433        if (!pag->MPageNam.isEmpty())
02434        {
02435               if (doc.pageSets[doc.currentPageLayout].Columns == 1)
02436               {
02437                      bleedRight = Options.bleeds.Right;
02438                      bleedLeft = Options.bleeds.Left;
02439               }
02440               else
02441               {
02442                      if (doc.locationOfPage(ActPageP->pageNr()) == LeftPage)
02443                      {
02444                             bleedRight = Options.bleeds.Left;
02445                             bleedLeft = Options.bleeds.Right;
02446                      }
02447                      else if (doc.locationOfPage(ActPageP->pageNr()) == RightPage)
02448                      {
02449                             bleedRight = Options.bleeds.Right;
02450                             bleedLeft = Options.bleeds.Left;
02451                      }
02452                      else
02453                      {
02454                             bleedRight = Options.bleeds.Left;
02455                             bleedLeft = Options.bleeds.Left;
02456                      }
02457               }
02458               PutPage("q 1 0 0 1 "+FToStr(bleedLeft+markOffs)+" "+FToStr(Options.bleeds.Bottom+markOffs)+" cm\n");
02459               bleedDisplacementX = bleedLeft+markOffs;
02460               bleedDisplacementY = Options.bleeds.Bottom+markOffs;
02461        }
02462        if ( (Options.MirrorH) && (!pag->MPageNam.isEmpty()) )
02463               PutPage("-1 0 0 1 "+FToStr(ActPageP->width())+" 0 cm\n");
02464        if ( (Options.MirrorV) && (!pag->MPageNam.isEmpty()) )
02465               PutPage("1 0 0 -1 0 "+FToStr(ActPageP->height())+" cm\n");
02466        if (clip)
02467        {
02468               PutPage(FToStr(pag->Margins.Left) + " " + FToStr(pag->Margins.Bottom) + " m\n");
02469               PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(pag->Margins.Bottom) + " l\n");
02470               PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l\n");
02471               PutPage(FToStr(pag->Margins.Left) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l h W n\n");
02472        }
02473        else
02474        {
02475               double maxBoxX = ActPageP->width()+bleedRight+bleedLeft;
02476               double maxBoxY = ActPageP->height()+Options.bleeds.Top+Options.bleeds.Bottom;
02477               PutPage(FToStr(-bleedLeft)+" "+FToStr(-Options.bleeds.Bottom)+" "+FToStr(maxBoxX)+" "+FToStr(maxBoxY)+" re W n\n");
02478        }
02479        if (!pag->MPageNam.isEmpty())
02480        {
02481               Page* mPage = doc.MasterPages.at(doc.MasterNames[doc.Pages->at(PNr)->MPageNam]);
02482               if (doc.MasterItems.count() != 0)
02483               {
02484                      if (!Options.MirrorH)
02485                             PutPage("1 0 0 1 0 0 cm\n");
02486                      for (uint lam = 0; lam < doc.Layers.count(); ++lam)
02487                      {
02488                             Level2Layer(&doc, &ll, Lnr);
02489                             Lnr++;
02490                             if (ll.isPrintable)
02491                             {
02492                                    if ((Options.Version == 15) && (Options.useLayers))
02493                                           PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n");
02494                                    for (uint am = 0; am < pag->FromMaster.count(); ++am)
02495                                    {
02496                                           ite = pag->FromMaster.at(am);
02497                                           if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled()))
02498                                                  continue;
02499                                           if ((!pag->pageName().isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1))
02500                                                  continue;
02501                                           QString name = "/"+pag->MPageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + QString::number(ite->ItemNr);
02502                                           if (ite->isGroupControl)
02503                                           {
02504                                                  PutPage("q\n");
02505                                                  FPointArray cl = ite->PoLine.copy();
02506                                                  FPointArray clb = ite->PoLine.copy();
02507                                                  QWMatrix mm;
02508                                                  mm.translate(ite->xPos() - mPage->xOffset(), (ite->yPos() - mPage->yOffset()) - mPage->height());
02509                                                  mm.rotate(ite->rotation());
02510                                                  cl.map( mm );
02511                                                  ite->PoLine = cl;
02512                                                  PutPage(SetClipPath(ite));
02513                                                  PutPage("h W* n\n");
02514                                                  groupStack.push(ite->groupsLastItem);
02515                                                  ite->PoLine = clb.copy();
02516                                                  continue;
02517                                           }
02518                                           if (! ite->asTextFrame())
02519                                                  PutPage(name+" Do\n");
02520                                           else
02521                                           {
02522                                                  double oldX = ite->xPos();
02523                                                  double oldY = ite->yPos();
02524                                                  double OldBX = ite->BoundingX;
02525                                                  double OldBY = ite->BoundingY;
02526                                                  ite->setXPos(ite->xPos() - mPage->xOffset() + pag->xOffset(), true);
02527                                                  ite->setYPos(ite->yPos() - mPage->yOffset() + pag->yOffset(), true);
02528                                                  PutPage(PDF_ProcessItem(ite, pag, pag->pageNr()));
02529                                                  ite->setXYPos(oldX, oldY, true);
02530                                                  ite->BoundingX = OldBX;
02531                                                  ite->BoundingY = OldBY;
02532                                           }
02533                                           if (groupStack.count() != 0)
02534                                           {
02535                                                  while (ite == groupStack.top())
02536                                                  {
02537                                                         PutPage("Q\n");
02538                                                         groupStack.pop();
02539                                                  }
02540                                           }
02541                                    }
02542                                    for (uint am = 0; am < pag->FromMaster.count(); ++am)
02543                                    {
02544                                           ite = pag->FromMaster.at(am);
02545                                           if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled()))
02546                                                  continue;
02547                                           if (ite->ChangedMasterItem)
02548                                                  continue;
02549                                           if ((!pag->pageName().isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1))
02550                                                  continue;
02551                                           if (!ite->isTableItem)
02552                                                  continue;
02553                                           double oldX = ite->xPos();
02554                                           double oldY = ite->yPos();
02555                                           double OldBX = ite->BoundingX;
02556                                           double OldBY = ite->BoundingY;
02557                                           ite->setXPos(ite->xPos() - mPage->xOffset() + pag->xOffset(), true);
02558                                           ite->setYPos(ite->yPos() - mPage->yOffset() + pag->yOffset(), true);
02559                                           PutPage(PDF_ProcessTableItem(ite, pag));
02560                                           ite->setXYPos(oldX, oldY, true);
02561                                           ite->BoundingX = OldBX;
02562                                           ite->BoundingY = OldBY;
02563                                    }
02564                                    if ((Options.Version == 15) && (Options.useLayers))
02565                                           PutPage("EMC\n");
02566                             }
02567                      }
02568               }
02569        }
02570        ll.isPrintable = false;
02571        ll.LNr = 0;
02572        Lnr = 0;
02573        //CB *2 because the Pitems count loop runs twice.. y.. dunno.
02574        if (usingGUI && pag->pageName().isEmpty())
02575               progressDialog->setProgress("ECPI", 0, doc.DocItems.count()*2);
02576        int pc_exportpagesitems=0;
02577        for (uint la = 0; la < doc.Layers.count() && !abortExport; ++la)
02578        {
02579               Level2Layer(&doc, &ll, Lnr);
02580               if (!pag->pageName().isEmpty())
02581                      PItems = doc.MasterItems;
02582               else
02583                      PItems = doc.DocItems;
02584               if (ll.isPrintable)
02585               {
02586                      QString inh = "";
02587                      if ((Options.Version == 15) && (Options.useLayers))
02588                             PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n");
02589                      for (uint a = 0; a < PItems.count() && !abortExport; ++a)
02590                      {
02591                             if (usingGUI)
02592                             {
02593                                    progressDialog->setProgress("ECPI", ++pc_exportpagesitems);
02594                                    qApp->processEvents();
02595                             }
02596                             ite = PItems.at(a);
02597                             if (ite->LayerNr != ll.LNr)
02598                                    continue;
02599                             QString grcon = "";
02600                             if (ite->isGroupControl)
02601                             {
02602                                    grcon += "q\n";
02603                                    FPointArray cl = ite->PoLine.copy();
02604                                    FPointArray clb = ite->PoLine.copy();
02605                                    QWMatrix mm;
02606                                    mm.translate(ite->xPos() - pag->xOffset(), (ite->yPos() - pag->yOffset()) - pag->height());
02607                                    mm.rotate(ite->rotation());
02608                                    cl.map( mm );
02609                                    ite->PoLine = cl;
02610                                    grcon += SetClipPath(ite);
02611                                    grcon += "h W* n\n";
02612                                    groupStack.push(ite->groupsLastItem);
02613                                    groupStackS.push(ite);
02614                                    if (((ll.transparency != 1) || (ll.blendMode != 0)) && (Options.Version >= 14))
02615                                    {
02616                                           inh += grcon;
02617                                           groupDataStack.push(inh);
02618                                           inh = "";
02619                                    }
02620                                    else
02621                                    {
02622                                           PutPage(grcon);
02623                                           groupDataStack.push(Inhalt);
02624                                           Inhalt = "";
02625                                    }
02626                                    ite->PoLine = clb.copy();
02627                                    continue;
02628                             }
02629                             if (((ll.transparency != 1) || (ll.blendMode != 0)) && (Options.Version >= 14))
02630                                    inh += PDF_ProcessItem(ite, pag, PNr);
02631                             else
02632                                    PutPage(PDF_ProcessItem(ite, pag, PNr));
02633                             if (groupStack.count() != 0)
02634                             {
02635                                    while (ite == groupStack.top())
02636                                    {
02637                                           QString tmpData;
02638                                           PageItem *controlItem = groupStackS.pop();
02639                                           if (((ll.transparency != 1) || (ll.blendMode != 0)) && (Options.Version >= 14))
02640                                           {
02641                                                  tmpData = inh;
02642                                                  inh = groupDataStack.pop();
02643                                                  if (Options.Version >= 14)
02644                                                         inh += Write_TransparencyGroup(controlItem->fillTransparency(), controlItem->fillBlendmode(), tmpData);
02645                                                  else
02646                                                         inh += tmpData;
02647                                                  inh += "Q\n";
02648                                           }
02649                                           else
02650                                           {
02651                                                  tmpData = Inhalt;
02652                                                  Inhalt = groupDataStack.pop();
02653                                                  if (Options.Version >= 14)
02654                                                         Inhalt += Write_TransparencyGroup(controlItem->fillTransparency(), controlItem->fillBlendmode(), tmpData);
02655                                                  else
02656                                                         Inhalt += tmpData;
02657                                                  PutPage("Q\n");
02658                                           }
02659                                           groupStack.pop();
02660                                    }
02661                             }
02662                      }
02663                      for (uint a = 0; a < PItems.count() && !abortExport; ++a)
02664                      {
02665                             if (usingGUI)
02666                             {
02667                                    progressDialog->setProgress("ECPI", ++pc_exportpagesitems);
02668                                    qApp->processEvents();
02669                             }
02670                             ite = PItems.at(a);
02671                             if (ite->LayerNr != ll.LNr)
02672                                    continue;
02673                             if (!ite->isTableItem)
02674                                    continue;
02675                             double x = pag->xOffset();
02676                             double y = pag->yOffset();
02677                             double w = pag->width();
02678                             double h1 = pag->height();
02679                             double ilw=ite->lineWidth();
02680                             double x2 = ite->BoundingX - ilw / 2.0;
02681                             double y2 = ite->BoundingY - ilw / 2.0;
02682                             double w2 = ite->BoundingW + ilw;
02683                             double h2 = ite->BoundingH + ilw;
02684                             if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
02685                                    continue;
02686                             if (ite->ChangedMasterItem)
02687                                    continue;
02688                             if ((!pag->pageName().isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1))
02689                                    continue;
02690                             if (!ite->printEnabled())
02691                                    continue;
02692                             if (((ll.transparency != 1) || (ll.blendMode != 0)) && (Options.Version >= 14))
02693                                    inh += PDF_ProcessTableItem(ite, pag);
02694                             else
02695                                    PutPage(PDF_ProcessTableItem(ite, pag));
02696                      }
02697                      if (((ll.transparency != 1) || (ll.blendMode != 0)) && (Options.Version >= 14))
02698                      {
02699                             StartObj(ObjCounter);
02700                             int Gobj = ObjCounter;
02701                             ObjCounter++;
02702                             PutDoc("<< /Type /Group\n");
02703                             PutDoc("/S /Transparency\n");
02704                             PutDoc("/I false\n");
02705                             PutDoc("/K false\n");
02706                             PutDoc(">>\nendobj\n");
02707                             StartObj(ObjCounter);
02708                             QString ShName = ResNam+QString::number(ResCount);
02709                             Transpar[ShName] = ObjCounter;
02710                             ResCount++;
02711                             ObjCounter++;
02712                             PutDoc("<< /Type /ExtGState\n");
02713                             PutDoc("/CA "+FToStr(ll.transparency)+"\n");
02714                             PutDoc("/ca "+FToStr(ll.transparency)+"\n");
02715                             PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
02716                             PutDoc("/BM /");
02717                             switch (ll.blendMode)
02718                             {
02719                                    case 0:
02720                                           PutDoc("Normal");
02721                                           break;
02722                                    case 1:
02723                                           PutDoc("Darken");
02724                                           break;
02725                                    case 2:
02726                                           PutDoc("Lighten");
02727                                           break;
02728                                    case 3:
02729                                           PutDoc("Multiply");
02730                                           break;
02731                                    case 4:
02732                                           PutDoc("Screen");
02733                                           break;
02734                                    case 5:
02735                                           PutDoc("Overlay");
02736                                           break;
02737                                    case 6:
02738                                           PutDoc("HardLight");
02739                                           break;
02740                                    case 7:
02741                                           PutDoc("SoftLight");
02742                                           break;
02743                                    case 8:
02744                                           PutDoc("Difference");
02745                                           break;
02746                                    case 9:
02747                                           PutDoc("Exclusion");
02748                                           break;
02749                                    case 10:
02750                                           PutDoc("ColorDodge");
02751                                           break;
02752                                    case 11:
02753                                           PutDoc("ColorBurn");
02754                                           break;
02755                                    case 12:
02756                                           PutDoc("Hue");
02757                                           break;
02758                                    case 13:
02759                                           PutDoc("Saturation");
02760                                           break;
02761                                    case 14:
02762                                           PutDoc("Color");
02763                                           break;
02764                                    case 15:
02765                                           PutDoc("Luminosity");
02766                                           break;
02767                             }
02768                             PutDoc("\n>>\nendobj\n");
02769                             StartObj(ObjCounter);
02770                             ObjCounter++;
02771                             PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
02772                             PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n");
02773                             PutDoc("/Group "+QString::number(Gobj)+" 0 R\n");
02774 /*                          PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
02775                             if (Seite.ImgObjects.count() != 0)
02776                             {
02777                                    PutDoc("/XObject <<\n");
02778                                    QMap<QString,int>::Iterator it;
02779                                    for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
02780                                           PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
02781                                    PutDoc(">>\n");
02782                             }
02783                             if (Seite.FObjects.count() != 0)
02784                             {
02785                                    PutDoc("/Font << \n");
02786                                    QMap<QString,int>::Iterator it2;
02787                                    for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
02788                                           PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
02789                                    PutDoc(">>\n");
02790                             }
02791                             if (Shadings.count() != 0)
02792                             {
02793                                    PutDoc("/Shading << \n");
02794                                    QMap<QString,int>::Iterator it3;
02795                                    for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
02796                                           PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
02797                                    PutDoc(">>\n");
02798                             }
02799                             if (Patterns.count() != 0)
02800                             {
02801                                    PutDoc("/Pattern << \n");
02802                                    QMap<QString,int>::Iterator it3p;
02803                                    for (it3p = Patterns.begin(); it3p != Patterns.end(); ++it3p)
02804                                           PutDoc("/"+it3p.key()+" "+QString::number(it3p.data())+" 0 R\n");
02805                                    PutDoc(">>\n");
02806                             }
02807                             if (Transpar.count() != 0)
02808                             {
02809                                    PutDoc("/ExtGState << \n");
02810                                    QMap<QString,int>::Iterator it3t;
02811                                    for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
02812                                           PutDoc("/"+it3t.key()+" "+QString::number(it3t.data())+" 0 R\n");
02813                                    PutDoc(">>\n");
02814                             }
02815                             if ((ICCProfiles.count() != 0) || (spotMap.count() != 0))
02816                             {
02817                                    PutDoc("/ColorSpace << \n");
02818                                    QMap<QString,ICCD>::Iterator it3c;
02819                                    if (ICCProfiles.count() != 0)
02820                                    {
02821                                           for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
02822                                                  PutDoc("/"+it3c.data().ResName+" "+QString::number(it3c.data().ResNum)+" 0 R\n");
02823                                    }
02824                                    QMap<QString,SpotC>::Iterator it3sc;
02825                                    if (spotMap.count() != 0)
02826                                    {
02827                                    for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
02828                                           PutDoc("/"+it3sc.data().ResName+" "+QString::number(it3sc.data().ResNum)+" 0 R\n");
02829                                    }
02830                                    PutDoc(">>\n");
02831                             }
02832                             PutDoc(">>\n"); */
02833                             if ((Options.Compress) && (CompAvail))
02834                                    inh = CompressStr(&inh);
02835                             PutDoc("/Length "+QString::number(inh.length()+1));
02836                             if ((Options.Compress) && (CompAvail))
02837                                    PutDoc("\n/Filter /FlateDecode");
02838                             PutDoc(" >>\nstream\n"+EncStream(inh, ObjCounter-1)+"\nendstream\nendobj\n");
02839                             QString name = ll.Name.simplifyWhiteSpace().replace(QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_") + QString::number(ll.LNr) + QString::number(PNr);
02840                             Seite.XObjects[name] = ObjCounter-1;
02841                             PutPage("/"+ShName+" gs\n");
02842                             PutPage("/"+name+" Do\n");
02843                      }
02844                      if ((Options.Version == 15) && (Options.useLayers))
02845                             PutPage("EMC\n");
02846                      }
02847               Lnr++;
02848        }
02849 }
02850 
02851 QString PDFlib::Write_TransparencyGroup(double trans, int blend, QString &data)
02852 {
02853        QString retString = "";
02854        StartObj(ObjCounter);
02855        int Gobj = ObjCounter;
02856        ObjCounter++;
02857        PutDoc("<< /Type /Group\n");
02858        PutDoc("/S /Transparency\n");
02859        PutDoc("/I false\n");
02860        PutDoc("/K false\n");
02861        PutDoc(">>\nendobj\n");
02862        StartObj(ObjCounter);
02863        QString ShName = ResNam+QString::number(ResCount);
02864        Transpar[ShName] = ObjCounter;
02865        ResCount++;
02866        ObjCounter++;
02867        PutDoc("<< /Type /ExtGState\n");
02868        PutDoc("/CA "+FToStr(1.0 - trans)+"\n");
02869        PutDoc("/ca "+FToStr(1.0 - trans)+"\n");
02870        PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
02871        PutDoc("/BM /");
02872        switch (blend)
02873        {
02874               case 0:
02875                      PutDoc("Normal");
02876                      break;
02877               case 1:
02878                      PutDoc("Darken");
02879                      break;
02880               case 2:
02881                      PutDoc("Lighten");
02882                      break;
02883               case 3:
02884                      PutDoc("Multiply");
02885                      break;
02886               case 4:
02887                      PutDoc("Screen");
02888                      break;
02889               case 5:
02890                      PutDoc("Overlay");
02891                      break;
02892               case 6:
02893                      PutDoc("HardLight");
02894                      break;
02895               case 7:
02896                      PutDoc("SoftLight");
02897                      break;
02898               case 8:
02899                      PutDoc("Difference");
02900                      break;
02901               case 9:
02902                      PutDoc("Exclusion");
02903                      break;
02904               case 10:
02905                      PutDoc("ColorDodge");
02906                      break;
02907               case 11:
02908                      PutDoc("ColorBurn");
02909                      break;
02910               case 12:
02911                      PutDoc("Hue");
02912                      break;
02913               case 13:
02914                      PutDoc("Saturation");
02915                      break;
02916               case 14:
02917                      PutDoc("Color");
02918                      break;
02919               case 15:
02920                      PutDoc("Luminosity");
02921                      break;
02922        }
02923        PutDoc("\n>>\nendobj\n");
02924        StartObj(ObjCounter);
02925        ObjCounter++;
02926        PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n");
02927        PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n");
02928        PutDoc("/Group "+QString::number(Gobj)+" 0 R\n");
02929 /*     PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
02930        if ((Seite.ImgObjects.count() != 0) || (Seite.XObjects.count() != 0))
02931        {
02932               PutDoc("/XObject <<\n");
02933               QMap<QString,int>::Iterator it;
02934               for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
02935                      PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
02936               QMap<QString,int>::Iterator iti;
02937               for (iti = Seite.XObjects.begin(); iti != Seite.XObjects.end(); ++iti)
02938                      PutDoc("/"+iti.key()+" "+QString::number(iti.data())+" 0 R\n");
02939               PutDoc(">>\n");
02940        }
02941        if (Seite.FObjects.count() != 0)
02942        {
02943               PutDoc("/Font << \n");
02944               QMap<QString,int>::Iterator it2;
02945               for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
02946                      PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
02947               PutDoc(">>\n");
02948        }
02949        if (Shadings.count() != 0)
02950        {
02951               PutDoc("/Shading << \n");
02952               QMap<QString,int>::Iterator it3;
02953               for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
02954                      PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
02955               PutDoc(">>\n");
02956        }
02957        if (Patterns.count() != 0)
02958        {
02959               PutDoc("/Pattern << \n");
02960               QMap<QString,int>::Iterator it3p;
02961               for (it3p = Patterns.begin(); it3p != Patterns.end(); ++it3p)
02962                      PutDoc("/"+it3p.key()+" "+QString::number(it3p.data())+" 0 R\n");
02963               PutDoc(">>\n");
02964        }
02965        if (Transpar.count() != 0)
02966        {
02967               PutDoc("/ExtGState << \n");
02968               QMap<QString,int>::Iterator it3t;
02969               for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
02970                      PutDoc("/"+it3t.key()+" "+QString::number(it3t.data())+" 0 R\n");
02971               PutDoc(">>\n");
02972        }
02973        if ((ICCProfiles.count() != 0) || (spotMap.count() != 0))
02974        {
02975               PutDoc("/ColorSpace << \n");
02976               QMap<QString,ICCD>::Iterator it3c;
02977               if (ICCProfiles.count() != 0)
02978               {
02979                      for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
02980                             PutDoc("/"+it3c.data().ResName+" "+QString::number(it3c.data().ResNum)+" 0 R\n");
02981               }
02982               QMap<QString,SpotC>::Iterator it3sc;
02983               if (spotMap.count() != 0)
02984               {
02985               for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
02986                      PutDoc("/"+it3sc.data().ResName+" "+QString::number(it3sc.data().ResNum)+" 0 R\n");
02987               }
02988               PutDoc(">>\n");
02989        }
02990        PutDoc(">>\n"); */
02991        if ((Options.Compress) && (CompAvail))
02992               data = CompressStr(&data);
02993        PutDoc("/Length "+QString::number(data.length()+1));
02994        if ((Options.Compress) && (CompAvail))
02995               PutDoc("\n/Filter /FlateDecode");
02996        PutDoc(" >>\nstream\n"+EncStream(data, ObjCounter-1)+"\nendstream\nendobj\n");
02997        QString name = ResNam+QString::number(ResCount);
02998        ResCount++;
02999        Seite.XObjects[name] = ObjCounter-1;
03000        retString += "/"+ShName+" gs\n";
03001        retString += "/"+name+" Do\n";
03002        return retString;
03003 }
03004 
03005 QString PDFlib::PDF_ProcessTableItem(PageItem* ite, const Page* pag)
03006 {
03007        if ((ite->lineColor() == CommonStrings::None) || (ite->lineWidth() == 0.0))
03008               return "";
03009        QString tmp("");
03010        tmp += "q\n";
03011        if ((ite->doOverprint) && (!Options.doOverprint) && (!Options.UseRGB))
03012        {
03013               StartObj(ObjCounter);
03014               QString ShName = ResNam+QString::number(ResCount);
03015               Transpar[ShName] = ObjCounter;
03016               ResCount++;
03017               ObjCounter++;
03018               PutDoc("<< /Type /ExtGState\n");
03019               PutDoc("/OP true\n");
03020               PutDoc("/op true\n");
03021               PutDoc("/OPM 1\n");
03022               PutDoc(">>\nendobj\n");
03023               tmp += "/"+ShName+" gs\n";
03024        }
03025 //     if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options.Version >= 14))
03026 //            tmp += PDF_Transparenz(ite);
03027 //     if (ite->fillColor() != CommonStrings::None)
03028 //            tmp += putColor(ite->fillColor(), ite->fillShade(), true);
03029        if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03030               tmp += PDF_TransparenzStroke(ite);
03031        if (ite->lineColor() != CommonStrings::None)
03032               tmp += putColor(ite->lineColor(), ite->lineShade(), false);
03033        tmp += FToStr(fabs(ite->lineWidth()))+" w\n";
03034        if (ite->DashValues.count() != 0)
03035        {
03036               tmp += "[ ";
03037               QValueList<double>::iterator it;
03038               for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it )
03039               {
03040                      int da = static_cast<int>(*it);
03041                      if (da != 0)
03042                             tmp += QString::number(da)+" ";
03043               }
03044               tmp += "] "+QString::number(static_cast<int>(ite->DashOffset))+" d\n";
03045        }
03046        else
03047        {
03048               QString Dt = FToStr(QMAX(2*fabs(ite->lineWidth()), 1));
03049               QString Da = FToStr(QMAX(6*fabs(ite->lineWidth()), 1));
03050               switch (ite->PLineArt)
03051               {
03052                      case Qt::SolidLine:
03053                             tmp += "[] 0 d\n";
03054                             break;
03055                      case Qt::DashLine:
03056                             tmp += "["+Da+" "+Dt+"] 0 d\n";
03057                             break;
03058                      case Qt::DotLine:
03059                             tmp += "["+Dt+"] 0 d\n";
03060                             break;
03061                      case Qt::DashDotLine:
03062                             tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03063                             break;
03064                      case Qt::DashDotDotLine:
03065                             tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03066                             break;
03067                      default:
03068                             tmp += "[] 0 d\n";
03069                             break;
03070               }
03071        }
03072        tmp += "2 J\n";
03073        switch (ite->PLineJoin)
03074        {
03075               case Qt::MiterJoin:
03076                      tmp += "0 j\n";
03077                      break;
03078               case Qt::BevelJoin:
03079                      tmp += "2 j\n";
03080                      break;
03081               case Qt::RoundJoin:
03082                      tmp += "1 j\n";
03083                      break;
03084               default:
03085                      tmp += "0 j\n";
03086                      break;
03087        }
03088        tmp += "1 0 0 1 "+FToStr(ite->xPos() - pag->xOffset())+" "+FToStr(pag->height() - (ite->yPos()  - pag->yOffset()))+" cm\n";
03089        if (ite->rotation() != 0)
03090        {
03091               double sr = sin(-ite->rotation()* M_PI / 180.0);
03092               double cr = cos(-ite->rotation()* M_PI / 180.0);
03093               if ((cr * cr) < 0.000001)
03094                      cr = 0;
03095               if ((sr * sr) < 0.000001)
03096                      sr = 0;
03097               tmp += FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+ " 0 0 cm\n";
03098        }
03099        if ((ite->TopLine) || (ite->RightLine) || (ite->BottomLine) || (ite->LeftLine))
03100        {
03101               if (ite->TopLine)
03102               {
03103                      tmp += "0 0 m\n";
03104                      tmp += FToStr(ite->width())+" 0 l\n";
03105               }
03106               if (ite->RightLine)
03107               {
03108                      tmp += FToStr(ite->width())+" 0 m\n";
03109                      tmp += FToStr(ite->width())+" "+FToStr(-ite->height())+" l\n";
03110               }
03111               if (ite->BottomLine)
03112               {
03113                      tmp += "0 "+FToStr(-ite->height())+" m\n";
03114                      tmp += FToStr(ite->width())+" "+FToStr(-ite->height())+" l\n";
03115               }
03116               if (ite->LeftLine)
03117               {
03118                      tmp += "0 0 m\n";
03119                      tmp += "0 "+FToStr(-ite->height())+" l\n";
03120               }
03121               tmp += "S\n";
03122        }
03123        tmp += "Q\n";
03124        return tmp;
03125 }
03126 
03127 QString PDFlib::PDF_ProcessItem(PageItem* ite, const Page* pag, uint PNr, bool embedded, bool pattern)
03128 {
03129        QString tmp("");
03130        ite->setRedrawBounding();
03131        double x = pag->xOffset();
03132        double y = pag->yOffset();
03133        double w = pag->width();
03134        double h1 = pag->height();
03135        double ilw=ite->lineWidth();
03136        double x2 = ite->BoundingX - ilw / 2.0;
03137        double y2 = ite->BoundingY - ilw / 2.0;
03138        double w2 = ite->BoundingW + ilw;
03139        double h2 = ite->BoundingH + ilw;
03140        if (!pattern)
03141        {
03142 //            qDebug(QString("pdflib process item: pagename=%1 ownpage=%2 pagenr=%3 changedMP=%4").arg(pag->pageName()).arg(ite->OwnPage).arg(pag->pageNr()).arg(ite->ChangedMasterItem));
03143 //            qDebug(QString("pdflib process item: x=%1 x2=%2 y=%3 y2=%4 w=%5 w2=%6 h1=%7 h2=%8 ilw=%9").arg(x).arg(x2).arg(y).arg(y2).arg(w).arg(w2).arg(h1).arg(h2).arg(ilw));
03144               if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
03145                      return tmp;
03146 //            qDebug("bb test done");
03147               if (ite->ChangedMasterItem)
03148                      return tmp;
03149               if ((!pag->pageName().isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1))
03150                      return tmp;
03151        }
03152 
03153        tmp += "q\n";
03154        if ((ite->doOverprint) && (!Options.doOverprint) && (!Options.UseRGB))
03155        {
03156               StartObj(ObjCounter);
03157               QString ShName = ResNam+QString::number(ResCount);
03158               Transpar[ShName] = ObjCounter;
03159               ResCount++;
03160               ObjCounter++;
03161               PutDoc("<< /Type /ExtGState\n");
03162               PutDoc("/OP true\n");
03163               PutDoc("/op true\n");
03164               PutDoc("/OPM 1\n");
03165               PutDoc(">>\nendobj\n");
03166               tmp += "/"+ShName+" gs\n";
03167        }
03168 //     if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options.Version >= 14))
03169 //            tmp += PDF_Transparenz(ite);
03170        if ((ite->isBookmark) && (Options.Bookmarks))
03171               PDF_Bookmark(ite, pag->height() - (ite->yPos() - pag->yOffset()));
03172        if (!pattern)
03173        {
03174               if (!ite->printEnabled() || ((ite->itemType() == PageItem::TextFrame) && (!pag->pageName().isEmpty())))
03175               {
03176 //                   qDebug("Q exit");
03177                      tmp += "Q\n";
03178                      return tmp;
03179               }
03180        }
03181        if (ite->fillColor() != CommonStrings::None)
03182               tmp += putColor(ite->fillColor(), ite->fillShade(), true);
03183        if (ite->lineColor() != CommonStrings::None)
03184               tmp += putColor(ite->lineColor(), ite->lineShade(), false);
03185        tmp += FToStr(fabs(ite->lineWidth()))+" w\n";
03186        if (ite->DashValues.count() != 0)
03187        {
03188               tmp += "[ ";
03189               QValueList<double>::iterator it;
03190               for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it )
03191               {
03192                      int da = static_cast<int>(*it);
03193                      if (da != 0)
03194                             tmp += QString::number(da)+" ";
03195               }
03196               tmp += "] "+QString::number(static_cast<int>(ite->DashOffset))+" d\n";
03197        }
03198        else
03199        {
03200               QString Dt = FToStr(QMAX(2*fabs(ite->lineWidth()), 1));
03201               QString Da = FToStr(QMAX(6*fabs(ite->lineWidth()), 1));
03202               switch (ite->PLineArt)
03203               {
03204                      case Qt::SolidLine:
03205                             tmp += "[] 0 d\n";
03206                             break;
03207                      case Qt::DashLine:
03208                             tmp += "["+Da+" "+Dt+"] 0 d\n";
03209                             break;
03210                      case Qt::DotLine:
03211                             tmp += "["+Dt+"] 0 d\n";
03212                             break;
03213                      case Qt::DashDotLine:
03214                             tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03215                             break;
03216                      case Qt::DashDotDotLine:
03217                             tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03218                             break;
03219                      default:
03220                             tmp += "[] 0 d\n";
03221                             break;
03222               }
03223        }
03224        switch (ite->PLineEnd)
03225        {
03226               case Qt::FlatCap:
03227                      tmp += "0 J\n";
03228                      break;
03229               case Qt::SquareCap:
03230                      tmp += "2 J\n";
03231                      break;
03232               case Qt::RoundCap:
03233                      tmp += "1 J\n";
03234                      break;
03235               default:
03236                      tmp += "0 J\n";
03237                      break;
03238        }
03239        switch (ite->PLineJoin)
03240        {
03241               case Qt::MiterJoin:
03242                      tmp += "0 j\n";
03243                      break;
03244               case Qt::BevelJoin:
03245                      tmp += "2 j\n";
03246                      break;
03247               case Qt::RoundJoin:
03248                      tmp += "1 j\n";
03249                      break;
03250               default:
03251                      tmp += "0 j\n";
03252                      break;
03253        }
03254        if (!embedded)
03255        {
03256               tmp += "1 0 0 1 "+FToStr(ite->xPos() - pag->xOffset())+" "+FToStr(pag->height() - (ite->yPos()  - pag->yOffset()))+" cm\n";
03257        }
03258        if (ite->rotation() != 0)
03259        {
03260               double sr = sin(-ite->rotation()* M_PI / 180.0);
03261               double cr = cos(-ite->rotation()* M_PI / 180.0);
03262               if ((cr * cr) < 0.000001)
03263                      cr = 0;
03264               if ((sr * sr) < 0.000001)
03265                      sr = 0;
03266               tmp += FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n";
03267        }
03268        switch (ite->itemType())
03269        {
03270               case PageItem::ImageFrame:
03271                      if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
03272                             tmp += PDF_TransparenzFill(ite);
03273                      if ((ite->fillColor() != CommonStrings::None) || (ite->GrType != 0))
03274                      {
03275                             if (ite->GrType != 0)
03276                                    tmp += PDF_Gradient(ite);
03277                             else
03278                             {
03279                                    tmp += SetClipPath(ite);
03280                                    tmp += "h\nf*\n";
03281                             }
03282                      }
03283                      tmp += "q\n";
03284                      if (ite->imageClip.size() != 0)
03285                      {
03286                             tmp += SetClipPathImage(ite);
03287                             tmp += "h\nW*\nn\n";
03288                      }
03289                      tmp += SetClipPath(ite);
03290                      tmp += "h\nW*\nn\n";
03291                      if (ite->imageFlippedH())
03292                             tmp += "-1 0 0 1 "+FToStr(ite->width())+" 0 cm\n";
03293                      if (ite->imageFlippedV())
03294                             tmp += "1 0 0 -1 0 "+FToStr(-ite->height())+" cm\n";
03295                      if ((ite->PicAvail) && (!ite->Pfile.isEmpty()))
03296                             tmp += PDF_Image(ite, ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), false, ite->IProfile, ite->UseEmbedded, ite->IRender);
03297                      tmp += "Q\n";
03298                      if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
03299                      {
03300                             if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03301                                    tmp += PDF_TransparenzStroke(ite);
03302                             if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
03303                             {
03304                                    tmp += SetClipPath(ite);
03305                                    tmp += "h\nS\n";
03306                             }
03307                             else
03308                             {
03309                                    multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03310                                    for (int it = ml.size()-1; it > -1; it--)
03311                                    {
03312                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03313                                           {
03314                                                  tmp += setStrokeMulti(&ml[it]);
03315                                                  tmp += SetClipPath(ite);
03316                                                  tmp += "h\nS\n";
03317                                           }
03318                                    }
03319                             }
03320                      }
03321                      break;
03322               case PageItem::TextFrame:
03323 //                   qDebug("case TextFrame");
03324                      if ((ite->isAnnotation()) && (Options.Version != 12))
03325                      {
03326 //                          qDebug("Annotation");
03327                             PDF_Annotation(ite, PNr);
03328                             break;
03329                      }
03330                      if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
03331                             tmp += PDF_TransparenzFill(ite);
03332                      if ((ite->fillColor() != CommonStrings::None) || (ite->GrType != 0))
03333                      {
03334                             if (ite->GrType != 0)
03335                                    tmp += PDF_Gradient(ite);
03336                             else
03337                             {
03338                                    tmp += SetClipPath(ite);
03339                                    tmp += "h\nf*\n";
03340                             }
03341                      }
03342                      tmp += "q\n";
03343                      if (ite->imageFlippedH())
03344                             tmp += "-1 0 0 1 "+FToStr(ite->width())+" 0 cm\n";
03345                      if (ite->imageFlippedV())
03346                             tmp += "1 0 0 -1 0 "+FToStr(-ite->height())+" cm\n";
03347                      tmp += setTextSt(ite, PNr, pag);
03348                      tmp += "Q\n";
03349                      if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
03350                      {
03351                             if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03352                                    tmp += PDF_TransparenzStroke(ite);
03353                             if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
03354                             {
03355                                    tmp += SetClipPath(ite);
03356                                    tmp += "h\nS\n";
03357                             }
03358                             else
03359                             {
03360                                    multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03361                                    for (int it = ml.size()-1; it > -1; it--)
03362                                    {
03363                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03364                                           {
03365                                                  tmp += setStrokeMulti(&ml[it]);
03366                                                  tmp += SetClipPath(ite);
03367                                                  tmp += "h\nS\n";
03368                                           }
03369                                    }
03370                             }
03371                      }
03372                      break;
03373               case PageItem::Line:
03374                      if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03375                             tmp += PDF_TransparenzStroke(ite);
03376                      if (ite->NamedLStyle.isEmpty())
03377                      {
03378                             tmp += "0 0 m\n";
03379                             tmp += FToStr(ite->width())+" 0 l\n";
03380                             tmp += "S\n";
03381                      }
03382                      else
03383                      {
03384                             multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03385                             for (int it = ml.size()-1; it > -1; it--)
03386                             {
03387                                    if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03388                                    {
03389                                           tmp += setStrokeMulti(&ml[it]);
03390                                           tmp += "0 0 m\n";
03391                                           tmp += FToStr(ite->width())+" 0 l\n";
03392                                           tmp += "S\n";
03393                                    }
03394                             }
03395                      }
03396                      if (ite->startArrowIndex() != 0)
03397                      {
03398                             QWMatrix arrowTrans;
03399                             FPointArray arrow = (*doc.arrowStyles.at(ite->startArrowIndex()-1)).points.copy();
03400                             arrowTrans.translate(0, 0);
03401                             arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
03402                             arrowTrans.scale(-1,1);
03403                             arrow.map(arrowTrans);
03404                             if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
03405                             {
03406                                    StartObj(ObjCounter);
03407                                    QString ShName = ResNam+QString::number(ResCount);
03408                                    Transpar[ShName] = ObjCounter;
03409                                    ResCount++;
03410                                    ObjCounter++;
03411                                    PutDoc("<< /Type /ExtGState\n");
03412                                    PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
03413                                    PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
03414                                    PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
03415                                    PutDoc("/BM /Normal\n>>\nendobj\n");
03416                                    tmp += "/"+ShName+" gs\n";
03417                             }
03418                             tmp += putColor(ite->lineColor(), ite->lineShade(), true);
03419                             tmp += SetClipPathArray(&arrow);
03420                             tmp += "h\nf*\n";
03421                      }
03422                      if (ite->endArrowIndex() != 0)
03423                      {
03424                             QWMatrix arrowTrans;
03425                             FPointArray arrow = (*doc.arrowStyles.at(ite->endArrowIndex()-1)).points.copy();
03426                             arrowTrans.translate(ite->width(), 0);
03427                             arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
03428                             arrow.map(arrowTrans);
03429                             if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
03430                             {
03431                                    StartObj(ObjCounter);
03432                                    QString ShName = ResNam+QString::number(ResCount);
03433                                    Transpar[ShName] = ObjCounter;
03434                                    ResCount++;
03435                                    ObjCounter++;
03436                                    PutDoc("<< /Type /ExtGState\n");
03437                                    PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
03438                                    PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
03439                                    PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
03440                                    PutDoc("/BM /Normal\n>>\nendobj\n");
03441                                    tmp += "/"+ShName+" gs\n";
03442                             }
03443                             tmp += putColor(ite->lineColor(), ite->lineShade(), true);
03444                             tmp += SetClipPathArray(&arrow);
03445                             tmp += "h\nf*\n";
03446                      }
03447                      break;
03448               case PageItem::ItemType1:
03449               case PageItem::ItemType3:
03450               case PageItem::Polygon:
03451                      if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
03452                             tmp += PDF_TransparenzFill(ite);
03453                      if (ite->GrType != 0)
03454                             tmp += PDF_Gradient(ite);
03455                      else
03456                      {
03457                             if (ite->fillColor() != CommonStrings::None)
03458                             {
03459                                    tmp += SetClipPath(ite);
03460                                    if (ite->fillRule)
03461                                           tmp += "h\nf*\n";
03462                                    else
03463                                           tmp += "h\nf\n";
03464                             }
03465                      }
03466                      if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
03467                      {
03468                             if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03469                                    tmp += PDF_TransparenzStroke(ite);
03470                             if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
03471                             {
03472                                    tmp += SetClipPath(ite);
03473                                    tmp += "h\nS\n";
03474                             }
03475                             else
03476                             {
03477                                    multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03478                                    for (int it = ml.size()-1; it > -1; it--)
03479                                    {
03480                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03481                                           {
03482                                                  tmp += setStrokeMulti(&ml[it]);
03483                                                  tmp += SetClipPath(ite);
03484                                                  tmp += "h\nS\n";
03485                                           }
03486                                    }
03487                             }
03488                      }
03489                      break;
03490               case PageItem::PolyLine:
03491                      if (ite->PoLine.size() > 4)  // && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3))))
03492                      {
03493                             if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
03494                                    tmp += PDF_TransparenzFill(ite);
03495                             if (ite->GrType != 0)
03496                                    tmp += PDF_Gradient(ite);
03497                             else
03498                             {
03499                                    if (ite->fillColor() != CommonStrings::None)
03500                                    {
03501                                           tmp += SetClipPath(ite);
03502                                           tmp += "h\nf*\n";
03503                                    }
03504                             }
03505                      }
03506                      if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
03507                      {
03508                             if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03509                                    tmp += PDF_TransparenzStroke(ite);
03510                             if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
03511                             {
03512                                    tmp += SetClipPath(ite, false);
03513                                    tmp += "S\n";
03514                             }
03515                             else
03516                             {
03517                                    multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03518                                    for (int it = ml.size()-1; it > -1; it--)
03519                                    {
03520                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03521                                           {
03522                                                  tmp += setStrokeMulti(&ml[it]);
03523                                                  tmp += SetClipPath(ite, false);
03524                                                  tmp += "S\n";
03525                                           }
03526                                    }
03527                             }
03528                      }
03529                      if (ite->startArrowIndex() != 0)
03530                      {
03531                             FPoint Start = ite->PoLine.point(0);
03532                             for (uint xx = 1; xx < ite->PoLine.size(); xx += 2)
03533                             {
03534                                    FPoint Vector = ite->PoLine.point(xx);
03535                                    if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
03536                                    {
03537                                           double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
03538                                           QWMatrix arrowTrans;
03539                                           FPointArray arrow = (*doc.arrowStyles.at(ite->startArrowIndex()-1)).points.copy();
03540                                           arrowTrans.translate(Start.x(), Start.y());
03541                                           arrowTrans.rotate(r);
03542                                           arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
03543                                           arrow.map(arrowTrans);
03544                                           if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
03545                                           {
03546                                                  StartObj(ObjCounter);
03547                                                  QString ShName = ResNam+QString::number(ResCount);
03548                                                  Transpar[ShName] = ObjCounter;
03549                                                  ResCount++;
03550                                                  ObjCounter++;
03551                                                  PutDoc("<< /Type /ExtGState\n");
03552                                                  PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
03553                                                  PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
03554                                                  PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
03555                                                  PutDoc("/BM /Normal\n>>\nendobj\n");
03556                                                  tmp += "/"+ShName+" gs\n";
03557                                           }
03558                                           tmp += putColor(ite->lineColor(), ite->lineShade(), true);
03559                                           tmp += SetClipPathArray(&arrow);
03560                                           tmp += "h\nf*\n";
03561                                           break;
03562                                    }
03563                             }
03564                      }
03565                      if (ite->endArrowIndex() != 0)
03566                      {
03567                             FPoint End = ite->PoLine.point(ite->PoLine.size()-2);
03568                             for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2)
03569                             {
03570                                    FPoint Vector = ite->PoLine.point(xx);
03571                                    if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
03572                                    {
03573                                           double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
03574                                           QWMatrix arrowTrans;
03575                                           FPointArray arrow = (*doc.arrowStyles.at(ite->endArrowIndex()-1)).points.copy();
03576                                           arrowTrans.translate(End.x(), End.y());
03577                                           arrowTrans.rotate(r);
03578                                           arrowTrans.scale(ite->lineWidth(), ite->lineWidth());
03579                                           arrow.map(arrowTrans);
03580                                           if ((ite->lineTransparency() != 0) && (Options.Version >= 14))
03581                                           {
03582                                                  StartObj(ObjCounter);
03583                                                  QString ShName = ResNam+QString::number(ResCount);
03584                                                  Transpar[ShName] = ObjCounter;
03585                                                  ResCount++;
03586                                                  ObjCounter++;
03587                                                  PutDoc("<< /Type /ExtGState\n");
03588                                                  PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n");
03589                                                  PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n");
03590                                                  PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
03591                                                  PutDoc("/BM /Normal\n>>\nendobj\n");
03592                                                  tmp += "/"+ShName+" gs\n";
03593                                           }
03594                                           tmp += putColor(ite->lineColor(), ite->lineShade(), true);
03595                                           tmp += SetClipPathArray(&arrow);
03596                                           tmp += "h\nf*\n";
03597                                           break;
03598                                    }
03599                             }
03600                      }
03601                      break;
03602               case PageItem::PathText:
03603                      if (ite->PoShow)
03604                      {
03605                             if (ite->PoLine.size() > 3)
03606                             {
03607                                    tmp += "q\n";
03608                                    if ((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty()))
03609                                    {
03610                                           if (((ite->lineTransparency() != 0) || (ite->lineBlendmode() != 0)) && (Options.Version >= 14))
03611                                                  tmp += PDF_TransparenzStroke(ite);
03612                                           if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
03613                                           {
03614                                                  tmp += SetClipPath(ite, false);
03615                                                  tmp += "S\n";
03616                                           }
03617                                           else
03618                                           {
03619                                                  multiLine ml = doc.MLineStyles[ite->NamedLStyle];
03620                                                  for (int it = ml.size()-1; it > -1; it--)
03621                                                  {
03622                                                         if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
03623                                                         {
03624                                                                tmp += setStrokeMulti(&ml[it]);
03625                                                                tmp += SetClipPath(ite, false);
03626                                                                tmp += "S\n";
03627                                                         }
03628                                                  }
03629                                           }
03630                                    }
03631                                    tmp += "Q\n";
03632                             }
03633                      }
03634                      if (((ite->fillTransparency() != 0) || (ite->fillBlendmode() != 0)) && (Options.Version >= 14))
03635                             tmp += PDF_TransparenzFill(ite);
03636                      tmp += setTextSt(ite, PNr, pag);
03637                      break;
03638               case PageItem::Multiple:
03639                      Q_ASSERT(false);
03640                      break;
03641        }
03642        tmp += "Q\n";
03643        return tmp;
03644 }
03645 
03646 QString PDFlib::putColor(const QString& color, int shade, bool fill)
03647 {
03648        QString tmp = "";
03649        QString colString = SetFarbe(color, shade);
03650        ScColor tmpC;
03651        tmpC = doc.PageColors[color];
03652        if (((tmpC.isSpotColor()) || (tmpC.isRegistrationColor())) && ((Options.isGrayscale == false) && (Options.UseRGB == false))  && (Options.UseSpotColors))
03653        {
03654               if (color != CommonStrings::None)
03655               {
03656                      if (fill)
03657                      {
03658                             tmp += "/"+spotMap[color].ResName+" cs\n";
03659                             tmp += FToStr(shade / 100.0)+" scn\n";
03660                      }
03661                      else
03662                      {
03663                             tmp += "/"+spotMap[color].ResName+" CS\n";
03664                             tmp += FToStr(shade / 100.0)+" SCN\n";
03665                      }
03666               }
03667               return tmp;
03668        }
03669        if (Options.isGrayscale)
03670        {
03671               if (color != CommonStrings::None)
03672               {
03673                      if (fill)
03674                             tmp += colString+" g\n";
03675                      else
03676                             tmp += colString+" G\n";
03677               }
03678               return tmp;
03679        }
03680        if (Options.UseRGB)
03681        {
03682               if (color != CommonStrings::None)
03683               {
03684                      if (fill)
03685                             tmp += colString+" rg\n";
03686                      else
03687                             tmp += colString+" RG\n";
03688               }
03689        }
03690        else
03691        {
03692               if ((doc.HasCMS) && (Options.UseProfiles))
03693               {
03694                      if (tmpC.getColorModel() == colorModelCMYK)
03695                      {
03696                             if (color != CommonStrings::None)
03697                             {
03698                                    if (fill)
03699                                           tmp += colString+" k\n";
03700                                    else
03701                                           tmp += colString+" K\n";
03702                             }
03703                      }
03704                      else
03705                      {
03706                             QString tmp2[] = {"/Perceptual", "/RelativeColorimetric", "/Saturation", "/AbsoluteColorimetric"};
03707                             tmp += tmp2[Options.Intent]+ " ri\n";
03708                             if (color != CommonStrings::None)
03709                             {
03710                                    if (fill)
03711                                    {
03712                                           tmp += "/"+ICCProfiles[Options.SolidProf].ResName+" cs\n";
03713                                           tmp += colString+" scn\n";
03714                                    }
03715                                    else
03716                                    {
03717                                           tmp += "/"+ICCProfiles[Options.SolidProf].ResName+" CS\n";
03718                                           tmp += colString+" SCN\n";
03719                                    }
03720                             }
03721                      }
03722               }
03723               else
03724               {
03725                      if (color != CommonStrings::None)
03726                      {
03727                             if (fill)
03728                                    tmp += colString+" k\n";
03729                             else
03730                                    tmp += colString+" K\n";
03731                      }
03732               }
03733        }
03734        return tmp;
03735 }
03736 
03737 /*CB 2982: cache code is borked somehow, original function is above
03738 QString PDFlib::putColor(const QString & colorName, int shade, bool fill)
03739 {
03740        // Cache of last foreground and background colours We cache fg and bg
03741        // separately because they're alternated so much.  The primary purpose of
03742        // this cache is to avoid re-caculating the fg and bg colors on each char
03743        // of text when the color doens't change.
03744        static QString lastFGColorName, lastFGOutput, lastBGColorName, lastBGOutput;
03745        static int lastFGShade = -1, lastBGShade = -1;
03746        if (fill && colorName == lastBGColorName && shade == lastBGShade)
03747               return lastBGOutput;
03748        else if (colorName == lastFGColorName && shade == lastFGShade)
03749               return lastFGOutput;
03750        // Cache miss, generate the color
03751        else if (fill)
03752        {
03753               lastBGColorName = colorName;
03754               lastBGShade = shade;
03755               lastBGOutput = putColorUncached(colorName, shade, fill);
03756               return lastBGOutput;
03757        }
03758        else
03759        {
03760               lastFGColorName = colorName;
03761               lastFGShade = shade;
03762               lastFGOutput = putColorUncached(colorName, shade, fill);
03763               return lastFGOutput;
03764        }
03765 }
03766 */
03767 
03768 QString PDFlib::putColorUncached(const QString& color, int shade, bool fill)
03769 {
03770        ScColor tmpC(doc.PageColors[color]);
03771        if (((tmpC.isSpotColor()) || (tmpC.isRegistrationColor())) && ((Options.isGrayscale == false) && (Options.UseRGB == false))  && (Options.UseSpotColors))
03772        {
03773               QString tmpSpot("");
03774               if (color != CommonStrings::None)
03775               {
03776                      if (fill)
03777                      {
03778                             tmpSpot += "/"+spotMap[color].ResName+" cs\n";
03779                             tmpSpot += FToStr(shade / 100.0)+" scn\n";
03780                      }
03781                      else
03782                      {
03783                             tmpSpot += "/"+spotMap[color].ResName+" CS\n";
03784                             tmpSpot += FToStr(shade / 100.0)+" SCN\n";
03785                      }
03786               }
03787               return tmpSpot;
03788        }
03789        QString colString(SetFarbe(color, shade));
03790        if (Options.isGrayscale)
03791        {
03792               QString tmpGray("");
03793               if (color != CommonStrings::None)
03794               {
03795                      if (fill)
03796                             tmpGray += colString+" g\n";
03797                      else
03798                             tmpGray += colString+" G\n";
03799               }
03800               return tmpGray;
03801        }
03802        QString tmp("");
03803        if (Options.UseRGB)
03804        {
03805               if (color != CommonStrings::None)
03806               {
03807                      if (fill)
03808                             tmp += colString+" rg\n";
03809                      else
03810                             tmp += colString+" RG\n";
03811               }
03812        }
03813        else
03814        {
03815               if ((doc.HasCMS) && (Options.UseProfiles))
03816               {
03817                      if (tmpC.getColorModel() == colorModelCMYK)
03818                      {
03819                             if (color != CommonStrings::None)
03820                             {
03821                                    if (fill)
03822                                           tmp += colString+" k\n";
03823                                    else
03824                                           tmp += colString+" K\n";
03825                             }
03826                      }
03827                      else
03828                      {
03829                             QString tmp2[] = {"/Perceptual", "/RelativeColorimetric", "/Saturation", "/AbsoluteColorimetric"};
03830                             tmp += tmp2[Options.Intent]+ " ri\n";
03831                             if (color != CommonStrings::None)
03832                             {
03833                                    if (fill)
03834                                    {
03835                                           tmp += "/"+ICCProfiles[Options.SolidProf].ResName+" cs\n";
03836                                           tmp += colString+" scn\n";
03837                                    }
03838                                    else
03839                                    {
03840                                           tmp += "/"+ICCProfiles[Options.SolidProf].ResName+" CS\n";
03841                                           tmp += colString+" SCN\n";
03842                                    }
03843                             }
03844                      }
03845               }
03846               else
03847               {
03848                      if (color != CommonStrings::None)
03849                      {
03850                             if (fill)
03851                                    tmp += colString+" k\n";
03852                             else
03853                                    tmp += colString+" K\n";
03854                      }
03855               }
03856        }
03857        return tmp;
03858 }
03859 
03860 QString PDFlib::setStrokeMulti(struct SingleLine *sl)
03861 {
03862        QString tmp(
03863                      putColor(sl->Color, sl->Shade, false) +
03864                      FToStr(sl->Width)+" w\n"
03865                      );
03866        QString Dt = FToStr(QMAX(2*sl->Width, 1));
03867        QString Da = FToStr(QMAX(6*sl->Width, 1));
03868        switch (static_cast<PenStyle>(sl->Dash))
03869        {
03870               case Qt::SolidLine:
03871                      tmp += "[] 0 d\n";
03872                      break;
03873               case Qt::DashLine:
03874                      tmp += "["+Da+" "+Dt+"] 0 d\n";
03875                      break;
03876               case Qt::DotLine:
03877                      tmp += "["+Dt+"] 0 d\n";
03878                      break;
03879               case Qt::DashDotLine:
03880                      tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03881                      break;
03882               case Qt::DashDotDotLine:
03883                      tmp += "["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n";
03884                      break;
03885               default:
03886                      tmp += "[] 0 d\n";
03887                      break;
03888               }
03889        switch (static_cast<PenCapStyle>(sl->LineEnd))
03890        {
03891               case Qt::FlatCap:
03892                      tmp += "0 J\n";
03893                      break;
03894               case Qt::SquareCap:
03895                      tmp += "2 J\n";
03896                      break;
03897               case Qt::RoundCap:
03898                      tmp += "1 J\n";
03899                      break;
03900               default:
03901                      tmp += "0 J\n";
03902                      break;
03903        }
03904        switch (static_cast<PenJoinStyle>(sl->LineJoin))
03905        {
03906               case Qt::MiterJoin:
03907                      tmp += "0 j\n";
03908                      break;
03909               case Qt::BevelJoin:
03910                      tmp += "2 j\n";
03911                      break;
03912               case Qt::RoundJoin:
03913                      tmp += "1 j\n";
03914                      break;
03915               default:
03916                      tmp += "0 j\n";
03917                      break;
03918        }
03919        return tmp;
03920 }
03921 
03922 // Return a PDF substring representing a PageItem's text
03923 QString PDFlib::setTextSt(PageItem *ite, uint PNr, const Page* pag)
03924 {
03925        int savedOwnPage = ite->OwnPage;
03926        ite->OwnPage = PNr;
03927        if (ite->itemType() == PageItem::TextFrame)
03928               ite->asTextFrame()->layout();
03929        ite->OwnPage = savedOwnPage;
03930        QString tmp("");
03931        QString tmp2("");
03932        uint tabCc = 0;
03933        QValueList<ParagraphStyle::TabRecord> tTabValues;
03934        double tabDist=ite->textToFrameDistLeft();
03935        if (ite->lineColor() != CommonStrings::None)
03936               tabDist += ite->lineWidth() / 2.0;
03937 #ifndef NLS_PROTO
03938        // Loop over each character (!) in the pageItem...
03939        if (ite->itemType() == PageItem::TextFrame)
03940        {
03941               tmp += "BT\n";
03942               for (uint ll=0; ll < ite->itemText.lines(); ++ll)
03943               {
03944                      LineSpec ls = ite->itemText.line(ll);
03945                      tabDist = ls.x;
03946                      double CurX = ls.x;
03947                      for (int d = ls.firstItem; d <= ls.lastItem; ++d)
03948                      {
03949                             const ScText * const hl = ite->itemText.item(d);
03950                             const QString ch = ite->itemText.text(d,1);
03951                             const CharStyle& chstyle(ite->itemText.charStyle(d));
03952                             const ParagraphStyle& pstyle(ite->itemText.paragraphStyle(d));
03953                             if ((ch[0] == SpecialChars::PARSEP) || (ch[0] == QChar(10)) || (ch[0] == SpecialChars::LINEBREAK) || (ch[0] == SpecialChars::FRAMEBREAK) || (ch[0] == SpecialChars::COLBREAK))
03954                                    continue;
03955                             if (chstyle.effects() & ScStyle_SuppressSpace)
03956                                    continue;
03957                             tTabValues = pstyle.tabValues();
03958                             if (chstyle.effects() & ScStyle_StartOfLine)
03959                                    tabCc = 0;
03960                             if ((ch[0] == SpecialChars::TAB) && (tTabValues.count() != 0))
03961                             {
03962                                    if ((!tTabValues[tabCc].tabFillChar.isNull()) && (tabCc < tTabValues.count()))
03963                                    {
03964                                           ScText hl2;
03965                                           static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
03966                                           double wt = chstyle.font().charWidth(tTabValues[tabCc].tabFillChar, chstyle.fontSize());
03967                                           int coun = static_cast<int>((CurX+hl->glyph.xoffset - tabDist) / wt);
03968                                           double sPos = CurX+hl->glyph.xoffset - (CurX+hl->glyph.xoffset - tabDist) + 1;
03969                                           hl2.ch = QString(tTabValues[tabCc].tabFillChar);
03970                                           hl2.setTracking(0);
03971                                           hl2.setScaleH(1000);
03972                                           hl2.setScaleV(1000);
03973                                           hl2.glyph.yoffset = hl->glyph.yoffset;
03974                                           for (int cx = 0; cx < coun; ++cx)
03975                                           {
03976                                                  hl2.glyph.xoffset =  sPos + wt * cx;
03977                                                  if ((chstyle.effects() & ScStyle_Shadowed) && (chstyle.strokeColor() != CommonStrings::None))
03978                                                  {
03979                                                         ScText hl3;
03980                                                         static_cast<CharStyle&>(hl3) = static_cast<const CharStyle&>(hl2);
03981                                                         hl3.ch = hl2.ch;
03982                                                         hl3.glyph.glyph = hl2.glyph.glyph;
03983                                                         hl3.setFillColor(hl2.strokeColor());
03984                                                         hl3.glyph.yoffset = hl2.glyph.yoffset - (chstyle.fontSize() * chstyle.shadowYOffset() / 10000.0);
03985                                                         hl3.glyph.xoffset = hl2.glyph.xoffset + (chstyle.fontSize() * chstyle.shadowXOffset() / 10000.0);
03986                                                         setTextCh(ite, PNr, CurX, ls.y, d, tmp, tmp2, &hl3, pstyle, pag);
03987                                                  }
03988                                                  setTextCh(ite, PNr, CurX, ls.y, d, tmp, tmp2, &hl2, pstyle, pag);
03989                                           }
03990                                           tabCc++;
03991                                    }
03992                                    else
03993                                    {
03994                                           tabCc++;
03995                                    }
03996                             }
03997                             if (ch[0] == SpecialChars::TAB) 
03998                             {
03999                                    CurX += hl->glyph.wide();
04000                                    continue;
04001                             }
04002                             if ((chstyle.effects() & ScStyle_Shadowed) && (chstyle.strokeColor() != CommonStrings::None))
04003                             {
04004                                    ScText hl2;
04005                                    hl2.ch = ch;
04006                                    hl2.glyph.glyph = hl->glyph.glyph;
04007                                    static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
04008                                    hl2.setFillColor(hl->strokeColor());
04009                                    hl2.glyph.yoffset = hl->glyph.yoffset - (chstyle.fontSize() * chstyle.shadowYOffset() / 10000.0);
04010                                    hl2.glyph.xoffset = hl->glyph.xoffset + (chstyle.fontSize() * chstyle.shadowXOffset() / 10000.0);
04011                                    hl2.glyph.scaleH = hl->glyph.scaleH;
04012                                    hl2.glyph.scaleV = hl->glyph.scaleV;
04013                                    setTextCh(ite, PNr, CurX, ls.y, d, tmp, tmp2, &hl2, pstyle, pag);
04014                             }
04015                             setTextCh(ite, PNr, CurX, ls.y, d, tmp, tmp2, hl, pstyle, pag);
04016                             if (hl->ch[0] == SpecialChars::OBJECT)
04017                             {
04018                                    InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
04019                                    CurX += (embedded.getItem()->gWidth + embedded.getItem()->lineWidth());
04020                             }
04021                             else
04022                                    CurX += hl->glyph.wide();
04023                             tabDist = CurX;
04024                      }
04025               }
04026        }
04027        else
04028        {
04029               double CurX = 0;
04030               for (int d = 0; d < ite->itemText.length(); ++d)
04031               {
04032                      const ScText * const hl = ite->itemText.item(d);
04033                      const QString ch = ite->itemText.text(d,1);
04034                      const CharStyle& chstyle(ite->itemText.charStyle(d));
04035                      const ParagraphStyle& pstyle(ite->itemText.paragraphStyle(d));
04036                      if ((ch[0] == SpecialChars::PARSEP) || (ch[0] == QChar(10)) || (ch[0] == SpecialChars::LINEBREAK) || (ch[0] == SpecialChars::FRAMEBREAK) || (ch[0] == SpecialChars::COLBREAK))
04037                             continue;
04038                      if (chstyle.effects() & ScStyle_SuppressSpace)
04039                             continue;
04040                      tTabValues = pstyle.tabValues();
04041                      if (chstyle.effects() & ScStyle_StartOfLine)
04042                             tabCc = 0;
04043                      if ((ch[0] == SpecialChars::TAB) && (tTabValues.count() != 0))
04044                      {
04045                             if ((!tTabValues[tabCc].tabFillChar.isNull()) && (tabCc < tTabValues.count()))
04046                             {
04047                                    ScText hl2;
04048                                    static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
04049                                    double wt = chstyle.font().charWidth(tTabValues[tabCc].tabFillChar, chstyle.fontSize());
04050                                    int coun = static_cast<int>((CurX+hl->glyph.xoffset - tabDist) / wt);
04051                                    double sPos = CurX+hl->glyph.xoffset - (CurX+hl->glyph.xoffset - tabDist) + 1;
04052                                    hl2.ch = QString(tTabValues[tabCc].tabFillChar);
04053                                    hl2.setTracking(0);
04054                                    hl2.setScaleH(1000);
04055                                    hl2.setScaleV(1000);
04056                                    hl2.glyph.yoffset = hl->glyph.yoffset;
04057                                    for (int cx = 0; cx < coun; ++cx)
04058                                    {
04059                                           hl2.glyph.xoffset =  sPos + wt * cx;
04060                                           if ((chstyle.effects() & ScStyle_Shadowed) && (chstyle.strokeColor() != CommonStrings::None))
04061                                           {
04062                                                  ScText hl3;
04063                                                  static_cast<CharStyle&>(hl3) = static_cast<const CharStyle&>(hl2);
04064                                                  hl3.ch = hl2.ch;
04065                                                  hl3.glyph.glyph = hl2.glyph.glyph;
04066                                                  hl3.setFillColor(hl2.strokeColor());
04067                                                  hl3.glyph.yoffset = hl2.glyph.yoffset - (chstyle.fontSize() * chstyle.shadowYOffset() / 10000.0);
04068                                                  hl3.glyph.xoffset = hl2.glyph.xoffset + (chstyle.fontSize() * chstyle.shadowXOffset() / 10000.0);
04069                                                  setTextCh(ite, PNr, 0, 0, d, tmp, tmp2, &hl3, pstyle, pag);
04070                                           }
04071                                           setTextCh(ite, PNr, 0, 0, d, tmp, tmp2, &hl2, pstyle, pag);
04072                                    }
04073                                    tabCc++;
04074                             }
04075                             else
04076                             {
04077                                    tabCc++;
04078                             }
04079                      }
04080                      if (ch[0] == SpecialChars::TAB) 
04081                      {
04082                             CurX += hl->glyph.wide();
04083                             continue;
04084                      }
04085                      if ((chstyle.effects() & ScStyle_Shadowed) && (chstyle.strokeColor() != CommonStrings::None))
04086                      {
04087                             ScText hl2;
04088                             hl2.ch = ch;
04089                             hl2.glyph.glyph = hl->glyph.glyph;
04090                             static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
04091                             hl2.setFillColor(hl->strokeColor());
04092                             hl2.glyph.yoffset = hl->glyph.yoffset - (chstyle.fontSize() * chstyle.shadowYOffset() / 10000.0);
04093                             hl2.glyph.xoffset = hl->glyph.xoffset + (chstyle.fontSize() * chstyle.shadowXOffset() / 10000.0);
04094                             hl2.glyph.scaleH = hl->glyph.scaleH;
04095                             hl2.glyph.scaleV = hl->glyph.scaleV;
04096                             setTextCh(ite, PNr, 0, 0, d, tmp, tmp2, &hl2, pstyle, pag);
04097                      }
04098                      setTextCh(ite, PNr, 0, 0, d, tmp, tmp2, hl, pstyle, pag);
04099                      CurX += hl->glyph.wide();
04100                      tabDist = CurX;
04101               }
04102        }
04103 #endif
04104        if (ite->itemType() == PageItem::TextFrame)
04105               tmp += "ET\n"+tmp2;
04106        return tmp;
04107 }
04108 
04109 void PDFlib::setTextCh(PageItem *ite, uint PNr, double x,  double y, uint d, QString &tmp, QString &tmp2, const ScText *hl, const ParagraphStyle& pstyle, const Page* pag)
04110 {
04111 #ifndef NLS_PROTO
04112        QString FillColor = "";
04113        QString StrokeColor = "";
04114        if (ite->asPathText())
04115        {
04116               tmp += "q\n";
04117               QWMatrix trafo = QWMatrix( 1, 0, 0, -1, -hl->PRot, 0 );
04118               if (ite->textPathFlipped)
04119                      trafo *= QWMatrix(1, 0, 0, -1, 0, 0);
04120               if (ite->textPathType == 0)
04121                      trafo *= QWMatrix( hl->PtransX, -hl->PtransY, -hl->PtransY, -hl->PtransX, hl->glyph.xoffset, -hl->glyph.yoffset );
04122               else if (ite->textPathType == 1)
04123                      trafo *= QWMatrix(1, 0, 0, -1, hl->glyph.xoffset, -hl->glyph.yoffset );
04124               else if (ite->textPathType == 2)
04125               {
04126                      double a = 1;
04127                      double b = -1;
04128                      if (hl->PtransX < 0)
04129                      {
04130                             a = -1;
04131                             b = 1;
04132                      }
04133                      if (fabs(hl->PtransX) > 0.1)
04134                             trafo *= QWMatrix( a, (hl->PtransY / hl->PtransX) * b, 0, -1, hl->glyph.xoffset, -hl->glyph.yoffset ); // ID's Skew mode
04135                      else
04136                             trafo *= QWMatrix( a, 6 * b, 0, -1, hl->glyph.xoffset, -hl->glyph.yoffset );
04137               }
04138               tmp += FToStr(trafo.m11())+" "+FToStr(trafo.m12())+" "+FToStr(trafo.m21())+" "+FToStr(trafo.m22())+" "+FToStr(trafo.dx())+" "+FToStr(trafo.dy())+" cm\n";
04139               if (ite->BaseOffs != 0)
04140                      tmp += "1 0 0 1 0 "+FToStr( -ite->BaseOffs)+" cm\n";
04141               if (hl->ch != SpecialChars::OBJECT)
04142                      tmp += "BT\n";
04143        }
04144        int tsz = hl->fontSize();
04145        QString chstr = hl->ch;
04146        const CharStyle& style(*hl);
04147        
04148 /*     if (hl->effects() & ScStyle_DropCap)
04149        {
04150               if (pstyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
04151                      tsz = qRound(10 * ((doc.typographicSettings.valueBaseGrid * (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (hl->font().realCharHeight(chstr[0], 10))));
04152               else
04153               {
04154                      if (pstyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
04155                             tsz = qRound(10 * ((pstyle.lineSpacing() *  (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (hl->font().realCharHeight(chstr[0], 10))));
04156                      else
04157                      {
04158                             double currasce = hl->font().height(pstyle.charStyle().fontSize());
04159                             tsz = qRound(10 * ((currasce * (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / hl->font().realCharHeight(chstr[0], 10)));
04160                      }
04161               }
04162        }
04163        */
04164        InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
04165        if ((hl->ch == SpecialChars::OBJECT) && (embedded.hasItem()))
04166        {
04167               if (!ite->asPathText())
04168               {
04169                      tmp += "ET\n"+tmp2;
04170                      tmp2 = "";
04171               }
04172               QPtrList<PageItem> emG = embedded.getGroupedItems();
04173               QPtrStack<PageItem> groupStack;
04174               for (uint em = 0; em < emG.count(); ++em)
04175               {
04176                      PageItem* embedded = emG.at(em);
04177                      if (embedded->isGroupControl)
04178                      {
04179                             tmp2 += "q\n";
04180                             FPointArray cl = embedded->PoLine.copy();
04181                             FPointArray clb = embedded->PoLine.copy();
04182                             QWMatrix mm;
04183                             if (ite->asPathText())
04184                                    mm.translate(embedded->gXpos * (style.scaleH() / 1000.0), ((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)) * -1);
04185                             else
04186                                    mm.translate(x + hl->glyph.xoffset + embedded->gXpos * (style.scaleH() / 1000.0), (y + hl->glyph.yoffset - (embedded->gHeight * (style.scaleV() / 1000.0)) + embedded->gYpos * (style.scaleV() / 1000.0)));
04187                             if (style.baselineOffset() != 0)
04188                                    mm.translate(0, embedded->gHeight * (style.baselineOffset() / 1000.0));
04189                             if (style.scaleH() != 1000)
04190                                    mm.scale(style.scaleH() / 1000.0, 1);
04191                             if (style.scaleV() != 1000)
04192                                    mm.scale(1, style.scaleV() / 1000.0);
04193                             mm.rotate(embedded->rotation());
04194                             cl.map( mm );
04195                             embedded->PoLine = cl;
04196                             tmp2 += SetClipPath(embedded);
04197                             tmp2 += "h W* n\n";
04198                             groupStack.push(embedded->groupsLastItem);
04199                             embedded->PoLine = clb.copy();
04200                             continue;
04201                      }
04202                      tmp2 += "q\n";
04203                      if (ite->asPathText())
04204                             tmp2 +=  FToStr(style.scaleH() / 1000.0)+" 0 0 "+FToStr(style.scaleV() / 1000.0)+" "+FToStr(embedded->gXpos * (style.scaleH() / 1000.0))+" "+FToStr((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)+embedded->gHeight * (style.baselineOffset() / 1000.0))+" cm\n";
04205                      else
04206                             tmp2 +=  FToStr(style.scaleH() / 1000.0)+" 0 0 "+FToStr(style.scaleV() / 1000.0)+" "+FToStr(x+hl->glyph.xoffset + embedded->gXpos * (style.scaleH() / 1000.0))+" "+FToStr(-y-hl->glyph.yoffset + (embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)+embedded->gHeight * (style.baselineOffset() / 1000.0))+" cm\n";
04207                      tmp2 += PDF_ProcessItem(embedded, pag, PNr, true);
04208                      tmp2 += "Q\n";
04209                      if (groupStack.count() != 0)
04210                      {
04211                             while (embedded == groupStack.top())
04212                             {
04213                                    tmp2 += "Q\n";
04214                                    groupStack.pop();
04215                             }
04216                      }
04217               }
04218               tmp += tmp2+"\n";
04219               tmp2 = "";
04220               if (ite->asPathText())
04221                      tmp += "Q\n";
04222               else
04223                      tmp += "BT\n";
04224               return;
04225        }
04226 
04227        uint glyph = hl->glyph.glyph;
04228 
04229        if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
04230               glyph == (ScFace::CONTROL_GLYPHS + 32)) 
04231        {
04232               glyph = style.font().char2CMap(QChar(' '));
04233               chstr = " ";
04234        }
04235        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
04236        {
04237               glyph = style.font().char2CMap(QChar('-'));
04238               chstr = "-";
04239        }
04240        
04241        if (glyph < ScFace::CONTROL_GLYPHS)
04242        {
04243               if (style.strokeColor() != CommonStrings::None)
04244               {
04245                      StrokeColor = "";
04246                      StrokeColor += putColor(style.strokeColor(), style.strokeShade(), false);
04247               }
04248               if (style.fillColor() != CommonStrings::None)
04249               {
04250                      FillColor = "";
04251                      FillColor += putColor(style.fillColor(), style.fillShade(), true);
04252               }
04253               if (((style.effects() & ScStyle_Underline) && (chstr != SpecialChars::PARSEP))  || ((style.effects() & ScStyle_UnderlineWords) && (!chstr[0].isSpace())))
04254               {
04255                      //            double Ulen = style.font().charWidth(chstr[0], style.fontSize()) * (hl->glyph.scaleH);
04256                      double Ulen = hl->glyph.xadvance;
04257                      double Upos, Uwid, kern;
04258                      if (style.effects() & ScStyle_StartOfLine)
04259                             kern = 0;
04260                      else
04261                             kern = style.fontSize() * style.tracking() / 10000.0;
04262                      if ((style.underlineOffset() != -1) || (style.underlineWidth() != -1))
04263                      {
04264                             if (style.underlineOffset() != -1)
04265                                    Upos = (style.underlineOffset() / 1000.0) * (style.font().descent(style.fontSize() / 10.0));
04266                             else
04267                                    Upos = style.font().underlinePos(style.fontSize() / 10.0);
04268                             if (style.underlineWidth() != -1)
04269                                    Uwid = (style.underlineWidth() / 1000.0) * (style.fontSize() / 10.0);
04270                             else
04271                                    Uwid = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1);
04272                      }
04273                      else
04274                      {
04275                             Upos = style.font().underlinePos(style.fontSize() / 10.0);
04276                             Uwid = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1);
04277                      }
04278                      if (style.baselineOffset() != 0)
04279                             Upos += (style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0);
04280                      if (style.fillColor() != CommonStrings::None)
04281                             tmp2 += putColor(style.fillColor(), style.fillShade(), false);
04282                      tmp2 += FToStr(Uwid)+" w\n";
04283                      if (style.effects() & ScStyle_Subscript)
04284                      {
04285                             tmp2 += FToStr(x+hl->glyph.xoffset-kern)+" "+FToStr(-y-hl->glyph.yoffset+Upos)+" m\n";
04286                             tmp2 += FToStr(x+hl->glyph.xoffset+Ulen)+" "+FToStr(-y-hl->glyph.yoffset+Upos)+" l\n";
04287                      }
04288                      else
04289                      {
04290                             tmp2 += FToStr(x+hl->glyph.xoffset-kern)+" "+FToStr(-y+Upos)+" m\n";
04291                             tmp2 += FToStr(x+hl->glyph.xoffset+Ulen)+" "+FToStr(-y+Upos)+" l\n";
04292                      }
04293                      tmp2 += "S\n";
04294               }
04295               if (!style.font().hasNames())
04296               {
04297                      if (glyph != style.font().char2CMap(QChar(' ')))
04298                      {
04299                             if ((style.strokeColor() != CommonStrings::None) && (style.effects() & ScStyle_Outline))
04300                             {
04301                                    tmp2 += FToStr((tsz * style.outlineWidth() / 1000.0) / tsz)+" w\n[] 0 d\n0 J\n0 j\n";
04302                                    tmp2 += StrokeColor;
04303                             }
04304                             if (style.fillColor() != CommonStrings::None)
04305                                    tmp2 += FillColor;
04306                             tmp2 += "q\n";
04307                             if (ite->itemType() == PageItem::PathText)
04308                             {
04309                                    QWMatrix trafo = QWMatrix( 1, 0, 0, -1, -hl->PRot, 0 );
04310                                    if (ite->textPathFlipped)
04311                                           trafo *= QWMatrix(1, 0, 0, -1, 0, 0);
04312                                    if (ite->textPathType == 0)
04313                                           trafo *= QWMatrix( hl->PtransX, -hl->PtransY, -hl->PtransY, -hl->PtransX, hl->glyph.xoffset, -hl->glyph.yoffset );
04314                                    else if (ite->textPathType == 1)
04315                                           trafo *= QWMatrix(1, 0, 0, -1, hl->glyph.xoffset, -hl->glyph.yoffset );
04316                                    tmp2 += FToStr(trafo.m11())+" "+FToStr(trafo.m12())+" "+FToStr(trafo.m21())+" "+FToStr(trafo.m22())+" "+FToStr(trafo.dx())+" "+FToStr(trafo.dy())+" cm\n";
04317                             }
04318                             if (!ite->asPathText())
04319                             {
04320                                    if (ite->reversed())
04321                                    {
04322                                           double wid = style.font().charWidth(chstr[0], style.fontSize()) * (hl->glyph.scaleH);
04323                                           tmp2 += "1 0 0 1 "+FToStr(x+hl->glyph.xoffset)+" "+FToStr((y+hl->glyph.yoffset - (tsz / 10.0)) * -1 + ((tsz / 10.0) * (style.baselineOffset() / 1000.0)))+" cm\n";
04324                                           tmp2 += "-1 0 0 1 0 0 cm\n";
04325                                           tmp2 += "1 0 0 1 "+FToStr(-wid)+" 0 cm\n";
04326                                           tmp2 += FToStr(tsz / 10.0)+" 0 0 "+FToStr(tsz / 10.0)+" 0 0 cm\n";
04327                                    }
04328                                    else
04329                                    {
04330                                           tmp2 += FToStr(tsz / 10.0)+" 0 0 "+FToStr(tsz / 10.0)+" "+FToStr(x+hl->glyph.xoffset)+" "+FToStr((y+hl->glyph.yoffset - (tsz / 10.0)) * -1 + ((tsz / 10.0) * (style.baselineOffset() / 1000.0)))+" cm\n";
04331                                    }
04332                             }
04333                             else
04334                             {
04335                                    if (ite->BaseOffs != 0)
04336                                           tmp2 += "1 0 0 1 0 "+FToStr( -ite->BaseOffs)+" cm\n";
04337                                    tmp2 += FToStr(tsz / 10.0)+" 0 0 "+FToStr(tsz / 10.0)+" 0 "+FToStr(tsz / 10.0)+" cm\n";
04338                             }
04339                             if (hl->glyph.scaleV != 1.0)
04340                                    tmp2 += "1 0 0 1 0 "+FToStr( (((tsz / 10.0) - (tsz / 10.0) * (hl->glyph.scaleV)) / (tsz / 10.0)) * -1)+" cm\n";
04341                             tmp2 += FToStr(QMAX(hl->glyph.scaleH, 0.1))+" 0 0 "+FToStr(QMAX(hl->glyph.scaleV, 0.1))+" 0 0 cm\n";
04342                             if (style.fillColor() != CommonStrings::None)
04343                                    tmp2 += "/"+style.font().psName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+QString::number(glyph)+" Do\n";
04344                             if (style.effects() & ScStyle_Outline)
04345                             {
04346                                    FPointArray gly = style.font().glyphOutline(glyph);
04347                                    QWMatrix mat;
04348                                    mat.scale(0.1, 0.1);
04349                                    gly.map(mat);
04350                                    bool nPath = true;
04351                                    FPoint np;
04352                                    if (gly.size() > 3)
04353                                    {
04354                                           for (uint poi=0; poi<gly.size()-3; poi += 4)
04355                                           {
04356                                                  if (gly.point(poi).x() > 900000)
04357                                                  {
04358                                                         tmp2 += "h\n";
04359                                                         nPath = true;
04360                                                         continue;
04361                                                  }
04362                                                  if (nPath)
04363                                                  {
04364                                                         np = gly.point(poi);
04365                                                         tmp2 += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
04366                                                         nPath = false;
04367                                                  }
04368                                                  np = gly.point(poi+1);
04369                                                  tmp2 += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04370                                                  np = gly.point(poi+3);
04371                                                  tmp2 += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04372                                                  np = gly.point(poi+2);
04373                                                  tmp2 += FToStr(np.x())+" "+FToStr(-np.y())+" c\n";
04374                                           }
04375                                    }
04376                                    tmp2 += "s\n";
04377                             }
04378                             tmp2 += "Q\n";
04379                      }
04380               }
04381               else
04382               {
04383                      if (style.strokeColor() != CommonStrings::None)
04384                      {
04385                             if ((style.effects() & ScStyle_Underline) || (style.effects() & ScStyle_Strikethrough))
04386                                    tmp2 += StrokeColor;
04387                      }
04388                      if (style.fillColor() != CommonStrings::None)
04389                      {
04390                             if ((style.effects() & ScStyle_Underline) || (style.effects() & ScStyle_Strikethrough))
04391                                    tmp2 += FillColor;
04392                      }
04393                      if (glyph != style.font().char2CMap(QChar(' ')))
04394                      {
04395                             uint idx = hl->glyph.glyph;
04396                             uint idx1;
04397                             if (Options.SubsetList.contains(style.font().replacementName()))
04398                                    idx1 = Type3Fonts[UsedFontsP[style.font().replacementName()]][idx] / 255;
04399                             else
04400                                    idx1 = idx / 224;
04401                             tmp += UsedFontsP[style.font().replacementName()]+"S"+QString::number(idx1)+" "+FToStr(tsz / 10.0)+" Tf\n";
04402                             if (style.strokeColor() != CommonStrings::None)
04403                                    tmp += StrokeColor;
04404                             if (style.fillColor() != CommonStrings::None)
04405                                    tmp += FillColor;
04406                             if (style.effects() & 4)
04407                                    tmp += FToStr(tsz * style.outlineWidth() / 10000.0) + (style.fillColor() != CommonStrings::None ? " w 2 Tr\n" : " w 1 Tr\n");
04408                             else
04409                                    tmp += "0 Tr\n";
04410                             if (!ite->asPathText())
04411                             {
04412                                    if (ite->reversed())
04413                                    {
04414                                           double wtr = hl->glyph.xadvance;
04415                                           tmp +=  FToStr(-QMAX(hl->glyph.scaleH, 0.1))+" 0 0 "+FToStr(QMAX(hl->glyph.scaleV, 0.1)) +" "+FToStr(x+hl->glyph.xoffset+wtr)+" "+FToStr(-y-hl->glyph.yoffset+(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0))+" Tm\n";
04416                                    }
04417                                    else
04418                                           tmp +=  FToStr(QMAX(hl->glyph.scaleH, 0.1))+" 0 0 "+FToStr(QMAX(hl->glyph.scaleV, 0.1))+" "+FToStr(x+hl->glyph.xoffset)+" "+FToStr(-y-hl->glyph.yoffset+(style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0))+" Tm\n";
04419                             }
04420                             else
04421                                    tmp += FToStr(QMAX(hl->glyph.scaleH, 0.1))+" 0 0 "+FToStr(QMAX(hl->glyph.scaleV, 0.1))+" 0 0 Tm\n";
04422                             uchar idx2;
04423                             if (Options.SubsetList.contains(style.font().replacementName()))
04424                                    idx2 = Type3Fonts[UsedFontsP[style.font().replacementName()]][idx] % 255;
04425                             else
04426                                    idx2 = idx % 224 + 32;
04427                             tmp += "<"+QString(toHex(idx2))+"> Tj\n";
04428                      }
04429               }
04430               if ((style.effects() & ScStyle_Strikethrough) && (chstr != SpecialChars::PARSEP))
04431               {
04432                      //            double Ulen = style.font().charWidth(chstr[0], style.fontSize()) * (hl->glyph.scaleH);
04433                      double Ulen = hl->glyph.xadvance;
04434                      double Upos, Uwid, kern;
04435                      if (hl->effects() & ScStyle_StartOfLine)
04436                             kern = 0;
04437                      else
04438                             kern = style.fontSize() * style.tracking() / 10000.0;
04439                      if ((style.strikethruOffset() != -1) || (style.strikethruWidth() != -1))
04440                      {
04441                             if (style.strikethruOffset() != -1)
04442                                    Upos = (style.strikethruOffset() / 1000.0) * (style.font().ascent(style.fontSize() / 10.0));
04443                             else
04444                                    Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
04445                             if (style.strikethruWidth() != -1)
04446                                    Uwid = (style.strikethruWidth() / 1000.0) * (style.fontSize() / 10.0);
04447                             else
04448                                    Uwid = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1);
04449                      }
04450                      else
04451                      {
04452                             Upos = style.font().strikeoutPos(style.fontSize() / 10.0);
04453                             Uwid = QMAX(style.font().strokeWidth(style.fontSize() / 10.0), 1);
04454                      }
04455                      if (style.baselineOffset() != 0)
04456                             Upos += (style.fontSize() / 10.0) * (style.baselineOffset() / 1000.0);
04457                      if (style.fillColor() != CommonStrings::None)
04458                             tmp2 += putColor(style.fillColor(), style.fillShade(), false);
04459                      tmp2 += FToStr(Uwid)+" w\n";
04460                      tmp2 += FToStr(x+hl->glyph.xoffset-kern)+" "+FToStr(-y-hl->glyph.yoffset+Upos)+" m\n";
04461                      tmp2 += FToStr(x+hl->glyph.xoffset+Ulen)+" "+FToStr(-y-hl->glyph.yoffset+Upos)+" l\n";
04462                      tmp2 += "S\n";
04463               }
04464               if (ite->asPathText())
04465               {
04466                      tmp += "ET\nQ\n"+tmp2;
04467                      tmp2 = "";
04468               }
04469        }
04470        if (hl->glyph.more) {
04471               // ugly hack until setTextCh interface is changed
04472               ScText hl2(*hl);
04473               hl2.glyph = *(hl->glyph.more);
04474               setTextCh(ite, PNr, x + hl->glyph.xadvance, y, d, tmp, tmp2, &hl2, pstyle, pag);
04475               // don't let hl2's destructor delete these!
04476               hl2.glyph.more = 0;
04477        }
04478        
04479 #endif
04480 }
04481 
04482 QString PDFlib::SetFarbe(const QString& farbe, int Shade)
04483 {
04484        const ScColor& col = doc.PageColors[farbe];
04485        return SetFarbe(col, Shade);
04486 }
04487 
04488 QString PDFlib::SetFarbe(const ScColor& farbe, int Shade)
04489 {
04490        QString tmp;
04491        RGBColor rgb;
04492        CMYKColor cmyk;
04493        int h, s, v, k;
04494        ScColor tmpC(farbe);
04495        QColor tmpR;
04496        if (Options.isGrayscale)
04497        {
04498               tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
04499               tmpR.rgb(&h, &s, &v);
04500               tmp = FToStr((0.3 * h + 0.59 * s + 0.11 * v) / 255.0);
04501               return tmp;
04502        }
04503        if (Options.UseRGB)
04504        {
04505               tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
04506               tmpR.rgb(&h, &s, &v);
04507               tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04508        }
04509        else
04510        {
04511               if ((doc.HasCMS) && (Options.UseProfiles))
04512               {
04513                      if (tmpC.getColorModel() == colorModelCMYK)
04514                      {
04515                             ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
04516                             cmyk.getValues(h, s, v, k);
04517                             tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04518                      }
04519                      else
04520                      {
04521                             if (Options.SComp == 3)
04522                             {
04523                                    ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
04524                                    rgb.getValues(h, s, v);
04525                                    tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04526                             }
04527                             else
04528                             {
04529                                    ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
04530                                    cmyk.getValues(h, s, v, k);
04531                                    tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04532                             }
04533                      }
04534               }
04535               else
04536               {
04537                      ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
04538                      cmyk.getValues(h, s, v, k);
04539                      tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04540               }
04541        }
04542        return tmp;
04543 }
04544 
04545 QString PDFlib::SetFarbeGrad(const QString& farbe, int Shade)
04546 {
04547        QString tmp;
04548        RGBColor rgb;
04549        CMYKColor cmyk;
04550        int h, s, v, k;
04551        ScColor tmpC(doc.PageColors[farbe]);
04552        QColor tmpR;
04553        if (Options.isGrayscale)
04554        {
04555               tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
04556               tmpR.rgb(&h, &s, &v);
04557               tmp = FToStr((0.3 * h + 0.59 * s + 0.11 * v) / 255.0);
04558               return tmp;
04559        }
04560        if (Options.UseRGB)
04561        {
04562               tmpR = ScColorEngine::getShadeColor(tmpC, &doc, Shade);
04563               tmpR.rgb(&h, &s, &v);
04564               tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04565        }
04566        else
04567        {
04568               if ((doc.HasCMS) && (Options.UseProfiles))
04569               {
04570                      if (Options.SComp == 3)
04571                      {
04572                             ScColorEngine::getShadeColorRGB(tmpC, &doc, rgb, Shade);
04573                             rgb.getValues(h, s, v);
04574                             tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04575                      }
04576                      else
04577                      {
04578                             ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
04579                             cmyk.getValues(h, s, v, k);
04580                             tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04581                      }
04582               }
04583               else
04584               {
04585                      ScColorEngine::getShadeColorCMYK(tmpC, &doc, cmyk, Shade);
04586                      cmyk.getValues(h, s, v, k);
04587                      tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04588               }
04589        }
04590        return tmp;
04591 }
04592 
04593 /*CB 2982: cache code is borked somehow, original function is above
04594 QString PDFlib::SetFarbe(const QString& farbe, int Shade)
04595 {
04596        // Cache last color
04597        static QString lastColorName;
04598        static QString lastColorData;
04599        if (farbe == lastColorName)
04600               return lastColorData;
04601        // Not cached, build the color and cache it
04602        lastColorName = farbe;
04603        QString tmp;
04604        ScColor tmpC(doc.PageColors[farbe]);
04605        int h, s, v, k;
04606        QColor tmpR;
04607        if (Options.isGrayscale)
04608        {
04609               tmpR = tmpC.getShadeColor(Shade);
04610               tmpR.rgb(&h, &s, &v);
04611               tmp = lastColorData = FToStr((0.3 * h + 0.59 * s + 0.11 * v) / 255.0);
04612               return tmp;
04613        }
04614        if (Options.UseRGB)
04615        {
04616               tmpR = tmpC.getShadeColor(Shade);
04617               tmpR.rgb(&h, &s, &v);
04618               tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04619        }
04620        else
04621        {
04622               if ((doc.HasCMS) && (Options.UseProfiles))
04623               {
04624                      if (tmpC.getColorModel() == colorModelCMYK)
04625                      {
04626                             tmpC.getShadeColorCMYK(&h, &s, &v, &k, Shade);
04627                             tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04628                      }
04629                      else
04630                      {
04631                             if (Options.SComp == 3)
04632                             {
04633                                    tmpC.getShadeColorRGB(&h, &s, &v, Shade);
04634                                    tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0);
04635                             }
04636                             else
04637                             {
04638                                    tmpC.getShadeColorCMYK(&h, &s, &v, &k, Shade);
04639                                    tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04640                             }
04641                      }
04642               }
04643               else
04644               {
04645                      tmpC.getShadeColorCMYK(&h, &s, &v, &k, Shade);
04646                      tmp = FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" "+FToStr(k / 255.0);
04647               }
04648        }
04649        lastColorData = tmp;
04650        return tmp;
04651 }
04652 */
04653 
04654 QString PDFlib::SetClipPathImage(PageItem *ite)
04655 {
04656        QString tmp("");
04657        if (ite->imageClip.size() > 3)
04658        {
04659               bool nPath = true;
04660               for (uint poi=0; poi<ite->imageClip.size()-3; poi += 4)
04661               {
04662                      if (ite->imageClip.point(poi).x() > 900000)
04663                      {
04664                             tmp += "h\n";
04665                             nPath = true;
04666                             continue;
04667                      }
04668                      FPoint np;
04669                      if (nPath)
04670                      {
04671                             np = ite->imageClip.point(poi);
04672                             tmp += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
04673                             nPath = false;
04674                      }
04675                      np = ite->imageClip.point(poi+1);
04676                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04677                      np = ite->imageClip.point(poi+3);
04678                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04679                      np = ite->imageClip.point(poi+2);
04680                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" c\n";
04681               }
04682        }
04683        return tmp;
04684 }
04685 
04686 QString PDFlib::SetClipPath(PageItem *ite, bool poly)
04687 {
04688        QString tmp("");
04689        if (ite->PoLine.size() > 3)
04690        {
04691               bool nPath = true;
04692               for (uint poi=0; poi<ite->PoLine.size()-3; poi += 4)
04693               {
04694                      if (ite->PoLine.point(poi).x() > 900000)
04695                      {
04696                             if (poly)
04697                                    tmp += "h\n";
04698                             nPath = true;
04699                             continue;
04700                      }
04701                      FPoint np;
04702                      if (nPath)
04703                      {
04704                             np = ite->PoLine.point(poi);
04705                             tmp += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
04706                             nPath = false;
04707                      }
04708                      np = ite->PoLine.point(poi+1);
04709                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04710                      np = ite->PoLine.point(poi+3);
04711                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04712                      np = ite->PoLine.point(poi+2);
04713                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" c\n";
04714               }
04715        }
04716        return tmp;
04717 }
04718 
04719 QString PDFlib::SetClipPathArray(FPointArray *ite, bool poly)
04720 {
04721        QString tmp("");
04722        if (ite->size() > 3)
04723        {
04724               bool nPath = true;
04725               for (uint poi=0; poi<ite->size()-3; poi += 4)
04726               {
04727                      if (ite->point(poi).x() > 900000)
04728                      {
04729                             if (poly)
04730                                    tmp += "h\n";
04731                             nPath = true;
04732                             continue;
04733                      }
04734                      FPoint np;
04735                      if (nPath)
04736                      {
04737                             np = ite->point(poi);
04738                             tmp += FToStr(np.x())+" "+FToStr(-np.y())+" m\n";
04739                             nPath = false;
04740                      }
04741                      np = ite->point(poi+1);
04742                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04743                      np = ite->point(poi+3);
04744                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" ";
04745                      np = ite->point(poi+2);
04746                      tmp += FToStr(np.x())+" "+FToStr(-np.y())+" c\n";
04747               }
04748        }
04749        return tmp;
04750 }
04751 
04752 QString PDFlib::PDF_TransparenzFill(PageItem *currItem)
04753 {
04754        StartObj(ObjCounter);
04755        QString ShName = ResNam+QString::number(ResCount);
04756        Transpar[ShName] = ObjCounter;
04757        ResCount++;
04758        ObjCounter++;
04759        PutDoc("<< /Type /ExtGState\n");
04760        PutDoc("/ca "+FToStr(1.0 - currItem->fillTransparency())+"\n");
04761        PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
04762        PutDoc("/BM /");
04763        switch (currItem->fillBlendmode())
04764        {
04765               case 0:
04766                      PutDoc("Normal");
04767                      break;
04768               case 1:
04769                      PutDoc("Darken");
04770                      break;
04771               case 2:
04772                      PutDoc("Lighten");
04773                      break;
04774               case 3:
04775                      PutDoc("Multiply");
04776                      break;
04777               case 4:
04778                      PutDoc("Screen");
04779                      break;
04780               case 5:
04781                      PutDoc("Overlay");
04782                      break;
04783               case 6:
04784                      PutDoc("HardLight");
04785                      break;
04786               case 7:
04787                      PutDoc("SoftLight");
04788                      break;
04789               case 8:
04790                      PutDoc("Difference");
04791                      break;
04792               case 9:
04793                      PutDoc("Exclusion");
04794                      break;
04795               case 10:
04796                      PutDoc("ColorDodge");
04797                      break;
04798               case 11:
04799                      PutDoc("ColorBurn");
04800                      break;
04801               case 12:
04802                      PutDoc("Hue");
04803                      break;
04804               case 13:
04805                      PutDoc("Saturation");
04806                      break;
04807               case 14:
04808                      PutDoc("Color");
04809                      break;
04810               case 15:
04811                      PutDoc("Luminosity");
04812                      break;
04813        }
04814        PutDoc("\n>>\nendobj\n");
04815        QString tmp("/"+ShName+" gs\n");
04816        return tmp;
04817 }
04818 
04819 QString PDFlib::PDF_TransparenzStroke(PageItem *currItem)
04820 {
04821        StartObj(ObjCounter);
04822        QString ShName = ResNam+QString::number(ResCount);
04823        Transpar[ShName] = ObjCounter;
04824        ResCount++;
04825        ObjCounter++;
04826        PutDoc("<< /Type /ExtGState\n");
04827        PutDoc("/CA "+FToStr(1.0 - currItem->lineTransparency())+"\n");
04828        PutDoc("/SMask /None\n/AIS false\n/OPM 1\n");
04829        PutDoc("/BM /");
04830        switch (currItem->fillBlendmode())
04831        {
04832               case 0:
04833                      PutDoc("Normal");
04834                      break;
04835               case 1:
04836                      PutDoc("Darken");
04837                      break;
04838               case 2:
04839                      PutDoc("Lighten");
04840                      break;
04841               case 3:
04842                      PutDoc("Multiply");
04843                      break;
04844               case 4:
04845                      PutDoc("Screen");
04846                      break;
04847               case 5:
04848                      PutDoc("Overlay");
04849                      break;
04850               case 6:
04851                      PutDoc("HardLight");
04852                      break;
04853               case 7:
04854                      PutDoc("SoftLight");
04855                      break;
04856               case 8:
04857                      PutDoc("Difference");
04858                      break;
04859               case 9:
04860                      PutDoc("Exclusion");
04861                      break;
04862               case 10:
04863                      PutDoc("ColorDodge");
04864                      break;
04865               case 11:
04866                      PutDoc("ColorBurn");
04867                      break;
04868               case 12:
04869                      PutDoc("Hue");
04870                      break;
04871               case 13:
04872                      PutDoc("Saturation");
04873                      break;
04874               case 14:
04875                      PutDoc("Color");
04876                      break;
04877               case 15:
04878                      PutDoc("Luminosity");
04879                      break;
04880        }
04881        PutDoc("\n>>\nendobj\n");
04882        QString tmp("/"+ShName+" gs\n");
04883        return tmp;
04884 }
04885 
04886 QString PDFlib::PDF_Gradient(PageItem *currItem)
04887 {
04888        if (currItem->GrType == 8)
04889        {
04890               QPtrStack<PageItem> groupStack;
04891               QString tmp2 = "";
04892               ScPattern *pat = &doc.docPatterns[currItem->pattern()];
04893               for (uint em = 0; em < pat->items.count(); ++em)
04894               {
04895                      PageItem* item = pat->items.at(em);
04896                      if (item->isGroupControl)
04897                      {
04898                             tmp2 += "q\n";
04899                             FPointArray cl = item->PoLine.copy();
04900                             FPointArray clb = item->PoLine.copy();
04901                             QWMatrix mm;
04902                             mm.translate(item->gXpos, item->gYpos);
04903                             mm.rotate(item->rotation());
04904                             cl.map( mm );
04905                             item->PoLine = cl;
04906                             tmp2 += SetClipPath(item);
04907                             tmp2 += "h W* n\n";
04908                             groupStack.push(item->groupsLastItem);
04909                             item->PoLine = clb.copy();
04910                             continue;
04911                      }
04912                      tmp2 += "q\n";
04913                      tmp2 +=  "1 0 0 1 "+FToStr(item->gXpos)+" "+FToStr(-item->gYpos)+" cm\n";
04914                      item->setXYPos(item->xPos() + ActPageP->xOffset(), item->yPos() + ActPageP->yOffset(), true);
04915                      inPattern++;
04916                      tmp2 += PDF_ProcessItem(item, doc.Pages->at(0), 0, true, true);
04917                      item->setXYPos(item->xPos() - ActPageP->xOffset(), item->yPos() - ActPageP->yOffset(), true);
04918                      inPattern--;
04919                      tmp2 += "Q\n";
04920                      if (groupStack.count() != 0)
04921                      {
04922                             while (item == groupStack.top())
04923                             {
04924                                    tmp2 += "Q\n";
04925                                    groupStack.pop();
04926                             }
04927                      }
04928               }
04929               if ((Options.Compress) && (CompAvail))
04930                      tmp2 = CompressStr(&tmp2);
04931               StartObj(ObjCounter);
04932               ObjCounter++;
04933               PutDoc("<< /Type /Pattern\n");
04934               PutDoc("/PatternType 1\n");
04935               PutDoc("/PaintType 1\n");
04936               PutDoc("/TilingType 1\n");
04937               PutDoc("/BBox [ 0 0 "+FToStr(pat->width)+" "+FToStr(-pat->height)+" ]\n");
04938               QWMatrix mpa;
04939               if (inPattern == 0)
04940               {
04941                      mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
04942                      mpa.rotate(-currItem->rotation());
04943               }
04944               double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
04945               currItem->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
04946               mpa.translate(patternOffsetX, -patternOffsetY);
04947               mpa.rotate(-patternRotation);
04948               mpa.scale(pat->scaleX, pat->scaleY);
04949               mpa.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
04950               PutDoc("/Matrix ["+FToStr(mpa.m11())+" "+FToStr(mpa.m12())+" "+FToStr(mpa.m21())+" "+FToStr(mpa.m22())+" "+FToStr(mpa.dx())+" "+FToStr(mpa.dy())+"]\n");
04951               PutDoc("/XStep "+FToStr(pat->width)+"\n");
04952               PutDoc("/YStep "+FToStr(pat->height)+"\n");
04953               PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
04954               if (Seite.ImgObjects.count() != 0)
04955               {
04956                      PutDoc("/XObject <<\n");
04957                      QMap<QString,int>::Iterator it;
04958                      for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
04959                             PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
04960                      PutDoc(">>\n");
04961               }
04962               if (Seite.FObjects.count() != 0)
04963               {
04964                      PutDoc("/Font << \n");
04965                      QMap<QString,int>::Iterator it2;
04966                      for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
04967                             PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
04968                      PutDoc(">>\n");
04969               }
04970               if (Shadings.count() != 0)
04971               {
04972                      PutDoc("/Shading << \n");
04973                      QMap<QString,int>::Iterator it3;
04974                      for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
04975                             PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
04976                      PutDoc(">>\n");
04977               }
04978               if (Patterns.count() != 0)
04979               {
04980                      PutDoc("/Pattern << \n");
04981                      QMap<QString,int>::Iterator it3p;
04982                      for (it3p = Patterns.begin(); it3p != Patterns.end(); ++it3p)
04983                             PutDoc("/"+it3p.key()+" "+QString::number(it3p.data())+" 0 R\n");
04984                      PutDoc(">>\n");
04985               }
04986               if (Transpar.count() != 0)
04987               {
04988                      PutDoc("/ExtGState << \n");
04989                      QMap<QString,int>::Iterator it3t;
04990                      for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
04991                             PutDoc("/"+it3t.key()+" "+QString::number(it3t.data())+" 0 R\n");
04992                      PutDoc(">>\n");
04993               }
04994               if ((ICCProfiles.count() != 0) || (spotMap.count() != 0))
04995               {
04996                      PutDoc("/ColorSpace << \n");
04997                      QMap<QString,ICCD>::Iterator it3c;
04998                      if (ICCProfiles.count() != 0)
04999                      {
05000                             for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
05001                                    PutDoc("/"+it3c.data().ResName+" "+QString::number(it3c.data().ResNum)+" 0 R\n");
05002                      }
05003                      QMap<QString,SpotC>::Iterator it3sc;
05004                      if (spotMap.count() != 0)
05005                      {
05006                      for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
05007                             PutDoc("/"+it3sc.data().ResName+" "+QString::number(it3sc.data().ResNum)+" 0 R\n");
05008                      }
05009                      PutDoc(">>\n");
05010               }
05011               PutDoc(">>\n");
05012               PutDoc("/Length "+QString::number(tmp2.length()));
05013               if ((Options.Compress) && (CompAvail))
05014                      PutDoc("\n/Filter /FlateDecode");
05015               PutDoc(" >>\nstream\n"+EncStream(tmp2, ObjCounter-1)+"\nendstream\nendobj\n");
05016               Patterns.insert("Pattern"+currItem->pattern()+QString::number(ResCount), ObjCounter-1);
05017               QString tmp = "/Pattern cs\n";
05018               tmp += "/Pattern"+currItem->pattern()+QString::number(ResCount)+" scn\n";
05019               tmp += SetClipPath(currItem);
05020               if (currItem->fillRule)
05021                      tmp += "h\nf*\n";
05022               else
05023                      tmp += "h\nf\n";
05024               ResCount++;
05025               return tmp;
05026        }
05027        double StartX = currItem->GrStartX;
05028        double StartY = -currItem->GrStartY;
05029        double EndX = currItem->GrEndX;
05030        double EndY =- currItem->GrEndY;
05031        QValueList<double> StopVec;
05032        QValueList<double> TransVec;
05033        QStringList Gcolors;
05034        QStringList colorNames;
05035        QValueList<int> colorShades;
05036        QPtrVector<VColorStop> cstops = currItem->fill_gradient.colorStops();
05037        StopVec.clear();
05038        TransVec.clear();
05039        Gcolors.clear();
05040        colorNames.clear();
05041        colorShades.clear();
05042        double lastStop = -1.0;
05043        double actualStop = 0.0;
05044        bool isFirst = true;
05045        if ((currItem->GrType == 5) || (currItem->GrType == 7))
05046        {
05047               for (uint cst = 0; cst < currItem->fill_gradient.Stops(); ++cst)
05048               {
05049                      actualStop = cstops.at(cst)->rampPoint;
05050                      if ((actualStop != lastStop) || (isFirst))
05051                      {
05052                             isFirst = false;
05053                             lastStop = actualStop;
05054                             TransVec.prepend(cstops.at(cst)->opacity);
05055                             StopVec.prepend(sqrt(pow(EndX - StartX, 2) + pow(EndY - StartY,2))*cstops.at(cst)->rampPoint);
05056                             Gcolors.prepend(SetFarbeGrad(cstops.at(cst)->name, cstops.at(cst)->shade));
05057                             colorNames.prepend(cstops.at(cst)->name);
05058                             colorShades.prepend(cstops.at(cst)->shade);
05059                      }
05060               }
05061        }
05062        else
05063        {
05064               for (uint cst = 0; cst < currItem->fill_gradient.Stops(); ++cst)
05065               {
05066                      actualStop = cstops.at(cst)->rampPoint;
05067                      if ((actualStop != lastStop) || (isFirst))
05068                      {
05069                             isFirst = false;
05070                             lastStop = actualStop;
05071                             double x = (1 - cstops.at(cst)->rampPoint) * StartX + cstops.at(cst)->rampPoint * EndX;
05072                             double y = (1 - cstops.at(cst)->rampPoint) * StartY + cstops.at(cst)->rampPoint * EndY;
05073                             TransVec.append(cstops.at(cst)->opacity);
05074                             StopVec.append(x);
05075                             StopVec.append(y);
05076                             Gcolors.append(SetFarbeGrad(cstops.at(cst)->name, cstops.at(cst)->shade));
05077                             colorNames.append(cstops.at(cst)->name);
05078                             colorShades.append(cstops.at(cst)->shade);
05079                      }
05080               }
05081        }
05082        QString tmp(PDF_DoLinGradient(currItem, StopVec, TransVec, Gcolors, colorNames, colorShades));
05083        return tmp;
05084 }
05085 
05086 QString PDFlib::PDF_DoLinGradient(PageItem *currItem, QValueList<double> Stops, QValueList<double> Trans, const QStringList& Colors, QStringList colorNames, QValueList<int> colorShades)
05087 {
05088        QString tmp("");
05089        bool first = true;
05090        bool oneSpot1 = false;
05091        bool oneSpot2 = false;
05092        bool twoSpot = false;
05093        bool spotMode = false;
05094        int cc, mc, yc, kc;
05095        double w = currItem->width();
05096        double h = -currItem->height();
05097        double w2 = currItem->GrStartX;
05098        double h2 = -currItem->GrStartY;
05099        uint colorsCountm1=Colors.count()-1;
05100        for (uint c = 0; c < colorsCountm1; ++c)
05101        {
05102               oneSpot1 = false;
05103               oneSpot2 = false;
05104               twoSpot = false;
05105               spotMode = false;
05106               QString spot1 = colorNames[c].simplifyWhiteSpace().replace("#", "#23").replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "#20" );
05107               QString spot2 = colorNames[c+1].simplifyWhiteSpace().replace("#", "#23").replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "#20" );
05108               QString TRes("");
05109               if ((Options.Version >= 14) && (((*Trans.at(c+1)) != 1) || ((*Trans.at(c)) != 1)))
05110               {
05111                      StartObj(ObjCounter);
05112                      QString ShName = ResNam+QString::number(ResCount);
05113                      Shadings[ShName] = ObjCounter;
05114                      ResCount++;
05115                      ObjCounter++;
05116                      PutDoc("<<\n");
05117                      if ((currItem->GrType == 5) || (currItem->GrType == 7))
05118                             PutDoc("/ShadingType 3\n");
05119                      else
05120                             PutDoc("/ShadingType 2\n");
05121                      PutDoc("/ColorSpace /DeviceGray\n");
05122                      PutDoc("/BBox [0 "+FToStr(h)+" "+FToStr(w)+" 0]\n");
05123                      if ((currItem->GrType == 5) || (currItem->GrType == 7))
05124                      {
05125                             PutDoc("/Coords ["+FToStr(w2)+" "+FToStr(h2)+" "+FToStr((*Stops.at(c+1)))+" "+FToStr(w2)+" "+FToStr(h2)+" "+FToStr((*Stops.at(c)))+"]\n");
05126                             PutDoc("/Extend [true true]\n");
05127                             PutDoc("/Function\n<<\n/FunctionType 2\n/Domain [0 1]\n");
05128                             PutDoc("/C0 ["+FToStr((*Trans.at(c+1)))+"]\n");
05129                             PutDoc("/C1 ["+FToStr((*Trans.at(c)))+"]\n");
05130                      }
05131                      else
05132                      {
05133                             PutDoc("/Coords ["+FToStr((*Stops.at(c*2)))+"  "+FToStr((*Stops.at(c*2+1)))+" "+FToStr((*Stops.at(c*2+2)))+" "+FToStr((*Stops.at(c*2+3)))+"]\n");
05134                             PutDoc("/Extend [true true]\n");
05135                             PutDoc("/Function\n<<\n/FunctionType 2\n/Domain [0 1]\n");
05136                             PutDoc("/C0 ["+FToStr((*Trans.at(c)))+"]\n");
05137                             PutDoc("/C1 ["+FToStr((*Trans.at(c+1)))+"]\n");
05138                      }
05139                      PutDoc("/N 1\n>>\n>>\nendobj\n");
05140                      StartObj(ObjCounter);
05141                      ObjCounter++;
05142                      PutDoc("<<\n/Type /XObject\n/Subtype /Form\n");
05143                      PutDoc("/FormType 1\n");
05144                      PutDoc("/Group << /S /Transparency /CS /DeviceGray >>\n");
05145                      PutDoc("/BBox [ 0 0 "+FToStr(currItem->width())+" "+FToStr(-currItem->height())+" ]\n");
05146                      PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
05147                      if (Shadings.count() != 0)
05148                      {
05149                             PutDoc("/Shading << \n");
05150                             QMap<QString,int>::Iterator it3;
05151                             for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
05152                                    PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
05153                             PutDoc(">>\n");
05154                      }
05155                      PutDoc(">>\n");
05156                      QString stre = "";
05157                      stre += "q\n"+SetClipPath(currItem)+"h\nW* n\n"+"/"+ShName+" sh\nQ\n";
05158                      if ((Options.Compress) && (CompAvail))
05159                             stre = CompressStr(&stre);
05160                      PutDoc("/Length "+QString::number(stre.length())+"\n");
05161                      if ((Options.Compress) && (CompAvail))
05162                             PutDoc("/Filter /FlateDecode\n");
05163                      PutDoc(">>\nstream\n"+EncStream(stre, ObjCounter-1)+"\nendstream\nendobj\n");
05164                      Seite.XObjects[ResNam+QString::number(ResCount)] = ObjCounter-1;
05165                      ResCount++;
05166                      StartObj(ObjCounter);
05167                      QString GXName = ResNam+QString::number(ResCount);
05168                      Transpar[GXName] = ObjCounter;
05169                      ResCount++;
05170                      ObjCounter++;
05171                      PutDoc("<< /Type /ExtGState\n");
05172                      PutDoc("/SMask << /S /Luminosity /G "+QString::number(ObjCounter-2)+" 0 R >>\n");
05173                      PutDoc("/BM /Normal\n>>\nendobj\n");
05174                      TRes = GXName;
05175               }
05176               StartObj(ObjCounter);
05177               QString ShName = ResNam+QString::number(ResCount);
05178               Shadings[ShName] = ObjCounter;
05179               ResCount++;
05180               ObjCounter++;
05181               PutDoc("<<\n");
05182               if ((currItem->GrType == 5) || (currItem->GrType == 7))
05183                      PutDoc("/ShadingType 3\n");
05184               else
05185                      PutDoc("/ShadingType 2\n");
05186               if (Options.UseRGB)
05187                      PutDoc("/ColorSpace /DeviceRGB\n");
05188               else
05189               {
05190                      if (Options.isGrayscale)
05191                             PutDoc("/ColorSpace /DeviceGray\n");
05192                      else
05193                      {
05194                             if ((doc.HasCMS) && (Options.UseProfiles))
05195                                    PutDoc("/ColorSpace "+ICCProfiles[Options.SolidProf].ICCArray+"\n");
05196                             else
05197                             {
05198                                    if (spotMap.contains(colorNames[c]))
05199                                           oneSpot1 = true;
05200                                    else if  (spotMap.contains(colorNames[c+1]))
05201                                           oneSpot2 = true;
05202                                    if ((spotMap.contains(colorNames[c])) && (spotMap.contains(colorNames[c+1])))
05203                                    {
05204                                           oneSpot1 = false;
05205                                           oneSpot2 = false;
05206                                           twoSpot = true;
05207                                    }
05208                                    if ((!oneSpot1) && (!oneSpot2) && (!twoSpot) || (!Options.UseSpotColors)) 
05209                                           PutDoc("/ColorSpace /DeviceCMYK\n");
05210                                    else
05211                                    {
05212                                           spotMode = true;
05213                                           PutDoc("/ColorSpace [ /DeviceN [");
05214                                           if (oneSpot1)
05215                                                  PutDoc(" /Cyan /Magenta /Yellow /Black /"+spot1+" ]\n");
05216                                           else if (oneSpot2)
05217                                                  PutDoc(" /Cyan /Magenta /Yellow /Black /"+spot2+" ]\n");
05218                                           else if (twoSpot)
05219                                                  PutDoc(" /"+spot1+" /"+spot2+" ]\n");
05220                                           PutDoc("/DeviceCMYK\n");
05221                                           PutDoc(QString::number(ObjCounter)+" 0 R\n");
05222                                           PutDoc("]\n");
05223                                    }
05224                             }
05225                      }
05226               }
05227               PutDoc("/BBox [0 "+FToStr(h)+" "+FToStr(w)+" 0]\n");
05228               if ((currItem->GrType == 5) || (currItem->GrType == 7))
05229               {
05230                      PutDoc("/Coords ["+FToStr(w2)+" "+FToStr(h2)+" "+FToStr((*Stops.at(c+1)))+" "+FToStr(w2)+" "+FToStr(h2)+" "+FToStr((*Stops.at(c)))+"]\n");
05231                      if (Colors.count() == 2)
05232                             PutDoc("/Extend [true true]\n");
05233                      else
05234                      {
05235                             if (first)
05236                                    PutDoc("/Extend [false true]\n");
05237                             else
05238                             {
05239                                    if (c == Colors.count()-2)
05240                                           PutDoc("/Extend [true false]\n");
05241                                    else
05242                                           PutDoc("/Extend [false false]\n");
05243                             }
05244                      }
05245                      first = false;
05246                      PutDoc("/Function\n<<\n/FunctionType 2\n/Domain [0 1]\n");
05247                      if (Options.UseSpotColors)
05248                      {
05249                             if (oneSpot1)
05250                             {
05251                                    PutDoc("/C1 [0 0 0 0 "+FToStr(colorShades[c] / 100.0)+"]\n");
05252                                    PutDoc("/C0 ["+Colors[c+1]+" 0 ]\n");
05253                             }
05254                             else if (oneSpot2)
05255                             {
05256                                    PutDoc("/C1 ["+Colors[c]+" 0 ]\n");
05257                                    PutDoc("/C0 [0 0 0 0 "+FToStr(colorShades[c+1] / 100.0)+"]\n");
05258                             }
05259                             else if (twoSpot)
05260                             {
05261                                    PutDoc("/C1 ["+FToStr(colorShades[c] / 100.0)+" 0]\n");
05262                                    PutDoc("/C0 [0 "+FToStr(colorShades[c+1] / 100.0)+"]\n");
05263                             }
05264                             else
05265                             {
05266                                    PutDoc("/C1 ["+Colors[c]+"]\n");
05267                                    PutDoc("/C0 ["+Colors[c+1]+"]\n");
05268                             }
05269                      }
05270                      else
05271                      {
05272                             PutDoc("/C0 ["+Colors[c+1]+"]\n");
05273                             PutDoc("/C1 ["+Colors[c]+"]\n");
05274                      }
05275               }
05276               else
05277               {
05278                      PutDoc("/Coords ["+FToStr((*Stops.at(c*2)))+"  "+FToStr((*Stops.at(c*2+1)))+" "+FToStr((*Stops.at(c*2+2)))+" "+FToStr((*Stops.at(c*2+3)))+"]\n");
05279                      if (Colors.count() == 2)
05280                             PutDoc("/Extend [true true]\n");
05281                      else
05282                      {
05283                             if (first)
05284                                    PutDoc("/Extend [true false]\n");
05285                             else
05286                             {
05287                                    if (c == Colors.count()-2)
05288                                           PutDoc("/Extend [false true]\n");
05289                                    else
05290                                           PutDoc("/Extend [false false]\n");
05291                             }
05292                      }
05293                      first = false;
05294                      PutDoc("/Function\n<<\n/FunctionType 2\n/Domain [0 1]\n");
05295                      if (Options.UseSpotColors)
05296                      {
05297                             if (oneSpot1)
05298                             {
05299                                    PutDoc("/C0 [0 0 0 0 "+FToStr(colorShades[c] / 100.0)+"]\n");
05300                                    PutDoc("/C1 ["+Colors[c+1]+" 0 ]\n");
05301                             }
05302                             else if (oneSpot2)
05303                             {
05304                                    PutDoc("/C0 ["+Colors[c]+" 0 ]\n");
05305                                    PutDoc("/C1 [0 0 0 0 "+FToStr(colorShades[c+1] / 100.0)+"]\n");
05306                             }
05307                             else if (twoSpot)
05308                             {
05309                                    PutDoc("/C0 ["+FToStr(colorShades[c] / 100.0)+" 0]\n");
05310                                    PutDoc("/C1 [0 "+FToStr(colorShades[c+1] / 100.0)+"]\n");
05311                             }
05312                             else
05313                             {
05314                                    PutDoc("/C0 ["+Colors[c]+"]\n");
05315                                    PutDoc("/C1 ["+Colors[c+1]+"]\n");
05316                             }
05317                      }
05318                      else
05319                      {
05320                             PutDoc("/C0 ["+Colors[c]+"]\n");
05321                             PutDoc("/C1 ["+Colors[c+1]+"]\n");
05322                      }
05323               }
05324               PutDoc("/N 1\n>>\n>>\nendobj\n");
05325               if (spotMode)
05326               {
05327                      CMYKColor cmykValues;
05328                      QString colorDesc;
05329                      StartObj(ObjCounter);
05330                      ObjCounter++;
05331                      PutDoc("<<\n/FunctionType 4\n");
05332                      if (twoSpot)
05333                      {
05334                             PutDoc("/Domain [0.0 1.0 0.0 1.0]\n");
05335                             ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
05336                             cmykValues.getValues(cc, mc, yc, kc);
05337                             colorDesc = "{\nexch\n";
05338                             colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul exch\n";
05339                             colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul exch\n";
05340                             colorDesc += "dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul exch\n";
05341                             colorDesc += "dup "+FToStr(static_cast<double>(kc) / 255.0)+" mul exch pop 5 -1 roll\n";
05342                             ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
05343                             cmykValues.getValues(cc, mc, yc, kc);
05344                             colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n";
05345                             colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n";
05346                             colorDesc += "dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n";
05347                             colorDesc += "dup "+FToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n}\n";
05348                      }
05349                      else
05350                      {
05351                             PutDoc("/Domain [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n");
05352                             if (oneSpot1)
05353                             {
05354                                    ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
05355                                    cmykValues.getValues(cc, mc, yc, kc);
05356                             }
05357                             else
05358                             {
05359                                    ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
05360                                    cmykValues.getValues(cc, mc, yc, kc);
05361                             }
05362                             colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n";
05363                             colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n";
05364                             colorDesc += "dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n";
05365                             colorDesc += "dup "+FToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n}\n";
05366                      }
05367                      PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n");
05368                      PutDoc("/Length "+QString::number(colorDesc.length()+1)+"\n");
05369                      PutDoc(">>\nstream\n"+EncStream(colorDesc, ObjCounter-1)+"\nendstream\nendobj\n");
05370               }
05371               tmp += "q\n";
05372               if ((Options.Version >= 14) && (((*Trans.at(c+1)) != 1) || ((*Trans.at(c)) != 1)))
05373                      tmp += "/"+TRes+" gs\n";
05374               tmp += SetClipPath(currItem);
05375               tmp += "h\nW* n\n";
05376               tmp += "/"+ShName+" sh\nQ\n";
05377        }
05378        return tmp;
05379 }
05380 
05381 void PDFlib::PDF_Annotation(PageItem *ite, uint)
05382 {
05383        ScImage img;
05384        ScImage img2;
05385        ScImage img3;
05386        QMap<int, QString> ind2PDFabr;
05387        static const QString bifonts[] = {"/Courier", "/Courier-Bold", "/Courier-Oblique", "/Courier-BoldOblique",
05388                                                                                     "/Helvetica", "/Helvetica-Bold", "/Helvetica-Oblique", "/Helvetica-BoldOblique",
05389                                                                                     "/Times-Roman", "/Times-Bold", "/Times-Italic", "/Times-BoldItalic",
05390                                                                                     "/ZapfDingbats", "/Symbol"};
05391        static const size_t ar = sizeof(bifonts) / sizeof(*bifonts);
05392        for (uint a = 0; a < ar; ++a)
05393               ind2PDFabr[a] = bifonts[a];
05394        double x = ite->xPos() - ActPageP->xOffset();
05395        double y = ActPageP->height() - (ite->yPos()  - ActPageP->yOffset());
05396        double x2 = x+ite->width();
05397        double y2 = y-ite->height();
05398        QString bm("");
05399        QString cc;
05400        for (uint d = 0; d < static_cast<uint>(ite->itemText.length()); ++d)
05401        {
05402               cc = ite->itemText.text(d, 1);
05403               if ((cc == "(") || (cc == ")") || (cc == "\\"))
05404                      bm += "\\";
05405               if (cc == QChar(13))
05406                      cc = "\\r";
05407               bm += cc;
05408        }
05409        QString anTitle = ite->itemName().replace(".", "_" );
05410        QStringList bmst = QStringList::split("\\r", bm);
05411        const QString m[] = {"4", "5", "F", "l", "H", "n"};
05412        QString ct(m[ite->annotation().ChkStil()]);
05413        StartObj(ObjCounter);
05414        Seite.AObjects.append(ObjCounter);
05415        ObjCounter++;
05416        PutDoc("<<\n/Type /Annot\n");
05417        switch (ite->annotation().Type())
05418        {
05419               case 0:
05420               case 10:
05421                      PutDoc("/Subtype /Text\n");
05422                      PutDoc("/Contents "+EncString("("+bm+")",ObjCounter-1)+"\n");
05423                      break;
05424               case 1:
05425               case 11:
05426                      PutDoc("/Subtype /Link\n");
05427                      if (ite->annotation().ActionType() == 2)
05428                      {
05429                             PutDoc("/Dest /"+NDnam+QString::number(NDnum)+"\n");
05430                             Dest de;
05431                             de.Name = NDnam+QString::number(NDnum);
05432                             de.Seite = ite->annotation().Ziel();
05433                             de.Act = ite->annotation().Action();
05434                             NamedDest.append(de);
05435                             NDnum++;
05436                      }
05437                      if (ite->annotation().ActionType() == 7)
05438                      {
05439                             PutDoc("/A << /Type /Action /S /GoToR\n/F "+ EncString("("+Path2Relative(ite->annotation().Extern())+")",ObjCounter-1)+"\n");
05440                             PutDoc("/D ["+QString::number(ite->annotation().Ziel())+" /XYZ "+ite->annotation().Action()+"]\n>>\n");
05441                      }
05442                      if (ite->annotation().ActionType() == 8)
05443                             PutDoc("/A << /Type /Action /S /URI\n/URI "+ EncString("("+ite->annotation().Extern()+")",ObjCounter-1)+"\n>>\n");
05444                      break;
05445               case 2:
05446               case 3:
05447               case 4:
05448               case 5:
05449               case 6:
05450                      Seite.FormObjects.append(ObjCounter-1);
05451                      PutDoc("/Subtype /Widget\n");
05452                      PutDoc("/T "+EncString("("+anTitle+")",ObjCounter-1)+"\n");
05453                      if (!ite->annotation().ToolTip().isEmpty())
05454                             PutDoc("/TU "+EncString("("+PDFEncode(ite->annotation().ToolTip())+")",ObjCounter-1)+"\n");
05455                      PutDoc("/F ");
05456                      QString mm[] = {"4", "2", "0", "32"};
05457                      PutDoc(mm[ite->annotation().Vis()]);
05458                      PutDoc("\n");
05459                      PutDoc("/BS << /Type /Border /W ");
05460                      PutDoc(ite->annotation().borderColor() != CommonStrings::None ? QString::number(ite->annotation().Bwid()) : QString("0"));
05461                      PutDoc(" /S /");
05462                      const QString x[] = {"S", "D", "U", "B", "I"};
05463                      PutDoc(x[ite->annotation().Bsty()]);
05464                      PutDoc(" >>\n");
05465                      QString cnx = "(";
05466                      if (ite->annotation().Type() == 4)
05467                             cnx += "/"+StdFonts["/ZapfDingbats"];
05468                      else
05469                      {
05470                             if (Options.Version < 14)
05471                                    cnx += "/"+StdFonts[ind2PDFabr[ite->annotation().Font()]];
05472                             else
05473                                    cnx += UsedFontsF[ite->itemText.defaultStyle().charStyle().font().replacementName()];
05474 //                                 cnx += UsedFontsP[ite->itemText.defaultStyle().charStyle().font().replacementName()]+"Form";
05475                      }
05476                      cnx += " "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf";
05477                      if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
05478                             cnx += " "+ putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
05479                      if (ite->fillColor() != CommonStrings::None)
05480                             cnx += " "+ putColor(ite->fillColor(), ite->fillShade(), false);
05481                      cnx += ")";
05482                      PutDoc("/DA "+EncString(cnx,ObjCounter-1)+"\n");
05483                      int flg = ite->annotation().Flag();
05484                      if (Options.Version == 13)
05485                             flg = flg & 522247;
05486                      PutDoc("/Ff "+QString::number(flg)+"\n");
05487                      QString xs[] = {"N", "I", "O", "P"};
05488                      switch (ite->annotation().Type())
05489                      {
05490                             case 2:
05491                                    PutDoc("/FT /Btn\n");
05492                                    PutDoc("/H /");
05493                                    PutDoc(xs[ite->annotation().Feed()]);
05494                                    PutDoc("\n");
05495                                    PutDoc("/Q 0\n");
05496                                    break;
05497                             case 3:
05498                                    PutDoc("/FT /Tx\n");
05499                                    PutDoc("/V "+EncString("("+bm+")",ObjCounter-1)+"\n");
05500                                    PutDoc("/DV "+EncString("("+bm+")",ObjCounter-1)+"\n");
05501                                    PutDoc("/Q "+QString::number(QMIN(ite->itemText.defaultStyle().alignment(),2))+"\n");
05502                                    PutDoc("/AP << /N "+QString::number(ObjCounter)+" 0 R >>\n");
05503                                    if (ite->annotation().MaxChar() != -1)
05504                                           PutDoc("/MaxLen "+QString::number(ite->annotation().MaxChar())+"\n");
05505                                    break;
05506                             case 4:
05507                                    PutDoc("/FT /Btn\n");
05508                                    PutDoc(ite->annotation().IsChk() ? "/V /Yes\n/DV /Yes\n/AS /Yes\n" :
05509                                                         "/V /Off\n/DV /Off\n/AS /Off\n");
05510                                    PutDoc("/AP << /N << /Yes "+QString::number(ObjCounter)+" 0 R >> >>\n");
05511                                    break;
05512                             case 5:
05513                             case 6:
05514                                    PutDoc("/FT /Ch\n/V (");
05515                                    if (bmst.count() > 0)
05516                                           PutDoc(bmst[0]);
05517                                    PutDoc(")\n/DV ");
05518                                    cnx = "(";
05519                                    if (bmst.count() > 0)
05520                                           cnx += bmst[0];
05521                                    cnx += ")";
05522                                    PutDoc(EncString(cnx,ObjCounter-1)+"\n");
05523                                    PutDoc("/Opt [ ");
05524                                    for (uint bmc = 0; bmc < bmst.count(); ++bmc)
05525                                           PutDoc(EncString("("+bmst[bmc]+")",ObjCounter-1)+"\n");
05526                                    PutDoc("]\n");
05527                                    PutDoc("/AP << /N "+QString::number(ObjCounter)+" 0 R >>\n");
05528                                    break;
05529                      }
05530                      PutDoc("/MK << ");
05531                      if ((ite->annotation().Type() == 5) || (ite->annotation().Type() == 6))
05532                      {
05533                             PutDoc("/BG [ 1 1 1 ] ");
05534                             if (ite->annotation().borderColor() != CommonStrings::None)
05535                                    PutDoc("/BC [ "+SetFarbe(ite->annotation().borderColor(), 100)+" ] ");
05536                      }
05537                      else
05538                      {
05539                             if (ite->fillColor() != CommonStrings::None)
05540                                    PutDoc("/BG [ "+SetFarbe(ite->fillColor(), ite->fillShade())+" ] ");
05541                             if (ite->annotation().borderColor() != CommonStrings::None)
05542                                    PutDoc("/BC [ "+SetFarbe(ite->annotation().borderColor(), 100)+" ] ");
05543                      }
05544                      int IconOb = 0;
05545                      switch (ite->annotation().Type())
05546                      {
05547                             case 2:
05548                                    PutDoc("/CA "+EncString("("+bm+")",ObjCounter-1)+" ");
05549                                    if (!ite->annotation().RollOver().isEmpty())
05550                                           PutDoc("/RC "+ EncString("("+PDFEncode(ite->annotation().RollOver())+")",ObjCounter-1)+" ");
05551                                    if (!ite->annotation().Down().isEmpty())
05552                                           PutDoc("/AC "+ EncString("("+PDFEncode(ite->annotation().Down())+")",ObjCounter-1)+" ");
05553                                    if (ite->annotation().UseIcons())
05554                                    {
05555                                           if (!ite->Pfile.isEmpty())
05556                                           {
05557                                                  IconOb += ite->pixm.hasAlpha() ? 3 : 2;
05558                                                  PutDoc("/I "+QString::number(ObjCounter+IconOb-1)+" 0 R ");
05559                                           }
05560                                           if (!ite->Pfile2.isEmpty())
05561                                           {
05562                                                  CMSettings cms(ite->doc(), "", 0);
05563                                                  img.LoadPicture(ite->Pfile2, cms, false, false, ScImage::RGBData, 72);
05564                                                  QByteArray im;
05565                                                  im = img3.getAlpha(ite->Pfile2, true, false);
05566                                                  IconOb += !im.isEmpty() ? 3 : 2;
05567                                                  im.resize(0);
05568                                                  PutDoc("/IX "+QString::number(ObjCounter+IconOb-1)+" 0 R ");
05569                                           }
05570                                           if (!ite->Pfile3.isEmpty())
05571                                           {
05572                                                  CMSettings cms(ite->doc(), "", 0);
05573                                                  img2.LoadPicture(ite->Pfile3, cms, false, false, ScImage::RGBData, 72);
05574                                                  QByteArray im;
05575                                                  im = img3.getAlpha(ite->Pfile3, true, false);
05576                                                  IconOb += !im.isEmpty() ? 3 : 2;
05577                                                  im.resize(0);
05578                                                  PutDoc("/RI "+QString::number(ObjCounter+IconOb-1)+" 0 R ");
05579                                           }
05580                                           PutDoc("/TP "+QString::number(ite->annotation().IPlace())+" ");
05581                                           PutDoc("/IF << /SW /");
05582                                           QString x[] = {"A", "S", "B", "N"};
05583                                           PutDoc(x[ite->annotation().ScaleW()]);
05584                                           PutDoc(" /S /");
05585                                           PutDoc(ite->imageXScale() != ite->imageYScale() ? "A" : "P");
05586                                           PutDoc(" /A [ ");
05587                                           if ((ite->width()/ite->imageXScale() - ite->pixm.width()) != 0)
05588                                           {
05589                                                  if (ite->annotation().ScaleW() == 3)
05590                                                         PutDoc(FToStr(QMAX(ite->imageXOffset() / (ite->width()/ite->imageXScale() - ite->pixm.width()), 0.01)));
05591                                                  else
05592                                                         PutDoc("0.5 ");
05593                                           }
05594                                           else
05595                                                  PutDoc("0 ");
05596                                           if ((ite->height()/ite->imageYScale() - ite->pixm.height()) != 0)
05597                                           {
05598                                                  if (ite->annotation().ScaleW() == 3)
05599                                                         PutDoc(FToStr(QMAX(ite->imageYOffset() / (ite->height()/ite->imageYScale() - ite->pixm.height()), 0.01)));
05600                                                  else
05601                                                         PutDoc("0.5");
05602                                           }
05603                                           else
05604                                                  PutDoc("0");
05605                                           PutDoc(" ] >> ");
05606                                    }
05607                                    break;
05608                             case 6:
05609                             case 5:
05610                             case 3:
05611                                    break;
05612                             case 4:
05613                                    PutDoc("/CA "+EncString("("+ct+")",ObjCounter-1)+" ");
05614                                    break;
05615                      }
05616                      if (ite->rotation() != 0)
05617                             PutDoc("/R "+QString::number((abs(static_cast<int>(ite->rotation())) / 90)*90)+" ");
05618                      PutDoc(">>\n");
05619                      if ((ite->annotation().ActionType() != 0) || (ite->annotation().AAact()))
05620                      {
05621                             if (ite->annotation().ActionType() == 7)
05622                             {
05623                                    PutDoc("/A << /Type /Action /S /GoToR\n/F "+ EncString("("+Path2Relative(ite->annotation().Extern())+")",ObjCounter-1)+ "\n");
05624                                    PutDoc("/D ["+QString::number(ite->annotation().Ziel())+" /XYZ "+ite->annotation().Action()+"]\n>>\n");
05625                             }
05626                             if (ite->annotation().ActionType() == 5)
05627                                    PutDoc("/A << /Type /Action /S /ImportData\n/F "+ EncString("("+ite->annotation().Action()+")",ObjCounter-1)+" >>\n");
05628                             if (ite->annotation().ActionType() == 4)
05629                                    PutDoc("/A << /Type /Action /S /ResetForm >>\n");
05630                             if (ite->annotation().ActionType() == 3)
05631                             {
05632                                    PutDoc("/A << /Type /Action /S /SubmitForm\n/F << /FS /URL /F "+ EncString("("+ite->annotation().Action()+")",ObjCounter-1)+" >>\n");
05633                                    if (ite->annotation().HTML())
05634                                           PutDoc("/Flags 4");
05635                                    PutDoc(">>\n");
05636                             }
05637                             if (ite->annotation().ActionType() == 1)
05638                             {
05639                                    if (!ite->annotation().Action().isEmpty())
05640                                    {
05641                                           PutDoc("/A << /Type /Action /S /JavaScript /JS ");
05642                                           PutDoc(ite->annotation().Type() > 2 ? QString::number(ObjCounter+1+IconOb) :
05643                                            QString::number(ObjCounter+IconOb));
05644                                           PutDoc(" 0 R >>\n");
05645                                    }
05646                             }
05647                             if (ite->annotation().AAact())
05648                             {
05649                                    if (!ite->annotation().Action().isEmpty())
05650                                    {
05651                                           PutDoc("/A << /Type /Action /S /JavaScript /JS ");
05652                                           PutDoc(ite->annotation().Type() > 2 ? QString::number(ObjCounter+1+IconOb) :
05653                                            QString::number(ObjCounter+IconOb));
05654                                           PutDoc(" 0 R >>\n");
05655                                    }
05656                                    PutDoc("/AA ");
05657                                    if (ite->annotation().Type() > 2)
05658                                           {
05659                                           if (!ite->annotation().Action().isEmpty())
05660                                                  PutDoc(QString::number(ObjCounter+2+IconOb));
05661                                           else
05662                                                  PutDoc(QString::number(ObjCounter+1+IconOb));
05663                                           }
05664                                    else
05665                                           {
05666                                           if (!ite->annotation().Action().isEmpty())
05667                                                  PutDoc(QString::number(ObjCounter+1+IconOb));
05668                                           else
05669                                                  PutDoc(QString::number(ObjCounter));
05670                                           }
05671                                    PutDoc(" 0 R\n");
05672                                    if (!ite->annotation().C_act().isEmpty())
05673                                           CalcFields.append(ObjCounter-1+IconOb);
05674                             }
05675                             if (ite->annotation().ActionType() == 2)
05676                             {
05677                                    PutDoc("/A << /Type /Action /S /GoTo /D /"+NDnam+QString::number(NDnum)+" >>\n");
05678                                    Dest de;
05679                                    de.Name = NDnam+QString::number(NDnum);
05680                                    de.Seite = ite->annotation().Ziel();
05681                                    de.Act = ite->annotation().Action();
05682                                    NamedDest.append(de);
05683                                    NDnum++;
05684                             }
05685                      }
05686                      break;
05687               }
05688        if ((ite->annotation().Type() < 2) || (ite->annotation().Type() > 9))
05689               PutDoc("/Border [ 0 0 0 ]\n");
05690        switch (((abs(static_cast<int>(ite->rotation())) / 90)*90))
05691        {
05692               case 0:
05693                      break;
05694               case 90:
05695                      x = ite->xPos() - ActPageP->xOffset();
05696                      y2 = ActPageP->height() - (ite->yPos()  - ActPageP->yOffset());
05697                      x2 = x + ite->height();
05698                      y = y2 + ite->width();
05699                      break;
05700               case 180:
05701                      x = ite->xPos() - ActPageP->xOffset() - ite->width();
05702                      y2 = ActPageP->height() - (ite->yPos()  - ActPageP->yOffset());
05703                      x2 = ite->xPos() - ActPageP->xOffset();
05704                      y = y2 + ite->height();
05705                      break;
05706               case 270:
05707                      x = ite->xPos() - ActPageP->xOffset() - ite->height();
05708                      y2 = ActPageP->height() - (ite->yPos()  - ActPageP->yOffset()) - ite->width();
05709                      x2 = ite->xPos() - ActPageP->xOffset();
05710                      y = ActPageP->height() - (ite->yPos()  - ActPageP->yOffset());
05711                      break;
05712        }
05713        PutDoc("/Rect [ "+FToStr(x+bleedDisplacementX)+" "+FToStr(y2+bleedDisplacementY)+" "+FToStr(x2+bleedDisplacementX)+" "+FToStr(y+bleedDisplacementY)+" ]\n");
05714        PutDoc(">>\nendobj\n");
05715        if ((ite->annotation().Type() == 2) && (ite->annotation().UseIcons()))
05716        {
05717               if (!ite->Pfile.isEmpty())
05718               {
05719                      PDF_Image(ite, ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), true);
05720                      cc = QString::number(ite->pixm.width())+" 0 0 "+QString::number(ite->pixm.height())+" 0 0 cm\n";
05721                      cc += "/"+ResNam+"I"+QString::number(ResCount-1)+" Do";
05722                      PDF_xForm(ite->pixm.width(), ite->pixm.height(), cc);
05723               }
05724               if (!ite->Pfile2.isEmpty())
05725               {
05726                      PDF_Image(ite, ite->Pfile2, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), true);
05727                      cc = QString::number(img.width())+" 0 0 "+QString::number(img.height())+" 0 0 cm\n";
05728                      cc += "/"+ResNam+"I"+QString::number(ResCount-1)+" Do";
05729                      PDF_xForm(img.width(), img.height(), cc);
05730               }
05731               if (!ite->Pfile3.isEmpty())
05732               {
05733                      PDF_Image(ite, ite->Pfile3, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), true);
05734                      cc = QString::number(img2.width())+" 0 0 "+QString::number(img2.height())+" 0 0 cm\n";
05735                      cc += "/"+ResNam+"I"+QString::number(ResCount-1)+" Do";
05736                      PDF_xForm(img2.width(), img2.height(), cc);
05737               }
05738        }
05739        if (ite->annotation().Type() == 3)
05740        {
05741               cc = "";
05742               if (ite->fillColor() != CommonStrings::None)
05743                      cc += putColor(ite->fillColor(), ite->fillShade(), false);
05744               cc += FToStr(x)+" "+FToStr(y2)+" "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
05745               cc += "/Tx BMC\nBT\n";
05746               if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
05747                      cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
05748               if (Options.Version < 14)
05749                      cc += "/"+StdFonts[ind2PDFabr[ite->annotation().Font()]];
05750               else
05751                      cc += UsedFontsF[ite->itemText.defaultStyle().charStyle().font().replacementName()];
05752 //                   cc += UsedFontsP[ite->itemText.defaultStyle().charStyle().font().replacementName()]+"Form";
05753               cc += " "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
05754               if (bmst.count() > 1)
05755               {
05756                      cc += "1 0 0 1 0 0 Tm\n0 0 Td\n";
05757                      for (uint mz = 0; mz < bmst.count(); ++mz)
05758                      {
05759                             cc += EncString("("+bmst[mz]+")",ObjCounter-1);
05760                             cc += " Tj\nT*\n";
05761                      }
05762                      cc += "ET\nEMC";
05763               }
05764               else
05765                      cc += "1 0 0 1 0 0 Tm\n0 0 Td\n"+EncString("("+bm+")",ObjCounter-1)+" Tj\nET\nEMC";
05766               PDF_xForm(ite->width(), ite->height(), cc);
05767        }
05768        if (ite->annotation().Type() == 4)
05769        {
05770               cc = "q\nBT\n";
05771               if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
05772                      cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
05773               cc += "/"+StdFonts["/ZapfDingbats"]+" "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
05774               cc += "0 0 Td\n("+ct+") Tj\nET\nQ";
05775               PDF_xForm(ite->width(), ite->height(), cc);
05776        }
05777        if ((ite->annotation().Type() == 5) || (ite->annotation().Type() == 6))
05778        {
05779               cc = "";
05780               cc += "1 g\n";
05781               cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
05782               cc += QString::number(ite->annotation().Bwid())+" w\n";
05783               if (ite->annotation().borderColor() != CommonStrings::None)
05784                      cc += putColor(ite->annotation().borderColor(), 100l, false);
05785               else
05786                      cc += "0 G\n";
05787               cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nS\n";
05788               cc += "/Tx BMC\nq\nBT\n";
05789               cc += "0 g\n";
05790               if (Options.Version < 14)
05791                      cc += "/"+StdFonts[ind2PDFabr[ite->annotation().Font()]];
05792               else
05793                      cc += UsedFontsF[ite->itemText.defaultStyle().charStyle().font().replacementName()];
05794 //                   cc += UsedFontsP[ite->itemText.defaultStyle().charStyle().font().replacementName()]+"Form";
05795               cc += " "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
05796               cc += "1 0 0 1 0 0 Tm\n0 0 Td\n";
05797               if (bmst.count() > 0)
05798                      cc += EncString("("+bmst[0]+")",ObjCounter-1);
05799               cc += " Tj\nET\nQ\nEMC";
05800               PDF_xForm(ite->width(), ite->height(), cc);
05801        }
05802        if ((ite->annotation().Type() > 1) && ((ite->annotation().ActionType() == 1) || (ite->annotation().AAact())) && (!ite->annotation().Action().isEmpty()))
05803               WritePDFStream(ite->annotation().Action());
05804        if ((ite->annotation().Type() > 1) && (ite->annotation().AAact()))
05805        {
05806               StartObj(ObjCounter);
05807               ObjCounter++;
05808               PutDoc("<<\n");
05809               int AAcoun = 0;
05810               if (!ite->annotation().E_act().isEmpty())
05811               {
05812                      PutDoc("/E << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+" 0 R >>\n");
05813                      AAcoun++;
05814               }
05815               if (!ite->annotation().X_act().isEmpty())
05816               {
05817                      PutDoc("/X << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+" 0 R >>\n");
05818                      AAcoun++;
05819               }
05820               if (!ite->annotation().D_act().isEmpty())
05821               {
05822                      PutDoc("/D << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+" 0 R >>\n");
05823                      AAcoun++;
05824               }
05825               if (!ite->annotation().Fo_act().isEmpty())
05826               {
05827                      PutDoc("/Fo << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+" 0 R >>\n");
05828                      AAcoun++;
05829               }
05830               if (!ite->annotation().Bl_act().isEmpty())
05831               {
05832                      PutDoc("/Bl << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+" 0 R >>\n");
05833                      AAcoun++;
05834               }
05835               if ((ite->annotation().Type() == 3) || (ite->annotation().Type() == 5) || (ite->annotation().Type() == 6))
05836               {
05837                      if (!ite->annotation().K_act().isEmpty())
05838                      {
05839                             PutDoc("/K << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+
05840                                    " 0 R >>\n");
05841                             AAcoun++;
05842                      }
05843                      if (!ite->annotation().F_act().isEmpty())
05844                      {
05845                             PutDoc("/F << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+
05846                                    " 0 R >>\n");
05847                             AAcoun++;
05848                      }
05849                      if (!ite->annotation().V_act().isEmpty())
05850                      {
05851                             PutDoc("/V << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+
05852                                    " 0 R >>\n");
05853                             AAcoun++;
05854                      }
05855                      if (!ite->annotation().C_act().isEmpty())
05856                      {
05857                             PutDoc("/C << /Type /Action /S /JavaScript /JS "+QString::number(ObjCounter+AAcoun)+
05858                                    " 0 R >>\n");
05859                             AAcoun++;
05860                      }
05861               }
05862               PutDoc(">>\nendobj\n");
05863               if (!ite->annotation().E_act().isEmpty())
05864                      WritePDFStream(ite->annotation().E_act());
05865               if (!ite->annotation().X_act().isEmpty())
05866                      WritePDFStream(ite->annotation().X_act());
05867               if (!ite->annotation().D_act().isEmpty())
05868                      WritePDFStream(ite->annotation().D_act());
05869               if (!ite->annotation().Fo_act().isEmpty())
05870                      WritePDFStream(ite->annotation().Fo_act());
05871               if (!ite->annotation().Bl_act().isEmpty())
05872                      WritePDFStream(ite->annotation().Bl_act());
05873               if ((ite->annotation().Type() == 3) || (ite->annotation().Type() == 5) || (ite->annotation().Type() == 6))
05874               {
05875                      if (!ite->annotation().K_act().isEmpty())
05876                             WritePDFStream(ite->annotation().K_act());
05877                      if (!ite->annotation().F_act().isEmpty())
05878                             WritePDFStream(ite->annotation().F_act());
05879                      if (!ite->annotation().V_act().isEmpty())
05880                             WritePDFStream(ite->annotation().V_act());
05881                      if (!ite->annotation().C_act().isEmpty())
05882                             WritePDFStream(ite->annotation().C_act());
05883               }
05884        }
05885 }
05886 
05887 void PDFlib::WritePDFStream(const QString& cc)
05888 {
05889        QString tmp(cc);
05890        if ((Options.Compress) && (CompAvail))
05891               tmp = CompressStr(&tmp);
05892        StartObj(ObjCounter);
05893        ObjCounter++;
05894        PutDoc("<< /Length "+QString::number(tmp.length()));  // moeglicherweise +1
05895        if ((Options.Compress) && (CompAvail))
05896               PutDoc("\n/Filter /FlateDecode");
05897        PutDoc(" >>\nstream\n"+EncStream(tmp, ObjCounter-1)+"\nendstream\nendobj\n");
05898 }
05899 
05900 void PDFlib::PDF_xForm(double w, double h, QString im)
05901 {
05902        StartObj(ObjCounter);
05903        ObjCounter++;
05904        PutDoc("<<\n/Type /XObject\n/Subtype /Form\n");
05905        PutDoc("/BBox [ 0 0 "+FToStr(w)+" "+FToStr(h)+" ]\n");
05906        PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
05907        if (Seite.ImgObjects.count() != 0)
05908        {
05909               PutDoc("/XObject <<\n");
05910               QMap<QString,int>::Iterator it;
05911               for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
05912                      PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
05913               PutDoc(">>\n");
05914        }
05915        if (Seite.FObjects.count() != 0)
05916        {
05917               PutDoc("/Font << \n");
05918               QMap<QString,int>::Iterator it2;
05919               for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
05920                      PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
05921               PutDoc(">>\n");
05922        }
05923        PutDoc(">>\n");
05924        PutDoc("/Length "+QString::number(im.length())+"\n");
05925        PutDoc(">>\nstream\n"+EncStream(im, ObjCounter-1)+"\nendstream\nendobj\n");
05926        Seite.XObjects[ResNam+QString::number(ResCount)] = ObjCounter-1;
05927        ResCount++;
05928 }
05929 
05930 void PDFlib::PDF_Form(const QString& im)
05931 {
05932        StartObj(ObjCounter);
05933        ObjCounter++;
05934        PutDoc("<<\n");
05935        PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
05936        if (Seite.FObjects.count() != 0)
05937        {
05938               PutDoc("/Font << \n");
05939               QMap<QString,int>::Iterator it2;
05940               for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
05941                      PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
05942               PutDoc(">>\n");
05943        }
05944        PutDoc(">>\n");
05945        PutDoc("/Length "+QString::number(im.length())+"\n");
05946        PutDoc(">>\nstream\n"+EncStream(im, ObjCounter-1)+"\nendstream\nendobj\n");
05947 }
05948 
05949 void PDFlib::PDF_Bookmark(PageItem *currItem, double ypos)
05950 {
05951        Bvie->SetAction(currItem, "/XYZ 0 "+FToStr(ypos)+" 0]");
05952        BookMinUse = true;
05953 }
05954 
05955 QString PDFlib::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN, const QString& Profil, bool Embedded, int Intent)
05956 {
05957        QFileInfo fi = QFileInfo(fn);
05958        QString ext = fi.extension(false).lower();
05959        if (ext.isEmpty())
05960               ext = getImageType(fn);
05961        ScImage img;
05962        QByteArray im;
05963        QString tmp, tmpy, dummy, cmd1, cmd2, BBox;
05964        QChar tc;
05965        bool found = false;
05966        bool alphaM = false;
05967        bool realCMYK = false;
05968        int afl = Options.Resolution;
05969        double x2, ax, ay, a2, a1;
05970        double sxn = 0;
05971        double syn = 0;
05972        x2 = 0;
05973        double aufl = Options.Resolution / 72.0;
05974        int ImRes, ImWid, ImHei;
05975        int origWidth = 1;
05976        int origHeight = 1;
05977        struct ShIm ImInfo;
05978        if ((!SharedImages.contains(fn)) || (fromAN) || (c->effectsInUse.count() != 0))
05979        {
05980 /*            if ((ext == "pdf") && (Options.Version  >= 14))
05981               {
05982                      StartObj(ObjCounter);
05983                      PutDoc("<<\n/Type /EmbeddedFile\n");
05984                      im = "";
05985                      loadText(fn, &im);
05986                      if ((Options.Compress) && (CompAvail))
05987                      {
05988                             PutDoc("/Filter /FlateDecode\n");
05989                             im = CompressStr(&im);
05990                      }
05991                      PutDoc("/Length "+QString::number(im.length())+"\n");
05992                      PutDoc(">>\nstream\n"+EncStream(im, ObjCounter)+"\nendstream\nendobj\n");
05993                      ObjCounter++;
05994                      StartObj(ObjCounter);
05995                      PutDoc("<<\n/Type /Filespec\n/F ("+fn+")\n/EF << /F "+QString::number(ObjCounter-1)+" 0 R >>\n");
05996                      PutDoc(">>\nendobj\n");
05997                      ObjCounter++;
05998                      StartObj(ObjCounter);
05999                      PutDoc("<<\n/Type /XObject\n/Subtype /Form\n");
06000                      PutDoc("/BBox [ 0 0 "+FToStr(c->Width)+" "+FToStr(c->Height)+" ]\n");
06001                      PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]>>\n");
06002                      PutDoc("/Ref <<\n/Page 1\n/F "+QString::number(ObjCounter-1)+" 0 R\n>>\n");
06003                      PutDoc("/Length 0\n");
06004                      PutDoc(">>\nstream\nendstream\nendobj\n");
06005                      ObjCounter++;
06006               }
06007               else
06008               { */
06009               if (((ext == "eps") || (ext == "epsi") || (ext == "pdf")) && (c->pixm.imgInfo.type != 7))
06010               {
06011                      QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.png");
06012                      if (Options.RecalcPic)
06013                      {
06014                             afl = QMIN(Options.PicRes, Options.Resolution);
06015                             aufl = afl / 72.0;
06016                      }
06017                      else
06018                             afl = Options.Resolution;
06019                      if (ext == "pdf")
06020                      {
06021                             CMSettings cms(c->doc(), Profil, Intent);
06022                             if (Options.UseRGB)
06023                                    img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06024                             else
06025                             {
06026                                    if ((doc.HasCMS) && (Options.UseProfiles2))
06027                                           img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06028                                    else
06029                                    {
06030                                           if (Options.isGrayscale)
06031                                                  img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06032                                           else
06033                                                  img.LoadPicture(fn, cms, Embedded, true, ScImage::CMYKData, afl);
06034                                    }
06035                             }
06036                      }
06037                      else
06038                      {
06039                             QFile f(fn);
06040                             if (f.open(IO_ReadOnly))
06041                             {
06042                                    QTextStream ts(&f);
06043                                    while (!ts.atEnd())
06044                                    {
06045                                           tc = ' ';
06046                                           tmp = "";
06047                                           while ((tc != '\n') && (tc != '\r'))
06048                                           {
06049                                                  ts >> tc;
06050                                                  if ((tc != '\n') && (tc != '\r'))
06051                                                         tmp += QChar(tc);
06052                                           }
06053                                           if (tmp.startsWith("%%BoundingBox:"))
06054                                           {
06055                                                  found = true;
06056                                                  BBox = tmp.remove("%%BoundingBox:");
06057                                           }
06058                                           if (!found)
06059                                           {
06060                                                  if (tmp.startsWith("%%BoundingBox"))
06061                                                  {
06062                                                         found = true;
06063                                                         BBox = tmp.remove("%%BoundingBox");
06064                                                  }
06065                                           }
06066                                           if (tmp.startsWith("%%EndComments"))
06067                                                  break;
06068                                    }
06069                                    f.close();
06070                                    if (found)
06071                                    {
06072                                           CMSettings cms(c->doc(), Profil, Intent);
06073                                           if (Options.UseRGB)
06074                                                  img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06075                                           else
06076                                           {
06077                                                  if ((doc.HasCMS) && (Options.UseProfiles2))
06078                                                         img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06079                                                  else
06080                                                  {
06081                                                         if (Options.isGrayscale)
06082                                                                img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, afl);
06083                                                         else
06084                                                                img.LoadPicture(fn, cms, Embedded, true, ScImage::CMYKData, afl);
06085                                                  }
06086                                           }
06087                                    }
06088                             }
06089                      }
06090                      if (Options.RecalcPic)
06091                      {
06092                             sxn = sx * (1.0 / aufl);
06093                             syn = sy * (1.0 / aufl);
06094                      }
06095               }
06096               else
06097               {
06098                      img.imgInfo.valid = false;
06099                      img.imgInfo.clipPath = "";
06100                      img.imgInfo.PDSpathData.clear();
06101                      img.imgInfo.layerInfo.clear();
06102                      img.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
06103                      img.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
06104                      CMSettings cms(c->doc(), Profil, Intent);
06105                      if (Options.UseRGB)
06106                             img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, 72, &realCMYK);
06107                      else
06108                      {
06109                             if ((doc.HasCMS) && (Options.UseProfiles2))
06110                                    img.LoadPicture(fn, cms, Embedded, true, ScImage::RawData, 72, &realCMYK);
06111                             else
06112                             {
06113                                    if (Options.isGrayscale)
06114                                           img.LoadPicture(fn, cms, Embedded, true, ScImage::RGBData, 72, &realCMYK);
06115                                    else
06116                                           img.LoadPicture(fn, cms, Embedded, true, ScImage::CMYKData, 72, &realCMYK);
06117                             }
06118                      }
06119                      if ((Options.RecalcPic) && (Options.PicRes < (QMAX(72.0 / c->imageXScale(), 72.0 / c->imageYScale()))))
06120                      {
06121                             double afl = QMIN(Options.PicRes, Options.Resolution);
06122                             a2 = (72.0 / sx) / afl;
06123                             a1 = (72.0 / sy) / afl;
06124                             origWidth = img.width();
06125                             origHeight = img.height();
06126                             ax = img.width() / a2;
06127                             ay = img.height() / a1;
06128                             if ((Options.UseRGB) || (Options.isGrayscale) || ((Options.UseProfiles2) && !(img.imgInfo.colorspace == 1)) )
06129                             {
06130                                    int colsp = img.imgInfo.colorspace;
06131                                    bool prog = img.imgInfo.progressive;
06132                                    img = img.smoothScale(qRound(ax), qRound(ay));
06133                                    img.imgInfo.colorspace = colsp;
06134                                    img.imgInfo.progressive = prog;
06135                             }
06136                             else
06137                                    img.scaleImage(qRound(ax), qRound(ay));
06138                             sxn = sx * a2;
06139                             syn = sy * a1;
06140                      }
06141                      aufl = 1;
06142               }
06143               if ((doc.HasCMS) && (Options.UseProfiles2))
06144               {
06145                      if (!ICCProfiles.contains(Profil))
06146                      {
06147                             ScImage img3;
06148                             int components = 0;
06149                             StartObj(ObjCounter);
06150                             ObjCounter++;
06151                             QByteArray dataP;
06152                             struct ICCD dataD;
06153                             if ((Embedded) && (!Options.EmbeddedI))
06154                             {
06155                                    img3.getEmbeddedProfile(fn, &dataP, &components);
06156                                    if (dataP.isEmpty())
06157                                    {
06158                                           if (img.imgInfo.colorspace == 1)
06159                                           {
06160                                                  loadRawBytes((Embedded ? ScCore->InputProfilesCMYK[Options.ImageProf] : ScCore->InputProfilesCMYK[Profil]), dataP);
06161                                                  components = 4;
06162                                           }
06163                                           else
06164                                           {
06165                                                  loadRawBytes((Embedded ? ScCore->InputProfiles[Options.ImageProf] : ScCore->InputProfiles[Profil]), dataP);
06166                                                  components = 3;
06167                                           }
06168                                    }
06169                             }
06170                             else
06171                             {
06172                                    if (img.imgInfo.colorspace == 1)
06173                                    {
06174                                           loadRawBytes((Embedded ? ScCore->InputProfilesCMYK[Options.ImageProf] : ScCore->InputProfilesCMYK[Profil]), dataP);
06175                                           components = 4;
06176                                    }
06177                                    else
06178                                    {
06179                                           loadRawBytes((Embedded ? ScCore->InputProfiles[Options.ImageProf] : ScCore->InputProfiles[Profil]), dataP);
06180                                           components = 3;
06181                                    }
06182                             }
06183                             PutDoc("<<\n");
06184                             if ((Options.CompressMethod != 3) && (CompAvail) && (Options.Compress))
06185                             {
06186                                    PutDoc("/Filter /FlateDecode\n");
06187                                    dataP = CompressArray(&dataP);
06188                             }
06189                             PutDoc("/Length "+QString::number(dataP.size()+1)+"\n");
06190                             PutDoc("/N "+QString::number(components)+"\n");
06191                             PutDoc(">>\nstream\n");
06192                             PutDoc(EncStreamArray(dataP, ObjCounter-1));
06193                             PutDoc("\nendstream\nendobj\n");
06194                             StartObj(ObjCounter);
06195                             dataD.ResName = ResNam+QString::number(ResCount);
06196                             dataD.ICCArray = "[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]";
06197                             dataD.ResNum = ObjCounter;
06198                             ICCProfiles[Profil] = dataD;
06199                             PutDoc("[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]\n");
06200                             PutDoc("endobj\n");
06201                             ResCount++;
06202                             ObjCounter++;
06203                      }
06204               }
06205               QByteArray im2;
06206               ScImage img2;
06207               img2.imgInfo.clipPath = "";
06208               img2.imgInfo.PDSpathData.clear();
06209               img2.imgInfo.layerInfo.clear();
06210               img2.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
06211               img2.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
06212               if (c->pixm.imgInfo.type == 7)
06213                      alphaM = false;
06214               else
06215               {
06216                      if (Options.Version >= 14)
06217                             im2 = img2.getAlpha(fn, true, true, afl, img.width(), img.height());
06218                      else
06219                             im2 = img2.getAlpha(fn, true, false, afl, img.width(), img.height());
06220                      if (!im2.isEmpty())
06221                             alphaM = true;
06222               }
06223               bool imgE = false;
06224               if ((Options.UseRGB) || (Options.isGrayscale))
06225                      imgE = false;
06226               else
06227               {
06228                      if ((Options.UseProfiles2) && (img.imgInfo.colorspace != 1))
06229                             imgE = false;
06230                      else
06231                             imgE = true;
06232               }
06233               origWidth = img.width();
06234               origHeight = img.height();
06235               img.applyEffect(c->effectsInUse, c->doc()->PageColors, imgE);
06236               if (!((Options.RecalcPic) && (Options.PicRes < (QMAX(72.0 / c->imageXScale(), 72.0 / c->imageYScale())))))
06237               {
06238                      sxn = sx * (1.0 / aufl);
06239                      syn = sy * (1.0 / aufl);
06240               }
06241               if (alphaM)
06242               {
06243                      StartObj(ObjCounter);
06244                      ObjCounter++;
06245                      PutDoc("<<\n/Type /XObject\n/Subtype /Image\n");
06246                      if (Options.Version >= 14)
06247                      {
06248                             if ((Options.CompressMethod != 3) && (CompAvail))
06249                                    im2 = CompressArray(&im2);
06250                             PutDoc("/Width "+QString::number(origWidth)+"\n");
06251                             PutDoc("/Height "+QString::number(origHeight)+"\n");
06252                             PutDoc("/ColorSpace /DeviceGray\n");
06253                             PutDoc("/BitsPerComponent 8\n");
06254                             PutDoc("/Length "+QString::number(im2.size())+"\n");
06255                      }
06256                      else
06257                      {
06258                             if ((Options.CompressMethod != 3) && (CompAvail))
06259                                    im2 = CompressArray(&im2);
06260                             PutDoc("/Width "+QString::number(origWidth)+"\n");
06261                             PutDoc("/Height "+QString::number(origHeight)+"\n");
06262                             PutDoc("/ImageMask true\n/BitsPerComponent 1\n");
06263                             PutDoc("/Length "+QString::number(im2.size())+"\n");
06264                      }
06265                      if ((Options.CompressMethod != 3) && (CompAvail))
06266                             PutDoc("/Filter /FlateDecode\n");
06267                      PutDoc(">>\nstream\n");
06268                      PutDoc(EncStreamArray(im2, ObjCounter-1));
06269                      PutDoc("\nendstream\nendobj\n");
06270                      Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = ObjCounter-1;
06271                      ResCount++;
06272               }
06273               if (Options.UseRGB)
06274                      im = img.ImageToArray();
06275               else
06276               {
06277                      if (Options.isGrayscale)
06278                             im = img.ImageToGray();
06279                      else
06280                      {
06281                             if ((doc.HasCMS) && (Options.UseProfiles2) && (!realCMYK))
06282                                    im = img.ImageToArray();
06283                             else
06284                                    im = img.ImageToCMYK_PDF(true);
06285                      }
06286               }
06287               StartObj(ObjCounter);
06288               ObjCounter++;
06289               if (((Options.CompressMethod == 2) || (Options.CompressMethod == 0)) && (CompAvail))
06290                      im = CompressArray(&im);
06291               PutDoc("<<\n/Type /XObject\n/Subtype /Image\n");
06292               PutDoc("/Width "+QString::number(img.width())+"\n");
06293               PutDoc("/Height "+QString::number(img.height())+"\n");
06294               if ((doc.HasCMS) && (Options.UseProfiles2))
06295               {
06296                      PutDoc("/ColorSpace "+ICCProfiles[Profil].ICCArray+"\n");
06297                      PutDoc("/Intent /");
06298                      int inte2 = Intent;
06299                      if (Options.EmbeddedI)
06300                             inte2 = Options.Intent2;
06301                      static const QString cmsmode[] = {"Perceptual", "RelativeColorimetric", "Saturation", "AbsoluteColorimetric"};
06302                      PutDoc(cmsmode[inte2] + "\n");
06303               }
06304               else
06305               {
06306                      if (Options.UseRGB)
06307                             PutDoc("/ColorSpace /DeviceRGB\n");
06308                      else
06309                      {
06310                             if (Options.isGrayscale)
06311                                    PutDoc("/ColorSpace /DeviceGray\n");
06312                             else
06313                                    PutDoc("/ColorSpace /DeviceCMYK\n");
06314                      }
06315               }
06316               int cm = Options.CompressMethod;
06317               bool specialCMYK = false;
06318               if (((ext == "jpg") || (ext == "jpeg")) && (cm != 3))
06319               {
06320                      if (((Options.UseRGB || Options.UseProfiles2) && (cm == 0) && (c->effectsInUse.count() == 0) && (img.imgInfo.colorspace == 0)) && (!img.imgInfo.progressive) && (!((Options.RecalcPic) && (Options.PicRes < (QMAX(72.0 / c->imageXScale(), 72.0 / c->imageYScale()))))))
06321                      {
06322                             im.resize(0);
06323                             loadRawBytes(fn, im);
06324                             cm = 1;
06325                      }
06326                      else if (((!Options.UseRGB) && (!Options.isGrayscale) && (!Options.UseProfiles2)) && (cm== 0) && (c->effectsInUse.count() == 0) && (img.imgInfo.colorspace == 1) && (!((Options.RecalcPic) && (Options.PicRes < (QMAX(72.0 / c->imageXScale(), 72.0 / c->imageYScale()))))) && (!img.imgInfo.progressive))
06327                      {
06328                             im.resize(0);
06329                             loadRawBytes(fn, im);
06330                             cm = 1;
06331                             specialCMYK = true;
06332                      }
06333                      else
06334                      {
06335                             if (Options.CompressMethod == 1)
06336                             {
06337                                    QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.jpg");
06338                                    if ((Options.UseRGB) || (Options.UseProfiles2) && (!realCMYK))
06339                                           img.Convert2JPG(tmpFile, Options.Quality, false, false);
06340                                    else
06341                                    {
06342                                           if (Options.isGrayscale)
06343                                                  img.Convert2JPG(tmpFile, Options.Quality, false, true);
06344                                           else
06345                                           {
06346                                                  img.Convert2JPG(tmpFile, Options.Quality, true, false);
06347                                                  specialCMYK = true;
06348                                           }
06349                                    }
06350                                    im.resize(0);
06351                                    loadRawBytes(tmpFile, im);
06352                                    cm = 1;
06353                                    QFile::remove(tmpFile);
06354                             }
06355                             else
06356                                    cm = 2;
06357                      }
06358               }
06359               else
06360               {
06361                      if ((Options.CompressMethod == 1) || (Options.CompressMethod == 0))
06362                      {
06363                             QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.jpg");
06364                             if ((Options.UseRGB) || (Options.UseProfiles2) && (!realCMYK))
06365                                    img.Convert2JPG(tmpFile, Options.Quality, false, false);
06366                             else
06367                             {
06368                                    if (Options.isGrayscale)
06369                                           img.Convert2JPG(tmpFile, Options.Quality, false, true);
06370                                    else
06371                                    {
06372                                           img.Convert2JPG(tmpFile, Options.Quality, true, false);
06373                                           specialCMYK = true;
06374                                    }
06375                             }
06376                             if (Options.CompressMethod == 0)
06377                             {
06378                                    QFileInfo fi(tmpFile);
06379                                    if (fi.size() < im.size())
06380                                    {
06381                                           im.resize(0);
06382                                           loadRawBytes(tmpFile, im);
06383                                           cm = 1;
06384                                    }
06385                                    else
06386                                           cm = 2;
06387                             }
06388                             else
06389                             {
06390                                    im.resize(0);
06391                                    loadRawBytes(tmpFile, im);
06392                                    cm = 1;
06393                             }
06394                             QFile::remove(tmpFile);
06395                      }
06396               }
06397               PutDoc("/BitsPerComponent 8\n");
06398               PutDoc("/Length "+QString::number(im.size())+"\n");
06399               if (CompAvail)
06400               {
06401                      if (cm == 1)
06402                             PutDoc("/Filter /DCTDecode\n");
06403                      else if (cm != 3)
06404                             PutDoc("/Filter /FlateDecode\n");
06405               }
06406               if ((specialCMYK) && ((cm == 1) && (CompAvail)))
06407                      PutDoc("/Decode [1 0 1 0 1 0 1 0]\n");
06408               if (alphaM)
06409               {
06410                      if (Options.Version >= 14)
06411                             PutDoc("/SMask "+QString::number(ObjCounter-2)+" 0 R\n");
06412                      else
06413                             PutDoc("/Mask "+QString::number(ObjCounter-2)+" 0 R\n");
06414               }
06415               PutDoc(">>\nstream\n");
06416               PutDoc(EncStreamArray(im, ObjCounter-1));
06417               PutDoc("\nendstream\nendobj\n");
06418 //            }
06419               Seite.ImgObjects[ResNam+"I"+QString::number(ResCount)] = ObjCounter-1;
06420               ImRes = ResCount;
06421               ImWid = img.width();
06422               ImHei = img.height();
06423               ImInfo.ResNum = ImRes;
06424               ImInfo.Width = ImWid;
06425               ImInfo.Height = ImHei;
06426               ImInfo.aufl = aufl;
06427               ImInfo.sxa = sxn;
06428               ImInfo.sya = syn;
06429               ImInfo.xa = sx;
06430               ImInfo.ya = sy;
06431               if (c->effectsInUse.count() == 0)
06432                      SharedImages.insert(fn, ImInfo);
06433               ResCount++;
06434        }
06435        else
06436        {
06437               ImRes = SharedImages[fn].ResNum;
06438               ImWid = SharedImages[fn].Width;
06439               ImHei = SharedImages[fn].Height;
06440               aufl = SharedImages[fn].aufl;
06441               sxn = SharedImages[fn].sxa * sx / SharedImages[fn].xa;
06442               syn = SharedImages[fn].sya * sy / SharedImages[fn].ya;
06443        }
06444        if ((ext == "eps") || (ext == "epsi") || (ext == "pdf"))// compensate gsResolution setting
06445        {
06446               sxn = PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * sxn;
06447               syn = PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * syn;
06448        }
06449        if (!fromAN)
06450        {
06451               QString tmp(FToStr(ImWid*sxn)+" 0 0 "+FToStr(ImHei*syn)+" "+FToStr(x*sx)+" "+FToStr((-ImHei*syn+y*sy))+" cm\n/"+ResNam+"I"+QString::number(ImRes)+" Do\n");
06452               return tmp;
06453        }
06454        else
06455               return "";
06456 }
06457 
06458 void PDFlib::PDF_End_Doc(const QString& PrintPr, const QString& Name, int Components)
06459 {
06460        QString tmp;
06461        uint StX;
06462        int Basis;
06463        int ResO;
06464        BookMItem* ip;
06465        QListViewItem* pp;
06466        QString Inhal = "";
06467        QMap<int,QString> Inha;
06468        Inha.clear();
06469        int Bmc = 0;
06470        if ((Bvie->childCount() != 0) && (Options.Bookmarks) && (BookMinUse))
06471        {
06472               Basis = ObjCounter - 1;
06473               Outlines.Count = Bvie->childCount();
06474               ip = (BookMItem*)Bvie->firstChild();
06475               pp = Bvie->firstChild();
06476               Outlines.First = ip->ItemNr+Basis;
06477               while (pp)
06478               {
06479                      if (!pp->nextSibling())
06480                      {
06481                             ip = (BookMItem*)pp;
06482                             Outlines.Last = ip->ItemNr+Basis;
06483                             break;
06484                      }
06485                      pp = pp->nextSibling();
06486               }
06487               QListViewItemIterator it(Bvie);
06488               for ( ; it.current(); ++it)
06489               {
06490                      ip = (BookMItem*)it.current();
06491                      Inhal = "";
06492                      Bmc++;
06493                      Inhal += QString::number(ip->ItemNr+Basis)+ " 0 obj\n";
06494                      QString encText = "";
06495                      for (uint telen = 0; telen < ip->Titel.length(); telen++)
06496                      {
06497                             encText += ip->Titel.at(telen);
06498                      }
06499                      Inhal += "<<\n/Title "+EncStringUTF16("("+encText+")", ip->ItemNr+Basis)+"\n";
06500                      if (ip->Pare == 0)
06501                             Inhal += "/Parent 3 0 R\n";
06502                      else
06503                             Inhal += "/Parent "+QString::number(ip->Pare+Basis)+" 0 R\n";
06504                      if (ip->Prev != 0)
06505                             Inhal += "/Prev "+QString::number(ip->Prev+Basis)+" 0 R\n";
06506                      if (ip->Next != 0)
06507                             Inhal += "/Next "+QString::number(ip->Next+Basis)+" 0 R\n";
06508                      if (ip->First != 0)
06509                             Inhal += "/First "+QString::number(ip->First+Basis)+" 0 R\n";
06510                      if (ip->Last != 0)
06511                             Inhal += "/Last "+QString::number(ip->Last+Basis)+" 0 R\n";
06512                      if (ip->firstChild())
06513                             Inhal += "/Count -"+QString::number(ip->childCount())+"\n";
06514                      if ((ip->PageObject->OwnPage != -1) && (ip->PageObject->OwnPage < static_cast<int>(PageTree.Kids.count())))
06515                             Inhal += "/Dest ["+QString::number(PageTree.Kids[ip->PageObject->OwnPage])+" 0 R "+ip->Action+"\n";
06516                      Inhal += ">>\nendobj\n";
06517                      Inha[ip->ItemNr] = Inhal;
06518               }
06519               for (int b = 1; b < Bmc+1; ++b)
06520               {
06521                      XRef.append(bytesWritten());
06522                      PutDoc(Inha[b]);
06523                      ObjCounter++;
06524               }
06525        }
06526        StartObj(ObjCounter);
06527        ResO = ObjCounter;
06528        PutDoc("<< /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n");
06529        if ((Seite.ImgObjects.count() != 0) || (Seite.XObjects.count() != 0))
06530        {
06531               PutDoc("/XObject <<\n");
06532               QMap<QString,int>::Iterator it;
06533               for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it)
06534                      PutDoc("/"+it.key()+" "+QString::number(it.data())+" 0 R\n");
06535               QMap<QString,int>::Iterator iti;
06536               for (iti = Seite.XObjects.begin(); iti != Seite.XObjects.end(); ++iti)
06537                      PutDoc("/"+iti.key()+" "+QString::number(iti.data())+" 0 R\n");
06538               PutDoc(">>\n");
06539        }
06540        if (Seite.FObjects.count() != 0)
06541        {
06542               PutDoc("/Font << \n");
06543               QMap<QString,int>::Iterator it2;
06544               for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2)
06545                      PutDoc("/"+it2.key()+" "+QString::number(it2.data())+" 0 R\n");
06546               PutDoc(">>\n");
06547        }
06548        if (Shadings.count() != 0)
06549        {
06550               PutDoc("/Shading << \n");
06551               QMap<QString,int>::Iterator it3;
06552               for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3)
06553                      PutDoc("/"+it3.key()+" "+QString::number(it3.data())+" 0 R\n");
06554               PutDoc(">>\n");
06555        }
06556        if (Patterns.count() != 0)
06557        {
06558               PutDoc("/Pattern << \n");
06559               QMap<QString,int>::Iterator it3p;
06560               for (it3p = Patterns.begin(); it3p != Patterns.end(); ++it3p)
06561                      PutDoc("/"+it3p.key()+" "+QString::number(it3p.data())+" 0 R\n");
06562               PutDoc(">>\n");
06563        }
06564        if (Transpar.count() != 0)
06565        {
06566               PutDoc("/ExtGState << \n");
06567               QMap<QString,int>::Iterator it3t;
06568               for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t)
06569                      PutDoc("/"+it3t.key()+" "+QString::number(it3t.data())+" 0 R\n");
06570               PutDoc(">>\n");
06571        }
06572        if ((ICCProfiles.count() != 0) || (spotMap.count() != 0) || (spotMapReg.count() != 0))
06573        {
06574               PutDoc("/ColorSpace << \n");
06575               QMap<QString,ICCD>::Iterator it3c;
06576               if (ICCProfiles.count() != 0)
06577               {
06578                      for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c)
06579                             PutDoc("/"+it3c.data().ResName+" "+QString::number(it3c.data().ResNum)+" 0 R\n");
06580               }
06581               QMap<QString,SpotC>::Iterator it3sc;
06582               if (spotMap.count() != 0)
06583               {
06584                      for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
06585                             PutDoc("/"+it3sc.data().ResName+" "+QString::number(it3sc.data().ResNum)+" 0 R\n");
06586               }
06587               QMap<QString,SpotC>::Iterator it3scr;
06588               if (spotMapReg.count() != 0)
06589               {
06590                      for (it3scr = spotMapReg.begin(); it3scr != spotMapReg.end(); ++it3scr)
06591                             PutDoc("/"+it3scr.data().ResName+" "+QString::number(it3scr.data().ResNum)+" 0 R\n");
06592               }
06593               PutDoc(">>\n");
06594        }
06595        if ((Options.Version == 15) && (Options.useLayers))
06596        {
06597               PutDoc("/Properties <<\n");
06598               struct Layer ll;
06599               ll.isPrintable = false;
06600               ll.LNr = 0;
06601               int Lnr = 0;
06602               for (uint la = 0; la < doc.Layers.count(); ++la)
06603               {
06604                      Level2Layer(&doc, &ll, la);
06605                      PutDoc("/"+OCGEntries[ll.Name].Name+" "+QString::number(OCGEntries[ll.Name].ObjNum)+" 0 R\n");
06606                      Lnr++;
06607               }
06608               PutDoc(">>\n");
06609        }
06610        PutDoc(">>\nendobj\n");
06611        ObjCounter++;
06612        XRef[2] = bytesWritten();
06613        PutDoc("3 0 obj\n<<\n/Type /Outlines\n");
06614        PutDoc("/Count "+QString::number(Outlines.Count)+"\n");
06615        if ((Bvie->childCount() != 0) && (Options.Bookmarks))
06616        {
06617               PutDoc("/First "+QString::number(Outlines.First)+" 0 R\n");
06618               PutDoc("/Last "+QString::number(Outlines.Last)+" 0 R\n");
06619        }
06620        PutDoc(">>\nendobj\n");
06621        XRef[3] = bytesWritten();
06622        PutDoc("4 0 obj\n<<\n/Type /Pages\n/Kids [");
06623        for (uint b = 0; b < PageTree.Kids.count(); ++b)
06624               PutDoc(QString::number(PageTree.Kids[b])+" 0 R ");
06625        PutDoc("]\n");
06626        PutDoc("/Count "+QString::number(PageTree.Count)+"\n");
06627        PutDoc("/Resources "+QString::number(ObjCounter-1)+" 0 R\n");
06628        PutDoc(">>\nendobj\n");
06629        XRef[4] = bytesWritten();
06630        PutDoc("5 0 obj\n<<\n");
06631        if (NamedDest.count() != 0)
06632        {
06633               QValueList<Dest>::Iterator vt;
06634               for (vt = NamedDest.begin(); vt != NamedDest.end(); ++vt)
06635               {
06636                      if ((*vt).Seite < static_cast<int>(PageTree.Kids.count()))
06637                             PutDoc("/"+(*vt).Name+" ["+QString::number(PageTree.Kids[(*vt).Seite])+" 0 R /XYZ "+(*vt).Act+"]\n");
06638               }
06639        }
06640        PutDoc(">>\nendobj\n");
06641        XRef[5] = bytesWritten();
06642        PutDoc("6 0 obj\n<<\n");
06643        if (Seite.FormObjects.count() != 0)
06644        {
06645               PutDoc("/Fields [ ");
06646               for (uint fo = 0; fo < Seite.FormObjects.count(); ++fo)
06647                      PutDoc(QString::number(Seite.FormObjects[fo])+" 0 R ");
06648               PutDoc(" ]\n");
06649        }
06650        if (CalcFields.count() != 0)
06651        {
06652               PutDoc("/CO [ ");
06653               for (uint foc = 0; foc < CalcFields.count(); ++foc)
06654                      PutDoc(QString::number(CalcFields[foc])+" 0 R ");
06655               PutDoc(" ]\n");
06656        }
06657        if ((Seite.FormObjects.count() != 0) || (CalcFields.count() != 0))
06658               PutDoc("/NeedAppearances true\n/DR "+QString::number(ResO)+" 0 R\n");
06659        PutDoc(">>\nendobj\n");
06660        if (doc.JavaScripts.count() != 0)
06661        {
06662               int Fjav0 = ObjCounter;
06663               QMap<QString,QString>::Iterator itja0;
06664               for (itja0 = doc.JavaScripts.begin(); itja0 != doc.JavaScripts.end(); ++itja0)
06665                      WritePDFStream(itja0.data());
06666               int Fjav = ObjCounter;
06667               QMap<QString,QString>::Iterator itja;
06668               for (itja = doc.JavaScripts.begin(); itja != doc.JavaScripts.end(); ++itja)
06669               {
06670                      StartObj(ObjCounter);
06671                      ObjCounter++;
06672                      PutDoc("<< /S /JavaScript /JS "+QString::number(Fjav0)+" 0 R >>\n");
06673                      PutDoc("endobj\n");
06674                      Fjav0++;
06675               }
06676               StartObj(ObjCounter);
06677               ObjCounter++;
06678               PutDoc("<< /Names [ ");
06679               QMap<QString,QString>::Iterator itja2;
06680               for (itja2 = doc.JavaScripts.begin(); itja2 != doc.JavaScripts.end(); ++itja2)
06681               {
06682                      PutDoc(EncString("("+itja2.key()+")", 6)+" "+QString::number(Fjav)+" 0 R ");
06683                      Fjav++;
06684               }
06685               PutDoc("] >>\nendobj\n");
06686        }
06687        XRef[6] = bytesWritten();
06688        PutDoc("7 0 obj\n<< ");
06689        if (doc.JavaScripts.count() != 0)
06690               PutDoc("/JavaScript "+QString::number(ObjCounter-1)+" 0 R");
06691        PutDoc(" >>\nendobj\n");
06692        Threads.clear();
06693        if (Options.Articles)
06694        {
06695               for (uint ele = 0; ele < doc.Items->count(); ++ele)
06696               {
06697                      PageItem* tel = doc.Items->at(ele);
06698                      if ((tel->asTextFrame()) && (tel->prevInChain() == 0) && (tel->nextInChain() != 0) &&
06699                                    (!tel->inPdfArticle))
06700                      {
06701                             StartObj(ObjCounter);
06702                             Threads.append(ObjCounter);
06703                             ObjCounter++;
06704                             PutDoc("<< /Type /Thread\n");
06705                             PutDoc("   /F "+QString::number(ObjCounter)+" 0 R\n");
06706                             PutDoc(">>\nendobj\n");
06707                             Beads.clear();
06708                             struct Bead bd;
06709                             int fir = ObjCounter;
06710                             int ccb = ObjCounter;
06711                             bd.Parent = ObjCounter-1;
06712                             while (tel->nextInChain() != 0)
06713                             {
06714                                    if (tel->OwnPage != -1)
06715                                    {
06716                                           bd.Next = ccb + 1;
06717                                           bd.Prev = ccb - 1;
06718                                           ccb++;
06719                                           bd.Page = PageTree.Kids[tel->OwnPage];
06720                                           bd.Recht = QRect(static_cast<int>(tel->xPos() - doc.Pages->at(tel->OwnPage)->xOffset()),
06721                                                                static_cast<int>(doc.Pages->at(tel->OwnPage)->height() - (tel->yPos()  - doc.Pages->at(tel->OwnPage)->yOffset())),
06722                                                                static_cast<int>(tel->width()),
06723                                                                static_cast<int>(tel->height()));
06724                                           Beads.append(bd);
06725                                    }
06726                                    tel->inPdfArticle = true;
06727                                    tel = tel->nextInChain();
06728                             }
06729                             bd.Next = ccb + 1;
06730                             bd.Prev = ccb - 1;
06731                             if (tel->OwnPage != -1)
06732                             {
06733                                    bd.Page = PageTree.Kids[tel->OwnPage];
06734                                    bd.Recht = QRect(static_cast<int>(tel->xPos() - doc.Pages->at(tel->OwnPage)->xOffset()),
06735                                                         static_cast<int>(doc.Pages->at(tel->OwnPage)->height() - (tel->yPos()  - doc.Pages->at(tel->OwnPage)->yOffset())),
06736                                                         static_cast<int>(tel->width()),
06737                                                         static_cast<int>(tel->height()));
06738                                    Beads.append(bd);
06739                             }
06740                             tel->inPdfArticle = true;
06741                             Beads[0].Prev = fir + Beads.count()-1;
06742                             Beads[Beads.count()-1].Next = fir;
06743                             for (uint beac = 0; beac < Beads.count(); ++beac)
06744                             {
06745                                    StartObj(ObjCounter);
06746                                    ObjCounter++;
06747                                    PutDoc("<< /Type /Bead\n");
06748                                    PutDoc("   /T "+QString::number(Beads[beac].Parent)+" 0 R\n");
06749                                    PutDoc("   /N "+QString::number(Beads[beac].Next)+" 0 R\n");
06750                                    PutDoc("   /V "+QString::number(Beads[beac].Prev)+" 0 R\n");
06751                                    PutDoc("   /P "+QString::number(Beads[beac].Page)+" 0 R\n");
06752                                    PutDoc("   /R [ "+QString::number(Beads[beac].Recht.x())+" "+
06753                                                  QString::number(Beads[beac].Recht.y())+" ");
06754                                    PutDoc(QString::number(Beads[beac].Recht.bottomRight().x())+" "+QString::number(Beads[beac].Recht.y()-Beads[beac].Recht.height())+" ]\n");
06755                                    PutDoc(">>\nendobj\n");
06756                             }
06757                      }
06758               }
06759               for (uint ele = 0; ele < doc.Items->count(); ++ele)
06760                      doc.Items->at(ele)->inPdfArticle = false;
06761        }
06762        XRef[7] = bytesWritten();
06763        PutDoc("8 0 obj\n[");
06764        for (uint th = 0; th < Threads.count(); ++th)
06765               PutDoc(QString::number(Threads[th])+" 0 R ");
06766        PutDoc("]\nendobj\n");
06767        if ((Options.Version == 15) && (Options.useLayers))
06768        {
06769               XRef[8] = bytesWritten();
06770               QStringList lay;
06771               PutDoc("9 0 obj\n<<\n");
06772               PutDoc("/D << /BaseState /ON /Order [ ");
06773               QMap<QString, OCGInfo>::Iterator itoc;
06774               for (itoc = OCGEntries.begin(); itoc != OCGEntries.end(); ++itoc)
06775               {
06776                      lay.prepend(QString::number(itoc.data().ObjNum)+" 0 R ");
06777               }
06778               for (uint layc = 0; layc < lay.count(); ++layc)
06779               {
06780                      PutDoc(lay[layc]);
06781               }
06782               PutDoc("]\n/OFF [ ");
06783               for (itoc = OCGEntries.begin(); itoc != OCGEntries.end(); ++itoc)
06784               {
06785                      if (!itoc.data().visible)
06786                             PutDoc(QString::number(itoc.data().ObjNum)+" 0 R ");
06787               }
06788               PutDoc("] >>\n/OCGs [ ");
06789               for (itoc = OCGEntries.begin(); itoc != OCGEntries.end(); ++itoc)
06790               {
06791                      PutDoc(QString::number(itoc.data().ObjNum)+" 0 R ");
06792               }
06793               PutDoc("]\n");
06794 /*            PutDoc("/AS << /Event /Print /Category [/Print] /OCGs [");
06795               for (itoc = OCGEntries.begin(); itoc != OCGEntries.end(); ++itoc)
06796               {
06797                      PutDoc(QString::number(itoc.data().ObjNum)+" 0 R ");
06798               }
06799               PutDoc("] >>\n"); */
06800               PutDoc(">>\nendobj\n");
06801        }
06802        if (Options.Version == 12)
06803        {
06804               StartObj(ObjCounter);
06805               ObjCounter++;
06806               QByteArray dataP;
06807               loadRawBytes(PrintPr, dataP);
06808               PutDoc("<<\n");
06809               if ((Options.Compress) && (CompAvail))
06810               {
06811                      PutDoc("/Filter /FlateDecode\n");
06812                      dataP = CompressArray(&dataP);
06813               }
06814               PutDoc("/Length "+QString::number(dataP.size()+1)+"\n");
06815               PutDoc("/N "+QString::number(Components)+"\n");
06816               PutDoc(">>\nstream\n");
06817               PutDoc(dataP);
06818               PutDoc("\nendstream\nendobj\n");
06819               XRef[8] = bytesWritten();
06820               PutDoc("9 0 obj\n");
06821               PutDoc("<<\n/Type /OutputIntent\n/S /GTS_PDFX\n");
06822               PutDoc("/DestOutputProfile "+QString::number(ObjCounter-1)+" 0 R\n");
06823               PutDoc("/OutputConditionIdentifier (Custom)\n");
06824               PutDoc("/Info ("+PDFEncode(Options.Info)+")\n");
06825               PutDoc("/OutputCondition ("+PDFEncode(Name)+")\n");
06826               PutDoc(">>\nendobj\n");
06827        }
06828        StX = bytesWritten();
06829        PutDoc("xref\n");
06830        PutDoc("0 "+QString::number(ObjCounter)+"\n");
06831        PutDoc("0000000000 65535 f \n");
06832        for (uint a = 0; a < XRef.count(); ++a)
06833        {
06834               tmp.sprintf("%10d", XRef[a]);
06835               tmp.replace(QRegExp(" "), "0");
06836               PutDoc(tmp+" 00000 n \n");
06837        }
06838        PutDoc("trailer\n<<\n/Size "+QString::number(XRef.count()+1)+"\n");
06839        QString IDs ="";
06840        for (uint cl = 0; cl < 16; ++cl)
06841               IDs += QChar(FileID[cl]);
06842        IDs = String2Hex(&IDs);
06843        PutDoc("/Root 1 0 R\n/Info 2 0 R\n/ID [<"+IDs+"><"+IDs+">]\n");
06844        if (Options.Encrypt)
06845               PutDoc("/Encrypt "+QString::number(Encrypt)+" 0 R\n");
06846        PutDoc(">>\nstartxref\n");
06847        PutDoc(QString::number(StX)+"\n%%EOF\n");
06848        closeAndCleanup();
06849 }
06850 
06851 void PDFlib::closeAndCleanup()
06852 {
06853        Spool.close();
06854        if (abortExport)
06855        {
06856               if (Spool.exists())
06857                      Spool.remove();
06858        }
06859        Seite.XObjects.clear();
06860        Seite.ImgObjects.clear();
06861        Seite.FObjects.clear();
06862        Seite.AObjects.clear();
06863        Seite.FormObjects.clear();
06864        CalcFields.clear();
06865        Shadings.clear();
06866        Transpar.clear();
06867        ICCProfiles.clear();
06868 
06869 }
06870 
06871 void PDFlib::cancelRequested()
06872 {
06873        abortExport=true;
06874 }