summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-28 17:01:08 +0100
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2021-09-30 10:55:21 +0200
commit95a2e765469ed072c35cf487b0526c93993ce1c4 (patch)
treef503b0f2e42cc23b0ebc0c627f464dec79b0c1b4
parentf75ec59c9a77065d4a39a4b433b139cabe1405e1 (diff)
Resolves: tdf#144139 checkboxs in print output shouldn't be themed
Change-Id: Ibbde5d64595d2fec1fa63756d628cf295dcdbb78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122792 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 8230731a4201419f32e80b22a576e8b2e1350277) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122746 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--svx/source/fmcomp/gridcell.cxx97
-rw-r--r--svx/source/inc/gridcell.hxx1
2 files changed, 97 insertions, 1 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 9339a7cba09b..1fadc6709cfe 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -1680,7 +1680,23 @@ void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rR
CheckBoxControl* pControl = static_cast<CheckBoxControl*>(m_pPainter.get());
lcl_setCheckBoxState( _rxField, pControl );
- Size aBoxSize = pControl->GetBox().get_preferred_size();
+ Size aBoxSize;
+
+ switch (rDev.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ aBoxSize = pControl->GetBox().get_preferred_size();
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ {
+ auto nSize = std::min(rRect.GetWidth(), rRect.GetHeight());
+ aBoxSize = Size(nSize, nSize);
+ break;
+ }
+ }
+
tools::Rectangle aRect(Point(rRect.Left() + ((rRect.GetWidth() - aBoxSize.Width()) / 2),
rRect.Top() + ((rRect.GetHeight() - aBoxSize.Height()) / 2)),
aBoxSize);
@@ -1688,6 +1704,85 @@ void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rR
DbCellControl::PaintFieldToCell(rDev, aRect, _rxField, xFormatter);
}
+void DbCheckBox::PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect)
+{
+ switch (rDev.GetOutDevType())
+ {
+ case OUTDEV_WINDOW:
+ case OUTDEV_VIRDEV:
+ DbCellControl::PaintCell(rDev, rRect);
+ break;
+ case OUTDEV_PRINTER:
+ case OUTDEV_PDF:
+ {
+ TriState eState = static_cast<CheckBoxControl*>(m_pWindow.get())->GetState();
+
+ MapMode aResMapMode(MapUnit::Map100thMM);
+ Size aBrd1Size = rDev.LogicToPixel(Size(20, 20), aResMapMode);
+ Size aBrd2Size = rDev.LogicToPixel(Size(30, 30), aResMapMode);
+ int nCheckWidth = rDev.LogicToPixel(Size(20, 20), aResMapMode).Width();
+ tools::Rectangle aStateRect(rRect);
+
+ rDev.Push();
+ rDev.SetMapMode();
+
+ rDev.SetLineColor();
+ rDev.SetFillColor(COL_BLACK);
+ rDev.DrawRect(aStateRect);
+ aStateRect.AdjustLeft(aBrd1Size.Width());
+ aStateRect.AdjustTop(aBrd1Size.Height());
+ aStateRect.AdjustRight(-aBrd1Size.Width());
+ aStateRect.AdjustBottom(-aBrd1Size.Height());
+ if (eState == TRISTATE_INDET)
+ rDev.SetFillColor(COL_LIGHTGRAY);
+ else
+ rDev.SetFillColor(COL_WHITE);
+ rDev.DrawRect(aStateRect);
+
+ if (eState == TRISTATE_TRUE)
+ {
+ aStateRect.AdjustLeft(aBrd2Size.Width());
+ aStateRect.AdjustTop(aBrd2Size.Height());
+ aStateRect.AdjustRight(-aBrd2Size.Width());
+ aStateRect.AdjustBottom(-aBrd2Size.Height());
+ Point aPos11(aStateRect.TopLeft());
+ Point aPos12(aStateRect.BottomRight());
+ Point aPos21(aStateRect.TopRight());
+ Point aPos22(aStateRect.BottomLeft());
+ Point aTempPos11(aPos11);
+ Point aTempPos12(aPos12);
+ Point aTempPos21(aPos21);
+ Point aTempPos22(aPos22);
+ rDev.SetLineColor(COL_BLACK);
+ int nDX = 0;
+ for (int i = 0; i < nCheckWidth; i++)
+ {
+ if ( !(i % 2) )
+ {
+ aTempPos11.setX(aPos11.X() + nDX);
+ aTempPos12.setX(aPos12.X() + nDX);
+ aTempPos21.setX(aPos21.X() + nDX);
+ aTempPos22.setX(aPos22.X() + nDX);
+ }
+ else
+ {
+ nDX++;
+ aTempPos11.setX(aPos11.X() - nDX);
+ aTempPos12.setX(aPos12.X() - nDX);
+ aTempPos21.setX(aPos21.X() - nDX);
+ aTempPos22.setX(aPos22.X() - nDX);
+ }
+ rDev.DrawLine(aTempPos11, aTempPos12);
+ rDev.DrawLine(aTempPos21, aTempPos22);
+ }
+ }
+
+ rDev.Pop();
+ break;
+ }
+ }
+}
+
void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel )
{
OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" );
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 413928e600c9..2e9564d8c5ad 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -442,6 +442,7 @@ public:
virtual void PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect,
const css::uno::Reference< css::sdb::XColumn >& _rxField,
const css::uno::Reference< css::util::XNumberFormatter >& xFormatter) override;
+ virtual void PaintCell(OutputDevice& rDev, const tools::Rectangle& rRect) override;
virtual OUString GetFormatText(const css::uno::Reference< css::sdb::XColumn >& _rxField, const css::uno::Reference< css::util::XNumberFormatter >& xFormatter, const Color** ppColor = nullptr) override;
protected: