From c1191c4e9d874d3633d7b206d0b825ab50169644 Mon Sep 17 00:00:00 2001 From: Sabine Schmaltz Date: Mon, 17 Feb 2014 23:57:51 +0100 Subject: [PATCH] added saving of layout as .ps and .eps file --HG-- branch : develop --- src/tablewindow.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++-- src/tablewindow.h | 12 ++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp index ded1c8012..f42f48c75 100644 --- a/src/tablewindow.cpp +++ b/src/tablewindow.cpp @@ -166,6 +166,8 @@ void TableWindow::saveScene() extByMessage[ tr("Svg files (*.svg)") ] = ".svg"; extByMessage[ tr("PDF files (*.pdf)") ] = ".pdf"; extByMessage[ tr("Images (*.png)") ] = ".png"; + extByMessage[ tr("PS files (*.ps)") ] = ".ps"; + extByMessage[ tr("EPS files (*.eps)") ] = ".eps"; QString saveMessage; QMapIterator i(extByMessage); @@ -191,7 +193,8 @@ void TableWindow::saveScene() // what if the users did not specify a suffix...? QFileInfo f( name ); - if (f.suffix().isEmpty() && f.suffix() != "svg" && f.suffix() != "png" && f.suffix() != "pdf") + if (f.suffix().isEmpty() && f.suffix() != "svg" && f.suffix() != "png" && f.suffix() != "pdf" + && f.suffix() != "eps" && f.suffix() != "ps") { name += extByMessage[sf]; } @@ -220,7 +223,18 @@ void TableWindow::saveScene() PdfFile(name); paper->setPen(QPen(Qt::black, widthMainLine)); } - + else if (fi.suffix() == "eps") + { + paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); + EpsFile(name); + paper->setPen(QPen(Qt::black, widthMainLine)); + } + else if (fi.suffix() == "ps") + { + paper->setPen(QPen(Qt::white, 0.1, Qt::NoPen)); + PsFile(name); + paper->setPen(QPen(Qt::black, widthMainLine)); + } brush->setColor( QColor( Qt::gray ) ); brush->setStyle( Qt::SolidPattern ); tableScene->setBackgroundBrush( *brush ); @@ -460,3 +474,49 @@ void TableWindow::PdfFile(const QString &name) const tableScene->render(&painter); painter.end(); } + +void TableWindow::EpsFile(const QString &name) const +{ + QTemporaryFile tmp; + if (tmp.open()) { + QProcess proc; + QString program; + QStringList params; + + PdfFile(tmp.fileName()); + +#ifdef Q_OS_WIN32 + program = "pdftops.exe"; +#else + program = "pdftops"; +#endif + params << "-eps" << tmp.fileName() << name; + + proc.start(program,params); + proc.waitForFinished(); + qDebug() << proc.errorString(); + } +} + +void TableWindow::PsFile(const QString &name) const +{ + QTemporaryFile tmp; + if (tmp.open()) { + QProcess proc; + QString program; + QStringList params; + + PdfFile(tmp.fileName()); + +#ifdef Q_OS_WIN32 + program = "pdftops.exe"; +#else + program = "pdftops"; +#endif + params << tmp.fileName() << name; + + proc.start(program,params); + proc.waitForFinished(); + qDebug() << proc.errorString(); + } +} diff --git a/src/tablewindow.h b/src/tablewindow.h index 7047415d6..519867258 100644 --- a/src/tablewindow.h +++ b/src/tablewindow.h @@ -204,10 +204,20 @@ private: */ void PngFile(const QString &name)const; /** - * @brief PdfFile save layout to ps file. + * @brief PdfFile save layout to pdf file. * @param name name layout file. */ void PdfFile(const QString &name)const; + /** + * @brief EpsFile save layout to eps file. + * @param name name layout file. + */ + void EpsFile(const QString &name)const; + /** + * @brief PsFile save layout to ps file. + * @param name name layout file. + */ + void PsFile(const QString &name)const; }; #endif // TABLEWINDOW_H