diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-05-10 13:35:26 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-05-10 18:01:09 +0200 |
commit | ffe239962f195781c6b086c5a284aad333e3e12e (patch) | |
tree | 3df7bc31587e3362aa1ace55dbc4aeb58df580f4 | |
parent | 60901e880b215d06ab3a7d79d2041bb2c6c64a78 (diff) |
sw: avoid assert in SwUndoDelete::RedoImpl
1. insert as-char fly in paragraph
2. hit DEL to delete it
3. Undo
4. Redo
Assertion `aTmp.GetPoint()->nNode != rPam.GetPoint()->nNode && aTmp.GetPoint()->nNode != rPam.GetMark()->nNode' failed
This was added in e06131e96629eee4e94eba1da7242380716e8e88 assuming that
this branch is only reachable with m_bDelFullPara, but it turns out that
you get no start/end text also because DelContentIndex() already
deleted everything.
Change-Id: If4ce55dd4b63d6db11ed3195f78cd595149c0c1b
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 35 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 6 |
2 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 0d40ae1829a1..4d58b7c242aa 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -187,6 +187,7 @@ public: void testTdf88899(); void testTdf90362(); void testUndoCharAttribute(); + void testUndoDelAsChar(); void testTdf86639(); void testTdf90883TableBoxGetCoordinates(); void testEmbeddedDataSource(); @@ -319,6 +320,7 @@ public: CPPUNIT_TEST(testTdf88899); CPPUNIT_TEST(testTdf90362); CPPUNIT_TEST(testUndoCharAttribute); + CPPUNIT_TEST(testUndoDelAsChar); CPPUNIT_TEST(testTdf86639); CPPUNIT_TEST(testTdf90883TableBoxGetCoordinates); CPPUNIT_TEST(testEmbeddedDataSource); @@ -3220,6 +3222,39 @@ void SwUiWriterTest::testUndoCharAttribute() CPPUNIT_ASSERT_EQUAL((*pPoolItem == aWeightItem), false); } +void SwUiWriterTest::testUndoDelAsChar() +{ + SwDoc * pDoc(createDoc()); + sw::UndoManager & rUndoManager(pDoc->GetUndoManager()); + IDocumentContentOperations & rIDCO(pDoc->getIDocumentContentOperations()); + SwCursorShell * pShell(pDoc->GetEditShell()); + SfxItemSet frameSet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1); + SfxItemSet grfSet(pDoc->GetAttrPool(), RES_GRFATR_BEGIN, RES_GRFATR_END-1); + SwFormatAnchor anchor(RndStdIds::FLY_AS_CHAR); + frameSet.Put(anchor); + GraphicObject grf; + CPPUNIT_ASSERT(rIDCO.InsertGraphicObject(*pShell->GetCursor(), grf, &frameSet, &grfSet, nullptr)); + CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); + pShell->SetMark(); + pShell->Left(1, CRSR_SKIP_CHARS); + rIDCO.DeleteAndJoin(*pShell->GetCursor()); + CPPUNIT_ASSERT_EQUAL(size_t(0), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); + CPPUNIT_ASSERT(!pShell->GetCursor()->GetNode().GetTextNode()->HasHints()); + CPPUNIT_ASSERT_EQUAL(0, pShell->GetCursor()->GetNode().GetTextNode()->Len()); + rUndoManager.Undo(); + CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); + CPPUNIT_ASSERT(pShell->GetCursor()->GetNode().GetTextNode()->HasHints()); + CPPUNIT_ASSERT_EQUAL(1, pShell->GetCursor()->GetNode().GetTextNode()->Len()); + rUndoManager.Redo(); + CPPUNIT_ASSERT_EQUAL(size_t(0), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); + CPPUNIT_ASSERT(!pShell->GetCursor()->GetNode().GetTextNode()->HasHints()); + CPPUNIT_ASSERT_EQUAL(0, pShell->GetCursor()->GetNode().GetTextNode()->Len()); + rUndoManager.Undo(); + CPPUNIT_ASSERT_EQUAL(size_t(1), pDoc->GetFlyCount(FLYCNTTYPE_GRF)); + CPPUNIT_ASSERT(pShell->GetCursor()->GetNode().GetTextNode()->HasHints()); + CPPUNIT_ASSERT_EQUAL(1, pShell->GetCursor()->GetNode().GetTextNode()->Len()); +} + void SwUiWriterTest::testTdf86639() { SwDoc* pDoc = createDoc("tdf86639.rtf"); diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 566a268af6e6..565405c1bcab 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1048,6 +1048,12 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) } pTableNd->DelFrames(); } + else if (*rPam.GetMark() == *rPam.GetPoint()) + { // paragraph with only footnote or as-char fly, delete that + // => DelContentIndex has already deleted it! nothing to do here + assert(nEndNode == nSttNode); + return; + } // avoid asserts from ~SwIndexReg for deleted nodes SwPaM aTmp(*rPam.End()); |