summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2024-10-10 20:48:10 -0400
committerJustin Luth <jluth@mail.com>2024-10-17 17:33:49 +0200
commitbc21a85029a6b31cab07a4e3d481e059120ff510 (patch)
tree7cd9d1e39bce1c0b5c7ebf4536c89b6198999435 /svx/source
parent4df8414e919f2ff82429dfa302db9cd2d1261b26 (diff)
tdf#34804 sw: enable keyboard shortcut for CharColor and CharBackColor
The result of this patch is that a keyboard shortcut can now set the font fore-/back-ground color using the color shown in the toolbar/sidebar. This is now possible thanks to Maxim's work in 7.6.2 tdf#154270 Sync toolbar button recent colors and Andreas Heinisch's 24.8 commit 8c822b764b35a0116a0865e991a87c8315e0 tdf#72991 - Remember last used color depending in cui This patch does 3 things: 1. SetRecentColor when the app initializes 2. Uses SID_ATTR_CHAR_COLOR's recentColor for .uno:FontColor if no pItem was provided (i.e. a keyboard shortcut called it) 3. Uses SID_ATTR_CHAR_BACK_COLOR's recentColor for .uno:CharBackColor if no pItem was provided (Note that without a selection, CharBackColor isn't so useful for a keyboard shortcut, since it turns the drag-and-drop template on.) Setting the recent color right away is critical for user acceptance. Otherwise, it would only function after they first modified the color in the toolbar/sidebar. make CppunitTest_sw_uiwriter9 CPPUNIT_TEST_NAME=testTdf34804 Unfortunately, I can't reliably know if this request came from an awt::KeyEvent or not, because in that case we could just avoid CharBackColor's template altogether. [While there is rReq.GetModifiers() as a good hint, it is not a guarantee (in case assigned to a function key, or CTRL held while clicking the toolbar, etc.)] Change-Id: I7377f087dcdf7011205af005cd0d172100bade2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174804 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/tbxctrls/tbxcolorupdate.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx
index be2d13c79b3e..c84d37fe73eb 100644
--- a/svx/source/tbxctrls/tbxcolorupdate.cxx
+++ b/svx/source/tbxctrls/tbxcolorupdate.cxx
@@ -122,6 +122,7 @@ namespace svx
o3tl::toUInt32(o3tl::getToken(aUserData, 0, ';', nIdx)));
}
}
+ SetRecentColor(aNamedColor, /*Broadcast=*/false);
Update(aNamedColor);
}
else
@@ -149,10 +150,10 @@ namespace svx
}
}
- void ToolboxButtonColorUpdaterBase::SetRecentColor(const NamedColor &rNamedColor)
+ void ToolboxButtonColorUpdaterBase::SetRecentColor(const NamedColor &rNamedColor, bool bBroadcast)
{
if (rtl::Reference xModel = dynamic_cast<SfxBaseModel*>(mxFrame->getController()->getModel().get()))
- xModel->GetObjectShell()->SetRecentColor(mnSlotId, rNamedColor);
+ xModel->GetObjectShell()->SetRecentColor(mnSlotId, rNamedColor, bBroadcast);
else if (!mbWideButton)
Update(rNamedColor);
}