Author: jghali
Date: Mon Apr  6 20:50:38 2020
New Revision: 23557

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23557
Log:
Refactoring and cleanups for PSLib

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
    trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/pslib.h
    trunk/Scribus/scribus/scprintengine_gdi.cpp
    trunk/Scribus/scribus/scprintengine_ps.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/preview.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp   (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objprinter.cpp   Mon Apr  6 
20:50:38 2020
@@ -415,6 +415,7 @@
        options.toFile    = fil;
        options.separationName = SepName;
        options.outputSeparations = SepName != QString("No");
+       options.useSpotColors = true;
        options.useColor = self->color;
        options.mirrorH  = self->mph;
        options.mirrorV  = self->mpv;
@@ -423,14 +424,14 @@
        options.bleedMarks = false;
        options.registrationMarks = false;
        options.colorMarks = false;
+       options.includePDFMarks = false;
        options.markOffset = 0.0;
        options.bleeds.set(0, 0, 0, 0);
        if (!PrinterUtil::checkPrintEngineSupport(options.printer, 
options.prnEngine, options.toFile))
                options.prnEngine = 
PrinterUtil::getDefaultPrintEngine(options.printer, options.toFile);
        printcomm = PyUnicode_asQString(self->cmd);
-       QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
-       ReallyUsed.clear();
-       ScCore->primaryMainWindow()->doc->getUsedFonts(ReallyUsed);
+
+       ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
 
 #if defined(_WIN32)
        if (!options.toFile)
@@ -440,7 +441,7 @@
                if ( PrinterUtil::getDefaultSettings(prn, options.devMode) )
                {
                        ScPrintEngine_GDI winPrint;
-                       printDone = winPrint.print( 
*ScCore->primaryMainWindow()->doc, options );
+                       printDone = winPrint.print( *currentDoc, options );
                }
                if (!printDone)
                        PyErr_SetString(PyExc_SystemError, "Printing failed");
@@ -448,26 +449,26 @@
        }
 #endif
 
-       PSLib *dd = new PSLib(options, true, 
PrefsManager::instance().appPrefs.fontPrefs.AvailFonts, ReallyUsed, 
ScCore->primaryMainWindow()->doc->PageColors, false, true);
+       PSLib *dd = new PSLib(currentDoc, options, PSLib::OutputPS, 
&currentDoc->PageColors);
        if (dd != nullptr)
        {
                if (!fil)
-                       fna = 
QDir::toNativeSeparators(ScPaths::tempFileDir()+"/tmp.ps");
+                       fna = QDir::toNativeSeparators(ScPaths::tempFileDir() + 
"/tmp.ps");
                PSfile = dd->PS_set_file(fna);
                fna = QDir::toNativeSeparators(fna);
                if (PSfile)
                {
                        options.setDevParam = false;
                        options.doClip = false;
-                       dd->CreatePS(ScCore->primaryMainWindow()->doc, options);
+                       dd->createPS(options);
                        if (options.prnEngine == PostScript1 || 
options.prnEngine == PostScript2)
                        {
                                if (ScCore->haveGS())
                                {
                                        QString tmp;
                                        QStringList opts;
-                                       opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(ScCore->primaryMainWindow()->doc->pageWidth()))
 );
-                                       opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(ScCore->primaryMainWindow()->doc->pageHeight()))
 );
+                                       opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(currentDoc->pageWidth())) );
+                                       opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(currentDoc->pageHeight())) );
                                        convertPS2PS(fna, fna+".tmp", opts, 
options.prnEngine);
                                        moveFile( fna + ".tmp", fna );
                                }

Modified: trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.cpp      
(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin_py2x/objprinter.cpp      Mon Apr 
 6 20:50:38 2020
@@ -428,9 +428,8 @@
        if (!PrinterUtil::checkPrintEngineSupport(options.printer, 
options.prnEngine, options.toFile))
                options.prnEngine = 
PrinterUtil::getDefaultPrintEngine(options.printer, options.toFile);
        printcomm = QString(PyString_AsString(self->cmd));
-       QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
-       ReallyUsed.clear();
-       ScCore->primaryMainWindow()->doc->getUsedFonts(ReallyUsed);
+       
+       ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
 
 #if defined(_WIN32)
        if (!options.toFile)
@@ -440,7 +439,7 @@
                if ( PrinterUtil::getDefaultSettings(prn, options.devMode) )
                {
                        ScPrintEngine_GDI winPrint;
-                       printDone = winPrint.print( 
*ScCore->primaryMainWindow()->doc, options );
+                       printDone = winPrint.print( *currentDoc, options );
                }
                if (!printDone)
                        PyErr_SetString(PyExc_SystemError, "Printing failed");
@@ -448,7 +447,7 @@
        }
 #endif
 
-       PSLib *dd = new PSLib(options, true, 
PrefsManager::instance().appPrefs.fontPrefs.AvailFonts, ReallyUsed, 
ScCore->primaryMainWindow()->doc->PageColors, false, true);
+       PSLib *dd = new PSLib(options, PSLib::OutputPS, 
&currentDoc->PageColors);
        if (dd != nullptr)
        {
                if (!fil)
@@ -459,15 +458,15 @@
                {
                        options.setDevParam = false;
                        options.doClip = false;
-                       dd->CreatePS(ScCore->primaryMainWindow()->doc, options);
+                       dd->CreatePS(options);
                        if (options.prnEngine == PostScript1 || 
options.prnEngine == PostScript2)
                        {
                                if (ScCore->haveGS())
                                {
                                        QString tmp;
                                        QStringList opts;
-                                       opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(ScCore->primaryMainWindow()->doc->pageWidth()))
 );
-                                       opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(ScCore->primaryMainWindow()->doc->pageHeight()))
 );
+                                       opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(currentDoc->pageWidth())) );
+                                       opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(currentDoc->pageHeight())) );
                                        convertPS2PS(fna, fna+".tmp", opts, 
options.prnEngine);
                                        moveFile( fna + ".tmp", fna );
                                }

Modified: trunk/Scribus/scribus/pslib.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp     (original)
+++ trunk/Scribus/scribus/pslib.cpp     Mon Apr  6 20:50:38 2020
@@ -68,7 +68,6 @@
        ScribusDoc* m_Doc;
        uint m_argh;
        ScPage* m_page;
-       bool m_sep;
        bool m_farb;
        bool m_master;
        PSLib* m_ps;
@@ -84,12 +83,10 @@
        }
 
 public:
-       PSPainter(ScribusDoc* Doc, uint argh, ScPage* page, bool sep, bool 
farb, bool master, PSLib* ps):
+       PSPainter(ScribusDoc* Doc, uint argh, ScPage* page, bool master, PSLib* 
ps):
                m_Doc(Doc),
                m_argh(argh),
                m_page(page),
-               m_sep(sep),
-               m_farb(farb),
                m_master(master),
                m_ps(ps)
        {}
@@ -234,57 +231,46 @@
        applyTransform();
        if (scaleH() != 1 || scaleV() != 1)
                m_ps->PS_scale(scaleH(), scaleV());
-       m_ps->ProcessItem(m_Doc, m_page, item, m_argh, m_sep, m_farb, m_master, 
true);
+       m_ps->ProcessItem(m_page, item, m_argh, m_master, true);
        m_ps->PS_restore();
 }
 
