summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx5
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx33
2 files changed, 28 insertions, 10 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 67c04db7df2c..b42f05cd3f56 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -163,6 +163,11 @@ void SwTiledRenderingTest::testSetTextSelection()
pXTextDocument->setTextSelection(LOK_SETTEXTSELECTION_START, aStart.getX(), aStart.getY());
// The new selection must include the first word, too -- but not the ending dot.
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()
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)