[Libreoffice-commits] core.git: xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 25 06:55:35 UTC 2018


 xmloff/source/chart/MultiPropertySetHandler.hxx             |   12 -
 xmloff/source/chart/PropertyMaps.cxx                        |   12 -
 xmloff/source/chart/SchXMLAutoStylePoolP.cxx                |   13 -
 xmloff/source/chart/SchXMLExport.cxx                        |   95 +++++-------
 xmloff/source/chart/SchXMLSeriesHelper.cxx                  |    8 -
 xmloff/source/chart/SchXMLTableContext.cxx                  |   61 +++----
 xmloff/source/chart/SchXMLTools.cxx                         |   13 -
 xmloff/source/core/attrlist.cxx                             |   36 +---
 xmloff/source/core/fasttokenhandler.cxx                     |    6 
 xmloff/source/core/nmspmap.cxx                              |   16 --
 xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx |   14 -
 xmloff/source/core/xmlerror.cxx                             |    6 
 xmloff/source/draw/XMLShapeStyleContext.cxx                 |    8 -
 xmloff/source/draw/animexp.cxx                              |   12 -
 xmloff/source/draw/sdpropls.cxx                             |   12 -
 xmloff/source/draw/sdxmlexp.cxx                             |   65 +++-----
 xmloff/source/draw/shapeexport.cxx                          |   21 --
 xmloff/source/draw/shapeimport.cxx                          |    9 -
 xmloff/source/draw/ximpcustomshape.cxx                      |   26 +--
 xmloff/source/draw/ximpshap.cxx                             |   12 -
 xmloff/source/draw/ximpstyl.cxx                             |   28 +--
 21 files changed, 191 insertions(+), 294 deletions(-)

