diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-10-22 11:53:10 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-15 15:10:01 +0100 |
commit | 1e6ee2bf10c7c42942725a18b8c097f668829e65 (patch) | |
tree | 86735659dd0e661147f750eae9a761e6662f6a25 /sw | |
parent | 3645e458de1de661e1edd7d5e5016fe1e5356d7c (diff) |
sw_redlinehide_3: remove dubious fallback code from SwNodes::ChgNode()
There is no obvious case where such a fallback would be needed, but it
does introduce a bug with a delete redline inside a hidden section:
on Show, when moving the nodes into the body content,
FindPrvNxtFrameNode() will return nullptr because there are no frames
inside the hidden section, but then this fallback will cause it to
erroneously create a frame.
Change-Id: I2328a6f213fdec95857b6e4446e1a8504c17f599
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 60 | ||||
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 9 |
2 files changed, 60 insertions, 9 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 1ef90535f101..b5924c6e15b1 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -31,6 +31,7 @@ class SwUiWriterTest2 : public SwModelTestBase { public: void testRedlineMoveInsertInDelete(); + void testRedlineInHiddenSection(); void testTdf101534(); void testTdf54819(); void testTdf108687_tabstop(); @@ -39,6 +40,7 @@ public: CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testRedlineMoveInsertInDelete); + CPPUNIT_TEST(testRedlineInHiddenSection); CPPUNIT_TEST(testTdf101534); CPPUNIT_TEST(testTdf54819); CPPUNIT_TEST(testTdf108687_tabstop); @@ -125,6 +127,64 @@ void SwUiWriterTest2::testRedlineMoveInsertInDelete() pWrtShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); } +void SwUiWriterTest2::testRedlineInHiddenSection() +{ + loadURL("private:factory/swriter", nullptr); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwWrtShell* const pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + + pWrtShell->SplitNode(); + pWrtShell->Insert("foo"); + pWrtShell->SplitNode(); + pWrtShell->Insert("bar"); + pWrtShell->SplitNode(); + pWrtShell->Insert("baz"); + + RedlineFlags const mode(pWrtShell->GetRedlineFlags() | RedlineFlags::On); + CPPUNIT_ASSERT(mode & (RedlineFlags::ShowDelete | RedlineFlags::ShowInsert)); + pWrtShell->SetRedlineFlags(mode); + + // delete paragraph "bar" + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 2, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 8, /*bBasicCall=*/false); + pWrtShell->Delete(); + + pWrtShell->StartOfSection(); + pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->EndOfSection(true); + + SwSectionData section(CONTENT_SECTION, pWrtShell->GetUniqueSectionName()); + section.SetHidden(true); + SwSection const* pSection = pWrtShell->InsertSection(section, nullptr); + + SwSectionNode const* pNode = pSection->GetFormat()->GetSectionNode(); + + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 1]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 2]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 3]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT(pNode->GetNodes()[pNode->GetIndex() + 4]->IsEndNode()); + + pWrtShell->SetRedlineFlags(mode & ~RedlineFlags::ShowDelete); // hide + + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 1]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT(pNode->GetNodes()[pNode->GetIndex() + 2]->IsEndNode()); + + pWrtShell->SetRedlineFlags(mode); // show again + + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 1]->GetTextNode()->getLayoutFrame(nullptr)); + // there was a frame created here + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 2]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT( + !pNode->GetNodes()[pNode->GetIndex() + 3]->GetTextNode()->getLayoutFrame(nullptr)); + CPPUNIT_ASSERT(pNode->GetNodes()[pNode->GetIndex() + 4]->IsEndNode()); +} + void SwUiWriterTest2::testTdf54819() { load(DATA_DIRECTORY, "tdf54819.fodt"); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index c37bc375b5da..5415901819ff 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -358,15 +358,6 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz, SwNode* pFrameNd = rNds.FindPrvNxtFrameNode( aFrameNdIdx, rNds[ rInsPos.GetIndex() - 1 ] ); - if( !pFrameNd && aFrameNdIdx > rNds.GetEndOfExtras().GetIndex() ) - { - OSL_ENSURE( false, "here, something wrong happened" ); - aFrameNdIdx = rNds.GetEndOfContent(); - pFrameNd = SwNodes::GoPrevSection( &aFrameNdIdx, true, false ); - if( pFrameNd && !static_cast<SwContentNode*>(pFrameNd)->HasWriterListeners() ) - pFrameNd = nullptr; - OSL_ENSURE( pFrameNd, "ChgNode() - no FrameNode found" ); - } if( pFrameNd ) while( aIdx != rInsPos ) { |