summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml/xmltbli.cxx
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-11-03 15:10:04 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-03 16:00:36 +0100
commit4284f618557992fdf12574f8fd014be76ec9fffc (patch)
treefac74828b9a4139d1f74087443c3fcc0b8a1363f /sw/source/filter/xml/xmltbli.cxx
parentf575cf3320684efe7db9844da89a5ebdb3083498 (diff)
Simplify containers iterations in sw/source/filter
Use range-based loop or replace with STL functions. Change-Id: Ifffb7ba08b3a9950ee076558ec4048b0788a38c8 Reviewed-on: https://gerrit.libreoffice.org/62806 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/xml/xmltbli.cxx')
-rw-r--r--sw/source/filter/xml/xmltbli.cxx42
1 files changed, 23 insertions, 19 deletions
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 8517963383f8..2207d929a9c4 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -2378,20 +2378,20 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
sal_Int32 nRelWidth = 0;
sal_Int32 nMinRelColWidth = 0;
sal_uInt32 nRelCols = 0;
- for( colIter = m_aColumnWidths.begin(); colIter < m_aColumnWidths.end(); ++colIter)
+ for( const auto& rCol : m_aColumnWidths)
{
- if( colIter->isRelative )
+ if( rCol.isRelative )
{
- nRelWidth += colIter->width;
- if( 0 == nMinRelColWidth || colIter->width < nMinRelColWidth )
- nMinRelColWidth = colIter->width;
+ nRelWidth += rCol.width;
+ if( 0 == nMinRelColWidth || rCol.width < nMinRelColWidth )
+ nMinRelColWidth = rCol.width;
nRelCols++;
}
else
{
- nAbsWidth += colIter->width;
- if( 0 == nMinAbsColWidth || colIter->width < nMinAbsColWidth )
- nMinAbsColWidth = colIter->width;
+ nAbsWidth += rCol.width;
+ if( 0 == nMinAbsColWidth || rCol.width < nMinAbsColWidth )
+ nMinAbsColWidth = rCol.width;
}
}
sal_uInt32 nAbsCols = nCols - nRelCols;
@@ -2410,20 +2410,22 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
if( 0 == nMinRelColWidth )
nMinRelColWidth = nMinAbsColWidth;
- for( colIter = m_aColumnWidths.begin(); nAbsCols > 0 && colIter < m_aColumnWidths.end(); ++colIter)
+ for( auto& rCol : m_aColumnWidths)
{
- if( !colIter->isRelative )
+ if( !rCol.isRelative )
{
if (nMinAbsColWidth == 0)
throw o3tl::divide_by_zero();
sal_Int32 nVal;
- if (o3tl::checked_multiply<sal_Int32>(colIter->width, nMinRelColWidth, nVal))
+ if (o3tl::checked_multiply<sal_Int32>(rCol.width, nMinRelColWidth, nVal))
throw std::overflow_error("overflow in multiply");
sal_Int32 nRelCol = nVal / nMinAbsColWidth;
- colIter->width = nRelCol;
- colIter->isRelative = true;
+ rCol.width = nRelCol;
+ rCol.isRelative = true;
nRelWidth += nRelCol;
nAbsCols--;
+ if (nAbsCols <= 0)
+ break;
}
}
}
@@ -2494,9 +2496,9 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
// Otherwise, if there is enough space for every column, every
// column gets this space.
- for( colIter = m_aColumnWidths.begin(); nRelCols > 0 && colIter < m_aColumnWidths.end(); ++colIter )
+ for( auto& rCol : m_aColumnWidths )
{
- if( colIter->isRelative )
+ if( rCol.isRelative )
{
sal_Int32 nAbsCol;
if( 1 == nRelCols )
@@ -2513,20 +2515,22 @@ void SwXMLTableContext::MakeTable_( SwTableBox *pBox )
}
else if( bMinExtra )
{
- sal_Int32 nExtraRelCol = colIter->width - nMinRelColWidth;
+ sal_Int32 nExtraRelCol = rCol.width - nMinRelColWidth;
nAbsCol = MINLAY + (nExtraRelCol * nExtraAbs) /
nExtraRel;
}
else
{
- nAbsCol = ( colIter->width * nAbsForRelWidth) / nRelWidth;
+ nAbsCol = ( rCol.width * nAbsForRelWidth) / nRelWidth;
}
}
- colIter->width = nAbsCol;
- colIter->isRelative = false;
+ rCol.width = nAbsCol;
+ rCol.isRelative = false;
nAbsForRelWidth -= nAbsCol;
nAbsWidth += nAbsCol;
nRelCols--;
+ if (nRelCols <= 0)
+ break;
}
}
}