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

View File

@ -218,6 +218,13 @@ private:
* @param name name layout file. * @param name name layout file.
*/ */
void PsFile(const QString &name)const; 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 #endif // TABLEWINDOW_H