From 13b15ca63a476ff8c8da0761395d49d6c8127371 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 13 Feb 2020 16:48:02 +0000 Subject: weld MatchCaseControl Item Window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I33a8d96c449e653284d570ef534dcc453f27ad5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88619 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- svx/UIConfig_svx.mk | 1 + svx/source/tbxctrls/tbunosearchcontrollers.cxx | 71 ++++++++++++++++++++++---- svx/uiconfig/ui/checkbuttonbox.ui | 27 ++++++++++ 3 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 svx/uiconfig/ui/checkbuttonbox.ui (limited to 'svx') diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 561bdac0482a..542c42ad8b7b 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -23,6 +23,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/asianphoneticguidedialog \ svx/uiconfig/ui/cellmenu \ svx/uiconfig/ui/charsetmenu \ + svx/uiconfig/ui/checkbuttonbox \ svx/uiconfig/ui/chineseconversiondialog \ svx/uiconfig/ui/chinesedictionary \ svx/uiconfig/ui/classificationdialog \ diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 3769273ac3df..8d753e347f29 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -78,6 +78,58 @@ static const char COMMAND_SEARCHFORMATTED[] = ".uno:SearchFormattedDisplayString static const sal_Int32 REMEMBER_SIZE = 10; +class CheckButtonItemWindow final : public InterimItemWindow +{ +public: + CheckButtonItemWindow(vcl::Window* pParent) + : InterimItemWindow(pParent, "svx/ui/checkbuttonbox.ui", "CheckButtonBox") + , m_xWidget(m_xBuilder->weld_check_button("checkbutton")) + { + m_xWidget->connect_key_press(LINK(this, CheckButtonItemWindow, KeyInputHdl)); + } + + void SetOptimalSize() + { + SetSizePixel(m_xWidget->get_preferred_size()); + } + + void set_label(const OUString& rText) + { + m_xWidget->set_label(rText); + } + + bool get_active() const + { + return m_xWidget->get_active(); + } + + virtual void dispose() override + { + m_xWidget.reset(); + InterimItemWindow::dispose(); + } + + virtual ~CheckButtonItemWindow() override + { + disposeOnce(); + } + + virtual void GetFocus() override + { + m_xWidget->grab_focus(); + } + +private: + std::unique_ptr m_xWidget; + + DECL_LINK(KeyInputHdl, const KeyEvent&, bool); +}; + +IMPL_LINK(CheckButtonItemWindow, KeyInputHdl, const KeyEvent&, rKeyEvent, bool) +{ + return ChildKeyInput(rKeyEvent); +} + void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const css::uno::Reference< css::frame::XFrame >& xFrame, const ToolBox* pToolBox, @@ -106,9 +158,9 @@ void impl_executeSearch( const css::uno::Reference< css::uno::XComponentContext sFindText = pItemWin->get_active_text(); } else if ( sItemCommand == COMMAND_MATCHCASE ) { - CheckBox* pItemWin = static_cast( pToolBox->GetItemWindow(id) ); + CheckButtonItemWindow* pItemWin = static_cast( pToolBox->GetItemWindow(id) ); if (pItemWin) - aMatchCase = pItemWin->IsChecked(); + aMatchCase = pItemWin->get_active(); } else if ( sItemCommand == COMMAND_SEARCHFORMATTED ) { CheckBox* pItemWin = static_cast( pToolBox->GetItemWindow(id) ); @@ -800,14 +852,14 @@ public: virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; private: - VclPtr m_pMatchCaseControl; + VclPtr m_xMatchCaseControl; }; MatchCaseToolboxController::MatchCaseToolboxController( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) : svt::ToolboxController( rxContext, css::uno::Reference< css::frame::XFrame >(), COMMAND_MATCHCASE ) - , m_pMatchCaseControl(nullptr) + , m_xMatchCaseControl(nullptr) { } @@ -856,7 +908,7 @@ void SAL_CALL MatchCaseToolboxController::dispose() svt::ToolboxController::dispose(); - m_pMatchCaseControl.disposeAndClear(); + m_xMatchCaseControl.disposeAndClear(); } // XInitialization @@ -875,12 +927,11 @@ css::uno::Reference< css::awt::XWindow > SAL_CALL MatchCaseToolboxController::cr if ( pParent ) { ToolBox* pToolbar = static_cast(pParent.get()); - m_pMatchCaseControl = VclPtr::Create( pToolbar, 0 ); - m_pMatchCaseControl->SetText( SvxResId( RID_SVXSTR_FINDBAR_MATCHCASE ) ); - Size aSize( m_pMatchCaseControl->GetOptimalSize() ); - m_pMatchCaseControl->SetSizePixel( aSize ); + m_xMatchCaseControl = VclPtr::Create(pToolbar); + m_xMatchCaseControl->set_label(SvxResId(RID_SVXSTR_FINDBAR_MATCHCASE)); + m_xMatchCaseControl->SetOptimalSize(); } - xItemWindow = VCLUnoHelper::GetInterface( m_pMatchCaseControl ); + xItemWindow = VCLUnoHelper::GetInterface(m_xMatchCaseControl); return xItemWindow; } diff --git a/svx/uiconfig/ui/checkbuttonbox.ui b/svx/uiconfig/ui/checkbuttonbox.ui new file mode 100644 index 000000000000..7d2ac5c3d0a7 --- /dev/null +++ b/svx/uiconfig/ui/checkbuttonbox.ui @@ -0,0 +1,27 @@ + + + + + + True + False + True + 6 + + + True + True + False + True + True + True + True + + + False + True + 0 + + + + -- cgit