diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-28 15:58:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-28 22:01:14 +0200 |
commit | 918316ba57230b1eaaf5138507546f743687e52b (patch) | |
tree | de6c1f5a8ff9982d4d0f84222d7e67f6bea50aeb /extensions | |
parent | d3313148d9ceb6427ddfef32b26b9d87cbdb3e14 (diff) |
bibliography copy and paste doesn't work from menus
when using native gtk menubar and menus because the focus
isn't in the bibliography window at that stage. Just remember
who had the focus when enabling/disabling the copy/paste entries.
Change-Id: I52e907725691932bdc61e0774ef5d2a50f0eb8cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101555
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/bibliography/framectr.cxx | 21 | ||||
-rw-r--r-- | extensions/source/bibliography/framectr.hxx | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index 6e70479e20d2..d41b7c78c9b7 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -225,7 +225,8 @@ void BibFrameController_Impl::dispose() mxImpl->aLC.disposeAndClear(aObject); m_xDatMan.clear(); aStatusListeners.clear(); - } + m_xLastQueriedFocusWin.clear(); +} void BibFrameController_Impl::addEventListener( const uno::Reference< lang::XEventListener > & aListener ) { @@ -560,7 +561,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen } else if(aCommand == "Cut") { - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + vcl::Window* pChild = m_xLastQueriedFocusWin.get(); if(pChild) { KeyEvent aEvent( 0, KeyFuncType::CUT ); @@ -569,7 +570,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen } else if(aCommand == "Copy") { - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + vcl::Window* pChild = m_xLastQueriedFocusWin.get(); if(pChild) { KeyEvent aEvent( 0, KeyFuncType::COPY ); @@ -578,7 +579,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen } else if(aCommand == "Paste") { - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + vcl::Window* pChild = m_xLastQueriedFocusWin.get(); if(pChild) { KeyEvent aEvent( 0, KeyFuncType::PASTE ); @@ -648,21 +649,21 @@ void BibFrameController_Impl::addStatusListener( } else if(aURL.Path == "Cut") { - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); - Edit* pEdit = dynamic_cast<Edit*>( pChild ); + m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + Edit* pEdit = dynamic_cast<Edit*>(m_xLastQueriedFocusWin.get()); aEvent.IsEnabled = pEdit && !pEdit->IsReadOnly() && pEdit->GetSelection().Len(); } if(aURL.Path == "Copy") { - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); - Edit* pEdit = dynamic_cast<Edit*>( pChild ); + m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + Edit* pEdit = dynamic_cast<Edit*>(m_xLastQueriedFocusWin.get()); aEvent.IsEnabled = pEdit && pEdit->GetSelection().Len(); } else if(aURL.Path == "Paste" ) { aEvent.IsEnabled = false; - vcl::Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); - Edit* pEdit = dynamic_cast<Edit*>( pChild ); + m_xLastQueriedFocusWin = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) ); + Edit* pEdit = dynamic_cast<Edit*>(m_xLastQueriedFocusWin.get()); if (pEdit && !pEdit->IsReadOnly()) { uno::Reference< datatransfer::clipboard::XClipboard > xClip = pEdit->GetClipboard(); diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx index 50bf20cfd057..75c336c763f0 100644 --- a/extensions/source/bibliography/framectr.hxx +++ b/extensions/source/bibliography/framectr.hxx @@ -28,6 +28,7 @@ #include <cppuhelper/implbase.hxx> #include <rtl/ref.hxx> #include <tools/link.hxx> +#include <vcl/window.hxx> #include <vector> #include <memory> @@ -67,6 +68,7 @@ friend class BibFrameCtrl_Impl; css::uno::Reference< css::frame::XFrame > xFrame; bool bDisposing; rtl::Reference<BibDataManager> m_xDatMan; + VclPtr<vcl::Window> m_xLastQueriedFocusWin; DECL_LINK( DisposeHdl, void*, void ); |