2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of the Lime Report project *
|
2021-08-18 20:21:36 +03:00
|
|
|
* Copyright (C) 2021 by Alexander Arin *
|
2016-02-17 10:11:00 +03:00
|
|
|
* arin_a@bk.ru *
|
|
|
|
* *
|
|
|
|
** GNU General Public License Usage **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
** GNU Lesser General Public License **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this library. *
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef LRREPORTDESIGNINTF_H
|
|
|
|
#define LRREPORTDESIGNINTF_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QPrintDialog>
|
2016-11-01 20:42:45 +03:00
|
|
|
//#include <QJSEngine>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
#include "lrglobal.h"
|
|
|
|
#include "lrdatasourcemanagerintf.h"
|
|
|
|
#include "lrscriptenginemanagerintf.h"
|
2016-03-30 23:21:44 +03:00
|
|
|
#include "lrpreviewreportwidget.h"
|
2017-11-27 23:14:05 +03:00
|
|
|
#include "lrreportdesignwindowintrerface.h"
|
2019-05-29 16:32:58 +03:00
|
|
|
#include "lrpreparedpagesintf.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
class QPrinter;
|
2019-03-11 22:12:35 +03:00
|
|
|
class QGraphicsScene;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
namespace LimeReport {
|
|
|
|
|
|
|
|
class PrintRange{
|
|
|
|
public:
|
|
|
|
int fromPage() const { return m_fromPage;}
|
|
|
|
int toPage() const { return m_toPage;}
|
|
|
|
QPrintDialog::PrintRange rangeType() const { return m_rangeType;}
|
|
|
|
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0);
|
|
|
|
void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;}
|
|
|
|
void setFromPage(int fromPage){ m_fromPage = fromPage;}
|
|
|
|
void setToPage(int toPage){ m_toPage = toPage;}
|
|
|
|
private:
|
|
|
|
QPrintDialog::PrintRange m_rangeType;
|
|
|
|
int m_fromPage;
|
|
|
|
int m_toPage;
|
|
|
|
};
|
|
|
|
|
2019-03-30 09:37:40 +03:00
|
|
|
class LIMEREPORT_EXPORT ItemGeometry{
|
|
|
|
public:
|
2019-06-11 22:18:54 +03:00
|
|
|
enum Type{Millimeters, Pixels};
|
|
|
|
ItemGeometry(qreal x, qreal y, qreal width, qreal height, Qt::Alignment anchor, Type type = Millimeters)
|
2019-04-02 22:56:12 +03:00
|
|
|
:m_x(x), m_y(y), m_width(width), m_height(height), m_type(type), m_anchor(anchor){}
|
2019-06-11 22:18:54 +03:00
|
|
|
ItemGeometry(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters){}
|
2019-03-30 09:37:40 +03:00
|
|
|
|
|
|
|
qreal x() const;
|
|
|
|
void setX(const qreal &x);
|
|
|
|
|
|
|
|
qreal y() const;
|
|
|
|
void setY(const qreal &y);
|
|
|
|
|
|
|
|
qreal width() const;
|
|
|
|
void setWidth(const qreal &width);
|
|
|
|
|
|
|
|
qreal height() const;
|
|
|
|
void setHeight(const qreal &height);
|
|
|
|
|
|
|
|
Type type() const;
|
|
|
|
void setType(const Type &type);
|
|
|
|
|
2019-04-02 22:56:12 +03:00
|
|
|
Qt::Alignment anchor() const;
|
|
|
|
void setAnchor(const Qt::Alignment &anchor);
|
|
|
|
|
2019-03-30 09:37:40 +03:00
|
|
|
private:
|
|
|
|
qreal m_x;
|
|
|
|
qreal m_y;
|
|
|
|
qreal m_width;
|
|
|
|
qreal m_height;
|
|
|
|
Type m_type;
|
2019-04-02 22:56:12 +03:00
|
|
|
Qt::Alignment m_anchor;
|
2019-03-30 09:37:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT WatermarkSetting{
|
|
|
|
public:
|
|
|
|
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font)
|
2019-04-06 00:28:02 +03:00
|
|
|
: m_text(text), m_font(font), m_opacity(50), m_geometry(geometry), m_color(QColor(Qt::black)){}
|
|
|
|
WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()){}
|
2019-03-30 09:37:40 +03:00
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &text);
|
|
|
|
|
|
|
|
QFont font() const;
|
|
|
|
void setFont(const QFont &font);
|
|
|
|
|
|
|
|
int opacity() const;
|
|
|
|
void setOpacity(const int &opacity);
|
|
|
|
|
2019-04-06 00:28:02 +03:00
|
|
|
ItemGeometry geometry() const;
|
|
|
|
void setGeometry(const ItemGeometry &geometry);
|
2019-03-30 09:37:40 +03:00
|
|
|
|
|
|
|
QColor color() const;
|
|
|
|
void setColor(const QColor &color);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_text;
|
|
|
|
QFont m_font;
|
|
|
|
int m_opacity;
|
2019-04-06 00:28:02 +03:00
|
|
|
ItemGeometry m_geometry;
|
2019-03-30 09:37:40 +03:00
|
|
|
QColor m_color;
|
|
|
|
};
|
|
|
|
|
2019-04-02 22:56:12 +03:00
|
|
|
class ItemBuilder{
|
|
|
|
virtual void setProperty(QString name, QVariant value) = 0;
|
|
|
|
virtual QVariant property(QString name) = 0;
|
|
|
|
virtual void setGeometry(ItemGeometry geometry) = 0;
|
|
|
|
virtual ItemGeometry geometry() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
class DataSourceManager;
|
|
|
|
class ReportEnginePrivate;
|
2016-06-10 18:05:18 +03:00
|
|
|
class PageDesignIntf;
|
|
|
|
class PageItemDesignIntf;
|
2017-03-22 14:42:09 +03:00
|
|
|
class ReportDesignWidget;
|
|
|
|
class PreviewReportWidget;
|
2019-05-29 16:32:58 +03:00
|
|
|
class PreparedPages;
|
2016-06-10 18:05:18 +03:00
|
|
|
|
|
|
|
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
|
|
|
Q_OBJECT
|
2017-03-22 14:42:09 +03:00
|
|
|
friend class ReportDesignWidget;
|
|
|
|
friend class PreviewReportWidget;
|
2017-08-05 01:38:19 +03:00
|
|
|
friend class TranslationEditor;
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
|
|
|
static void setSettings(QSettings *value){m_settings=value;}
|
|
|
|
public:
|
|
|
|
explicit ReportEngine(QObject *parent = 0);
|
|
|
|
~ReportEngine();
|
|
|
|
bool printReport(QPrinter *printer=0);
|
2019-02-09 23:57:19 +03:00
|
|
|
bool printReport(QMap<QString, QPrinter*> printers, bool printToAllPrinters = false);
|
2017-04-21 23:03:56 +03:00
|
|
|
bool printPages(ReportPages pages, QPrinter *printer);
|
2016-02-17 10:11:00 +03:00
|
|
|
void printToFile(const QString& fileName);
|
2019-03-11 22:12:35 +03:00
|
|
|
QGraphicsScene* createPreviewScene(QObject *parent = 0);
|
2016-02-17 10:19:50 +03:00
|
|
|
bool printToPDF(const QString& fileName);
|
2018-06-23 00:04:28 +03:00
|
|
|
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
2016-08-08 15:50:04 +03:00
|
|
|
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
2019-02-20 13:54:26 +03:00
|
|
|
void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting);
|
2016-02-17 10:11:00 +03:00
|
|
|
void designReport();
|
2017-11-27 23:14:05 +03:00
|
|
|
ReportDesignWindowInterface* getDesignerWindow();
|
2016-02-17 10:11:00 +03:00
|
|
|
void setShowProgressDialog(bool value);
|
2019-10-16 02:08:45 +03:00
|
|
|
bool isShowProgressDialog();
|
2016-02-17 10:11:00 +03:00
|
|
|
IDataSourceManager* dataManager();
|
|
|
|
IScriptEngineManager* scriptManager();
|
2017-04-20 05:43:48 +03:00
|
|
|
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
|
2016-02-17 10:11:00 +03:00
|
|
|
bool loadFromByteArray(QByteArray *data);
|
2016-02-17 10:39:17 +03:00
|
|
|
bool loadFromString(const QString& data);
|
2016-02-17 10:11:00 +03:00
|
|
|
QString reportFileName();
|
2016-04-21 14:58:21 +03:00
|
|
|
void setReportFileName(const QString& fileName);
|
2016-02-17 10:11:00 +03:00
|
|
|
bool saveToFile(const QString& fileName);
|
2016-02-17 10:39:17 +03:00
|
|
|
QByteArray saveToByteArray();
|
|
|
|
QString saveToString();
|
2016-02-17 10:11:00 +03:00
|
|
|
QString lastError();
|
2016-02-17 10:39:17 +03:00
|
|
|
void setCurrentReportsDir(const QString& dirName);
|
2024-07-25 21:44:11 +03:00
|
|
|
bool setDefaultExportDir(const QString& dirName);
|
2016-02-17 10:39:17 +03:00
|
|
|
void setReportName(const QString& name);
|
|
|
|
QString reportName();
|
2016-03-30 23:21:44 +03:00
|
|
|
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
|
2016-04-06 22:03:58 +03:00
|
|
|
void setPreviewWindowTitle(const QString& title);
|
|
|
|
void setPreviewWindowIcon(const QIcon& icon);
|
2019-02-18 15:16:55 +03:00
|
|
|
void setPreviewPageBackgroundColor(QColor color);
|
2017-02-03 14:20:30 +03:00
|
|
|
void setResultEditable(bool value);
|
|
|
|
bool resultIsEditable();
|
2019-04-10 16:23:50 +03:00
|
|
|
void setSaveToFileVisible(bool value);
|
|
|
|
bool saveToFileIsVisible();
|
|
|
|
void setPrintToPdfVisible(bool value);
|
|
|
|
bool printToPdfIsVisible();
|
|
|
|
void setPrintVisible(bool value);
|
|
|
|
bool printIsVisible();
|
2016-12-13 12:47:46 +03:00
|
|
|
bool isBusy();
|
2019-06-11 21:28:58 +03:00
|
|
|
void setPassPhrase(QString& passPhrase);
|
|
|
|
QList<QLocale::Language> availableLanguages();
|
2017-07-29 00:54:43 +03:00
|
|
|
bool setReportLanguage(QLocale::Language language);
|
2017-11-01 22:09:19 +03:00
|
|
|
Qt::LayoutDirection previewLayoutDirection();
|
|
|
|
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
2018-05-15 22:14:17 +03:00
|
|
|
QList<QLocale::Language> designerLanguages();
|
2018-04-10 16:28:48 +03:00
|
|
|
QLocale::Language currentDesignerLanguage();
|
2018-07-11 02:42:43 +03:00
|
|
|
ScaleType previewScaleType();
|
|
|
|
int previewScalePercent();
|
|
|
|
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
2019-03-30 09:37:40 +03:00
|
|
|
void addWatermark(const WatermarkSetting& watermarkSetting);
|
|
|
|
void clearWatermarks();
|
2019-05-29 03:41:18 +03:00
|
|
|
IPreparedPages* preparedPages();
|
|
|
|
bool showPreparedPages(PreviewHints hints = PreviewBarsUserSetting);
|
|
|
|
bool prepareReportPages();
|
2019-06-03 22:30:50 +03:00
|
|
|
bool printPreparedPages();
|
2020-01-09 21:22:58 +03:00
|
|
|
bool showDesignerModal() const;
|
|
|
|
void setShowDesignerModal(bool showDesignerModal);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
2018-06-04 22:31:03 +03:00
|
|
|
void cleared();
|
2016-02-17 10:11:00 +03:00
|
|
|
void renderStarted();
|
|
|
|
void renderFinished();
|
|
|
|
void renderPageFinished(int renderedPageCount);
|
2019-10-12 22:31:35 +03:00
|
|
|
|
|
|
|
void printingStarted(int pageCount);
|
|
|
|
void printingFinished();
|
|
|
|
void pagePrintingFinished(int index);
|
|
|
|
|
2018-05-23 19:01:30 +03:00
|
|
|
void onSave(bool& saved);
|
|
|
|
void onSaveAs(bool& saved);
|
2016-02-17 10:39:17 +03:00
|
|
|
void onLoad(bool& loaded);
|
2019-05-29 16:32:58 +03:00
|
|
|
void onSavePreview(bool& saved, LimeReport::IPreparedPages* pages);
|
2016-04-21 17:44:58 +03:00
|
|
|
void saveFinished();
|
2018-05-23 19:01:30 +03:00
|
|
|
void loadFinished();
|
2018-05-08 16:30:10 +03:00
|
|
|
void printedToPDF(QString fileName);
|
2018-05-21 21:18:23 +03:00
|
|
|
|
2019-06-11 21:55:59 +03:00
|
|
|
void getAvailableDesignerLanguages(QList<QLocale::Language>* languages);
|
|
|
|
void currentDefaultDesignerLanguageChanged(QLocale::Language);
|
|
|
|
QLocale::Language getCurrentDefaultDesignerLanguage();
|
2018-05-21 21:18:23 +03:00
|
|
|
|
2018-12-12 22:55:03 +03:00
|
|
|
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
public slots:
|
|
|
|
void cancelRender();
|
2019-10-13 14:20:26 +03:00
|
|
|
void cancelPrinting();
|
2016-02-17 10:11:00 +03:00
|
|
|
protected:
|
|
|
|
ReportEnginePrivate * const d_ptr;
|
|
|
|
ReportEngine(ReportEnginePrivate &dd, QObject * parent=0);
|
|
|
|
private:
|
|
|
|
Q_DECLARE_PRIVATE(ReportEngine)
|
|
|
|
static QSettings* m_settings;
|
2020-01-09 21:22:58 +03:00
|
|
|
bool m_showDesignerModal;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace LimeReport
|
|
|
|
|
|
|
|
#endif // LRREPORTDESIGNINTF_H
|