New commits:
commit daf44342ca82c5b0e79da88b7f9dbf28f6d43a8b
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Wed Sep 19 08:25:34 2018 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Sep 25 08:55:12 2018 +0200

    Simplify containers iterations in xmloff/source/[c-d]*
    
    Use range-based loop or replace with STL functions.
    
    Change-Id: I2af2d739d55a0bf480bb6e9d57b49dd16806af30
    Reviewed-on: https://gerrit.libreoffice.org/60734
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/source/chart/MultiPropertySetHandler.hxx b/xmloff/source/chart/MultiPropertySetHandler.hxx
index 5b70383ea6ab..85391f89e071 100644
--- a/xmloff/source/chart/MultiPropertySetHandler.hxx
+++ b/xmloff/source/chart/MultiPropertySetHandler.hxx
@@ -186,8 +186,8 @@ bool    MultiPropertySetHandler::GetProperties()
 {
     css::uno::Sequence< OUString> aNameList (aPropertyList.size());
     int i = 0;
-    for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
-        aNameList[i++] = I->second->msName;
+    for (const auto& rProperty : aPropertyList)
+        aNameList[i++] = rProperty.second->msName;
     if ( ! MultiGet(aNameList))
         if ( ! SingleGet(aNameList))
             return false;
@@ -205,8 +205,8 @@ bool    MultiPropertySetHandler::MultiGet   (const css::uno::Sequence<
             int i = 0;
             css::uno::Sequence< css::uno::Any> aValueList =
                 xMultiSet->getPropertyValues (rNameList);
-            for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
-                I->second->SetValue (aValueList[i++]);
+            for (auto& rProperty : aPropertyList)
+                rProperty.second->SetValue (aValueList[i++]);
         }
         catch (const css::beans::UnknownPropertyException&)
         {
@@ -227,8 +227,8 @@ bool    MultiPropertySetHandler::SingleGet  (const css::uno::Sequence<
         try
         {
             int i = 0;
-            for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I)
-                I->second->SetValue (xSingleSet->getPropertyValue (rNameList[i++]));
+            for (auto& rProperty : aPropertyList)
+                rProperty.second->SetValue (xSingleSet->getPropertyValue (rNameList[i++]));
         }
         catch (const css::beans::UnknownPropertyException&)
         {
diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx
index a2145ae6bcc2..fcef31d05036 100644
--- a/xmloff/source/chart/PropertyMaps.cxx
+++ b/xmloff/source/chart/PropertyMaps.cxx
@@ -207,13 +207,11 @@ void XMLChartExportPropertyMapper::ContextFilter(
     bool bCheckAuto = false;
 
     // filter properties
-    for( std::vector< XMLPropertyState >::iterator property = rProperties.begin();
-         property != rProperties.end();
-         ++property )
+    for( auto& rProperty : rProperties )
     {
         // find properties with context
         // to prevent writing this property set mnIndex member to -1
-        switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ))
+        switch( getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex ))
         {
             // if Auto... is set the corresponding properties mustn't be exported
             case XML_SCH_CONTEXT_MIN:
@@ -241,7 +239,7 @@ void XMLChartExportPropertyMapper::ContextFilter(
             // the following property is deprecated
             // element-item symbol-image is used now
             case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE_NAME:
-                property->mnIndex = -1;
+                rProperty.mnIndex = -1;
                 break;
 
             case XML_SCH_CONTEXT_STOCK_WITH_VOLUME:
@@ -251,7 +249,7 @@ void XMLChartExportPropertyMapper::ContextFilter(
                 // because there, the transformation to OOo is done after the
                 // complete export of the chart in OASIS format.
                 if( mrExport.getExportFlags() & SvXMLExportFlags::OASIS )
-                    property->mnIndex = -1;
+                    rProperty.mnIndex = -1;
                 break;
         }
 
@@ -265,7 +263,7 @@ void XMLChartExportPropertyMapper::ContextFilter(
                     uno::Any aAny = rPropSet->getPropertyValue( aAutoPropName );
                     aAny >>= bAuto;
                     if( bAuto )
-                        property->mnIndex = -1;
+                        rProperty.mnIndex = -1;
                 }
                 catch(const beans::UnknownPropertyException&)
                 {
diff --git a/xmloff/source/chart/SchXMLAutoStylePoolP.cxx b/xmloff/source/chart/SchXMLAutoStylePoolP.cxx
index 087e890b4826..ee5081c489ab 100644
--- a/xmloff/source/chart/SchXMLAutoStylePoolP.cxx
+++ b/xmloff/source/chart/SchXMLAutoStylePoolP.cxx
@@ -48,27 +48,26 @@ void SchXMLAutoStylePoolP::exportStyleAttributes(
 
     if( nFamily == XML_STYLE_FAMILY_SCH_CHART_ID )
     {
-        for( ::std::vector< XMLPropertyState >::const_iterator iter = rProperties.begin();
-             (iter != rProperties.end()); ++iter )
+        for( const auto& rProp : rProperties )
         {
-            if( iter->mnIndex == -1 )
+            if( rProp.mnIndex == -1 )
                 continue;
 
             rtl::Reference< XMLPropertySetMapper > aPropMapper =
                 mrSchXMLExport.GetPropertySetMapper();
-            sal_Int16 nContextID = aPropMapper->GetEntryContextId( iter->mnIndex );
+            sal_Int16 nContextID = aPropMapper->GetEntryContextId( rProp.mnIndex );
             if( nContextID == XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT )
             {
                 sal_Int32 nNumberFormat = -1;
-                if( ( iter->maValue >>= nNumberFormat ) &&
+                if( ( rProp.maValue >>= nNumberFormat ) &&
                     ( nNumberFormat != -1 ))
                 {
                     OUString sAttrValue = mrSchXMLExport.getDataStyleName( nNumberFormat );
                     if( !sAttrValue.isEmpty() )
                     {
                         mrSchXMLExport.AddAttribute(
-                            aPropMapper->GetEntryNameSpace( iter->mnIndex ),
-                            aPropMapper->GetEntryXMLName( iter->mnIndex ),
+                            aPropMapper->GetEntryNameSpace( rProp.mnIndex ),
+                            aPropMapper->GetEntryXMLName( rProp.mnIndex ),
                             sAttrValue );
                     }
                 }
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 49a18503c2ab..0fe3f44b9d8e 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -378,10 +378,9 @@ Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequ
     {
         Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
         ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
-        for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
-            ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt )
+        for( const auto& rSeries : aSeriesVector )
         {
-            Reference< chart2::data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY );
+            Reference< chart2::data::XDataSource > xDataSource( rSeries, uno::UNO_QUERY );
             if( !xDataSource.is() )
                 continue;
             uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() );
@@ -555,12 +554,11 @@ sal_Int32 lcl_getMaxSequenceLength(
     const SchXMLExportHelper_Impl::tDataSequenceCont & rContainer )
 {
     sal_Int32 nResult = 0;
-    for( SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( rContainer.begin());
-         aIt != rContainer.end(); ++aIt )
+    for( const auto& rDataSequence : rContainer )
     {
-        if( aIt->second.is())
+        if( rDataSequence.second.is())
         {
-            sal_Int32 nSeqLength = aIt->second->getData().getLength();
+            sal_Int32 nSeqLength = rDataSequence.second->getData().getLength();
             if( nSeqLength > nResult )
                 nResult = nSeqLength;
         }
@@ -733,20 +731,22 @@ void lcl_ReorderInternalSequencesAccordingToTheirRangeName(
 
     rInOutSequences.clear();
     sal_Int32 nIndex = 0;
-    for( lcl_DataSequenceMap::const_iterator aIt = aIndexSequenceMap.begin();
-         aIt != aIndexSequenceMap.end(); ++aIt, ++nIndex )
+    for( const auto& rEntry : aIndexSequenceMap )
     {
-        if( aIt->first < 0 )
-            continue;
-        // fill empty columns
-        rInOutSequences.insert(
-                rInOutSequences.end(),
-                aIt->first - nIndex,
-                SchXMLExportHelper_Impl::tDataSequenceCont::value_type(
-                    uno::Reference< chart2::data::XDataSequence >(),
-                    uno::Reference< chart2::data::XDataSequence >() ));
-        nIndex = aIt->first;
-        rInOutSequences.push_back( aIt->second );
+        if( rEntry.first >= 0 )
+        {
+            // fill empty columns
+            rInOutSequences.insert(
+                    rInOutSequences.end(),
+                    rEntry.first - nIndex,
+                    SchXMLExportHelper_Impl::tDataSequenceCont::value_type(
+                        uno::Reference< chart2::data::XDataSequence >(),
+                        uno::Reference< chart2::data::XDataSequence >() ));
+            nIndex = rEntry.first;
+            rInOutSequences.push_back( rEntry.second );
+        }
+
+        ++nIndex;
     }
 }
 
@@ -779,9 +779,6 @@ lcl_TableData lcl_getDataForLocalTable(
 
         //series values and series labels
         SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size();
-        SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin());
-        SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end());
-        SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aIt( aBegin );
 
         auto nMaxSequenceLength( lcl_getMaxSequenceLength( aSequencesToExport ));
         if( aSimpleCategories.getLength() > nMaxSequenceLength )
@@ -822,30 +819,30 @@ lcl_TableData lcl_getDataForLocalTable(
         // iterate over all sequences
         size_t nSeqIdx = 0;
         Sequence< Sequence< OUString > > aComplexLabels(nNumSequences);
-        for( ; aIt != aEnd; ++aIt, ++nSeqIdx )
+        for( const auto& rDataSequence : aSequencesToExport )
         {
             OUString aRange;
             Sequence< OUString >& rCurrentComplexLabel = aComplexLabels[nSeqIdx];
-            if( aIt->first.is())
+            if( rDataSequence.first.is())
             {
-                lcl_getLabelStringSequence( rCurrentComplexLabel, aIt->first );
+                lcl_getLabelStringSequence( rCurrentComplexLabel, rDataSequence.first );
                 rLabels[nSeqIdx] = lcl_flattenStringSequence( rCurrentComplexLabel );
-                aRange = aIt->first->getSourceRangeRepresentation();
+                aRange = rDataSequence.first->getSourceRangeRepresentation();
                 if( xRangeConversion.is())
                     aRange = xRangeConversion->convertRangeToXML( aRange );
             }
-            else if( aIt->second.is())
+            else if( rDataSequence.second.is())
             {
                 rCurrentComplexLabel.realloc(1);
                 rLabels[nSeqIdx] = rCurrentComplexLabel[0] = lcl_flattenStringSequence(
-                    aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE ));
+                    rDataSequence.second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE ));
             }
             if( bSeriesFromColumns )
                 aResult.aColumnDescriptions_Ranges.push_back( aRange );
             else
                 aResult.aRowDescriptions_Ranges.push_back( aRange );
 
-            ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( aIt->second ));
+            ::std::vector< double > aNumbers( lcl_getAllValuesFromSequence( rDataSequence.second ));
             if( bSeriesFromColumns )
             {
                 const sal_Int32 nSize( static_cast< sal_Int32 >( aNumbers.size()));
@@ -855,17 +852,19 @@ lcl_TableData lcl_getDataForLocalTable(
             else
                 aResult.aDataInRows[nSeqIdx] = aNumbers;
 
-            if( aIt->second.is())
+            if( rDataSequence.second.is())
             {
-                aRange =  aIt->second->getSourceRangeRepresentation();
+                aRange =  rDataSequence.second->getSourceRangeRepresentation();
                 if( xRangeConversion.is())
                     aRange = xRangeConversion->convertRangeToXML( aRange );
             }
             aResult.aDataRangeRepresentations.push_back( aRange );
 
             //is column hidden?
-            if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) )
+            if( !lcl_SequenceHasUnhiddenData(rDataSequence.first) && !lcl_SequenceHasUnhiddenData(rDataSequence.second) )
                 aResult.aHiddenColumns.push_back(nSeqIdx);
+
+            ++nSeqIdx;
         }
         Sequence< Sequence< Any > >& rComplexAnyLabels = bSeriesFromColumns ? aResult.aComplexColumnDescriptions : aResult.aComplexRowDescriptions;//#i116544#
         rComplexAnyLabels.realloc(aComplexLabels.getLength());
@@ -1633,9 +1632,7 @@ void SchXMLExportHelper_Impl::exportTable()
         const Sequence< Sequence< uno::Any > >& rComplexColumnDescriptions = aData.aComplexColumnDescriptions;
         sal_Int32 nComplexCount = rComplexColumnDescriptions.getLength();
         sal_Int32 nC = 0;
-        for( tStringVector::const_iterator aIt( aData.aColumnDescriptions.begin())
-             ; (aIt != aData.aColumnDescriptions.end())
-             ; ++aIt, nC++ )
+        for( const auto& rDesc : aData.aColumnDescriptions )
         {
             bool bExportString = true;
             if( nC < nComplexCount )
@@ -1662,7 +1659,7 @@ void SchXMLExportHelper_Impl::exportTable()
             }
 
             SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true );
-            exportText( *aIt );
+            exportText( rDesc );
             if( nC < nComplexCount )
                 lcl_exportComplexLabel( rComplexColumnDescriptions[nC], mrExport );
             if( !bHasOwnData && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd )
@@ -1672,6 +1669,8 @@ void SchXMLExportHelper_Impl::exportTable()
                     SchXMLTools::exportRangeToSomewhere( mrExport, *aColumnDescriptions_RangeIter );
                 ++aColumnDescriptions_RangeIter;
             }
+
+            nC++;
         }
         SAL_WARN_IF( !bHasOwnData && (aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd), "xmloff.chart", "bHasOwnData == false && aColumnDescriptions_RangeIter != aColumnDescriptions_RangeEnd" );
     } // closing row and header-rows elements
@@ -1684,9 +1683,7 @@ void SchXMLExportHelper_Impl::exportTable()
         sal_Int32 nComplexCount = rComplexRowDescriptions.getLength();
         sal_Int32 nC = 0;
 
-        for( t2DNumberContainer::const_iterator aRowIt( aData.aDataInRows.begin())
-            ; aRowIt != aData.aDataInRows.end()
-            ; ++aRowIt, ++nC )
+        for( const auto& rRow : aData.aDataInRows )
         {
             SvXMLElementExport aRow( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true );
 
@@ -1732,8 +1729,8 @@ void SchXMLExportHelper_Impl::exportTable()
             }
 
             //export row values
-            for( t2DNumberContainer::value_type::const_iterator aColIt( aRowIt->begin());
-                 aColIt != aRowIt->end(); ++aColIt )
+            for( t2DNumberContainer::value_type::const_iterator aColIt( rRow.begin());
+                 aColIt != rRow.end(); ++aColIt )
             {
                 ::sax::Converter::convertDouble( msStringBuffer, *aColIt );
                 msString = msStringBuffer.makeStringAndClear();
@@ -1742,7 +1739,7 @@ void SchXMLExportHelper_Impl::exportTable()
                 SvXMLElementExport aCell( mrExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true );
                 exportText( msString ); // do not convert tabs and lfs
                 if( ( !bHasOwnData && aDataRangeIter != aDataRangeEndIter ) &&
-                    ( mbRowSourceColumns || (aColIt == aRowIt->begin()) ) )
+                    ( mbRowSourceColumns || (aColIt == rRow.begin()) ) )
                 {
                     // remind the original range to allow a correct re-association when copying via clipboard
                     if (!(*aDataRangeIter).isEmpty())
@@ -1750,6 +1747,8 @@ void SchXMLExportHelper_Impl::exportTable()
                     ++aDataRangeIter;
                 }
             }
+
+            ++nC;
         }
     }
 
