sc/source/ui/drawfunc/drtxtob.cxx |   15 +++++++++++++++
 sc/source/ui/view/editsh.cxx      |   13 +++++++++++++
 2 files changed, 28 insertions(+)

New commits:
commit cdd00486a73ab94eeda2e403eba5df813f472e60
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Oct 11 14:10:01 2024 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Thu Oct 17 19:28:06 2024 +0200

    tdf#34804 sc: enable keyboard shortcut for CharColor and CharBackColor
    
    A followup patch that adds keyboard shortcut support to Calc
    for .uno:Color and .uno:CharBackColor to use recentColor.
    
    Note that for Writer, it was .uno:FontColor (SID_ATTR_CHAR_COLOR2)
    but the rest of the applications are .uno:Color (SID_ATTR_CHAR_COLOR)
    
    I purposely did not add CharBackColor support to native Calc.
    Notice that the "fill" icon on the toolbar is CELL-background, so the
    color used would NOT NECESSARILY match what is seen in the toolbar,
    and the sidebar also does not include a CharBackColor button.
    [See patchset 1 for stuff needed for implementation.]
    
    formatsh is for entire cells - .uno:Color opens dialog when no args: OK
    
    editsc is for cursor-in-cell and for cursor-in-formula-bar.
    
    drtxtobj is for comments, shapes, and textboxes (draw stuff).
    
    Change-Id: I104b39eab1d475fc5c88837addf4bdbbd313d1be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174827
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 6138b29120e4..8eba19057411 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -23,6 +23,7 @@
 #include <i18nutil/transliteration.hxx>
 #include <editeng/adjustitem.hxx>
 #include <svx/clipfmtitem.hxx>
+#include <editeng/colritem.hxx>
 #include <editeng/contouritem.hxx>
 #include <editeng/crossedoutitem.hxx>
 #include <editeng/eeitem.hxx>
@@ -48,6 +49,7 @@
 #include <editeng/wghtitem.hxx>
 #include <editeng/writingmodeitem.hxx>
 #include <sfx2/dispatch.hxx>
+#include <sfx2/namedcolor.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/request.hxx>
@@ -918,6 +920,19 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
                     );
                 }
                 break;
+            case SID_ATTR_CHAR_COLOR:
+            case SID_ATTR_CHAR_BACK_COLOR:
+            {
+                const sal_uInt16 nEEWhich = 
GetPool().GetWhichIDFromSlotID(nSlot);
+                const std::optional<NamedColor>& oColor
+                    = mrViewData.GetDocShell()->GetRecentColor(nSlot);
+                if (oColor.has_value())
+                {
+                    const model::ComplexColor& rCol = 
(*oColor).getComplexColor();
+                    aNewAttr.Put(SvxColorItem(rCol.getFinalColor(), rCol, 
nEEWhich));
+                }
+                break;
+            }
         }
     }
 
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 4f89028d4c16..e5396188f418 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -48,6 +48,7 @@
 #include <sfx2/dispatch.hxx>
 #include <sfx2/docfile.hxx>
 #include <sfx2/docfilt.hxx>
+#include <sfx2/namedcolor.hxx>
 #include <sfx2/msg.hxx>
 #include <sfx2/objface.hxx>
 #include <sfx2/objsh.hxx>
@@ -1028,12 +1029,24 @@ void ScEditShell::ExecuteAttr(SfxRequest& rReq)
             break;
 
         case SID_ATTR_CHAR_COLOR:
+        case SID_ATTR_CHAR_BACK_COLOR:
             {
                 if (pArgs)
                 {
                     aSet.Put( pArgs->Get( 
pArgs->GetPool()->GetWhichIDFromSlotID( nSlot ) ) );
                     rBindings.Invalidate( nSlot );
                 }
+                else
+                {
+                    const sal_uInt16 nEEWhich = 
GetPool().GetWhichIDFromSlotID(nSlot);
+                    const std::optional<NamedColor>& oColor
+                        = rViewData.GetDocShell()->GetRecentColor(nSlot);
+                    if (oColor.has_value())
+                    {
+                        const model::ComplexColor& rCol = 
(*oColor).getComplexColor();
+                        aSet.Put(SvxColorItem(rCol.getFinalColor(), rCol, 
nEEWhich));
+                    }
+                }
             }
             break;
 

Reply via email to