Here's another bug fix. This time, it allows for undoing the
insertion of section breaks. I also changed the section break
insertion code slightly to make section break insertion always user
atomic.
While I was testing I discovered an assertion failure unrelated to the
code I changed, so I entered it in Bugzilla as bug #413.
The patch is attached.
-- Matt Kimball mkimball@xmission.com--GvXjxJ+pjyke8COw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="abiword-bug318.patch"
diff -ur ../abi-0.5.5/src/text/fmt/xp/fv_View.cpp ./src/text/fmt/xp/fv_View.cpp --- ../abi-0.5.5/src/text/fmt/xp/fv_View.cpp Thu Apr 29 11:34:46 1999 +++ ./src/text/fmt/xp/fv_View.cpp Sun May 2 14:02:55 1999 @@ -878,12 +878,10 @@ void FV_View::insertSectionBreak(void) { - UT_Bool bDidGlob = UT_FALSE; - + m_pDoc->beginUserAtomicGlob(); + if (!isSelectionEmpty()) { - bDidGlob = UT_TRUE; - m_pDoc->beginUserAtomicGlob(); _deleteSelection(); } else @@ -899,8 +897,7 @@ m_pDoc->insertStrux(iPoint, PTX_Block); m_pDoc->insertStrux(iPoint, PTX_Section); - if (bDidGlob) - m_pDoc->endUserAtomicGlob(); + m_pDoc->endUserAtomicGlob(); _generalUpdate(); diff -ur ../abi-0.5.5/src/text/ptbl/xp/pt_PT_Undo.cpp ./src/text/ptbl/xp/pt_PT_Undo.cpp --- ../abi-0.5.5/src/text/ptbl/xp/pt_PT_Undo.cpp Fri Apr 23 08:25:16 1999 +++ ./src/text/ptbl/xp/pt_PT_Undo.cpp Sun May 2 13:32:23 1999 @@ -203,29 +203,19 @@ case PX_ChangeRecord::PXT_DeleteStrux: { const PX_ChangeRecord_Strux * pcrStrux = static_cast<const PX_ChangeRecord_Strux *>(pcr); + UT_Bool (pt_PieceTable::* pmUnlink)(pf_Frag_Strux * pfs, + pf_Frag ** ppfEnd, + UT_uint32 * pfragOffsetEnd); + pmUnlink = NULL; + switch (pcrStrux->getStruxType()) { case PTX_Block: - { - pf_Frag * pf = NULL; - PT_BlockOffset fragOffset = 0; - UT_Bool bFoundFrag = getFragFromPosition(pcrStrux->getPosition(),&pf,&fragOffset); - UT_ASSERT(bFoundFrag); - UT_ASSERT(pf->getType() == pf_Frag::PFT_Strux); - - pf_Frag_Strux * pfs = static_cast<pf_Frag_Strux *> (pf); -#ifndef PT_NOTIFY_BEFORE_DELETES - UT_Bool bResult = _unlinkStrux_Block(pfs,NULL,NULL); -#endif - m_pDocument->notifyListeners(pfs,pcr); -#ifdef PT_NOTIFY_BEFORE_DELETES - UT_Bool bResult = _unlinkStrux_Block(pfs,NULL,NULL); -#endif - UT_ASSERT(bResult); - DONE(); + pmUnlink = &_unlinkStrux_Block; + break; - delete pfs; - } + case PTX_Section: + pmUnlink = &_unlinkStrux_Section; break; default: @@ -233,6 +223,25 @@ UT_ASSERT(0); return UT_FALSE; } + + pf_Frag * pf = NULL; + PT_BlockOffset fragOffset = 0; + UT_Bool bFoundFrag = getFragFromPosition(pcrStrux->getPosition(),&pf,&fragOffset); + UT_ASSERT(bFoundFrag); + UT_ASSERT(pf->getType() == pf_Frag::PFT_Strux); + + pf_Frag_Strux * pfs = static_cast<pf_Frag_Strux *> (pf); +#ifndef PT_NOTIFY_BEFORE_DELETES + UT_Bool bResult = (this->*pmUnlink)(pfs,NULL,NULL); +#endif + m_pDocument->notifyListeners(pfs,pcr); +#ifdef PT_NOTIFY_BEFORE_DELETES + UT_Bool bResult = (this->*pmUnlink)(pfs,NULL,NULL); +#endif + UT_ASSERT(bResult); + DONE(); + + delete pfs; } return UT_TRUE;
--GvXjxJ+pjyke8COw--