de-duplicate some code

Change-Id: I5900ee56cf5c80f00743060d1d22dfd3d383f1eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88622
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2020-02-13 17:06:04 +00:00
parent 3688235a8d
commit 3f893b52e7

View File

@@ -80,23 +80,15 @@ static const sal_Int32 REMEMBER_SIZE = 10;
class CheckButtonItemWindow final : public InterimItemWindow class CheckButtonItemWindow final : public InterimItemWindow
{ {
public: public:
CheckButtonItemWindow(vcl::Window* pParent) CheckButtonItemWindow(vcl::Window* pParent, const OUString& rLabel)
: InterimItemWindow(pParent, "svx/ui/checkbuttonbox.ui", "CheckButtonBox") : InterimItemWindow(pParent, "svx/ui/checkbuttonbox.ui", "CheckButtonBox")
, m_xWidget(m_xBuilder->weld_check_button("checkbutton")) , m_xWidget(m_xBuilder->weld_check_button("checkbutton"))
{ {
m_xWidget->connect_key_press(LINK(this, CheckButtonItemWindow, KeyInputHdl)); m_xWidget->connect_key_press(LINK(this, CheckButtonItemWindow, KeyInputHdl));
} m_xWidget->set_label(rLabel);
void SetOptimalSize()
{
SetSizePixel(m_xWidget->get_preferred_size()); SetSizePixel(m_xWidget->get_preferred_size());
} }
void set_label(const OUString& rText)
{
m_xWidget->set_label(rText);
}
bool get_active() const bool get_active() const
{ {
return m_xWidget->get_active(); return m_xWidget->get_active();
@@ -926,9 +918,7 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::cr
if ( pParent ) if ( pParent )
{ {
ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get()); ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get());
m_xMatchCaseControl = VclPtr<CheckButtonItemWindow>::Create(pToolbar); m_xMatchCaseControl = VclPtr<CheckButtonItemWindow>::Create(pToolbar, SvxResId(RID_SVXSTR_FINDBAR_MATCHCASE));
m_xMatchCaseControl->set_label(SvxResId(RID_SVXSTR_FINDBAR_MATCHCASE));
m_xMatchCaseControl->SetOptimalSize();
} }
xItemWindow = VCLUnoHelper::GetInterface(m_xMatchCaseControl); xItemWindow = VCLUnoHelper::GetInterface(m_xMatchCaseControl);
@@ -1044,9 +1034,7 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL SearchFormattedToolboxControll
if ( pParent ) if ( pParent )
{ {
ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get()); ToolBox* pToolbar = static_cast<ToolBox*>(pParent.get());
m_xSearchFormattedControl = VclPtr<CheckButtonItemWindow>::Create(pToolbar); m_xSearchFormattedControl = VclPtr<CheckButtonItemWindow>::Create(pToolbar, SvxResId(RID_SVXSTR_FINDBAR_SEARCHFORMATTED));
m_xSearchFormattedControl->set_label(SvxResId(RID_SVXSTR_FINDBAR_SEARCHFORMATTED));
m_xSearchFormattedControl->SetOptimalSize();
} }
xItemWindow = VCLUnoHelper::GetInterface(m_xSearchFormattedControl); xItemWindow = VCLUnoHelper::GetInterface(m_xSearchFormattedControl);