@@ -3050,11 +3049,10 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe
                 // register data ranges for error bars for export in local table
                 ::std::vector< Reference< chart2::data::XDataSequence > > aErrorBarSequences(
                     lcl_getErrorBarSequences( xErrorBarProp ));
-                for( ::std::vector< Reference< chart2::data::XDataSequence > >::const_iterator aIt(
-                         aErrorBarSequences.begin()); aIt != aErrorBarSequences.end(); ++aIt )
+                for( const auto& rErrorBarSequence : aErrorBarSequences )
                 {
                     m_aDataSequencesToExport.emplace_back(
-                        uno::Reference< chart2::data::XDataSequence >(), *aIt );
+                        uno::Reference< chart2::data::XDataSequence >(), rErrorBarSequence );
                 }
             }
 
@@ -3384,7 +3382,6 @@ void SchXMLExportHelper_Impl::exportDataPoints(
         return;
 
     // write elements (merge equal ones)
-    ::std::vector< SchXMLDataPointStruct >::iterator aIter = aDataPointVector.begin();
     SchXMLDataPointStruct aPoint;
     SchXMLDataPointStruct aLastPoint;
 
@@ -3392,9 +3389,9 @@ void SchXMLExportHelper_Impl::exportDataPoints(
     // the element is counted in the first iteration
     aLastPoint.mnRepeat = 0;
 
-    for( ; aIter != aDataPointVector.end(); ++aIter )
+    for( const auto& rPoint : aDataPointVector )
     {
-        aPoint = (*aIter);
+        aPoint = rPoint;
 
         if( aPoint.maStyleName == aLastPoint.maStyleName )
             aPoint.mnRepeat += aLastPoint.mnRepeat;
diff --git a/xmloff/source/chart/SchXMLSeriesHelper.cxx b/xmloff/source/chart/SchXMLSeriesHelper.cxx
index 5966a44391e6..c4764a856f89 100644
--- a/xmloff/source/chart/SchXMLSeriesHelper.cxx
+++ b/xmloff/source/chart/SchXMLSeriesHelper.cxx
@@ -77,17 +77,15 @@ using ::com::sun::star::uno::Sequence;
     sal_Int32 nIndex=0;
 
     ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram ));
-    const ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesEnd( aSeriesVector.end() );
-    for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() )
-        ; aSeriesIt != aSeriesEnd
-        ; ++aSeriesIt, nIndex++ )
+    for( const auto& rSeries : aSeriesVector )
     {
-        Reference< chart2::XDataSeries > xSeries( *aSeriesIt );
+        Reference< chart2::XDataSeries > xSeries( rSeries );
         if( xSeries.is() )
         {
             if( aRet.end() == aRet.find(xSeries) )
                 aRet[xSeries]=nIndex;
         }
+        nIndex++;
     }
     return aRet;
 }
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index ad38d26f9081..35218c5325f0 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -304,14 +304,13 @@ void SchXMLTableContext::EndElement()
             return;
 
         // permute the values of all rows according to aPermutation
