mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
Exporters infrastructure has been added
This commit is contained in:
parent
44e37178d0
commit
fef507dde0
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
|
@ -48,6 +48,7 @@ public:
|
||||
~HorizontalLayout();
|
||||
BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
bool isSplittable() const { return true;}
|
||||
bool canContainChildren() const { return true;}
|
||||
|
||||
protected:
|
||||
void updateLayoutSize();
|
||||
|
@ -66,7 +66,8 @@ SOURCES += \
|
||||
$$REPORT_PATH/lrcolorindicator.cpp \
|
||||
$$REPORT_PATH/items/lrchartitem.cpp \
|
||||
$$REPORT_PATH/items/lrchartitemeditor.cpp \
|
||||
$$REPORT_PATH/lrreporttranslation.cpp
|
||||
$$REPORT_PATH/lrreporttranslation.cpp \
|
||||
$$REPORT_PATH/exporters/lrpdfexporter.cpp
|
||||
|
||||
contains(CONFIG, staticlib){
|
||||
SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp
|
||||
@ -144,7 +145,10 @@ HEADERS += \
|
||||
$$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.h \
|
||||
$$REPORT_PATH/items/editors/lritemsborderseditorwidget.h \
|
||||
$$REPORT_PATH/lrreporttranslation.h \
|
||||
$$REPORT_PATH/lrreportdesignwindowintrerface.h
|
||||
$$REPORT_PATH/lrreportdesignwindowintrerface.h \
|
||||
$$REPORT_PATH/lrexporterintf.h \
|
||||
$$REPORT_PATH/lrexportersfactory.h \
|
||||
$$REPORT_PATH/exporters/lrpdfexporter.h
|
||||
|
||||
contains(CONFIG, staticlib){
|
||||
HEADERS += $$REPORT_PATH/lrfactoryinitializer.h
|
||||
|
@ -1015,12 +1015,11 @@ void BandDesignIntf::setKeepFooterTogether(bool value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
qreal spaceBorder=0;
|
||||
if (keepBottomSpaceOption()) spaceBorder = bottomSpace();
|
||||
spaceBorder = spaceBorder>0 ? spaceBorder : 0;
|
||||
spaceBorder = spaceBorder > 0 ? spaceBorder : 0;
|
||||
if (borderLines()!=0){
|
||||
spaceBorder += borderLineSize();
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public:
|
||||
|
||||
bool startFromNewPage() const;
|
||||
void setStartFromNewPage(bool startFromNewPage);
|
||||
bool canContainChildren(){ return true;}
|
||||
bool canContainChildren() const{ return true;}
|
||||
bool printAlways() const;
|
||||
void setPrintAlways(bool printAlways);
|
||||
bool repeatOnEachRow() const;
|
||||
|
@ -227,6 +227,16 @@ qreal BaseDesignIntf::getItemPosY()
|
||||
return y() / mmFactor();
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::getAbsolutePosX()
|
||||
{
|
||||
return calcAbsolutePosX(0,this);
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::getAbsolutePosY()
|
||||
{
|
||||
return calcAbsolutePosY(0,this);
|
||||
}
|
||||
|
||||
QString BaseDesignIntf::setItemPosX(qreal xValue)
|
||||
{
|
||||
setItemPos(xValue * mmFactor(),y());
|
||||
@ -1485,6 +1495,24 @@ void BaseDesignIntf::addChildItems(QList<BaseDesignIntf*>* list){
|
||||
}
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::calcAbsolutePosY(qreal currentOffset, BaseDesignIntf *item)
|
||||
{
|
||||
BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(item->parent());
|
||||
if (parent)
|
||||
return calcAbsolutePosY(currentOffset + item->getItemPosY(), parent);
|
||||
else
|
||||
return currentOffset + item->getItemPosY();
|
||||
}
|
||||
|
||||
qreal BaseDesignIntf::calcAbsolutePosX(qreal currentOffset, BaseDesignIntf *item)
|
||||
{
|
||||
BaseDesignIntf* parent = dynamic_cast<BaseDesignIntf*>(item->parent());
|
||||
if (parent)
|
||||
return calcAbsolutePosX(currentOffset + item->getItemPosX(), parent);
|
||||
else
|
||||
return currentOffset + item->getItemPosX();
|
||||
}
|
||||
|
||||
QList<BaseDesignIntf*> BaseDesignIntf::allChildBaseItems()
|
||||
{
|
||||
QList<BaseDesignIntf *> resList;
|
||||
|
@ -268,7 +268,7 @@ public:
|
||||
QColor borderColor() const;
|
||||
void setBorderColor(const QColor &borderColor);
|
||||
void setItemVisible(const bool& value);
|
||||
virtual bool canContainChildren(){ return false;}
|
||||
virtual bool canContainChildren() const { return false;}
|
||||
ReportSettings* reportSettings() const;
|
||||
void setReportSettings(ReportSettings *reportSettings);
|
||||
void setZValueProperty(qreal value);
|
||||
@ -288,6 +288,8 @@ public:
|
||||
Q_INVOKABLE qreal getItemHeight();
|
||||
Q_INVOKABLE qreal getItemPosX();
|
||||
Q_INVOKABLE qreal getItemPosY();
|
||||
Q_INVOKABLE qreal getAbsolutePosX();
|
||||
Q_INVOKABLE qreal getAbsolutePosY();
|
||||
Q_INVOKABLE QString setItemPosX(qreal xValue);
|
||||
Q_INVOKABLE QString setItemPosY(qreal yValue);
|
||||
|
||||
@ -352,7 +354,8 @@ protected:
|
||||
virtual void processPopUpAction(QAction* action){Q_UNUSED(action)}
|
||||
|
||||
void addChildItems(QList<BaseDesignIntf*>* list);
|
||||
|
||||
qreal calcAbsolutePosY(qreal currentOffset, BaseDesignIntf* item);
|
||||
qreal calcAbsolutePosX(qreal currentOffset, BaseDesignIntf* item);
|
||||
private:
|
||||
void updateSelectionMarker();
|
||||
int resizeDirectionFlags(QPointF position);
|
||||
@ -410,7 +413,7 @@ private:
|
||||
QString m_patternName;
|
||||
BaseDesignIntf* m_patternItem;
|
||||
bool m_fillInSecondPass;
|
||||
bool m_watermark;
|
||||
bool m_watermark;
|
||||
|
||||
signals:
|
||||
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||
|
@ -31,7 +31,6 @@
|
||||
#define LRDESIGNELEMENTSFACTORY_H
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
//#include "lrpageheader.h"
|
||||
#include "lrattribsabstractfactory.h"
|
||||
#include "lrsimpleabstractfactory.h"
|
||||
#include "lrsingleton.h"
|
||||
|
21
limereport/lrexporterintf.h
Normal file
21
limereport/lrexporterintf.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef LREXPORTERINTF_H
|
||||
#define LREXPORTERINTF_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QtPlugin>
|
||||
#include "lrpageitemdesignintf.h"
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ReportExporterInterface {
|
||||
public:
|
||||
virtual ~ReportExporterInterface(){}
|
||||
virtual bool exportPages(LimeReport::ReportPages pages, const QString& fileName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>()) = 0;
|
||||
virtual QString exporterName() = 0;
|
||||
virtual QString exporterFileExt() = 0;
|
||||
virtual QString hint() = 0;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
#endif // LREXPORTERINTF_H
|
34
limereport/lrexportersfactory.h
Normal file
34
limereport/lrexportersfactory.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef LREXPORTERSFACTORY_H
|
||||
#define LREXPORTERSFACTORY_H
|
||||
|
||||
#include "lrattribsabstractfactory.h"
|
||||
#include "lrexporterintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
typedef ReportExporterInterface* (*CreateExporter)(ReportEnginePrivate* parent);
|
||||
|
||||
struct ExporterAttribs{
|
||||
QString m_alias;
|
||||
QString m_tag;
|
||||
ExporterAttribs(){}
|
||||
ExporterAttribs(const QString& alias, const QString& tag):m_alias(alias),m_tag(tag){}
|
||||
bool operator==( const ExporterAttribs &right) const {
|
||||
return (m_alias==right.m_alias) && (m_tag==right.m_tag);
|
||||
}
|
||||
};
|
||||
|
||||
class ExportersFactory : public AttribsAbstractFactory<LimeReport::ReportExporterInterface, QString, CreateExporter, ExporterAttribs>
|
||||
{
|
||||
private:
|
||||
friend class Singleton<ExportersFactory>;
|
||||
private:
|
||||
ExportersFactory(){}
|
||||
~ExportersFactory(){}
|
||||
ExportersFactory(const ExportersFactory&){}
|
||||
ExportersFactory& operator = (const ExportersFactory&){return *this;}
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LREXPORTERSFACTORY_H
|
@ -41,6 +41,10 @@
|
||||
#include "serializators/lrxmlqrectserializator.h"
|
||||
#include "serializators/lrxmlserializatorsfactory.h"
|
||||
|
||||
#include "lrexportersfactory.h"
|
||||
#include "lrexporterintf.h"
|
||||
#include "exporters/lrpdfexporter.h"
|
||||
|
||||
void initResources(){
|
||||
Q_INIT_RESOURCE(report);
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
@ -442,4 +446,17 @@ void initSerializators()
|
||||
XMLAbstractSerializatorFactory::instance().registerCreator("QRectF", createQRectSerializator);
|
||||
}
|
||||
|
||||
LimeReport::ReportExporterInterface* createPDFExporter(ReportEnginePrivate* parent){
|
||||
return new LimeReport::PDFExporter(parent);
|
||||
}
|
||||
|
||||
void initExporters()
|
||||
{
|
||||
ExportersFactory::instance().registerCreator(
|
||||
"PDF",
|
||||
LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"),
|
||||
createPDFExporter
|
||||
);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
|
@ -3,4 +3,5 @@ namespace LimeReport{
|
||||
void initReportItems();
|
||||
void initObjectInspectorProperties();
|
||||
void initSerializators();
|
||||
void initExporters();
|
||||
} // namespace LimeReport
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
|
||||
bool oldPrintMode() const;
|
||||
void setOldPrintMode(bool oldPrintMode);
|
||||
bool canContainChildren(){ return true;}
|
||||
bool canContainChildren() const{ return true;}
|
||||
bool resetPageNumber() const;
|
||||
void setResetPageNumber(bool resetPageNumber);
|
||||
void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager);
|
||||
|
@ -13,6 +13,9 @@
|
||||
#include "lrpreviewreportwidget_p.h"
|
||||
#include "serializators/lrxmlwriter.h"
|
||||
|
||||
#include "lrexportersfactory.h"
|
||||
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
bool PreviewReportWidgetPrivate::pageIsVisible(){
|
||||
@ -60,6 +63,11 @@ PageItemDesignIntf::Ptr PreviewReportWidgetPrivate::currentPage()
|
||||
else return PageItemDesignIntf::Ptr(0);
|
||||
}
|
||||
|
||||
QList<QString> PreviewReportWidgetPrivate::aviableExporters()
|
||||
{
|
||||
return ExportersFactory::instance().map().keys();
|
||||
}
|
||||
|
||||
PreviewReportWidget::PreviewReportWidget(ReportEngine *report, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this))
|
||||
@ -86,6 +94,31 @@ PreviewReportWidget::~PreviewReportWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QList<QString> PreviewReportWidget::aviableExporters()
|
||||
{
|
||||
return d_ptr->aviableExporters();
|
||||
}
|
||||
|
||||
bool PreviewReportWidget::exportReport(QString exporterName, const QMap<QString, QVariant> ¶ms)
|
||||
{
|
||||
if (ExportersFactory::instance().map().contains(exporterName)){
|
||||
|
||||
ReportExporterInterface* e = ExportersFactory::instance().objectCreator(exporterName)(d_ptr->m_report);
|
||||
|
||||
QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt());
|
||||
QString fileName = QFileDialog::getSaveFileName(this,tr("%1 file name").arg(e->exporterName()),"",filter);
|
||||
if (!fileName.isEmpty()){
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.suffix().isEmpty())
|
||||
fileName += QString(".%1").arg(e->exporterFileExt());
|
||||
bool result = e->exportPages(d_ptr->m_reportPages, fileName, params);
|
||||
delete e;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PreviewReportWidget::initPreview()
|
||||
{
|
||||
if (ui->graphicsView->scene()!=d_ptr->m_previewPage)
|
||||
@ -185,22 +218,11 @@ void PreviewReportWidget::print()
|
||||
|
||||
void PreviewReportWidget::printToPDF()
|
||||
{
|
||||
QString filter = "PDF (*.pdf)";
|
||||
QString fileName = QFileDialog::getSaveFileName(this,tr("PDF file name"),"","PDF (*.pdf)");
|
||||
if (!fileName.isEmpty()){
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.suffix().isEmpty())
|
||||
fileName+=".pdf";
|
||||
QPrinter printer;
|
||||
printer.setOutputFileName(fileName);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
if (!d_ptr->m_reportPages.isEmpty()){
|
||||
ReportEnginePrivate::printReport(d_ptr->m_reportPages,printer);
|
||||
}
|
||||
if (!d_ptr->m_reportPages.isEmpty()){
|
||||
exportReport("PDF");
|
||||
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
|
||||
d_ptr->m_previewPage->reactivatePageItem(pageItem);
|
||||
}
|
||||
d_ptr->m_report->emitPrintedToPDF(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
|
||||
friend class PreviewReportWidgetPrivate;
|
||||
public:
|
||||
explicit PreviewReportWidget(ReportEngine *report, QWidget *parent = 0);
|
||||
~PreviewReportWidget();
|
||||
~PreviewReportWidget();
|
||||
QList<QString> aviableExporters();
|
||||
bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
public slots:
|
||||
void refreshPages();
|
||||
void zoomIn();
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
QRectF calcPageShift();
|
||||
void setPages( ReportPages pages);
|
||||
PageItemDesignIntf::Ptr currentPage();
|
||||
QList<QString> aviableExporters();
|
||||
public:
|
||||
PageDesignIntf* m_previewPage;
|
||||
ReportPages m_reportPages;
|
||||
|
@ -35,7 +35,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>19</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
@ -283,6 +283,8 @@
|
||||
<resources>
|
||||
<include location="report.qrc"/>
|
||||
<include location="databrowser/lrdatabrowser.qrc"/>
|
||||
<include location="report.qrc"/>
|
||||
<include location="databrowser/lrdatabrowser.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QPluginLoader>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "time.h"
|
||||
|
||||
@ -55,6 +56,8 @@
|
||||
#include "lrpreviewreportwindow.h"
|
||||
#include "lrpreviewreportwidget.h"
|
||||
#include "lrpreviewreportwidget_p.h"
|
||||
#include "lrexporterintf.h"
|
||||
#include "lrexportersfactory.h"
|
||||
|
||||
#ifdef BUILD_WITH_EASY_PROFILER
|
||||
#include "easy/profiler.h"
|
||||
@ -63,7 +66,6 @@
|
||||
# define EASY_END_BLOCK
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_STATIC_BUILD
|
||||
#include "lrfactoryinitializer.h"
|
||||
#endif
|
||||
@ -102,7 +104,6 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
connect(m_datasources,SIGNAL(loadCollectionFinished(QString)),this,SLOT(slotDataSourceCollectionLoaded(QString)));
|
||||
connect(m_fileWatcher,SIGNAL(fileChanged(const QString &)),this,SLOT(slotLoadFromFile(const QString &)));
|
||||
|
||||
#ifndef HAVE_REPORT_DESIGNER
|
||||
QDir pluginsDir = QCoreApplication::applicationDirPath();
|
||||
pluginsDir.cd("../lib" );
|
||||
if (!pluginsDir.exists()){
|
||||
@ -113,13 +114,15 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) :
|
||||
foreach( const QString& pluginName, pluginsDir.entryList( QDir::Files ) ) {
|
||||
QPluginLoader loader( pluginsDir.absoluteFilePath( pluginName ) );
|
||||
if( loader.load() ) {
|
||||
#ifndef HAVE_REPORT_DESIGNER
|
||||
if( LimeReportDesignerPluginInterface* designerPlugin = qobject_cast< LimeReportDesignerPluginInterface* >( loader.instance() ) ) {
|
||||
m_designerFactory = designerPlugin;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ReportEnginePrivate::~ReportEnginePrivate()
|
||||
@ -476,17 +479,31 @@ void ReportEnginePrivate::printToFile(const QString &fileName)
|
||||
|
||||
bool ReportEnginePrivate::printToPDF(const QString &fileName)
|
||||
{
|
||||
if (!fileName.isEmpty()){
|
||||
QFileInfo fi(fileName);
|
||||
QString fn = fileName;
|
||||
if (fi.suffix().isEmpty())
|
||||
fn+=".pdf";
|
||||
QPrinter printer;
|
||||
printer.setOutputFileName(fn);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
bool success = printReport(&printer);
|
||||
if(success) emitPrintedToPDF(fileName);
|
||||
return success;
|
||||
return exportReport("PDF");
|
||||
}
|
||||
|
||||
bool ReportEnginePrivate::exportReport(QString exporterName, const QString &fileName, const QMap<QString, QVariant> ¶ms)
|
||||
{
|
||||
QString fn = fileName;
|
||||
if (ExportersFactory::instance().map().contains(exporterName)){
|
||||
ReportExporterInterface* e = ExportersFactory::instance().objectCreator(exporterName)(this);
|
||||
if (fn.isEmpty()){
|
||||
QString filter = QString("%1 (*.%2)").arg(e->exporterName()).arg(e->exporterFileExt());
|
||||
QString fn = QFileDialog::getSaveFileName(0,tr("%1 file name").arg(e->exporterName()),"",filter);
|
||||
if (!fn.isEmpty()){
|
||||
QFileInfo fi(fn);
|
||||
if (fi.suffix().isEmpty())
|
||||
fn += QString(".%1").arg(e->exporterFileExt());
|
||||
|
||||
bool designTime = dataManager()->designTime();
|
||||
dataManager()->setDesignTime(false);
|
||||
ReportPages pages = renderToPages();
|
||||
dataManager()->setDesignTime(designTime);
|
||||
bool result = e->exportPages(pages, fn, params);
|
||||
delete e;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1221,6 +1238,12 @@ bool ReportEngine::printToPDF(const QString &fileName)
|
||||
return d->printToPDF(fileName);
|
||||
}
|
||||
|
||||
bool ReportEngine::exportReport(QString exporterName, const QString &fileName, const QMap<QString, QVariant> ¶ms)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
return d->exportReport(exporterName, fileName, params);
|
||||
}
|
||||
|
||||
void ReportEngine::previewReport(PreviewHints hints)
|
||||
{
|
||||
Q_D(ReportEngine);
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
void printToFile(const QString& fileName);
|
||||
PageDesignIntf *createPreviewScene(QObject *parent = 0);
|
||||
bool printToPDF(const QString& fileName);
|
||||
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
||||
void designReport();
|
||||
ReportDesignWindowInterface* getDesignerWindow();
|
||||
|
@ -48,11 +48,13 @@
|
||||
|
||||
class QFileSystemWatcher;
|
||||
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class PageDesignIntf;
|
||||
class PrintRange;
|
||||
class ReportDesignWindow;
|
||||
class ReportExporterInterface;
|
||||
|
||||
class ReportEnginePrivateInterface {
|
||||
public:
|
||||
@ -132,6 +134,7 @@ public:
|
||||
bool printPages(ReportPages pages, QPrinter *printer);
|
||||
void printToFile(const QString& fileName);
|
||||
bool printToPDF(const QString& fileName);
|
||||
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
||||
|
||||
ReportDesignWindowInterface* getDesignerWindow();
|
||||
@ -267,6 +270,7 @@ private:
|
||||
LimeReportDesignerPluginInterface* m_designerFactory;
|
||||
QString m_styleSheet;
|
||||
QLocale::Language m_currentDesignerLanguage;
|
||||
QMap<QString, ReportExporterInterface*> exporters;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user