summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-28 15:58:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-28 22:01:14 +0200
commit918316ba57230b1eaaf5138507546f743687e52b (patch)
treede6c1f5a8ff9982d4d0f84222d7e67f6bea50aeb /extensions
parentd3313148d9ceb6427ddfef32b26b9d87cbdb3e14 (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.cxx21
-rw-r--r--extensions/source/bibliography/framectr.hxx2
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 );