-        for( ::std::vector< ::std::vector< SchXMLCell > >::iterator aRowIt( mrTable.aData.begin());
-             aRowIt != mrTable.aData.end(); ++aRowIt )
+        for( auto& rRow : mrTable.aData )
         {
             bool bModified = false;
             ::std::vector< SchXMLCell > aModifiedRow;
             const size_t nPermSize = aPermutation.size();
             SAL_WARN_IF( static_cast< sal_Int32 >( nPermSize ) - 1 != *(::std::max_element( aPermutation.begin(), aPermutation.end())), "xmloff.chart", "nPermSize - 1 != *(::std::max_element( aPermutation.begin(), aPermutation.end())");
-            const size_t nRowSize = aRowIt->size();
+            const size_t nRowSize = rRow.size();
             const size_t nDestSize = ::std::min( nPermSize, nRowSize );
             for( size_t nDestinationIndex = 0; nDestinationIndex < nDestSize; ++nDestinationIndex )
             {
@@ -323,18 +322,18 @@ void SchXMLTableContext::EndElement()
                     if( !bModified )
                     {
                         SAL_WARN_IF( !aModifiedRow.empty(), "xmloff.chart", "aModifiedRow is NOT NULL");
-                        aModifiedRow.reserve( aRowIt->size());
-                        ::std::copy( aRowIt->begin(), aRowIt->end(), ::std::back_inserter( aModifiedRow ));
+                        aModifiedRow.reserve( rRow.size());
+                        ::std::copy( rRow.begin(), rRow.end(), ::std::back_inserter( aModifiedRow ));
                         SAL_WARN_IF( aModifiedRow.empty(), "xmloff.chart", "aModifiedRow is NULL");
                     }
                     SAL_WARN_IF( nDestinationIndex >= aModifiedRow.size(), "xmloff.chart", "nDestinationIndex >= aModifiedRow.size()");
-                    aModifiedRow[ nDestinationIndex ] = (*aRowIt)[ nSourceIndex ];
+                    aModifiedRow[ nDestinationIndex ] = rRow[ nSourceIndex ];
                     bModified = true;
                 }
             }
             // copy back
             if( bModified )
-                ::std::copy( aModifiedRow.begin(), aModifiedRow.end(), aRowIt->begin());
+                ::std::copy( aModifiedRow.begin(), aModifiedRow.end(), rRow.begin());
         }
     }
     else if( mbHasRowPermutation )
@@ -851,16 +850,15 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
 
     bool bCategoriesApplied = false;
     // translate ranges (using the map created before)
-    for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin());
-         aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+    for( const auto& rLSeq : rLSequencesPerIndex )
     {
-        if( aLSeqIt->second.is())
+        if( rLSeq.second.is())
         {
             // values/error bars/categories
-            if( aLSeqIt->first.second == SCH_XML_PART_VALUES ||
-                aLSeqIt->first.second == SCH_XML_PART_ERROR_BARS )
+            if( rLSeq.first.second == SCH_XML_PART_VALUES ||
+                rLSeq.first.second == SCH_XML_PART_ERROR_BARS )
             {
-                Reference< chart2::data::XDataSequence > xSeq( aLSeqIt->second->getValues());
+                Reference< chart2::data::XDataSequence > xSeq( rLSeq.second->getValues());
 
                 OUString aRange;
                 if( xSeq.is() &&
@@ -873,46 +871,46 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                     {
                         SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
                                             Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
-                        aLSeqIt->second->setValues( xNewSeq );
+                        rLSeq.second->setValues( xNewSeq );
                     }
                 }
                 else
                 {
                     if( lcl_tableOfRangeMatches( aRange, rTable.aTableNameOfFile ))
                     {
-                        if( aLSeqIt->first.first == SCH_XML_CATEGORIES_INDEX )
+                        if( rLSeq.first.first == SCH_XML_CATEGORIES_INDEX )
                             bCategoriesApplied = true;
                     }
                     else
                     {
-                        if( aLSeqIt->first.first == SCH_XML_CATEGORIES_INDEX )
+                        if( rLSeq.first.first == SCH_XML_CATEGORIES_INDEX )
                         {
-                            Reference< beans::XPropertySet > xOldSequenceProp( aLSeqIt->second->getValues(), uno::UNO_QUERY );
+                            Reference< beans::XPropertySet > xOldSequenceProp( rLSeq.second->getValues(), uno::UNO_QUERY );
                             Reference< chart2::data::XDataSequence > xNewSequence(
                                 xDataProv->createDataSequenceByRangeRepresentation("categories"));
                             SchXMLTools::copyProperties(
                                 xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
-                            aLSeqIt->second->setValues( xNewSequence );
+                            rLSeq.second->setValues( xNewSequence );
                             bCategoriesApplied = true;
                         }
                         else
                         {
-                            Reference< beans::XPropertySet > xOldSequenceProp( aLSeqIt->second->getValues(), uno::UNO_QUERY );
-                            OUString aRep( OUString::number( aLSeqIt->first.first ));
+                            Reference< beans::XPropertySet > xOldSequenceProp( rLSeq.second->getValues(), uno::UNO_QUERY );
+                            OUString aRep( OUString::number( rLSeq.first.first ));
                             Reference< chart2::data::XDataSequence > xNewSequence(
                                 xDataProv->createDataSequenceByRangeRepresentation( aRep ));
                             SchXMLTools::copyProperties(
                                 xOldSequenceProp, Reference< beans::XPropertySet >( xNewSequence, uno::UNO_QUERY ));
-                            aLSeqIt->second->setValues( xNewSequence );
+                            rLSeq.second->setValues( xNewSequence );
                         }
                     }
                 }
             }
             else // labels
             {
-                SAL_WARN_IF( aLSeqIt->first.second != SCH_XML_PART_LABEL, "xmloff.chart", "aLSeqIt->first.second != SCH_XML_PART_LABEL" );
+                SAL_WARN_IF( rLSeq.first.second != SCH_XML_PART_LABEL, "xmloff.chart", "rLSeq.first.second != SCH_XML_PART_LABEL" );
                 // labels
-                Reference< chart2::data::XDataSequence > xSeq( aLSeqIt->second->getLabel());
+                Reference< chart2::data::XDataSequence > xSeq( rLSeq.second->getLabel());
                 OUString aRange;
                 if( xSeq.is() &&
                     SchXMLTools::getXMLRangePropertyFromDataSequence( xSeq, aRange, /* bClearProp = */ true ) &&
@@ -924,19 +922,19 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                     {
                         SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
                                             Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
-                        aLSeqIt->second->setLabel( xNewSeq );
+                        rLSeq.second->setLabel( xNewSeq );
                     }
                 }
                 else if( ! lcl_tableOfRangeMatches( aRange, rTable.aTableNameOfFile ))
                 {
                     OUString aRep("label ");
-                    aRep += OUString::number( aLSeqIt->first.first );
+                    aRep += OUString::number( rLSeq.first.first );
 
                     Reference< chart2::data::XDataSequence > xNewSeq(
                         xDataProv->createDataSequenceByRangeRepresentation( aRep ));
                     SchXMLTools::copyProperties( Reference< beans::XPropertySet >( xSeq, uno::UNO_QUERY ),
                                         Reference< beans::XPropertySet >( xNewSeq, uno::UNO_QUERY ));
-                    aLSeqIt->second->setLabel( xNewSeq );
+                    rLSeq.second->setLabel( xNewSeq );
                 }
             }
         }
@@ -1049,14 +1047,9 @@ void SchXMLTableHelper::switchRangesFromOuterToInternalIfNecessary(
                             }
 
                             ::std::vector< sal_Int32 > aSequenceIndexesToDelete;
-                            for( ::std::vector< sal_Int32 >::const_iterator aIt(
-                                     rTable.aHiddenColumns.begin()); aIt != rTable.aHiddenColumns.end(); ++aIt )
-                            {
-                                sal_Int32 nSequenceIndex = *aIt;
-                                if( aUsageMap.find(nSequenceIndex) != aUsageMap.end() )
-                                    continue;
-                                aSequenceIndexesToDelete.push_back(nSequenceIndex);
-                            }
+                            std::copy_if(rTable.aHiddenColumns.begin(), rTable.aHiddenColumns.end(),
+                                std::back_inserter(aSequenceIndexesToDelete),
+                                [&aUsageMap](sal_Int32 nSequenceIndex) { return aUsageMap.find(nSequenceIndex) == aUsageMap.end(); });
 
                             // delete unnecessary sequences of the internal data
                             // iterate using greatest index first, so that deletion does not
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index eb0934cc8a90..ccce96ef93a6 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -532,16 +532,14 @@ uno::Any getPropertyFromContext( const OUString& rPropertyName, const XMLPropSty
         return aRet;
     const ::std::vector< XMLPropertyState >& rProperties = pPropStyleContext->GetProperties();
     const rtl::Reference< XMLPropertySetMapper >& rMapper = pStylesCtxt->GetImportPropertyMapper( pPropStyleContext->GetFamily()/*XML_STYLE_FAMILY_SCH_CHART_ID*/ )->getPropertySetMapper();
-    ::std::vector< XMLPropertyState >::const_iterator aEnd( rProperties.end() );
-    ::std::vector< XMLPropertyState >::const_iterator aPropIter( rProperties.begin() );
-    for( aPropIter = rProperties.begin(); aPropIter != aEnd; ++aPropIter )
+    for( const auto& rProp : rProperties )
     {
-        sal_Int32 nIdx = aPropIter->mnIndex;
+        sal_Int32 nIdx = rProp.mnIndex;
         if( nIdx == -1 )
             continue;
         OUString aPropName = rMapper->GetEntryAPIName( nIdx );
         if(rPropertyName == aPropName)
-            return aPropIter->maValue;
+            return rProp.maValue;
     }
     return aRet;
 }
@@ -719,10 +717,9 @@ bool switchBackToDataProviderFromParent( const Reference< chart2::XChartDocument
 
     xDataReceiver->attachDataProvider( xDataProviderFromParent );
 
-    for( tSchXMLLSequencesPerIndex::const_iterator aLSeqIt( rLSequencesPerIndex.begin() );
-         aLSeqIt != rLSequencesPerIndex.end(); ++aLSeqIt )
+    for( const auto& rLSeq : rLSequencesPerIndex )
     {
-        Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( aLSeqIt->second );
+        Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( rLSeq.second );
         if( !xLabeledSeq.is() )
             continue;
         Reference< chart2::data::XDataSequence > xNewSeq;
diff --git a/xmloff/source/core/attrlist.cxx b/xmloff/source/core/attrlist.cxx
index 5673d66f9d93..e58707c6953c 100644
--- a/xmloff/source/core/attrlist.cxx
+++ b/xmloff/source/core/attrlist.cxx
@@ -113,13 +113,12 @@ OUString SAL_CALL SvXMLAttributeList::getTypeByName( const OUString& )
 
 OUString SAL_CALL SvXMLAttributeList::getValueByName(const OUString& sName)
 {
-    ::std::vector<struct SvXMLTagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
+    auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+        [&sName](struct SvXMLTagAttribute_Impl& rAttr) { return rAttr.sName == sName; });
+
+    if (ii != m_pImpl->vecAttribute.end())
+        return (*ii).sValue;
 
-    for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
-        if( (*ii).sName == sName ) {
-            return (*ii).sValue;
-        }
-    }
     return OUString();
 }
 
@@ -158,14 +157,11 @@ void SvXMLAttributeList::Clear()
 
 void SvXMLAttributeList::RemoveAttribute( const OUString& sName )
 {
-    ::std::vector<struct SvXMLTagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
+    auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+        [&sName](struct SvXMLTagAttribute_Impl& rAttr) { return rAttr.sName == sName; });
 
-    for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
-        if( (*ii).sName == sName ) {
-            m_pImpl->vecAttribute.erase( ii );
-            break;
-        }
-    }
+    if (ii != m_pImpl->vecAttribute.end())
+        m_pImpl->vecAttribute.erase( ii );
 }
 
 void SvXMLAttributeList::AppendAttributeList( const uno::Reference< css::xml::sax::XAttributeList >  &r )
