diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-02-21 16:33:06 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-02-21 17:45:02 +0100 |
commit | 949b9dc8ed2f5cdfd6f99531fc4ac2b8c201b145 (patch) | |
tree | d18450554b7a6346ee75484a1b63c5da75dc5f5d /sw/source | |
parent | bf586debd4d8274cff2737f02beac465525328e8 (diff) |
Use more proper types and range-for loops
Change-Id: I90b71a5abbca19d9b5eaf2ded2f33b01fb775d3a
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/fmtcol.cxx | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index 5124ec43f8f9..4d9d28ec61ff 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -565,19 +565,16 @@ SwConditionTxtFmtColl::~SwConditionTxtFmtColl() const SwCollCondition* SwConditionTxtFmtColl::HasCondition( const SwCollCondition& rCond ) const { - const SwCollCondition* pFnd = 0; - sal_uInt16 n; + for( const auto &rFnd : aCondColls ) + if( rFnd == rCond ) + return &rFnd; - for( n = 0; n < aCondColls.size(); ++n ) - if( *( pFnd = &aCondColls[ n ]) == rCond ) - break; - - return n < aCondColls.size() ? pFnd : 0; + return nullptr; } void SwConditionTxtFmtColl::InsertCondition( const SwCollCondition& rCond ) { - for( sal_uInt16 n = 0; n < aCondColls.size(); ++n ) + for( SwFmtCollConditions::size_type n = 0; n < aCondColls.size(); ++n ) if( aCondColls[ n ] == rCond ) { aCondColls.erase( aCondColls.begin() + n ); @@ -592,7 +589,7 @@ void SwConditionTxtFmtColl::InsertCondition( const SwCollCondition& rCond ) bool SwConditionTxtFmtColl::RemoveCondition( const SwCollCondition& rCond ) { bool bRet = false; - for( sal_uInt16 n = 0; n < aCondColls.size(); ++n ) + for( SwFmtCollConditions::size_type n = 0; n < aCondColls.size(); ++n ) if( aCondColls[ n ] == rCond ) { aCondColls.erase( aCondColls.begin() + n ); @@ -607,19 +604,18 @@ void SwConditionTxtFmtColl::SetConditions( const SwFmtCollConditions& rCndClls ) // Copy the Conditions, but first delete the old ones aCondColls.clear(); SwDoc& rDoc = *GetDoc(); - for( sal_uInt16 n = 0; n < rCndClls.size(); ++n ) + for( const auto &rFnd : rCndClls ) { - const SwCollCondition* pFnd = &rCndClls[ n ]; - SwTxtFmtColl* pTmpColl = pFnd->GetTxtFmtColl() - ? rDoc.CopyTxtColl( *pFnd->GetTxtFmtColl() ) + SwTxtFmtColl* pTmpColl = rFnd.GetTxtFmtColl() + ? rDoc.CopyTxtColl( *rFnd.GetTxtFmtColl() ) : 0; SwCollCondition* pNew; - if( USRFLD_EXPRESSION & pFnd->GetCondition() ) - pNew = new SwCollCondition( pTmpColl, pFnd->GetCondition(), - *pFnd->GetFldExpression() ); + if( USRFLD_EXPRESSION & rFnd.GetCondition() ) + pNew = new SwCollCondition( pTmpColl, rFnd.GetCondition(), + *rFnd.GetFldExpression() ); else - pNew = new SwCollCondition( pTmpColl, pFnd->GetCondition(), - pFnd->GetSubCondition() ); + pNew = new SwCollCondition( pTmpColl, rFnd.GetCondition(), + rFnd.GetSubCondition() ); aCondColls.push_back( pNew ); } } |