0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00

Added the ability to send page margins to the printer

This commit is contained in:
Arin Alexander 2019-09-03 12:59:59 +03:00
parent 872a2219e0
commit 6e92feffa7
3 changed files with 86 additions and 5 deletions

View File

@ -51,7 +51,9 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
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_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split),
m_printerMarginTop(0), m_printerMarginRight(0), m_printerMarginBottom(0), m_printerMarginLeft(0),
m_changePrinterMargins(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
@ -65,7 +67,9 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
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_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split),
m_printerMarginTop(0), m_printerMarginRight(0), m_printerMarginBottom(0), m_printerMarginLeft(0),
m_changePrinterMargins(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
@ -344,6 +348,56 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
}
}
bool PageItemDesignIntf::changePrinterMargins() const
{
return m_changePrinterMargins;
}
void PageItemDesignIntf::setChangePrinterMargins(bool value)
{
m_changePrinterMargins = value;
}
int PageItemDesignIntf::printerMarginLeft() const
{
return m_printerMarginLeft;
}
void PageItemDesignIntf::setPrinterMarginLeft(int printerMarginLeft)
{
m_printerMarginLeft = printerMarginLeft;
}
int PageItemDesignIntf::printerMarginBottom() const
{
return m_printerMarginBottom;
}
void PageItemDesignIntf::setPrinterMarginBottom(int printerMarginBottom)
{
m_printerMarginBottom = printerMarginBottom;
}
int PageItemDesignIntf::printerMarginRight() const
{
return m_printerMarginRight;
}
void PageItemDesignIntf::setPrinterMarginRight(int printerMarginRight)
{
m_printerMarginRight = printerMarginRight;
}
int PageItemDesignIntf::printerMarginTop() const
{
return m_printerMarginTop;
}
void PageItemDesignIntf::setPrinterMarginTop(int printerMarginTop)
{
m_printerMarginTop = printerMarginTop;
}
void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior)
{
m_printBehavior = printBehavior;

View File

@ -64,6 +64,12 @@ 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(int printerMarginTop READ printerMarginTop WRITE setPrinterMarginTop)
Q_PROPERTY(int printerMarginRight READ printerMarginRight WRITE setPrinterMarginRight)
Q_PROPERTY(int printerMarginBottom READ printerMarginBottom WRITE setPrinterMarginBottom)
Q_PROPERTY(int printerMarginLeft READ printerMarginLeft WRITE setPrinterMarginLeft)
Q_PROPERTY(bool changePrinterMargins READ changePrinterMargins WRITE setChangePrinterMargins)
friend class ReportRender;
public:
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
@ -169,6 +175,18 @@ public:
PrintBehavior printBehavior() const;
void setPrintBehavior(const PrintBehavior &printBehavior);
int printerMarginTop() const;
void setPrinterMarginTop(int printerMarginTop);
int printerMarginRight() const;
void setPrinterMarginRight(int printerMarginRight);
int printerMarginBottom() const;
void setPrinterMarginBottom(int printerMarginBottom);
int printerMarginLeft() const;
void setPrinterMarginLeft(int printerMarginLeft);
bool changePrinterMargins() const;
void setChangePrinterMargins(bool value);
signals:
void beforeFirstPageRendered();
void afterLastPageRendered();
@ -212,8 +230,11 @@ private:
QString m_printerName;
BandDesignIntf* m_pageFooter;
PrintBehavior m_printBehavior;
int m_printerMarginTop;
int m_printerMarginRight;
int m_printerMarginBottom;
int m_printerMarginLeft;
bool m_changePrinterMargins;
};
typedef QList<PageItemDesignIntf::Ptr> ReportPages;

View File

@ -1845,7 +1845,13 @@ void PrintProcessor::initPrinter(PageItemDesignIntf* page)
m_printer->setPaperSize(pageSize,QPrinter::Millimeter);
} else {
m_printer->setFullPage(page->fullPage());
m_printer->setPageMargins(0,0,0,0, QPrinter::Millimeter);
if (page->changePrinterMargins()){
m_printer->setPageMargins(page->printerMarginLeft(),
page->printerMarginTop(),
page->printerMarginRight(),
page->printerMarginBottom(),
QPrinter::Millimeter);
}
m_printer->setOrientation(static_cast<QPrinter::Orientation>(page->pageOrientation()));
if (page->pageSize()==PageItemDesignIntf::Custom){
QSizeF pageSize = (page->pageOrientation()==PageItemDesignIntf::Landscape)?