2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of the Lime Report project *
|
|
|
|
* Copyright (C) 2015 by Alexander Arin *
|
|
|
|
* 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 <QObject>
|
|
|
|
#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"
|
|
|
|
|
|
|
|
namespace LimeReport{
|
|
|
|
|
|
|
|
class PageDesignIntf;
|
|
|
|
class BandDesignIntf;
|
|
|
|
|
|
|
|
class GroupBandsHolder: public QList<BandDesignIntf*>{
|
|
|
|
public:
|
|
|
|
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;}
|
|
|
|
private:
|
|
|
|
bool m_tryToKeepTogether;
|
|
|
|
bool m_dataGroup;
|
|
|
|
bool m_footerGroup;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
struct PagesRange{
|
|
|
|
int firstPage;
|
|
|
|
int lastPage;
|
|
|
|
};
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
class ReportRender: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QObject* datasourcesManager READ datasources())
|
|
|
|
public:
|
2016-02-17 10:28:27 +03:00
|
|
|
enum DataRenderMode {StartNewPageAsNeeded, NotStartNewPage, ForcedStartPage};
|
2016-02-17 10:11:00 +03:00
|
|
|
enum BandPrintMode {PrintAlwaysPrintable, PrintNotAlwaysPrintable };
|
2016-09-16 01:59:56 +03:00
|
|
|
enum ResetPageNuberType{BandReset, PageReset};
|
2016-02-17 10:11:00 +03:00
|
|
|
typedef QSharedPointer<ReportRender> Ptr;
|
|
|
|
~ReportRender();
|
|
|
|
ReportRender(QObject *parent = 0);
|
|
|
|
void setDatasources(DataSourceManager* value);
|
2016-06-10 18:05:18 +03:00
|
|
|
void setScriptContext(ScriptEngineContext* scriptContext);
|
2016-02-17 10:11:00 +03:00
|
|
|
DataSourceManager* datasources(){return m_datasources;}
|
|
|
|
int pageCount();
|
|
|
|
PageItemDesignIntf::Ptr pageAt(int index);
|
|
|
|
QString renderPageToString(PageDesignIntf *patternPage);
|
|
|
|
ReportPages renderPageToPages(PageDesignIntf *patternPage);
|
2016-09-16 01:59:56 +03:00
|
|
|
void secondRenderPass(ReportPages renderedPages);
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
|
|
|
void pageRendered(int renderedPageCount);
|
|
|
|
public slots:
|
|
|
|
void cancelRender();
|
|
|
|
private:
|
2016-05-26 22:21:42 +03:00
|
|
|
void renderPage(PageDesignIntf *patternPage);
|
2016-02-17 10:18:19 +03:00
|
|
|
void initDatasources();
|
2016-09-18 11:05:46 +03:00
|
|
|
void initDatasource(const QString &name);
|
2016-02-17 10:11:00 +03:00
|
|
|
void initRenderPage();
|
2016-06-10 18:05:18 +03:00
|
|
|
#ifdef HAVE_UI_LOADER
|
|
|
|
void initDialogs();
|
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
void initVariables();
|
2016-06-10 18:05:18 +03:00
|
|
|
bool runInitScript();
|
2016-02-17 10:11:00 +03:00
|
|
|
void clearPageMap();
|
|
|
|
void renderBand(BandDesignIntf *patternBand, DataRenderMode mode = NotStartNewPage, bool isLast = false);
|
|
|
|
void renderDataBand(BandDesignIntf* dataBand);
|
|
|
|
void renderPageHeader(PageItemDesignIntf* patternPage);
|
|
|
|
void renderPageFooter(PageItemDesignIntf* patternPage);
|
2016-10-04 03:21:22 +03:00
|
|
|
void moveTearOffBand();
|
2016-02-17 10:11:00 +03:00
|
|
|
void renderPageItems(PageItemDesignIntf* patternPage);
|
|
|
|
qreal calcPageFooterHeight(PageItemDesignIntf* patternPage);
|
|
|
|
qreal calcSlicePercent(qreal height);
|
|
|
|
void renderChildHeader(BandDesignIntf* parent, BandPrintMode printMode);
|
|
|
|
void renderChildFooter(BandDesignIntf* parent, BandPrintMode printMode);
|
|
|
|
void renderChildBands(BandDesignIntf* parentBand);
|
2016-02-17 10:28:27 +03:00
|
|
|
void renderGroupHeader(BandDesignIntf* parentBand, IDataSource* dataSource, bool firstTime);
|
2016-02-17 10:11:00 +03:00
|
|
|
void renderGroupFooter(BandDesignIntf* parentBand);
|
|
|
|
|
2016-09-28 01:24:55 +03:00
|
|
|
void initGroups();
|
2016-02-17 10:11:00 +03:00
|
|
|
void extractGroupsFunction(BandDesignIntf* band);
|
|
|
|
void replaceGroupsFunction(BandDesignIntf* band);
|
|
|
|
|
|
|
|
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();
|
2016-02-17 10:39:17 +03:00
|
|
|
void checkLostHeadersOnPrevPage();
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
BandDesignIntf* findEnclosingGroup();
|
|
|
|
bool registerBand(BandDesignIntf* band, bool registerInChildren=true);
|
|
|
|
BandDesignIntf *sliceBand(BandDesignIntf* band, BandDesignIntf *patternBand, bool isLast);
|
2016-09-16 01:59:56 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf *patternBand);
|
|
|
|
BandDesignIntf* renderData(BandDesignIntf* patternBand);
|
2016-02-17 10:28:27 +03:00
|
|
|
void startNewColumn();
|
2016-02-17 10:11:00 +03:00
|
|
|
void startNewPage();
|
2016-09-16 01:59:56 +03:00
|
|
|
void resetPageNumber(ResetPageNuberType resetType);
|
2016-02-17 10:28:27 +03:00
|
|
|
int findLastPageNumber(int currentPage);
|
2016-10-04 03:21:22 +03:00
|
|
|
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();
|
|
|
|
int columnItemsCount(int columnIndex);
|
|
|
|
qreal columnHeigth(int columnIndex);
|
|
|
|
qreal maxColumnHeight();
|
2016-05-26 22:21:42 +03:00
|
|
|
void renameChildItems(BaseDesignIntf *item);
|
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;
|
|
|
|
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
|
2016-02-17 10:39:17 +03:00
|
|
|
QList<BandDesignIntf*> m_reprintableBands;
|
|
|
|
// QList<BandDesignIntf*> m_lastRenderedHeaders;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
//int m_maxHeightByColumn[0];
|
|
|
|
//int m_currentStartDataPos;
|
2016-02-17 10:11:00 +03:00
|
|
|
int m_currentIndex;
|
|
|
|
int m_pageCount;
|
|
|
|
|
|
|
|
QMap<QString,QVariant> m_popupedValues;
|
|
|
|
QMultiMap<BandDesignIntf*,QString> m_popupedExpression;
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
qreal m_pageFooterHeight;
|
|
|
|
qreal m_dataAreaSize;
|
|
|
|
qreal m_reportFooterHeight;
|
|
|
|
int m_renderedDataBandCount;
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf* m_lastDataBand;
|
2016-04-12 19:37:47 +03:00
|
|
|
BandDesignIntf* m_lastRenderedFooter;
|
2016-02-17 10:28:27 +03:00
|
|
|
bool m_renderCanceled;
|
|
|
|
QVector<qreal> m_maxHeightByColumn;
|
|
|
|
QVector<qreal> m_currentStartDataPos;
|
|
|
|
int m_currentColumn;
|
|
|
|
QList<PagesRange> m_ranges;
|
2016-02-17 10:39:17 +03:00
|
|
|
QVector<BandDesignIntf*> m_columnedBandItems;
|
2016-05-26 22:21:42 +03:00
|
|
|
unsigned long long m_curentNameIndex;
|
2016-09-18 11:05:46 +03:00
|
|
|
|
2016-10-04 03:21:22 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
} // namespace LimeReport
|
|
|
|
#endif // LRREPORTRENDER_H
|