@@ -215,16 +211,12 @@ void SvXMLAttributeList::RenameAttributeByIndex( sal_Int16 i,
 
 sal_Int16 SvXMLAttributeList::GetIndexByName( const OUString& rName ) const
 {
-    ::std::vector<struct SvXMLTagAttribute_Impl>::iterator ii =
-        m_pImpl->vecAttribute.begin();
+    auto ii = std::find_if(m_pImpl->vecAttribute.begin(), m_pImpl->vecAttribute.end(),
+        [&rName](struct SvXMLTagAttribute_Impl& rAttr) { return rAttr.sName == rName; });
+
+    if (ii != m_pImpl->vecAttribute.end())
+        return static_cast<sal_Int16>(std::distance(m_pImpl->vecAttribute.begin(), ii));
 
-    for( sal_Int16 nIndex=0; ii!=m_pImpl->vecAttribute.end(); ++ii, ++nIndex )
-    {
-        if( (*ii).sName == rName )
-        {
-            return nIndex;
-        }
-    }
     return -1;
 }
 
diff --git a/xmloff/source/core/fasttokenhandler.cxx b/xmloff/source/core/fasttokenhandler.cxx
index 277e18e7770b..319bdce5f367 100644
--- a/xmloff/source/core/fasttokenhandler.cxx
+++ b/xmloff/source/core/fasttokenhandler.cxx
@@ -44,12 +44,12 @@ TokenMap::TokenMap() :
     };
 
     const sal_Char* const* ppcTokenName = sppcTokenNames;
-    for( std::vector< uno::Sequence< sal_Int8 > >::iterator aIt = maTokenNames.begin(), aEnd = maTokenNames.end();
-            aIt != aEnd; ++aIt, ++ppcTokenName )
+    for( auto& rTokenName : maTokenNames )
     {
         OString aUtf8Token( *ppcTokenName );
-        *aIt = uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >(
+        rTokenName = uno::Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >(
                     aUtf8Token.getStr() ), aUtf8Token.getLength() );
+        ++ppcTokenName;
     }
 }
 
diff --git a/xmloff/source/core/nmspmap.cxx b/xmloff/source/core/nmspmap.cxx
index a0a949e821f5..e70dafd83b4e 100644
--- a/xmloff/source/core/nmspmap.cxx
+++ b/xmloff/source/core/nmspmap.cxx
@@ -148,16 +148,12 @@ sal_uInt16 SvXMLNamespaceMap::GetKeyByPrefix( const OUString& rPrefix ) const
 sal_uInt16 SvXMLNamespaceMap::GetKeyByName( const OUString& rName ) const
 {
     sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN;
-    NameSpaceHash::const_iterator aIter = aNameHash.begin(), aEnd = aNameHash.end();
-    while (aIter != aEnd )
-    {
-        if ((*aIter).second->sName == rName)
-        {
-            nKey = (*aIter).second->nKey;
-            break;
-        }
-        ++aIter;
-    }
+    auto aIter = std::find_if(aNameHash.cbegin(), aNameHash.cend(),
+        [&rName](const NameSpaceHash::value_type& rEntry) { return rEntry.second->sName == rName; });
+
+    if (aIter != aNameHash.cend())
+        nKey = (*aIter).second->nKey;
+
     return nKey;
 }
 
