summaryrefslogtreecommitdiff
path: root/toolkit/source/controls/grid
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-30 13:39:03 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-06-30 17:17:49 +0200
commit172a5e3306edbef3d40d9850c446dba00b7ada06 (patch)
treec0a18bb6138c1f0909386801abc4e5a2ba08b7d9 /toolkit/source/controls/grid
parentb2fe75d13e8cf7bf1deabfb232fd907f0894996e (diff)
Simplify Sequence iterations in toolkit
Use range-based loops or replace with STL functions Change-Id: I8129ca201dd7017fc4064b04834f41d69cc01274 Reviewed-on: https://gerrit.libreoffice.org/74926 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'toolkit/source/controls/grid')
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index 892685fd74f9..ae08e1da9a6a 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -243,8 +243,11 @@ private:
// create new data row
RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() );
RowData::iterator cellData = newRow.begin();
- for ( const Any* pData = i_rowData.begin(); pData != i_rowData.end(); ++pData, ++cellData )
- cellData->first = *pData;
+ for ( const Any& rData : i_rowData )
+ {
+ cellData->first = rData;
+ ++cellData;
+ }
// insert data row
m_aData.insert( m_aData.begin() + i_position, newRow );
@@ -301,10 +304,9 @@ private:
return;
// determine max col count in the new data
- sal_Int32 maxColCount = 0;
- for ( sal_Int32 row=0; row<rowCount; ++row )
- if ( i_data[row].getLength() > maxColCount )
- maxColCount = i_data[row].getLength();
+ auto pData = std::max_element(i_data.begin(), i_data.end(),
+ [](const Sequence< Any >& a, const Sequence< Any >& b) { return a.getLength() < b.getLength(); });
+ sal_Int32 maxColCount = pData->getLength();
if ( maxColCount < m_nColumnCount )
maxColCount = m_nColumnCount;
@@ -386,9 +388,9 @@ private:
if ( columnCount == 0 )
return;
- for ( sal_Int32 col = 0; col < columnCount; ++col )
+ for ( sal_Int32 const columnIndex : i_columnIndexes )
{
- if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) )
+ if ( ( columnIndex < 0 ) || ( columnIndex > m_nColumnCount ) )
throw IndexOutOfBoundsException( OUString(), *this );
}