[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - editeng/source include/vcl sc/source vcl/source

Noel Grandin noelgrandin at gmail.com
Thu Aug 17 11:55:45 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 a0636486e54bf9c8cf35657368e2779792da8b6d
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"
    
    Reviewed-on: https://gerrit.libreoffice.org/41111
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    (cherry picked from commit 5b3b0a91edc4c468c7c9c132cd066c0d25de9706)
    
    Change-Id: I262dd4c9cd1dc6eca82521f5fd9fbfc952fb7745
    Reviewed-on: https://gerrit.libreoffice.org/41133
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 10c7e9650fba..dcecf17887a6 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1285,7 +1285,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 dcc5ce7ec654..243783490cbb 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 22a80c561b7a..ef859a001a6a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1823,7 +1823,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 406cf2d9faba..d1f522f5f5fa 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1370,6 +1370,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 c6cb9618e4cf..f3c1b1a47b3c 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -736,7 +736,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 c44b57db20b5..b37395ad9bd0 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -761,6 +761,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