diff --git a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
index 00a97a9cc3fa..6a7f4c7cac73 100644
--- a/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
+++ b/xmloff/source/core/unointerfacetouniqueidentifiermapper.cxx
@@ -115,22 +115,16 @@ bool UnoInterfaceToUniqueIdentifierMapper::findReference( const Reference< XInte
 {
     uno::Reference< uno::XInterface > xRef( rInterface, uno::UNO_QUERY );
 
-    rIter = maEntries.begin();
-
     const IdMap_t::const_iterator aEnd( maEntries.end() );
-    while( rIter != aEnd )
-    {
+    rIter = std::find_if(maEntries.begin(), aEnd, [&xRef](const IdMap_t::value_type& rItem) {
         // The Reference == operator, does a repeated queryInterface on
         // this to ensure we got the right XInterface base-class. However,
         // we can be sure that this has been done already by the time we
         // get to here.
-        if( (*rIter).second.get() == xRef.get() )
-            return true;
-
-        ++rIter;
-    }
+        return rItem.second.get() == xRef.get();
+    });
 
-    return false;
+    return rIter != aEnd;
 }
 
 bool UnoInterfaceToUniqueIdentifierMapper::findIdentifier( const OUString& rIdentifier, IdMap_t::const_iterator& rIter ) const
diff --git a/xmloff/source/core/xmlerror.cxx b/xmloff/source/core/xmlerror.cxx
index a19a6ae23df8..750cee7d820f 100644
--- a/xmloff/source/core/xmlerror.cxx
+++ b/xmloff/source/core/xmlerror.cxx
@@ -193,11 +193,9 @@ void XMLErrors::AddRecord(
 void XMLErrors::ThrowErrorAsSAXException(sal_Int32 nIdMask)
 {
     // search first error/warning that matches the nIdMask
-    for( ErrorList::iterator aIter = aErrors.begin();
-         aIter != aErrors.end();
-         ++aIter )
+    for( const auto& rError : aErrors )
     {
-        if ( (aIter->nId & nIdMask) != 0 )
+        if ( (rError.nId & nIdMask) != 0 )
         {
             // we throw the error
             ErrorRecord& rErr = aErrors[0];
diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx
index 31f4beeb2044..10013b18fc3c 100644
--- a/xmloff/source/draw/XMLShapeStyleContext.cxx
+++ b/xmloff/source/draw/XMLShapeStyleContext.cxx
@@ -135,16 +135,12 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet
 
         ::std::vector< XMLPropertyState > &rProperties = GetProperties();
         ::std::vector< XMLPropertyState >::iterator end( rProperties.end() );
-        ::std::vector< XMLPropertyState >::iterator property;
 
         // first, look for the old format, where we had a text:list-style-name
         // attribute in the style:properties element
-        for( property = rProperties.begin(); property != end; ++property )
-        {
+        auto property = std::find_if(rProperties.begin(), end, [&rMapper](XMLPropertyState& rProp) {
             // find properties with context
-            if( (property->mnIndex != -1) && (rMapper->GetEntryContextId( property->mnIndex ) == CTF_SD_NUMBERINGRULES_NAME) )
-                break;
-        }
+            return (rProp.mnIndex != -1) && (rMapper->GetEntryContextId( rProp.mnIndex ) == CTF_SD_NUMBERINGRULES_NAME); });
 
         // if we did not find an old list-style-name in the properties, and we need one
         // because we got a style:list-style attribute in the style-style element
diff --git a/xmloff/source/draw/animexp.cxx b/xmloff/source/draw/animexp.cxx
index dc17b1776102..abb2a0266622 100644
--- a/xmloff/source/draw/animexp.cxx
+++ b/xmloff/source/draw/animexp.cxx
@@ -426,19 +426,14 @@ void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport )
 {
     mpImpl->maEffects.sort();
 
-    list<XMLEffectHint>::iterator aIter = mpImpl->maEffects.begin();
-    const list<XMLEffectHint>::iterator aEnd = mpImpl->maEffects.end();
-
     OUStringBuffer sTmp;
 
-    if( aIter != aEnd )
+    if( !mpImpl->maEffects.empty() )
     {
         SvXMLElementExport aElement( rExport, XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, true, true );
 
-        do
+        for (const auto& rEffect : mpImpl->maEffects)
         {
-            XMLEffectHint& rEffect = *aIter;
-
             SAL_WARN_IF( !rEffect.mxShape.is(), "xmloff", "shape id creation failed for animation effect?" );
 
             rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_SHAPE_ID, rExport.getInterfaceToIdentifierMapper().getIdentifier( rEffect.mxShape ) );
@@ -523,10 +518,7 @@ void XMLAnimationsExporter::exportAnimations( SvXMLExport& rExport )
                     SvXMLElementExport aElem( rExport, XML_NAMESPACE_PRESENTATION, XML_SOUND, true, true );
                 }
             }
-
-            ++aIter;
         }
-        while( aIter != aEnd );
     }
 
     mpImpl->maEffects.clear();
diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx
index b362798246c7..050b2ff3938a 100644
--- a/xmloff/source/draw/sdpropls.cxx
+++ b/xmloff/source/draw/sdpropls.cxx
@@ -1338,11 +1338,9 @@ void XMLShapeExportPropertyMapper::ContextFilter(
     XMLPropertyState* pControlWritingMode = nullptr;
 
     // filter properties
-    for( std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
-         aIter != rProperties.end();
-         ++aIter )
+    for( auto& rProp : rProperties )
     {
-            XMLPropertyState *property = &(*aIter);
+        XMLPropertyState *property = &rProp;
         if( property->mnIndex == -1 )
             continue;
 
@@ -1700,11 +1698,9 @@ void XMLPageExportPropertyMapper::ContextFilter(
     sal_Int16 nTransitionType = 0;
 
     // filter properties
-    for( std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
-         aIter != rProperties.end();
-         ++aIter )
+    for( auto& rProp : rProperties )
     {
-        XMLPropertyState *property = &(*aIter);
+        XMLPropertyState *property = &rProp;
         if( property->mnIndex == -1 )
             continue;
 
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index ab352d8298d1..0eb2051d9edb 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -1362,13 +1362,8 @@ void SdXMLExport::ImpPrepDrawPageInfos()
 static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, const sal_Char* pPrefix )
 {
     // search rVector if there is already a string that equals rText
-    std::vector< OUString >::iterator aIter;
-    sal_Int32 nIndex;
-    for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); ++aIter, ++nIndex )
-    {
-        if( (*aIter) == rText )
-            break;
-    }
+    auto aIter = std::find(rVector.begin(), rVector.end(), rText);
+    sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;
 
     // if nothing is found, append the string at the end of rVector
     if( aIter == rVector.end() )
@@ -1384,16 +1379,13 @@ static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUStri
 static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, bool bFixed, sal_Int32 nFormat, const sal_Char* pPrefix )
 {
     // search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
-    std::vector< DateTimeDeclImpl >::iterator aIter;
-    sal_Int32 nIndex;
-    for( nIndex = 1, aIter = rVector.begin(); aIter != rVector.end(); ++aIter, ++nIndex )
-    {
-        const DateTimeDeclImpl& rDecl = (*aIter);
-        if( (rDecl.mbFixed == bFixed ) &&
-            (!bFixed || rDecl.maStrText == rText) &&
-            (bFixed || (rDecl.mnFormat == nFormat) ) )
-            break;
-    }
+    auto aIter = std::find_if(rVector.begin(), rVector.end(),
+        [bFixed, &rText, nFormat](const DateTimeDeclImpl& rDecl) {
+            return (rDecl.mbFixed == bFixed) &&
+                (!bFixed || (rDecl.maStrText == rText)) &&
+                (bFixed || (rDecl.mnFormat == nFormat));
+        });
+    sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;
 
     // if nothing is found, append a new DateTimeDeclImpl
     if( aIter == rVector.end() )
@@ -1410,7 +1402,6 @@ static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, cons
     OUString aStr( OUString::createFromAscii( pPrefix ) );
     aStr += OUString::number( nIndex );
     return aStr;
-
 }
 
 static const sal_Char gpStrHeaderTextPrefix[] = "hdr";
@@ -1477,16 +1468,16 @@ void SdXMLExport::ImpWriteHeaderFooterDecls()
     {
         // export header decls
         const OUString aPrefix( gpStrHeaderTextPrefix );
-        std::vector< OUString >::iterator aIter;
-        sal_Int32 nIndex;
-        for( nIndex = 1, aIter = maHeaderDeclsVector.begin(); aIter != maHeaderDeclsVector.end(); ++aIter, ++nIndex )
+        sal_Int32 nIndex = 1;
+        for( const auto& rDecl : maHeaderDeclsVector )
         {
             sBuffer.append( aPrefix );
             sBuffer.append( nIndex );
             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
 
             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, true, true);
-            Characters(*aIter);
+            Characters(rDecl);
+            ++nIndex;
         }
     }
 
@@ -1494,16 +1485,16 @@ void SdXMLExport::ImpWriteHeaderFooterDecls()
     {
         // export footer decls
         const OUString aPrefix( gpStrFooterTextPrefix );
-        std::vector< OUString >::iterator aIter;
-        sal_Int32 nIndex;
-        for( nIndex = 1, aIter = maFooterDeclsVector.begin(); aIter != maFooterDeclsVector.end(); ++aIter, ++nIndex )
+        sal_Int32 nIndex = 1;
+        for( const auto& rDecl : maFooterDeclsVector )
         {
             sBuffer.append( aPrefix );
             sBuffer.append( nIndex );
             AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
 
             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, false, false);
-            Characters(*aIter);
+            Characters(rDecl);
+            ++nIndex;
         }
     }
 
@@ -1511,12 +1502,9 @@ void SdXMLExport::ImpWriteHeaderFooterDecls()
     {
         // export footer decls
         const OUString aPrefix( gpStrDateTimeTextPrefix );
-        std::vector< DateTimeDeclImpl >::iterator aIter;
-        sal_Int32 nIndex;
-        for( nIndex = 1, aIter = maDateTimeDeclsVector.begin(); aIter != maDateTimeDeclsVector.end(); ++aIter, ++nIndex )
+        sal_Int32 nIndex = 1;
+        for( const auto& rDecl : maDateTimeDeclsVector )
         {
-            const DateTimeDeclImpl& rDecl = (*aIter);
-
             sBuffer.append( aPrefix );
             sBuffer.append( nIndex );
             AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());
@@ -1529,6 +1517,8 @@ void SdXMLExport::ImpWriteHeaderFooterDecls()
             SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, false, false);
             if( rDecl.mbFixed )
                 Characters(rDecl.maStrText);
+
+            ++nIndex;
         }
     }
 }