-PSLib::PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, 
QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool 
pdf, bool spot)
+PSLib::PSLib(ScribusDoc* doc, PrintOptions &options, OutputFormat outputFmt, 
ColorList *docColors)
+       : m_Doc(doc), m_outputFormat(outputFmt)
 {
        Options = options;
-       optimization = OptimizeCompat;
-       m_Doc = nullptr;
-       progressDialog = nullptr;
-       abortExport = false;
-       PageIndex = 0;
        User = "";
        Creator = "Scribus" + QString(VERSION);
-       Titel = "";
+       Title = "";
        FillColor = "0.0 0.0 0.0 0.0";
        StrokeColor = "0.0 0.0 0.0 0.0";
-       Header = psart ? "%!PS-Adobe-3.0\n" : "%!PS-Adobe-3.0 EPSF-3.0\n";
        BBox = "";
        BBoxH = "";
-       psExport = psart;
-       isPDF = pdf;
-       UsedFonts.clear();
-       Fonts = "";
        FontDesc = "";
-       GraySc = false;
-       DoSep = false;
-       abortExport = false;
-       useSpotColors = spot;
-       GrayCalc =  "/setcmykcolor {exch 0.11 mul add exch 0.59 mul add exch 
0.3 mul add\n";
-       GrayCalc += "               dup 1 gt {pop 1} if 1 exch sub oldsetgray} 
bind def\n";
-       GrayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul 
add\n";
-       GrayCalc += "              oldsetgray} bind def\n";
        Farben = "";
        FNamen = "";
+
        CMYKColorF cmykValues;
-       ColorList::Iterator itf;
        double c, m, y, k;
        int spotCount = 1;
-       bool erst = true;
-       colorsToUse = DocColors;
+       bool first = true;
        spotMap.clear();
-       colorDesc = "";
-       for (itf = DocColors.begin(); itf != DocColors.end(); ++itf)
-       {
-               if (((itf->isSpotColor()) || (itf->isRegistrationColor())) && 
(useSpotColors))
-               {
-                       ScColorEngine::getCMYKValues(*itf, 
DocColors.document(), cmykValues);
+       colorDesc.clear();
+
+       if (docColors != nullptr)
+               colorsToUse = *docColors;
+       else
+               m_Doc->getUsedColors(colorsToUse);
+       colorsToUse.setDocument(m_Doc);
+
+       for (auto itf = colorsToUse.begin(); itf != colorsToUse.end(); ++itf)
+       {
+               if (((itf->isSpotColor()) || (itf->isRegistrationColor())) && 
(Options.useSpotColors))
+               {
+                       ScColorEngine::getCMYKValues(*itf, 
colorsToUse.document(), cmykValues);
                        cmykValues.getValues(c, m, y, k);
-                       colorDesc += "/Spot"+QString::number(spotCount)+" { [ 
/Separation (";
-                       if (DocColors[itf.key()].isRegistrationColor())
+                       colorDesc += "/Spot" + QString::number(spotCount) + " { 
[ /Separation (";
+                       if (itf->isRegistrationColor())
                                colorDesc += "All";
                        else
                                colorDesc += itf.key();
@@ -296,11 +282,11 @@
                        spotMap.insert(itf.key(), "Spot" + 
QString::number(spotCount));
                        ++spotCount;
                }
-               if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && 
(itf.key() != "Yellow") && (itf.key() != "Black") && 
DocColors[itf.key()].isSpotColor())
-               {
-                       ScColorEngine::getCMYKValues(DocColors[itf.key()], 
DocColors.document(), cmykValues);
+               if ((itf.key() != "Cyan") && (itf.key() != "Magenta") && 
(itf.key() != "Yellow") && (itf.key() != "Black") && itf->isSpotColor())
+               {
+                       ScColorEngine::getCMYKValues(colorsToUse[itf.key()], 
colorsToUse.document(), cmykValues);
                        cmykValues.getValues(c, m, y, k);
-                       if (!erst)
+                       if (!first)
                        {
                                Farben += "%%+ ";
                                FNamen += "%%+ ";
@@ -308,18 +294,21 @@
                        Farben += ToStr(c) + " " + ToStr(m) + " ";
                        Farben += ToStr(y) + " " + ToStr(k) + " (" + itf.key() 
+ ")\n";
                        FNamen += "(" + itf.key() + ")\n";
-                       erst = false;
-               }
-       }
+                       first = false;
+               }
+       }
+
        QMap<QString, QString> psNameMap;
-       QMap<QString, QMap<uint, FPointArray> >::Iterator it;
-//     int a = 0;
-       for (it = DocFonts.begin(); it != DocFonts.end(); ++it)
+       SCFonts& allFonts = 
PrefsManager::instance().appPrefs.fontPrefs.AvailFonts;
+       QMap<QString, QMap<uint, FPointArray> > docFonts;
+       doc->getUsedFonts(docFonts);
+
+       for (auto it = docFonts.begin(); it != docFonts.end(); ++it)
        {
                // Subset all TTF Fonts until the bug in the TTF-Embedding Code 
is fixed
                // Subset also font whose postscript name conflicts with an 
already used font
                // Subset always now with new boxes code.
-               ScFace &face (AllFonts[it.key()]);
+               ScFace &face (allFonts[it.key()]);
                QMap<uint, FPointArray>& RealGlyphs(it.value());
                QString encodedName = face.psName().simplified().replace( 
QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" );
 
@@ -370,55 +359,6 @@
 
                psNameMap.insert(encodedName, face.scName());
        }
-       Prolog = "%%BeginProlog\n";
-       Prolog += "/Scribusdict 100 dict def\n";
-       Prolog += "Scribusdict begin\n";
-       Prolog += "/sp {showpage} bind def\n";
-       Prolog += "/oldsetgray /setgray load def\n";
-       Prolog += "/cmyk {setcmykcolor} def\n";
-       Prolog += "/m {moveto} bind def\n";
-       Prolog += "/l {lineto} bind def\n";
-       Prolog += "/li {lineto} bind def\n";
-       Prolog += "/cu {curveto} bind def\n";
-       Prolog += "/cl {closepath} bind def\n";
-       Prolog += "/gs {gsave} bind def\n";
-       Prolog += "/gr {grestore} bind def\n";
-       Prolog += "/tr {translate} bind def\n";
-       Prolog += "/ro {rotate} bind def\n";
-       Prolog += "/sh {show} bind def\n";
-       Prolog += "/shg {setcmykcolor moveto glyphshow} def\n";
-       Prolog += "/shgsp {moveto glyphshow} def\n";
-       Prolog += "/sc {scale} bind def\n";
-       Prolog += "/se {selectfont} bind def\n";
-       Prolog += "/sf {setfont} bind def\n";
-       Prolog += "/sw {setlinewidth} bind def\n";
-       Prolog += "/f  {findfont} bind def\n";
-       Prolog += "/fi {fill} bind def\n";
-       Prolog += "/st {stroke} bind def\n";
-       Prolog += "/shgf {gs dup scale begin cvx exec fill end gr} bind def\n";
-       Prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup 
scale\n";
-       Prolog += "       begin cvx exec st end gr} bind def\n";
-       Prolog += "/bEPS {\n";
-       Prolog += "    /b4_Inc_state save def\n";
-       Prolog += "    /dict_count countdictstack def\n";
-       Prolog += "    /op_count count 1 sub def\n";
-       Prolog += "    userdict begin\n";
-       Prolog += "    /showpage { } def\n";
-       Prolog += "    0 setgray 0 setlinecap\n";
-       Prolog += "    1 setlinewidth 0 setlinejoin\n";
-       Prolog += "    10 setmiterlimit [ ] 0 setdash newpath\n";
-       Prolog += "    /languagelevel where\n";
-       Prolog += "    {pop languagelevel\n";
-       Prolog += "    1 ne\n";
-       Prolog += "    {false setstrokeadjust false setoverprint\n";
-       Prolog += "    } if } if } bind def\n";
-       Prolog += "/eEPS { count op_count sub {pop} repeat\n";
-       Prolog += "    countdictstack dict_count sub {end} repeat\n";
-       Prolog += "    b4_Inc_state restore } bind def\n";
-       Prolog += "    end\n";
-       if ((Options.cropMarks) || (Options.bleedMarks) || 
(Options.registrationMarks) || (Options.colorMarks))
-               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";
-       Prolog += "%%EndProlog\n";
 }
 
 PSLib::~PSLib()
@@ -567,7 +507,7 @@
        if (art == "Creator")
                Creator = was;
        if (art == "Title")
-               Titel = was;
+               Title = was;
 }
 
 bool PSLib::PS_set_file(const QString& fn)
@@ -580,15 +520,15 @@
        return ret;
 }
 
-bool PSLib::PS_begin_doc(ScribusDoc *doc, double x, double y, double width, 
double height, int numpage, bool sep, bool farb)
-{
-       m_Doc = doc;
-       PutStream(Header);
+bool PSLib::PS_begin_doc(double x, double y, double width, double height, int 
numpage)
+{
+       QString header = (m_outputFormat == OutputPS) ? "%!PS-Adobe-3.0\n" : 
"%!PS-Adobe-3.0 EPSF-3.0\n";
+       PutStream(header);
        PutStream("%%For: " + User + "\n");
-       PutStream("%%Title: " + Titel + "\n");
+       PutStream("%%Title: " + Title + "\n");
        PutStream("%%Creator: " + Creator + "\n");
        PutStream("%%Pages: " + IToStr(numpage) + "\n");
-       if (width < height || !psExport)
+       if (width < height || (m_outputFormat == OutputEPS))
        {
                BBox = "%%BoundingBox: " + IToStr(qRound(x)) + " " + 
IToStr(qRound(y)) + " " + IToStr(qRound(width)) + " " + IToStr(qRound(height)) 
+ "\n";
                BBoxH = "%%HiResBoundingBox: " + ToStr(x) + " " + ToStr(y) + " 
" + ToStr(width) + " " + ToStr(height) + "\n";
@@ -606,26 +546,82 @@
                PutStream("%%CMYKCustomColor: "+Farben);
        PutStream("%%LanguageLevel: 3\n");
        PutStream("%%EndComments\n");
-       if (!psExport)
+       if (m_outputFormat == OutputEPS)
        {
                PutStream("%%BeginDefaults\n");
                PutStream("%%ViewingOrientation: 1 0 0 1\n");
                PutStream("%%EndDefaults\n");
        }
-       PutStream(Prolog);
+
+       QString prolog = "%%BeginProlog\n";
+       prolog += "/Scribusdict 100 dict def\n";
+       prolog += "Scribusdict begin\n";
+       prolog += "/sp {showpage} bind def\n";
+       prolog += "/oldsetgray /setgray load def\n";
+       prolog += "/cmyk {setcmykcolor} def\n";
+       prolog += "/m {moveto} bind def\n";
+       prolog += "/l {lineto} bind def\n";
+       prolog += "/li {lineto} bind def\n";
+       prolog += "/cu {curveto} bind def\n";
+       prolog += "/cl {closepath} bind def\n";
+       prolog += "/gs {gsave} bind def\n";
+       prolog += "/gr {grestore} bind def\n";
+       prolog += "/tr {translate} bind def\n";
+       prolog += "/ro {rotate} bind def\n";
+       prolog += "/sh {show} bind def\n";
+       prolog += "/shg {setcmykcolor moveto glyphshow} def\n";
+       prolog += "/shgsp {moveto glyphshow} def\n";
+       prolog += "/sc {scale} bind def\n";
+       prolog += "/se {selectfont} bind def\n";
+       prolog += "/sf {setfont} bind def\n";
+       prolog += "/sw {setlinewidth} bind def\n";
+       prolog += "/f  {findfont} bind def\n";
+       prolog += "/fi {fill} bind def\n";
+       prolog += "/st {stroke} bind def\n";
+       prolog += "/shgf {gs dup scale begin cvx exec fill end gr} bind def\n";
+       prolog += "/shgs {gs dup 1 exch div currentlinewidth mul sw dup 
scale\n";
+       prolog += "       begin cvx exec st end gr} bind def\n";
+       prolog += "/bEPS {\n";
+       prolog += "    /b4_Inc_state save def\n";
+       prolog += "    /dict_count countdictstack def\n";
+       prolog += "    /op_count count 1 sub def\n";
+       prolog += "    userdict begin\n";
+       prolog += "    /showpage { } def\n";
+       prolog += "    0 setgray 0 setlinecap\n";
+       prolog += "    1 setlinewidth 0 setlinejoin\n";
+       prolog += "    10 setmiterlimit [ ] 0 setdash newpath\n";
+       prolog += "    /languagelevel where\n";
+       prolog += "    {pop languagelevel\n";
+       prolog += "    1 ne\n";
+       prolog += "    {false setstrokeadjust false setoverprint\n";
+       prolog += "    } if } if } bind def\n";
+       prolog += "/eEPS { count op_count sub {pop} repeat\n";
+       prolog += "    countdictstack dict_count sub {end} repeat\n";
+       prolog += "    b4_Inc_state restore } bind def\n";
+       prolog += "    end\n";
+       if ((Options.cropMarks) || (Options.bleedMarks) || 
(Options.registrationMarks) || (Options.colorMarks))
+               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";
+       prolog += "%%EndProlog\n";
+       PutStream(prolog);
+
        PutStream("%%BeginSetup\n");
-       if (isPDF)
+       if (Options.includePDFMarks)
                PutStream("/pdfmark where {pop} {userdict /pdfmark /cleartomark 
load put} ifelse\n");
        if (!FontDesc.isEmpty())
                PutStream(FontDesc);
-       if ((!colorDesc.isEmpty()) && (!sep))
+       if ((!colorDesc.isEmpty()) && (!Options.outputSeparations))
                PutStream(colorDesc);
-//     PutStream("Scribusdict begin\n");
-       PutStream(Fonts);
        if (GraySc)
-               PutStream(GrayCalc);
-       Optimization optim = optimization;
-       optimization = OptimizeSize;
+       {
+               QString grayCalc =  "/setcmykcolor {exch 0.11 mul add exch 0.59 
mul add exch 0.3 mul add\n";
+               grayCalc += "               dup 1 gt {pop 1} if 1 exch sub 
oldsetgray} bind def\n";
+               grayCalc += "/setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 
mul add\n";
+               grayCalc += "              oldsetgray} bind def\n";
+               PutStream(grayCalc);
+       }
+               
+       Optimization optim = m_optimization;
+       m_optimization = OptimizeSize;
        QStringList patterns = 
m_Doc->getPatternDependencyList(m_Doc->getUsedPatterns());
        for (int c = 0; c < patterns.count(); ++c)
        {
@@ -633,7 +629,7 @@
                for (int em = 0; em < pa.items.count(); ++em)
                {
                        PageItem* item = pa.items.at(em);
-                       if ((item->asImageFrame()) && (item->imageIsAvailable) 
&& (!item->Pfile.isEmpty()) && (item->printEnabled()) && (!sep) && (farb))
+                       if ((item->asImageFrame()) && (item->imageIsAvailable) 
&& (!item->Pfile.isEmpty()) && (item->printEnabled()) && 
(!Options.outputSeparations) && (Options.useColor))
                        {
                                if (!PS_ImageData(item, item->Pfile, 
item->itemName(), item->ImageProfile, item->UseEmbedded))
                                        return false;
@@ -662,7 +658,7 @@
                        PutStream("{\n");
                        PS_save();
                        PS_translate(item->gXpos, pa.height - item->gYpos);
-                       ProcessItem(m_Doc, m_Doc->Pages->at(0), item, 0, sep, 
farb, false, true, true);
+                       ProcessItem(m_Doc->Pages->at(0), item, 0, false, true, 
true);
                        PS_restore();
                        PutStream("} exec\n");
                }
@@ -671,10 +667,9 @@
                PutStream("} def\n");
                PutStream("end\n");
        }
-       optimization = optim;
+       m_optimization = optim;
 //     PutStream("end\n");
 //     PutStream("%%EndSetup\n");
-       Prolog = "";
        FontDesc = "";
        return true;
 }
@@ -701,7 +696,7 @@
        PutStream("} bind def\n");
 }
 
-void PSLib::PS_begin_page(ScPage* pg, MarginStruct* Ma, bool Clipping)
+void PSLib::PS_begin_page(ScPage* pg, MarginStruct* Ma, bool clipping)
 {
        double bleedRight = 0.0;
        double bleedLeft = 0.0;
@@ -715,7 +710,7 @@
        double maxBoxY = 
pg->height()+Options.bleeds.bottom()+Options.bleeds.top()+markOffs*2.0;
        PageIndex++;
        PutStream("%%Page: " + IToStr(PageIndex) + " " + IToStr(PageIndex) + 
"\n");
-       if (psExport)
+       if (m_outputFormat == OutputPS)
        {
                if (pg->orientation() == 0)
                {
@@ -731,13 +726,13 @@
                }
        }
        PutStream("Scribusdict begin\n");
-       if ((psExport) && (Options.setDevParam))
+       if ((m_outputFormat == OutputPS) && (Options.setDevParam))
        {
                PutStream("<< /PageSize [ "+ToStr(maxBoxX)+" "+ToStr(maxBoxY)+" 
]\n");
                PutStream(">> setpagedevice\n");
        }
        PutStream("save\n");
-       if (pg->orientation() == 1 && psExport)
+       if ((pg->orientation() == 1) && (m_outputFormat == OutputPS))
                PutStream("90 rotate 0 "+IToStr(qRound(maxBoxY))+" neg 
translate\n");
        PutStream("/DeviceCMYK setcolorspace\n");
        // Clip to bleeds
@@ -753,13 +748,13 @@
        PutStream(ToStr(bleedLeft+markOffs)+" 
"+ToStr(Options.bleeds.bottom()+markOffs)+" tr\n");
        ActPage = pg;
        // Clip to margins if requested
-       if (Clipping)
-       {
-               PDev = ToStr(Ma->left()) + " " + ToStr(Ma->bottom()) + " m\n";
-               PDev += ToStr(pg->width() - Ma->right()) + " " + 
ToStr(Ma->bottom()) + " li\n";
-               PDev += ToStr(pg->width() - Ma->right()) + " " + 
ToStr(pg->height() - Ma->top()) + " li\n";
-               PDev += ToStr(Ma->left()) + " " + ToStr(pg->height() - 
Ma->top()) + " li cl clip newpath\n";
-               PutStream(PDev);
+       if (clipping)
+       {
+               QString clipPath = ToStr(Ma->left()) + " " + 
ToStr(Ma->bottom()) + " m\n";
+               clipPath += ToStr(pg->width() - Ma->right()) + " " + 
ToStr(Ma->bottom()) + " li\n";
+               clipPath += ToStr(pg->width() - Ma->right()) + " " + 
ToStr(pg->height() - Ma->top()) + " li\n";
+               clipPath += ToStr(Ma->left()) + " " + ToStr(pg->height() - 
Ma->top()) + " li cl clip newpath\n";
+               PutStream(clipPath);
        }
 }
 
@@ -777,7 +772,7 @@
        double maxBoxX = ActPage->width()+bleedLeft+bleedRight+markOffs*2.0;
        double maxBoxY = 
ActPage->height()+Options.bleeds.bottom()+Options.bleeds.top()+markOffs*2.0;
        PutStream("gs\n");
-       if (ActPage->orientation() == 1 && psExport)
+       if ((ActPage->orientation() == 1) && (m_outputFormat == OutputPS))
                PutStream("90 rotate 0 "+IToStr(qRound(maxBoxY))+" neg 
translate\n");
        if ((Options.cropMarks) || (Options.bleedMarks) || 
(Options.registrationMarks) || (Options.colorMarks))
        {
@@ -1073,11 +1068,6 @@
                }
 }
 
-void PSLib::PS_selectfont(const QString& f, double s)
-{
-       PutStream(UsedFonts[f] + " " + ToStr(s) + " se\n");
-}
-
 void PSLib::PS_fill()
 {
        if (fillRule)
@@ -1089,14 +1079,14 @@
 void PSLib::PS_fillspot(const QString& color, double shade)
 {
        if (fillRule)
-               PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" eofill\n");
+               PutStream(ToStr(shade / 100.0) + " " + spotMap[color] + " 
eofill\n");
        else
-               PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" fill\n");
+               PutStream(ToStr(shade / 100.0) + " " + spotMap[color] + " 
fill\n");
 }
 
 void PSLib::PS_strokespot(const QString& color, double shade)
 {
-       PutStream(ToStr(shade / 100.0)+" "+spotMap[color]+" st\n");
+       PutStream(ToStr(shade / 100.0) + " " + spotMap[color] + " st\n");
 }
 
 void PSLib::PS_stroke()
@@ -1407,7 +1397,7 @@
                        PutStream("/setrgbcolor {exch pop exch pop oldsetgray} 
bind def\n");
                        break;
                default:
-                       PutStream("%%PlateColor "+name+"\n");
+                       PutStream("%%PlateColor " + name + "\n");
                        PutStream("/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");
                        PutStream("/setrgbcolor {0.11 mul exch 0.59 mul add 
exch 0.3 mul add oldsetgray} bind def\n");
                        break;
@@ -1522,7 +1512,7 @@
        PS_Error( tr("Insufficient memory for processing an image"));
 }
 
-int PSLib::CreatePS(ScribusDoc* Doc, PrintOptions &options)
+int PSLib::createPS(PrintOptions &options)
 {
        bool errorOccured = false;
        Options = options;
@@ -1545,20 +1535,20 @@
        double gy = 0.0;
        double gw = 0.0;
        double gh = 0.0;;
-       PS_set_Info("Author", Doc->documentInfo().author());
-       PS_set_Info("Title", Doc->documentInfo().title());
-       if (!farb)
+       PS_set_Info("Author", m_Doc->documentInfo().author());
+       PS_set_Info("Title", m_Doc->documentInfo().title());
+       if (!Options.useColor)
                PS_setGray();
-       if ((Doc->HasCMS) && (ScCore->haveCMS()))
-               solidTransform = 
Doc->colorEngine.createTransform(Doc->DocInputCMYKProf, Format_CMYK_16, 
Doc->DocPrinterProf, Format_CMYK_16, Doc->IntentColors, 0);
+       if ((m_Doc->HasCMS) && (ScCore->haveCMS()))
+               solidTransform = 
m_Doc->colorEngine.createTransform(m_Doc->DocInputCMYKProf, Format_CMYK_16, 
m_Doc->DocPrinterProf, Format_CMYK_16, m_Doc->IntentColors, 0);
        else
                solidTransform = ScColorTransform();
        if (ScCore->usingGUI())
        {
                QString title = QObject::tr("Exporting PostScript File");
-               if (psExport)
+               if (m_outputFormat == OutputPS)
                        title = QObject::tr("Printing File");
-               progressDialog = new MultiProgressDialog(title, 
CommonStrings::tr_Cancel, Doc->scMW());
+               progressDialog = new MultiProgressDialog(title, 
CommonStrings::tr_Cancel, m_Doc->scMW());
                if (progressDialog)
                {
                        QStringList barNames, barTexts;
@@ -1567,8 +1557,8 @@
                        QList<bool> barsNumeric;
                        barsNumeric << true << true;
                        progressDialog->addExtraProgressBars(barNames, 
barTexts, barsNumeric);
-                       
progressDialog->setOverallTotalSteps(pageNs.size()+Doc->MasterPages.count());
-                       progressDialog->setTotalSteps("EMP", 
Doc->MasterPages.count());
+                       
progressDialog->setOverallTotalSteps(pageNs.size()+m_Doc->MasterPages.count());
+                       progressDialog->setTotalSteps("EMP", 
m_Doc->MasterPages.count());
                        progressDialog->setTotalSteps("EP", pageNs.size());
                        progressDialog->setOverallProgress(0);
                        progressDialog->setProgress("EMP", 0);
@@ -1578,8 +1568,8 @@
                        ScQApp->processEvents();
                }
        }
-       uint docSelectionCount = Doc->m_Selection->count();
-       if ((!psExport) && (docSelectionCount != 0))
+       uint docSelectionCount = m_Doc->m_Selection->count();
+       if ((m_outputFormat == OutputEPS) && (docSelectionCount != 0))
        {
                double minx =  std::numeric_limits<double>::max();
                double miny =  std::numeric_limits<double>::max();
@@ -1587,16 +1577,16 @@
                double maxy = -std::numeric_limits<double>::max();
                for (uint ep = 0; ep < docSelectionCount; ++ep)
                {
-                       PageItem* currItem = Doc->m_Selection->itemAt(ep);
+                       PageItem* currItem = m_Doc->m_Selection->itemAt(ep);
                        double lw = currItem->lineWidth() / 2.0;
                        if (currItem->rotation() != 0)
                        {
                                FPointArray pb;
                                pb.resize(0);
-                               pb.addPoint(FPoint(currItem->xPos()-lw, 
currItem->yPos()-lw));
-                               pb.addPoint(FPoint(currItem->width()+lw*2.0, 
-lw, currItem->xPos()-lw, currItem->yPos()-lw, currItem->rotation(), 1.0, 1.0));
-                               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));
-                               pb.addPoint(FPoint(-lw, 
currItem->height()+lw*2.0, currItem->xPos()-lw, currItem->yPos()-lw, 
currItem->rotation(), 1.0, 1.0));
+                               pb.addPoint(FPoint(currItem->xPos() - lw, 
currItem->yPos() - lw));
+                               pb.addPoint(FPoint(currItem->width() + lw * 
2.0, -lw, currItem->xPos() - lw, currItem->yPos() - lw, currItem->rotation(), 
1.0, 1.0));
+                               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));
+                               pb.addPoint(FPoint(-lw, currItem->height() + lw 
* 2.0, currItem->xPos() - lw, currItem->yPos() - lw, currItem->rotation(), 1.0, 
1.0));
                                for (uint pc = 0; pc < 4; ++pc)
                                {
                                        minx = qMin(minx, pb.point(pc).x());
@@ -1607,10 +1597,10 @@
                        }
                        else
                        {
-                               minx = qMin(minx, currItem->xPos()-lw);
-                               miny = qMin(miny, currItem->yPos()-lw);
-                               maxx = qMax(maxx, currItem->xPos()-lw + 
currItem->width()+lw*2.0);
-                               maxy = qMax(maxy, currItem->yPos()-lw + 
currItem->height()+lw*2.0);
+                               minx = qMin(minx, currItem->xPos() - lw);
+                               miny = qMin(miny, currItem->yPos() - lw);
+                               maxx = qMax(maxx, currItem->xPos() - lw + 
currItem->width() + lw * 2.0);
+                               maxy = qMax(maxy, currItem->yPos() - lw + 
currItem->height()+ lw * 2.0);
                        }
                }
                gx = minx;
@@ -1618,9 +1608,9 @@
                gw = maxx - minx;
                gh = maxy - miny;
                int pgNum = pageNs[0] - 1;
-               gx -= Doc->Pages->at(pgNum)->xOffset();
-               gy -= Doc->Pages->at(pgNum)->yOffset();
-               errorOccured = !PS_begin_doc(Doc, gx, Doc->pageHeight() - 
(gy+gh), gx + gw, Doc->pageHeight() - gy, 1*pagemult, sep, farb);
+               gx -= m_Doc->Pages->at(pgNum)->xOffset();
+               gy -= m_Doc->Pages->at(pgNum)->yOffset();
+               errorOccured = !PS_begin_doc(gx, m_Doc->pageHeight() - (gy + 
gh), gx + gw, m_Doc->pageHeight() - gy, 1 * pagemult);
        }
        else
        {
@@ -1629,13 +1619,13 @@
                for (size_t i = 0; i < pageNs.size(); ++i)
                {
                        int pgNum = pageNs[i] - 1;
-                       maxWidth = qMax(Doc->Pages->at(pgNum)->width(), 
maxWidth);
-                       maxHeight = qMax(Doc->Pages->at(pgNum)->height(), 
maxHeight);
-               }
-               errorOccured = !PS_begin_doc(Doc, 0.0, 0.0, maxWidth, 
maxHeight, pageNs.size()*pagemult, sep, farb);
+                       maxWidth = qMax(m_Doc->Pages->at(pgNum)->width(), 
maxWidth);
+                       maxHeight = qMax(m_Doc->Pages->at(pgNum)->height(), 
maxHeight);
+               }
+               errorOccured = !PS_begin_doc(0.0, 0.0, maxWidth, maxHeight, 
pageNs.size() * pagemult);
        }
        int ap=0;
-       for (; ap < Doc->MasterPages.count() && !abortExport && !errorOccured; 
++ap)
+       for (; ap < m_Doc->MasterPages.count() && !abortExport && 
!errorOccured; ++ap)
        {
                if (progressDialog)
                {
@@ -1643,30 +1633,30 @@
                        progressDialog->setProgress("EMP", ap);
                        ScQApp->processEvents();
                }
-               if (Doc->MasterItems.count() != 0)
+               if (m_Doc->MasterItems.count() != 0)
                {
                        int Lnr = 0;
                        ScLayer ll;
                        ll.isPrintable = false;
                        ll.ID = 0;
-                       for (int lam = 0; lam < Doc->Layers.count() && 
!abortExport && !errorOccured; ++lam)
-                       {
-                               Doc->Layers.levelToLayer(ll, Lnr);
+                       for (int lam = 0; lam < m_Doc->Layers.count() && 
!abortExport && !errorOccured; ++lam)
+                       {
+                               m_Doc->Layers.levelToLayer(ll, Lnr);
                                if (ll.isPrintable)
                                {
-                                       for (int api = 0; api < 
Doc->MasterItems.count() && !abortExport; ++api)
+                                       for (int api = 0; api < 
m_Doc->MasterItems.count() && !abortExport; ++api)
                                        {
-                                               PageItem *it = 
Doc->MasterItems.at(api);
+                                               PageItem *it = 
m_Doc->MasterItems.at(api);
                                                if (progressDialog)
                                                        ScQApp->processEvents();
                                                if ((it->m_layerID != ll.ID) || 
(!it->printEnabled()))
                                                        continue;
                                                double bLeft, bRight, bBottom, 
bTop;
-                                               
GetBleeds(Doc->MasterPages.at(ap), bLeft, bRight, bBottom, bTop);
-                                               double x1 = 
Doc->MasterPages.at(ap)->xOffset() - bLeft;
-                                               double y1 = 
Doc->MasterPages.at(ap)->yOffset() - bTop;
-                                               double w1 = 
Doc->MasterPages.at(ap)->width() + bLeft + bRight;
-                                               double h1 = 
Doc->MasterPages.at(ap)->height()+ bBottom + bTop;
+                                               
GetBleeds(m_Doc->MasterPages.at(ap), bLeft, bRight, bBottom, bTop);
+                                               double x1 = 
m_Doc->MasterPages.at(ap)->xOffset() - bLeft;
+                                               double y1 = 
m_Doc->MasterPages.at(ap)->yOffset() - bTop;
+                                               double w1 = 
m_Doc->MasterPages.at(ap)->width() + bLeft + bRight;
+                                               double h1 = 
m_Doc->MasterPages.at(ap)->height()+ bBottom + bTop;
                                                double lw = 
it->visualLineWidth();
                                                double x2 = it->BoundingX - lw 
/ 2.0;
                                                double y2 = it->BoundingY - lw 
/ 2.0;
@@ -1674,15 +1664,15 @@
                                                double h2 = qMax(it->BoundingH 
+ lw, 1.0);
                                                if (!QRectF(x2, y2, w2, 
h2).intersects(QRectF(x1, y1, w1, h1)))
                                                        continue;
-                                               if ((it->OwnPage != 
static_cast<int>(Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1))
+                                               if ((it->OwnPage != 
static_cast<int>(m_Doc->MasterPages.at(ap)->pageNr())) && (it->OwnPage != -1))
                                                        continue;
-                                               if ((optimization == 
OptimizeSize) && it->asImageFrame() && it->imageIsAvailable && 
(!it->Pfile.isEmpty()) && it->printEnabled() && (!sep) && farb)
+                                               if ((m_optimization == 
OptimizeSize) && it->asImageFrame() && it->imageIsAvailable && 
(!it->Pfile.isEmpty()) && it->printEnabled() && (!sep) && farb)
                                                {
                                                        errorOccured = 
!PS_ImageData(it, it->Pfile, it->itemName(), it->ImageProfile, it->UseEmbedded);
                                                        if (errorOccured) break;
                                                }
                                                
PS_TemplateStart(QString("mp_obj_%1_%2").arg(ap).arg(qHash(it)));
-                                               ProcessItem(Doc, 
Doc->MasterPages.at(ap), it, ap+1, sep, farb, true);
+                                               
ProcessItem(m_Doc->MasterPages.at(ap), it, ap+1, true);
                                                PS_TemplateEnd();
                                        }
                                }
@@ -1691,11 +1681,12 @@
                        }
                }
                if (errorOccured) break;
-       }
+       }       
+       PutStream("%%EndSetup\n");
+       
        sepac = 0;
        uint aa = 0;
-       uint a; 
-       PutStream("%%EndSetup\n");
+       uint a;
        while (aa < pageNs.size() && !abortExport && !errorOccured)
        {
                if (progressDialog)
@@ -1705,8 +1696,8 @@
                        ScQApp->processEvents();
                }
                a = pageNs[aa]-1;
-               ScPage* page = Doc->Pages->at(a);
-               if ((!psExport) && (Doc->m_Selection->count() != 0))
+               ScPage* page = m_Doc->Pages->at(a);
+               if ((m_outputFormat == OutputEPS) && 
(m_Doc->m_Selection->count() != 0))
                {
                        MarginStruct Ma;
                        Ma.setLeft(gx);
@@ -1744,18 +1735,18 @@
                }
                ScLayer ll;
                ll.isPrintable = false;
-               for (int lam = 0; lam < Doc->Layers.count() && !abortExport && 
!errorOccured; ++lam)
-               {
-                       Doc->Layers.levelToLayer(ll, lam);
+               for (int lam = 0; lam < m_Doc->Layers.count() && !abortExport 
&& !errorOccured; ++lam)
+               {
+                       m_Doc->Layers.levelToLayer(ll, lam);
                        if (!ll.isPrintable)
                                continue;
                        if (!page->masterPageNameEmpty() && !abortExport && 
!errorOccured)
                        {
-                               errorOccured |= !ProcessMasterPageLayer(Doc, 
page, ll, a, sep, farb);
+                               errorOccured |= !ProcessMasterPageLayer(page, 
ll, a);
                        }
                        if (!abortExport && !errorOccured)
                        {
-                               errorOccured |= !ProcessPageLayer(Doc, page, 
ll, a+1, sep, farb);
+                               errorOccured |= !ProcessPageLayer(page, ll, a + 
1);
                        }
                }
                if (!abortExport && !errorOccured)
@@ -1788,7 +1779,7 @@
        return 0; 
 }
 
-bool PSLib::ProcessItem(ScribusDoc* Doc, ScPage* page, PageItem* item, uint 
PNr, bool sep, bool farb, bool master, bool embedded, bool useTemplate)
+bool PSLib::ProcessItem(ScPage* page, PageItem* item, uint PNr, bool master, 
bool embedded, bool useTemplate)
 {
        double h, s, v, k;
        QVector<double> dum;
@@ -1858,7 +1849,7 @@
                {
                        bool imageOk = false;
                        PS_translate(0, -item->BBoxH*item->imageYScale());
-                       if ((optimization == OptimizeSize) && 
(((!page->pageNameEmpty()) && !sep && farb) || useTemplate))
+                       if ((m_optimization == OptimizeSize) && 
(((!page->pageNameEmpty()) && !Options.outputSeparations && Options.useColor) 
|| useTemplate))
                                imageOk = PS_image(item, item->imageXOffset(), 
-item->imageYOffset(), item->Pfile, item->imageXScale(), item->imageYScale(), 
item->ImageProfile, item->UseEmbedded, item->itemName());
                        else
                                imageOk = PS_image(item, item->imageXOffset(), 
-item->imageYOffset(), item->Pfile, item->imageXScale(), item->imageYScale(), 
item->ImageProfile, item->UseEmbedded);
@@ -1869,11 +1860,11 @@
                {
                        if (item->NamedLStyle.isEmpty()) // && 
(item->lineWidth() != 0.0))
                        {
-                               ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                               ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                                if ((strokePattern) && 
(item->patternStrokePath))
                                {
                                        QPainterPath path = 
item->PoLine.toQPainterPath(false);
-                                       HandleBrushPattern(item, path, page, 
PNr, sep, farb, master);
+                                       HandleBrushPattern(item, path, page, 
PNr, master);
                                }
                                else
                                {
@@ -1896,7 +1887,7 @@
                        }
                        else
                        {
-                               multiLine ml = 
Doc->MLineStyles[item->NamedLStyle];
+                               multiLine ml = 
m_Doc->MLineStyles[item->NamedLStyle];
                                for (int it = ml.size()-1; it > -1; it--)
                                {
                                        if (ml[it].Color != 
CommonStrings::None) // && (ml[it].Width != 0))
@@ -1917,7 +1908,7 @@
        case PageItem::TextFrame:
                if (master)
                        break;
-               if ((item->isBookmark || item->isAnnotation()) && (!isPDF))
+               if ((item->isBookmark || item->isAnnotation()) && 
(!Options.includePDFMarks))
                        break;
                if (item->isBookmark)
                {
@@ -1967,7 +1958,7 @@
                        PS_scale(1, -1);
                }
                if (item->itemText.length() != 0)
-                       setTextSt(Doc, item, PNr-1, page, sep, farb, master);
+                       setTextSt(item, PNr-1, page, master);
                if (((item->lineColor() != CommonStrings::None) || 
(!item->NamedLStyle.isEmpty()) || (!item->strokePattern().isEmpty()) || 
(item->GrTypeStroke > 0)))
                {
                        PS_setlinewidth(item->lineWidth());
@@ -1975,11 +1966,11 @@
                        PS_setdash(item->PLineArt, item->DashOffset, 
item->DashValues);
                        if (item->NamedLStyle.isEmpty()) // && 
(item->lineWidth() != 0.0))
                        {
-                               ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                               ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                                if ((strokePattern) && 
(item->patternStrokePath))
                                {
                                        QPainterPath path = 
item->PoLine.toQPainterPath(false);
-                                       HandleBrushPattern(item, path, page, 
PNr, sep, farb, master);
+                                       HandleBrushPattern(item, path, page, 
PNr, master);
                                }
                                else
                                {
@@ -1999,7 +1990,7 @@
                        }
                        else
                        {
-                               multiLine ml = 
Doc->MLineStyles[item->NamedLStyle];
+                               multiLine ml = 
m_Doc->MLineStyles[item->NamedLStyle];
                                for (int it = ml.size()-1; it > -1; it--)
                                {
                                        if (ml[it].Color != 
CommonStrings::None) //&& (ml[it].Width != 0))
@@ -2020,7 +2011,7 @@
        case PageItem::Line:
                if (item->NamedLStyle.isEmpty()) // && (item->lineWidth() != 
0.0))
                {
-                       ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                       ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                        if (strokePattern)
                        {
                                if (item->patternStrokePath)
@@ -2028,7 +2019,7 @@
                                        QPainterPath guidePath;
                                        guidePath.moveTo(0, 0);
                                        guidePath.lineTo(item->width(), 0);
-                                       HandleBrushPattern(item, guidePath, 
page, PNr, sep, farb, master);
+                                       HandleBrushPattern(item, guidePath, 
page, PNr, master);
                                }
                                else
                                {
@@ -2052,7 +2043,7 @@
                }
                else
                {
-                       multiLine ml = Doc->MLineStyles[item->NamedLStyle];
+                       multiLine ml = m_Doc->MLineStyles[item->NamedLStyle];
                        for (int it = ml.size()-1; it > -1; it--)
                        {
                                if (ml[it].Color != CommonStrings::None) //&& 
(ml[it].Width != 0))
@@ -2108,11 +2099,11 @@
                {
                        if (item->NamedLStyle.isEmpty()) //&& 
(item->lineWidth() != 0.0))
                        {
-                               ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                               ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                                if (strokePattern && (item->patternStrokePath))
                                {
                                        QPainterPath path = 
item->PoLine.toQPainterPath(false);
-                                       HandleBrushPattern(item, path, page, 
PNr, sep, farb, master);
+                                       HandleBrushPattern(item, path, page, 
PNr, master);
                                }
                                else
                                {
@@ -2128,7 +2119,7 @@
                        }
                        else
                        {
-                               multiLine ml = 
Doc->MLineStyles[item->NamedLStyle];
+                               multiLine ml = 
m_Doc->MLineStyles[item->NamedLStyle];
                                for (int it = ml.size()-1; it > -1; it--)
                                {
                                        if (ml[it].Color != 
CommonStrings::None) //&& (ml[it].Width != 0))
@@ -2165,11 +2156,11 @@
                {
                        if (item->NamedLStyle.isEmpty()) //&& 
(item->lineWidth() != 0.0))
                        {
-                               ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                               ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                                if (strokePattern && (item->patternStrokePath))
                                {
                                        QPainterPath path = 
item->PoLine.toQPainterPath(false);
-                                       HandleBrushPattern(item, path, page, 
PNr, sep, farb, master);
+                                       HandleBrushPattern(item, path, page, 
PNr, master);
                                }
                                else
                                {
@@ -2184,7 +2175,7 @@
                        }
                        else
                        {
-                               multiLine ml = 
Doc->MLineStyles[item->NamedLStyle];
+                               multiLine ml = 
m_Doc->MLineStyles[item->NamedLStyle];
                                for (int it = ml.size()-1; it > -1; it--)
                                {
                                        if (ml[it].Color != 
CommonStrings::None) //&& (ml[it].Width != 0))
@@ -2247,11 +2238,11 @@
                                PS_save();
                                if (item->NamedLStyle.isEmpty()) //&& 
(item->lineWidth() != 0.0))
                                {
-                                       ScPattern* strokePattern = 
Doc->checkedPattern(item->strokePattern());
+                                       ScPattern* strokePattern = 
m_Doc->checkedPattern(item->strokePattern());
                                        if (strokePattern && 
(item->patternStrokePath))
                                        {
                                                QPainterPath path = 
item->PoLine.toQPainterPath(false);
-                                               HandleBrushPattern(item, path, 
page, PNr, sep, farb, master);
+                                               HandleBrushPattern(item, path, 
page, PNr, master);
                                        }
                                        else
                                        {
@@ -2266,7 +2257,7 @@
                                }
                                else
                                {
-                                       multiLine ml = 
Doc->MLineStyles[item->NamedLStyle];
+                                       multiLine ml = 
m_Doc->MLineStyles[item->NamedLStyle];
                                        for (int it = ml.size()-1; it > -1; 
it--)
                                        {
                                                if (ml[it].Color != 
CommonStrings::None) //&& (ml[it].Width != 0))
@@ -2285,7 +2276,7 @@
                        }
                }
                if (item->itemText.length() != 0)
-                       setTextSt(Doc, item, PNr-1, page, sep, farb, master);
+                       setTextSt(item, PNr-1, page, master);
                break;
        case PageItem::Symbol:
                if (m_Doc->docPatterns.contains(item->pattern()))
@@ -2311,7 +2302,7 @@
                                PageItem* embed = pat.items.at(em);
                                PS_save();
                                PS_translate(embed->gXpos, item->height() - 
embed->gYpos);
-                               ProcessItem(m_Doc, page, embed, PNr, sep, farb, 
master, true);
+                               ProcessItem(page, embed, PNr, master, true);
                                PS_restore();
                        }
                        PS_restore();
@@ -2338,7 +2329,7 @@
                        PageItem* embed = item->groupItemList.at(em);
                        PS_save();
                        PS_translate(embed->gXpos, item->height() - 
embed->gYpos);
-                       ProcessItem(m_Doc, page, embed, PNr, sep, farb, master, 
true);
+                       ProcessItem(page, embed, PNr, master, true);
                        PS_restore();
                }
                PS_restore();
@@ -2536,7 +2527,7 @@
                                        PageItem* textFrame = cell.textFrame();
                                        PS_save();
                                        PS_translate(cell.contentRect().x(), 
-cell.contentRect().y());
-                                       ProcessItem(m_Doc, page, textFrame, 
PNr, sep, farb, master, true);
+                                       ProcessItem(page, textFrame, PNr, 
master, true);
                                        PS_restore();
                                }
                        }
@@ -2579,7 +2570,7 @@
        PS_restore();
 }
 
-void PSLib::ProcessPage(ScribusDoc* Doc, ScPage* page, uint PNr, bool sep, 
bool farb)
+void PSLib::ProcessPage(ScPage* page, uint PNr)
 {
        PageItem *item;
        QList<PageItem*> PItems;
@@ -2587,10 +2578,10 @@
        ScLayer ll;
        ll.isPrintable = false;
        ll.ID = 0;
-       PItems = (page->pageNameEmpty()) ? Doc->DocItems : Doc->MasterItems;
-       for (int la = 0; la < Doc->Layers.count(); ++la)
-       {
-               Doc->Layers.levelToLayer(ll, Lnr);
+       PItems = (page->pageNameEmpty()) ? m_Doc->DocItems : m_Doc->MasterItems;
+       for (int la = 0; la < m_Doc->Layers.count(); ++la)
+       {
+               m_Doc->Layers.levelToLayer(ll, Lnr);
                if (ll.isPrintable && !abortExport)
                {
                        for (int b = 0; b < PItems.count() && !abortExport; ++b)
@@ -2606,10 +2597,10 @@
                                        continue;
                                if ((!page->pageNameEmpty()) && 
(item->asTable()))
                                        continue;
-                               if ((!page->pageNameEmpty()) && 
(item->asImageFrame()) && ((sep) || (!farb)))
+                               if ((!page->pageNameEmpty()) && 
(item->asImageFrame()) && ((Options.outputSeparations) || (!Options.useColor)))
                                        continue;
                                //if ((!Art) && (view->SelItem.count() != 0) && 
(!item->Select))
-                               if ((!psExport) && (!item->isSelected()) && 
(Doc->m_Selection->count() != 0))
+                               if ((m_outputFormat == OutputEPS) && 
(!item->isSelected()) && (m_Doc->m_Selection->count() != 0))
                                        continue;
                                double bLeft, bRight, bBottom, bTop;
                                GetBleeds(page, bLeft, bRight, bBottom, bTop);
@@ -2628,19 +2619,19 @@
                                        continue;
                                if ((!page->pageNameEmpty()) && (item->OwnPage 
!= static_cast<int>(page->pageNr())) && (item->OwnPage != -1))
                                        continue;
-                               ProcessItem(Doc, page, item, PNr, sep, farb, 
false);
+                               ProcessItem(page, item, PNr, false);
                        }
                }
                Lnr++;
        }
 }
 
-bool PSLib::ProcessMasterPageLayer(ScribusDoc* Doc, ScPage* page, ScLayer& 
layer, uint PNr, bool sep, bool farb)
+bool PSLib::ProcessMasterPageLayer(ScPage* page, ScLayer& layer, uint PNr)
 {
        bool success = true;
        double h, s, v, k;
        QVector<double> dum;
-       ScPage* mPage = 
Doc->MasterPages.at(Doc->MasterNames[page->masterPageName()]);
+       ScPage* mPage = 
m_Doc->MasterPages.at(m_Doc->MasterNames[page->masterPageName()]);
        if (layer.isPrintable)
        {
                for (int am = 0; am < page->FromMaster.count() && !abortExport; 
++am)
@@ -2652,14 +2643,14 @@
                                continue;
                        if (!(ite->asTextFrame()) && !(ite->asImageFrame()) && 
!(ite->asPathText()) && !(ite->asTable()))
                        {
-                               int mpIndex = 
Doc->MasterNames[page->masterPageName()];
+                               int mpIndex = 
m_Doc->MasterNames[page->masterPageName()];
                                
PS_UseTemplate(QString("mp_obj_%1_%2").arg(mpIndex).arg(qHash(ite)));
                        }
                        else if (ite->asImageFrame())
                        {
                                PS_save();
                                // JG : replace what seems mostly duplicate 
code by corresponding function call (#3936)
-                               success &= ProcessItem(Doc, mPage, ite, PNr, 
sep, farb, false, false, true);
+                               success &= ProcessItem(mPage, ite, PNr, false, 
false, true);
                                PS_restore();
                        }
                        else if (ite->asTable())
@@ -2855,7 +2846,7 @@
                                                        PageItem* textFrame = 
cell.textFrame();
                                                        PS_save();
                                                        
PS_translate(cell.contentRect().x(), -cell.contentRect().y());
-                                                       ProcessItem(Doc, mPage, 
textFrame, PNr, sep, farb, false, false, true);
+                                                       ProcessItem(mPage, 
textFrame, PNr, false, false, true);
                                                        PS_restore();
                                                }
                                        }
@@ -2900,16 +2891,16 @@
                                        PS_scale(1, -1);
                                }
                                if (ite->itemText.length() != 0)
-                                       setTextSt(Doc, ite, PNr, mPage, sep, 
farb, true);
+                                       setTextSt(ite, PNr, mPage, true);
                                if (((ite->lineColor() != CommonStrings::None) 
|| (!ite->NamedLStyle.isEmpty()) || (!ite->strokePattern().isEmpty()) || 
(ite->GrTypeStroke > 0)))
                                {
                                        if (ite->NamedLStyle.isEmpty()) // && 
(ite->lineWidth() != 0.0))
                                        {
-                                               ScPattern* strokePattern = 
Doc->checkedPattern(ite->strokePattern());
+                                               ScPattern* strokePattern = 
m_Doc->checkedPattern(ite->strokePattern());
                                                if (strokePattern && 
(ite->patternStrokePath))
                                                {
                                                        QPainterPath path = 
ite->PoLine.toQPainterPath(false);
-                                                       HandleBrushPattern(ite, 
path, page, PNr, sep, farb, true);
+                                                       HandleBrushPattern(ite, 
path, page, PNr, true);
                                                }
                                                else
                                                {
@@ -2932,7 +2923,7 @@
                                        }
                                        else
                                        {
-                                               multiLine ml = 
Doc->MLineStyles[ite->NamedLStyle];
+                                               multiLine ml = 
m_Doc->MLineStyles[ite->NamedLStyle];
                                                for (int it = ml.size()-1; it > 
-1; it--)
                                                {
                                                        if (ml[it].Color != 
CommonStrings::None) //&& (ml[it].Width != 0))
@@ -2962,11 +2953,11 @@
                                                PS_save();
                                                if (ite->NamedLStyle.isEmpty()) 
//&& (item->lineWidth() != 0.0))
                                                {
-                                                       ScPattern* 
strokePattern = Doc->checkedPattern(ite->strokePattern());
+                                                       ScPattern* 
strokePattern = m_Doc->checkedPattern(ite->strokePattern());
                                                        if (strokePattern && 
(ite->patternStrokePath))
                                                        {
                                                                QPainterPath 
path = ite->PoLine.toQPainterPath(false);
-                                                               
HandleBrushPattern(ite, path, mPage, PNr, sep, farb, true);
+                                                               
HandleBrushPattern(ite, path, mPage, PNr, true);
                                                        }
                                                        else
                                                        {
@@ -2981,7 +2972,7 @@
                                                }
                                                else
                                                {
-                                                       multiLine ml = 
Doc->MLineStyles[ite->NamedLStyle];
+                                                       multiLine ml = 
m_Doc->MLineStyles[ite->NamedLStyle];
                                                        for (int it = 
ml.size()-1; it > -1; it--)
                                                        {
                                                                if 
(ml[it].Color != CommonStrings::None) //&& (ml[it].Width != 0))
@@ -3000,7 +2991,7 @@
                                        }
                                }
                                if (ite->itemText.length() != 0)
-                                       setTextSt(Doc, ite, PNr, mPage, sep, 
farb, true);
+                                       setTextSt(ite, PNr, mPage, true);
                                PS_restore();
                        }
                        if (!success)
@@ -3010,14 +3001,14 @@
        return success;
 }
 
-bool PSLib::ProcessPageLayer(ScribusDoc* Doc, ScPage* page, ScLayer& layer, 
uint PNr, bool sep, bool farb)
+bool PSLib::ProcessPageLayer(ScPage* page, ScLayer& layer, uint PNr)
 {
        bool success = true;
        if (!layer.isPrintable || abortExport)
                return true;
 
        QList<PageItem*> items;
-       items = (page->pageNameEmpty()) ? Doc->DocItems : Doc->MasterItems;
+       items = (page->pageNameEmpty()) ? m_Doc->DocItems : m_Doc->MasterItems;
 
        for (int i = 0; i < items.count() && !abortExport; ++i)
        {
@@ -3032,10 +3023,10 @@
                        continue;
                if ((!page->pageNameEmpty()) && (item->asTable()))
                        continue;
-               if ((!page->pageNameEmpty()) && (item->asImageFrame()) && 
((sep) || (!farb)))
+               if ((!page->pageNameEmpty()) && (item->asImageFrame()) && 
((Options.outputSeparations) || (!Options.useColor)))
                        continue;
                //if ((!Art) && (view->SelItem.count() != 0) && (!item->Select))
-               if ((!psExport) && (!item->isSelected()) && 
(Doc->m_Selection->count() != 0))
+               if ((m_outputFormat == OutputEPS) && (!item->isSelected()) && 
(m_Doc->m_Selection->count() != 0))
                        continue;
                double bLeft, bRight, bBottom, bTop;
                GetBleeds(page, bLeft, bRight, bBottom, bTop);
@@ -3054,7 +3045,7 @@
                        continue;
                if ((!page->pageNameEmpty()) && (item->OwnPage != 
static_cast<int>(page->pageNr())) && (item->OwnPage != -1))
                        continue;
-               success &= ProcessItem(Doc, page, item, PNr, sep, farb, false);
+               success &= ProcessItem(page, item, PNr, false);
                if (!success)
                        break;
        }
@@ -3062,7 +3053,7 @@
 }
 
 
-void PSLib::HandleBrushPattern(PageItem *item, QPainterPath &path, ScPage* a, 
uint PNr, bool sep, bool farb, bool master)
+void PSLib::HandleBrushPattern(PageItem *item, QPainterPath &path, ScPage* 
page, uint PNr, bool master)
 {
        ScPattern pat = m_Doc->docPatterns[item->strokePattern()];
        double pLen = path.length() - ((pat.width / 2.0) * 
(item->patternStrokeScaleX / 100.0));
@@ -3102,7 +3093,7 @@
                        PageItem* embedded = pat.items.at(em);
                        PS_save();
                        PS_translate(embedded->gXpos, embedded->gHeight - 
embedded->gYpos);
-                       ProcessItem(m_Doc, a, embedded, PNr, sep, farb, master, 
true);
+                       ProcessItem(page, embedded, PNr, master, true);
                        PS_restore();
                }
                xpos += adv;
@@ -3173,7 +3164,7 @@
        for (int ac = 0; ac < cols.count(); ac++)
        {
                QString colorVal = "";
-               if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
+               if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
                {
                        if (spotColorSet.contains(cols.at(ac)))
                        {
@@ -3225,7 +3216,7 @@
                {
                        PutStream("/ColorSpace /DeviceGray\n");
                }
-               else if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
+               else if ((Options.useSpotColors) && ((spotColorSet.count() > 0) 
&& (spotColorSet.count() < 28)))
                {
                        PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta 
/Yellow /Black");
                        for (int sc = 0; sc < spotColorSet.count(); sc++)
@@ -3354,7 +3345,7 @@
        for (int ac = 0; ac < cols.count(); ac++)
        {
                QString colorVal = "";
-               if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
+               if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
                {
                        if (spotColorSet.contains(cols.at(ac)))
                        {
@@ -3406,7 +3397,7 @@
                {
                        PutStream("/ColorSpace /DeviceGray\n");
                }
-               else if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
+               else if ((Options.useSpotColors) && ((spotColorSet.count() > 0) 
&& (spotColorSet.count() < 28)))
                {
                        PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta 
/Yellow /Black");
                        for (int sc = 0; sc < spotColorSet.count(); sc++)
@@ -3531,7 +3522,7 @@
        for (int ac = 0; ac < cols.count(); ac++)
        {
                QString colorVal = "";
-               if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
+               if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
                {
                        if (spotColorSet.contains(cols.at(ac)))
                        {
@@ -3578,7 +3569,7 @@
        PutStream("/ShadingType 6\n");
        if ((DoSep) || (GraySc))
                PutStream("/ColorSpace /DeviceGray\n");
-       else if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
+       else if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
        {
                PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta /Yellow 
/Black");
                for (int sc = 0; sc < spotColorSet.count(); sc++)
@@ -3726,7 +3717,7 @@
        PutStream("/ShadingType 7\n");
        if ((DoSep) || (GraySc))
                PutStream("/ColorSpace /DeviceGray\n");
-       else if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
+       else if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
        {
                PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta /Yellow 
/Black");
                for (int sc = 0; sc < spotColorSet.count(); sc++)
@@ -3769,7 +3760,7 @@
        PutStream(ToStr(item->GrControl2.x())+" 
"+ToStr(-item->GrControl2.y())+"\n");
        for (int ac = 0; ac < cols.count(); ac++)
        {
-               if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
+               if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
                {
                        if (spotColorSet.contains(cols.at(ac)))
                        {
@@ -3944,7 +3935,7 @@
                PutStream("/ShadingType 3\n");
        if ((DoSep) || (GraySc))
                PutStream("/ColorSpace /DeviceGray\n");
-       else if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
+       else if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)))
        {
                PutStream("/ColorSpace [ /DeviceN [/Cyan /Magenta /Yellow 
/Black");
                for (int sc = 0; sc < spotColorSet.count(); sc++)
@@ -4013,7 +4004,7 @@
                PutStream("<<\n");
                PutStream("/FunctionType 2\n");
                PutStream("/Domain [0 1]\n");
-               if ((useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
+               if ((Options.useSpotColors) && ((spotColorSet.count() > 0) && 
(spotColorSet.count() < 28)) && (!GraySc))
                {
                        if (spotColorSet.contains(colorNames.at(cc)))
                        {
@@ -4326,9 +4317,9 @@
        }
 }
 
-void PSLib::SetColor(const QString& farb, double shade, double *h, double *s, 
double *v, double *k)
-{
-       if (farb == CommonStrings::None)
+void PSLib::SetColor(const QString& color, double shade, double *h, double *s, 
double *v, double *k)
+{
+       if (color == CommonStrings::None)
        {
                *h = 0;
                *s = 0;
@@ -4336,17 +4327,17 @@
                *k = 0;
                return;
        }
-       ScColor& col = m_Doc->PageColors[farb];
+       ScColor& col = m_Doc->PageColors[color];
        SetColor(col, shade, h, s, v, k);
 }
 
-void PSLib::SetColor(const ScColor& farb, double shade, double *c, double *m, 
double *y, double *k)
+void PSLib::SetColor(const ScColor& color, double shade, double *c, double *m, 
double *y, double *k)
 {
        double c1 = *c, m1 = *m, y1 = *y, k1 = *k;
-       ScColor tmp(farb);
-       if (farb.getColorModel() != colorModelCMYK)
-               tmp = ScColorEngine::convertToModel(farb, m_Doc, 
colorModelCMYK);
-       if ((Options.doGCR) && (!farb.isRegistrationColor()))
+       ScColor tmp(color);
+       if (color.getColorModel() != colorModelCMYK)
+               tmp = ScColorEngine::convertToModel(color, m_Doc, 
colorModelCMYK);
+       if ((Options.doGCR) && (!color.isRegistrationColor()))
                ScColorEngine::applyGCR(tmp, m_Doc);
        tmp.getCMYK(&c1, &m1, &y1, &k1);
        if ((m_Doc->HasCMS) && (ScCore->haveCMS()) && (solidTransform))
@@ -4378,23 +4369,19 @@
 
 /**
  * @brief PSLib::setTextSt
- * @param Doc   our dicument
- * @param ite   the Textitem to set
+ * @param ite   the text item to set
  * @param argh  current page number
  * @param pg    current page
- * @param sep   separate colors option
- * @param farb  useColors option (== !grayscale)
- * @param ic    use ICC profile option
  * @param master true if setting master page item
  */
-void PSLib::setTextSt(ScribusDoc* Doc, PageItem* ite, uint argh, ScPage* pg, 
bool sep, bool farb, bool master)
+void PSLib::setTextSt(PageItem* ite, uint argh, ScPage* pg, bool master)
 {
        int savedOwnPage = ite->OwnPage;
        ite->OwnPage = argh;
        ite->layout();
        ite->OwnPage = savedOwnPage;
 
-       PSPainter p(Doc, argh, pg, sep, farb, master, this);
+       PSPainter p(m_Doc, argh, pg, master, this);
        ite->textLayout.renderBackground(&p);
        ite->textLayout.render(&p);
 }
@@ -4404,7 +4391,7 @@
        ScColor& color(colorsToUse[colorName]);
        if (fill)
        {
-               if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(useSpotColors))
+               if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(Options.useSpotColors))
                {
                        if (!DoSep)
                                PS_fillspot(colorName, shade);
@@ -4438,7 +4425,7 @@
        }
        else
        {
-               if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(useSpotColors))
+               if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(Options.useSpotColors))
                {
                        if (!DoSep)
                                PS_strokespot(colorName, shade);
@@ -4461,7 +4448,7 @@
 void PSLib::putColorNoDraw(const QString& colorName, double shade)
 {
        ScColor& color(colorsToUse[colorName]);
-       if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(useSpotColors))
+       if (((color.isSpotColor()) || (color.isRegistrationColor())) && 
(Options.useSpotColors))
        {
                if (!DoSep)
                        PutStream(ToStr(shade / 100.0)+" "+spotMap[colorName] + 
"\n");

Modified: trunk/Scribus/scribus/pslib.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/pslib.h
==============================================================================
--- trunk/Scribus/scribus/pslib.h       (original)
+++ trunk/Scribus/scribus/pslib.h       Mon Apr  6 20:50:38 2020
@@ -60,30 +60,39 @@
 
        public:
 
-               typedef enum
+               enum Optimization
                {
                        OptimizeCompat = 0,
                        OptimizeSize = 1
-               } Optimization;
-
-               PSLib(PrintOptions &options, bool psart, SCFonts &AllFonts, 
QMap<QString, QMap<uint, FPointArray> > DocFonts, ColorList DocColors, bool pdf 
= false, bool spot = true);
+               };
+
+               enum OutputFormat
+               {
+                       OutputPS = 0,
+                       OutputEPS = 1
+               };
+
+               PSLib(ScribusDoc* doc, PrintOptions &options, OutputFormat 
outputFmt, ColorList *docColors = nullptr);
                virtual ~PSLib();
 
-               void setOptimization (Optimization opt) { optimization = opt; }
-
-               virtual int   CreatePS(ScribusDoc* Doc, PrintOptions &options);
+               void setOptimization (Optimization opt) { m_optimization = opt; 
}
+               void setOutputFormat (OutputFormat outputFmt) { m_outputFormat 
= outputFmt; }
+
+               virtual int   createPS(PrintOptions &options);
                virtual const QString& errorMessage();
 
+               virtual bool PS_set_file(const QString& fn);
+               virtual void PS_set_Info(const QString& art, const QString& 
was);
+
+       protected:
                virtual void PS_Error(const QString& message);
                virtual void PS_Error_ImageDataWriteFailure();
                virtual void PS_Error_ImageLoadFailure(const QString& fileName);
                virtual void PS_Error_MaskLoadFailure(const QString& fileName);
                virtual void PS_Error_InsufficientMemory();
 
-               virtual bool PS_set_file(const QString& fn);
-               virtual void PS_set_Info(const QString& art, const QString& 
was);
-               virtual bool PS_begin_doc(ScribusDoc *doc, double x, double y, 
double width, double height, int numpage, bool sep, bool farb);
-               virtual void PS_begin_page(ScPage* pg, MarginStruct* Ma, bool 
Clipping);
+               virtual bool PS_begin_doc( double x, double y, double width, 
double height, int numpage);
+               virtual void PS_begin_page(ScPage* pg, MarginStruct* Ma, bool 
clipping);
                virtual void PS_end_page();
                virtual void PS_curve(double x1, double y1, double x2, double 
y2, double x3, double y3);
                virtual void PS_moveto(double x, double y);
@@ -101,7 +110,6 @@
                virtual void PS_setlinewidth(double w);
                virtual void PS_setcapjoin(Qt::PenCapStyle ca, Qt::PenJoinStyle 
jo);
                virtual void PS_setdash(Qt::PenStyle st, double offset, 
QVector<double> dash);
-               virtual void PS_selectfont(const QString& f, double s);
                virtual void PS_fill();
                virtual void PS_fillspot(const QString& color, double shade);
                virtual void PS_stroke();
@@ -121,10 +129,10 @@
                virtual void PS_TemplateStart(const QString& Name);
                virtual void PS_TemplateEnd();
                virtual void PS_UseTemplate(const QString& Name);
-               virtual bool ProcessItem(ScribusDoc* Doc, ScPage* page, 
PageItem* item, uint PNr, bool sep, bool farb, bool master, bool embedded = 
false, bool useTemplate = false);
-               virtual void ProcessPage(ScribusDoc* Doc, ScPage* page, uint 
PNr, bool sep = false, bool farb = true);
-               virtual bool ProcessMasterPageLayer(ScribusDoc* Doc, ScPage* 
page, ScLayer& ll, uint PNr, bool sep = false, bool farb = true);
-               virtual bool ProcessPageLayer(ScribusDoc* Doc, ScPage* a, 
ScLayer& ll, uint PNr, bool sep = false, bool farb = true);
+               virtual bool ProcessItem(ScPage* page, PageItem* item, uint 
PNr, bool master, bool embedded = false, bool useTemplate = false);
+               virtual void ProcessPage(ScPage* page, uint PNr);
+               virtual bool ProcessMasterPageLayer(ScPage* page, ScLayer& ll, 
uint PNr);
+               virtual bool ProcessPageLayer(ScPage* a, ScLayer& ll, uint PNr);
                virtual void PS_HatchFill(PageItem *currItem);
                virtual void drawArrow(PageItem *ite, QTransform &arrowTrans, 
int arrowIndex);
                virtual void putColor(const QString& color, double shade, bool 
fill);
@@ -133,7 +141,7 @@
                virtual void GetBleeds(ScPage* page, double& left, double& 
right, double& bottom, double& top);
                virtual void SetClipPath(const FPointArray &points, bool poly = 
true);
                virtual void SetPathAndClip(const FPointArray &points, bool 
clipRule);
-               virtual void HandleBrushPattern(PageItem *item, QPainterPath 
&path, ScPage* a, uint PNr, bool sep, bool farb, bool master);
+               virtual void HandleBrushPattern(PageItem *item, QPainterPath 
&path, ScPage* a, uint PNr, bool master);
                virtual void HandleStrokePattern(PageItem *item);
                virtual void HandleMeshGradient(PageItem* item);
                virtual void HandlePatchMeshGradient(PageItem* item);
@@ -142,11 +150,9 @@
                virtual void HandleGradientFillStroke(PageItem *item, bool 
stroke = true, bool forArrow = false);
                virtual void SetColor(const QString& color, double shade, 
double *c, double *m, double *y, double *k);
                virtual void SetColor(const ScColor& color, double shade, 
double *c, double *m, double *y, double *k);
-               virtual void setTextSt(ScribusDoc* Doc, PageItem* ite, uint a, 
ScPage* pg, bool sep, bool farb, bool master);
-               bool psExport;
+               virtual void setTextSt(PageItem* ite, uint a, ScPage* pg, bool 
master);
 
        private:
-
                void PutStream (const QString& c);
                void PutStream (const QByteArray& array, bool hexEnc);
                void PutStream (const char* in, int length, bool hexEnc);
@@ -161,49 +167,42 @@
                void WriteASCII85Bytes(const unsigned char* array, int length);
 
                void paintBorder(const TableBorder& border, const QPointF& 
start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& 
endOffsetFactors);
-
-               Optimization optimization;
+               
+               ScribusDoc *m_Doc { nullptr };
+               Optimization m_optimization { OptimizeCompat };
+               OutputFormat m_outputFormat { OutputPS };
 
                QString ToStr(double c);
                QString IToStr(int c);
                QString MatrixToStr(double m11, double m12, double m21, double 
m22, double x, double y);
                QString PSEncode(const QString& in);
                QString ErrorMessage;
-               QString Prolog;
-               QString Header;
                QString Creator;
                QString User;
-               QString Titel;
+               QString Title;
                QString BBox;
                QString BBoxH;
                QString Farben;
                QString FNamen;
-               QString PDev;
-               QString GrayCalc;
-               bool GraySc;
-               int  PageIndex;
+               bool GraySc { false };
+               int  PageIndex { 0 };
                QString FillColor;
                QString StrokeColor;
                double LineW;
-               QString Fonts;
                QString FontDesc;
-               QMap<QString, QString> UsedFonts;
                QMap<QString, QString> FontSubsetMap;
-               bool isPDF;
                QFile Spool;
                QDataStream spoolStream;
                int  Plate;
-               bool DoSep;
-               bool useSpotColors;
+               bool DoSep { false };
                bool fillRule;
                ScColorTransform solidTransform;
                QString currentSpot;
                ColorList colorsToUse;
                QString colorDesc;
-               ScribusDoc *m_Doc;
                QMap<QString, QString> spotMap;
-               MultiProgressDialog* progressDialog;
-               bool abortExport;
+               MultiProgressDialog* progressDialog { nullptr };
+               bool abortExport { false };
                PrintOptions Options;
                ScPage* ActPage;
 

Modified: trunk/Scribus/scribus/scprintengine_gdi.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/scprintengine_gdi.cpp
==============================================================================
--- trunk/Scribus/scribus/scprintengine_gdi.cpp (original)
+++ trunk/Scribus/scribus/scprintengine_gdi.cpp Mon Apr  6 20:50:38 2020
@@ -428,21 +428,18 @@
 bool ScPrintEngine_GDI::printPage_PS(ScribusDoc* doc, ScPage* page, 
PrintOptions& options, HDC printerDC, cairo_t* /*context*/)
 {
        bool succeed = false;
-       ColorList usedColors;
        PrintOptions options2 = options;
-       QMap<QString, QMap<uint, FPointArray> > usedFonts;
        QString tempFilePath;
        int ret = 0;
 
-       doc->getUsedFonts(usedFonts);
-       doc->getUsedColors(usedColors);
        options2.pageNumbers.clear();
        options2.pageNumbers.push_back(page->pageNr() + 1);
+       options2.includePDFMarks = false;
 
        tempFilePath = PrefsManager::instance().preferencesLocation() + 
"/tmp.ps";
-       PSLib *dd = new PSLib(options2, false, 
PrefsManager::instance().appPrefs.fontPrefs.AvailFonts, usedFonts, usedColors, 
false, options2.useSpotColors);
+       PSLib *dd = new PSLib(doc, options2, PSLib::OutputEPS);
        dd->PS_set_file(tempFilePath);
-       ret = dd->CreatePS(doc, options2);
+       ret = dd->createPS(options2);
        delete dd;
        if (ret != 0) return false;
 

Modified: trunk/Scribus/scribus/scprintengine_ps.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/scprintengine_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/scprintengine_ps.cpp  (original)
+++ trunk/Scribus/scribus/scprintengine_ps.cpp  Mon Apr  6 20:50:38 2020
@@ -17,13 +17,9 @@
 bool ScPrintEngine_PS::print(ScribusDoc& doc, PrintOptions& options)
 {
        bool retw = false;
-       ColorList usedColors;
-       QMap<QString, QMap<uint, FPointArray> > usedFonts;
        QString filename(options.filename);
-       doc.getUsedFonts(usedFonts);
-       doc.getUsedColors(usedColors);
        PrefsManager& prefsManager = PrefsManager::instance();
-       PSLib *dd = new PSLib(options, true, 
prefsManager.appPrefs.fontPrefs.AvailFonts, usedFonts, usedColors, 
options.includePDFMarks, options.useSpotColors);
+       PSLib *dd = new PSLib(&doc, options, PSLib::OutputPS);
        if (dd == nullptr)
                return false;
 
@@ -39,11 +35,11 @@
        // Write the PS to a file
        filename = QDir::toNativeSeparators(filename);
 
-       int psCreationRetVal=dd->CreatePS(&doc, options);
-       if (psCreationRetVal!=0)
+       int psCreationRetVal = dd->createPS(options);
+       if (psCreationRetVal != 0)
        {
                QFile::remove(filename);
-               if (psCreationRetVal==2)
+               if (psCreationRetVal == 2)
                        return true;
                m_errorMessage = dd->errorMessage();
                return false;

Modified: trunk/Scribus/scribus/scribus.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp   (original)
+++ trunk/Scribus/scribus/scribus.cpp   Mon Apr  6 20:50:38 2020
@@ -6966,11 +6966,6 @@
        QStringList spots;
        bool return_value = true;
        ReOrderText(doc, view);
-       QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
-       ReallyUsed.clear();
-       doc->getUsedFonts(ReallyUsed);
-       ColorList usedColors;
-       doc->getUsedColors(usedColors);
        ScCore->fileWatcher->forceScan();
        ScCore->fileWatcher->stop();
        PrintOptions options;
@@ -6978,6 +6973,7 @@
        options.outputSeparations = false;
        options.separationName = "All";
        options.allSeparations = spots;
+       options.useSpotColors = true;
        options.useColor = true;
        options.mirrorH = false;
        options.mirrorV = false;
@@ -6988,16 +6984,17 @@
        options.bleedMarks = false;
        options.registrationMarks = false;
        options.colorMarks = false;
+       options.includePDFMarks = false;
        options.markLength = 20.0;
        options.markOffset = 0.0;
        options.bleeds.set(0, 0, 0, 0);
-       PSLib *pslib = new PSLib(options, false, 
m_prefsManager.appPrefs.fontPrefs.AvailFonts, ReallyUsed, usedColors, false, 
true);
+       PSLib *pslib = new PSLib(doc, options, PSLib::OutputEPS);
        if (pslib != nullptr)
        {
                qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
                if (pslib->PS_set_file(fn))
                {
-                       int psRet = pslib->CreatePS(doc, options);
+                       int psRet = pslib->createPS(options);
                        if (psRet == 1)
                        {
                                error = pslib->errorMessage();

Modified: trunk/Scribus/scribus/ui/preview.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23557&path=/trunk/Scribus/scribus/ui/preview.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/preview.cpp        (original)
+++ trunk/Scribus/scribus/ui/preview.cpp        Mon Apr  6 20:50:38 2020
@@ -479,7 +479,6 @@
 {
        int ret = -1;
        QString cmd1;
-       QMap<QString,QMap<uint, FPointArray> > ReallyUsed;
 #if defined _WIN32
        if (!postscriptPreview)
        {
@@ -511,13 +510,12 @@
                || (MirrorHor->isChecked() != mHor) || (MirrorVert->isChecked() 
!= mVer) || (ClipMarg->isChecked() != fClip)
                || (spotColors->isChecked() != fSpot))
        {
-               ReallyUsed.clear();
-               doc->getUsedFonts(ReallyUsed);
                PrintOptions options;
                options.pageNumbers.push_back(pageIndex + 1);
                options.outputSeparations = false;
                options.separationName = "All";
                options.allSeparations = QStringList();
+               options.useSpotColors = !spotColors->isChecked();
                options.useColor = !useGray->isChecked();
                options.mirrorH = MirrorHor->isChecked();
                options.mirrorV = MirrorVert->isChecked();
@@ -528,14 +526,15 @@
                options.bleedMarks = false;
                options.registrationMarks = false;
                options.colorMarks = false;
+               options.includePDFMarks = false;
                options.markLength = 20.0;
                options.markOffset = 0.0;
                options.bleeds.set(0, 0, 0, 0);
-               PSLib *dd = new PSLib(options, true, 
prefsManager.appPrefs.fontPrefs.AvailFonts, ReallyUsed, doc->PageColors, false, 
!spotColors->isChecked());
+               PSLib *dd = new PSLib(doc, options, PSLib::OutputPS, 
&doc->PageColors);
                if (!dd)
                        return ret;
                dd->PS_set_file( ScPaths::tempFileDir() + "/tmp.ps");
-               ret = dd->CreatePS(doc, options);
+               ret = dd->createPS(options);
                delete dd;
                if (ret != 0) return 1;
        }
@@ -616,19 +615,17 @@
        int ret = -1;
        QString cmd;
        QStringList args, args1, args2, args3;
-       QMap<QString, QMap<uint, FPointArray> > ReallyUsed;
        // Recreate Postscript-File only when the actual Page has changed
        if ((pageIndex != APage)  || (EnableGCR->isChecked() != GMode) || 
(useGray->isChecked() != fGray)
                || (MirrorHor->isChecked() != mHor) || (MirrorVert->isChecked() 
!= mVer) || (ClipMarg->isChecked() != fClip)
                || (spotColors->isChecked() != fSpot))
        {
-               ReallyUsed.clear();
-               doc->getUsedFonts(ReallyUsed);
                PrintOptions options;
                options.pageNumbers.push_back(pageIndex + 1);
                options.outputSeparations = false;
                options.separationName = "All";
                options.allSeparations = QStringList();
+               options.useSpotColors = !spotColors->isChecked();
                options.useColor = !useGray->isChecked();
                options.mirrorH = MirrorHor->isChecked();
                options.mirrorV = MirrorVert->isChecked();
@@ -639,14 +636,15 @@
                options.bleedMarks = false;
                options.registrationMarks = false;
                options.colorMarks = false;
+               options.includePDFMarks = false;
                options.markLength = 20.0;
                options.markOffset = 0.0;
                options.bleeds.set(0, 0, 0, 0);
-               PSLib *dd = new PSLib(options, true, 
prefsManager.appPrefs.fontPrefs.AvailFonts, ReallyUsed, doc->PageColors, false, 
!spotColors->isChecked());
+               PSLib *dd = new PSLib(doc, options, PSLib::OutputPS, 
&doc->PageColors);
                if (dd != nullptr)
                {
                        dd->PS_set_file(ScPaths::tempFileDir()+"/tmp.ps");
-                       ret = dd->CreatePS(doc, options);
+                       ret = dd->createPS(options);
                        delete dd;
                        if (ret != 0) return 1;
                }


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to