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