dropPrinterMargins property has been added to page

This commit is contained in:
fralx 2020-05-19 11:48:43 +03:00
parent 69f91207e8
commit 3c4d384400
4 changed files with 25 additions and 9 deletions

View File

@ -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}\\\"

View File

@ -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<qreal> &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;

View File

@ -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;
};

View File

@ -1797,9 +1797,6 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
if (!m_firstPage && !m_painter->isActive()) return false;
PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(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<QPrinter::Orientation>(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<QPrinter::PageSize>(page->pageSize()));