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

sw: deploy asserts in lcl_CheckRedline()

Change-Id: Ib5c5758eab44532b383ca49542288a65cb10d548
üst d60db240
...@@ -40,34 +40,26 @@ using namespace com::sun::star; ...@@ -40,34 +40,26 @@ using namespace com::sun::star;
{ {
// helper function for lcl_CheckRedline // helper function for lcl_CheckRedline
// 1. make sure that pPos->nContent points into pPos->nNode // 1. make sure that pPos->nContent points into pPos->nNode
// (or into the 'special' no-content-node-IndexReg)
// 2. check that position is valid and doesn't point after text // 2. check that position is valid and doesn't point after text
static void lcl_CheckPosition( const SwPosition* pPos ) static void lcl_CheckPosition( const SwPosition* pPos )
{ {
SwPosition aComparePos( *pPos ); assert(dynamic_cast<SwIndexReg*>(&pPos->nNode.GetNode())
aComparePos.nContent.Assign( == pPos->nContent.GetIdxReg());
aComparePos.nNode.GetNode().GetCntntNode(), 0 );
OSL_ENSURE( pPos->nContent.GetIdxReg() ==
aComparePos.nContent.GetIdxReg(),
_ERROR_PREFIX "illegal position" );
SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode(); SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
if( pTxtNode == NULL ) if( pTxtNode == NULL )
{ {
OSL_ENSURE( pPos->nContent == 0, assert(pPos->nContent == 0);
_ERROR_PREFIX "non-text-node with content" );
} }
else else
{ {
OSL_ENSURE( pPos->nContent >= 0 && assert(pPos->nContent >= 0 && pPos->nContent <= pTxtNode->Len());
pPos->nContent <= pTxtNode->Len(),
_ERROR_PREFIX "index after text" );
} }
} }
static void lcl_CheckPam( const SwPaM* pPam ) static void lcl_CheckPam( const SwPaM* pPam )
{ {
OSL_ENSURE( pPam != NULL, _ERROR_PREFIX "illegal argument" ); assert(pPam);
lcl_CheckPosition( pPam->GetPoint() ); lcl_CheckPosition( pPam->GetPoint() );
lcl_CheckPosition( pPam->GetMark() ); lcl_CheckPosition( pPam->GetMark() );
} }
......
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