diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc index 91b3ad373520..685c22b75ec7 100644 --- a/cui/inc/strings.hrc +++ b/cui/inc/strings.hrc @@ -387,7 +387,12 @@ #define RID_CUISTR_ADDITIONS_THEMES NC_("RID_SVXSTR_ADDITIONS_THEMES", "Extensions: Color Themes") #define RID_CUISTR_ADDITIONS_TEMPLATES NC_("RID_SVXSTR_ADDITIONS_TEMPLATES", "Extensions: Templates") -#define RID_CUISTR_UI_APPLY NC_("RID_SVXSTR_UI_APPLY", "Apply to %MODULE") +// Application names for the “Apply to X” button in the UI chooser dialog +#define RID_CUISTR_UI_APPLY_TO_WRITER NC_("RID_CUISTR_UI_APPLY_TO_WRITER", "Apply to Writer") +#define RID_CUISTR_UI_APPLY_TO_CALC NC_("RID_CUISTR_UI_APPLY_TO_CALC", "Apply to Calc") +#define RID_CUISTR_UI_APPLY_TO_IMPRESS NC_("RID_CUISTR_UI_APPLY_TO_IMPRESS", "Apply to Impress") +#define RID_CUISTR_UI_APPLY_TO_DRAW NC_("RID_CUISTR_UI_APPLY_TO_DRAW", "Apply to Draw") + #define RID_CUISTR_UI_APPLYALL NC_("RID_SVXSTR_UI_APPLYALL", "Apply to All") #define RID_CUISTR_OLE_INSERT NC_("RID_SVXSTR_OLE_INSERT", "Inserting OLE object...") diff --git a/cui/source/dialogs/uipickerdlg.cxx b/cui/source/dialogs/uipickerdlg.cxx index 69a3df6a3b67..c8837ae0ab3a 100644 --- a/cui/source/dialogs/uipickerdlg.cxx +++ b/cui/source/dialogs/uipickerdlg.cxx @@ -22,6 +22,33 @@ #include #include +namespace +{ +OUString lcl_GetApplyToText() +{ + if (std::optional sApp = UITabPage::GetCurrentAppEnum()) + { + switch (*sApp) + { + case vcl::EnumContext::Application::Writer: + return CuiResId(RID_CUISTR_UI_APPLY_TO_WRITER); + case vcl::EnumContext::Application::Calc: + return CuiResId(RID_CUISTR_UI_APPLY_TO_CALC); + case vcl::EnumContext::Application::Impress: + return CuiResId(RID_CUISTR_UI_APPLY_TO_IMPRESS); + case vcl::EnumContext::Application::Draw: + return CuiResId(RID_CUISTR_UI_APPLY_TO_DRAW); + default: + break; + } + } + + assert(!"UI picker dialog used for unsupported application"); + + return OUString(); +} +} + UIPickerDialog::UIPickerDialog(weld::Window* pParent) : SfxTabDialogController(pParent, u"cui/ui/uipickerdialog.ui"_ustr, u"UIPickerDialog"_ustr) , m_xOKBtn(m_xBuilder->weld_button(u"ok"_ustr)) @@ -39,8 +66,7 @@ UIPickerDialog::UIPickerDialog(weld::Window* pParent) // it's mandatory for gtk3 to set the icon before changing the label m_xApplyBtn->set_from_icon_name("sw/res/sc20558.png"); - m_xApplyBtn->set_label( - CuiResId(RID_CUISTR_UI_APPLY).replaceFirst("%MODULE", UITabPage::GetCurrentApp())); + m_xApplyBtn->set_label(lcl_GetApplyToText()); m_xResetBtn->set_label(CuiResId(RID_CUISTR_UI_APPLYALL)); m_xApplyBtn->connect_clicked(LINK(this, UIPickerDialog, OnApplyClick)); m_xResetBtn->connect_clicked(LINK(this, UIPickerDialog, OnApplyClick));