Commit 0b191e69 authored by Gil Moskowitz's avatar Gil Moskowitz Committed by GitHub

Merge pull request #82 from ChristopherCotnoir/i30540

issue #30540 Honor watermark font size selection
parents 6df3b185 ce581e8d
......@@ -80,6 +80,7 @@ class ORPreRenderPrivate {
// pulled from a query source
QString _wmText; // the text that is to be rendered as a watermark
ORDataData _wmData; // the dynamic source for the watermark text
bool _wmUseDefaultFont; // the default font is being used
QFont _wmFont; // the font to use when rendering the _wmText value
// on the background of the page. For purposes of
// fit, pointSize() of font is ignored and the largest
......@@ -150,6 +151,7 @@ ORPreRenderPrivate::ORPreRenderPrivate()
_wmText = QString::null;
_wmData.query = QString::null;
_wmData.column = QString::null;
_wmUseDefaultFont = true;
_wmFont = QFont("Helvetic");
_wmOpacity = 25;
......@@ -284,6 +286,7 @@ void ORPreRenderPrivate::renderWatermark(OROPage * p)
return;
p->setWatermarkText(wmText);
p->setWatermarkUseDefaultFont(_wmUseDefaultFont);
p->setWatermarkFont(_wmFont);
p->setWatermarkOpacity(_wmOpacity);
}
......@@ -1624,6 +1627,7 @@ bool ORPreRender::setDom(const QDomDocument & docReport)
_internal->_wmText = QString::null;
_internal->_wmData.query = QString::null;
_internal->_wmData.column = QString::null;
_internal->_wmUseDefaultFont = true;
_internal->_wmFont = QFont("Arial");
_internal->_wmOpacity = 25;
......@@ -1637,6 +1641,7 @@ bool ORPreRender::setDom(const QDomDocument & docReport)
_internal->_wmData.query = _internal->_reportData->wmData.data.query;
_internal->_wmData.column = _internal->_reportData->wmData.data.column;
}
_internal->_wmUseDefaultFont = _internal->_reportData->wmData.useDefaultFont;
if(!_internal->_reportData->wmData.useDefaultFont)
_internal->_wmFont = _internal->_reportData->wmData.font;
_internal->_wmOpacity = _internal->_reportData->wmData.opacity;
......
......@@ -28,7 +28,7 @@
#include <QPaintEngine>
static void renderBackground(QImage &, const QImage &, const QRect &, bool, Qt::AspectRatioMode, int, unsigned int);
static void renderWatermark(QImage &, const QString &, const QFont &, const unsigned int, double, double, double, double);
static void renderWatermark(QImage &, const QString &, bool, const QFont &, const unsigned int, double, double, double, double);
ORPrintRender::ORPrintRender()
{
......@@ -223,7 +223,7 @@ void renderBackground(QImage & dest, const QImage & bgImage, const QRect & bgRec
#include <QFontDatabase>
// margin is in the same units as the image
void renderWatermark(QImage & image, const QString & wmText, const QFont & wmFont, const unsigned int wmOpacity, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
void renderWatermark(QImage & image, const QString & wmText, bool wmUseDefaultFont, const QFont & wmFont, const unsigned int wmOpacity, double leftMargin, double rightMargin, double topMargin, double bottomMargin)
{
const double pi = 3.14159265358979323846;
......@@ -255,6 +255,10 @@ void renderWatermark(QImage & image, const QString & wmText, const QFont & wmFon
if(fm.boundingRect(wmText).width() < l2)
break;
}
if(!wmUseDefaultFont && wmFont.pointSize() < fnt.pointSize())
fnt.setPointSize(wmFont.pointSize());
int fh = fm.height();
y = y - (fh/2);
......@@ -350,7 +354,8 @@ void ORPrintRender::renderPage(ORODocument * pDocument, int pageNb, QPainter *pa
if((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0))
{
doBgWm = true;
renderWatermark(image, p->watermarkText(), p->watermarkFont(), p->watermarkOpacity(),
renderWatermark(image, p->watermarkText(), p->watermarkUseDefaultFont(),
p->watermarkFont(), p->watermarkOpacity(),
pDocument->pageOptions().getMarginLeft() * resolution,
pDocument->pageOptions().getMarginRight() * resolution,
pDocument->pageOptions().getMarginTop() * resolution,
......
......@@ -133,6 +133,11 @@ void OROPage::setWatermarkText(const QString & txt)
_wmText = txt;
}
void OROPage::setWatermarkUseDefaultFont(bool useDefault)
{
_wmUseDefaultFont = useDefault;
}
void OROPage::setWatermarkFont(const QFont & fnt)
{
_wmFont = fnt;
......
......@@ -98,10 +98,12 @@ class OROPage
void addPrimitive(OROPrimitive*);
void setWatermarkText(const QString &);
void setWatermarkUseDefaultFont(bool);
void setWatermarkFont(const QFont &);
void setWatermarkOpacity(unsigned char); // 0..255 : default 25
QString watermarkText() const { return _wmText; };
bool watermarkUseDefaultFont() const { return _wmUseDefaultFont; };
QFont watermarkFont() const { return _wmFont; };
unsigned char watermarkOpacity() const { return _wmOpacity; };
......@@ -126,6 +128,7 @@ class OROPage
QList<OROPrimitive*> _primitives;
QString _wmText;
bool _wmUseDefaultFont;
QFont _wmFont;
unsigned char _wmOpacity;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment