editeng/source/editeng/impedit.hxx  |    2 +-
 editeng/source/editeng/impedit3.cxx |   13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

New commits:
commit 0279480ad68efe2690571b91d55495cd138ed895
Author:     Pranam Lashkari <[email protected]>
AuthorDate: Fri Jan 2 02:43:25 2026 +0530
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Jan 5 10:12:21 2026 +0100

    editeng: for automatic font color also check char background
    
    problem:
    in automatic color we only check doc color and background color(i.e: cell 
color)
    text can also have highlight color which also should be taken
    in cosideration when chosing automatic color
    
    Change-Id: I3689baa5cc95bc8d3b855251ae92c91a82102db3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196403
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>

diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 4bdcdaa6eefd..b650083ea3f5 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -820,7 +820,7 @@ private:
 
     tools::Long                CalcVertLineSpacing(Point& rStartPos) const;
 
-    Color               GetAutoColor() const;
+    Color               GetAutoColor(const SvxFont* pFonts = nullptr) const;
     void EnableAutoColor( bool b ) { mbUseAutoColor = b; }
     bool IsAutoColorEnabled() const { return mbUseAutoColor; }
     void ForceAutoColor( bool b ) { mbForceAutoColor = b; }
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 2b2a9aa4565b..e122bba3e06e 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2995,7 +2995,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, 
sal_Int32 nPos, SvxFont& rFo
         if ( IsAutoColorEnabled() && !bPrinting && !bPDFExporting)
         {
             // Never use WindowTextColor on the printer
-            rFont.SetColor( GetAutoColor() );
+            rFont.SetColor(GetAutoColor(&rFont));
         }
         else
         {
@@ -4775,16 +4775,21 @@ Reference < i18n::XExtendedInputSequenceChecker > const 
& ImpEditEngine::ImplGet
     return mxISC;
 }
 
-Color ImpEditEngine::GetAutoColor() const
+Color ImpEditEngine::GetAutoColor(const SvxFont* pFont) const
 {
     Color aColor;
 
     const SfxViewShell* pKitSh = comphelper::LibreOfficeKit::isActive() ? 
SfxViewShell::Current() : nullptr;
     if (pKitSh)
     {
-        Color aBackgroundColor = GetBackgroundColor();
-        if (aBackgroundColor == COL_AUTO)
+        Color aBackgroundColor;
+        if (pFont) //check for char backgound color
+            aBackgroundColor = pFont->GetFillColor();
+        if (aBackgroundColor == COL_AUTO) // check for aother backgound (i.e: 
cell color)
+            aBackgroundColor = GetBackgroundColor();
+        if (aBackgroundColor == COL_AUTO) // if everything is auto/transperent 
then use doc color
             aBackgroundColor = pKitSh->GetColorConfigColor(svtools::DOCCOLOR);
+
         if (aBackgroundColor.IsDark())
             aColor = COL_WHITE;
         else

Reply via email to