Author: jghali
Date: Thu Sep 13 16:47:06 2018
New Revision: 22689

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22689
Log:
refactor ScPrintEngine_PS print()

Modified:
    trunk/Scribus/scribus/scprintengine_ps.cpp

Modified: trunk/Scribus/scribus/scprintengine_ps.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22689&path=/trunk/Scribus/scribus/scprintengine_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/scprintengine_ps.cpp  (original)
+++ trunk/Scribus/scribus/scprintengine_ps.cpp  Thu Sep 13 16:47:06 2018
@@ -29,61 +29,63 @@
 
        if (!options.toFile)
                filename = prefsManager->preferencesLocation()+"/tmp.ps";
-       bool PSfile = dd->PS_set_file(filename);
+       bool psFile = dd->PS_set_file(filename);
+       if (!psFile)
+       {
+               delete dd;
+               return false;
+       }
+
+       // Write the PS to a file
        filename = QDir::toNativeSeparators(filename);
-       if (PSfile)
+
+       int psCreationRetVal=dd->CreatePS(&doc, options);
+       if (psCreationRetVal!=0)
        {
-               // Write the PS to a file
-               int psCreationRetVal=dd->CreatePS(&doc, options);
-               if (psCreationRetVal!=0)
+               QFile::remove(filename);
+               if (psCreationRetVal==2)
+                       return true;
+               m_errorMessage = dd->errorMessage();
+               return false;
+       }
+       if (options.prnEngine != PostScript3 && ScCore->haveGS())
+       {
+               // use gs to convert our PS to a lower version
+               QString tmp;
+               QStringList opts;
+               opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(doc.pageWidth())) );
+               opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(doc.pageHeight())) );
+               convertPS2PS(filename, filename + ".tmp", opts, 
options.prnEngine);
+               moveFile(filename + ".tmp", filename);
+       }
+       if (!options.toFile)
+       {
+               // print and delete the PS file
+               QByteArray cmd;
+               if (options.useAltPrintCommand)
                {
-                       QFile::remove(filename);
-                       if (psCreationRetVal==2)
-                               return true;
-                       m_errorMessage = dd->errorMessage();
-                       return false;
+                       cmd += options.printerCommand;
+                       cmd += " ";
+                       cmd += filename;
+                       system(cmd.data());
                }
-               if (options.prnEngine != PostScript3 && ScCore->haveGS())
+               else
                {
-                       // use gs to convert our PS to a lower version
-                       QString tmp;
-                       QStringList opts;
-                       opts.append( 
QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(doc.pageWidth())) );
-                       opts.append( 
QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(doc.pageHeight())) );
-                       convertPS2PS(filename, filename + ".tmp", opts, 
options.prnEngine);
-                       moveFile(filename + ".tmp", filename);
+                       QByteArray cc;
+                       cmd += "lpr -P '";
+                       cmd += options.printer;
+                       cmd += "'";
+                       if (options.copies > 1)
+                               cmd += " -#" + cc.setNum(options.copies);
+                       cmd += options.printerOptions;
+                       cmd += " "+filename;
+                       system(cmd.data());
                }
-               if (!options.toFile)
-               {
-                       // print and delete the PS file
-                       QByteArray cmd;
-                       if (options.useAltPrintCommand)
-                       {
-                               cmd += options.printerCommand;
-                               cmd += " ";
-                               cmd += filename;
-                               system(cmd.data());
-                       }
-                       else
-                       {
-                               QByteArray cc;
-                               cmd += "lpr -P '";
-                               cmd += options.printer;
-                               cmd += "'";
-                               if (options.copies > 1)
-                                       cmd += " -#" + 
cc.setNum(options.copies);
-                               cmd += options.printerOptions;
-                               cmd += " "+filename;
-                               system(cmd.data());
-                       }
-// Disabled that for now, as kprinter won't work otherwise
-// leaving that file around doesn't harm, as it will be overwritten the next 
time.
-//                             unlink(filename);
-               }
-               retw = true;
+               // Disabled that for now, as kprinter won't work otherwise
+               // leaving that file around doesn't harm, as it will be 
overwritten the next time.
+               // unlink(filename);
        }
-       else
-               retw = false;
-       delete dd;
+
+       retw = true;
        return retw;
 }


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

Reply via email to