Brought common part to a separate method.

--HG--
branch : develop
This commit is contained in:
dismine 2014-02-18 22:20:58 +02:00
parent 2b7570e886
commit 1264c1df58
2 changed files with 48 additions and 59 deletions

View File

@ -480,75 +480,57 @@ void TableWindow::PdfFile(const QString &name) const
void TableWindow::EpsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
QProcess proc;
QString program;
QStringList params;
if (tmp.open())
{
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
QStringList params;
params << "-eps" << tmp.fileName() << name;
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile F(name);
if(!F.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
"Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
PdfToPs(name, params);
}
}
void TableWindow::PsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
QProcess proc;
QString program;
QStringList params;
if (tmp.open())
{
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
QStringList params;
params << tmp.fileName() << name;
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile F(name);
if(!F.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
"Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
}
PdfToPs(name, params);
}
}
void TableWindow::PdfToPs(const QString &name, const QStringList &params) const
{
QProcess proc;
QString program;
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile f(name);
if (!f.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!", "Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
}

View File

@ -218,6 +218,13 @@ private:
* @param name name layout file.
*/
void PsFile(const QString &name)const;
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param name name output file.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void PdfToPs(const QString &name, const QStringList &params)const;
};
#endif // TABLEWINDOW_H