[Libreoffice-commits] core.git: sw/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 12 20:52:53 UTC 2019


 sw/source/uibase/docvw/edtwin.cxx |  135 ++++++++++++++++++++------------------
 sw/source/uibase/inc/edtwin.hxx   |    2 
 2 files changed, 74 insertions(+), 63 deletions(-)

New commits:
commit 6c741d38f828c75f3114c325fa7a0b08c8b476de
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Aug 9 06:46:02 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Aug 12 22:51:39 2019 +0200

    sw: factor out changing of mouse pointer on mouse move
    
    Change-Id: I3ff9783d17b018cd962b2416810ac2ce166d35c6
    Reviewed-on: https://gerrit.libreoffice.org/77361
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 51a26c8447a4..d32f1212c3d5 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -3728,6 +3728,75 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
         Window::MouseButtonDown(rMEvt);
 }
 
+bool SwEditWin::changeMousePointer(Point const & rDocPoint)
+{
+    SwWrtShell & rShell = m_rView.GetWrtShell();
+
+    SwTab nMouseTabCol;
+    if ( SwTab::COL_NONE != (nMouseTabCol = rShell.WhichMouseTabCol( rDocPoint ) ) &&
+         !rShell.IsObjSelectable( rDocPoint ) )
+    {
+        PointerStyle nPointer = PointerStyle::Null;
+        bool bChkTableSel = false;
+
+        switch ( nMouseTabCol )
+        {
+            case SwTab::COL_VERT :
+            case SwTab::ROW_HORI :
+                nPointer = PointerStyle::VSizeBar;
+                bChkTableSel = true;
+                break;
+            case SwTab::ROW_VERT :
+            case SwTab::COL_HORI :
+                nPointer = PointerStyle::HSizeBar;
+                bChkTableSel = true;
+                break;
+            // Enhanced table selection
+            case SwTab::SEL_HORI :
+                nPointer = PointerStyle::TabSelectSE;
+                break;
+            case SwTab::SEL_HORI_RTL :
+            case SwTab::SEL_VERT :
+                nPointer = PointerStyle::TabSelectSW;
+                break;
+            case SwTab::COLSEL_HORI :
+            case SwTab::ROWSEL_VERT :
+                nPointer = PointerStyle::TabSelectS;
+                break;
+            case SwTab::ROWSEL_HORI :
+                nPointer = PointerStyle::TabSelectE;
+                break;
+            case SwTab::ROWSEL_HORI_RTL :
+            case SwTab::COLSEL_VERT :
+                nPointer = PointerStyle::TabSelectW;
+                break;
+            default: break; // prevent compiler warning
+        }
+
+        if ( PointerStyle::Null != nPointer &&
+            // i#35543 - Enhanced table selection is explicitly allowed in table mode
+            ( !bChkTableSel || !rShell.IsTableMode() ) )
+        {
+            SetPointer( nPointer );
+        }
+
+        return true;
+    }
+    else if (rShell.IsNumLabel(rDocPoint, RULER_MOUSE_MARGINWIDTH))
+    {
+        // i#42921 - consider vertical mode
+        SwTextNode* pNodeAtPos = rShell.GetNumRuleNodeAtPos( rDocPoint );
+        const PointerStyle nPointer =
+                SwFEShell::IsVerticalModeAtNdAndPos( *pNodeAtPos, rDocPoint )
+                ? PointerStyle::VSizeBar
+                : PointerStyle::HSizeBar;
+        SetPointer( nPointer );
+
+        return true;
+    }
+    return false;
+}
+
 void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
 {
     MouseEvent rMEvt(_rMEvt);
@@ -3850,70 +3919,10 @@ void SwEditWin::MouseMove(const MouseEvent& _rMEvt)
         }
     }
 
-    SwTab nMouseTabCol;
-    if( !bIsDocReadOnly && bInsWin && !m_pApplyTempl && !rSh.IsInSelect() )
+    // determine if we only change the mouse pointer and return
+    if (!bIsDocReadOnly && bInsWin && !m_pApplyTempl && !rSh.IsInSelect() && changeMousePointer(aDocPt))
     {
-        if ( SwTab::COL_NONE != (nMouseTabCol = rSh.WhichMouseTabCol( aDocPt ) ) &&
-             !rSh.IsObjSelectable( aDocPt ) )
-        {
-            PointerStyle nPointer = PointerStyle::Null;
-            bool bChkTableSel = false;
-
-            switch ( nMouseTabCol )
-            {
-                case SwTab::COL_VERT :
-                case SwTab::ROW_HORI :
-                    nPointer = PointerStyle::VSizeBar;
-                    bChkTableSel = true;
-                    break;
-                case SwTab::ROW_VERT :
-                case SwTab::COL_HORI :
-                    nPointer = PointerStyle::HSizeBar;
-                    bChkTableSel = true;
-                    break;
-                // Enhanced table selection
-                case SwTab::SEL_HORI :
-                    nPointer = PointerStyle::TabSelectSE;
-                    break;
-                case SwTab::SEL_HORI_RTL :
-                case SwTab::SEL_VERT :
-                    nPointer = PointerStyle::TabSelectSW;
-                    break;
-                case SwTab::COLSEL_HORI :
-                case SwTab::ROWSEL_VERT :
-                    nPointer = PointerStyle::TabSelectS;
-                    break;
-                case SwTab::ROWSEL_HORI :
-                    nPointer = PointerStyle::TabSelectE;
-                    break;
-                case SwTab::ROWSEL_HORI_RTL :
-                case SwTab::COLSEL_VERT :
-                    nPointer = PointerStyle::TabSelectW;
-                    break;
-                default: break; // prevent compiler warning
-            }
-
-            if ( PointerStyle::Null != nPointer &&
-                // i#35543 - Enhanced table selection is explicitly allowed in table mode
-                ( !bChkTableSel || !rSh.IsTableMode() ) )
-            {
-                SetPointer( nPointer );
-            }
-
-            return;
-        }
-        else if (rSh.IsNumLabel(aDocPt, RULER_MOUSE_MARGINWIDTH))
-        {
-            // i#42921 - consider vertical mode
-            SwTextNode* pNodeAtPos = rSh.GetNumRuleNodeAtPos( aDocPt );
-            const PointerStyle nPointer =
-                    SwFEShell::IsVerticalModeAtNdAndPos( *pNodeAtPos, aDocPt )
-                    ? PointerStyle::VSizeBar
-                    : PointerStyle::HSizeBar;
-            SetPointer( nPointer );
-
-            return;
-        }
+        return;
     }
 
     bool bDelShadCursor = true;
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 44d5d784a9d9..36aee0b1f6fd 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -174,6 +174,8 @@ class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
     virtual void    GetFocus() override;
     virtual void    LoseFocus() override;
 
+    bool changeMousePointer(Point const & rDocPoint);
+
     virtual void    MouseMove(const MouseEvent& rMEvt) override;
     virtual void    MouseButtonDown(const MouseEvent& rMEvt) override;
     virtual void    MouseButtonUp(const MouseEvent& rMEvt) override;


More information about the Libreoffice-commits mailing list