Resolves tdf#142116 - Respect field shading color on dark background
This reverts #100366# commit ce057f404b7b39df4a9259eecd90e28cf9a75fbd
Change-Id: I50872e38a154f5d24bcfaafd11488508e3c52356
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121359
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 4f5df3e..82f0655 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -521,39 +521,6 @@ SwTextPaintInfo::SwTextPaintInfo( SwTextFrame *pFrame, const SwRect &rPaint )
CtorInitTextPaintInfo( pFrame->getRootFrame()->GetCurrShell()->GetOut(), pFrame, rPaint );
}
/// Returns if the current background color is dark.
static bool lcl_IsDarkBackground( const SwTextPaintInfo& rInf )
{
std::optional<Color> pCol = rInf.GetFont()->GetBackColor();
if( ! pCol || COL_TRANSPARENT == *pCol )
{
const SvxBrushItem* pItem;
SwRect aOrigBackRect;
drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes;
// Consider, that [GetBackgroundBrush(...)] can set <pCol>
// See implementation in /core/layout/paintfrm.cxx
// There is a background color, if there is a background brush and
// its color is *not* "no fill"/"auto fill".
if( rInf.GetTextFrame()->GetBackgroundBrush( aFillAttributes, pItem, pCol, aOrigBackRect, false, /*bConsiderTextBox=*/false ) )
{
if ( !pCol )
pCol = pItem->GetColor();
// Determined color <pCol> can be <COL_TRANSPARENT>. Thus, check it.
if ( *pCol == COL_TRANSPARENT)
pCol.reset();
}
else
pCol.reset();
}
if( !pCol )
pCol = aGlobalRetoucheColor;
return pCol->IsDark();
}
namespace
{
/**
@@ -1137,20 +1104,12 @@ void SwTextPaintInfo::DrawBackground( const SwLinePortion &rPor, const Color *pC
OutputDevice* pOut = const_cast<OutputDevice*>(GetOut());
pOut->Push( PushFlags::LINECOLOR | PushFlags::FILLCOLOR );
// For dark background we do not want to have a filled rectangle
if ( GetVsh() && GetVsh()->GetWin() && lcl_IsDarkBackground( *this ) )
{
pOut->SetLineColor( SwViewOption::GetFontColor() );
}
if ( pColor )
pOut->SetFillColor( *pColor );
else
{
if ( pColor )
pOut->SetFillColor( *pColor );
else
pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() );
pOut->SetFillColor( SwViewOption::GetFieldShadingsColor() );
pOut->SetLineColor();
}
pOut->SetLineColor();
DrawRect( aIntersect, true );
pOut->Pop();