[Libreoffice-commits] core.git: editeng/source include/vcl sc/source vcl/source
Noel Grandin
noelgrandin at gmail.com
Sun Aug 13 19:38:56 UTC 2017
editeng/source/editeng/impedit.cxx | 8 +++++++-
include/vcl/settings.hxx | 2 +-
sc/source/ui/app/inputwin.cxx | 9 ++++++++-
sc/source/ui/view/gridwin.cxx | 11 ++++++++++-
vcl/source/control/edit.cxx | 7 +++++++
vcl/source/edit/textview.cxx | 10 +++++++++-
vcl/source/window/winproc.cxx | 2 ++
7 files changed, 44 insertions(+), 5 deletions(-)
New commits:
commit 5b3b0a91edc4c468c7c9c132cd066c0d25de9706
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sun Aug 13 13:37:28 2017 +0200
tdf#110988 Middle click does not paste primary selection
regression from commit 65b7b6322b662785bf032e66c76abc36c9a2bb0e
"loplugin:unusedenumconstants read-only constants in vcl"
Change-Id: I262dd4c9cd1dc6eca82521f5fd9fbfc952fb7745
Reviewed-on: https://gerrit.libreoffice.org/41111
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index b670682104f4..f0f80b4f700d 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1349,7 +1349,13 @@ bool ImpEditView::MouseButtonUp( const MouseEvent& rMouseEvent )
nExtraCursorFlags = GetCursorFlags::NONE;
bClickedInSelection = false;
- if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() )
+ if ( rMouseEvent.IsMiddle() && !bReadOnly &&
+ ( GetWindow()->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
+ {
+ Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection());
+ Paste( aClipBoard );
+ }
+ else if ( rMouseEvent.IsLeft() && GetEditSelection().HasRange() )
{
Reference<css::datatransfer::clipboard::XClipboard> aClipBoard(GetWindow()->GetPrimarySelection());
CutCopy( aClipBoard, false );
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 8dcaa4ceacfc..097605e7c251 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -79,7 +79,7 @@ namespace o3tl
enum class MouseMiddleButtonAction
{
- Nothing, AutoScroll
+ Nothing, AutoScroll, PasteSelection
};
enum class MouseWheelBehaviour
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 7d0b7fa036fd..f60937c047f0 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1349,7 +1349,14 @@ void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
if (mpEditView)
if (mpEditView->MouseButtonUp( rMEvt ))
{
- SC_MOD()->InputSelection( mpEditView.get() );
+ if ( rMEvt.IsMiddle() &&
+ GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
+ {
+ // EditView may have pasted from selection
+ SC_MOD()->InputChanged( mpEditView.get() );
+ }
+ else
+ SC_MOD()->InputSelection( mpEditView.get() );
}
}
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3bcec4d4ac86..23edbf1b28bb 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1818,7 +1818,16 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
SCROW nEditRow;
pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
pEditView->MouseButtonUp( rMEvt );
- pScMod->InputSelection( pEditView ); // parentheses etc.
+
+ if ( rMEvt.IsMiddle() &&
+ GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection )
+ {
+ // EditView may have pasted from selection
+ pScMod->InputChanged( pEditView );
+ }
+ else
+ pScMod->InputSelection( pEditView ); // parentheses etc.
+
pViewData->GetView()->InvalidateAttribs();
rBindings.Invalidate( SID_HYPERLINK_GETLINK );
bEEMouse = false;
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 69cc50abf549..95c079c4a7c2 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1361,6 +1361,13 @@ void Edit::MouseButtonUp( const MouseEvent& rMEvt )
ImplSetCursorPos( nCharPos, false );
mbClickedInSelection = false;
}
+ else if ( rMEvt.IsMiddle() && !mbReadOnly &&
+ ( GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
+ {
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(Window::GetPrimarySelection());
+ ImplPaste( aSelection );
+ ImplModified();
+ }
}
void Edit::Tracking( const TrackingEvent& rTEvt )
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index ae9fac5aba7f..7c528430b151 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -734,7 +734,15 @@ void TextView::MouseButtonUp( const MouseEvent& rMouseEvent )
mpImpl->mbClickedInSelection = false;
mpImpl->mnTravelXPos = TRAVEL_X_DONTKNOW;
mpImpl->mpSelEngine->SelMouseButtonUp( rMouseEvent );
- if ( rMouseEvent.IsLeft() && GetSelection().HasRange() )
+ if ( rMouseEvent.IsMiddle() && !IsReadOnly() &&
+ ( GetWindow()->GetSettings().GetMouseSettings().GetMiddleButtonAction() == MouseMiddleButtonAction::PasteSelection ) )
+ {
+ css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetWindow()->GetPrimarySelection());
+ Paste( aSelection );
+ if ( mpImpl->mpTextEngine->IsModified() )
+ mpImpl->mpTextEngine->Broadcast( TextHint( SfxHintId::TextModified ) );
+ }
+ else if ( rMouseEvent.IsLeft() && GetSelection().HasRange() )
{
css::uno::Reference<css::datatransfer::clipboard::XClipboard> aSelection(GetWindow()->GetPrimarySelection());
Copy( aSelection );
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 7a182b07eeab..bc9c4682d258 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -755,6 +755,8 @@ bool ImplHandleMouseEvent( const VclPtr<vcl::Window>& xWindow, MouseNotifyEvent
MouseMiddleButtonAction nMiddleAction = pChild->GetSettings().GetMouseSettings().GetMiddleButtonAction();
if ( nMiddleAction == MouseMiddleButtonAction::AutoScroll )
bRet = !ImplCallCommand( pChild, CommandEventId::StartAutoScroll, nullptr, true, &aChildPos );
+ else if ( nMiddleAction == MouseMiddleButtonAction::PasteSelection )
+ bRet = !ImplCallCommand( pChild, CommandEventId::PasteSelection, nullptr, true, &aChildPos );
}
else
{
More information about the Libreoffice-commits
mailing list