summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-08-09 06:46:02 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-08-12 22:51:39 +0200
commit6c741d38f828c75f3114c325fa7a0b08c8b476de (patch)
tree331671b952633f323aa4826d1066c2b09b05f4c9 /sw
parent81aebe1845d2c5511a96b918cba4263bc6f3ef85 (diff)
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@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx135
-rw-r--r--sw/source/uibase/inc/edtwin.hxx2
2 files changed, 74 insertions, 63 deletions
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;