From 1264c1df5866757e4a53cfb9a7608018c58a68bd Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 18 Feb 2014 22:20:58 +0200 Subject: [PATCH] Brought common part to a separate method. --HG-- branch : develop --- src/tablewindow.cpp | 100 ++++++++++++++++++-------------------------- src/tablewindow.h | 7 ++++ 2 files changed, 48 insertions(+), 59 deletions(-) diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp index 3eaf9abf2..b08b548c4 100644 --- a/src/tablewindow.cpp +++ b/src/tablewindow.cpp @@ -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 ¶ms) 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(); + } } diff --git a/src/tablewindow.h b/src/tablewindow.h index 519867258..fea934939 100644 --- a/src/tablewindow.h +++ b/src/tablewindow.h @@ -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 ¶ms)const; }; #endif // TABLEWINDOW_H