@@ -2502,16 +2492,11 @@ void SdXMLExport::exportDataStyles()
 
 void SdXMLExport::exportAutoDataStyles()
 {
-    SdXMLFormatMap::iterator aIter( maUsedDateStyles.begin() );
-    SdXMLFormatMap::iterator aEnd( maUsedDateStyles.end() );
-
-    while( aIter != aEnd )
-        SdXMLNumberStylesExporter::exportDateStyle( *this, (*aIter++) );
+    for( const auto& rUsedDateStyle : maUsedDateStyles )
+        SdXMLNumberStylesExporter::exportDateStyle( *this, rUsedDateStyle );
 
-    aIter = maUsedTimeStyles.begin();
-    aEnd = maUsedTimeStyles.end();
-    while( aIter != aEnd )
-        SdXMLNumberStylesExporter::exportTimeStyle( *this, (*aIter++) );
+    for( const auto& rUsedTimeStyle : maUsedTimeStyles )
+        SdXMLNumberStylesExporter::exportTimeStyle( *this, rUsedTimeStyle );
 
     if(HasFormExport())
         GetFormExport()->exportAutoControlNumberStyles();
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 22c421e19a70..b78d6c3b2f89 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -437,14 +437,8 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
                 }
             }
 
-            std::vector< XMLPropertyState >::iterator aIter = aPropStates.begin();
-            std::vector< XMLPropertyState >::iterator aEnd = aPropStates.end();
-            while( aIter != aEnd )
-            {
-                if( aIter->mnIndex != -1 )
-                    nCount++;
-                ++aIter;
-            }
+            nCount = std::count_if(aPropStates.cbegin(), aPropStates.cend(),
+                [](const XMLPropertyState& rProp) { return rProp.mnIndex != -1; });
         }
 
         if(nCount == 0)
@@ -501,15 +495,8 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
                 }
             }
 
-            nCount = 0;
-            std::vector< XMLPropertyState >::iterator aIter = aPropStates.begin();
-            std::vector< XMLPropertyState >::iterator aEnd = aPropStates.end();
-            while( aIter != aEnd )
-            {
-                if( aIter->mnIndex != -1 )
-                    nCount++;
-                ++aIter;
-            }
+            nCount = std::count_if(aPropStates.cbegin(), aPropStates.cend(),
+                [](const XMLPropertyState& rProp) { return rProp.mnIndex != -1; });
 
             if( nCount )
             {
diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx
index a474cef96aa3..c55cd25411a9 100644
--- a/xmloff/source/draw/shapeimport.cxx
+++ b/xmloff/source/draw/shapeimport.cxx
@@ -982,13 +982,10 @@ void XMLShapeImportHelper::moveGluePointMapping( const css::uno::Reference< css:
         ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
         if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
         {
-            GluePointIdMap::iterator aShapeIdIter = (*aShapeIter).second.begin();
-            GluePointIdMap::iterator aShapeIdEnd  = (*aShapeIter).second.end();
-            while ( aShapeIdIter != aShapeIdEnd )
+            for ( auto& rShapeId : (*aShapeIter).second )
             {
-                if ( (*aShapeIdIter).second != -1 )
-                    (*aShapeIdIter).second += n;
-                ++aShapeIdIter;
+                if ( rShapeId.second != -1 )
+                    rShapeId.second += n;
             }
         }
     }
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index c30647b5a469..137131b7ce7a 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -1180,50 +1180,45 @@ void XMLEnhancedCustomShapeContext::EndElement()
         }
 
         // resolve equation
