From 5a1c372ec772f7600792deef044b7f5f21a116b6 Mon Sep 17 00:00:00 2001 From: Pranam Lashkari Date: Wed, 4 Sep 2024 13:54:58 +0200 Subject: sc: check only background color for automatic font color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit problem: when setting font color only background color matters. there are dark, bright and other types of color so better to keep conditions simple Change-Id: I513f97a281a8625cbe7781a10d2a2427c9b6be2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172867 Tested-by: Jenkins CollaboraOffice Reviewed-by: Caolán McNamara --- sc/source/core/data/patattr.cxx | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 32905201def9..17ca87c1159b 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -445,7 +445,7 @@ void ScPatternAttr::fillFontOnly( rFont.SetTransparent( true ); } -void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet* pCondSet, const Color* pBackConfigColor, const Color* pTextConfigColor) +void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemSet& rItemSet, ScAutoFontColorMode eAutoMode, const SfxItemSet* pCondSet, const Color* pBackConfigColor, const Color* /*pTextConfigColor*/) { model::ComplexColor aComplexColor; @@ -519,38 +519,17 @@ void ScPatternAttr::fillColor(model::ComplexColor& rComplexColor, const SfxItemS } } - // get system text color for comparison - Color aSysTextColor; - if (eAutoMode == ScAutoFontColorMode::Print) - { - aSysTextColor = COL_BLACK; - } - else if (pTextConfigColor) - { - // pTextConfigColor can be used to avoid repeated lookup of the configured color - aSysTextColor = *pTextConfigColor; - } - else - { - aSysTextColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor; - } - // select the resulting color - if ( aBackColor.IsDark() && aSysTextColor.IsDark() ) + if ( aBackColor.IsDark() ) { // use white instead of dark on dark aColor = COL_WHITE; } - else if ( aBackColor.IsBright() && aSysTextColor.IsBright() ) + else { // use black instead of bright on bright aColor = COL_BLACK; } - else - { - // use aSysTextColor (black for ScAutoFontColorMode::Print, from style settings otherwise) - aColor = aSysTextColor; - } } aComplexColor.setFinalColor(aColor); rComplexColor = aComplexColor; -- cgit