From 3c4d3844004f060ae67a1c53e6f472ecd278d4be Mon Sep 17 00:00:00 2001 From: fralx Date: Tue, 19 May 2020 11:48:43 +0300 Subject: [PATCH] dropPrinterMargins property has been added to page --- common.pri | 2 +- limereport/lrpageitemdesignintf.cpp | 20 ++++++++++++++++---- limereport/lrpageitemdesignintf.h | 5 +++++ limereport/lrreportengine.cpp | 7 +++---- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/common.pri b/common.pri index a0fcb3b..d905d94 100644 --- a/common.pri +++ b/common.pri @@ -133,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 53 +LIMEREPORT_VERSION_RELEASE = 54 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 42a1b71..f65c085 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -50,8 +50,9 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) : m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false), 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_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) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -64,8 +65,9 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0), m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false), 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_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) { setFixedPos(true); setPossibleResizeDirectionFlags(Fixed); @@ -345,6 +347,16 @@ void PageItemDesignIntf::initColumnsPos(QVector &posByColumns, qreal pos, } } +bool PageItemDesignIntf::dropPrinterMargins() const +{ + return m_dropPrinterMargins; +} + +void PageItemDesignIntf::setDropPrinterMargins(bool dropPrinterMargins) +{ + m_dropPrinterMargins = dropPrinterMargins; +} + void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior) { m_printBehavior = printBehavior; diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 3d968d1..d5918c3 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -61,6 +61,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName) Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty) Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior) + Q_PROPERTY(bool dropPrinterMargins READ dropPrinterMargins WRITE setDropPrinterMargins) friend class ReportRender; public: enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape }; @@ -177,6 +178,9 @@ public: PrintBehavior printBehavior() const; void setPrintBehavior(const PrintBehavior &printBehavior); + bool dropPrinterMargins() const; + void setDropPrinterMargins(bool dropPrinterMargins); + signals: void beforeFirstPageRendered(); void afterLastPageRendered(); @@ -220,6 +224,7 @@ private: QString m_printerName; BandDesignIntf* m_pageFooter; PrintBehavior m_printBehavior; + bool m_dropPrinterMargins; }; diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 52aba2c..5ba24bd 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -1797,9 +1797,6 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) if (!m_firstPage && !m_painter->isActive()) return false; PageDesignIntf* backupPage = dynamic_cast(page->scene()); - //LimeReport::PageDesignIntf m_renderPage; - //m_renderPage.setItemMode(PrintMode); - QPointF backupPagePos = page->pos(); page->setPos(0,0); m_renderPage.setPageItem(page); @@ -1869,13 +1866,15 @@ void PrintProcessor::initPrinter(PageItemDesignIntf* page) m_printer->setPaperSize(pageSize,QPrinter::Millimeter); } else { m_printer->setFullPage(page->fullPage()); + if (page->dropPrinterMargins()) + m_printer->setPageMargins(0, 0, 0, 0, QPrinter::Point); m_printer->setOrientation(static_cast(page->pageOrientation())); if (page->pageSize()==PageItemDesignIntf::Custom){ QSizeF pageSize = (page->pageOrientation()==PageItemDesignIntf::Landscape)? QSizeF(page->sizeMM().height(),page->sizeMM().width()): page->sizeMM(); if (page->getSetPageSizeToPrinter() || m_printer->outputFormat() == QPrinter::PdfFormat) - m_printer->setPaperSize(pageSize,QPrinter::Millimeter); + m_printer->setPaperSize(pageSize, QPrinter::Millimeter); } else { if (page->getSetPageSizeToPrinter() || m_printer->outputFormat() == QPrinter::PdfFormat) m_printer->setPaperSize(static_cast(page->pageSize()));