-        std::vector< OUString >::iterator aEquationIter = maEquations.begin();
-        std::vector< OUString >::iterator aEquationEnd  = maEquations.end();
-        while( aEquationIter != aEquationEnd )
+        for( auto& rEquation : maEquations )
         {
             sal_Int32 nIndexOf = 0;
             do
             {
-                nIndexOf = aEquationIter->indexOf( '?', nIndexOf );
+                nIndexOf = rEquation.indexOf( '?', nIndexOf );
                 if ( nIndexOf != -1 )
                 {
                     OUString aEquationName;
-                    if ( GetEquationName( *aEquationIter, nIndexOf + 1, aEquationName ) )
+                    if ( GetEquationName( rEquation, nIndexOf + 1, aEquationName ) )
                     {
                         // copying first characters inclusive '?'
-                        OUString aNew( aEquationIter->copy( 0, nIndexOf + 1 ) );
+                        OUString aNew( rEquation.copy( 0, nIndexOf + 1 ) );
                         sal_Int32 nIndex = 0;
                         EquationHashMap::iterator aHashIter( pH->find( aEquationName ) );
                         if ( aHashIter != pH->end() )
                             nIndex = (*aHashIter).second;
                         aNew += OUString::number( nIndex );
-                        aNew += aEquationIter->copy( nIndexOf + aEquationName.getLength() + 1 );
-                        *aEquationIter = aNew;
+                        aNew += rEquation.copy( nIndexOf + aEquationName.getLength() + 1 );
+                        rEquation = aNew;
                     }
                     nIndexOf++;
                 }
             }
             while( nIndexOf != -1 );
-            ++aEquationIter;
         }
 
         // Path
         sal_Int32 i;
-        std::vector< beans::PropertyValue >::iterator aPathIter = maPath.begin();
-        std::vector< beans::PropertyValue >::iterator aPathEnd  = maPath.end();
-        while ( aPathIter != aPathEnd )
+        for ( beans::PropertyValue& rPathItem : maPath )
         {
-            switch( EASGet( aPathIter->Name ) )
+            switch( EASGet( rPathItem.Name ) )
             {
                 case EAS_Coordinates :
                 case EAS_GluePoints :
                 {
                     uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > const & rSeq =
                         *o3tl::doAccess<uno::Sequence< css::drawing::EnhancedCustomShapeParameterPair > >(
-                            aPathIter->Value);
+                            rPathItem.Value);
                     for ( i = 0; i < rSeq.getLength(); i++ )
                     {
                         CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].First), pH.get() );
@@ -1235,7 +1230,7 @@ void XMLEnhancedCustomShapeContext::EndElement()
                 {
                     uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > const & rSeq =
                         *o3tl::doAccess<uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > >(
-                            aPathIter->Value);
+                            rPathItem.Value);
                     for ( i = 0; i < rSeq.getLength(); i++ )
                     {
                         CheckAndResolveEquationParameter( const_cast<css::drawing::EnhancedCustomShapeParameter &>(rSeq[ i ].TopLeft.First), pH.get() );
@@ -1248,7 +1243,6 @@ void XMLEnhancedCustomShapeContext::EndElement()
                 default:
                     break;
             }
-            ++aPathIter;
         }
         for ( css::beans::PropertyValues const & aHandle : maHandles )
         {
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 21339eb6bbcf..a286811d4e52 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -3762,15 +3762,9 @@ void SdXMLCustomShapeContext::EndElement()
 
             //fdo#84043 overwrite the property if it already exists, otherwise append it
             beans::PropertyValue* pItem;
-            std::vector< beans::PropertyValue >::iterator aI(maCustomShapeGeometry.begin());
-            std::vector< beans::PropertyValue >::iterator aE(maCustomShapeGeometry.end());
-            while (aI != aE)
-            {
-                if (aI->Name == sName)
-                    break;
-                ++aI;
-            }
-            if (aI != aE)
+            auto aI = std::find_if(maCustomShapeGeometry.begin(), maCustomShapeGeometry.end(),
+                [&sName](beans::PropertyValue& rValue) { return rValue.Name == sName; });
+            if (aI != maCustomShapeGeometry.end())
             {
                 beans::PropertyValue& rItem = *aI;
                 pItem = &rItem;
diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx
index 425c0a3b9942..0bc675d6d3e8 100644
--- a/xmloff/source/draw/ximpstyl.cxx
+++ b/xmloff/source/draw/ximpstyl.cxx
@@ -192,19 +192,18 @@ void SdXMLDrawingPageStyleContext::Finish( bool bOverwrite )
 
     const rtl::Reference< XMLPropertySetMapper >& rImpPrMap = GetStyles()->GetImportPropertyMapper( GetFamily() )->getPropertySetMapper();
 
-    ::std::vector< XMLPropertyState >::iterator property = rProperties.begin();
-    for(; property != rProperties.end(); ++property)
+    for(auto& property : rProperties)
     {
-        if( property->mnIndex == -1 )
+        if( property.mnIndex == -1 )
             continue;
 
-        sal_Int16 nContextID = rImpPrMap->GetEntryContextId(property->mnIndex);
+        sal_Int16 nContextID = rImpPrMap->GetEntryContextId(property.mnIndex);
         switch( nContextID )
         {
             case CTF_DATE_TIME_FORMAT:
             {
                 OUString sStyleName;
-                (*property).maValue >>= sStyleName;
+                property.maValue >>= sStyleName;
 
                 sal_Int32 nStyle = 0;
 
@@ -215,7 +214,7 @@ void SdXMLDrawingPageStyleContext::Finish( bool bOverwrite )
                 if( pSdNumStyle )
                     nStyle = pSdNumStyle->GetDrawKey();
 
-                (*property).maValue <<= nStyle;
+                property.maValue <<= nStyle;
             }
             break;
         }
@@ -1187,18 +1186,13 @@ static bool canSkipReset(const OUString &rName, const XMLPropStyleContext* pProp
         if (nIndexStyle != -1)
         {
             const ::std::vector< XMLPropertyState > &rProperties = pPropStyle->GetProperties();
-            ::std::vector< XMLPropertyState >::const_iterator property = rProperties.begin();
-            for(; property != rProperties.end(); ++property)
+            auto property = std::find_if(rProperties.cbegin(), rProperties.cend(),
+                [nIndexStyle](const XMLPropertyState& rProp) { return rProp.mnIndex == nIndexStyle; });
+            if (property != rProperties.cend())
             {
-                sal_Int32 nIdx = property->mnIndex;
-                if (nIdx == nIndexStyle)
-                {
-                    bool bNewStyleTextAutoGrowHeight(false);
-                    property->maValue >>= bNewStyleTextAutoGrowHeight;
-                    if (bNewStyleTextAutoGrowHeight == bOldStyleTextAutoGrowHeight)
-                        bCanSkipReset = true;
-                    break;
-                }
+                bool bNewStyleTextAutoGrowHeight(false);
+                property->maValue >>= bNewStyleTextAutoGrowHeight;
+                bCanSkipReset = (bNewStyleTextAutoGrowHeight == bOldStyleTextAutoGrowHeight);
             }
         }
     }


More information about the Libreoffice-commits mailing list