Kaydet (Commit) 358bd7bc authored tarafından Matteo Casalin's avatar Matteo Casalin

Use auto and range-based for loops

Change-Id: I400bce4479eb0ab8105384f88a379c3ea90b9f66
üst 9fbb74b5
......@@ -118,26 +118,23 @@ sal_uInt16 SwEditShell::GetSectionFmtCount() const
bool SwEditShell::IsAnySectionInDoc( bool bChkReadOnly, bool bChkHidden, bool bChkTOX ) const
{
const SwSectionFmts& rFmts = GetDoc()->GetSections();
sal_uInt16 nCnt = rFmts.size();
sal_uInt16 n;
for( n = 0; n < nCnt; ++n )
for( const SwSectionFmt* pFmt : rFmts )
{
SectionType eTmpType;
const SwSectionFmt* pFmt = rFmts[ n ];
if( pFmt->IsInNodesArr() &&
(bChkTOX ||
( (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
&& TOX_HEADER_SECTION != eTmpType ) ) )
{
const SwSection& rSect = *rFmts[ n ]->GetSection();
const SwSection& rSect = *pFmt->GetSection();
if( (!bChkReadOnly && !bChkHidden ) ||
(bChkReadOnly && rSect.IsProtectFlag() ) ||
(bChkHidden && rSect.IsHiddenFlag() ) )
break;
return true;
}
}
return n != nCnt;
return false;
}
sal_uInt16 SwEditShell::GetSectionFmtPos( const SwSectionFmt& rFmt ) const
......
......@@ -225,7 +225,7 @@ sal_uInt16 SwEditShell::GetTOXCount() const
{
const SwSectionFmts& rFmts = GetDoc()->GetSections();
sal_uInt16 nRet = 0;
for( sal_uInt16 n = rFmts.size(); n; )
for( auto n = rFmts.size(); n; )
{
const SwSection* pSect = rFmts[ --n ]->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
......@@ -238,9 +238,10 @@ sal_uInt16 SwEditShell::GetTOXCount() const
const SwTOXBase* SwEditShell::GetTOX( sal_uInt16 nPos ) const
{
const SwSectionFmts& rFmts = GetDoc()->GetSections();
for( sal_uInt16 n = 0, nCnt = 0; n < rFmts.size(); ++n )
sal_uInt16 nCnt {0};
for( const SwSectionFmt *pFmt : rFmts )
{
const SwSection* pSect = rFmts[ n ]->GetSection();
const SwSection* pSect = pFmt->GetSection();
if( TOX_CONTENT_SECTION == pSect->GetType() &&
pSect->GetFmt()->GetSectionNode() &&
nCnt++ == nPos )
......@@ -292,9 +293,8 @@ void SwEditShell::ApplyAutoMark()
SwTOXMarks aMarks;
SwTOXMark::InsertTOXMarks( aMarks, *pTOXType );
for( sal_uInt16 nMark=0; nMark<aMarks.size(); nMark++ )
for( SwTOXMark* pMark : aMarks )
{
SwTOXMark* pMark = aMarks[nMark];
if(pMark->IsAutoGenerated() && pMark->GetTxtTOXMark())
// mba: test iteration; objects are deleted in iteration
DeleteTOXMark(pMark);
......
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