sc/source/ui/view/formatsh.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 067e78a01ce9a9f4e8056108c640984a3c9dbc33
Author:     Heiko Tietze <[email protected]>
AuthorDate: Wed Dec 17 10:21:30 2025 +0100
Commit:     Heiko Tietze <[email protected]>
CommitDate: Wed Dec 17 21:19:40 2025 +0100

    Resolves tdf#138722 - Apply last used color for uno:BackgroundColor
    
    Change-Id: Ibf1d40ac9f1be78ad768166a50446e88a8586c1d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195771
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <[email protected]>

diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index a4224ae3b9c1..6c6c70814bff 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -24,6 +24,7 @@
 
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/bindings.hxx>
+#include <sfx2/namedcolor.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/request.hxx>
 #include <svl/whiter.hxx>
@@ -947,10 +948,19 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
 
             case SID_BACKGROUND_COLOR:
                 {
+                    Color aColor(COL_TRANSPARENT);
+                    if (auto pObjectShell = pTabViewShell->GetObjectShell())
+                    {
+                        const std::optional<NamedColor> oColor
+                            = 
pObjectShell->GetRecentColor(SID_BACKGROUND_COLOR);
+                        if (oColor.has_value())
+                            aColor = 
(*oColor).getComplexColor().getFinalColor();
+                    }
+
                     SvxBrushItem aBrushItem(
-                                     
pTabViewShell->GetSelectionPattern()->GetItem( ATTR_BACKGROUND ) );
-                    aBrushItem.SetColor( COL_TRANSPARENT );
-                    pTabViewShell->ApplyAttr( aBrushItem, false );
+                        
pTabViewShell->GetSelectionPattern()->GetItem(ATTR_BACKGROUND));
+                    aBrushItem.SetColor(aColor);
+                    pTabViewShell->ApplyAttr(aBrushItem, false);
                 }
                 break;
 

Reply via email to