mirror of
https://github.com/fralx/LimeReport.git
synced 2025-09-23 08:29:07 +03:00
Exporters infrastructure has been added
This commit is contained in:
38
limereport/exporters/lrpdfexporter.cpp
Normal file
38
limereport/exporters/lrpdfexporter.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <QPrinter>
|
||||
|
||||
#include "lrpdfexporter.h"
|
||||
#include "lrexportersfactory.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent){
|
||||
return new LimeReport::PDFExporter(parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator("PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"), createPDFExporter);
|
||||
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
PDFExporter::PDFExporter(ReportEnginePrivate *parent) : QObject(parent), m_reportEngine(parent)
|
||||
{}
|
||||
|
||||
bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> ¶ms)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
if (!fileName.isEmpty()){
|
||||
QPrinter printer;
|
||||
printer.setOutputFileName(fileName);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
if (!pages.isEmpty()){
|
||||
m_reportEngine->printReport(pages, printer);
|
||||
}
|
||||
m_reportEngine->emitPrintedToPDF(fileName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
35
limereport/exporters/lrpdfexporter.h
Normal file
35
limereport/exporters/lrpdfexporter.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef LRPDFEXPORTER_H
|
||||
#define LRPDFEXPORTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrexporterintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class ReportEnginePrivate;
|
||||
|
||||
class PDFExporter : public QObject, public ReportExporterInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PDFExporter(ReportEnginePrivate *parent = nullptr);
|
||||
// ReportExporterInterface interface
|
||||
bool exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> ¶ms);
|
||||
QString exporterName()
|
||||
{
|
||||
return "PDF";
|
||||
}
|
||||
QString exporterFileExt()
|
||||
{
|
||||
return "pdf";
|
||||
}
|
||||
QString hint()
|
||||
{
|
||||
return tr("Export to PDF");
|
||||
}
|
||||
private:
|
||||
ReportEnginePrivate* m_reportEngine;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
#endif // LRPDFEXPORTER_H
|
Reference in New Issue
Block a user