diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 3bcb402..6c09deb 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -52,7 +52,8 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) : m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), - m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false) + m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), + m_notPrintIfEmpty(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -67,7 +68,8 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false), m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false), m_endlessHeight(false), m_printable(true), - m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false) + m_pageFooter(0), m_printBehavior(Split), m_dropPrinterMargins(false), + m_notPrintIfEmpty(false) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -348,6 +350,16 @@ void PageItemDesignIntf::initColumnsPos(QVector &posByColumns, qreal pos, } } +bool PageItemDesignIntf::notPrintIfEmpty() const +{ + return m_notPrintIfEmpty; +} + +void PageItemDesignIntf::setNotPrintIfEmpty(bool notPrintIfEmpty) +{ + m_notPrintIfEmpty = notPrintIfEmpty; +} + bool PageItemDesignIntf::dropPrinterMargins() const { return m_dropPrinterMargins; @@ -358,6 +370,11 @@ void PageItemDesignIntf::setDropPrinterMargins(bool dropPrinterMargins) m_dropPrinterMargins = dropPrinterMargins; } +bool PageItemDesignIntf::isEmpty() const +{ + return childBaseItems().isEmpty(); +} + void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior) { m_printBehavior = printBehavior; diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 19ea35a..07b078e 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -62,6 +62,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty) Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior) Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins) + Q_PROPERTY(bool notPrintIfEmpty READ notPrintIfEmpty WRITE setNotPrintIfEmpty) friend class ReportRender; public: enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape }; @@ -182,6 +183,11 @@ public: bool dropPrinterMargins() const; void setDropPrinterMargins(bool dropPrinterMargins); + bool isEmpty() const; + + bool notPrintIfEmpty() const; + void setNotPrintIfEmpty(bool notPrintIfEmpty); + signals: void beforeFirstPageRendered(); void afterLastPageRendered(); @@ -226,6 +232,7 @@ private: BandDesignIntf* m_pageFooter; PrintBehavior m_printBehavior; bool m_dropPrinterMargins; + bool m_notPrintIfEmpty; }; diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 052fdba..f6d7bb3 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -1483,15 +1483,19 @@ BandDesignIntf* ReportRender::findEnclosingGroup() void ReportRender::savePage(bool isLast) { - if (m_renderPageItem->isTOC()) - m_pagesRanges.addTOCPage(); - else - m_pagesRanges.addPage(); m_datasources->setReportVariable("#IS_LAST_PAGEFOOTER",isLast); m_datasources->setReportVariable("#IS_FIRST_PAGEFOOTER",m_datasources->variable("#PAGE").toInt()==1); renderPageItems(m_patternPageItem); + + if (m_renderPageItem->isEmpty() and m_renderPageItem->notPrintIfEmpty()) return; + + if (m_renderPageItem->isTOC()) + m_pagesRanges.addTOCPage(); + else + m_pagesRanges.addPage(); + checkFooterGroup(m_lastDataBand); cutGroups(); rearrangeColumnsItems();