include/vcl/outdev.hxx | 2 ++ sw/source/core/crsr/FormFieldButton.cxx | 5 ++++- sw/source/core/layout/paintfrm.cxx | 7 ++++++- sw/source/core/text/inftxt.cxx | 7 +++++-- sw/source/core/view/viewsh.cxx | 10 ++++++++-- sw/source/ui/table/autoformatpreview.cxx | 5 ++++- 6 files changed, 29 insertions(+), 7 deletions(-)
New commits: commit 878dd795378776253e6c49d58805a219e0b8c33e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Jun 30 12:00:42 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Jun 30 17:49:51 2025 +0200 tdf#166842 do not use FillColor==COL_TRANSPARENT... .. on OutputDevice if that OutputDevice does not support alpha Change-Id: I52f8a496127462deecba9cf6fd19f827466d16cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187181 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index aeed95955e2e..a5dd08218c75 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1359,6 +1359,8 @@ public: virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const; + bool HasAlpha() const { return bool(mpAlphaVDev); } + /** Query extended bitmap (with alpha channel, if available). */ BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const; diff --git a/sw/source/core/crsr/FormFieldButton.cxx b/sw/source/core/crsr/FormFieldButton.cxx index 319dcdb9c0dd..a3edb345ce68 100644 --- a/sw/source/core/crsr/FormFieldButton.cxx +++ b/sw/source/core/crsr/FormFieldButton.cxx @@ -114,7 +114,10 @@ void FormFieldButton::Paint(vcl::RenderContext& rRenderContext, const tools::Rec m_aFieldFramePixel.GetSize().Height() - nPadding); const tools::Rectangle aFrameRect(tools::Rectangle(aPos, aSize)); rRenderContext.SetLineColor(aLineColor); - rRenderContext.SetFillColor(COL_TRANSPARENT); + if (rRenderContext.HasAlpha()) + rRenderContext.SetFillColor(COL_TRANSPARENT); + else + rRenderContext.SetFillColor(COL_WHITE); rRenderContext.DrawRect(aFrameRect); // Draw the button next to the frame diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 1a2114610ac9..a5c64a5af91b 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -2040,7 +2040,12 @@ void DrawGraphic( default: { if( rOutDev.GetFillColor() != aColor ) - rOutDev.SetFillColor( aColor ); + { + if (aColor.IsTransparent() && !rOutDev.HasAlpha()) + rOutDev.SetFillColor(); + else + rOutDev.SetFillColor( aColor ); + } break; } } diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 3cb5a8226d7a..7c85cc95a8a8 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -565,7 +565,7 @@ namespace */ class SwTransparentTextGuard { - ScopedVclPtrInstance<VirtualDevice> m_aContentVDev; + ScopedVclPtrInstance<VirtualDevice> m_aContentVDev { DeviceFormat::WITH_ALPHA }; GDIMetaFile m_aContentMetafile; MapMode m_aNewMapMode; SwRect m_aPorRect; @@ -1273,7 +1273,10 @@ void SwTextPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const pTmpOut->Push( vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR ); - pTmpOut->SetFillColor(aFillColor); + if (aFillColor == COL_TRANSPARENT) + pTmpOut->SetFillColor(); + else + pTmpOut->SetFillColor(aFillColor); pTmpOut->SetLineColor(); DrawRect( aIntersect, false ); diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 45fcd73f7225..3db52fd89e94 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -490,8 +490,14 @@ void SwViewShell::ImplUnlockPaint(std::vector<LockPaintReason>& rReasons, bool b GetWin()->Validate(); Imp()->UnlockPaint(); - pVout->SetLineColor( mpOut->GetLineColor() ); - pVout->SetFillColor( mpOut->GetFillColor() ); + if (mpOut->IsLineColor()) + pVout->SetLineColor( mpOut->GetLineColor() ); + else + pVout->SetLineColor(); + if (mpOut->IsFillColor()) + pVout->SetFillColor( mpOut->GetFillColor() ); + else + pVout->SetFillColor(); // #i72754# start Pre/PostPaint encapsulation before mpOut is changed to the buffering VDev const vcl::Region aRepaintRegion(VisArea().SVRect()); diff --git a/sw/source/ui/table/autoformatpreview.cxx b/sw/source/ui/table/autoformatpreview.cxx index 193d289793d1..fe41318798a5 100644 --- a/sw/source/ui/table/autoformatpreview.cxx +++ b/sw/source/ui/table/autoformatpreview.cxx @@ -329,7 +329,10 @@ void AutoFormatPreview::DrawBackground(vcl::RenderContext& rRenderContext) rRenderContext.Push(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); rRenderContext.SetLineColor(); - rRenderContext.SetFillColor(aBrushItem.GetColor()); + if (aBrushItem.GetColor() == COL_TRANSPARENT) + rRenderContext.SetFillColor(); + else + rRenderContext.SetFillColor(aBrushItem.GetColor()); const basegfx::B2DRange aCellRange(maArray.GetCellRange(nCol, nRow)); rRenderContext.DrawRect( tools::Rectangle(basegfx::fround<tools::Long>(aCellRange.getMinX()),