summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-15 09:58:25 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-15 10:41:08 +0200
commit3de68db1cd69627f4e529e5621eb97a8ea898aa3 (patch)
treea7cd29bafb773cba17b676650f7fd506681ddc11 /sw/source/uibase
parentf9bef754a7d81942d1f1362b5602c20490275ee3 (diff)
SwEditWin::SetCursorTwipPosition: support creating a selection
The Android LOK client always creates a text selection by double clicking on a word, and then the start/end of the selection can be adjusted using handles. In the GTK LOK client, it makes sense to allow the desktop-style selection, where you click somewhere, move the mouse and finally release the mouse to create a selection. That can be mapped to settextselect-reset on mouse-down, and settextselect-end on mouse-move easily. The only problem was that SetCursorTwipPosition() assumed that there is a selection already -- fix that by adding the missing Stt/EndSelect() calls and limiting the lifetime of the SwMvContext instance. Change-Id: Iaeeadd8e4d9030614ee069b9fcfa269ce74ed58a
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx33
1 files changed, 23 insertions, 10 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index fe41345faf5e..7a5d7117b4cf 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6247,16 +6247,29 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool
// Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
SwEditShell& rShell = m_rView.GetWrtShell();
- SwMvContext aMvContext(&rShell);
- if (bClearMark)
- rShell.ClearMark();
- // If the mark is to be updated, then exchange the point and mark before
- // and after, as we can't easily set the mark.
- if (!bPoint)
- rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
- rShell.SetCrsr(rPosition);
- if (!bPoint)
- rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
+
+ bool bCreateSelection = false;
+ {
+ SwMvContext aMvContext(&rShell);
+ if (bClearMark)
+ rShell.ClearMark();
+ else
+ bCreateSelection = !rShell.HasMark();
+
+ if (bCreateSelection)
+ m_rView.GetWrtShell().SttSelect();
+
+ // If the mark is to be updated, then exchange the point and mark before
+ // and after, as we can't easily set the mark.
+ if (!bPoint)
+ rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
+ rShell.SetCrsr(rPosition);
+ if (!bPoint)
+ rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
+ }
+
+ if (bCreateSelection)
+ m_rView.GetWrtShell().EndSelect();
}
void SwEditWin::SetGraphicTwipPosition(bool bStart, const Point& rPosition)