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
This commit is contained in:
@@ -163,6 +163,11 @@ void SwTiledRenderingTest::testSetTextSelection()
|
|||||||
pXTextDocument->setTextSelection(LOK_SETTEXTSELECTION_START, aStart.getX(), aStart.getY());
|
pXTextDocument->setTextSelection(LOK_SETTEXTSELECTION_START, aStart.getX(), aStart.getY());
|
||||||
// The new selection must include the first word, too -- but not the ending dot.
|
// The new selection must include the first word, too -- but not the ending dot.
|
||||||
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb"), pShellCrsr->GetTxt());
|
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb"), pShellCrsr->GetTxt());
|
||||||
|
|
||||||
|
// Next: test that LOK_SETTEXTSELECTION_RESET + LOK_SETTEXTSELECTION_END can be used to create a selection.
|
||||||
|
pXTextDocument->setTextSelection(LOK_SETTEXTSELECTION_RESET, aStart.getX(), aStart.getY());
|
||||||
|
pXTextDocument->setTextSelection(LOK_SETTEXTSELECTION_END, aStart.getX() + 1000, aStart.getY());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(OUString("Aaa b"), pShellCrsr->GetTxt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwTiledRenderingTest::testSetGraphicSelection()
|
void SwTiledRenderingTest::testSetGraphicSelection()
|
||||||
|
@@ -6247,9 +6247,18 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool
|
|||||||
|
|
||||||
// Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
|
// Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
|
||||||
SwEditShell& rShell = m_rView.GetWrtShell();
|
SwEditShell& rShell = m_rView.GetWrtShell();
|
||||||
|
|
||||||
|
bool bCreateSelection = false;
|
||||||
|
{
|
||||||
SwMvContext aMvContext(&rShell);
|
SwMvContext aMvContext(&rShell);
|
||||||
if (bClearMark)
|
if (bClearMark)
|
||||||
rShell.ClearMark();
|
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
|
// If the mark is to be updated, then exchange the point and mark before
|
||||||
// and after, as we can't easily set the mark.
|
// and after, as we can't easily set the mark.
|
||||||
if (!bPoint)
|
if (!bPoint)
|
||||||
@@ -6257,6 +6266,10 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool
|
|||||||
rShell.SetCrsr(rPosition);
|
rShell.SetCrsr(rPosition);
|
||||||
if (!bPoint)
|
if (!bPoint)
|
||||||
rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
|
rShell.getShellCrsr(/*bBlock=*/false)->Exchange();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bCreateSelection)
|
||||||
|
m_rView.GetWrtShell().EndSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwEditWin::SetGraphicTwipPosition(bool bStart, const Point& rPosition)
|
void SwEditWin::SetGraphicTwipPosition(bool bStart, const Point& rPosition)
|
||||||
|
Reference in New Issue
Block a user