summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-03-10 21:51:45 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-12 16:10:01 +0100
commit95a538180fd21c52b752cbef46acf2aa2b842ab8 (patch)
tree6b248190da44e68400fbd663dbb17d5fd6c4223d /chart2
parentf9b354784faf65ecc8024cf6d7d7aaf589f6d91f (diff)
Simplify containers iterations in chart2, cli_ure, comphelper, configmgr
Use range-based loop or replace with STL functions Change-Id: I7c229faa96e08b76cb4f182a1bd77c15bac4ba76 Reviewed-on: https://gerrit.libreoffice.org/69010 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ElementSelector.cxx25
-rw-r--r--chart2/source/tools/ObjectIdentifier.cxx13
-rw-r--r--chart2/source/view/axes/VCartesianAxis.cxx14
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx6
4 files changed, 26 insertions, 32 deletions
diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx
index d868365a19c1..03ae95147c27 100644
--- a/chart2/source/controller/main/ElementSelector.cxx
+++ b/chart2/source/controller/main/ElementSelector.cxx
@@ -107,26 +107,23 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
ObjectHierarchy aHierarchy( xChartDoc, pExplicitValueProvider, true /*bFlattenDiagram*/, true /*bOrderingForElementSelector*/ );
lcl_addObjectsToList( aHierarchy, ::chart::ObjectHierarchy::getRootNodeOID(), m_aEntries, 0, xChartDoc );
- std::vector< ListBoxEntryData >::iterator aIt( m_aEntries.begin() );
if( bAddSelectionToList )
{
if ( aSelectedOID.isAutoGeneratedObject() )
{
OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) );
- for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt )
+ std::vector< ListBoxEntryData >::iterator aIt = std::find_if(m_aEntries.begin(), m_aEntries.end(),
+ [&aSeriesCID](const ListBoxEntryData& rEntry) { return rEntry.OID.getObjectCID().match(aSeriesCID); });
+ if (aIt != m_aEntries.end())
{
- if( aIt->OID.getObjectCID().match( aSeriesCID ) )
- {
- ListBoxEntryData aEntry;
- aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
- aEntry.OID = aSelectedOID;
- ++aIt;
- if( aIt != m_aEntries.end() )
- m_aEntries.insert(aIt, aEntry);
- else
- m_aEntries.push_back( aEntry );
- break;
- }
+ ListBoxEntryData aEntry;
+ aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc );
+ aEntry.OID = aSelectedOID;
+ ++aIt;
+ if( aIt != m_aEntries.end() )
+ m_aEntries.insert(aIt, aEntry);
+ else
+ m_aEntries.push_back( aEntry );
}
}
else if ( aSelectedOID.isAdditionalShape() )
diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx
index 256be65e535f..40c7380d3c23 100644
--- a/chart2/source/tools/ObjectIdentifier.cxx
+++ b/chart2/source/tools/ObjectIdentifier.cxx
@@ -1436,15 +1436,10 @@ TitleHelper::eTitleType ObjectIdentifier::getTitleTypeForCID( const OUString& rC
OUString aParentParticle = ObjectIdentifier::getFullParentParticle( rCID );
const tTitleMap& rMap = lcl_getTitleMap();
- tTitleMap::const_iterator aIt( rMap.begin() );
- for( ;aIt != rMap.end(); ++aIt )
- {
- if( aParentParticle == (*aIt).second )
- {
- eRet = (*aIt).first;
- break;
- }
- }
+ tTitleMap::const_iterator aIt = std::find_if(rMap.begin(), rMap.end(),
+ [&aParentParticle](tTitleMap::const_reference rEntry) { return aParentParticle == rEntry.second; });
+ if (aIt != rMap.end())
+ eRet = (*aIt).first;
return eRet;
}
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx
index a83139719545..234e1000140a 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -1844,12 +1844,16 @@ void VCartesianAxis::createShapes()
if (rAllTickInfos.empty())
return;
- TickInfoArraysType::iterator aDepthIter = rAllTickInfos.begin();
- const TickInfoArraysType::const_iterator aDepthEnd = rAllTickInfos.end();
-
+ sal_Int32 nDepth = 0;
sal_Int32 nTickmarkPropertiesCount = m_aAxisProperties.m_aTickmarkPropertiesList.size();
- for( sal_Int32 nDepth=0; aDepthIter != aDepthEnd && nDepth < nTickmarkPropertiesCount; ++aDepthIter, nDepth++ )
- createTickMarkLineShapes( *aDepthIter, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ );
+ for( auto& rTickInfos : rAllTickInfos )
+ {
+ if (nDepth == nTickmarkPropertiesCount)
+ break;
+
+ createTickMarkLineShapes( rTickInfos, m_aAxisProperties.m_aTickmarkPropertiesList[nDepth], *pTickFactory2D, false /*bOnlyAtLabels*/ );
+ nDepth++;
+ }
}
//create axis main lines
//it serves also as the handle shape for the axis selection
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index d15bb92f8075..c7de326f0d8d 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -1453,10 +1453,8 @@ long VSeriesPlotter::calculateTimeResolutionOnXAxis()
if( !rDateCategories.empty() )
{
std::vector< double >::const_iterator aIt = rDateCategories.begin(), aEnd = rDateCategories.end();
- while (rtl::math::isNan(*aIt) && aIt != aEnd)
- {
- ++aIt;
- }
+ aIt = std::find_if(aIt, aEnd, [](const double& rDateCategory) { return !rtl::math::isNan(rDateCategory); });
+
Date aPrevious(aNullDate); aPrevious.AddDays(rtl::math::approxFloor(*aIt));
++aIt;
for(;aIt!=aEnd;++aIt)