sw/sdi/_annotsh.sdi | 7 ++++++ sw/sdi/drwtxtsh.sdi | 7 ++++++ sw/source/uibase/shells/annotsh.cxx | 37 ++++++++++++++++++++++++++++++++++- sw/source/uibase/shells/drwtxtex.cxx | 35 ++++++++++++++++++++++++++++++++- 4 files changed, 84 insertions(+), 2 deletions(-)
New commits: commit 1c7740f33b885eb20f913bff1283e509f86fba9d Author: Justin Luth <[email protected]> AuthorDate: Thu Oct 10 20:19:25 2024 -0400 Commit: Justin Luth <[email protected]> CommitDate: Thu Oct 17 19:25:50 2024 +0200 tdf#34804 swdr: enable keyboard shortcut for CharColor and CharBackColor A followup patch that adds keyboard shortcut support for the draw objects (textbox, shapes, comments) in Writer. Change-Id: I69dea0feb75c77fec615a3e478d4bb90db4ca84f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174805 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> diff --git a/sw/sdi/_annotsh.sdi b/sw/sdi/_annotsh.sdi index 0c26a55dd6d0..1a0a35a93390 100644 --- a/sw/sdi/_annotsh.sdi +++ b/sw/sdi/_annotsh.sdi @@ -313,6 +313,13 @@ interface _Annotation DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + SID_ATTR_CHAR_COLOR2 + [ + ExecMethod = Exec; + StateMethod = GetState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + SID_ATTR_CHAR_BACK_COLOR // api: [ ExecMethod = Exec; diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi index 366683fbd52d..ab34cebf9007 100644 --- a/sw/sdi/drwtxtsh.sdi +++ b/sw/sdi/drwtxtsh.sdi @@ -742,6 +742,13 @@ interface TextDrawFont DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + SID_ATTR_CHAR_COLOR2 + [ + ExecMethod = Execute ; + StateMethod = GetDrawTextCtrlState ; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] + SID_ATTR_CHAR_BACK_COLOR // api: [ ExecMethod = Execute ; diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 6af5aa52fba5..cdec53e184e8 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -28,11 +28,13 @@ #include <com/sun/star/linguistic2/XThesaurus.hpp> #include <i18nutil/transliteration.hxx> +#include <sfx2/namedcolor.hxx> #include <sfx2/objface.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> +#include <editeng/colritem.hxx> #include <editeng/editund2.hxx> #include <editeng/eeitem.hxx> #include <editeng/flstitem.hxx> @@ -248,7 +250,39 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) break; } case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; - case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break; + + case SID_ATTR_CHAR_COLOR2: + { + if (!rReq.GetArgs()) + { + const std::optional<NamedColor>& oColor + = m_rView.GetDocShell()->GetRecentColor(SID_ATTR_CHAR_COLOR); + if (oColor.has_value()) + { + nEEWhich = GetPool().GetWhichIDFromSlotID(SID_ATTR_CHAR_COLOR); + const model::ComplexColor& rCol = (*oColor).getComplexColor(); + aNewAttr.Put(SvxColorItem(rCol.getFinalColor(), rCol, nEEWhich)); + rReq.SetArgs(aNewAttr); + rReq.SetSlot(SID_ATTR_CHAR_COLOR); + } + } + break; + } + case SID_ATTR_CHAR_BACK_COLOR: + { + nEEWhich = GetPool().GetWhichIDFromSlotID(nSlot); + if (!rReq.GetArgs()) + { + const std::optional<NamedColor>& oColor + = m_rView.GetDocShell()->GetRecentColor(nSlot); + if (oColor.has_value()) + { + const model::ComplexColor& rCol = (*oColor).getComplexColor(); + aNewAttr.Put(SvxColorItem(rCol.getFinalColor(), rCol, nEEWhich)); + } + } + break; + } case SID_ATTR_CHAR_UNDERLINE: { if( rReq.GetArgs() ) @@ -724,6 +758,7 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) rSet.InvalidateItem( nWhich ); } break; + case SID_ATTR_CHAR_COLOR2: case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break; case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break; diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index c53fa4b8bfc8..ca666e1b34b7 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -23,6 +23,7 @@ #include <comphelper/string.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> +#include <sfx2/namedcolor.hxx> #include <sfx2/request.hxx> #include <svx/svdview.hxx> #include <editeng/spltitem.hxx> @@ -147,8 +148,39 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) break; case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; - case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break; + case SID_ATTR_CHAR_COLOR2: + { + if (!rReq.GetArgs()) + { + const std::optional<NamedColor>& oColor + = GetView().GetDocShell()->GetRecentColor(SID_ATTR_CHAR_COLOR); + if (oColor.has_value()) + { + nEEWhich = GetPool().GetWhichIDFromSlotID(SID_ATTR_CHAR_COLOR); + const model::ComplexColor& rCol = (*oColor).getComplexColor(); + aNewAttr.Put(SvxColorItem(rCol.getFinalColor(), rCol, nEEWhich)); + rReq.SetArgs(aNewAttr); + rReq.SetSlot(SID_ATTR_CHAR_COLOR); + } + } + } + break; + case SID_ATTR_CHAR_BACK_COLOR: + { + nEEWhich = GetPool().GetWhichIDFromSlotID(nSlot); + if (!rReq.GetArgs()) + { + const std::optional<NamedColor>& oColor + = m_rView.GetDocShell()->GetRecentColor(nSlot); + if (oColor.has_value()) + { + const model::ComplexColor& rCol = (*oColor).getComplexColor(); + aNewAttr.Put(SvxColorItem(rCol.getFinalColor(), rCol, nEEWhich)); + } + } + break; + } case SID_ATTR_CHAR_UNDERLINE: { if ( pNewAttrs ) @@ -1019,6 +1051,7 @@ void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet) rSet.InvalidateItem( nWhich ); } break; + case SID_ATTR_CHAR_COLOR2: case SID_ATTR_CHAR_COLOR: nEEWhich = EE_CHAR_COLOR; break; case SID_ATTR_CHAR_BACK_COLOR: nEEWhich = EE_CHAR_BKGCOLOR; break; case SID_ATTR_CHAR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE;break;
