From c977473546e450ec122f5d3dbc4578d8994962ef Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Tue, 15 Jan 2019 13:20:13 +0300 Subject: tdf#38328: allow Find&Replace key combinations in FindTextFieldControl ... using svt::AcceleratorExecute to detect user-configurable key combinations. Change-Id: Iad4f6d3e0becfb896d4b4342c819c98e04789a1c Reviewed-on: https://gerrit.libreoffice.org/66377 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- svx/source/tbxctrls/tbunosearchcontrollers.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'svx') diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index 323712913699..a3617a8362cf 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -159,6 +160,7 @@ private: css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::uno::XComponentContext > m_xContext; + std::unique_ptr m_pAcc; }; FindTextFieldControl::FindTextFieldControl( vcl::Window* pParent, WinBits nStyle, @@ -166,10 +168,12 @@ FindTextFieldControl::FindTextFieldControl( vcl::Window* pParent, WinBits nStyle const css::uno::Reference< css::uno::XComponentContext >& xContext) : ComboBox( pParent, nStyle ), m_xFrame(xFrame), - m_xContext(xContext) + m_xContext(xContext), + m_pAcc(svt::AcceleratorExecute::createAcceleratorHelper()) { SetPlaceholderText(SvxResId(RID_SVXSTR_FINDBAR_FIND)); EnableAutocomplete(true, true); + m_pAcc->init(m_xContext, m_xFrame); } void FindTextFieldControl::Remember_Impl(const OUString& rStr) @@ -262,11 +266,11 @@ bool FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) } } // Select text in the search box when Ctrl-F pressed - if ( bMod1 && nCode == KEY_F ) + else if ( bMod1 && nCode == KEY_F ) SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); // Execute the search when Return, Ctrl-G or F3 pressed - if ( KEY_RETURN == nCode || (bMod1 && (KEY_G == nCode)) || (KEY_F3 == nCode) ) + else if ( KEY_RETURN == nCode || (bMod1 && (KEY_G == nCode)) || (KEY_F3 == nCode) ) { Remember_Impl(GetText()); @@ -276,6 +280,13 @@ bool FindTextFieldControl::PreNotify( NotifyEvent& rNEvt ) impl_executeSearch( m_xContext, m_xFrame, pToolBox, bShift); bRet = true; } + else + { + auto awtKey = svt::AcceleratorExecute::st_VCLKey2AWTKey(pKeyEvent->GetKeyCode()); + const OUString aCommand(m_pAcc->findCommand(awtKey)); + if (aCommand == ".uno:SearchDialog") + bRet = m_pAcc->execute(awtKey); + } break; } -- cgit