summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-11-05 14:57:19 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-07 08:13:49 +0100
commitdb601f697acff89e216228f2d5828b1563e58aa0 (patch)
tree109c256e249cc270480c7130807699c51d8b75cf /sw/source/core/unocore
parent9476ecb71b1acc66506a768a5fe0c123afd46b93 (diff)
Simplify containers iterations in sw/source/core/[t-v]*
Use range-based loop or replace with STL functions Change-Id: Ib4a0da0c452dbfa00a1d7ec79f9570e41eda0d41 Reviewed-on: https://gerrit.libreoffice.org/62893 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/unocore')
-rw-r--r--sw/source/core/unocore/unochart.cxx25
-rw-r--r--sw/source/core/unocore/unoidx.cxx6
-rw-r--r--sw/source/core/unocore/unosrch.cxx15
-rw-r--r--sw/source/core/unocore/unostyle.cxx10
4 files changed, 19 insertions, 37 deletions
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index b12ddb64987e..87584578da2c 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -1396,11 +1396,9 @@ void SAL_CALL SwChartDataProvider::dispose( )
if (bMustDispose)
{
// dispose all data-sequences
- Map_Set_DataSequenceRef_t::iterator aIt( aDataSequences.begin() );
- while (aIt != aDataSequences.end())
+ for (auto& rEntry : aDataSequences)
{
- DisposeAllDataSequences( (*aIt).first );
- ++aIt;
+ DisposeAllDataSequences( rEntry.first );
}
// release all references to data-sequences
aDataSequences.clear();
@@ -1461,17 +1459,15 @@ void SwChartDataProvider::InvalidateTable( const SwTable *pTable )
pTable->GetFrameFormat()->GetDoc()->getIDocumentChartDataProviderAccess().GetChartControllerHelper().StartOrContinueLocking();
const Set_DataSequenceRef_t &rSet = aDataSequences[ pTable ];
- Set_DataSequenceRef_t::const_iterator aIt( rSet.begin() );
- while (aIt != rSet.end())
+ for (const auto& rItem : rSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
// mark the sequence as 'dirty' and notify listeners
xRef->setModified( true );
}
- ++aIt;
}
}
}
@@ -1545,17 +1541,14 @@ void SwChartDataProvider::DisposeAllDataSequences( const SwTable *pTable )
//! would become invalid.
const Set_DataSequenceRef_t aSet( aDataSequences[ pTable ] );
- Set_DataSequenceRef_t::const_iterator aIt( aSet.begin() );
- Set_DataSequenceRef_t::const_iterator aEndIt( aSet.end() );
- while (aIt != aEndIt)
+ for (const auto& rItem : aSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
xRef->dispose();
}
- ++aIt;
}
}
}
@@ -1619,10 +1612,9 @@ void SwChartDataProvider::AddRowCols(
// iterate over all data-sequences for the table
const Set_DataSequenceRef_t &rSet = aDataSequences[ &rTable ];
- Set_DataSequenceRef_t::const_iterator aIt( rSet.begin() );
- while (aIt != rSet.end())
+ for (const auto& rItem : rSet)
{
- uno::Reference< chart2::data::XDataSequence > xTemp(*aIt); // temporary needed for g++ 3.3.5
+ uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY );
if (xRef.is())
{
@@ -1658,7 +1650,6 @@ void SwChartDataProvider::AddRowCols(
}
}
}
- ++aIt;
}
}
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 9f2eae93fbed..ab2bae1d8aeb 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -2933,17 +2933,15 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex)
// #i21237#
SwFormTokens aPattern = rTOXBase.GetTOXForm().
GetPattern(static_cast<sal_uInt16>(nIndex));
- SwFormTokens::iterator aIt = aPattern.begin();
sal_Int32 nTokenCount = 0;
uno::Sequence< beans::PropertyValues > aRetSeq;
OUString aProgCharStyle;
- while(aIt != aPattern.end()) // #i21237#
+ for(const SwFormToken& aToken : aPattern) // #i21237#
{
nTokenCount++;
aRetSeq.realloc(nTokenCount);
beans::PropertyValues* pTokenProps = aRetSeq.getArray();
- SwFormToken aToken = *aIt; // #i21237#
uno::Sequence< beans::PropertyValue >& rCurTokenSeq =
pTokenProps[nTokenCount-1];
@@ -3157,8 +3155,6 @@ SwXDocumentIndex::TokenAccess_Impl::getByIndex(sal_Int32 nIndex)
default:
;
}
-
- ++aIt; // #i21237#
}
uno::Any aRet;
diff --git a/sw/source/core/unocore/unosrch.cxx b/sw/source/core/unocore/unosrch.cxx
index 62aaccb29819..87f342d231d2 100644
--- a/sw/source/core/unocore/unosrch.cxx
+++ b/sw/source/core/unocore/unosrch.cxx
@@ -80,15 +80,12 @@ void SwSearchProperties_Impl::SetProperties(const uno::Sequence< beans::Property
const sal_uInt32 nLen = aSearchAttribs.getLength();
for(sal_uInt32 i = 0; i < nLen; ++i)
{
- sal_uInt32 nIndex = 0;
- PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
- while(pProps[i].Name != aIt->sName)
- {
- ++aIt;
- nIndex++;
- if( aIt == aPropertyEntries.end() )
- throw beans::UnknownPropertyException();
- }
+ const OUString& sName = pProps[i].Name;
+ auto aIt = std::find_if(aPropertyEntries.begin(), aPropertyEntries.end(),
+ [&sName](const SfxItemPropertyNamedEntry& rProp) { return rProp.sName == sName; });
+ if( aIt == aPropertyEntries.end() )
+ throw beans::UnknownPropertyException();
+ auto nIndex = static_cast<sal_uInt32>(std::distance(aPropertyEntries.begin(), aIt));
pValueArr[nIndex].reset( new beans::PropertyValue(pProps[i]) );
}
}
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 35a3eaefda8c..55500a7eab90 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4249,17 +4249,15 @@ uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties()
// TODO: Optimize - and fix! the old iteration filled each WhichId
// only once but there are more properties than WhichIds
- PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
- while( aIt != aPropVector.end() )
+ for( const auto& rProp : aPropVector )
{
- if ( aIt->nWID == nWID )
+ if ( rProp.nWID == nWID )
{
beans::PropertyValue aPropertyValue;
- aPropertyValue.Name = aIt->sName;
- pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
+ aPropertyValue.Name = rProp.sName;
+ pItem->QueryValue( aPropertyValue.Value, rProp.nMemberId );
aPropertyVector.push_back( aPropertyValue );
}
- ++aIt;
}
pItem = aIter.NextItem();
}