diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-09-15 21:54:23 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-09-15 21:54:23 +0200 |
commit | 381a790066dba9d9e32196c36e31dd13402bbac4 (patch) | |
tree | 53c64abc47a954b2b0f31b1cbd23de633af0b7f4 /sw | |
parent | 5059efab2f982daf041701165d15587794ffbfc7 (diff) |
sw: remove some can-never-happen checks that are now assert()
Change-Id: I16cd7253b3c8e65bf9f400ace2aa93e47c8981e4
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/undo/docundo.cxx | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index 06a53f797b54..cc45eb82bed1 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -320,37 +320,34 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter) SfxListUndoAction *const pListAction( dynamic_cast<SfxListUndoAction*>(pUndoAction)); assert(pListAction); - if (pListAction) + if (UNDO_END != eUndoId) { - if (UNDO_END != eUndoId) + OSL_ENSURE(pListAction->GetId() == eUndoId, + "EndUndo(): given ID different from StartUndo()"); + // comment set by caller of EndUndo + OUString comment = SW_RES(UNDO_BASE + eUndoId); + if (pRewriter) { - OSL_ENSURE(pListAction->GetId() == eUndoId, - "EndUndo(): given ID different from StartUndo()"); - // comment set by caller of EndUndo - OUString comment = SW_RES(UNDO_BASE + eUndoId); - if (pRewriter) - { - comment = pRewriter->Apply(comment); - } - pListAction->SetComment(comment); - } - else if ((UNDO_START != pListAction->GetId())) - { - // comment set by caller of StartUndo: nothing to do here - } - else if (pLastUndo) - { - // comment was not set at StartUndo or EndUndo: - // take comment of last contained action - // (note that this works recursively, i.e. the last contained - // action may be a list action created by StartUndo/EndUndo) - OUString const comment(pLastUndo->GetComment()); - pListAction->SetComment(comment); - } - else - { - OSL_ENSURE(false, "EndUndo(): no comment?"); + comment = pRewriter->Apply(comment); } + pListAction->SetComment(comment); + } + else if ((UNDO_START != pListAction->GetId())) + { + // comment set by caller of StartUndo: nothing to do here + } + else if (pLastUndo) + { + // comment was not set at StartUndo or EndUndo: + // take comment of last contained action + // (note that this works recursively, i.e. the last contained + // action may be a list action created by StartUndo/EndUndo) + OUString const comment(pLastUndo->GetComment()); + pListAction->SetComment(comment); + } + else + { + OSL_ENSURE(false, "EndUndo(): no comment?"); } } @@ -646,7 +643,7 @@ bool UndoManager::Repeat(::sw::RepeatContext & rContext, } SfxUndoAction *const pRepeatAction(GetUndoAction()); assert(pRepeatAction); - if (!pRepeatAction || !pRepeatAction->CanRepeat(rContext)) + if (!pRepeatAction->CanRepeat(rContext)) { return false; } |