scprintengine_ps.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "scprintengine_ps.h"
00009 #include "scribusstructs.h"
00010 #include "scribusdoc.h"
00011 #include "scribuscore.h"
00012 #include "prefsmanager.h"
00013 #include "pslib.h"
00014 #include "util.h"
00015 #include "util_ghostscript.h"
00016
00017 bool ScPrintEngine_PS::print(ScribusDoc& doc, PrintOptions& options)
00018 {
00019 bool retw = false;
00020 ColorList usedColors;
00021 QMap<QString, QMap<uint, FPointArray> > usedFonts;
00022 QString filename(options.filename);
00023 doc.getUsedFonts(usedFonts);
00024 doc.getUsedColors(usedColors);
00025 PrefsManager *prefsManager = PrefsManager::instance();
00026 PSLib *dd = new PSLib(options, true, prefsManager->appPrefs.AvailFonts, usedFonts, usedColors, false, options.useSpotColors);
00027 if (dd != NULL)
00028 {
00029 if (!options.toFile)
00030 filename = prefsManager->preferencesLocation()+"/tmp.ps";
00031 bool PSfile = dd->PS_set_file(filename);
00032 filename = QDir::convertSeparators(filename);
00033 if (PSfile)
00034 {
00035
00036 int psCreationRetVal=dd->CreatePS(&doc, options);
00037 if (psCreationRetVal!=0)
00038 {
00039 QFile::remove(filename);
00040 if (psCreationRetVal==2)
00041 return true;
00042 else
00043 {
00044 m_errorMessage = dd->errorMessage();
00045 return false;
00046 }
00047 }
00048 if (options.prnEngine != PostScript3 && ScCore->haveGS())
00049 {
00050
00051 QString tmp;
00052 QStringList opts;
00053 opts.append( QString("-dDEVICEWIDTHPOINTS=%1").arg(tmp.setNum(doc.pageWidth)) );
00054 opts.append( QString("-dDEVICEHEIGHTPOINTS=%1").arg(tmp.setNum(doc.pageHeight)) );
00055 convertPS2PS(filename, filename + ".tmp", opts, options.prnEngine);
00056 moveFile( filename + ".tmp", filename );
00057 }
00058 if (!options.toFile)
00059 {
00060
00061 QByteArray cmd;
00062 if (options.useAltPrintCommand)
00063 {
00064 cmd += options.printerCommand;
00065 cmd += " ";
00066 cmd += filename;
00067 system(cmd.data());
00068 }
00069 else
00070 {
00071 QByteArray cc;
00072 cmd += "lpr -P '";
00073 cmd += options.printer;
00074 cmd += "'";
00075 if (options.copies > 1)
00076 cmd += " -#" + cc.setNum(options.copies);
00077 cmd += options.printerOptions;
00078 cmd += " "+filename;
00079 system(cmd.data());
00080 }
00081
00082
00083
00084 }
00085 retw = true;
00086 }
00087 else
00088 retw = false;
00089 delete dd;
00090 }
00091 return retw;
00092 }