diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-28 17:01:08 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-09-29 10:53:36 +0200 |
commit | 8230731a4201419f32e80b22a576e8b2e1350277 (patch) | |
tree | f6f468031d8dfd194320c1666d652bff539c1d01 | |
parent | 83876642498b0203b25b8b95e612603d46addd62 (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>
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 97 | ||||
-rw-r--r-- | svx/source/inc/gridcell.hxx | 1 |
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: |