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