vcl/source/control/button.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
New commits: commit 3009987854349732e726c14e54e7cc78e319e3c8 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Sep 30 14:35:14 2021 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Oct 5 10:52:45 2021 +0200 Related: tdf#141633 drawing buttons to outputdevice affects later drawing since... commit 0b76e106b8054c91a7b7d793d9219f6ee9ae7d2c Author: Oliver Bolte <o...@openoffice.org> Date: Thu Sep 4 06:42:10 2003 +0000 INTEGRATION: CWS mt801 (1.21.132); FILE MERGED 2003/08/29 14:35:52 mt 1.21.132.1: #80064# Print button with color... In the "sample db" example (Mockup.odb) there are two buttons with a yellow background, when printed part of the table control is also incorrectly painted with a yellow background. Change-Id: I481b721801b5e1d1c78dc7a01cb20745702f5c01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122896 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index 897d55618151..a6c86dea47bb 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1352,6 +1352,9 @@ void PushButton::Draw( OutputDevice* pDev, const Point& rPos, pDev->Push(); pDev->SetMapMode(); pDev->SetFont( aFont ); + + std::optional<StyleSettings> oOrigDevStyleSettings; + if ( nFlags & DrawFlags::Mono ) { pDev->SetTextColor( COL_BLACK ); @@ -1359,10 +1362,10 @@ void PushButton::Draw( OutputDevice* pDev, const Point& rPos, else { pDev->SetTextColor( GetTextColor() ); - // DecoView uses the FaceColor... AllSettings aSettings = pDev->GetSettings(); StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + oOrigDevStyleSettings = aStyleSettings; if ( IsControlBackground() ) aStyleSettings.SetFaceColor( GetControlBackground() ); else @@ -1381,6 +1384,16 @@ void PushButton::Draw( OutputDevice* pDev, const Point& rPos, aRect = aDecoView.DrawButton( aRect, nButtonStyle ); ImplDrawPushButtonContent( pDev, nFlags, aRect, true, nButtonStyle ); + + // restore original settings (which are not affected by Push/Pop) after + // finished drawing + if (oOrigDevStyleSettings) + { + AllSettings aSettings = pDev->GetSettings(); + aSettings.SetStyleSettings(*oOrigDevStyleSettings); + pDev->OutputDevice::SetSettings( aSettings ); + } + pDev->Pop(); }