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 LRREPORTRENDER_H
|
|
|
|
#define LRREPORTRENDER_H
|
|
|
|
#include "lrcollection.h"
|
|
|
|
#include "lrdatasourcemanager.h"
|
|
|
|
#include "lrpageitemdesignintf.h"
|
2016-06-10 18:05:18 +03:00
|
|
|
#include "lrscriptenginemanager.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "serializators/lrstorageintf.h"
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
namespace LimeReport {
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
class PageDesignIntf;
|
|
|
|
class BandDesignIntf;
|
2017-06-13 17:48:22 +03:00
|
|
|
class ContentItemDesignIntf;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class GroupBandsHolder: public QList<BandDesignIntf*> {
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
GroupBandsHolder(bool tryToKeepTogether):
|
|
|
|
QList<BandDesignIntf*>(),
|
|
|
|
m_tryToKeepTogether(tryToKeepTogether),
|
|
|
|
m_dataGroup(true),
|
|
|
|
m_footerGroup(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool tryToKeepTogether() { return m_tryToKeepTogether; }
|
|
|
|
void setTryToKeepTogether(bool value) { m_tryToKeepTogether = value; }
|
|
|
|
bool isDataGroup() { return m_dataGroup; }
|
|
|
|
bool isFooterGroup() { return m_footerGroup; }
|
|
|
|
void setIsFooterGroup()
|
|
|
|
{
|
|
|
|
m_footerGroup = true;
|
|
|
|
m_dataGroup = false;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
|
|
|
bool m_tryToKeepTogether;
|
|
|
|
bool m_dataGroup;
|
|
|
|
bool m_footerGroup;
|
|
|
|
};
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
struct PagesRange {
|
2016-02-17 10:28:27 +03:00
|
|
|
int firstPage;
|
|
|
|
int lastPage;
|
2019-01-16 03:58:54 +03:00
|
|
|
bool isTOC;
|
|
|
|
};
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class PagesRanges {
|
2019-01-16 03:58:54 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
PagesRanges(): m_TOCRangeIndex(-1) { }
|
2019-01-16 03:58:54 +03:00
|
|
|
int findLastPageNumber(int index);
|
|
|
|
int findPageNumber(int index);
|
2019-01-17 00:26:27 +03:00
|
|
|
PagesRange& currentRange(bool isTOC);
|
2019-01-16 03:58:54 +03:00
|
|
|
void startNewRange(bool isTOC = false);
|
|
|
|
void addTOCMarker(bool addNewRange);
|
|
|
|
void addPage();
|
|
|
|
void addTOCPage();
|
|
|
|
void clear();
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2019-01-16 03:58:54 +03:00
|
|
|
private:
|
|
|
|
void shiftRangesNextToTOC();
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2019-01-16 03:58:54 +03:00
|
|
|
private:
|
|
|
|
QVector<PagesRange> m_ranges;
|
|
|
|
int m_TOCRangeIndex;
|
2016-02-17 10:28:27 +03:00
|
|
|
};
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class ReportRender: public QObject {
|
2016-02-17 10:11:00 +03:00
|
|
|
Q_OBJECT
|
2021-08-18 05:32:45 +03:00
|
|
|
Q_PROPERTY(QObject* datasourcesManager READ datasources)
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
enum DataRenderMode {
|
|
|
|
StartNewPageAsNeeded,
|
|
|
|
NotStartNewPage,
|
|
|
|
ForcedStartPage
|
|
|
|
};
|
|
|
|
enum BandPrintMode {
|
|
|
|
PrintAlwaysPrintable,
|
|
|
|
PrintNotAlwaysPrintable
|
|
|
|
};
|
|
|
|
enum ResetPageNuberType {
|
|
|
|
BandReset,
|
|
|
|
PageReset
|
|
|
|
};
|
|
|
|
enum PageRenderStage {
|
|
|
|
BeforePageHeader,
|
|
|
|
AfterPageHeader
|
|
|
|
};
|
|
|
|
typedef QSharedPointer<ReportRender> Ptr;
|
2016-02-17 10:11:00 +03:00
|
|
|
~ReportRender();
|
2024-09-04 17:31:16 +03:00
|
|
|
ReportRender(QObject* parent = 0);
|
2016-02-17 10:11:00 +03:00
|
|
|
void setDatasources(DataSourceManager* value);
|
2016-06-10 18:05:18 +03:00
|
|
|
void setScriptContext(ScriptEngineContext* scriptContext);
|
2024-09-04 17:31:16 +03:00
|
|
|
DataSourceManager* datasources() { return m_datasources; }
|
|
|
|
int pageCount();
|
2016-02-17 10:11:00 +03:00
|
|
|
PageItemDesignIntf::Ptr pageAt(int index);
|
2024-09-04 17:31:16 +03:00
|
|
|
QString renderPageToString(PageItemDesignIntf* patternPage);
|
|
|
|
ReportPages renderPageToPages(PageItemDesignIntf* patternPage);
|
|
|
|
ReportPages renderTOC(PageItemDesignIntf* patternPage, bool first, bool resetPages);
|
|
|
|
void secondRenderPass(ReportPages renderedPages);
|
|
|
|
void createTOCMarker(bool startNewRange);
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
2024-09-04 17:31:16 +03:00
|
|
|
void pageRendered(int renderedPageCount);
|
2016-02-17 10:11:00 +03:00
|
|
|
public slots:
|
2024-09-04 17:31:16 +03:00
|
|
|
void cancelRender();
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
2024-09-04 17:31:16 +03:00
|
|
|
void analizeContainer(BaseDesignIntf* item, BandDesignIntf* band);
|
|
|
|
void analizeItem(ContentItemDesignIntf* item, BandDesignIntf* band);
|
|
|
|
void analizePage(PageItemDesignIntf* patternPage);
|
|
|
|
|
|
|
|
void initDatasources();
|
|
|
|
void initDatasource(const QString& name);
|
|
|
|
void initRenderPage();
|
|
|
|
void initVariables();
|
|
|
|
void initGroups();
|
|
|
|
void clearPageMap();
|
|
|
|
|
|
|
|
void renderPage(PageItemDesignIntf* patternPage, bool isTOC = false, bool isFirst = false,
|
|
|
|
bool = false);
|
|
|
|
BandDesignIntf* renderBand(BandDesignIntf* patternBand, BandDesignIntf* bandData,
|
|
|
|
DataRenderMode mode = NotStartNewPage, bool isLast = false);
|
|
|
|
void renderDataBand(BandDesignIntf* dataBand);
|
|
|
|
void renderPageHeader(PageItemDesignIntf* patternPage);
|
|
|
|
void renderReportHeader(PageItemDesignIntf* patternPage, PageRenderStage stage);
|
|
|
|
void renderPageFooter(PageItemDesignIntf* patternPage);
|
|
|
|
void renderPageItems(PageItemDesignIntf* patternPage);
|
|
|
|
void renderChildHeader(BandDesignIntf* parent, BandPrintMode printMode);
|
|
|
|
void renderChildFooter(BandDesignIntf* parent, BandPrintMode printMode);
|
|
|
|
void renderChildBands(BandDesignIntf* parentBand);
|
|
|
|
void recalcIfNeeded(BandDesignIntf* band);
|
|
|
|
void renderDataHeader(BandDesignIntf* header);
|
|
|
|
void renderGroupHeader(BandDesignIntf* parentBand, IDataSource* dataSource, bool firstTime);
|
|
|
|
void renderGroupFooter(BandDesignIntf* parentBand);
|
|
|
|
void moveTearOffBand();
|
|
|
|
qreal calcPageFooterHeight(PageItemDesignIntf* patternPage);
|
|
|
|
qreal calcSlicePercent(qreal height);
|
|
|
|
|
|
|
|
bool containsGroupFunctions(BaseDesignIntf* container);
|
|
|
|
void extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band);
|
|
|
|
void extractGroupFunctionsFromContainer(BaseDesignIntf* baseItem, BandDesignIntf* band);
|
|
|
|
void extractGroupFunctions(BandDesignIntf* band);
|
|
|
|
void replaceGroupFunctionsInItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band);
|
|
|
|
void replaceGroupFunctionsInContainer(BaseDesignIntf* baseItem, BandDesignIntf* band);
|
|
|
|
void replaceGroupsFunction(BandDesignIntf* band);
|
|
|
|
|
|
|
|
BandDesignIntf* findRecalcableBand(BandDesignIntf* patternBand);
|
|
|
|
|
|
|
|
void popPageFooterGroupValues(BandDesignIntf* dataBand);
|
|
|
|
void pushPageFooterGroupValues(BandDesignIntf* dataBand);
|
|
|
|
|
|
|
|
enum GroupType {
|
|
|
|
DATA,
|
|
|
|
FOOTER
|
|
|
|
};
|
|
|
|
void closeGroup(BandDesignIntf* band);
|
|
|
|
void openDataGroup(BandDesignIntf* band);
|
|
|
|
void closeDataGroup(BandDesignIntf* band);
|
|
|
|
void openFooterGroup(BandDesignIntf* band);
|
|
|
|
void closeFooterGroup(BandDesignIntf* band);
|
|
|
|
void cutGroups();
|
|
|
|
void checkFooterGroup(BandDesignIntf* groupBand);
|
|
|
|
void pasteGroups();
|
|
|
|
void checkLostHeadersOnPrevPage();
|
|
|
|
void checkLostHeadersInPrevColumn();
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
BandDesignIntf* findEnclosingGroup();
|
2024-09-04 17:31:16 +03:00
|
|
|
bool registerBand(BandDesignIntf* band, bool registerInChildren = true);
|
|
|
|
BandDesignIntf* sliceBand(BandDesignIntf* band, BandDesignIntf* patternBand, bool isLast);
|
2016-09-16 01:59:56 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf* band, int height,
|
|
|
|
BandDesignIntf* patternBand);
|
2021-01-10 23:28:16 +03:00
|
|
|
BandDesignIntf* renderData(BandDesignIntf* patternBand, bool emitBeforeRender = true);
|
2024-09-04 17:31:16 +03:00
|
|
|
void startNewColumn();
|
|
|
|
void startNewPage(bool isFirst = false);
|
|
|
|
void resetPageNumber(ResetPageNuberType resetType);
|
|
|
|
void savePage(bool isLast = false);
|
2016-02-17 10:11:00 +03:00
|
|
|
QString toString();
|
2016-02-17 10:28:27 +03:00
|
|
|
void initColumns();
|
2016-02-17 10:39:17 +03:00
|
|
|
bool isNeedToRearrangeColumnsItems();
|
|
|
|
BandDesignIntf* lastColumnItem(int columnIndex);
|
|
|
|
void rearrangeColumnsItems();
|
2024-09-04 17:31:16 +03:00
|
|
|
int columnItemsCount(int columnIndex);
|
2016-02-17 10:39:17 +03:00
|
|
|
qreal columnHeigth(int columnIndex);
|
|
|
|
qreal maxColumnHeight();
|
2024-09-04 17:31:16 +03:00
|
|
|
void renameChildItems(BaseDesignIntf* item);
|
|
|
|
void renderGroupFooterByHeader(BandDesignIntf* groupHeader);
|
2017-08-25 18:01:59 +03:00
|
|
|
void updateTOC(BaseDesignIntf* item, int pageNumber);
|
2024-09-04 17:31:16 +03:00
|
|
|
void placeBandOnPage(BandDesignIntf* band, int columnIndex);
|
|
|
|
QColor makeBackgroundColor(BandDesignIntf* band);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
|
|
|
DataSourceManager* m_datasources;
|
2016-06-10 18:05:18 +03:00
|
|
|
ScriptEngineContext* m_scriptEngineContext;
|
2016-02-17 10:11:00 +03:00
|
|
|
PageItemDesignIntf* m_renderPageItem;
|
|
|
|
PageItemDesignIntf* m_patternPageItem;
|
|
|
|
QList<PageItemDesignIntf::Ptr> m_renderedPages;
|
2024-09-04 17:31:16 +03:00
|
|
|
QMultiMap<BandDesignIntf*, GroupBandsHolder*> m_childBands;
|
2016-02-17 10:39:17 +03:00
|
|
|
QList<BandDesignIntf*> m_reprintableBands;
|
2017-03-21 18:01:35 +03:00
|
|
|
QList<BandDesignIntf*> m_recalcBands;
|
2024-09-04 17:31:16 +03:00
|
|
|
QMap<QString, QVector<QString>> m_groupfunctionItems;
|
2016-02-17 10:11:00 +03:00
|
|
|
int m_currentIndex;
|
|
|
|
int m_pageCount;
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
QMap<QString, QVariant> m_popupedValues;
|
|
|
|
QMultiMap<BandDesignIntf*, QString> m_popupedExpression;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
qreal m_pageFooterHeight;
|
|
|
|
qreal m_dataAreaSize;
|
|
|
|
qreal m_reportFooterHeight;
|
|
|
|
int m_renderedDataBandCount;
|
2018-07-20 14:04:53 +03:00
|
|
|
BandDesignIntf* m_lastRenderedHeader;
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf* m_lastDataBand;
|
2016-04-12 19:37:47 +03:00
|
|
|
BandDesignIntf* m_lastRenderedFooter;
|
2020-04-17 12:28:59 +03:00
|
|
|
BandDesignIntf* m_lastRenderedBand;
|
2024-09-04 17:31:16 +03:00
|
|
|
bool m_renderCanceled;
|
|
|
|
QVector<qreal> m_maxHeightByColumn;
|
|
|
|
QVector<qreal> m_currentStartDataPos;
|
|
|
|
int m_currentColumn;
|
|
|
|
PagesRanges m_pagesRanges;
|
2016-02-17 10:39:17 +03:00
|
|
|
QVector<BandDesignIntf*> m_columnedBandItems;
|
2018-06-07 20:43:05 +03:00
|
|
|
unsigned long long m_currentNameIndex;
|
2024-09-04 17:31:16 +03:00
|
|
|
bool m_newPageStarted;
|
|
|
|
bool m_lostHeadersMoved;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
} // namespace LimeReport
|
|
|
|
#endif // LRREPORTRENDER_H
|