editeng/source/editeng/impedit3.cxx |    8 ++++----
 sc/source/core/data/patattr.cxx     |   15 ++++++++++-----
 sw/source/core/txtnode/fntcache.cxx |   14 +++++---------
 3 files changed, 19 insertions(+), 18 deletions(-)

New commits:
commit 45330b2a16cc882ab0a7fe95dfe92879a15a7f96
Author:     Pranam Lashkari <lpra...@collabora.com>
AuthorDate: Fri Aug 30 03:18:22 2024 +0200
Commit:     Pranam Lashkari <lpra...@collabora.com>
CommitDate: Fri Aug 30 04:41:57 2024 +0200

    Revert "Fix font color must not change depending on background"
    
    Resolves tdf#159541-Fix font color must not change depending on background
    This reverts commit 8534ad7b7b9aae2520d731cf748ff0aadfe2f0ed.
    
    Reason for revert: not needed on this branch.
    incorrect automatic font color was chosen with certain background colors.
    the original patch was fix for a regression from 
ddb483509113e469b771320fea52f1b089574021. But that regressive patch doesn't 
exist on this branch and thus reverting this patch
    
    Change-Id: I0d1d24858243bac759feba2b1a71e5501e0aae72
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172621
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>
    Tested-by: Pranam Lashkari <lpra...@collabora.com>

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index afef27787738..096550bde30d 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4729,13 +4729,13 @@ Color ImpEditEngine::GetAutoColor() const
     }
     else
     {
-        aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR, 
false).nColor;
+        aColor = GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
 
-        if ( aColor == COL_AUTO )
+        if ( GetBackgroundColor() != COL_AUTO )
         {
-            if ( GetBackgroundColor().IsDark()  )
+            if ( GetBackgroundColor().IsDark() && aColor.IsDark() )
                 aColor = COL_WHITE;
-            else
+            else if ( GetBackgroundColor().IsBright() && aColor.IsBright() )
                 aColor = COL_BLACK;
         }
     }
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 86b59f5ffc01..32905201def9 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -535,15 +535,20 @@ void ScPatternAttr::fillColor(model::ComplexColor& 
rComplexColor, const SfxItemS
             aSysTextColor = 
SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
         }
 
-        if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current())
+        //  select the resulting color
+        if ( aBackColor.IsDark() && aSysTextColor.IsDark() )
         {
-            if (aBackColor.IsDark())
-                aColor = COL_WHITE;
-            else
-                aColor = COL_BLACK;
+            //  use white instead of dark on dark
+            aColor = COL_WHITE;
+        }
+        else if ( aBackColor.IsBright() && aSysTextColor.IsBright() )
+        {
+            //  use black instead of bright on bright
+            aColor = COL_BLACK;
         }
         else
         {
+            //  use aSysTextColor (black for ScAutoFontColorMode::Print, from 
style settings otherwise)
             aColor = aSysTextColor;
         }
     }
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index 54e078bc1bbb..4e9f2a1c1dc7 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -58,7 +58,6 @@
 #include <cstdint>
 #include <memory>
 #include "justify.hxx"
-#include <svtools/colorcfg.hxx>
 
 using namespace ::com::sun::star;
 
@@ -2227,14 +2226,11 @@ bool SwDrawTextInfo::ApplyAutoColor( vcl::Font* pFont )
             }
 
             // change painting color depending of dark/bright background
-            if (!pVSh->GetWin() || // ie. IsPrinting, see SwViewShell::GetWin()
-                svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR, 
false).nColor == COL_AUTO) // GetFontColor() uses the smart flag
-            {
-                if ( pCol->IsDark() )
-                    nNewColor = COL_WHITE;
-                else
-                    nNewColor = COL_BLACK;
-            }
+            Color aTmpColor( nNewColor );
+            if ( pCol->IsDark() && aTmpColor.IsDark() )
+                nNewColor = COL_WHITE;
+            else if ( pCol->IsBright() && aTmpColor.IsBright() )
+                nNewColor = COL_BLACK;
         }
     }
 

Reply via email to