Back to index

scribus-ng  1.3.4.dfsg+svn20071115
pslib.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                           pslib.cpp  -  description
00009                              -------------------
00010     begin                : Sat May 26 2001
00011     copyright            : (C) 2001 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 "pslib.h"
00025 #include "pslib.moc"
00026 
00027 #include <qfileinfo.h>
00028 #include <qimage.h>
00029 #include <qcolor.h>
00030 #include <qcstring.h>
00031 #include <qfontinfo.h>
00032 #include <cstdlib>
00033 #include <qregexp.h>
00034 #include <qbuffer.h>
00035 #include <qptrstack.h>
00036 
00037 #include "commonstrings.h"
00038 #include "scconfig.h"
00039 #include "pluginapi.h"
00040 #include "prefsmanager.h"
00041 #include "scribusdoc.h"
00042 #include "scribus.h"
00043 #include "scribuscore.h"
00044 #include "scfonts.h"
00045 #include "selection.h"
00046 #include <cmath>
00047 #include "util.h"
00048 #include "multiprogressdialog.h"
00049 #include "scribusapp.h"
00050 #include "scpattern.h"
00051 #include "sccolorengine.h"
00052 
00053 #include "text/nlsconfig.h"
00054 
00055 PSLib::PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf, bool spot)
00056 {
00057        Options = options;
00058        usingGUI=ScCore->usingGUI();
00059        abortExport=false;
00060        QString tmp, tmp2, tmp3, tmp4, CHset;
00061        QStringList wt;
00062        Seiten = 0;
00063        User = "";
00064        Creator = "Scribus" + QString(VERSION);
00065        Titel = "";
00066        FillColor = "0.0 0.0 0.0 0.0";
00067        StrokeColor = "0.0 0.0 0.0 0.0";
00068        Header = psart ? "%!PS-Adobe-3.0\n" : "%!PS-Adobe-3.0 EPSF-3.0\n";
00069        BBox = "";
00070        BBoxH = "";
00071        Art = psart;
00072        isPDF = pdf;
00073        UsedFonts.clear();
00074        Fonts = "";
00075        FontDesc = "";
00076        GraySc = false;
00077        DoSep = false;
00078        abortExport = false;
00079        useSpotColors = spot;
00080        CompAvail = true;
00081        GrayCalc =  "/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add\n";
00082        GrayCalc += "               dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n";
00083        GrayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add\n";
00084        GrayCalc += "              oldsetgray} bind def\n";
00085        Farben = "";
00086        FNamen = "";
00087        CMYKColor cmykValues;
00088        ColorList::Iterator itf;
00089        int c, m, y, k;
00090        bool erst = true;
00091        colorsToUse = DocColors;
00092        spotMap.clear();
00093        colorDesc = "";
00094        for (itf = DocColors.begin(); itf != DocColors.end(); ++itf)
00095        {
00096               if (((DocColors[itf.key()].isSpotColor()) || (DocColors[itf.key()].isRegistrationColor())) && (useSpotColors))
00097               {
00098                      ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues);
00099                      cmykValues.getValues(c, m, y, k);
00100                      colorDesc += "/Spot"+PSEncode(itf.key())+" { [ /Separation (";
00101                      if (DocColors[itf.key()].isRegistrationColor())
00102                             colorDesc += "All";
00103                      else
00104                             colorDesc += itf.key();
00105                      colorDesc += ")\n";
00106                      colorDesc += "/DeviceCMYK\n{\ndup "+ToStr(static_cast<double>(c) / 255)+"\nmul exch dup ";
00107                      colorDesc += ToStr(static_cast<double>(m) / 255)+"\nmul exch dup ";
00108                      colorDesc += ToStr(static_cast<double>(y) / 255)+"\nmul exch ";
00109                      colorDesc += ToStr(static_cast<double>(k) / 255)+" mul }] setcolorspace setcolor} bind def\n";
00110                      spotMap.insert(itf.key(), "Spot"+PSEncode(itf.key()));
00111               }
00112               if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && (itf.key() != "Yellow") && (itf.key() != "Black") && DocColors[itf.key()].isSpotColor())
00113               {
00114                      ScColorEngine::getCMYKValues(DocColors[itf.key()], DocColors.document(), cmykValues);
00115                      cmykValues.getValues(c, m, y, k);
00116                      if (!erst)
00117                      {
00118                             Farben += "%%+ ";
00119                             FNamen += "%%+ ";
00120                      }
00121                      Farben += ToStr(static_cast<double>(c) / 255) + " " + ToStr(static_cast<double>(m) / 255) + " ";
00122                      Farben += ToStr(static_cast<double>(y) / 255) + " " + ToStr(static_cast<double>(k) / 255) + " (" + itf.key() + ")\n";
00123                      FNamen += "(" + itf.key() + ")\n";
00124                      erst = false;
00125               }
00126        }
00127        QMap<QString, QMap<uint, FPointArray> >::Iterator it;
00128        int a = 0;
00129        for (it = DocFonts.begin(); it != DocFonts.end(); ++it)
00130        {
00131 /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
00132               ScFace::FontType type = AllFonts[it.key()].type();
00133 
00134               if ((type == ScFace::TTF) || (AllFonts[it.key()].isOTF()) || (AllFonts[it.key()].subset()))
00135               {
00136                      QMap<uint, FPointArray>& RealGlyphs(it.data());
00137                      FontDesc += "/"+AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+
00138                                    " "+IToStr(RealGlyphs.count()+1)+" dict def\n";
00139                      FontDesc += AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" begin\n";
00140                      QMap<uint,FPointArray>::Iterator ig;
00141                      for (ig = RealGlyphs.begin(); ig != RealGlyphs.end(); ++ig)
00142                      {
00143                             FontDesc += "/G"+IToStr(ig.key())+" { newpath\n";
00144                             FPoint np, np1, np2;
00145                             bool nPath = true;
00146                             if (ig.data().size() > 3)
00147                             {
00148                                    for (uint poi = 0; poi < ig.data().size()-3; poi += 4)
00149                                    {
00150                                           if (ig.data().point(poi).x() > 900000)
00151                                           {
00152                                                  FontDesc += "cl\n";
00153                                                  nPath = true;
00154                                                  continue;
00155                                           }
00156                                           if (nPath)
00157                                           {
00158                                                  np = ig.data().point(poi);
00159                                                  FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " m\n";
00160                                                  nPath = false;
00161                                           }
00162                                           np = ig.data().point(poi+1);
00163                                           np1 = ig.data().point(poi+3);
00164                                           np2 = ig.data().point(poi+2);
00165                                           FontDesc += ToStr(np.x()) + " " + ToStr(-np.y()) + " " +
00166                                                         ToStr(np1.x()) + " " + ToStr(-np1.y()) + " " +
00167                                                         ToStr(np2.x()) + " " + ToStr(-np2.y()) + " cu\n";
00168                                    }
00169                             }
00170                             FontDesc += "cl\n} bind def\n";
00171                      }
00172                      FontDesc += "end\n";
00173               }
00174               else
00175               {
00176                      UsedFonts.insert(it.key(), "/Fo"+IToStr(a));
00177                      Fonts += "/Fo"+IToStr(a)+" /"+AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+" findfont definefont pop\n";
00178                      if (AllFonts[it.key()].embedPs())
00179                      {
00180                             QString tmp;
00181                             if(AllFonts[it.key()].EmbedFont(tmp))
00182                             {
00183                                    FontDesc += "%%BeginFont: " + AllFonts[it.key()].psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + "\n";
00184                                    FontDesc += tmp + "\n%%EndFont\n";
00185                             }
00186                      }
00187                      GListe gl;
00188                      AllFonts[it.key()].glyphNames(gl);
00189                      GlyphsOfFont.insert(it.key(), gl);
00190                      a++;
00191               }
00192        }
00193        Prolog = "%%BeginProlog\n";
00194        Prolog += "/Scribusdict 100 dict def\n";
00195        Prolog += "Scribusdict begin\n";
00196        Prolog += "/sp {showpage} bind def\n";
00197        Prolog += "/oldsetgray /setgray load def\n";
00198        Prolog += "/cmyk {setcmykcolor} def\n";
00199        Prolog += "/m {moveto} bind def\n";
00200        Prolog += "/l {lineto} bind def\n";
00201        Prolog += "/li {lineto} bind def\n";
00202        Prolog += "/cu {curveto} bind def\n";
00203        Prolog += "/cl {closepath} bind def\n";
00204        Prolog += "/gs {gsave} bind def\n";
00205        Prolog += "/gr {grestore} bind def\n";
00206        Prolog += "/tr {translate} bind def\n";
00207        Prolog += "/ro {rotate} bind def\n";
00208        Prolog += "/sh {show} bind def\n";
00209        Prolog += "/shg {setcmykcolor moveto glyphshow} def\n";
00210        Prolog += "/shgsp {moveto glyphshow} def\n";
00211        Prolog += "/sc {scale} bind def\n";
00212        Prolog += "/se {selectfont} bind def\n";
00213        Prolog += "/sf {setfont} bind def\n";
00214        Prolog += "/sw {setlinewidth} bind def\n";
00215        Prolog += "/f  {findfont} bind def\n";
00216        Prolog += "/fi {fill} bind def\n";
00217        Prolog += "/st {stroke} bind def\n";
00218        Prolog += "/shgf {gs dup scale begin cvx exec fill end gr} bind def\n";
00219        Prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup scale\n";
00220        Prolog += "       begin cvx exec st end gr} bind def\n";
00221        Prolog += "/bEPS {\n";
00222        Prolog += "    /b4_Inc_state save def\n";
00223        Prolog += "    /dict_count countdictstack def\n";
00224        Prolog += "    /op_count count 1 sub def\n";
00225        Prolog += "    userdict begin\n";
00226        Prolog += "    /showpage { } def\n";
00227        Prolog += "    0 setgray 0 setlinecap\n";
00228        Prolog += "    1 setlinewidth 0 setlinejoin\n";
00229        Prolog += "    10 setmiterlimit [ ] 0 setdash newpath\n";
00230        Prolog += "    /languagelevel where\n";
00231        Prolog += "    {pop languagelevel\n";
00232        Prolog += "    1 ne\n";
00233        Prolog += "    {false setstrokeadjust false setoverprint\n";
00234        Prolog += "    } if } if } bind def\n";
00235        Prolog += "/eEPS { count op_count sub {pop} repeat\n";
00236        Prolog += "    countdictstack dict_count sub {end} repeat\n";
00237        Prolog += "    b4_Inc_state restore } bind def\n";
00238        Prolog += "    end\n";
00239        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
00240               Prolog += "/rb { [ /Separation (All)\n/DeviceCMYK { dup 0 mul exch dup 0 mul exch dup 0 mul exch 1 mul }\n] setcolorspace setcolor} bind def\n";
00241        Prolog += "%%EndProlog\n";
00242 }
00243 
00244 void PSLib::PutSeite(QString c)
00245 {
00246        spoolStream.writeRawBytes(c, c.length());
00247 }
00248 
00249 void PSLib::PutSeite(QByteArray& array, bool hexEnc)
00250 {
00251        if(hexEnc)
00252        {
00253               int length = 0;
00254               for (uint i = 0; i < array.size(); i++)
00255               {
00256                      length++;
00257                      spoolStream << toHex(array[i]);
00258                      if ( length > 40 )
00259                      {
00260                             spoolStream << "\n";
00261                             length = 0;
00262                      }
00263               }
00264        }
00265        else
00266               spoolStream.writeRawBytes(array, array.size());
00267 }
00268 
00269 void PSLib::PutSeite(const char* array, int length, bool hexEnc)
00270 {
00271        if(hexEnc)
00272        {
00273               int len = 0;
00274               for (int i = 0; i < length; i++)
00275               {
00276                      len++;
00277                      spoolStream << toHex(array[i]);
00278                      if ( len > 40 )
00279                      {
00280                             spoolStream << "\n";
00281                             len = 0;
00282                      }
00283               }
00284        }
00285        else
00286               spoolStream.writeRawBytes(array, length);
00287 }
00288 
00289 void PSLib::PutDoc(QString c)
00290 {
00291        spoolStream.writeRawBytes(c, c.length());
00292 }
00293 
00294 void PSLib::PutDoc(QByteArray& array, bool hexEnc)
00295 {
00296        if(hexEnc)
00297        {
00298               int length = 0;
00299               for (uint i = 0; i < array.size(); i++)
00300               {
00301                      length++;
00302                      spoolStream << toHex(array[i]);
00303                      if ( length > 40 )
00304                      {
00305                             spoolStream << "\n";
00306                             length = 0;
00307                      }
00308               }
00309        }
00310        else
00311               spoolStream.writeRawBytes(array, array.size());
00312 }
00313 
00314 void PSLib::PutDoc(const char* array, int length, bool hexEnc)
00315 {
00316        if(hexEnc)
00317        {
00318               int len = 0;
00319               for (int i = 0; i < length; i++)
00320               {
00321                      len++;
00322                      spoolStream << toHex(array[i]);
00323                      if ( len > 40 )
00324                      {
00325                             spoolStream << "\n";
00326                             len = 0;
00327                      }
00328               }
00329        }
00330        else
00331               spoolStream.writeRawBytes(array, length);
00332 }
00333 
00334 QString PSLib::ToStr(double c)
00335 {
00336        QString cc;
00337        return cc.setNum(c);
00338 }
00339 
00340 QString PSLib::IToStr(int c)
00341 {
00342        QString cc;
00343        return cc.setNum(c);
00344 }
00345 
00346 void PSLib::PS_set_Info(QString art, QString was)
00347 {
00348        if (art == "Author")
00349               User = was;
00350        if (art == "Creator")
00351               Creator = was;
00352        if (art == "Title")
00353               Titel = was;
00354 }
00355 
00356 bool PSLib::PS_set_file(QString fn)
00357 {
00358        Spool.setName(fn);
00359        if (Spool.exists())
00360               Spool.remove();
00361        bool ret = Spool.open(IO_WriteOnly);
00362        spoolStream.setDevice(&Spool);
00363        return ret;
00364 }
00365 
00366 void PSLib::PS_begin_doc(ScribusDoc *doc, double x, double y, double breite, double hoehe, int numpage, bool doDev, bool sep, bool farb, bool ic, bool gcr, bool over)
00367 {
00368        m_Doc = doc;
00369        PutDoc(Header);
00370        PutDoc("%%For: " + User + "\n");
00371        PutDoc("%%Title: " + Titel + "\n");
00372        PutDoc("%%Creator: " + Creator + "\n");
00373        PutDoc("%%Pages: " + IToStr(numpage) + "\n");
00374        BBox = "%%BoundingBox: " + IToStr(qRound(x)) + " " + IToStr(qRound(y)) + " " + IToStr(qRound(breite)) + " " + IToStr(qRound(hoehe)) + "\n";
00375        BBoxH = "%%HiResBoundingBox: " + ToStr(x) + " " + ToStr(y) + " " + ToStr(breite) + " " + ToStr(hoehe) + "\n";
00376  //    if (!Art)
00377 //     {
00378               PutDoc(BBox);
00379               PutDoc(BBoxH);
00380 //     }
00381        if (!FNamen.isEmpty())
00382               PutDoc("%%DocumentCustomColors: "+FNamen);
00383        if (!Farben.isEmpty())
00384               PutDoc("%%CMYKCustomColor: "+Farben);
00385        PutDoc("%%LanguageLevel: 3\n");
00386        PutDoc("%%EndComments\n");
00387        PutDoc(Prolog);
00388        PutDoc("%%BeginSetup\n");
00389        PutDoc("/pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse\n");
00390        if (!FontDesc.isEmpty())
00391               PutDoc(FontDesc);
00392        if ((!colorDesc.isEmpty()) && (!sep))
00393               PutDoc(colorDesc);
00394        PutDoc("Scribusdict begin\n");
00395        PutDoc(Fonts);
00396        if (GraySc)
00397               PutDoc(GrayCalc);
00398        if (over)
00399        {
00400               PutDoc("true setoverprint\n");
00401               PutDoc("true setoverprintmode\n");
00402        }
00403        QStringList patterns = m_Doc->getUsedPatterns();
00404        for (uint c = 0; c < patterns.count(); ++c)
00405        {
00406               ScPattern pa = m_Doc->docPatterns[patterns[c]];
00407               for (uint em = 0; em < pa.items.count(); ++em)
00408               {
00409                      PageItem* item = pa.items.at(em);
00410                      if ((item->asImageFrame()) && (item->PicAvail) && (!item->Pfile.isEmpty()) && (item->printEnabled()) && (!sep) && (farb))
00411                             PS_ImageData(item, item->Pfile, item->itemName(), item->IProfile, item->UseEmbedded, ic);
00412               }
00413               PutDoc("/Pattern"+patterns[c]+" 8 dict def\n");
00414               PutDoc("Pattern"+patterns[c]+" begin\n");
00415               PutDoc("/PatternType 1 def\n");
00416               PutDoc("/PaintType 1 def\n");
00417               PutDoc("/TilingType 1 def\n");
00418               PutDoc("/BBox [ 0 0 "+ToStr(pa.width)+" "+ToStr(pa.height)+"] def\n");
00419               PutDoc("/XStep "+ToStr(pa.width)+" def\n");
00420               PutDoc("/YStep "+ToStr(pa.height)+" def\n");
00421               PutDoc("/PaintProc {\n");
00422               QIODevice *spStream = spoolStream.device();
00423               QByteArray buf;
00424               QBuffer b(buf);
00425               b.open( IO_WriteOnly );
00426               spoolStream.setDevice(&b);
00427               QPtrStack<PageItem> groupStack;
00428               for (uint em = 0; em < pa.items.count(); ++em)
00429               {
00430                      PageItem* item = pa.items.at(em);
00431                      if (item->isGroupControl)
00432                      {
00433                             PS_save();
00434                             FPointArray cl = item->PoLine.copy();
00435                             QWMatrix mm;
00436                             mm.translate(item->gXpos, item->gYpos - pa.height);
00437                             mm.rotate(item->rotation());
00438                             cl.map( mm );
00439                             SetClipPath(&cl);
00440                             PS_closepath();
00441                             PS_clip(true);
00442                             groupStack.push(item->groupsLastItem);
00443                             continue;
00444                      }
00445                      PS_save();
00446                      PS_translate(item->gXpos, pa.height - item->gYpos);
00447                      ProcessItem(m_Doc, m_Doc->Pages->at(0), item, 0, sep, farb, ic, gcr, false, true, true);
00448                      PS_restore();
00449                      if (groupStack.count() != 0)
00450                      {
00451                             while (item == groupStack.top())
00452                             {
00453                                    PS_restore();
00454                                    groupStack.pop();
00455                             }
00456                      }
00457               }
00458               spoolStream.setDevice(spStream);
00459               PutDoc(buf);
00460               PutDoc("} def\n");
00461               PutDoc("end\n");
00462        }
00463        PutDoc("%%EndSetup\n");
00464        Prolog = "";
00465        FontDesc = "";
00466 }
00467 
00468 QString PSLib::PSEncode(QString in)
00469 {
00470        static QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
00471        QString tmp = "";
00472        tmp = in.simplifyWhiteSpace().replace( badchars, "_" );
00473        return tmp;
00474 }
00475 
00476 void PSLib::PS_TemplateStart(QString Name)
00477 {
00478        PutDoc("/"+PSEncode(Name)+"\n{\n");
00479 }
00480 
00481 void PSLib::PS_UseTemplate(QString Name)
00482 {
00483        PutDoc(PSEncode(Name)+"\n");
00484 }
00485 
00486 void PSLib::PS_TemplateEnd()
00487 {
00488        PutDoc("} bind def\n");
00489 }
00490 
00491 void PSLib::PS_begin_page(Page* pg, MarginStruct* Ma, bool Clipping)
00492 {
00493        double bleedRight = 0.0;
00494        double bleedLeft = 0.0;
00495        double markOffs = 0.0;
00496        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
00497               markOffs = 20.0 + Options.markOffset;
00498        if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1)
00499        {
00500               bleedRight = Options.bleeds.Right;
00501               bleedLeft = Options.bleeds.Left;
00502        }
00503        else
00504        {
00505               if (m_Doc->locationOfPage(pg->pageNr()) == LeftPage)
00506               {
00507                      bleedRight = Options.bleeds.Right;
00508                      bleedLeft = Options.bleeds.Left;
00509               }
00510               else if (m_Doc->locationOfPage(pg->pageNr()) == RightPage)
00511               {
00512                      bleedRight = Options.bleeds.Left;
00513                      bleedLeft = Options.bleeds.Right;
00514               }
00515               else
00516               {
00517                      bleedRight = Options.bleeds.Left;
00518                      bleedLeft = Options.bleeds.Left;
00519               }
00520        }
00521        double maxBoxX = pg->width()+bleedLeft+bleedRight+markOffs*2.0;
00522        double maxBoxY = pg->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
00523        Seiten++;
00524        PutSeite("%%Page: " + IToStr(Seiten) + " " + IToStr(Seiten) + "\n");
00525        PutSeite("%%PageOrientation: ");
00526 // when creating EPS files determine the orientation from the bounding box
00527        if (!Art)
00528        {
00529               if ((pg->width() - Ma->Left - Ma->Right) <= (pg->height() - Ma->Bottom - Ma->Top))
00530                      PutSeite("Portrait\n");
00531               else
00532                      PutSeite("Landscape\n");
00533        }
00534        else
00535        {
00536               if (pg->PageOri == 0)
00537                      PutSeite("Portrait\n");
00538               else
00539                      PutSeite("Landscape\n");
00540        }
00541        PutSeite("%%PageBoundingBox: 0 0 "+IToStr(qRound(maxBoxX))+" "+IToStr(qRound(maxBoxY))+"\n");
00542        PutSeite("%%PageCropBox: "+ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" "+ToStr(maxBoxX-bleedRight-markOffs*2.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs*2.0)+"\n");
00543        PutSeite("save\n");
00544        if (Clipping)
00545               PutSeite(PDev);
00546        PutSeite("/DeviceCMYK setcolorspace\n");
00547        if ((Art) && (Options.setDevParam))
00548        {
00549               PutSeite("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" ]\n");
00550               PutSeite(">> setpagedevice\n");
00551        }
00552        PutSeite(ToStr(bleedLeft+markOffs)+" "+ToStr(Options.bleeds.Bottom+markOffs)+" tr\n");
00553        ActPage = pg;
00554        if (Clipping)
00555        {
00556               PDev = ToStr(Ma->Left) + " " + ToStr(Ma->Bottom) + " m\n";
00557               PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(Ma->Bottom) + " li\n";
00558               PDev += ToStr(pg->width() - Ma->Right) + " " + ToStr(pg->height() - Ma->Top) + " li\n";
00559               PDev += ToStr(Ma->Left) + " " + ToStr(pg->height() - Ma->Top) + " li cl clip newpath\n";
00560        }
00561 }
00562 
00563 void PSLib::PS_end_page()
00564 {
00565        PutSeite("%%PageTrailer\nrestore\n");
00566        double markOffs = 0.0;
00567        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
00568               markOffs = 20.0 + Options.markOffset;
00569        double bleedRight;
00570        double bleedLeft;
00571        if (m_Doc->pageSets[m_Doc->currentPageLayout].Columns == 1)
00572        {
00573               bleedRight = Options.bleeds.Right;
00574               bleedLeft = Options.bleeds.Left;
00575        }
00576        else
00577        {
00578               if (m_Doc->locationOfPage(ActPage->pageNr()) == LeftPage)
00579               {
00580                      bleedRight = Options.bleeds.Right;
00581                      bleedLeft = Options.bleeds.Left;
00582               }
00583               else if (m_Doc->locationOfPage(ActPage->pageNr()) == RightPage)
00584               {
00585                      bleedRight = Options.bleeds.Left;
00586                      bleedLeft = Options.bleeds.Right;
00587               }
00588               else
00589               {
00590                      bleedRight = Options.bleeds.Left;
00591                      bleedLeft = Options.bleeds.Left;
00592               }
00593        }
00594        double maxBoxX = ActPage->width()+bleedLeft+bleedRight+markOffs*2.0;
00595        double maxBoxY = ActPage->height()+Options.bleeds.Bottom+Options.bleeds.Top+markOffs*2.0;
00596        if ((Options.cropMarks) || (Options.bleedMarks) || (Options.registrationMarks) || (Options.colorMarks))
00597        {
00598               PutSeite("gs\n");
00599               PS_setlinewidth(0.5);
00600               PutSeite("[] 0 setdash\n");
00601               PutSeite("0 setlinecap\n");
00602               PutSeite("0 setlinejoin\n");
00603               PutSeite("1 rb\n");
00604               if (Options.cropMarks)
00605               {
00606               // Bottom Left
00607                      PutSeite("0 "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
00608                      PutSeite(ToStr(20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
00609                      PutSeite("st\n");
00610                      PutSeite(ToStr(markOffs+bleedLeft)+" 0 m\n");
00611                      PutSeite(ToStr(markOffs+bleedLeft)+" 20 li\n");
00612                      PutSeite("st\n");
00613               // Top Left
00614                      PutSeite("0 "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
00615                      PutSeite(ToStr(20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n");
00616                      PutSeite("st\n");
00617                      PutSeite(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY)+" m\n");
00618                      PutSeite(ToStr(markOffs+bleedLeft)+" "+ToStr(maxBoxY-20.0)+" li\n");
00619                      PutSeite("st\n");
00620               // Bottom Right
00621                      PutSeite(ToStr(maxBoxX)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" m\n");
00622                      PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs+Options.bleeds.Bottom)+" li\n");
00623                      PutSeite("st\n");
00624                      PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(0.0)+" m\n");
00625                      PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(20.0)+" li\n");
00626                      PutSeite("st\n");
00627               // Top Right
00628                      PutSeite(ToStr(maxBoxX)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" m\n");
00629                      PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-Options.bleeds.Top-markOffs)+" li\n");
00630                      PutSeite("st\n");
00631                      PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY)+" m\n");
00632                      PutSeite(ToStr(maxBoxX-bleedRight-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
00633                      PutSeite("st\n");
00634               }
00635               if (Options.bleedMarks)
00636               {
00637                      PutSeite("gs\n");
00638                      PutSeite("[3 1 1 1] 0 setdash\n");
00639               // Bottom Left
00640                      PutSeite("0 "+ToStr(markOffs)+" m\n");
00641                      PutSeite(ToStr(20.0)+" "+ToStr(markOffs)+" li\n");
00642                      PutSeite("st\n");
00643                      PutSeite(ToStr(markOffs)+" 0 m\n");
00644                      PutSeite(ToStr(markOffs)+" 20 l\n");
00645                      PutSeite("st\n");
00646               // Top Left
00647                      PutSeite("0 "+ToStr(maxBoxY-markOffs)+" m\n");
00648                      PutSeite(ToStr(20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
00649                      PutSeite("st\n");
00650                      PutSeite(ToStr(markOffs)+" "+ToStr(maxBoxY)+" m\n");
00651                      PutSeite(ToStr(markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
00652                      PutSeite("st\n");
00653               // Bottom Right
00654                      PutSeite(ToStr(maxBoxX)+" "+ToStr(markOffs)+" m\n");
00655                      PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(markOffs)+" li\n");
00656                      PutSeite("st\n");
00657                      PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(0.0)+" m\n");
00658                      PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(20.0)+" li\n");
00659                      PutSeite("st\n");
00660               // Top Right
00661                      PutSeite(ToStr(maxBoxX)+" "+ToStr(maxBoxY-markOffs)+" m\n");
00662                      PutSeite(ToStr(maxBoxX-20.0)+" "+ToStr(maxBoxY-markOffs)+" li\n");
00663                      PutSeite("st\n");
00664                      PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY)+" m\n");
00665                      PutSeite(ToStr(maxBoxX-markOffs)+" "+ToStr(maxBoxY-20.0)+" li\n");
00666                      PutSeite("st\n");
00667                      PutSeite("gr\n");
00668               }
00669               if (Options.registrationMarks)
00670               {
00671                      QString regCross = "0 7 m\n14 7 li\n7 0 m\n7 14 li\n13 7 m\n13 10.31383 10.31383 13 7 13 cu\n3.68629 13 1 10.31383 1 7 cu\n1 3.68629 3.68629 1 7 1 cu\n";
00672                      regCross += "10.31383 1 13 3.68629 13 7 cu\ncl\n10.5 7 m\n10.5 8.93307 8.93307 10.5 7 10.5 cu\n5.067 10.5 3.5 8.93307 3.5 7 cu\n";
00673                      regCross += "3.5 5.067 5.067 3.5 7 3.5 cu\n8.93307 3.5 10.5 5.067 10.5 7 cu\ncl\nst\n";
00674                      PutSeite("gs\n");
00675                      PutSeite(ToStr(maxBoxX / 2.0 - 7.0)+" 3 tr\n");
00676                      PutSeite(regCross);
00677                      PutSeite("gr\n");
00678                      PutSeite("gs\n");
00679                      PutSeite("3 "+ToStr(maxBoxY / 2.0 + 7.0)+" tr\n");
00680                      PutSeite(regCross);
00681                      PutSeite("gr\n");
00682                      PutSeite("gs\n");
00683                      PutSeite(ToStr(maxBoxX / 2.0 - 7.0)+" "+ToStr(maxBoxY - 17.0)+" tr\n");
00684                      PutSeite(regCross);
00685                      PutSeite("gr\n");
00686                      PutSeite("gs\n");
00687                      PutSeite(ToStr(maxBoxX - 17.0)+" "+ToStr(maxBoxY / 2.0 + 7.0)+" tr\n");
00688                      PutSeite(regCross);
00689                      PutSeite("gr\n");
00690               }
00691               if (Options.colorMarks)
00692               {
00693                      double startX = markOffs+bleedLeft+6.0;
00694                      double startY = maxBoxY - 18.0;
00695                      PutSeite("0 0 0 1 cmyk\n");
00696                      double col = 1.0;
00697                      for (int bl = 0; bl < 11; bl++)
00698                      {
00699                             PutSeite("0 0 0 "+ToStr(col)+" cmyk\n");
00700                             PutSeite(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectfill\n");
00701                             PutSeite("0 0 0 1 cmyk\n");
00702                             PutSeite(ToStr(startX+bl*14.0)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00703                             col -= 0.1;
00704                      }
00705                      startX = maxBoxX-bleedRight-markOffs-20.0;
00706                      PutSeite("0 0 0 0.5 cmyk\n");
00707                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00708                      PutSeite("0 0 0 1 cmyk\n");
00709                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00710                      startX -= 14.0;
00711                      PutSeite("0 0 0.5 0 cmyk\n");
00712                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00713                      PutSeite("0 0 0 1 cmyk\n");
00714                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00715                      startX -= 14.0;
00716                      PutSeite("0 0.5 0 0 cmyk\n");
00717                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00718                      PutSeite("0 0 0 1 cmyk\n");
00719                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00720                      startX -= 14.0;
00721                      PutSeite("0.5 0 0 0 cmyk\n");
00722                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00723                      PutSeite("0 0 0 1 cmyk\n");
00724                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00725                      startX -= 14.0;
00726                      PutSeite("1 1 0 0 cmyk\n");
00727                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00728                      PutSeite("0 0 0 1 cmyk\n");
00729                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00730                      startX -= 14.0;
00731                      PutSeite("1 0 1 0 cmyk\n");
00732                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00733                      PutSeite("0 0 0 1 cmyk\n");
00734                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00735                      startX -= 14.0;
00736                      PutSeite("0 1 1 0 cmyk\n");
00737                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00738                      PutSeite("0 0 0 1 cmyk\n");
00739                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00740                      startX -= 14.0;
00741                      PutSeite("0 0 0 1 cmyk\n");
00742                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00743                      PutSeite("0 0 0 1 cmyk\n");
00744                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00745                      startX -= 14.0;
00746                      PutSeite("0 0 1 0 cmyk\n");
00747                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00748                      PutSeite("0 0 0 1 cmyk\n");
00749                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00750                      startX -= 14.0;
00751                      PutSeite("0 1 0 0 cmyk\n");
00752                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00753                      PutSeite("0 0 0 1 cmyk\n");
00754                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00755                      startX -= 14.0;
00756                      PutSeite("1 0 0 0 cmyk\n");
00757                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectfill\n");
00758                      PutSeite("0 0 0 1 cmyk\n");
00759                      PutSeite(ToStr(startX)+" "+ToStr(startY)+" 14 14 rectstroke\n");
00760               }
00761               PutSeite("gr\n");
00762        }
00763        PutSeite("sp\n");
00764 }
00765 
00766 void PSLib::PS_curve(double x1, double y1, double x2, double y2, double x3, double y3)
00767 {
00768        PutSeite(ToStr(x1) + " " + ToStr(y1) + " " + ToStr(x2) + " " + ToStr(y2) + " " + ToStr(x3) + " " + ToStr(y3) + " curveto\n");
00769 }
00770 
00771 void PSLib::PS_moveto(double x, double y)
00772 {
00773        PutSeite(ToStr(x) + " " + ToStr(y) + " m\n");
00774 }
00775 
00776 void PSLib::PS_lineto(double x, double y)
00777 {
00778        PutSeite(ToStr(x) + " " + ToStr(y) + " li\n");
00779 }
00780 
00781 void PSLib::PS_closepath()
00782 {
00783        PutSeite("cl\n");
00784 }
00785 
00786 void PSLib::PS_translate(double x, double y)
00787 {
00788        PutSeite(ToStr(x) + " " + ToStr(y) + " tr\n");
00789 }
00790 
00791 void PSLib::PS_scale(double x, double y)
00792 {
00793        PutSeite(ToStr(x) + " " + ToStr(y) + " sc\n");
00794 }
00795 
00796 void PSLib::PS_rotate(double x)
00797 {
00798        PutSeite(ToStr(x) + " ro\n");
00799 }
00800 
00801 void PSLib::PS_clip(bool mu)
00802 {
00803        PutSeite( mu ? "eoclip newpath\n" : "clip newpath\n" );
00804 }
00805 
00806 void PSLib::PS_save()
00807 {
00808        PutSeite("gs\n");
00809 }
00810 
00811 void PSLib::PS_restore()
00812 {
00813        PutSeite("gr\n");
00814 }
00815 
00816 void PSLib::PS_setcmykcolor_fill(double c, double m, double y, double k)
00817 {
00818        FillColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
00819 }
00820 
00821 void PSLib::PS_setcmykcolor_dummy()
00822 {
00823        PutSeite("0 0 0 0 cmyk\n");
00824 }
00825 
00826 void PSLib::PS_setcmykcolor_stroke(double c, double m, double y, double k)
00827 {
00828        StrokeColor = ToStr(c) + " " + ToStr(m) + " " + ToStr(y) + " " + ToStr(k);
00829 }
00830 
00831 void PSLib::PS_setlinewidth(double w)
00832 {
00833        PutSeite(ToStr(w) + " sw\n");
00834        LineW = w;
00835 }
00836 
00837 void PSLib::PS_setdash(Qt::PenStyle st, double offset, QValueList<double> dash)
00838 {
00839        QString Dt = ToStr(QMAX(2*LineW, 1));
00840        QString Da = ToStr(QMAX(6*LineW, 1));
00841        if (dash.count() != 0)
00842        {
00843               PutSeite("[ ");
00844               QValueList<double>::iterator it;
00845               for ( it = dash.begin(); it != dash.end(); ++it )
00846               {
00847                      PutSeite(IToStr(static_cast<int>(*it))+" ");
00848               }
00849               PutSeite("] "+IToStr(static_cast<int>(offset))+" setdash\n");
00850        }
00851        else
00852        {
00853               switch (st)
00854               {
00855                      case Qt::SolidLine:
00856                             PutSeite("[] 0 setdash\n");
00857                             break;
00858                      case Qt::DashLine:
00859                             PutSeite("["+Da+" "+Dt+"] 0 setdash\n");
00860                             break;
00861                      case Qt::DotLine:
00862                             PutSeite("["+Dt+"] 0 setdash\n");
00863                             break;
00864                      case Qt::DashDotLine:
00865                             PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n");
00866                             break;
00867                      case Qt::DashDotDotLine:
00868                             PutSeite("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 setdash\n");
00869                             break;
00870                      default:
00871                             PutSeite("[] 0 setdash\n");
00872                             break;
00873               }
00874        }
00875 }
00876 
00877 void PSLib::PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle jo)
00878 {
00879        switch (ca)
00880               {
00881               case Qt::FlatCap:
00882                      PutSeite("0 setlinecap\n");
00883                      break;
00884               case Qt::SquareCap:
00885                      PutSeite("2 setlinecap\n");
00886                      break;
00887               case Qt::RoundCap:
00888                      PutSeite("1 setlinecap\n");
00889                      break;
00890               default:
00891                      PutSeite("0 setlinecap\n");
00892                      break;
00893               }
00894        switch (jo)
00895               {
00896               case Qt::MiterJoin:
00897                      PutSeite("0 setlinejoin\n");
00898                      break;
00899               case Qt::BevelJoin:
00900                      PutSeite("2 setlinejoin\n");
00901                      break;
00902               case Qt::RoundJoin:
00903                      PutSeite("1 setlinejoin\n");
00904                      break;
00905               default:
00906                      PutSeite("0 setlinejoin\n");
00907                      break;
00908               }
00909 }
00910 
00911 void PSLib::PS_selectfont(QString f, double s)
00912 {
00913        PutSeite(UsedFonts[f] + " " + ToStr(s) + " se\n");
00914 }
00915 
00916 void PSLib::PS_fill()
00917 {
00918        if (fillRule)
00919               PutSeite(FillColor + " cmyk eofill\n");
00920        else
00921               PutSeite(FillColor + " cmyk fill\n");
00922 }
00923 
00924 void PSLib::PS_fillspot(QString color, int shade)
00925 {
00926        if (fillRule)
00927               PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" eofill\n");
00928        else
00929               PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" fill\n");
00930 }
00931 
00932 void PSLib::PS_strokespot(QString color, int shade)
00933 {
00934        PutSeite(ToStr(shade / 100.0)+" "+spotMap[color]+" st\n");
00935 }
00936 
00937 void PSLib::PS_stroke()
00938 {
00939        PutSeite(StrokeColor + " cmyk st\n");
00940 }
00941 
00942 void PSLib::PS_fill_stroke()
00943 {
00944        PS_save();
00945        PS_fill();
00946        PS_restore();
00947        PS_stroke();
00948 }
00949 
00950 void PSLib::PS_newpath()
00951 {
00952        PutSeite("newpath\n");
00953 }
00954 
00955 void PSLib::PS_MultiRadGradient(double w, double h, double x, double y, QValueList<double> Stops, QStringList Colors, QStringList colorNames, QValueList<int> colorShades)
00956 {
00957        bool first = true;
00958        bool oneSpot1 = false;
00959        bool oneSpot2 = false;
00960        bool twoSpot = false;
00961        CMYKColor cmykValues;
00962        int cc, mc, yc, kc;
00963        PutSeite( "clipsave\n" );
00964        PutSeite("eoclip\n");
00965        for (uint c = 0; c < Colors.count()-1; ++c)
00966        {
00967               oneSpot1 = false;
00968               oneSpot2 = false;
00969               twoSpot = false;
00970               QString spot1 = colorNames[c];
00971               QString spot2 = colorNames[c+1];
00972               PutSeite("<<\n");
00973               PutSeite("/ShadingType 3\n");
00974               if (DoSep)
00975                      PutSeite("/ColorSpace /DeviceGray\n");
00976               else
00977               {
00978                      if (spotMap.contains(colorNames[c]))
00979                             oneSpot1 = true;
00980                      else if  (spotMap.contains(colorNames[c+1]))
00981                             oneSpot2 = true;
00982                      if ((spotMap.contains(colorNames[c])) && (spotMap.contains(colorNames[c+1])))
00983                      {
00984                             oneSpot1 = false;
00985                             oneSpot2 = false;
00986                             twoSpot = true;
00987                      }
00988                      if ((!oneSpot1) && (!oneSpot2) && (!twoSpot) || (!useSpotColors) || (GraySc))
00989                      {
00990                             if (GraySc)
00991                                    PutSeite("/ColorSpace /DeviceGray\n");
00992                             else
00993                                    PutSeite("/ColorSpace /DeviceCMYK\n");
00994                      }
00995                      else
00996                      {
00997                             PutSeite("/ColorSpace [ /DeviceN [");
00998                             if (oneSpot1)
00999                             {
01000                                    PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n");
01001                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
01002                                    cmykValues.getValues(cc, mc, yc, kc);
01003                             }
01004                             else if (oneSpot2)
01005                             {
01006                                    PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n");
01007                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
01008                                    cmykValues.getValues(cc, mc, yc, kc);
01009                             }
01010                             else if (twoSpot)
01011                             {
01012                                    PutSeite(" ("+spot1+") ("+spot2+") ]\n");
01013                             }
01014                             PutSeite("/DeviceCMYK\n");
01015                             PutSeite("{\n");
01016                             if (twoSpot)
01017                             {
01018                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
01019                                    cmykValues.getValues(cc, mc, yc, kc);
01020                                    PutSeite("exch\n");
01021                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n");
01022                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n");
01023                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n");
01024                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop 5 -1 roll\n");
01025                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
01026                                    cmykValues.getValues(cc, mc, yc, kc);
01027                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n");
01028                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n");
01029                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n");
01030                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n");
01031                             }
01032                             else
01033                             {
01034                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n");
01035                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n");
01036                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n");
01037                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n");
01038                             }
01039                             PutSeite("} ]\n");
01040                      }
01041               }
01042               PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
01043               if (Colors.count() == 2)
01044                      PutDoc("/Extend [true true]\n");
01045               else
01046               {
01047                      if (first)
01048                             PutSeite("/Extend [false true]\n");
01049                      else
01050                      {
01051                             if (c == Colors.count()-2)
01052                                    PutSeite("/Extend [true false]\n");
01053                             else
01054                                    PutSeite("/Extend [false false]\n");
01055                      }
01056               }
01057               PutSeite("/Coords ["+ToStr(x)+" "+ToStr(y)+" "+ToStr((*Stops.at(c+1)))+" "+ToStr(x)+" "+ToStr(y)+" "+ToStr((*Stops.at(c)))+"]\n");
01058               PutSeite("/Function\n");
01059               PutSeite("<<\n");
01060               PutSeite("/FunctionType 2\n");
01061               PutSeite("/Domain [0 1]\n");
01062               if (DoSep)
01063               {
01064                      int pla = Plate - 1 < 0 ? 3 : Plate - 1;
01065                      QStringList cols1 = QStringList::split(" ", Colors[c+1]);
01066                      QStringList cols2 = QStringList::split(" ", Colors[c]);
01067                      PutSeite("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n");
01068                      PutSeite("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n");
01069               }
01070               else
01071               {
01072                      if (useSpotColors)
01073                      {
01074                             if (oneSpot1)
01075                             {
01076                                    PutSeite("/C1 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
01077                                    PutSeite("/C0 ["+Colors[c+1]+" 0 ]\n");
01078                             }
01079                             else if (oneSpot2)
01080                             {
01081                                    PutSeite("/C1 ["+Colors[c]+" 0 ]\n");
01082                                    PutSeite("/C0 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
01083                             }
01084                             else if (twoSpot)
01085                             {
01086                                    PutSeite("/C1 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
01087                                    PutSeite("/C0 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
01088                             }
01089                             else
01090                             {
01091                                    PutSeite("/C1 ["+Colors[c]+"]\n");
01092                                    PutSeite("/C0 ["+Colors[c+1]+"]\n");
01093                             }
01094                      }
01095                      else
01096                      {
01097                             PutSeite("/C1 ["+Colors[c]+"]\n");
01098                             PutSeite("/C0 ["+Colors[c+1]+"]\n");
01099                      }
01100               }
01101               PutSeite("/N 1\n");
01102               PutSeite(">>\n");
01103               PutSeite(">>\n");
01104               PutSeite("shfill\n");
01105               first = false;
01106        }
01107        PutSeite("cliprestore\n");
01108 }
01109 
01110 void PSLib::PS_MultiLinGradient(double w, double h, QValueList<double> Stops, QStringList Colors, QStringList colorNames, QValueList<int> colorShades)
01111 {
01112        bool first = true;
01113        bool oneSpot1 = false;
01114        bool oneSpot2 = false;
01115        bool twoSpot = false;
01116        int cc, mc, yc, kc;
01117        CMYKColor cmykValues;
01118        PutSeite( "clipsave\n" );
01119        PutSeite("eoclip\n");
01120        for (uint c = 0; c < Colors.count()-1; ++c)
01121        {
01122               oneSpot1 = false;
01123               oneSpot2 = false;
01124               twoSpot = false;
01125               QRegExp badchars("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]");
01126               QString spot1 = colorNames[c];
01127               QString spot2 = colorNames[c+1];
01128               PutSeite("<<\n");
01129               PutSeite("/ShadingType 2\n");
01130               if (DoSep)
01131                      PutSeite("/ColorSpace /DeviceGray\n");
01132               else
01133               {
01134                      if (spotMap.contains(colorNames[c]))
01135                             oneSpot1 = true;
01136                      else if  (spotMap.contains(colorNames[c+1]))
01137                             oneSpot2 = true;
01138                      if ((spotMap.contains(colorNames[c])) && (spotMap.contains(colorNames[c+1])))
01139                      {
01140                             oneSpot1 = false;
01141                             oneSpot2 = false;
01142                             twoSpot = true;
01143                      }
01144                      if ((!oneSpot1) && (!oneSpot2) && (!twoSpot) || (!useSpotColors) || (GraySc))
01145                      {
01146                             if (GraySc)
01147                                    PutSeite("/ColorSpace /DeviceGray\n");
01148                             else
01149                                    PutSeite("/ColorSpace /DeviceCMYK\n");
01150                      }
01151                      else
01152                      {
01153                             PutSeite("/ColorSpace [ /DeviceN [");
01154                             if (oneSpot1)
01155                             {
01156                                    PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot1+") ]\n");
01157                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
01158                                    cmykValues.getValues(cc, mc, yc, kc);
01159                             }
01160                             else if (oneSpot2)
01161                             {
01162                                    PutSeite(" /Cyan /Magenta /Yellow /Black ("+spot2+") ]\n");
01163                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
01164                                    cmykValues.getValues(cc, mc, yc, kc);
01165                             }
01166                             else if (twoSpot)
01167                             {
01168                                    PutSeite(" ("+spot1+") ("+spot2+") ]\n");
01169                             }
01170                             PutSeite("/DeviceCMYK\n");
01171                             PutSeite("{\n");
01172                             if (twoSpot)
01173                             {
01174                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c]], m_Doc, cmykValues);
01175                                    cmykValues.getValues(cc, mc, yc, kc);
01176                                    PutSeite("exch\n");
01177                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul exch\n");
01178                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul exch\n");
01179                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul exch\n");
01180                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul exch pop 5 -1 roll\n");
01181                                    ScColorEngine::getCMYKValues(m_Doc->PageColors[colorNames[c+1]], m_Doc, cmykValues);
01182                                    cmykValues.getValues(cc, mc, yc, kc);
01183                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n");
01184                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n");
01185                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n");
01186                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n");
01187                             }
01188                             else
01189                             {
01190                                    PutSeite("dup "+ToStr(static_cast<double>(cc) / 255.0)+" mul 6 -1 roll add dup 1.0 gt {pop 1.0} if 5 1 roll\n");
01191                                    PutSeite("dup "+ToStr(static_cast<double>(mc) / 255.0)+" mul 5 -1 roll add dup 1.0 gt {pop 1.0} if 4 1 roll\n");
01192                                    PutSeite("dup "+ToStr(static_cast<double>(yc) / 255.0)+" mul 4 -1 roll add dup 1.0 gt {pop 1.0} if 3 1 roll\n");
01193                                    PutSeite("dup "+ToStr(static_cast<double>(kc) / 255.0)+" mul 3 -1 roll add dup 1.0 gt {pop 1.0} if 2 1 roll pop\n");
01194                             }
01195                             PutSeite("} ]\n");
01196                      }
01197               }
01198               PutSeite("/BBox [0 "+ToStr(h)+" "+ToStr(w)+" 0]\n");
01199               if (Colors.count() == 2)
01200                      PutDoc("/Extend [true true]\n");
01201               else
01202               {
01203                      if (first)
01204                             PutSeite("/Extend [true false]\n");
01205                      else
01206                      {
01207                             if (c == Colors.count()-2)
01208                                    PutSeite("/Extend [false true]\n");
01209                             else
01210                                    PutSeite("/Extend [false false]\n");
01211                      }
01212               }
01213               first = false;
01214               PutSeite("/Coords ["+ToStr((*Stops.at(c*2)))+"  "+ToStr((*Stops.at(c*2+1)))+" "+ToStr((*Stops.at(c*2+2)))+" "+ToStr((*Stops.at(c*2+3)))+"]\n");
01215               PutSeite("/Function\n");
01216               PutSeite("<<\n");
01217               PutSeite("/FunctionType 2\n");
01218               PutSeite("/Domain [0 1]\n");
01219               if (DoSep)
01220               {
01221                      int pla = Plate - 1 < 0 ? 3 : Plate - 1;
01222                      QStringList cols1 = QStringList::split(" ", Colors[c]);
01223                      QStringList cols2 = QStringList::split(" ", Colors[c+1]);
01224                      PutSeite("/C1 ["+ToStr(1-cols1[pla].toDouble())+"]\n");
01225                      PutSeite("/C0 ["+ToStr(1-cols2[pla].toDouble())+"]\n");
01226               }
01227               else
01228               {
01229                      if (useSpotColors)
01230                      {
01231                             if (oneSpot1)
01232                             {
01233                                    PutSeite("/C0 [0 0 0 0 "+ToStr(colorShades[c] / 100.0)+"]\n");
01234                                    PutSeite("/C1 ["+Colors[c+1]+" 0 ]\n");
01235                             }
01236                             else if (oneSpot2)
01237                             {
01238                                    PutSeite("/C0 ["+Colors[c]+" 0 ]\n");
01239                                    PutSeite("/C1 [0 0 0 0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
01240                             }
01241                             else if (twoSpot)
01242                             {
01243                                    PutSeite("/C0 ["+ToStr(colorShades[c] / 100.0)+" 0]\n");
01244                                    PutSeite("/C1 [0 "+ToStr(colorShades[c+1] / 100.0)+"]\n");
01245                             }
01246                             else
01247                             {
01248                                    PutSeite("/C0 ["+Colors[c]+"]\n");
01249                                    PutSeite("/C1 ["+Colors[c+1]+"]\n");
01250                             }
01251                      }
01252                      else
01253                      {
01254                             PutSeite("/C0 ["+Colors[c]+"]\n");
01255                             PutSeite("/C1 ["+Colors[c+1]+"]\n");
01256                      }
01257               }
01258               PutSeite("/N 1\n");
01259               PutSeite(">>\n");
01260               PutSeite(">>\n");
01261               PutSeite("shfill\n");
01262        }
01263        PutSeite("cliprestore\n");
01264 }
01265 
01266 void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, bool spot)
01267 {
01268        QString Name;
01269        Name = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef");
01270        if (spot)
01271               PutSeite("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n");
01272        else
01273               PutSeite("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" "+StrokeColor+" shg\n");
01274 }
01275 
01276 void PSLib::PS_show(double x, double y)
01277 {
01278        PS_moveto(x, y);
01279        PutSeite("/hyphen glyphshow\n");
01280 }
01281 
01282 void PSLib::PS_showSub(uint chr, QString font, double size, bool stroke)
01283 {
01284        PutSeite(" (G"+IToStr(chr)+") "+font+" "+ToStr(size / 10.0)+" ");
01285        PutSeite(stroke ? "shgs\n" : "shgf\n");
01286 }
01287 
01288 void PSLib::PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf)
01289 {
01290        bool dummy;
01291        QCString tmp;
01292        QFileInfo fi = QFileInfo(fn);
01293        QString ext = fi.extension(false).lower();
01294        if (ext.isEmpty())
01295               ext = getImageType(fn);
01296        if (((ext == "eps") || (ext == "epsi")) && (c->pixm.imgInfo.type != 7))
01297        {
01298               if (loadRawText(fn, tmp))
01299               {
01300                      PutSeite("currentfile 1 (%ENDEPSDATA) /SubFileDecode filter /ReusableStreamDecode filter\n");
01301                      PutSeite("%%BeginDocument: " + fi.fileName() + "\n");
01302                      if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6)
01303                      {
01304                             char* data = tmp.data();
01305                             uint startPos = getDouble(QString(tmp.mid(4, 4)), false);
01306                             uint length = getDouble(QString(tmp.mid(8, 4)), false);
01307                             PutSeite(data+startPos, length, false);
01308                      }
01309                      else
01310                             PutSeite(tmp, false);
01311                      PutSeite("\n%ENDEPSDATA\n");
01312                      PutSeite("%%EndDocument\n");
01313                      PutSeite("/"+PSEncode(Name)+"Bild exch def\n");
01314               }
01315               return;
01316        }
01317        ScImage image;
01318        QByteArray imgArray;
01319        image.imgInfo.valid = false;
01320        image.imgInfo.clipPath = "";
01321        image.imgInfo.PDSpathData.clear();
01322        image.imgInfo.layerInfo.clear();
01323        image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
01324        image.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
01325        CMSettings cms(c->doc(), Prof, c->IRender);
01326        image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 300, &dummy);
01327        image.applyEffect(c->effectsInUse, colorsToUse, true);
01328        imgArray = image.ImageToCMYK_PS(-1, true);
01329        if (CompAvail)
01330        {
01331               PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n");
01332               imgArray = CompressArray(&imgArray);
01333        }
01334        else
01335               PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
01336        PutSeite(imgArray, true);
01337        PutSeite("\n>\n");
01338        PutSeite("/"+PSEncode(Name)+"Bild exch def\n");
01339        imgArray.resize(0);
01340        QByteArray maskArray;
01341        maskArray = image.getAlpha(fn, false, false, 300);
01342        if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != 7))
01343        {
01344               if (CompAvail)
01345               {
01346                      PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n");
01347                      maskArray = CompressArray(&maskArray);
01348               }
01349               else
01350                      PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
01351               PutSeite(maskArray, true);
01352               PutSeite("\n>\n");
01353               PutSeite("/"+PSEncode(Name)+"Mask exch def\n");
01354        }
01355 }
01356 
01357 void PSLib::PS_image(PageItem *c, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, bool UseProf, QString Name)
01358 {
01359        bool dummy;
01360        QCString tmp;
01361        QFileInfo fi = QFileInfo(fn);
01362        QString ext = fi.extension(false).lower();
01363        if (ext.isEmpty())
01364               ext = getImageType(fn);
01365        if (((ext == "eps") || (ext == "epsi")) && (c->pixm.imgInfo.type != 7))
01366        {
01367               if (loadRawText(fn, tmp))
01368               {
01369                      PutSeite("bEPS\n");
01370                      PutSeite(ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scalex) + " " + ToStr(PrefsManager::instance()->appPrefs.gs_Resolution / 72.0 * scaley) + " sc\n");
01371                      PutSeite(ToStr(-c->BBoxX+x * scalex) + " " + ToStr(y * scalex) + " tr\n");
01372                      if (!Name.isEmpty())
01373                      {
01374                             PutSeite(PSEncode(Name)+"Bild cvx exec\n");
01375                             PutSeite(PSEncode(Name)+"Bild resetfile\n");
01376                      }
01377                      else
01378                      {
01379                             PutSeite("%%BeginDocument: " + fi.fileName() + "\n");
01380                                    if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6)
01381                                    {
01382                                           char* data = tmp.data();
01383                                           uint startPos = getDouble(tmp.mid(4, 4), false);
01384                                           uint length = getDouble(tmp.mid(8, 4), false);
01385                                           PutSeite(data+startPos, length, false);
01386                                    }
01387                                    else
01388                                           PutSeite(tmp);
01389                                    PutSeite("\n%%EndDocument\n");
01390                      }
01391                      PutSeite("eEPS\n");
01392               }
01393        }
01394        else
01395        {
01396               ScImage image;
01397               QByteArray imgArray;
01398               image.imgInfo.valid = false;
01399               image.imgInfo.clipPath = "";
01400               image.imgInfo.PDSpathData.clear();
01401               image.imgInfo.layerInfo.clear();
01402               image.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
01403               image.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
01404               CMSettings cms(c->doc(), Prof, c->IRender);
01405               if (c->pixm.imgInfo.type == 7)
01406                      image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 72, &dummy);
01407               else
01408                      image.LoadPicture(fn, cms, UseEmbedded, UseProf, ScImage::CMYKData, 300, &dummy);
01409               image.applyEffect(c->effectsInUse, colorsToUse, true);
01410               int w = image.width();
01411               int h = image.height();
01412               if (ext == "pdf")
01413               {
01414                      scalex *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
01415                      scaley *= PrefsManager::instance()->appPrefs.gs_Resolution / 300.0;
01416               }
01417               PutSeite(ToStr(x*scalex) + " " + ToStr(y*scaley) + " tr\n");
01418               PutSeite(ToStr(qRound(scalex*w)) + " " + ToStr(qRound(scaley*h)) + " sc\n");
01419               PutSeite(((!DoSep) && (!GraySc)) ? "/DeviceCMYK setcolorspace\n" : "/DeviceGray setcolorspace\n");
01420               QByteArray maskArray;
01421               ScImage img2;
01422               img2.imgInfo.clipPath = "";
01423               img2.imgInfo.PDSpathData.clear();
01424               img2.imgInfo.layerInfo.clear();
01425               img2.imgInfo.RequestProps = c->pixm.imgInfo.RequestProps;
01426               img2.imgInfo.isRequest = c->pixm.imgInfo.isRequest;
01427               if (c->pixm.imgInfo.type != 7)
01428                      maskArray = img2.getAlpha(fn, false, false, 300);
01429               if ((maskArray.size() > 0) && (c->pixm.imgInfo.type != 7))
01430               {
01431                      if (DoSep)
01432                             imgArray = image.ImageToCMYK_PS(Plate, true);
01433                      else
01434                             imgArray = GraySc ? image.ImageToCMYK_PS( -2, true) : image.ImageToCMYK_PS(-1, true);
01435                      if (Name.isEmpty())
01436                      {
01437                             if (CompAvail)
01438                             {
01439                                    PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n");
01440                                    imgArray = CompressArray(&imgArray);
01441                             }
01442                             else
01443                                    PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
01444                             PutSeite(imgArray, true);
01445                             imgArray.resize(0);
01446                             PutSeite("\n>\n");
01447                             PutSeite("/Bild exch def\n");
01448                             if (CompAvail)
01449                             {
01450                                    PutSeite("currentfile /ASCIIHexDecode filter /FlateDecode filter /ReusableStreamDecode filter\n");
01451                                    maskArray = CompressArray(&maskArray);
01452                             }
01453                             else
01454                                    PutSeite("currentfile /ASCIIHexDecode filter /ReusableStreamDecode filter\n");
01455                             PutSeite(maskArray, true);
01456                             PutSeite("\n>\n");
01457                             PutSeite("/Mask exch def\n");
01458                      }
01459                      PutSeite("<<\n");
01460                      PutSeite("  /PaintType   1\n");
01461                      PutSeite("  /PatternType 1\n");
01462                      PutSeite("  /TilingType  3\n");
01463                      PutSeite("  /BBox        [ 0 0 1 1 ]\n");
01464                      PutSeite("  /XStep       2\n");
01465                      PutSeite("  /YStep       2\n");
01466                      PutSeite("  /PaintProc   {\n");
01467                      PutSeite("   pop\n");
01468                      PutSeite("   1 1 1 1 setcmykcolor\n");
01469                      PutSeite("   <<\n");
01470                      PutSeite("   /ImageType 1\n");
01471                      PutSeite("   /Height    " + IToStr(h) + "\n");
01472                      PutSeite("   /Width     " + IToStr(w) + "\n");
01473                      PutSeite("   /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h)
01474                             +"]\n");
01475                      if (DoSep)
01476                             PutSeite("   /Decode [1 0]\n");
01477                      else
01478                             PutSeite( GraySc ? "   /Decode [1 0]\n" : "   /Decode [0 1 0 1 0 1 0 1]\n" );
01479                      PutSeite("   /BitsPerComponent 8\n");
01480                      PutSeite("   /DataSource "+PSEncode(Name)+"Bild\n");
01481                      PutSeite("   >>\n");
01482                      PutSeite("   image\n");
01483                      PutSeite("   }\n");
01484                      PutSeite(">> matrix makepattern setpattern\n");
01485                      PutSeite("<< /ImageType 1\n");
01486                      PutSeite("   /Width " + IToStr(w) + "\n");
01487                      PutSeite("   /Height " + IToStr(h) + "\n");
01488                      PutSeite("   /BitsPerComponent 1\n");
01489                      PutSeite("   /Decode [1 0]\n");
01490                      PutSeite("   /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) + "]\n");
01491                      PutSeite("   /DataSource "+PSEncode(Name)+"Mask\n");
01492                      PutSeite(">>\n");
01493                      PutSeite("imagemask\n");
01494                      if (!Name.isEmpty())
01495                      {
01496                             PutSeite(PSEncode(Name)+"Bild resetfile\n");
01497                             PutSeite(PSEncode(Name)+"Mask resetfile\n");
01498                      }
01499               }
01500               else
01501               {
01502                      PutSeite("<< /ImageType 1\n");
01503                      PutSeite("   /Width " + IToStr(w) + "\n");
01504                      PutSeite("   /Height " + IToStr(h) + "\n");
01505                      PutSeite("   /BitsPerComponent 8\n");
01506                      if (DoSep)
01507                             PutSeite("   /Decode [1 0]\n");
01508                      else
01509                             PutSeite( GraySc ? "   /Decode [1 0]\n" : "   /Decode [0 1 0 1 0 1 0 1]\n");
01510                      PutSeite("   /ImageMatrix [" + IToStr(w) + " 0 0 " + IToStr(-h) + " 0 " + IToStr(h) +
01511                                    "]\n");
01512                      if (!Name.isEmpty())
01513                      {
01514                             PutSeite("   /DataSource "+PSEncode(Name)+"Bild >>\n");
01515                             PutSeite("image\n");
01516                             PutSeite(PSEncode(Name)+"Bild resetfile\n");
01517                      }
01518                      else
01519                      {
01520                             PutSeite ( CompAvail ? "   /DataSource currentfile /ASCIIHexDecode filter /FlateDecode filter >>\n" :
01521                                                  "   /DataSource currentfile /ASCIIHexDecode filter >>\n");
01522                             PutSeite("image\n");
01523                             if (DoSep)
01524                                    imgArray = image.ImageToCMYK_PS(Plate, true);
01525                             else
01526                                    imgArray = GraySc ? image.ImageToCMYK_PS(-2, true) : image.ImageToCMYK_PS(-1, true);
01527                             if (CompAvail)
01528                                    imgArray = CompressArray(&imgArray);
01529                             PutSeite(imgArray, true);
01530                             PutSeite("\n>\n");
01531                      }
01532               }
01533        }
01534 }
01535 
01536 
01537 void PSLib::PS_plate(int nr, QString name)
01538 {
01539        switch (nr)
01540        {
01541               case 0:
01542                      PutSeite("%%PlateColor Black\n");
01543                      PutSeite("/setcmykcolor {exch pop exch pop exch pop 1 exch sub oldsetgray} bind def\n");
01544                      PutSeite("/setrgbcolor {pop pop pop 1 oldsetgray} bind def\n");
01545                      break;
01546               case 1:
01547                      PutSeite("%%PlateColor Cyan\n");
01548                      PutSeite("/setcmykcolor {pop pop pop 1 exch sub oldsetgray} bind def\n");
01549                      PutSeite("/setrgbcolor {pop pop oldsetgray} bind def\n");
01550                      break;
01551               case 2:
01552                      PutSeite("%%PlateColor Magenta\n");
01553                      PutSeite("/setcmykcolor {pop pop exch pop 1 exch sub oldsetgray} bind def\n");
01554                      PutSeite("/setrgbcolor {pop exch pop oldsetgray} bind def\n");
01555                      break;
01556               case 3:
01557                      PutSeite("%%PlateColor Yellow\n");
01558                      PutSeite("/setcmykcolor {pop exch pop exch pop 1 exch sub oldsetgray} bind def\n");
01559                      PutSeite("/setrgbcolor {exch pop exch pop oldsetgray} bind def\n");
01560                      break;
01561               default:
01562                      PutSeite("%%PlateColor "+name+"\n");
01563                      PutSeite("/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 0.3 mul add dup 1 gt {pop 1} if 1 exch sub oldsetgray} bind def\n");
01564                      PutSeite("/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add oldsetgray} bind def\n");
01565                      break;
01566        }
01567        Plate = nr;
01568        currentSpot = name;
01569        DoSep = true;
01570 }
01571 
01572 void PSLib::PS_setGray()
01573 {
01574        GraySc = true;
01575 }
01576 
01577 void PSLib::PDF_Bookmark(QString text, uint Seite)
01578 {
01579        PutSeite("[/Title ("+text+") /Page "+IToStr(Seite)+" /View [/Fit]\n");
01580        PutSeite("/OUT pdfmark\n");
01581        isPDF = true;
01582 }
01583 
01584 void PSLib::PDF_Annotation(QString text, double x, double y, double b, double h)
01585 {
01586        PutSeite("[ /Rect [ "+ToStr(static_cast<int>(x))+" "+ToStr(static_cast<int>(y))
01587                      +" "+ToStr(static_cast<int>(b))+" "+ToStr(static_cast<int>(h))+" ]\n");
01588        PutSeite("  /Contents ("+text+")\n  /Open false\n");
01589        PutSeite("/ANN pdfmark\n");
01590        isPDF = true;
01591 }
01592 
01593 
01594 void PSLib::PS_close()
01595 {
01596        PutDoc("%%Trailer\n");
01597        PutDoc("end\n");
01598        PutDoc("%%EOF\n");
01599        Spool.close();
01600 }
01601 
01602 
01603 void PSLib::PS_insert(QString i)
01604 {
01605        PutDoc(i);
01606 }
01607 
01608 int PSLib::CreatePS(ScribusDoc* Doc, PrintOptions &options)
01609 {
01610        Options = options;
01611        std::vector<int> &pageNs = options.pageNumbers;
01612        bool sep = options.outputSeparations;
01613        QString SepNam = options.separationName;
01614        QStringList spots = options.allSeparations;
01615        bool farb = options.useColor;
01616        bool Hm = options.mirrorH;
01617        bool Vm = options.mirrorV;
01618        bool Ic = options.useICC;
01619        bool gcr = options.doGCR;
01620        bool doDev = options.setDevParam;
01621        bool doClip = options.doClip;
01622        bool over = options.doOverprint;
01623        QPtrStack<PageItem> groupStack;
01624        int sepac;
01625        int pagemult;
01626        doOverprint = over;
01627        if ((sep) && (SepNam == QObject::tr("All")))
01628               pagemult = spots.count();
01629        else
01630               pagemult = 1;
01631        QValueList<double> dum;
01632        double gx = 0.0;
01633        double gy = 0.0;
01634        double gw = 0.0;
01635        double gh = 0.0;;
01636        dum.clear();
01637        PS_set_Info("Author", Doc->documentInfo.getAuthor());
01638        PS_set_Info("Title", Doc->documentInfo.getTitle());
01639        if (!farb)
01640               PS_setGray();
01641        applyICC = Ic;
01642        if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
01643               solidTransform = cmsCreateTransform(Doc->DocInputCMYKProf, TYPE_CMYK_16, Doc->DocPrinterProf, TYPE_CMYK_16, Doc->IntentColors, 0);
01644        else
01645               applyICC = false;
01646        if (usingGUI)
01647        {
01648               QString title=QObject::tr("Exporting PostScript File");
01649               if (Art)
01650                      title=QObject::tr("Printing File");
01651               progressDialog=new MultiProgressDialog(title, CommonStrings::tr_Cancel, Doc->scMW(), "psexportprogress");
01652               if (progressDialog==0)
01653                      usingGUI=false;
01654               else
01655               {
01656                      QStringList barNames, barTexts;
01657                      barNames << "EMP" << "EP";
01658                      barTexts << tr("Processing Master Page:") << tr("Exporting Page:");
01659                      QValueList<bool> barsNumeric;
01660                      barsNumeric << true << true;
01661                      progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
01662                      progressDialog->setOverallTotalSteps(pageNs.size()+Doc->MasterPages.count());
01663                      progressDialog->setTotalSteps("EMP", Doc->MasterPages.count());
01664                      progressDialog->setTotalSteps("EP", pageNs.size());
01665                      progressDialog->setOverallProgress(0);
01666                      progressDialog->setProgress("EMP", 0);
01667                      progressDialog->setProgress("EP", 0);
01668                      progressDialog->show();
01669                      connect(progressDialog->buttonCancel, SIGNAL(clicked()), this, SLOT(cancelRequested()));
01670                      ScQApp->processEvents();
01671               }
01672        }
01673        //if ((!Art) && (view->SelItem.count() != 0))
01674        uint docSelectionCount=Doc->m_Selection->count();
01675        if ((!Art) && (docSelectionCount != 0))
01676        {
01677               double minx = 99999.9;
01678               double miny = 99999.9;
01679               double maxx = -99999.9;
01680               double maxy = -99999.9;
01681               for (uint ep = 0; ep < docSelectionCount; ++ep)
01682               {
01683                      //PageItem* currItem = view->SelItem.at(ep);
01684                      PageItem* currItem = Doc->m_Selection->itemAt(ep);
01685                      double lw = currItem->lineWidth() / 2.0;
01686                      if (currItem->rotation() != 0)
01687                      {
01688                             FPointArray pb;
01689                             pb.resize(0);
01690                             pb.addPoint(FPoint(currItem->xPos()-lw, currItem->yPos()-lw));
01691                             pb.addPoint(FPoint(currItem->width()+lw*2.0, -lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
01692                             pb.addPoint(FPoint(currItem->width()+lw*2.0, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
01693                             pb.addPoint(FPoint(-lw, currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
01694                             for (uint pc = 0; pc < 4; ++pc)
01695                             {
01696                                    minx = QMIN(minx, pb.point(pc).x());
01697                                    miny = QMIN(miny, pb.point(pc).y());
01698                                    maxx = QMAX(maxx, pb.point(pc).x());
01699                                    maxy = QMAX(maxy, pb.point(pc).y());
01700                             }
01701                      }
01702                      else
01703                      {
01704                             minx = QMIN(minx, currItem->xPos()-lw);
01705                             miny = QMIN(miny, currItem->yPos()-lw);
01706                             maxx = QMAX(maxx, currItem->xPos()-lw + currItem->width()+lw*2.0);
01707                             maxy = QMAX(maxy, currItem->yPos()-lw + currItem->height()+lw*2.0);
01708                      }
01709               }
01710               gx = minx;
01711               gy = miny;
01712               gw = maxx - minx;
01713               gh = maxy - miny;
01714               int pgNum = pageNs[0]-1;
01715               gx -= Doc->Pages->at(pgNum)->xOffset();
01716               gy -= Doc->Pages->at(pgNum)->yOffset();
01717               PS_begin_doc(Doc, gx, Doc->pageHeight - (gy+gh), gx + gw, Doc->pageHeight - gy, 1*pagemult, false, sep, farb, Ic, gcr, over);
01718        }
01719        else
01720        {
01721               uint a;
01722               double maxWidth = 0.0;
01723               double maxHeight = 0.0;
01724               for (uint aa = 0; aa < pageNs.size(); ++aa)
01725               {
01726                      a = pageNs[aa]-1;
01727                      maxWidth = QMAX(Doc->Pages->at(a)->width(), maxWidth);
01728                      maxHeight = QMAX(Doc->Pages->at(a)->height(), maxHeight);
01729               }
01730               PS_begin_doc(Doc, 0.0, 0.0, maxWidth, maxHeight, pageNs.size()*pagemult, doDev, sep, farb, Ic, gcr, over);
01731        }
01732        uint ap=0;
01733        for (; ap < Doc->MasterPages.count() && !abortExport; ++ap)
01734        {
01735               progressDialog->setOverallProgress(ap);
01736               progressDialog->setProgress("EMP", ap);
01737               ScQApp->processEvents();
01738               if (Doc->MasterItems.count() != 0)
01739               {
01740                      int Lnr = 0;
01741                      struct Layer ll;
01742                      ll.isPrintable = false;
01743                      ll.LNr = 0;
01744                      for (uint lam = 0; lam < Doc->Layers.count(); ++lam)
01745                      {
01746                             Level2Layer(Doc, &ll, Lnr);
01747                             if (ll.isPrintable)
01748                             {
01749                                    for (uint api = 0; api < Doc->MasterItems.count(); ++api)
01750                                    {
01751                                           QString tmps;
01752                                           PageItem *it = Doc->MasterItems.at(api);
01753                                           if ((it->LayerNr != ll.LNr) || (!it->printEnabled()))
01754                                                  continue;
01755 /*                                        int x = static_cast<int>(Doc->MasterPages.at(ap)->xOffset());
01756                                           int y = static_cast<int>(Doc->MasterPages.at(ap)->yOffset());
01757                                           int w = static_cast<int>(Doc->MasterPages.at(ap)->width());
01758                                           int h = static_cast<int>(Doc->MasterPages.at(ap)->height());
01759                                           double ilw=it->lineWidth();
01760                                           int x2 = static_cast<int>(it->BoundingX - ilw / 2.0);
01761                                           int y2 = static_cast<int>(it->BoundingY - ilw / 2.0);
01762                                           int w2 = static_cast<int>(it->BoundingW + ilw);
01763                                           int h2 = static_cast<int>(it->BoundingH + ilw);
01764                                           if (!QRect(x, y, w, h).intersects(QRect(x2, y2, w2, h2)))
01765                                                  continue; */
01766                                           double x = Doc->MasterPages.at(ap)->xOffset();
01767                                           double y = Doc->MasterPages.at(ap)->yOffset();
01768                                           double w = Doc->MasterPages.at(ap)->width();
01769                                           double h1 = Doc->MasterPages.at(ap)->height();
01770                                           double ilw = it->lineWidth();
01771                                           double x2 = it->BoundingX - ilw / 2.0;
01772                                           double y2 = it->BoundingY - ilw / 2.0;
01773                                           double w2 = it->BoundingW + ilw;
01774                                           double h2 = it->BoundingH + ilw;
01775                                           if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
01776                                                  continue;
01777                                           if ((it->OwnPage != static_cast<int>(Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1))
01778                                                  continue;
01779                                           if ((it->asImageFrame()) && (it->PicAvail) && (!it->Pfile.isEmpty()) && (it->printEnabled()) && (!sep) && (farb))
01780                                                  PS_ImageData(it, it->Pfile, it->itemName(), it->IProfile, it->UseEmbedded, Ic);
01781                                           PS_TemplateStart(Doc->MasterPages.at(ap)->pageName() + tmps.setNum(it->ItemNr));
01782                                           ProcessItem(Doc, Doc->MasterPages.at(ap), it, ap+1, sep, farb, Ic, gcr, true);
01783                                           PS_TemplateEnd();
01784                                    }
01785                             }
01786                             Lnr++;
01787                      }
01788               }
01789        }
01790        sepac = 0;
01791        uint aa = 0;
01792        uint a;       
01793        while (aa < pageNs.size() && !abortExport)
01794        {
01795               progressDialog->setProgress("EP", aa);
01796               progressDialog->setOverallProgress(ap+aa);
01797               ScQApp->processEvents();
01798               a = pageNs[aa]-1;
01799               //if ((!Art) && (view->SelItem.count() != 0))
01800               if ((!Art) && (Doc->m_Selection->count() != 0))
01801               {
01802                      MarginStruct Ma;
01803                      Ma.Left = gx;
01804                      Ma.Top = gy;
01805                      Ma.Bottom = Doc->Pages->at(a)->height() - (gy + gh);
01806                      Ma.Right = Doc->Pages->at(a)->width() - (gx + gw);
01807                      PS_begin_page(Doc->Pages->at(a), &Ma, true);
01808               }
01809               else
01810                      PS_begin_page(Doc->Pages->at(a), &Doc->Pages->at(a)->Margins, doClip);
01811               if (Hm)
01812               {
01813                      PS_translate(Doc->Pages->at(a)->width(), 0);
01814                      PS_scale(-1, 1);
01815               }
01816               if (Vm)
01817               {
01818                      PS_translate(0, Doc->Pages->at(a)->height());
01819                      PS_scale(1, -1);
01820               }
01821               if (sep)
01822               {
01823                      if (SepNam == QObject::tr("Black"))
01824                             PS_plate(0);
01825                      else if (SepNam == QObject::tr("Cyan"))
01826                             PS_plate(1);
01827                      else if (SepNam == QObject::tr("Magenta"))
01828                             PS_plate(2);
01829                      else if (SepNam == QObject::tr("Yellow"))
01830                             PS_plate(3);
01831                      else if (SepNam == QObject::tr("All"))
01832                             PS_plate(sepac, spots[sepac]);
01833                      else
01834                             PS_plate(4, SepNam);
01835               }
01836               if (!Doc->Pages->at(a)->MPageNam.isEmpty())
01837               {
01838                      int h, s, v, k;
01839                      QCString chstrc;
01840                      QString chstr;
01841                      int Lnr = 0;
01842                      struct Layer ll;
01843                      ll.isPrintable = false;
01844                      ll.LNr = 0;
01845                      Page* mPage = Doc->MasterPages.at(Doc->MasterNames[Doc->Pages->at(a)->MPageNam]);
01846                      if (Doc->MasterItems.count() != 0)
01847                      {
01848                             for (uint lam = 0; lam < Doc->Layers.count(); ++lam)
01849                             {
01850                                    Level2Layer(Doc, &ll, Lnr);
01851                                    if (ll.isPrintable)
01852                                    {
01853                                           for (uint am = 0; am < Doc->Pages->at(a)->FromMaster.count(); ++am)
01854                                           {
01855                                                  QString tmps;
01856                                                  PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
01857                                                  if ((ite->LayerNr != ll.LNr) || (!ite->printEnabled()))
01858                                                         continue;
01859                                                  if (ite->isGroupControl)
01860                                                  {
01861                                                         PS_save();
01862                                                         FPointArray cl = ite->PoLine.copy();
01863                                                         QWMatrix mm;
01864                                                         mm.translate(ite->xPos() - mPage->xOffset(), (ite->yPos() - mPage->yOffset()) - Doc->Pages->at(a)->height());
01865                                                         mm.rotate(ite->rotation());
01866                                                         cl.map( mm );
01867                                                         SetClipPath(&cl);
01868                                                         PS_closepath();
01869                                                         PS_clip(true);
01870                                                         groupStack.push(ite->groupsLastItem);
01871                                                         continue;
01872                                                  }
01873                                                  if (!(ite->asTextFrame()) && !(ite->asImageFrame()))
01874                                                         PS_UseTemplate(Doc->Pages->at(a)->MPageNam + tmps.setNum(ite->ItemNr));
01875                                                  else if (ite->asImageFrame())
01876                                                  {
01877                                                         PS_save();
01878                                                         // JG : replace what seems mostly duplicate code by corresponding function call (#3936)
01879                                                         ProcessItem(Doc, Doc->Pages->at(a), ite, a, sep, farb, Ic, gcr, false, false, true);
01880                                                         /*if (!doOverprint)
01881                                                         {
01882                                                                if (ite->doOverprint)
01883                                                                {
01884                                                                       PutSeite("true setoverprint\n");
01885                                                                       PutSeite("true setoverprintmode\n");
01886                                                                }
01887                                                         }
01888                                                         PS_translate(ite->xPos() - Doc->Pages->at(a)->xOffset(), Doc->Pages->at(a)->height() -(ite->yPos()) - Doc->Pages->at(a)->yOffset());
01889                                                         if (ite->rotation() != 0)
01890                                                                PS_rotate(-ite->rotation());
01891                                                         if (ite->fillColor() != CommonStrings::None)
01892                                                         {
01893                                                                SetClipPath(&ite->PoLine);
01894                                                                PS_closepath();
01895                                                                SetFarbe(ite->fillColor(), ite->fillShade(), &h, &s, &v, &k, gcr);
01896                                                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
01897                                                                putColor(ite->fillColor(), ite->fillShade(), true);
01898                                                         }
01899                                                         else
01900                                                                PS_setcmykcolor_dummy();
01901                                                         if (ite->imageClip.size() != 0)
01902                                                                SetClipPath(&ite->imageClip);
01903                                                         else
01904                                                                SetClipPath(&ite->PoLine);
01905                                                         PS_closepath();
01906                                                         PS_clip(false);
01907                                                         PS_save();
01908                                                         if (ite->imageFlippedH())
01909                                                         {
01910                                                                PS_translate(ite->width(), 0);
01911                                                                PS_scale(-1, 1);
01912                                                         }
01913                                                         if (ite->imageFlippedV())
01914                                                         {
01915                                                                PS_translate(0, -ite->height());
01916                                                                PS_scale(1, -1);
01917                                                         }
01918                                                         if ((ite->PicAvail) && (!ite->Pfile.isEmpty()))
01919                                                         {
01920                                                                PS_translate(0, -ite->BBoxH*ite->imageYScale());
01921                                                                if ((!sep) && (farb))
01922                                                                       PS_image(ite, ite->imageXOffset(), -ite->imageYOffset(), ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->IProfile, ite->UseEmbedded, Ic, ite->itemName());
01923                                                                else
01924                                                                       PS_image(ite, ite->imageXOffset(), -ite->imageYOffset(), ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->IProfile, ite->UseEmbedded, Ic);
01925                                                         }
01926                                                         PS_restore();
01927                                                         if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
01928                                                         {
01929                                                                if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
01930                                                                {
01931                                                                       SetFarbe(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
01932                                                                       PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
01933                                                                       PS_setlinewidth(ite->lineWidth());
01934                                                                       PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
01935                                                                       PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
01936                                                                       SetClipPath(&ite->PoLine);
01937                                                                       PS_closepath();
01938                                                                       putColor(ite->lineColor(), ite->lineShade(), false);
01939                                                                }
01940                                                                else
01941                                                                {
01942                                                                       multiLine ml = Doc->MLineStyles[ite->NamedLStyle];
01943                                                                       for (int it = ml.size()-1; it > -1; it--)
01944                                                                       {
01945                                                                              SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
01946                                                                              PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
01947                                                                              PS_setlinewidth(ml[it].Width);
01948                                                                              PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
01949                                                                              PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
01950                                                                              SetClipPath(&ite->PoLine);
01951                                                                              PS_closepath();
01952                                                                              putColor(ml[it].Color, ml[it].Shade, false);
01953                                                                       }
01954                                                                }
01955                                                         }*/
01956                                                         PS_restore();
01957                                                  }
01958                                                  else if (ite->asTextFrame())
01959                                                  {
01960                                                         PS_save();
01961                                                         if (!doOverprint)
01962                                                         {
01963                                                                if (ite->doOverprint)
01964                                                                {
01965                                                                       PutSeite("true setoverprint\n");
01966                                                                       PutSeite("true setoverprintmode\n");
01967                                                                }
01968                                                         }
01969                                                         if (ite->fillColor() != CommonStrings::None)
01970                                                         {
01971                                                                SetFarbe(ite->fillColor(), ite->fillShade(), &h, &s, &v, &k, gcr);
01972                                                                PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
01973                                                         }
01974                                                         PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
01975                                                         if (ite->rotation() != 0)
01976                                                                PS_rotate(-ite->rotation());
01977                                                         if ((ite->fillColor() != CommonStrings::None) || (ite->GrType != 0))
01978                                                         {
01979                                                                SetClipPath(&ite->PoLine);
01980                                                                PS_closepath();
01981                                                                if (ite->GrType != 0)
01982                                                                       HandleGradient(ite, ite->width(), ite->height(), gcr);
01983                                                                else
01984                                                                       putColor(ite->fillColor(), ite->fillShade(), true);
01985                                                         }
01986                                                         if (ite->imageFlippedH())
01987                                                         {
01988                                                                PS_translate(ite->width(), 0);
01989                                                                PS_scale(-1, 1);
01990                                                         }
01991                                                         if (ite->imageFlippedV())
01992                                                         {
01993                                                                PS_translate(0, -ite->height());
01994                                                                PS_scale(1, -1);
01995                                                         }
01996                                                         setTextSt(Doc, ite, gcr, a, mPage, sep, farb, Ic, true);
01997                                                         if (((ite->lineColor() != CommonStrings::None) || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem))
01998                                                         {
01999                                                                if ((ite->NamedLStyle.isEmpty()) && (ite->lineWidth() != 0.0))
02000                                                                {
02001                                                                       SetFarbe(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
02002                                                                       PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02003                                                                       PS_setlinewidth(ite->lineWidth());
02004                                                                       PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
02005                                                                       PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
02006                                                                       SetClipPath(&ite->PoLine);
02007                                                                       PS_closepath();
02008                                                                       putColor(ite->lineColor(), ite->lineShade(), false);
02009                                                                }
02010                                                                else
02011                                                                {
02012                                                                       multiLine ml = Doc->MLineStyles[ite->NamedLStyle];
02013                                                                       for (int it = ml.size()-1; it > -1; it--)
02014                                                                       {
02015                                                                              if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02016                                                                              {
02017                                                                                     SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02018                                                                                     PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02019                                                                                     PS_setlinewidth(ml[it].Width);
02020                                                                                     PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02021                                                                                     PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02022                                                                                     SetClipPath(&ite->PoLine);
02023                                                                                     PS_closepath();
02024                                                                                     putColor(ml[it].Color, ml[it].Shade, false);
02025                                                                              }
02026                                                                       }
02027                                                                }
02028                                                         }
02029                                                         PS_restore();
02030                                                  }
02031                                                  if (groupStack.count() != 0)
02032                                                  {
02033                                                         while (ite == groupStack.top())
02034                                                         {
02035                                                                PS_restore();
02036                                                                groupStack.pop();
02037                                                         }
02038                                                  }
02039                                           }
02040                                    }
02041                                    for (uint am = 0; am < Doc->Pages->at(a)->FromMaster.count(); ++am)
02042                                    {
02043                                           PageItem *ite = Doc->Pages->at(a)->FromMaster.at(am);
02044                                           if (!ite->isTableItem)
02045                                                  continue;
02046                                           if ((ite->lineColor() != CommonStrings::None) || (ite->lineWidth() == 0.0))
02047                                                  continue;
02048                                           if (ite->printEnabled())
02049                                           {
02050                                                  PS_save();
02051                                                  if (!doOverprint)
02052                                                  {
02053                                                         if (ite->doOverprint)
02054                                                         {
02055                                                                PutSeite("true setoverprint\n");
02056                                                                PutSeite("true setoverprintmode\n");
02057                                                         }
02058                                                  }
02059                                                  if (ite->lineColor() != CommonStrings::None)
02060                                                  {
02061                                                         SetFarbe(ite->lineColor(), ite->lineShade(), &h, &s, &v, &k, gcr);
02062                                                         PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02063                                                  }
02064                                                  PS_setlinewidth(ite->lineWidth());
02065                                                  PS_setcapjoin(ite->PLineEnd, ite->PLineJoin);
02066                                                  PS_setdash(ite->PLineArt, ite->DashOffset, ite->DashValues);
02067                                                  PS_translate(ite->xPos() - mPage->xOffset(), mPage->height() - (ite->yPos() - mPage->yOffset()));
02068                                                  if (ite->rotation() != 0)
02069                                                         PS_rotate(-ite->rotation());
02070                                                  if ((ite->TopLine) || (ite->RightLine) || (ite->BottomLine) || (ite->LeftLine))
02071                                                  {
02072                                                         if (ite->TopLine)
02073                                                         {
02074                                                                PS_moveto(0, 0);
02075                                                                PS_lineto(ite->width(), 0);
02076                                                         }
02077                                                         if (ite->RightLine)
02078                                                         {
02079                                                                PS_moveto(ite->width(), 0);
02080                                                                PS_lineto(ite->width(), -ite->height());
02081                                                         }
02082                                                         if (ite->BottomLine)
02083                                                         {
02084                                                                PS_moveto(0, -ite->height());
02085                                                                PS_lineto(ite->width(), -ite->height());
02086                                                         }
02087                                                         if (ite->LeftLine)
02088                                                         {
02089                                                                PS_moveto(0, 0);
02090                                                                PS_lineto(0, -ite->height());
02091                                                         }
02092                                                         putColor(ite->lineColor(), ite->lineShade(), false);
02093                                                  }
02094                                                  PS_restore();
02095                                           }
02096                                    }
02097                                    Lnr++;
02098                             }
02099                      }
02100               }
02101               if (!abortExport)
02102                      ProcessPage(Doc, Doc->Pages->at(a), a+1, sep, farb, Ic, gcr);
02103               if (!abortExport)
02104                      PS_end_page();
02105               if (sep)
02106               {
02107                      if (SepNam != QObject::tr("All"))
02108                             aa++;
02109                      else
02110                      {
02111                             if (sepac == static_cast<int>(spots.count()-1))
02112                             {
02113                                    aa++;
02114                                    sepac = 0;
02115                             }
02116                             else
02117                                    sepac++;
02118                      }
02119               }
02120               else
02121                      aa++;
02122        }
02123        PS_close();
02124        if (usingGUI) progressDialog->close();
02125        if ((Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
02126               cmsDeleteTransform(solidTransform);
02127        if (!abortExport)
02128               return 0;
02129        else
02130               return 2; //CB Lets leave 1 for general error condition
02131 }
02132 
02133 void PSLib::ProcessItem(ScribusDoc* Doc, Page* a, PageItem* c, uint PNr, bool sep, bool farb, bool ic, bool gcr, bool master, bool embedded, bool useTemplate)
02134 {
02135        int h, s, v, k, tsz;
02136        int d;
02137        ScText *hl;
02138        QValueList<double> dum;
02139        dum.clear();
02140        QString tmps, chstr;
02141        if (c->printEnabled())
02142        {
02143               fillRule = true;
02144               PS_save();
02145               if (!doOverprint)
02146               {
02147                      if (c->doOverprint)
02148                      {
02149                             PutSeite("true setoverprint\n");
02150                             PutSeite("true setoverprintmode\n");
02151                      }
02152               }
02153               if (c->fillColor() != CommonStrings::None)
02154               {
02155                      SetFarbe(c->fillColor(), c->fillShade(), &h, &s, &v, &k, gcr);
02156                      PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02157               }
02158               if (c->lineColor() != CommonStrings::None)
02159               {
02160                      SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02161                      PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02162               }
02163               PS_setlinewidth(c->lineWidth());
02164               PS_setcapjoin(c->PLineEnd, c->PLineJoin);
02165               PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
02166               if (!embedded)
02167               {
02168                      PS_translate(c->xPos() - a->xOffset(), a->height() - (c->yPos() - a->yOffset()));
02169               }
02170               if (c->rotation() != 0)
02171                      PS_rotate(-c->rotation());
02172               switch (c->itemType())
02173               {
02174               case PageItem::ImageFrame:
02175                      if (master)
02176                             break;
02177                      if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
02178                      {
02179                             SetClipPath(&c->PoLine);
02180                             PS_closepath();
02181                             if ((c->GrType != 0) && (a->pageName().isEmpty()))
02182                                    HandleGradient(c, c->width(), c->height(), gcr);
02183                             else
02184                                    putColor(c->fillColor(), c->fillShade(), true);
02185                             PS_newpath();
02186                      }
02187                      PS_save();
02188                      if (c->imageClip.size() != 0)
02189                      {
02190                             SetClipPath(&c->imageClip);
02191                             PS_closepath();
02192                             PS_clip(true);
02193                      }
02194                      SetClipPath(&c->PoLine);
02195                      PS_closepath();
02196                      PS_clip(true);
02197                      if (c->imageFlippedH())
02198                      {
02199                             PS_translate(c->width(), 0);
02200                             PS_scale(-1, 1);
02201                      }
02202                      if (c->imageFlippedV())
02203                      {
02204                             PS_translate(0, -c->height());
02205                             PS_scale(1, -1);
02206                      }
02207                      if ((c->PicAvail) && (!c->Pfile.isEmpty()))
02208                      {
02209                             PS_translate(0, -c->BBoxH*c->imageYScale());
02210                             if (((!a->pageName().isEmpty()) && (!sep) && (farb)) || useTemplate)
02211                                    PS_image(c, /*-c->BBoxX+*/c->imageXOffset(), -c->imageYOffset(), c->Pfile, c->imageXScale(), c->imageYScale(), c->IProfile, c->UseEmbedded, ic, c->itemName());
02212                             else
02213                                    PS_image(c, /*-c->BBoxX+*/c->imageXOffset(), -c->imageYOffset(), c->Pfile, c->imageXScale(), c->imageYScale(), c->IProfile, c->UseEmbedded, ic);
02214                      }
02215                      PS_restore();
02216                      if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
02217                      {
02218                             if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02219                             {
02220                                    SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02221                                    PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02222                                    PS_setlinewidth(c->lineWidth());
02223                                    PS_setcapjoin(c->PLineEnd, c->PLineJoin);
02224                                    PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
02225                                    SetClipPath(&c->PoLine);
02226                                    PS_closepath();
02227                                    putColor(c->lineColor(), c->lineShade(), false);
02228                             }
02229                             else
02230                             {
02231                                    multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02232                                    for (int it = ml.size()-1; it > -1; it--)
02233                                    {
02234                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02235                                           {
02236                                                  SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02237                                                  PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02238                                                  PS_setlinewidth(ml[it].Width);
02239                                                  PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02240                                                  PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02241                                                  SetClipPath(&c->PoLine);
02242                                                  PS_closepath();
02243                                                  putColor(ml[it].Color, ml[it].Shade, false);
02244                                           }
02245                                    }
02246                             }
02247                      }
02248                      break;
02249               case PageItem::TextFrame:
02250                      if (master)
02251                             break;
02252                      if (c->isBookmark)
02253                      {
02254                             QString bm = "";
02255                             QString cc;
02256                             for (int d = 0; d < c->itemText.length(); ++d)
02257                             {
02258                                    if ((c->itemText.text(d) == QChar(13)) || (c->itemText.text(d) == QChar(10)) || (c->itemText.text(d) == QChar(28)))
02259                                           break;
02260                                    bm += "\\"+cc.setNum(QMAX(c->itemText.text(d).unicode(), 32), 8);
02261                             }
02262                             PDF_Bookmark(bm, a->pageNr()+1);
02263                      }
02264                      if (c->isAnnotation())
02265                      {
02266                             QString bm = "";
02267                             QString cc;
02268                             for (int d = 0; d < c->itemText.length(); ++d)
02269                             {
02270                                    bm += "\\"+cc.setNum(QMAX(c->itemText.text(d).unicode(), 32), 8);
02271                             }
02272                             PDF_Annotation(bm, 0, 0, c->width(), -c->height());
02273                             break;
02274                      }
02275                      if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
02276                      {
02277                             SetClipPath(&c->PoLine);
02278                             PS_closepath();
02279                             if ((c->GrType != 0) && (a->pageName().isEmpty()))
02280                                    HandleGradient(c, c->width(), c->height(), gcr);
02281                             else
02282                                    putColor(c->fillColor(), c->fillShade(), true);
02283                      }
02284                      if (c->imageFlippedH())
02285                      {
02286                             PS_translate(c->width(), 0);
02287                             PS_scale(-1, 1);
02288                      }
02289                      if (c->imageFlippedV())
02290                      {
02291                             PS_translate(0, -c->height());
02292                             PS_scale(1, -1);
02293                      }
02294                      setTextSt(Doc, c, gcr, PNr-1, a, sep, farb, ic, master);
02295                      if (((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty())) && (!c->isTableItem))
02296                      {
02297                             SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02298                             PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02299                             PS_setlinewidth(c->lineWidth());
02300                             PS_setcapjoin(c->PLineEnd, c->PLineJoin);
02301                             PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
02302                             if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02303                             {
02304                                    SetClipPath(&c->PoLine);
02305                                    PS_closepath();
02306                                    putColor(c->lineColor(), c->lineShade(), false);
02307                             }
02308                             else
02309                             {
02310                                    multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02311                                    for (int it = ml.size()-1; it > -1; it--)
02312                                    {
02313                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02314                                           {
02315                                                  SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02316                                                  PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02317                                                  PS_setlinewidth(ml[it].Width);
02318                                                  PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02319                                                  PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02320                                                  SetClipPath(&c->PoLine);
02321                                                  PS_closepath();
02322                                                  putColor(ml[it].Color, ml[it].Shade, false);
02323                                           }
02324                                    }
02325                             }
02326                      }
02327                      break;
02328               case PageItem::Line:
02329                      if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02330                      {
02331                             PS_moveto(0, 0);
02332                             PS_lineto(c->width(), 0);
02333                             putColor(c->lineColor(), c->lineShade(), false);
02334                      }
02335                      else
02336                      {
02337                             multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02338                             for (int it = ml.size()-1; it > -1; it--)
02339                             {
02340                                    if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02341                                    {
02342                                           SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02343                                           PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02344                                           PS_setlinewidth(ml[it].Width);
02345                                           PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02346                                           PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02347                                           PS_moveto(0, 0);
02348                                           PS_lineto(c->width(), 0);
02349                                           putColor(ml[it].Color, ml[it].Shade, false);
02350                                    }
02351                             }
02352                      }
02353                      if (c->startArrowIndex() != 0)
02354                      {
02355                             QWMatrix arrowTrans;
02356                             FPointArray arrow = (*Doc->arrowStyles.at(c->startArrowIndex()-1)).points.copy();
02357                             arrowTrans.translate(0, 0);
02358                             arrowTrans.scale(c->lineWidth(), c->lineWidth());
02359                             arrowTrans.scale(-1,1);
02360                             arrow.map(arrowTrans);
02361                             SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02362                             PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02363                             PS_newpath();
02364                             SetClipPath(&arrow);
02365                             PS_closepath();
02366                             putColor(c->lineColor(), c->lineShade(), true);
02367                      }
02368                      if (c->endArrowIndex() != 0)
02369                      {
02370                             QWMatrix arrowTrans;
02371                             FPointArray arrow = (*Doc->arrowStyles.at(c->endArrowIndex()-1)).points.copy();
02372                             arrowTrans.translate(c->width(), 0);
02373                             arrowTrans.scale(c->lineWidth(), c->lineWidth());
02374                             arrow.map(arrowTrans);
02375                             SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02376                             PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02377                             PS_newpath();
02378                             SetClipPath(&arrow);
02379                             PS_closepath();
02380                             putColor(c->lineColor(), c->lineShade(), true);
02381                      }
02382                      break;
02383               /* OBSOLETE CR 2005-02-06
02384               case 1:
02385               case 3:
02386               */
02387               case PageItem::ItemType1:
02388               case PageItem::ItemType3:
02389               case PageItem::Polygon:
02390                      if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
02391                      {
02392                             SetClipPath(&c->PoLine);
02393                             PS_closepath();
02394                             fillRule = c->fillRule;
02395                             if (c->GrType != 0)
02396                                    HandleGradient(c, c->width(), c->height(), gcr);
02397                             else
02398                                    putColor(c->fillColor(), c->fillShade(), true);
02399                      }
02400                      if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
02401                      {
02402                             if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02403                             {
02404                                    SetClipPath(&c->PoLine);
02405                                    PS_closepath();
02406                                    putColor(c->lineColor(), c->lineShade(), false);
02407                             }
02408                             else
02409                             {
02410                                    multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02411                                    for (int it = ml.size()-1; it > -1; it--)
02412                                    {
02413                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02414                                           {
02415                                                  SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02416                                                  PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02417                                                  PS_setlinewidth(ml[it].Width);
02418                                                  PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02419                                                  PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02420                                                  SetClipPath(&c->PoLine);
02421                                                  PS_closepath();
02422                                                  putColor(ml[it].Color, ml[it].Shade, false);
02423                                           }
02424                                    }
02425                             }
02426                      }
02427                      break;
02428               case PageItem::PolyLine:
02429                      if ((c->fillColor() != CommonStrings::None) || (c->GrType != 0))
02430                      {
02431                             SetClipPath(&c->PoLine);
02432                             PS_closepath();
02433                             if (c->GrType != 0)
02434                                    HandleGradient(c, c->width(), c->height(), gcr);
02435                             else
02436                                    putColor(c->fillColor(), c->fillShade(), true);
02437                             PS_newpath();
02438                      }
02439                      if ((c->lineColor() != CommonStrings::None) || (!c->NamedLStyle.isEmpty()))
02440                      {
02441                             if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02442                             {
02443                                    SetClipPath(&c->PoLine, false);
02444                                    putColor(c->lineColor(), c->lineShade(), false);
02445                             }
02446                             else
02447                             {
02448                                    multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02449                                    for (int it = ml.size()-1; it > -1; it--)
02450                                    {
02451                                           if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02452                                           {
02453                                                  SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02454                                                  PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02455                                                  PS_setlinewidth(ml[it].Width);
02456                                                  PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02457                                                  PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02458                                                  SetClipPath(&c->PoLine, false);
02459                                                  putColor(ml[it].Color, ml[it].Shade, false);
02460                                           }
02461                                    }
02462                             }
02463                      }
02464                      if (c->startArrowIndex() != 0)
02465                      {
02466                             FPoint Start = c->PoLine.point(0);
02467                             for (uint xx = 1; xx < c->PoLine.size(); xx += 2)
02468                             {
02469                                    FPoint Vector = c->PoLine.point(xx);
02470                                    if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
02471                                    {
02472                                           double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
02473                                           QWMatrix arrowTrans;
02474                                           FPointArray arrow = (*Doc->arrowStyles.at(c->startArrowIndex()-1)).points.copy();
02475                                           arrowTrans.translate(Start.x(), Start.y());
02476                                           arrowTrans.rotate(r);
02477                                           arrowTrans.scale(c->lineWidth(), c->lineWidth());
02478                                           arrow.map(arrowTrans);
02479                                           SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02480                                           PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02481                                           PS_newpath();
02482                                           SetClipPath(&arrow);
02483                                           PS_closepath();
02484                                           putColor(c->lineColor(), c->lineShade(), true);
02485                                           break;
02486                                    }
02487                             }
02488                      }
02489                      if (c->endArrowIndex() != 0)
02490                      {
02491                             FPoint End = c->PoLine.point(c->PoLine.size()-2);
02492                             for (uint xx = c->PoLine.size()-1; xx > 0; xx -= 2)
02493                             {
02494                                    FPoint Vector = c->PoLine.point(xx);
02495                                    if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
02496                                    {
02497                                           double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
02498                                           QWMatrix arrowTrans;
02499                                           FPointArray arrow = (*Doc->arrowStyles.at(c->endArrowIndex()-1)).points.copy();
02500                                           arrowTrans.translate(End.x(), End.y());
02501                                           arrowTrans.rotate(r);
02502                                           arrowTrans.scale(c->lineWidth(), c->lineWidth());
02503                                           arrow.map(arrowTrans);
02504                                           SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02505                                           PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02506                                           PS_newpath();
02507                                           SetClipPath(&arrow);
02508                                           PS_closepath();
02509                                           putColor(c->lineColor(), c->lineShade(), true);
02510                                           break;
02511                                    }
02512                             }
02513                      }
02514                      break;
02515               case PageItem::PathText:
02516                      if (c->PoShow)
02517                      {
02518                             if (c->PoLine.size() > 3)
02519                             {
02520                                    PS_save();
02521                                    if ((c->NamedLStyle.isEmpty()) && (c->lineWidth() != 0.0))
02522                                    {
02523                                           SetClipPath(&c->PoLine, false);
02524                                           putColor(c->lineColor(), c->lineShade(), false);
02525                                    }
02526                                    else
02527                                    {
02528                                           multiLine ml = Doc->MLineStyles[c->NamedLStyle];
02529                                           for (int it = ml.size()-1; it > -1; it--)
02530                                           {
02531                                                  if ((ml[it].Color != CommonStrings::None) && (ml[it].Width != 0))
02532                                                  {
02533                                                         SetFarbe(ml[it].Color, ml[it].Shade, &h, &s, &v, &k, gcr);
02534                                                         PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02535                                                         PS_setlinewidth(ml[it].Width);
02536                                                         PS_setcapjoin(static_cast<Qt::PenCapStyle>(ml[it].LineEnd), static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
02537                                                         PS_setdash(static_cast<Qt::PenStyle>(ml[it].Dash), 0, dum);
02538                                                         SetClipPath(&c->PoLine, false);
02539                                                         putColor(ml[it].Color, ml[it].Shade, false);
02540                                                  }
02541                                           }
02542                                    }
02543                                    PS_restore();
02544                             }
02545                      }
02546 #ifndef NLS_PROTO
02547                      for (d = c->firstInFrame(); d <= c->lastInFrame(); ++d)
02548                      {
02549                             hl = c->itemText.item(d);
02550                             const CharStyle & style(c->itemText.charStyle(d));
02551                             if ((hl->ch == QChar(13)) || (hl->ch == QChar(30)) || (hl->ch == QChar(32)) || (hl->ch == QChar(9)) || (hl->ch == QChar(28)))
02552                                    continue;
02553                             tsz = style.fontSize();
02554                             chstr = hl->ch;
02555                             if (hl->ch == QChar(29))
02556                                    chstr = " ";
02557                             if (hl->ch == QChar(0xA0))
02558                                    chstr = " ";
02559                             if (style.effects() & 32)
02560                             {
02561                                    if (chstr.upper() != chstr)
02562                                           chstr = chstr.upper();
02563                             }
02564                             if (style.effects() & 64)
02565                             {
02566                                    if (chstr.upper() != chstr)
02567                                    {
02568                                           tsz = style.fontSize() * Doc->typographicSettings.valueSmallCaps / 100;
02569                                           chstr = chstr.upper();
02570                                    }
02571                             }
02572                             if (style.effects() & 1)
02573                                    tsz = style.fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
02574                             if (style.effects() & 2)
02575                                    tsz = style.fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
02576                             if (style.fillColor() != CommonStrings::None)
02577                             {
02578                                    SetFarbe(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
02579                                    PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02580                             }
02581                             if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
02582                             {
02583                                    PS_save();
02584                                    PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(-hl->PRot) + " " + ToStr(0) + "]\n");
02585                                    if (c->textPathFlipped)
02586                                    {
02587                                           PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(0) + " " + ToStr(0) + "]\n");
02588                                           PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\n");
02589                                    }
02590                                    if (c->textPathType == 0)
02591                                           PutSeite("["+ToStr(hl->PtransX) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransX) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02592                                    else if (c->textPathType == 1)
02593                                           PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02594                                    else if (c->textPathType == 2)
02595                                    {
02596                                           double a = 1;
02597                                           double b = -1;
02598                                           if (hl->PtransX < 0)
02599                                           {
02600                                                  a = -1;
02601                                                  b = 1;
02602                                           }
02603                                           if (fabs(hl->PtransX) > 0.1)
02604                                                  PutSeite("["+ToStr(a) + " " + ToStr((hl->PtransY / hl->PtransX) * b) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02605                                           else
02606                                                  PutSeite("["+ToStr(a) + " " + ToStr(4) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02607                                    }
02608                                    PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\nconcat\n");
02609 //                                 PS_translate(0, (tsz / 10.0));
02610                                    if (c->BaseOffs != 0)
02611                                           PS_translate(0, -c->BaseOffs);
02612                                    if (style.scaleH() != 1000)
02613                                           PS_scale(style.scaleH() / 1000.0, 1);
02614                                    QPtrList<PageItem> emG = hl->embedded.getGroupedItems();
02615                                    QPtrStack<PageItem> groupStack;
02616                                    for (uint em = 0; em < emG.count(); ++em)
02617                                    {
02618                                           PageItem* embedded = emG.at(em);
02619                                           if (embedded->isGroupControl)
02620                                           {
02621                                                  PS_save();
02622                                                  FPointArray cl = embedded->PoLine.copy();
02623                                                  QWMatrix mm;
02624                                                  mm.translate(embedded->gXpos * (style.scaleH() / 1000.0), ((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)) * -1);
02625                                                  if (style.baselineOffset() != 0)
02626                                                         mm.translate(0, embedded->gHeight * (style.baselineOffset() / 1000.0));
02627                                                  if (style.scaleH() != 1000)
02628                                                         mm.scale(style.scaleH() / 1000.0, 1);
02629                                                  if (style.scaleV() != 1000)
02630                                                         mm.scale(1, style.scaleV() / 1000.0);
02631                                                  mm.rotate(embedded->rotation());
02632                                                  cl.map( mm );
02633                                                  SetClipPath(&cl);
02634                                                  PS_closepath();
02635                                                  PS_clip(true);
02636                                                  groupStack.push(embedded->groupsLastItem);
02637                                                  continue;
02638                                           }
02639                                           PS_save();
02640                                           PS_translate(embedded->gXpos * (style.scaleH() / 1000.0), ((embedded->gHeight * (style.scaleV() / 1000.0)) - embedded->gYpos * (style.scaleV() / 1000.0)));
02641                                           if (style.baselineOffset() != 0)
02642                                                  PS_translate(0, embedded->gHeight * (style.baselineOffset() / 1000.0));
02643                                           if (style.scaleH() != 1000)
02644                                                  PS_scale(style.scaleH() / 1000.0, 1);
02645                                           if (style.scaleV() != 1000)
02646                                                  PS_scale(1, style.scaleV() / 1000.0);
02647                                           ProcessItem(Doc, a, embedded, PNr, sep, farb, ic, gcr, master, true);
02648                                           PS_restore();
02649                                           if (groupStack.count() != 0)
02650                                           {
02651                                                  while (embedded == groupStack.top())
02652                                                  {
02653                                                         PS_restore();
02654                                                         groupStack.pop();
02655                                                  }
02656                                           }
02657                                    }
02658                                    PS_restore();
02659                                    continue;
02660                             }
02661                             /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
02662                             ScFace::FontType type = style.font().type();
02663                             if ((type == ScFace::TTF) ||  (style.font().isOTF()) || (style.font().subset()))
02664                             {
02665 //                                 uint chr = chstr[0].unicode();
02666                                    uint chr = style.font().char2CMap(chstr[0]);
02667                                    if ((style.font().canRender(chstr[0])) && (chr != 32))
02668                                    {
02669                                           PS_save();
02670                                           if (style.fillColor() != CommonStrings::None)
02671                                           {
02672                                                  SetFarbe(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
02673                                                  PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02674                                                  PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(-hl->PRot) + " " + ToStr(0) + "]\n");
02675                                                  if (c->textPathFlipped)
02676                                                  {
02677                                                         PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(0) + " " + ToStr(0) + "]\n");
02678                                                         PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\n");
02679                                                  }
02680                                                  if (c->textPathType == 0)
02681                                                         PutSeite("["+ToStr(hl->PtransX) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransX) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02682                                                  else if (c->textPathType == 1)
02683                                                         PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02684                                                  else if (c->textPathType == 2)
02685                                                  {
02686                                                         double a = 1;
02687                                                         double b = -1;
02688                                                         if (hl->PtransX < 0)
02689                                                         {
02690                                                                a = -1;
02691                                                                b = 1;
02692                                                         }
02693                                                         if (fabs(hl->PtransX) > 0.1)
02694                                                                PutSeite("["+ToStr(a) + " " + ToStr((hl->PtransY / hl->PtransX) * b) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02695                                                         else
02696                                                                PutSeite("["+ToStr(a) + " " + ToStr(4) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02697                                                  }
02698                                                  PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\nconcat\n");
02699                                                  PS_translate(0, (tsz / 10.0));
02700                                                  if (c->BaseOffs != 0)
02701                                                         PS_translate(0, -c->BaseOffs);
02702                                                  if (style.scaleH() != 1000)
02703                                                         PS_scale(style.scaleH() / 1000.0, 1);
02704                                                  if ((colorsToUse[style.fillColor()].isSpotColor()) && (!DoSep))
02705                                                         PutSeite(ToStr(style.fillShade() / 100.0)+" "+spotMap[style.fillColor()]);
02706                                                  else
02707                                                         PutSeite(FillColor + " cmyk");
02708                                                  PS_showSub(chr, style.font().psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
02709                                                  if ((style.effects() & ScStyle_Outline))
02710                                                  {
02711                                                         if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
02712                                                         {
02713                                                                PS_save();
02714                                                                PS_setlinewidth(tsz * style.outlineWidth() / 10000.0);
02715                                                                SetFarbe(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
02716                                                                PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02717                                                                if ((colorsToUse[style.strokeColor()].isSpotColor()) && (!DoSep))
02718                                                                       PutSeite(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
02719                                                                else
02720                                                                       PutSeite(StrokeColor + " cmyk");
02721                                                                PS_showSub(chr, style.font().psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, true);
02722                                                                PS_restore();
02723                                                         }
02724                                                  }
02725                                           }
02726                                           PS_restore();
02727                                    }
02728                             }
02729                             else
02730                             {
02731                                    uint glyph = hl->glyph.glyph;
02732                                    PS_selectfont(style.font().replacementName(), tsz / 10.0);
02733                                    PS_save();
02734                                    PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(-hl->PRot) + " " + ToStr(0) + "]\n");
02735                                    if (c->textPathFlipped)
02736                                    {
02737                                           PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(0) + " " + ToStr(0) + "]\n");
02738                                           PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\n");
02739                                    }
02740                                    if (c->textPathType == 0)
02741                                           PutSeite("["+ToStr(hl->PtransX) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransY) + " " + ToStr(-hl->PtransX) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02742                                    else if (c->textPathType == 1)
02743                                           PutSeite("["+ToStr(1) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02744                                    else if (c->textPathType == 2)
02745                                    {
02746                                           double a = 1;
02747                                           double b = -1;
02748                                           if (hl->PtransX < 0)
02749                                           {
02750                                                  a = -1;
02751                                                  b = 1;
02752                                           }
02753                                           if (fabs(hl->PtransX) > 0.1)
02754                                                  PutSeite("["+ToStr(a) + " " + ToStr((hl->PtransY / hl->PtransX) * b) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02755                                           else
02756                                                  PutSeite("["+ToStr(a) + " " + ToStr(4) + " " + ToStr(0) + " " + ToStr(-1) + " " + ToStr(hl->glyph.xoffset) + " " + ToStr(-hl->glyph.yoffset) + "]\n");
02757                                    }
02758                                    PutSeite("["+ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + " " + ToStr(0) + "] concatmatrix\nconcat\n");
02759                                    if (c->BaseOffs != 0)
02760                                           PS_translate(0, -c->BaseOffs);
02761                                    if ((colorsToUse[style.fillColor()].isSpotColor()) && (!DoSep))
02762                                    {
02763                                           PutSeite(ToStr(style.fillShade() / 100.0)+" "+spotMap[style.fillColor()]);
02764                                           PS_show_xyG(style.font().replacementName(), glyph, 0, 0, true);
02765                                    }
02766                                    else
02767                                           PS_show_xyG(style.font().replacementName(), glyph, 0, 0, false);
02768                                    if ((style.effects() & ScStyle_Outline))
02769                                    {
02770                                           if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
02771                                           {
02772                                                  uint gl = style.font().char2CMap(chstr[0]);
02773                                                  FPointArray gly = style.font().glyphOutline(gl);
02774                                                  QWMatrix chma;
02775                                                  chma.scale(tsz / 100.0, tsz / 100.0);
02776                                                  gly.map(chma);
02777                                                  PS_save();
02778                                                  PS_setlinewidth(tsz * style.outlineWidth() / 10000.0);
02779                                                  PS_translate(0,  tsz / 10.0);
02780                                                  SetFarbe(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
02781                                                  PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02782                                                  SetClipPath(&gly);
02783                                                  PS_closepath();
02784                                                  putColor(style.strokeColor(), style.strokeShade(), false);
02785                                                  PS_restore();
02786                                           }
02787                                    }
02788                                    PS_restore();
02789                             }
02790                      }
02791 #endif
02792                      break;
02793               default:
02794                      break;
02795               }
02796               PS_restore();
02797        }
02798 }
02799 
02800 void PSLib::ProcessPage(ScribusDoc* Doc, Page* a, uint PNr, bool sep, bool farb, bool ic, bool gcr)
02801 {
02802        uint b;
02803        int h, s, v, k;
02804        QCString chstrc;
02805        QString chstr, chglyph, tmp;
02806        PageItem *c;
02807        QPtrList<PageItem> PItems;
02808        QPtrStack<PageItem> groupStack;
02809        int Lnr = 0;
02810        struct Layer ll;
02811        ll.isPrintable = false;
02812        ll.LNr = 0;
02813        for (uint la = 0; la < Doc->Layers.count(); ++la)
02814        {
02815               Level2Layer(Doc, &ll, Lnr);
02816               if (!a->pageName().isEmpty())
02817                      PItems = Doc->MasterItems;
02818               else
02819                      PItems = Doc->DocItems;
02820               if (ll.isPrintable)
02821               {
02822                      for (b = 0; b < PItems.count(); ++b)
02823                      {
02824                             c = PItems.at(b);
02825                             if (c->LayerNr != ll.LNr)
02826                                    continue;
02827                             if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
02828                                    continue;
02829                             if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
02830                                    continue;
02831                             //if ((!Art) && (view->SelItem.count() != 0) && (!c->Select))
02832                             if ((!Art) && (!c->isSelected()) && (Doc->m_Selection->count() != 0))
02833                                    continue;
02834                             double x = a->xOffset();
02835                             double y = a->yOffset();
02836                             double w = a->width();
02837                             double h1 = a->height();
02838                             double ilw = c->lineWidth();
02839                             double x2 = c->BoundingX - ilw / 2.0;
02840                             double y2 = c->BoundingY - ilw / 2.0;
02841                             double w2 = c->BoundingW + ilw;
02842                             double h2 = c->BoundingH + ilw;
02843                             if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
02844                                    continue;
02845                             if (c->ChangedMasterItem)
02846                                    continue;
02847                             if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
02848                                    continue;
02849                             if (c->isGroupControl)
02850                             {
02851                                    PS_save();
02852                                    FPointArray cl = c->PoLine.copy();
02853                                    QWMatrix mm;
02854                                    mm.translate(c->xPos() - a->xOffset(), (c->yPos() - a->yOffset()) - a->height());
02855                                    mm.rotate(c->rotation());
02856                                    cl.map( mm );
02857                                    SetClipPath(&cl);
02858                                    PS_closepath();
02859                                    PS_clip(true);
02860                                    groupStack.push(c->groupsLastItem);
02861                                    continue;
02862                             }
02863                             ProcessItem(Doc, a, c, PNr, sep, farb, ic, gcr, false);
02864                             if (groupStack.count() != 0)
02865                             {
02866                                    while (c == groupStack.top())
02867                                    {
02868                                           PS_restore();
02869                                           groupStack.pop();
02870                                    }
02871                             }
02872                      }
02873               }
02874               for (b = 0; b < PItems.count(); ++b)
02875               {
02876                      c = PItems.at(b);
02877                      if (c->LayerNr != ll.LNr)
02878                             continue;
02879                      if ((!a->pageName().isEmpty()) && (c->asTextFrame()))
02880                             continue;
02881                      if ((!a->pageName().isEmpty()) && (c->asImageFrame()) && ((sep) || (!farb)))
02882                             continue;
02883                      double x = a->xOffset();
02884                      double y = a->yOffset();
02885                      double w = a->width();
02886                      double h1 = a->height();
02887                      double ilw=c->lineWidth();
02888                      double x2 = c->BoundingX - ilw / 2.0;
02889                      double y2 = c->BoundingY - ilw / 2.0;
02890                      double w2 = c->BoundingW + ilw;
02891                      double h2 = c->BoundingH + ilw;
02892                      if (!( QMAX( x, x2 ) <= QMIN( x+w, x2+w2 ) && QMAX( y, y2 ) <= QMIN( y+h1, y2+h2 )))
02893                             continue;
02894                      if (c->ChangedMasterItem)
02895                             continue;
02896                      if (!c->isTableItem)
02897                             continue;
02898                      if ((c->lineColor() != CommonStrings::None) || (c->lineWidth() == 0.0))
02899                             continue;
02900                      if ((!a->pageName().isEmpty()) && (c->OwnPage != static_cast<int>(a->pageNr())) && (c->OwnPage != -1))
02901                             continue;
02902                      if (c->printEnabled())
02903                      {
02904                             PS_save();
02905                             if (!doOverprint)
02906                             {
02907                                    if (c->doOverprint)
02908                                    {
02909                                           PutSeite("true setoverprint\n");
02910                                           PutSeite("true setoverprintmode\n");
02911                                    }
02912                             }
02913                             if (c->lineColor() != CommonStrings::None)
02914                             {
02915                                    SetFarbe(c->lineColor(), c->lineShade(), &h, &s, &v, &k, gcr);
02916                                    PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
02917                             }
02918                             PS_setlinewidth(c->lineWidth());
02919                             PS_setcapjoin(c->PLineEnd, c->PLineJoin);
02920                             PS_setdash(c->PLineArt, c->DashOffset, c->DashValues);
02921                             PS_translate(c->xPos() - a->xOffset(), a->height() - (c->yPos() - a->yOffset()));
02922                             if (c->rotation() != 0)
02923                                    PS_rotate(-c->rotation());
02924                             if ((c->TopLine) || (c->RightLine) || (c->BottomLine) || (c->LeftLine))
02925                             {
02926                                    if (c->TopLine)
02927                                    {
02928                                           PS_moveto(0, 0);
02929                                           PS_lineto(c->width(), 0);
02930                                    }
02931                                    if (c->RightLine)
02932                                    {
02933                                           PS_moveto(c->width(), 0);
02934                                           PS_lineto(c->width(), -c->height());
02935                                    }
02936                                    if (c->BottomLine)
02937                                    {
02938                                           PS_moveto(0, -c->height());
02939                                           PS_lineto(c->width(), -c->height());
02940                                    }
02941                                    if (c->LeftLine)
02942                                    {
02943                                           PS_moveto(0, 0);
02944                                           PS_lineto(0, -c->height());
02945                                    }
02946                                    putColor(c->lineColor(), c->lineShade(), false);
02947                             }
02948                             PS_restore();
02949                      }
02950               }
02951               Lnr++;
02952        }
02953 }
02954 
02955 void PSLib::HandleGradient(PageItem *c, double w, double h, bool gcr)
02956 {
02957        int ch,cs,cv,ck;
02958        double StartX = 0;
02959        double StartY = 0;
02960        double EndX = 0;
02961        double EndY =0;
02962        ScPattern *pat;
02963        QWMatrix patternMatrix;
02964        double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
02965        QPtrVector<VColorStop> cstops = c->fill_gradient.colorStops();
02966        switch (c->GrType)
02967        {
02968 /*            case 1:
02969                      StartX = 0;
02970                      StartY = h / 2.0;
02971                      EndX = w;
02972                      EndY = h / 2.0;
02973                      break;
02974               case 2:
02975                      StartX = w / 2.0;
02976                      StartY = 0;
02977                      EndX = w / 2.0;
02978                      EndY = h;
02979                      break;
02980               case 3:
02981                      StartX = 0;
02982                      StartY = 0;
02983                      EndX = w;
02984                      EndY = h;
02985                      break;
02986               case 4:
02987                      StartX = 0;
02988                      StartY = h;
02989                      EndX = w;
02990                      EndY = 0;
02991                      break;
02992               case 5:
02993                      StartX = w / 2.0;
02994                      StartY = h / 2.0;
02995                      if (w >= h)
02996                      {
02997                             EndX = w;
02998                             EndY = h / 2.0;
02999                      }
03000                      else
03001                      {
03002                             EndX = w / 2.0;
03003                             EndY = h;
03004                      }
03005                      break; */
03006               case 1:
03007               case 2:
03008               case 3:
03009               case 4:
03010               case 5:
03011               case 6:
03012               case 7:
03013                      StartX = c->GrStartX;
03014                      StartY = c->GrStartY;
03015                      EndX = c->GrEndX;
03016                      EndY = c->GrEndY;
03017                      break;
03018               case 8:
03019                      pat = &m_Doc->docPatterns[c->pattern()];
03020                      c->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
03021                      patternMatrix.translate(patternOffsetX, -patternOffsetY);
03022                      patternMatrix.rotate(-patternRotation);
03023                      patternMatrix.scale(pat->scaleX, pat->scaleY);
03024                      patternMatrix.scale(patternScaleX / 100.0 , patternScaleY / 100.0);
03025                      PutSeite("Pattern"+c->pattern()+" ["+ToStr(patternMatrix.m11())+" "+ToStr(patternMatrix.m12())+" "+ToStr(patternMatrix.m21())+" "+ToStr(patternMatrix.m22())+" "+ToStr(patternMatrix.dx())+" "+ToStr(patternMatrix.dy())+"] makepattern setpattern\n");
03026                      if (fillRule)
03027                             PutSeite("eofill\n");
03028                      else
03029                             PutSeite("fill\n");
03030                      return;
03031                      break;
03032        }
03033        QValueList<double> StopVec;
03034        QStringList Gcolors;
03035        QStringList colorNames;
03036        QValueList<int> colorShades;
03037        QString hs,ss,vs,ks;
03038        double lastStop = -1.0;
03039        double actualStop = 0.0;
03040        bool isFirst = true;
03041        if ((c->GrType == 5) || (c->GrType == 7))
03042        {
03043               StopVec.clear();
03044               for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
03045               {
03046                      actualStop = cstops.at(cst)->rampPoint;
03047                      if ((actualStop != lastStop) || (isFirst))
03048                      {
03049                             isFirst = false;
03050                             lastStop = actualStop;
03051                             StopVec.prepend(sqrt(pow(EndX - StartX, 2) + pow(EndY - StartY,2))*cstops.at(cst)->rampPoint);
03052                             SetFarbe(cstops.at(cst)->name, cstops.at(cst)->shade, &ch, &cs, &cv, &ck, gcr);
03053                             QString GCol;
03054                             if (GraySc)
03055                                    GCol = hs.setNum((255.0 - QMIN(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0))  / 255.0);
03056                             else
03057                                    GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
03058                             Gcolors.prepend(GCol);
03059                             colorNames.prepend(cstops.at(cst)->name);
03060                             colorShades.prepend(cstops.at(cst)->shade);
03061                      }
03062               }
03063               PS_MultiRadGradient(w, -h, StartX, -StartY, StopVec, Gcolors, colorNames, colorShades);
03064        }
03065        else
03066        {
03067               StopVec.clear();
03068               for (uint cst = 0; cst < c->fill_gradient.Stops(); ++cst)
03069               {
03070                      actualStop = cstops.at(cst)->rampPoint;
03071                      if ((actualStop != lastStop) || (isFirst))
03072                      {
03073                             isFirst = false;
03074                             lastStop = actualStop;
03075                             double x = (1 - cstops.at(cst)->rampPoint) * StartX + cstops.at(cst)->rampPoint * EndX;
03076                             double y = (1 - cstops.at(cst)->rampPoint) * StartY + cstops.at(cst)->rampPoint * EndY;
03077                             StopVec.append(x);
03078                             StopVec.append(-y);
03079                             SetFarbe(cstops.at(cst)->name, cstops.at(cst)->shade, &ch, &cs, &cv, &ck, gcr);
03080                             QString GCol;
03081                             if (GraySc)
03082                                    GCol = hs.setNum((255.0 - QMIN(0.3 * ch + 0.59 * cs + 0.11 * cv + ck, 255.0))  / 255.0);
03083                             else
03084                                    GCol = hs.setNum(ch / 255.0)+" "+ss.setNum(cs / 255.0)+" "+vs.setNum(cv / 255.0)+" "+ks.setNum(ck / 255.0);
03085                             Gcolors.append(GCol);
03086                             colorNames.append(cstops.at(cst)->name);
03087                             colorShades.append(cstops.at(cst)->shade);
03088                      }
03089               }
03090               PS_MultiLinGradient(w, -h, StopVec, Gcolors, colorNames, colorShades);
03091        }
03092 }
03093 
03094 void PSLib::SetFarbe(const QString& farb, int shade, int *h, int *s, int *v, int *k, bool gcr)
03095 {
03096        ScColor& col = m_Doc->PageColors[farb];
03097        SetFarbe(col, shade, h, s, v, k, gcr);
03098 }
03099 
03100 void PSLib::SetFarbe(const ScColor& farb, int shade, int *h, int *s, int *v, int *k, bool gcr)
03101 {
03102        int h1, s1, v1, k1;
03103        h1 = *h;
03104        s1 = *s;
03105        v1 = *v;
03106        k1 = *k;
03107        ScColor tmp(farb);
03108        if (farb.getColorModel() == colorModelRGB)
03109               tmp = ScColorEngine::convertToModel(farb, m_Doc, colorModelCMYK);
03110        if ((gcr) && (!farb.isRegistrationColor()))
03111               ScColorEngine::applyGCR(tmp, m_Doc);
03112        tmp.getCMYK(&h1, &s1, &v1, &k1);
03113        if ((m_Doc->HasCMS) && (ScCore->haveCMS()) && (applyICC))
03114        {
03115               h1 = h1 * shade / 100;
03116               s1 = s1 * shade / 100;
03117               v1 = v1 * shade / 100;
03118               k1 = k1 * shade / 100;
03119               WORD inC[4];
03120               WORD outC[4];
03121               inC[0] = h1 * 257;
03122               inC[1] = s1 * 257;
03123               inC[2] = v1 * 257;
03124               inC[3] = k1 * 257;
03125               cmsDoTransform(solidTransform, inC, outC, 1);
03126               *h= outC[0] / 257;
03127               *s = outC[1] / 257;
03128               *v = outC[2] / 257;
03129               *k = outC[3] / 257;
03130        }
03131        else
03132        {
03133               *h = h1 * shade / 100;
03134               *s = s1 * shade / 100;
03135               *v = v1 * shade / 100;
03136               *k = k1 * shade / 100;
03137        }
03138 }
03139 
03140 void PSLib::setTextSt(ScribusDoc* Doc, PageItem* ite, bool gcr, uint argh, Page* pg, bool sep, bool farb, bool ic, bool master)
03141 {
03142 //     qDebug(QString("pslib setTextSt: ownPage=%1 pageNr=%2 OnMasterPage=%3;").arg(ite->OwnPage).arg(pg->pageNr()).arg(ite->OnMasterPage));
03143        int savedOwnPage = ite->OwnPage;
03144        ite->OwnPage = argh;
03145        ite->layout();
03146        ite->OwnPage = savedOwnPage;
03147 #ifndef NLS_PROTO
03148        ScText *hl;
03149        uint tabCc = 0;
03150        QValueList<ParagraphStyle::TabRecord> tTabValues;
03151        double tabDist = ite->textToFrameDistLeft();
03152        if (ite->lineColor() != CommonStrings::None)
03153               tabDist += ite->lineWidth() / 2.0;
03154 
03155        for (uint ll=0; ll < ite->itemText.lines(); ++ll) {
03156               LineSpec ls = ite->itemText.line(ll);
03157               tabDist = ls.x;
03158               double CurX = ls.x;
03159 
03160               for (int d = ls.firstItem; d <= ls.lastItem; ++d)
03161               {
03162                      hl = ite->itemText.item(d);
03163                      const CharStyle & cstyle(ite->itemText.charStyle(d));
03164                      const ParagraphStyle& pstyle(ite->itemText.paragraphStyle(d));
03165                      
03166 //                   if ((hl->ch[0] == QChar(13)) || (hl->ch[0] == QChar(10)) || (hl->ch[0] == QChar(28)) || (hl->ch[0] == QChar(27)) || (hl->ch[0] == QChar(26)))
03167 //                          continue;
03168                      if (hl->effects() & 4096)
03169                             continue;
03170                      tTabValues = pstyle.tabValues();
03171                      if (hl->effects() & 16384)
03172                             tabCc = 0;
03173                      if ((hl->ch == QChar(9)) && (tTabValues.count() != 0))
03174                      {
03175                             if ((!tTabValues[tabCc].tabFillChar.isNull()) && (tabCc < tTabValues.count()))
03176                             {
03177                                    ScText hl2;
03178                                    double wt = cstyle.font().charWidth(tTabValues[tabCc].tabFillChar, cstyle.fontSize());
03179                                    int coun = static_cast<int>((ls.x + hl->glyph.xoffset - tabDist) / wt);
03180                                    double sPos = ls.x + hl->glyph.xoffset - (ls.x + hl->glyph.xoffset - tabDist) + 1;
03181                                    hl2.ch = QString(tTabValues[tabCc].tabFillChar);
03182                                    static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
03183                                    
03184                                    hl2.glyph.yoffset = hl->glyph.yoffset;
03185                                    
03186                                    hl2.setTracking(0);
03187                                    hl2.setScaleH(1000);
03188                                    hl2.setScaleV(1000);
03189                                    
03190                                    for (int cx = 0; cx < coun; ++cx)
03191                                    {
03192                                           hl2.glyph.xoffset =  sPos + wt * cx;
03193                                           if ((hl2.effects() & 256) && (hl2.strokeColor() != CommonStrings::None))
03194                                           {
03195                                                  ScText hl3;
03196                                                  static_cast<CharStyle&>(hl3) = static_cast<const CharStyle&>(hl2);
03197                                                  hl3.ch = hl2.ch;
03198                                                  hl3.glyph.glyph = hl2.glyph.glyph;
03199                                                  hl3.setFillColor(hl2.strokeColor());
03200                                                  hl3.glyph.yoffset = hl2.glyph.yoffset - (hl2.fontSize() * hl2.shadowYOffset() / 10000.0);
03201                                                  hl3.glyph.xoffset = hl2.glyph.xoffset + (hl2.fontSize() * hl2.shadowXOffset() / 10000.0);
03202                                                  
03203                                                  setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl3, pstyle, pg, sep, farb, ic, master);
03204                                           }
03205                                           setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
03206                                    }
03207                                    tabCc++;
03208                             }
03209                             else
03210                             {
03211                                    tabCc++;
03212                             }
03213                      }
03214                      if (hl->ch == SpecialChars::TAB) {
03215                             CurX += hl->glyph.wide();
03216                             continue;
03217                      }
03218                      if ((cstyle.effects() & ScStyle_Shadowed) && (cstyle.strokeColor() != CommonStrings::None))
03219                      {
03220                             ScText hl2;
03221                             static_cast<CharStyle&>(hl2) = static_cast<const CharStyle&>(*hl);
03222                             hl2.ch = hl->ch;
03223                             hl2.glyph.glyph = hl->glyph.glyph;
03224                             hl2.setFillColor(cstyle.strokeColor());
03225                             hl2.glyph.yoffset = hl->glyph.yoffset - (cstyle.fontSize() * cstyle.shadowYOffset() / 10000.0);
03226                             hl2.glyph.xoffset = hl->glyph.xoffset + (cstyle.fontSize() * cstyle.shadowXOffset() / 10000.0);
03227                             hl2.glyph.scaleH = hl->glyph.scaleH;
03228                             hl2.glyph.scaleV = hl->glyph.scaleV;
03229                             
03230                             setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, &hl2, pstyle, pg, sep, farb, ic, master);
03231                      }
03232                      setTextCh(Doc, ite, CurX, ls.y, gcr, argh, d, hl, pstyle, pg, sep, farb, ic, master);
03233                      if (hl->ch[0] == SpecialChars::OBJECT)
03234                      {
03235                             InlineFrame& embedded(const_cast<InlineFrame&>(hl->embedded));
03236                             CurX += (embedded.getItem()->gWidth + embedded.getItem()->lineWidth());
03237                      }
03238                      else
03239                             CurX += hl->glyph.wide();
03240                      tabDist = CurX;
03241               }
03242        }
03243 #endif
03244 }
03245 
03246 void PSLib::setTextCh(ScribusDoc* Doc, PageItem* ite, double x, double y, bool gcr, uint argh, uint doh, ScText *hl, const ParagraphStyle& pstyle, Page* pg, bool sep, bool farb, bool ic, bool master)
03247 {
03248 #if 0
03249 //#ifndef NLS_PROTO
03250        QString chstr;
03251        int h, s, v, k, tsz;
03252        double wideR;
03253        QValueList<double> dum;
03254        dum.clear();
03255        chstr = hl->ch;
03256        tsz = hl->fontSize();
03257        if (hl->effects() & 2048)
03258        {
03259               if (pstyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing())
03260                      tsz = qRound(10 * ((Doc->typographicSettings.valueBaseGrid *  (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (hl->font().realCharHeight(chstr[0], 10))));
03261               else
03262               {
03263                      if (pstyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
03264                             tsz = qRound(10 * ((pstyle.lineSpacing() *  (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (hl->font().realCharHeight(chstr[0], 10))));
03265                      else
03266                      {
03267                             double currasce = hl->font().height(pstyle.charStyle().fontSize());
03268                             tsz = qRound(10 * ((currasce * (pstyle.dropCapLines()-1)+(hl->font().ascent(pstyle.charStyle().fontSize() / 10.0))) / hl->font().realCharHeight(chstr[0], 10)));
03269                      }
03270               }
03271        }
03272        if ((hl->ch == QChar(25)) && (hl->embedded.hasItem()))
03273        {
03274               QPtrList<PageItem> emG = hl->embedded.getGroupedItems();
03275 
03276               for (uint em = 0; em < emG.count(); ++em)
03277               {
03278                      PageItem* embedded = emG.at(em);
03279                      PS_save();
03280                      PS_translate(x+hl->glyph.xoffset + embedded->gXpos * (hl->scaleH() / 1000.0), (y+hl->glyph.yoffset - (embedded->gHeight * (hl->scaleV() / 1000.0)) + embedded->gYpos * (hl->scaleV() / 1000.0)) * -1);
03281                      if (hl->baselineOffset() != 0)
03282                             PS_translate(0, embedded->gHeight * (hl->baselineOffset() / 1000.0));
03283                      if (hl->scaleH() != 1000)
03284                             PS_scale(hl->scaleH() / 1000.0, 1);
03285                      if (hl->scaleV() != 1000)
03286                             PS_scale(1, hl->scaleV() / 1000.0);
03287                      ProcessItem(Doc, pg, embedded, argh, sep, farb, ic, gcr, master, true);
03288                      PS_restore();
03289               }
03290               return;
03291        }
03292        if (hl->ch == QChar(29))
03293               chstr = " ";
03294        if (hl->ch == QChar(24))
03295               chstr = "-";
03296        if (hl->ch == QChar(0xA0))
03297               chstr = " ";
03298        if (hl->ch == QChar(30))
03299        {
03300               //FIXME Stop duplicating PageItem::ExpandToken code!!!
03301               if (Doc->masterPageMode())
03302                      chstr = "#";
03303               else
03304               {
03305                      uint zae = 0;
03306                      uint za2 = doh;
03307                      do
03308                      {
03309                             if (za2 == 0)
03310                                    break;
03311                             za2--;
03312                      }
03313                      while (ite->itemText.text(za2) == QChar(30));
03314                      if (ite->itemText.text(za2) != QChar(30))
03315                             za2++;
03316                      while (ite->itemText.text(za2+zae) == QChar(30))
03317                      {
03318                             zae++;
03319                             if ( ! ite->frameDisplays(za2+zae) )
03320                                    break;
03321                      }
03322                      QString out="%1";
03323                      QString out2;
03324                      //CB Section numbering
03325                      //out2 = out.arg(a+Doc->FirstPnum, -zae);
03326                      out2=out.arg(Doc->getSectionPageNumberForPageIndex(argh), -(int)zae);
03327                      chstr = out2.mid(doh-za2, 1);
03328               }
03329        }
03330        if (hl->effects() & 32)
03331        {
03332               if (chstr.upper() != chstr)
03333                      chstr = chstr.upper();
03334        }
03335        if (hl->effects() & 64)
03336        {
03337               if (chstr.upper() != chstr)
03338               {
03339                      tsz = hl->fontSize() * Doc->typographicSettings.valueSmallCaps / 100;
03340                      chstr = chstr.upper();
03341               }
03342        }
03343        if (hl->effects() & 1)
03344               tsz = hl->fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
03345        if (hl->effects() & 2)
03346               tsz = hl->fontSize() * Doc->typographicSettings.scalingSuperScript / 100;
03347        /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
03348        ScFace::FontType ftype = hl->font().type();
03349        if ((ftype == ScFace::TTF) || (hl->font().isOTF()) || (hl->font().subset()))
03350        {
03351               uint chr = chstr[0].unicode();
03352               if ((hl->font().canRender(chstr[0])) && (chr != 32))
03353               {
03354                      PS_save();
03355                      if (ite->reversed())
03356                      {
03357                             PS_translate(x+hl->glyph.xoffset, (y+hl->glyph.yoffset - (tsz / 10.0)) * -1);
03358                             PS_scale(-1, 1);
03359                             if (ite->frameDisplays(doh+1))
03360                             {
03361                                    QString ctx = ite->itemText.text(doh+1, 1);
03362                                    if (ctx == QChar(29))
03363                                           ctx = " ";
03364                                    if (ctx == QChar(0xA0))
03365                                           ctx = " ";
03366                                    wideR = - hl->font().charWidth(chstr[0], tsz, ctx[0]) * (hl->scaleH() / 1000.0);
03367                             }
03368                             else
03369                                    wideR = - hl->font().charWidth(chstr[0], tsz) * (hl->scaleH() / 1000.0);
03370                             PS_translate(wideR, 0);
03371                      }
03372                      else
03373                             PS_translate(x+hl->glyph.xoffset, (y+hl->glyph.yoffset - (tsz / 10.0)) * -1);
03374                      if (hl->baselineOffset() != 0)
03375                             PS_translate(0, (hl->fontSize() / 10.0) * (hl->baselineOffset() / 1000.0));
03376                      if (hl->scaleH() != 100)
03377                             PS_scale(hl->scaleH() / 1000.0, 1);
03378                      if (hl->scaleV() != 100)
03379                      {
03380                             PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * (hl->scaleV() / 1000.0)));
03381                             PS_scale(1, hl->scaleV() / 1000.0);
03382                      }
03383                      if (hl->fillColor() != CommonStrings::None)
03384                      {
03385                             SetFarbe(hl->fillColor(), hl->fillShade(), &h, &s, &v, &k, gcr);
03386                             PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03387                             if ((colorsToUse[hl->fillColor()].isSpotColor()) && (!DoSep))
03388                                    PutSeite(ToStr(hl->fillShade() / 100.0)+" "+spotMap[hl->fillColor()]);
03389                             else
03390                                    PutSeite(FillColor + " cmyk");
03391                             PS_showSub(chr, hl->font().psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
03392                      }
03393                      PS_restore();
03394               }
03395        }
03396        else
03397        {
03398               PS_selectfont(hl->font().replacementName(), tsz / 10.0);
03399               PS_save();
03400               PS_translate(x+hl->glyph.xoffset, -y-hl->glyph.yoffset);
03401               if (ite->reversed())
03402               {
03403                      int chs = hl->fontSize();
03404                      GlyphLayout dummy;
03405                      ite->layoutGlyphs(*hl, chstr, dummy);
03406                      // chs = ??? FIXME
03407                      PS_scale(-1, 1);
03408                      if (ite->frameDisplays(doh+1))
03409                      {
03410                             QString ctx = ite->itemText.text(doh+1, 1);
03411                             if (ctx[0] == QChar(29))
03412                                    ctx = " ";
03413                             if (ctx[0] == QChar(0xA0))
03414                                    ctx = " ";
03415                             wideR = - hl->font().charWidth(chstr[0], chs, ctx[0]) * (hl->scaleH() / 1000.0);
03416                             PS_translate(wideR, 0);
03417                      }
03418                      else
03419                      {
03420                             wideR = -hl->font().charWidth(chstr[0], chs) * (hl->scaleH() / 1000.0);
03421                             PS_translate(wideR, 0);
03422                      }
03423               }
03424               if (hl->baselineOffset() != 0)
03425                      PS_translate(0, (hl->fontSize() / 10.0) * (hl->baselineOffset() / 1000.0));
03426               if (hl->scaleH() != 1000)
03427                      PS_scale(hl->scaleH() / 1000.0, 1);
03428               if (hl->scaleV() != 1000)
03429                      PS_scale(1, hl->scaleV() / 1000.0);
03430               if (hl->fillColor() != CommonStrings::None)
03431               {
03432                      SetFarbe(hl->fillColor(), hl->fillShade(), &h, &s, &v, &k, gcr);
03433                      PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03434                      if ((colorsToUse[hl->fillColor()].isSpotColor()) && (!DoSep))
03435                      {
03436                             PutSeite(ToStr(hl->fillShade() / 100.0)+" "+spotMap[hl->fillColor()]);
03437                             PS_show_xyG(hl->font().replacementName(), chstr, 0, 0, true);
03438                      }
03439                      else
03440                             PS_show_xyG(hl->font().replacementName(), chstr, 0, 0, false);
03441               }
03442               PS_restore();
03443        }
03444        if ((hl->effects() & 4) && (chstr != QChar(13)))
03445        {
03446               if (hl->font().canRender(chstr[0]))
03447               {
03448                      uint gl = hl->font().char2CMap(chstr[0]);
03449                      FPointArray gly = hl->font().glyphOutline(gl);
03450                      QWMatrix chma, chma2, chma3;
03451                      chma.scale(tsz / 100.0, tsz / 100.0);
03452                      chma2.scale(hl->scaleH() / 1000.0, hl->scaleV() / 1000.0);
03453                      if (hl->baselineOffset() != 0)
03454                             chma3.translate(0, -(hl->fontSize() / 10.0) * (hl->baselineOffset() / 1000.0));
03455                      gly.map(chma * chma2 * chma3);
03456                      if (ite->reversed())
03457                      {
03458                             chma = QWMatrix();
03459                             chma.scale(-1, 1);
03460                             chma.translate(wideR, 0);
03461                             gly.map(chma);
03462                      }
03463                      if ((hl->strokeColor() != CommonStrings::None) && ((tsz * hl->outlineWidth() / 10000.0) != 0))
03464                      {
03465                             PS_save();
03466                             PS_setlinewidth(tsz * hl->outlineWidth() / 10000.0);
03467                             PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03468                             PS_setdash(Qt::SolidLine, 0, dum);
03469                             PS_translate(x+hl->glyph.xoffset, (y+hl->glyph.yoffset - (tsz / 10.0)) * -1);
03470                             if (hl->scaleV() != 1000)
03471                                    PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * (hl->scaleV() / 1000.0)));
03472                             SetFarbe(hl->strokeColor(), hl->strokeShade(), &h, &s, &v, &k, gcr);
03473                             PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03474                             SetClipPath(&gly);
03475                             PS_closepath();
03476                             putColor(hl->strokeColor(), hl->strokeShade(), false);
03477                             PS_restore();
03478                      }
03479               }
03480        }
03481        if ((hl->effects() & 16) && (chstr != QChar(13)))
03482        {
03483               double Ulen = hl->font().charWidth(chstr[0], hl->fontSize()) * (hl->scaleH() / 1000.0);
03484               double Upos, lw, kern;
03485               if (hl->effects() & 16384)
03486                      kern = 0;
03487               else
03488                      kern = hl->fontSize() * hl->tracking() / 10000.0;
03489               if ((hl->strikethruOffset() != -1) || (hl->strikethruWidth() != -1))
03490               {
03491                      if (hl->strikethruOffset() != -1)
03492                             Upos = (hl->strikethruOffset() / 1000.0) * (hl->font().ascent(hl->fontSize() / 10.0));
03493                      else
03494                             Upos = hl->font().strikeoutPos(hl->fontSize() / 10.0);
03495                      if (hl->strikethruWidth() != -1)
03496                             lw = (hl->strikethruWidth() / 1000.0) * (hl->fontSize() / 10.0);
03497                      else
03498                             lw = QMAX(hl->font().strokeWidth(hl->fontSize() / 10.0), 1);
03499               }
03500               else
03501               {
03502                      Upos = hl->font().strikeoutPos(hl->fontSize() / 10.0);
03503                      lw = QMAX(hl->font().strokeWidth(hl->fontSize() / 10.0), 1);
03504               }
03505               if (hl->baselineOffset() != 0)
03506                      Upos += (hl->fontSize() / 10.0) * (hl->baselineOffset() / 1000.0);
03507               if (hl->fillColor() != CommonStrings::None)
03508               {
03509                      PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03510                      PS_setdash(Qt::SolidLine, 0, dum);
03511                      SetFarbe(hl->fillColor(), hl->fillShade(), &h, &s, &v, &k, gcr);
03512                      PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03513               }
03514               PS_setlinewidth(lw);
03515               PS_moveto(x+hl->glyph.xoffset-kern, -y-hl->glyph.yoffset+Upos);
03516               PS_lineto(x+hl->glyph.xoffset+Ulen, -y-hl->glyph.yoffset+Upos);
03517               putColor(hl->fillColor(), hl->fillShade(), false);
03518        }
03519        if (((hl->effects() & 8) && (chstr != QChar(13)))  || ((hl->effects() & 512) && (!chstr[0].isSpace())))
03520        {
03521               double Ulen = hl->font().charWidth(chstr[0], hl->fontSize()) * (hl->scaleH() / 1000.0);
03522               double Upos, lw, kern;
03523               if (hl->effects() & 16384)
03524                      kern = 0;
03525               else
03526                      kern = hl->fontSize() * hl->tracking() / 10000.0;
03527               if ((hl->underlineOffset() != -1) || (hl->underlineWidth() != -1))
03528               {
03529                      if (hl->underlineOffset() != -1)
03530                             Upos = (hl->underlineOffset() / 1000.0) * (hl->font().descent(hl->fontSize() / 10.0));
03531                      else
03532                             Upos = hl->font().underlinePos(hl->fontSize() / 10.0);
03533                      if (hl->underlineWidth() != -1)
03534                             lw = (hl->underlineWidth() / 1000.0) * (hl->fontSize() / 10.0);
03535                      else
03536                             lw = QMAX(hl->font().strokeWidth(hl->fontSize() / 10.0), 1);
03537               }
03538               else
03539               {
03540                      Upos = hl->font().underlinePos(hl->fontSize() / 10.0);
03541                      lw = QMAX(hl->font().strokeWidth(hl->fontSize() / 10.0), 1);
03542               }
03543               if (hl->baselineOffset() != 0)
03544                      Upos += (hl->fontSize() / 10.0) * (hl->baselineOffset() / 1000.0);
03545               if (hl->fillColor() != CommonStrings::None)
03546               {
03547                      PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03548                      PS_setdash(Qt::SolidLine, 0, dum);
03549                      SetFarbe(hl->fillColor(), hl->fillShade(), &h, &s, &v, &k, gcr);
03550                      PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03551               }
03552               PS_setlinewidth(lw);
03553               PS_moveto(x+hl->glyph.xoffset-kern, -y-hl->glyph.yoffset+Upos);
03554               PS_lineto(x+hl->glyph.xoffset+Ulen, -y-hl->glyph.yoffset+Upos);
03555               putColor(hl->fillColor(), hl->fillShade(), false);
03556        }
03557        if (hl->effects() & 8192)
03558        {
03559               int chs = hl->fontSize();
03560               GlyphLayout dummy;
03561               ite->layoutGlyphs(*hl, chstr, dummy);
03562               // chs = ???
03563               double wide = hl->font().charWidth(chstr[0], chs) * (hl->scaleH() / 1000.0);
03564               chstr = "-";
03565               if (hl->font().canRender(chstr[0]))
03566               {
03567                      uint gl = hl->font().char2CMap(chstr[0]);
03568                      FPointArray gly = hl->font().glyphOutline(gl);
03569                      QWMatrix chma;
03570                      chma.scale(tsz / 100.0, tsz / 100.0);
03571                      gly.map(chma);
03572                      chma = QWMatrix();
03573                      chma.scale(hl->scaleH() / 1000.0, hl->scaleV() / 1000.0);
03574                      gly.map(chma);
03575                      if (hl->fillColor() != CommonStrings::None)
03576                      {
03577                             PS_save();
03578                             PS_newpath();
03579                             PS_translate(x + hl->glyph.xoffset+wide, (y + hl->glyph.yoffset - (tsz / 10.0)) * -1);
03580                             SetFarbe(hl->fillColor(), hl->fillShade(), &h, &s, &v, &k, gcr);
03581                             PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03582                             SetClipPath(&gly);
03583                             PS_closepath();
03584                             putColor(hl->fillColor(), hl->fillShade(), true);
03585                             PS_restore();
03586                      }
03587               }
03588        }
03589 #else
03590        const CharStyle & cstyle(*hl);
03591        const GlyphLayout & glyphs(hl->glyph);
03592        uint glyph = glyphs.glyph;
03593 
03594        int h, s, v, k, tsz;
03595        double wideR = 0.0;
03596        QValueList<double> dum;
03597        dum.clear();
03598 
03599        QString chstr = hl->ch;
03600 
03601        tsz = cstyle.fontSize();
03602 
03603 /*     if (cstyle.effects() & ScStyle_DropCap)
03604        {
03605 //            QString chstr; // dummy, FIXME: replace by glyph
03606               if (pstyle.lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing)
03607                      tsz = qRound(10 * ((Doc->typographicSettings.valueBaseGrid *  (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (cstyle.font().realCharHeight(chstr[0], 10))));
03608               else
03609               {
03610                      if (pstyle.lineSpacingMode() == ParagraphStyle::FixedLineSpacing)
03611                             tsz = qRound(10 * ((pstyle.lineSpacing() *  (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / (cstyle.font().realCharHeight(chstr[0], 10))));
03612                      else
03613                      {
03614                             double currasce = cstyle.font().height(pstyle.charStyle().fontSize());
03615                             tsz = qRound(10 * ((currasce * (pstyle.dropCapLines()-1)+(cstyle.font().ascent(pstyle.charStyle().fontSize() / 10.0))) / cstyle.font().realCharHeight(chstr[0], 10)));
03616                      }
03617               }
03618        }
03619        */
03620        if ((hl->ch == SpecialChars::OBJECT) && (hl->embedded.hasItem()))
03621        {
03622               QPtrList<PageItem> emG = hl->embedded.getGroupedItems();
03623               QPtrStack<PageItem> groupStack;
03624               for (uint em = 0; em < emG.count(); ++em)
03625               {
03626                      PageItem* embedded = emG.at(em);
03627                      if (embedded->isGroupControl)
03628                      {
03629                             PS_save();
03630                             FPointArray cl = embedded->PoLine.copy();
03631                             QWMatrix mm;
03632                             mm.translate(x + hl->glyph.xoffset + embedded->gXpos * (cstyle.scaleH() / 1000.0), (y + hl->glyph.yoffset - (embedded->gHeight * (cstyle.scaleV() / 1000.0)) + embedded->gYpos * (cstyle.scaleV() / 1000.0)));
03633                             if (cstyle.baselineOffset() != 0)
03634                                    mm.translate(0, embedded->gHeight * (cstyle.baselineOffset() / 1000.0));
03635                             if (cstyle.scaleH() != 1000)
03636                                    mm.scale(cstyle.scaleH() / 1000.0, 1);
03637                             if (cstyle.scaleV() != 1000)
03638                                    mm.scale(1, cstyle.scaleV() / 1000.0);
03639                             mm.rotate(embedded->rotation());
03640                             cl.map( mm );
03641                             SetClipPath(&cl);
03642                             PS_closepath();
03643                             PS_clip(true);
03644                             groupStack.push(embedded->groupsLastItem);
03645                             continue;
03646                      }
03647                      PS_save();
03648                      PS_translate(x + hl->glyph.xoffset + embedded->gXpos * (cstyle.scaleH() / 1000.0), (y + hl->glyph.yoffset - (embedded->gHeight * (cstyle.scaleV() / 1000.0)) + embedded->gYpos * (cstyle.scaleV() / 1000.0)) * -1);
03649                      if (cstyle.baselineOffset() != 0)
03650                             PS_translate(0, embedded->gHeight * (cstyle.baselineOffset() / 1000.0));
03651                      if (cstyle.scaleH() != 1000)
03652                             PS_scale(cstyle.scaleH() / 1000.0, 1);
03653                      if (cstyle.scaleV() != 1000)
03654                             PS_scale(1, cstyle.scaleV() / 1000.0);
03655                      ProcessItem(Doc, pg, embedded, argh, sep, farb, ic, gcr, master, true);
03656                      PS_restore();
03657                      if (groupStack.count() != 0)
03658                      {
03659                             while (embedded == groupStack.top())
03660                             {
03661                                    PS_restore();
03662                                    groupStack.pop();
03663                             }
03664                      }
03665               }
03666               return;
03667        }
03668 
03669        if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBSPACE.unicode()) ||
03670               glyph == (ScFace::CONTROL_GLYPHS + 32)) 
03671        {
03672               glyph = cstyle.font().char2CMap(QChar(' '));
03673               chstr = " ";
03674        }
03675        else if (glyph == (ScFace::CONTROL_GLYPHS + SpecialChars::NBHYPHEN.unicode()))
03676        {
03677               glyph = cstyle.font().char2CMap(QChar('-'));
03678               chstr = "-";
03679        }
03680        
03681        if (glyph < ScFace::CONTROL_GLYPHS)
03682        {
03683               if (((cstyle.effects() & ScStyle_Underline)) //FIXME && (chstr != QChar(13)))  
03684                      || ((cstyle.effects() & ScStyle_UnderlineWords) && (!chstr[0].isSpace()))) 
03685               {
03686        //            double Ulen = cstyle.font().glyphWidth(glyph, cstyle.fontSize()) * glyphs.scaleH;
03687                      double Ulen = glyphs.xadvance;
03688                      double Upos, lw, kern;
03689                      if (cstyle.effects() & ScStyle_StartOfLine)
03690                             kern = 0;
03691                      else
03692                             kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
03693                      if ((cstyle.underlineOffset() != -1) || (cstyle.underlineWidth() != -1))
03694                      {
03695                             if (cstyle.underlineOffset() != -1)
03696                                    Upos = (cstyle.underlineOffset() / 1000.0) * (cstyle.font().descent(cstyle.fontSize() / 10.0));
03697                             else
03698                                    Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
03699                             if (cstyle.underlineWidth() != -1)
03700                                    lw = (cstyle.underlineWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
03701                             else
03702                                    lw = QMAX(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1);
03703                      }
03704                      else
03705                      {
03706                             Upos = cstyle.font().underlinePos(cstyle.fontSize() / 10.0);
03707                             lw = QMAX(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1);
03708                      }
03709                      if (cstyle.baselineOffset() != 0)
03710                             Upos += (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0);
03711                      if (cstyle.fillColor() != CommonStrings::None)
03712                      {
03713                             PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03714                             PS_setdash(Qt::SolidLine, 0, dum);
03715                             SetFarbe(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
03716                             PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03717                      }
03718                      PS_setlinewidth(lw);
03719                      if (cstyle.effects() & ScStyle_Subscript)
03720                      {
03721                             PS_moveto(x + glyphs.xoffset-kern, -y - glyphs.yoffset+Upos);
03722                             PS_lineto(x + glyphs.xoffset+Ulen, -y - glyphs.yoffset+Upos);
03723                      }
03724                      else
03725                      {
03726                             PS_moveto(x + glyphs.xoffset-kern, -y + Upos);
03727                             PS_lineto(x + glyphs.xoffset+Ulen, -y + Upos);
03728                      }
03729                      putColor(cstyle.fillColor(), cstyle.fillShade(), false);
03730               }
03731               /* Subset all TTF Fonts until the bug in the TTF-Embedding Code is fixed */
03732               ScFace::FontType ftype = cstyle.font().type();
03733               if ((ftype == ScFace::TTF) || (cstyle.font().isOTF()) || (cstyle.font().subset()))
03734               {
03735                      if (glyph != 0 && glyph != cstyle.font().char2CMap(QChar(' ')))
03736                      {
03737                             PS_save();
03738                             if (ite->reversed())
03739                             {
03740                                    PS_translate(x + hl->glyph.xoffset, (y + hl->glyph.yoffset - (tsz / 10.0)) * -1);
03741                                    PS_scale(-1, 1);
03742                                    PS_translate(-glyphs.xadvance, 0);
03743                             }
03744                             else
03745                                    PS_translate(x + glyphs.xoffset, (y + glyphs.yoffset - (cstyle.fontSize() / 10.0)) * -1);
03746                             if (cstyle.baselineOffset() != 0)
03747                                    PS_translate(0, (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
03748                             if (glyphs.scaleH != 1.0)
03749                                    PS_scale(glyphs.scaleH, 1);
03750                             if (glyphs.scaleV != 1.0)
03751                             {
03752                                    PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * (glyphs.scaleV)));
03753                                    PS_scale(1, glyphs.scaleV);
03754                             }
03755                             if (cstyle.fillColor() != CommonStrings::None)
03756                             {
03757                                    SetFarbe(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
03758                                    PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03759                             if ((colorsToUse[cstyle.fillColor()].isSpotColor()) && (!DoSep) && (useSpotColors))
03760                                    PutSeite(ToStr(cstyle.fillShade() / 100.0)+" "+spotMap[cstyle.fillColor()]);
03761                                    else
03762                                           PutSeite(FillColor + " cmyk");
03763                                    PS_showSub(glyph, cstyle.font().psName().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ), tsz / 10.0, false);
03764                             }
03765                             PS_restore();
03766                      }
03767               }
03768               else if (glyph != 0)
03769               {
03770                      PS_selectfont(cstyle.font().replacementName(), tsz / 10.0);
03771                      PS_save();
03772                      PS_translate(x + glyphs.xoffset, -y - glyphs.yoffset);
03773                      if (ite->reversed())
03774                      {
03775                             PS_scale(-1, 1);
03776                             PS_translate(glyphs.xadvance, 0);
03777                      }
03778                      if (cstyle.baselineOffset() != 0)
03779                             PS_translate(0, (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
03780                      if (glyphs.scaleH != 1.0 || glyphs.scaleV != 1.0)
03781                             PS_scale(glyphs.scaleH, glyphs.scaleV);
03782                      if (cstyle.fillColor() != CommonStrings::None)
03783                      {
03784                             SetFarbe(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
03785                             PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03786                             if ((colorsToUse[cstyle.fillColor()].isSpotColor()) && (!DoSep) && (useSpotColors))
03787                             {
03788                                    PutSeite(ToStr(cstyle.fillShade() / 100.0)+" "+spotMap[cstyle.fillColor()]);
03789                                    PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, true);
03790                             }
03791                             else
03792                                    PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, false);
03793                      }
03794                      PS_restore();
03795               }
03796               if ((cstyle.effects() & ScStyle_Outline) || glyph == 0)//&& (chstr != QChar(13)))
03797               {
03798 //            if (cstyle.font().canRender(chstr[0]))
03799                      {
03800                             FPointArray gly = cstyle.font().glyphOutline(glyph);
03801                             QWMatrix chma, chma2, chma3;
03802                             chma.scale(tsz / 100.0, tsz / 100.0);
03803                             chma2.scale(glyphs.scaleH, glyphs.scaleV);
03804                             if (cstyle.baselineOffset() != 0)
03805                                    chma3.translate(0, -(cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0));
03806                             gly.map(chma * chma2 * chma3);
03807                             if (ite->reversed())
03808                             {
03809                                    chma = QWMatrix();
03810                                    chma.scale(-1, 1);
03811                                    chma.translate(wideR, 0);
03812                                    gly.map(chma);
03813                             }
03814                             if ((cstyle.strokeColor() != CommonStrings::None) && ((tsz * cstyle.outlineWidth() / 10000.0) != 0))
03815                             {
03816                                    PS_save();
03817                                    PS_setlinewidth(tsz * cstyle.outlineWidth() / 10000.0);
03818                                    PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03819                                    PS_setdash(Qt::SolidLine, 0, dum);
03820                                    PS_translate(x + glyphs.xoffset, (y + glyphs.yoffset - (tsz / 10.0)) * -1);
03821                                    PS_translate(0, -((tsz / 10.0) - (tsz / 10.0) * glyphs.scaleV));
03822                                    SetFarbe(cstyle.strokeColor(), cstyle.strokeShade(), &h, &s, &v, &k, gcr);
03823                                    PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03824                                    SetClipPath(&gly);
03825                                    PS_closepath();
03826                                    putColor(cstyle.strokeColor(), cstyle.strokeShade(), false);
03827                                    PS_restore();
03828                             }
03829                      }
03830               }
03831               if ((cstyle.effects() & ScStyle_Strikethrough))//&& (chstr != QChar(13)))
03832               {
03833                      //            double Ulen = cstyle.font().glyphWidth(glyph, cstyle.fontSize()) * glyphs.scaleH;
03834                      double Ulen = glyphs.xadvance;
03835                      double Upos, lw, kern;
03836                      if (cstyle.effects() & 16384)
03837                             kern = 0;
03838                      else
03839                             kern = cstyle.fontSize() * cstyle.tracking() / 10000.0;
03840                      if ((cstyle.strikethruOffset() != -1) || (cstyle.strikethruWidth() != -1))
03841                      {
03842                             if (cstyle.strikethruOffset() != -1)
03843                                    Upos = (cstyle.strikethruOffset() / 1000.0) * (cstyle.font().ascent(cstyle.fontSize() / 10.0));
03844                             else
03845                                    Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
03846                             if (cstyle.strikethruWidth() != -1)
03847                                    lw = (cstyle.strikethruWidth() / 1000.0) * (cstyle.fontSize() / 10.0);
03848                             else
03849                                    lw = QMAX(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1);
03850                      }
03851                      else
03852                      {
03853                             Upos = cstyle.font().strikeoutPos(cstyle.fontSize() / 10.0);
03854                             lw = QMAX(cstyle.font().strokeWidth(cstyle.fontSize() / 10.0), 1);
03855                      }
03856                      if (cstyle.baselineOffset() != 0)
03857                             Upos += (cstyle.fontSize() / 10.0) * (cstyle.baselineOffset() / 1000.0);
03858                      if (cstyle.fillColor() != CommonStrings::None)
03859                      {
03860                             PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
03861                             PS_setdash(Qt::SolidLine, 0, dum);
03862                             SetFarbe(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
03863                             PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03864                      }
03865                      PS_setlinewidth(lw);
03866                      PS_moveto(x + glyphs.xoffset-kern, -y-glyphs.yoffset+Upos);
03867                      PS_lineto(x + glyphs.xoffset+Ulen, -y-glyphs.yoffset+Upos);
03868                      putColor(cstyle.fillColor(), cstyle.fillShade(), false);
03869               }
03870        }
03871        if (glyphs.more) {
03872               // ugly hack until setTextCh interface is changed
03873               ScText hl2(*hl);
03874               hl2.glyph = *glyphs.more;
03875               setTextCh(Doc, ite, x + glyphs.xadvance, y, gcr, argh, doh, &hl2, pstyle, pg, sep, farb, ic, master);
03876               // don't let hl2's destructor delete these!
03877               hl2.glyph.more = 0;
03878        }
03879 /*     if (cstyle.effects() & ScStyle_SmartHyphenVisible)
03880        {
03881               int chs = cstyle.fontSize();
03882 //            double wide = cstyle.font().charWidth(chstr[0], chs) * (cstyle.scaleH() / 1000.0);
03883 //            chstr = "-";
03884 //            if (cstyle.font().canRender(chstr[0]))
03885               {
03886                      FPointArray gly = cstyle.font().glyphOutline(glyph);
03887                      QWMatrix chma;
03888                      chma.scale(tsz / 100.0, tsz / 100.0);
03889                      gly.map(chma);
03890                      chma = QWMatrix();
03891                      chma.scale(glyphs.scaleH, glyphs.scaleV);
03892                      gly.map(chma);
03893                      if (cstyle.fillColor() != CommonStrings::None)
03894                      {
03895                             PS_save();
03896                             PS_newpath();
03897                             PS_translate(x + glyphs.xoffset + glyphs.xadvance, (y + glyphs.yoffset - (tsz / 10.0)) * -1);
03898                             SetFarbe(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
03899                             PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
03900                             SetClipPath(&gly);
03901                             PS_closepath();
03902                             putColor(cstyle.fillColor(), cstyle.fillShade(), true);
03903                             PS_restore();
03904                      }
03905               }
03906        }*/
03907 #endif
03908 }
03909 
03910 void PSLib::putColor(const QString& color, int shade, bool fill)
03911 {
03912        if (fill)
03913        {
03914               if (((colorsToUse[color].isSpotColor()) || (colorsToUse[color].isRegistrationColor())) && (useSpotColors))
03915               {
03916                      if (!DoSep)
03917                             PS_fillspot(color, shade);
03918                      else
03919                      {
03920                             if ((color == currentSpot) || (colorsToUse[color].isRegistrationColor()))
03921                             {
03922                                    if (fillRule)
03923                                           PutSeite("0 0 0 "+ToStr(shade / 100.0)+" cmyk eofill\n");
03924                                    else
03925                                           PutSeite("0 0 0 "+ToStr(shade / 100.0)+" cmyk fill\n");
03926                             }
03927                      }
03928               }
03929               else
03930               {
03931                      if (DoSep)
03932                      {
03933                             if ((Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
03934                                    PS_fill();
03935                      }
03936                      else
03937                             PS_fill();
03938               }
03939        }
03940        else
03941        {
03942               if (((colorsToUse[color].isSpotColor()) || (colorsToUse[color].isRegistrationColor())) && (useSpotColors))
03943               {
03944                      if (!DoSep)
03945                             PS_strokespot(color, shade);
03946                      else
03947                      {
03948                             if ((color == currentSpot) || (colorsToUse[color].isRegistrationColor()))
03949                                    PutSeite("0 0 0 "+ToStr(shade / 100.0)+" cmyk st\n");
03950                      }
03951               }
03952               else
03953               {
03954                      if (DoSep)
03955                      {
03956                             if ((Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
03957                                    PS_stroke();
03958                      }
03959                      else
03960                             PS_stroke();
03961               }
03962        }
03963 }
03964 
03965 void PSLib::SetClipPath(FPointArray *c, bool poly)
03966 {
03967        FPoint np, np1, np2;
03968        bool nPath = true;
03969        if (c->size() > 3)
03970        {
03971               for (uint poi=0; poi<c->size()-3; poi += 4)
03972               {
03973                      if (c->point(poi).x() > 900000)
03974                      {
03975                             if (poly)
03976                                    PS_closepath();
03977                             nPath = true;
03978                             continue;
03979                      }
03980                      if (nPath)
03981                      {
03982                             np = c->point(poi);
03983                             PS_moveto(np.x(), -np.y());
03984                             nPath = false;
03985                      }
03986                      np = c->point(poi+1);
03987                      np1 = c->point(poi+3);
03988                      np2 = c->point(poi+2);
03989                      PS_curve(np.x(), -np.y(), np1.x(), -np1.y(), np2.x(), -np2.y());
03990               }
03991        }
03992 }
03993 
03994 void PSLib::cancelRequested()
03995 {
03996        abortExport=true;
03997 }