Kaydet (Commit) b5dc7296 authored tarafından Michael Stahl's avatar Michael Stahl

sw: undobj.cxx: deploy some asserts

üst 13424b43
...@@ -235,19 +235,19 @@ private: ...@@ -235,19 +235,19 @@ private:
void SwUndo::Undo() void SwUndo::Undo()
{ {
OSL_ENSURE(false, "SwUndo::Undo(): ERROR: must call Undo(context) instead"); assert(false); // SwUndo::Undo(): ERROR: must call UndoWithContext instead
} }
void SwUndo::Redo() void SwUndo::Redo()
{ {
OSL_ENSURE(false, "SwUndo::Redo(): ERROR: must call Redo(context) instead"); assert(false); // SwUndo::Redo(): ERROR: must call RedoWithContext instead
} }
void SwUndo::UndoWithContext(SfxUndoContext & rContext) void SwUndo::UndoWithContext(SfxUndoContext & rContext)
{ {
::sw::UndoRedoContext *const pContext( ::sw::UndoRedoContext *const pContext(
dynamic_cast< ::sw::UndoRedoContext * >(& rContext)); dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
OSL_ASSERT(pContext); assert(pContext);
if (!pContext) { return; } if (!pContext) { return; }
UndoRedoRedlineGuard const g(*pContext, *this); UndoRedoRedlineGuard const g(*pContext, *this);
UndoImpl(*pContext); UndoImpl(*pContext);
...@@ -257,7 +257,7 @@ void SwUndo::RedoWithContext(SfxUndoContext & rContext) ...@@ -257,7 +257,7 @@ void SwUndo::RedoWithContext(SfxUndoContext & rContext)
{ {
::sw::UndoRedoContext *const pContext( ::sw::UndoRedoContext *const pContext(
dynamic_cast< ::sw::UndoRedoContext * >(& rContext)); dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
OSL_ASSERT(pContext); assert(pContext);
if (!pContext) { return; } if (!pContext) { return; }
UndoRedoRedlineGuard const g(*pContext, *this); UndoRedoRedlineGuard const g(*pContext, *this);
RedoImpl(*pContext); RedoImpl(*pContext);
...@@ -267,7 +267,7 @@ void SwUndo::Repeat(SfxRepeatTarget & rContext) ...@@ -267,7 +267,7 @@ void SwUndo::Repeat(SfxRepeatTarget & rContext)
{ {
::sw::RepeatContext *const pRepeatContext( ::sw::RepeatContext *const pRepeatContext(
dynamic_cast< ::sw::RepeatContext * >(& rContext)); dynamic_cast< ::sw::RepeatContext * >(& rContext));
OSL_ASSERT(pRepeatContext); assert(pRepeatContext);
if (!pRepeatContext) { return; } if (!pRepeatContext) { return; }
RepeatImpl(*pRepeatContext); RepeatImpl(*pRepeatContext);
} }
...@@ -276,7 +276,7 @@ sal_Bool SwUndo::CanRepeat(SfxRepeatTarget & rContext) const ...@@ -276,7 +276,7 @@ sal_Bool SwUndo::CanRepeat(SfxRepeatTarget & rContext) const
{ {
::sw::RepeatContext *const pRepeatContext( ::sw::RepeatContext *const pRepeatContext(
dynamic_cast< ::sw::RepeatContext * >(& rContext)); dynamic_cast< ::sw::RepeatContext * >(& rContext));
OSL_ASSERT(pRepeatContext); assert(pRepeatContext);
if (!pRepeatContext) { return false; } if (!pRepeatContext) { return false; }
return CanRepeatImpl(*pRepeatContext); return CanRepeatImpl(*pRepeatContext);
} }
...@@ -595,7 +595,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, ...@@ -595,7 +595,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark,
pHistory = new SwHistory; pHistory = new SwHistory;
SwTxtAttr* const pFtnHnt = SwTxtAttr* const pFtnHnt =
pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx );
OSL_ENSURE( pFtnHnt, "kein FtnAttribut" ); assert(pFtnHnt);
SwIndex aIdx( pTxtNd, nFtnSttIdx ); SwIndex aIdx( pTxtNd, nFtnSttIdx );
pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false );
pTxtNd->EraseText( aIdx, 1 ); pTxtNd->EraseText( aIdx, 1 );
...@@ -619,7 +619,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, ...@@ -619,7 +619,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark,
pHistory = new SwHistory; pHistory = new SwHistory;
SwTxtAttr* const pFtnHnt = SwTxtAttr* const pFtnHnt =
pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx );
OSL_ENSURE( pFtnHnt, "kein FtnAttribut" ); assert(pFtnHnt);
SwIndex aIdx( pTxtNd, nFtnSttIdx ); SwIndex aIdx( pTxtNd, nFtnSttIdx );
pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false );
pTxtNd->EraseText( aIdx, 1 ); pTxtNd->EraseText( aIdx, 1 );
...@@ -659,7 +659,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, ...@@ -659,7 +659,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark,
pAPos->nNode.GetNode().GetTxtNode(); pAPos->nNode.GetNode().GetTxtNode();
SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt( SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt(
pAPos->nContent.GetIndex()); pAPos->nContent.GetIndex());
OSL_ENSURE( pFlyHnt, "kein FlyAttribut" ); assert(pFlyHnt);
pHistory->Add( pFlyHnt, 0, false ); pHistory->Add( pFlyHnt, 0, false );
// n wieder zurueck, damit nicht ein Format uebesprungen wird ! // n wieder zurueck, damit nicht ein Format uebesprungen wird !
n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1; n = n >= rSpzArr.Count() ? rSpzArr.Count() : n+1;
...@@ -980,8 +980,8 @@ SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos, ...@@ -980,8 +980,8 @@ SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos,
: SwUndRng( rRedl ), : SwUndRng( rRedl ),
SwRedlineData( rRedl.GetRedlineData(), bCopyNext ) SwRedlineData( rRedl.GetRedlineData(), bCopyNext )
{ {
OSL_ENSURE( POS_OUTSIDE == eCmpPos || assert( POS_OUTSIDE == eCmpPos ||
!rRedl.GetContentIdx(), "Redline mit Content" ); !rRedl.GetContentIdx() ); // "Redline with Content"
switch( eCmpPos ) switch( eCmpPos )
{ {
...@@ -1014,7 +1014,7 @@ SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos, ...@@ -1014,7 +1014,7 @@ SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos,
break; break;
default: default:
OSL_ENSURE( !this, "keine gueltigen Daten!" ); assert(false);
} }
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
...@@ -1052,8 +1052,7 @@ void SwRedlineSaveData::RedlineToDoc( SwPaM& rPam ) ...@@ -1052,8 +1052,7 @@ void SwRedlineSaveData::RedlineToDoc( SwPaM& rPam )
rDoc.GetDocShell()->Broadcast(SwRedlineHint(pRedl,SWREDLINE_INSERTED)); rDoc.GetDocShell()->Broadcast(SwRedlineHint(pRedl,SWREDLINE_INSERTED));
// //
bool const bSuccess = rDoc.AppendRedline( pRedl, true ); bool const bSuccess = rDoc.AppendRedline( pRedl, true );
OSL_ENSURE(bSuccess, assert(bSuccess); // SwRedlineSaveData::RedlineToDoc: insert redline failed
"SwRedlineSaveData::RedlineToDoc: insert redline failed");
(void) bSuccess; // unused in non-debug (void) bSuccess; // unused in non-debug
rDoc.SetRedlineMode_intern( eOld ); rDoc.SetRedlineMode_intern( eOld );
} }
...@@ -1131,9 +1130,9 @@ void SwUndo::SetSaveData( SwDoc& rDoc, const SwRedlineSaveDatas& rSData ) ...@@ -1131,9 +1130,9 @@ void SwUndo::SetSaveData( SwDoc& rDoc, const SwRedlineSaveDatas& rSData )
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
// check redline count against count saved in RedlineSaveData object // check redline count against count saved in RedlineSaveData object
OSL_ENSURE( (rSData.Count() == 0) || assert((rSData.Count() == 0) ||
(rSData[0]->nRedlineCount == rDoc.GetRedlineTbl().Count()), (rSData[0]->nRedlineCount == rDoc.GetRedlineTbl().Count()));
"redline count not restored properly" ); // "redline count not restored properly"
#endif #endif
rDoc.SetRedlineMode_intern( eOld ); rDoc.SetRedlineMode_intern( eOld );
...@@ -1188,7 +1187,7 @@ sal_Bool SwUndo::CanRedlineGroup( SwRedlineSaveDatas& rCurr, ...@@ -1188,7 +1187,7 @@ sal_Bool SwUndo::CanRedlineGroup( SwRedlineSaveDatas& rCurr,
// #111827# // #111827#
String ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr) String ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr)
{ {
OSL_ENSURE( nLength - rFillStr.Len() >= 2, "improper arguments"); assert(nLength - rFillStr.Len() >= 2);
String aResult; String aResult;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment