From 197d78c533307bd110e9b03fe94fb2f2d5240337 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 23 Sep 2016 18:15:14 +0200 Subject: tdf#102384 sw: avoid moving cursors of other windows in SwTextNode::Update() There is a list of exceptional SwIndex containers in that member function, like bookmarks, at-char anchored fly frames, etc. If we're growing (so basically in the safe case), don't touch the cursors of other windows, either. This helps to avoid the surprising "I didn't do anything and my cursor moved" behavior. (cherry picked from commit ecdec24c035513dbf2ee1814eb437e2a9d9a3d6c) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx sw/source/core/txtnode/ndtxt.cxx Change-Id: I9941fdcb6b7ad4b6e18a321cecc72fdf73d917fd --- sw/qa/extras/uiwriter/uiwriter.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sw/qa') diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index f68d292f0009..cb55d49ca919 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -88,6 +88,7 @@ #include #include #include +#include static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; @@ -191,6 +192,7 @@ public: void testRedlineParam(); void testRedlineViewAuthor(); void testRedlineTimestamp(); + void testCursorWindows(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -287,6 +289,7 @@ public: CPPUNIT_TEST(testRedlineParam); CPPUNIT_TEST(testRedlineViewAuthor); CPPUNIT_TEST(testRedlineTimestamp); + CPPUNIT_TEST(testCursorWindows); CPPUNIT_TEST_SUITE_END(); private: @@ -3397,6 +3400,27 @@ void SwUiWriterTest::testRedlineTimestamp() CPPUNIT_ASSERT(nSec1 != 0 || nSec2 != 0); } +void SwUiWriterTest::testCursorWindows() +{ + // Create a new document with one window. + SwDoc* pDoc = createDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + SwWrtShell* pWrtShell1 = pDocShell->GetWrtShell(); + + // Create a second view and type something. + SfxLokHelper::createView(); + SwWrtShell* pWrtShell2 = pDocShell->GetWrtShell(); + OUString aText("foo"); + pWrtShell2->Insert(aText); + + // Assert that only the cursor of the actual window move, not other cursors. + SwShellCursor* pShellCursor1 = pWrtShell1->getShellCursor(false); + SwShellCursor* pShellCursor2 = pWrtShell2->getShellCursor(false); + // This was 3, not 0 -- cursor of the other window moved. + CPPUNIT_ASSERT_EQUAL(static_cast(0), pShellCursor1->Start()->nContent.GetIndex()); + CPPUNIT_ASSERT_EQUAL(aText.getLength(), pShellCursor2->Start()->nContent.GetIndex()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit