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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Dec 3 07:14:36 UTC 2018


 sdext/source/minimizer/configurationaccess.cxx     |   10 -
 sdext/source/minimizer/fileopendialog.cxx          |   20 +--
 sdext/source/minimizer/graphiccollector.cxx        |   59 ++++------
 sdext/source/minimizer/impoptimizer.cxx            |   64 +++++------
 sdext/source/minimizer/optimizationstats.cxx       |    7 -
 sdext/source/minimizer/optimizerdialogcontrols.cxx |   39 ++-----
 sdext/source/minimizer/pagecollector.cxx           |   50 ++-------
 sdext/source/pdfimport/odf/odfemitter.cxx          |    9 -
 sdext/source/pdfimport/sax/emitcontext.cxx         |    6 -
 sdext/source/pdfimport/sax/saxattrlist.cxx         |    8 -
 sdext/source/pdfimport/tree/drawtreevisiting.cxx   |   23 ++--
 sdext/source/pdfimport/tree/genericelements.cxx    |   26 ++--
 sdext/source/pdfimport/tree/style.cxx              |   15 +-
 sdext/source/pdfimport/tree/style.hxx              |   12 --
 sdext/source/pdfimport/tree/writertreevisiting.cxx |   97 ++++++++---------
 sdext/source/presenter/PresenterAccessibility.cxx  |   56 ++--------
 sdext/source/presenter/PresenterController.cxx     |   40 +++----
 sdext/source/presenter/PresenterHelpView.cxx       |   59 ++++------
 sdext/source/presenter/PresenterPaneContainer.cxx  |   70 ++++--------
 sdext/source/presenter/PresenterPaneFactory.cxx    |    6 -
 sdext/source/presenter/PresenterTextView.cxx       |   64 +++--------
 sdext/source/presenter/PresenterTheme.cxx          |   44 +++-----
 sdext/source/presenter/PresenterTimer.cxx          |   23 +---
 sdext/source/presenter/PresenterToolBar.cxx        |  115 ++++++++-------------
 sdext/source/presenter/PresenterViewFactory.cxx    |    6 -
 sdext/source/presenter/PresenterWindowManager.cxx  |   63 ++++-------
 26 files changed, 383 insertions(+), 608 deletions(-)

New commits:
commit 056845403c387f1fe286f9df13f73fa2fc6d0014
Author:     Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Mon Dec 3 00:52:17 2018 +0300
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Dec 3 08:14:15 2018 +0100

    Simplify containers iterations in sdext
    
    Use range-based loop or replace with STL functions
    
    Change-Id: I760c1aaeae9afc99effee6a2645bb77439260ddf
    Reviewed-on: https://gerrit.libreoffice.org/64435
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx
index a7c5cbd6df4f..f7978379761b 100644
--- a/sdext/source/minimizer/configurationaccess.cxx
+++ b/sdext/source/minimizer/configurationaccess.cxx
@@ -466,14 +466,8 @@ Sequence< PropertyValue > ConfigurationAccess::GetConfigurationSequence()
 
 std::vector< OptimizerSettings >::iterator ConfigurationAccess::GetOptimizerSettingsByName( const OUString& rName )
 {
-    std::vector< OptimizerSettings >::iterator aIter( maSettings.begin() + 1 );
-    const std::vector< OptimizerSettings >::const_iterator aEnd( maSettings.end() );
-    for ( ; aIter != aEnd; ++aIter )
-    {
-        if ( aIter->maName == rName )
-            break;
-    }
-    return aIter;
+    return std::find_if(maSettings.begin() + 1, maSettings.end(),
+        [&rName](const OptimizerSettings& rSettings) { return rSettings.maName == rName; });
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/fileopendialog.cxx b/sdext/source/minimizer/fileopendialog.cxx
index 13728bc5cba9..472951469571 100644
--- a/sdext/source/minimizer/fileopendialog.cxx
+++ b/sdext/source/minimizer/fileopendialog.cxx
@@ -118,12 +118,12 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
     Reference< XNameAccess > xTypes( rxContext->getServiceManager()->createInstanceWithContext(
         "com.sun.star.document.TypeDetection", rxContext ), UNO_QUERY_THROW );
 
-    for( std::vector< FilterEntry >::const_iterator aIter(aFilterEntryList.begin()), aEnd(aFilterEntryList.end()); aIter != aEnd; ++aIter )
+    for( const auto& rFilterEntry : aFilterEntryList )
     {
         Sequence< PropertyValue > aTypeProperties;
         try
         {
-            if ( xTypes->getByName( aIter->maType ) >>= aTypeProperties )
+            if ( xTypes->getByName( rFilterEntry.maType ) >>= aTypeProperties )
             {
                 Sequence< OUString > aExtensions;
                 for ( int i = 0; i < aTypeProperties.getLength(); i++ )
@@ -139,10 +139,10 @@ FileOpenDialog::FileOpenDialog( const Reference< XComponentContext >& rxContext
                     // The filter title must be formed in the same way it is
                     // currently done in the internal implementation:
                     OUString aTitle(
-                        aIter->maUIName + " (." + aExtensions[0] + ")");
+                        rFilterEntry.maUIName + " (." + aExtensions[0] + ")");
                     OUString aFilter("*." + aExtensions[0]);
                     mxFilePicker->appendFilter(aTitle, aFilter);
-                    if ( aIter->maFlags & 0x100 )
+                    if ( rFilterEntry.maFlags & 0x100 )
                         mxFilePicker->setCurrentFilter(aTitle);
                 }
             }
@@ -173,14 +173,10 @@ OUString FileOpenDialog::getFilterName() const
     OUString aFilterName;
     Reference< XFilterManager > xFilterManager( mxFilePicker, UNO_QUERY_THROW );
     OUString aUIName( xFilterManager->getCurrentFilter() );
-    for( std::vector< FilterEntry >::const_iterator aIter(aFilterEntryList.begin()), aEnd(aFilterEntryList.end()); aIter != aEnd; ++aIter )
-    {
-        if ( aIter->maUIName == aUIName )
-        {
-            aFilterName = aIter->maFilterEntryName;
-            break;
-        }
-    }
+    auto aIter = std::find_if(aFilterEntryList.begin(), aFilterEntryList.end(),
+        [&aUIName](const FilterEntry& rFilterEntry) { return rFilterEntry.maUIName == aUIName; });
+    if (aIter != aFilterEntryList.end())
+        aFilterName = aIter->maFilterEntryName;
     return aFilterName;
 };
 
diff --git a/sdext/source/minimizer/graphiccollector.cxx b/sdext/source/minimizer/graphiccollector.cxx
index 26ae7fca3555..c0ca3d57f4a0 100644
--- a/sdext/source/minimizer/graphiccollector.cxx
+++ b/sdext/source/minimizer/graphiccollector.cxx
@@ -62,25 +62,23 @@ static void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraph
 {
     if ( rGraphicSettings.mbEmbedLinkedGraphics )
     {
-        std::vector< GraphicCollector::GraphicEntity >::iterator aIter( rGraphicEntities.begin() );
-        while( aIter != rGraphicEntities.end() )
-        {
-            if ( aIter->maUser[ 0 ].mxGraphic == rUser.mxGraphic )
-            {
-                if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
-                    aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
-                if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
-                    aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
-                aIter->maUser.push_back( rUser );
-                break;
-            }
-            ++aIter;
-        }
+        auto aIter = std::find_if(rGraphicEntities.begin(), rGraphicEntities.end(),
+            [&rUser](const GraphicCollector::GraphicEntity& rGraphicEntity) {
+                return rGraphicEntity.maUser[ 0 ].mxGraphic == rUser.mxGraphic;
+            });
         if ( aIter == rGraphicEntities.end() )
         {
             GraphicCollector::GraphicEntity aEntity( rUser );
             rGraphicEntities.push_back( aEntity );
         }
+        else
+        {
+            if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
+                aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
+            if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
+                aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
+            aIter->maUser.push_back( rUser );
+        }
     }
 }
 
@@ -288,38 +286,35 @@ void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rx
             ImpCollectGraphicObjects( rxMSF, xMasterPage, rGraphicSettings, rGraphicList );
         }
 
-        std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() );
-        std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() );
-        while( aGraphicIter != aGraphicIEnd )
+        for( auto& rGraphic : rGraphicList )
         {
             // check if it is possible to remove the crop area
-            aGraphicIter->mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea;
-            if ( aGraphicIter->mbRemoveCropArea )
+            rGraphic.mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea;
+            if ( rGraphic.mbRemoveCropArea )
             {
-                std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( aGraphicIter->maUser.begin() );
-                while( aGraphicIter->mbRemoveCropArea && ( aGUIter != aGraphicIter->maUser.end() ) )
+                std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( rGraphic.maUser.begin() );
+                while( rGraphic.mbRemoveCropArea && ( aGUIter != rGraphic.maUser.end() ) )
                 {
                     if ( aGUIter->maGraphicCropLogic.Left || aGUIter->maGraphicCropLogic.Top
                         || aGUIter->maGraphicCropLogic.Right || aGUIter->maGraphicCropLogic.Bottom )
                     {
-                        if ( aGUIter == aGraphicIter->maUser.begin() )
-                            aGraphicIter->maGraphicCropLogic = aGUIter->maGraphicCropLogic;
-                        else if ( ( aGraphicIter->maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
-                            || ( aGraphicIter->maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
-                            || ( aGraphicIter->maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
-                            || ( aGraphicIter->maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
+                        if ( aGUIter == rGraphic.maUser.begin() )
+                            rGraphic.maGraphicCropLogic = aGUIter->maGraphicCropLogic;
+                        else if ( ( rGraphic.maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
+                            || ( rGraphic.maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
+                            || ( rGraphic.maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
+                            || ( rGraphic.maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
                         {
-                            aGraphicIter->mbRemoveCropArea = false;
+                            rGraphic.mbRemoveCropArea = false;
                         }
                     }
                     else
-                        aGraphicIter->mbRemoveCropArea = false;
+                        rGraphic.mbRemoveCropArea = false;
                     ++aGUIter;
                 }
             }
-            if ( !aGraphicIter->mbRemoveCropArea )
-                aGraphicIter->maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
-            ++aGraphicIter;
+            if ( !rGraphic.mbRemoveCropArea )
+                rGraphic.maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
         }
     }
     catch ( Exception& )
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx
index da4f611bc474..6b3d054f1be1 100644
--- a/sdext/source/minimizer/impoptimizer.cxx
+++ b/sdext/source/minimizer/impoptimizer.cxx
@@ -81,9 +81,8 @@ static void ImpExtractCustomShow( const Reference< XModel >& rxModel, const OUSt
         PageCollector::CollectNonCustomShowPages( rxModel, rCustomShowName, vNonUsedPageList );
         Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
-        vector< Reference< XDrawPage > >::iterator aIter( vNonUsedPageList.begin() );
-        while( aIter != vNonUsedPageList.end() )
-            xDrawPages->remove( *aIter++ );
+        for( const auto& rxPage : vNonUsedPageList )
+            xDrawPages->remove( rxPage );
     }
     catch( Exception& )
     {
@@ -99,12 +98,10 @@ static void ImpDeleteUnusedMasterPages( const Reference< XModel >& rxModel )
     // now master pages that are not marked can be deleted
     Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
     Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
-    vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
-    while( aIter != aMasterPageList.end() )
+    for( const auto& rMasterPage : aMasterPageList )
     {
-        if ( !aIter->bUsed )
-            xMasterPages->remove( aIter->xMasterPage );
-        ++aIter;
+        if ( !rMasterPage.bUsed )
+            xMasterPages->remove( rMasterPage.xMasterPage );
     }
 }
 
@@ -376,65 +373,62 @@ static void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XCompon
 {
     try
     {
-        std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() );
-        std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() );
         double i = 0;
-        while( aGraphicIter != aGraphicIEnd )
+        for( auto& rGraphic : rGraphicList )
         {
             i++;
             sal_Int32 nProgress = static_cast< sal_Int32 >( 40.0 * ( i / static_cast< double >( rGraphicList.size() ) ) ) + 50;
             rOptimizer.SetStatusValue( TK_Progress, Any( nProgress ) );
             rOptimizer.DispatchStatus();
 
-            if ( !aGraphicIter->maUser.empty() )
+            if ( !rGraphic.maUser.empty() )
             {
                 GraphicSettings aGraphicSettings( rGraphicSettings );
-                aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea;
+                aGraphicSettings.mbRemoveCropArea = rGraphic.mbRemoveCropArea;
 
                 Reference< XGraphic > xGraphic;
-                if ( aGraphicIter->maUser[ 0 ].mbFillBitmap && aGraphicIter->maUser[ 0 ].mxPropertySet.is() )
+                if ( rGraphic.maUser[ 0 ].mbFillBitmap && rGraphic.maUser[ 0 ].mxPropertySet.is() )
                 {
                     Reference< XBitmap > xFillBitmap;
-                    if ( aGraphicIter->maUser[ 0 ].mxPropertySet->getPropertyValue( "FillBitmap" ) >>= xFillBitmap )
+                    if ( rGraphic.maUser[ 0 ].mxPropertySet->getPropertyValue( "FillBitmap" ) >>= xFillBitmap )
                         xGraphic.set( xFillBitmap, UNO_QUERY_THROW );
                 }
-                else if ( aGraphicIter->maUser[ 0 ].mxShape.is() )
+                else if ( rGraphic.maUser[ 0 ].mxShape.is() )
                 {
-                    Reference< XPropertySet > xShapePropertySet( aGraphicIter->maUser[ 0 ].mxShape, UNO_QUERY_THROW );
+                    Reference< XPropertySet > xShapePropertySet( rGraphic.maUser[ 0 ].mxShape, UNO_QUERY_THROW );
                     xShapePropertySet->getPropertyValue( "Graphic" ) >>= xGraphic;
                 }
                 if ( xGraphic.is() )
                 {
                     Reference< XPropertySet > xNewGraphicPropertySet( xGraphic, UNO_QUERY_THROW );
                     awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxContext, xGraphic ) );
-                    Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxContext, xGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) );
+                    Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxContext, xGraphic, rGraphic.maLogicalSize, rGraphic.maGraphicCropLogic, aGraphicSettings ) );
                     if ( xNewGraphic.is() )
                     {
                         // applying graphic to each user
-                        std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() );
-                        while( aGraphicUserIter != aGraphicIter->maUser.end() )
+                        for( auto& rGraphicUser : rGraphic.maUser )
                         {
-                            if ( aGraphicUserIter->mxShape.is() )
+                            if ( rGraphicUser.mxShape.is() )
                             {
-                                Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW );
+                                Reference< XPropertySet > xShapePropertySet( rGraphicUser.mxShape, UNO_QUERY_THROW );
                                 xShapePropertySet->setPropertyValue( "Graphic", Any( xNewGraphic ) );
 
-                                if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top
-                                || aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom )
+                                if ( rGraphicUser.maGraphicCropLogic.Left || rGraphicUser.maGraphicCropLogic.Top
+                                || rGraphicUser.maGraphicCropLogic.Right || rGraphicUser.maGraphicCropLogic.Bottom )
                                 {   // removing crop area was not possible or shouldn't been applied
                                     text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
                                     if ( !aGraphicSettings.mbRemoveCropArea )
                                     {
                                         awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxContext, xNewGraphic ) );
-                                        aGraphicCropLogic.Left = static_cast<sal_Int32>(static_cast<double>(aGraphicUserIter->maGraphicCropLogic.Left) * (static_cast<double>(aNewSize.Width) / static_cast<double>(aSize100thMM.Width)));
-                                        aGraphicCropLogic.Top = static_cast<sal_Int32>(static_cast<double>(aGraphicUserIter->maGraphicCropLogic.Top) * (static_cast<double>(aNewSize.Height) / static_cast<double>(aSize100thMM.Height)));
-                                        aGraphicCropLogic.Right = static_cast<sal_Int32>(static_cast<double>(aGraphicUserIter->maGraphicCropLogic.Right) * (static_cast<double>(aNewSize.Width) / static_cast<double>(aSize100thMM.Width)));
-                                        aGraphicCropLogic.Bottom = static_cast<sal_Int32>(static_cast<double>(aGraphicUserIter->maGraphicCropLogic.Bottom) * (static_cast<double>(aNewSize.Height) / static_cast<double>(aSize100thMM.Height)));
+                                        aGraphicCropLogic.Left = static_cast<sal_Int32>(static_cast<double>(rGraphicUser.maGraphicCropLogic.Left) * (static_cast<double>(aNewSize.Width) / static_cast<double>(aSize100thMM.Width)));
+                                        aGraphicCropLogic.Top = static_cast<sal_Int32>(static_cast<double>(rGraphicUser.maGraphicCropLogic.Top) * (static_cast<double>(aNewSize.Height) / static_cast<double>(aSize100thMM.Height)));
+                                        aGraphicCropLogic.Right = static_cast<sal_Int32>(static_cast<double>(rGraphicUser.maGraphicCropLogic.Right) * (static_cast<double>(aNewSize.Width) / static_cast<double>(aSize100thMM.Width)));
+                                        aGraphicCropLogic.Bottom = static_cast<sal_Int32>(static_cast<double>(rGraphicUser.maGraphicCropLogic.Bottom) * (static_cast<double>(aNewSize.Height) / static_cast<double>(aSize100thMM.Height)));
                                     }
                                     xShapePropertySet->setPropertyValue( "GraphicCrop", Any( aGraphicCropLogic ) );
                                 }
                             }
-                            else if ( aGraphicUserIter->mxPropertySet.is() )
+                            else if ( rGraphicUser.mxPropertySet.is() )
                             {
                                 Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY );
                                 if ( xFillBitmap.is() )
@@ -442,7 +436,7 @@ static void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XCompon
                                     awt::Size aSize;
                                     bool bLogicalSize;
 
-                                    Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet );
+                                    Reference< XPropertySet >& rxPropertySet( rGraphicUser.mxPropertySet );
                                     rxPropertySet->setPropertyValue( "FillBitmap", Any( xFillBitmap ) );
                                     if ( ( rxPropertySet->getPropertyValue( "FillBitmapLogicalSize" ) >>= bLogicalSize )
                                         && ( rxPropertySet->getPropertyValue( "FillBitmapSizeX" ) >>= aSize.Width )
@@ -451,20 +445,18 @@ static void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XCompon
                                         if ( !aSize.Width || !aSize.Height )
                                         {
                                             rxPropertySet->setPropertyValue( "FillBitmapLogicalSize", Any( true ) );
-                                            rxPropertySet->setPropertyValue( "FillBitmapSizeX", Any( aGraphicUserIter->maLogicalSize.Width ) );
-                                            rxPropertySet->setPropertyValue( "FillBitmapSizeY", Any( aGraphicUserIter->maLogicalSize.Height ) );
+                                            rxPropertySet->setPropertyValue( "FillBitmapSizeX", Any( rGraphicUser.maLogicalSize.Width ) );
+                                            rxPropertySet->setPropertyValue( "FillBitmapSizeY", Any( rGraphicUser.maLogicalSize.Height ) );
                                         }
                                     }
-                                    if ( aGraphicUserIter->mxPagePropertySet.is() )
-                                        aGraphicUserIter->mxPagePropertySet->setPropertyValue( "Background", Any( rxPropertySet ) );
+                                    if ( rGraphicUser.mxPagePropertySet.is() )
+                                        rGraphicUser.mxPagePropertySet->setPropertyValue( "Background", Any( rxPropertySet ) );
                                 }
                             }
-                            ++aGraphicUserIter;
                         }
                     }
                 }
             }
-            ++aGraphicIter;
         }
     }
     catch ( Exception& )
diff --git a/sdext/source/minimizer/optimizationstats.cxx b/sdext/source/minimizer/optimizationstats.cxx
index b3f25bdd9a17..93d86ed9cb1c 100644
--- a/sdext/source/minimizer/optimizationstats.cxx
+++ b/sdext/source/minimizer/optimizationstats.cxx
@@ -54,11 +54,10 @@ css::beans::PropertyValues OptimizationStats::GetStatusSequence()
 {
     int i = 0;
     uno::Sequence< PropertyValue > aStatsSequence( maStats.size() );
-    std::map< PPPOptimizerTokenEnum, uno::Any >::iterator aIter( maStats.begin() );
-    while( aIter != maStats.end() )
+    for( const auto& rEntry : maStats )
     {
-        aStatsSequence[ i ].Name = TKGet( (*aIter).first );
-        aStatsSequence[ i++ ].Value = (*aIter++).second;
+        aStatsSequence[ i ].Name = TKGet( rEntry.first );
+        aStatsSequence[ i++ ].Value = rEntry.second;
     }
     return aStatsSequence;
 }
diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx
index 987557920c58..e5326e5096b0 100644
--- a/sdext/source/minimizer/optimizerdialogcontrols.cxx
+++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx
@@ -671,10 +671,9 @@ void OptimizerDialog::UpdateControlStatesPage4()
         {
             std::vector< Reference< XDrawPage > > vUsedPageList;
             PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
-            std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
-            while( aIter != vUsedPageList.end() )
+            for( const auto& rxPage : vUsedPageList )
             {
-                Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
+                Reference< XPropertySet > xPropSet( rxPage, UNO_QUERY_THROW );
                 bool bVisible = true;
                 const OUString sVisible( "Visible"  );
                 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
@@ -682,7 +681,6 @@ void OptimizerDialog::UpdateControlStatesPage4()
                     if (!bVisible )
                         nDeletedSlides++;
                 }
-                ++aIter;
             }
         }
         else
@@ -710,13 +708,8 @@ void OptimizerDialog::UpdateControlStatesPage4()
         PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
         Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
-        std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
-        while( aIter != aMasterPageList.end() )
-        {
-            if ( !aIter->bUsed )
-                nDeletedSlides++;
-            ++aIter;
-        }
+        nDeletedSlides += std::count_if(aMasterPageList.begin(), aMasterPageList.end(),
+            [](const PageCollector::MasterPageEntity& rEntity) { return !rEntity.bUsed; });
     }
     if ( nDeletedSlides > 1 )
     {
@@ -907,31 +900,23 @@ void OptimizerDialog::InitPage4()
 
 void OptimizerDialog::EnablePage( sal_Int16 nStep )
 {
-    std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
-    std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
-    while( aBeg != aEnd )
-        setControlProperty( *aBeg++, "Enabled", Any( true ) );
+    for( const auto& rItem : maControlPages[ nStep ] )
+        setControlProperty( rItem, "Enabled", Any( true ) );
 }
 void OptimizerDialog::DisablePage( sal_Int16 nStep )
 {
-    std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
-    std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
-    while( aBeg != aEnd )
-        setControlProperty( *aBeg++, "Enabled", Any( false ) );
+    for( const auto& rItem : maControlPages[ nStep ] )
+        setControlProperty( rItem, "Enabled", Any( false ) );
 }
 void OptimizerDialog::ActivatePage( sal_Int16 nStep )
 {
-    std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
-    std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
-    while( aBeg != aEnd )
-        setVisible( *aBeg++, true );
+    for( const auto& rItem : maControlPages[ nStep ] )
+        setVisible( rItem, true );
 }
 void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
 {
-    std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
-    std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
-    while( aBeg != aEnd )
-        setVisible( *aBeg++, false );
+    for( const auto& rItem : maControlPages[ nStep ] )
+        setVisible( rItem, false );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sdext/source/minimizer/pagecollector.cxx b/sdext/source/minimizer/pagecollector.cxx
index ca634e560a76..dcb630881761 100644
--- a/sdext/source/minimizer/pagecollector.cxx
+++ b/sdext/source/minimizer/pagecollector.cxx
@@ -54,15 +54,8 @@ void PageCollector::CollectCustomShowPages( const css::uno::Reference< css::fram
                     for ( j = 0; j < nSlideCount; j++ )
                     {
                         Reference< XDrawPage > xDrawPage( aXIC->getByIndex( j ), UNO_QUERY_THROW );
-                        std::vector< Reference< XDrawPage > >::iterator aIter( rUsedPageList.begin() );
-                        std::vector< Reference< XDrawPage > >::iterator aEnd( rUsedPageList.end() );
-                        while( aIter != aEnd )
-                        {
-                            if ( *aIter == xDrawPage )
-                                break;
-                            ++aIter;
-                        }
-                        if ( aIter == aEnd )
+                        auto aIter = std::find(rUsedPageList.begin(), rUsedPageList.end(), xDrawPage);
+                        if ( aIter == rUsedPageList.end() )
                             rUsedPageList.push_back( xDrawPage );
                     }
                 }
@@ -88,15 +81,8 @@ void PageCollector::CollectNonCustomShowPages( const css::uno::Reference< css::f
             for ( sal_Int32 j = 0; j < xDrawPages->getCount(); j++ )
             {
                 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
-                std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
-                std::vector< Reference< XDrawPage > >::iterator aEnd( vUsedPageList.end() );
-                while( aIter != aEnd )
-                {
-                    if ( *aIter == xDrawPage )
-                        break;
-                    ++aIter;
-                }
-                if ( aIter == aEnd )
+                auto aIter = std::find(vUsedPageList.begin(), vUsedPageList.end(), xDrawPage);
+                if ( aIter == vUsedPageList.end() )
                     rNonUsedPageList.push_back( xDrawPage );
             }
         }
@@ -117,15 +103,9 @@ void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std:
         for ( sal_Int32 i = 0; i < xMasterPages->getCount(); i++ )
         {
             Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
-            auto aIter( rMasterPageList.begin() );
-            auto aEnd ( rMasterPageList.end() );
-            while( aIter != aEnd )
-            {
-                if ( aIter->xMasterPage == xMasterPage )
-                    break;
-                ++aIter;
-            }
-            if ( aIter == aEnd )
+            auto aIter = std::find_if(rMasterPageList.begin(), rMasterPageList.end(),
+                [&xMasterPage](const MasterPageEntity& rEntity) { return rEntity.xMasterPage == xMasterPage; });
+            if ( aIter == rMasterPageList.end() )
             {
                 MasterPageEntity aMasterPageEntity;
                 aMasterPageEntity.xMasterPage = xMasterPage;
@@ -141,19 +121,11 @@ void PageCollector::CollectMasterPages( const Reference< XModel >& rxModel, std:
         {
             Reference< XMasterPageTarget > xMasterPageTarget( xDrawPages->getByIndex( j ), UNO_QUERY_THROW );
             Reference< XDrawPage > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY_THROW );
-            auto aIter( rMasterPageList.begin() );
-            auto aEnd ( rMasterPageList.end() );
-            while( aIter != aEnd )
-            {
-                if ( aIter->xMasterPage == xMasterPage )
-                {
-                    aIter->bUsed = true;
-                    break;
-                }
-                ++aIter;
-            }
-            if ( aIter == aEnd )
+            auto aIter = std::find_if(rMasterPageList.begin(), rMasterPageList.end(),
+                [&xMasterPage](const MasterPageEntity& rEntity) { return rEntity.xMasterPage == xMasterPage; });
+            if ( aIter == rMasterPageList.end() )
                 throw uno::RuntimeException();
+            aIter->bUsed = true;
         }
     }
     catch( Exception& )
diff --git a/sdext/source/pdfimport/odf/odfemitter.cxx b/sdext/source/pdfimport/odf/odfemitter.cxx
index f83c7323193c..78a38e42502f 100644
--- a/sdext/source/pdfimport/odf/odfemitter.cxx
+++ b/sdext/source/pdfimport/odf/odfemitter.cxx
@@ -71,17 +71,14 @@ void OdfEmitter::beginTag( const char* pTag, const PropertyMap& rProperties )
     aElement.append(" ");
 
     std::vector<OUString>        aAttributes;
-    PropertyMap::const_iterator       aCurr(rProperties.begin());
-    const PropertyMap::const_iterator aEnd(rProperties.end());
-    while( aCurr != aEnd )
+    for( const auto& rCurr : rProperties )
     {
         OUStringBuffer aAttribute;
-        aAttribute.append(aCurr->first);
+        aAttribute.append(rCurr.first);
         aAttribute.append("=\"");
-        aAttribute.append(aCurr->second);
+        aAttribute.append(rCurr.second);
         aAttribute.append("\" ");
         aAttributes.push_back(aAttribute.makeStringAndClear());
-        ++aCurr;
     }
 
     // since the hash map's sorting is undefined (and varies across
diff --git a/sdext/source/pdfimport/sax/emitcontext.cxx b/sdext/source/pdfimport/sax/emitcontext.cxx
index f21b17e60c88..8eab0e0b5ddf 100644
--- a/sdext/source/pdfimport/sax/emitcontext.cxx
+++ b/sdext/source/pdfimport/sax/emitcontext.cxx
@@ -116,12 +116,12 @@ void SaxEmitter::beginTag( const char* pTag, const PropertyMap& rProperties )
         OStringBuffer aBuf( 1024 );
         aBuf.append( '<' );
         aBuf.append( pTag );
-        for( PropertyMap::const_iterator it = rProperties.begin(); it != rProperties.end(); ++it )
+        for( const auto& rProperty : rProperties )
         {
             aBuf.append( ' ' );
-            aBuf.append( OUStringToOString( it->first, RTL_TEXTENCODING_UTF8 ) );
+            aBuf.append( OUStringToOString( rProperty.first, RTL_TEXTENCODING_UTF8 ) );
             aBuf.append( "=\"" );
-            aBuf.append( OUStringToOString( it->second, RTL_TEXTENCODING_UTF8 ) );
+            aBuf.append( OUStringToOString( rProperty.second, RTL_TEXTENCODING_UTF8 ) );
             aBuf.append( "\"" );
         }
         aBuf.append( ">\n" );
diff --git a/sdext/source/pdfimport/sax/saxattrlist.cxx b/sdext/source/pdfimport/sax/saxattrlist.cxx
index feb6b3ba9385..8efb6b4c9acc 100644
--- a/sdext/source/pdfimport/sax/saxattrlist.cxx
+++ b/sdext/source/pdfimport/sax/saxattrlist.cxx
@@ -26,12 +26,10 @@ namespace pdfi
 SaxAttrList::SaxAttrList( const std::unordered_map< OUString, OUString >& rMap )
 {
     m_aAttributes.reserve(rMap.size());
-    for( std::unordered_map< OUString,
-                        OUString >::const_iterator it = rMap.begin();
-         it != rMap.end(); ++it )
+    for( const auto& rEntry : rMap )
     {
-        m_aIndexMap[ it->first ] = m_aAttributes.size();
-        m_aAttributes.emplace_back( it->first, it->second );
+        m_aIndexMap[ rEntry.first ] = m_aAttributes.size();
+        m_aAttributes.emplace_back( rEntry.first, rEntry.second );
     }
 }
 
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index d845d827ce5d..8182d5fd47eb 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -500,10 +500,9 @@ void DrawXmlOptimizer::visit( PageElement& elem, const std::list< std::unique_pt
             // adjust line height and text items
             fCurLineHeight = 0.0;
             nCurLineElements = 0;
-            for( auto it = pCurPara->Children.begin();
-                 it != pCurPara->Children.end(); ++it )
+            for( auto& rxChild : pCurPara->Children )
             {
-                TextElement* pTestText = dynamic_cast<TextElement*>(it->get());
+                TextElement* pTestText = dynamic_cast<TextElement*>(rxChild.get());
                 if( pTestText )
                 {
                     fCurLineHeight = (fCurLineHeight*double(nCurLineElements) + pTestText->h)/double(nCurLineElements+1);
@@ -985,16 +984,16 @@ void DrawXmlFinalizer::visit( PageElement& elem, const std::list< std::unique_pt
     elem.LeftMargin = elem.w;
     elem.RightMargin = 0;
 
-    for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it )
+    for( const auto& rxChild : elem.Children )
     {
-        if( (*it)->x < elem.LeftMargin )
-            elem.LeftMargin = (*it)->x;
-        if( (*it)->y < elem.TopMargin )
-            elem.TopMargin = (*it)->y;
-        if( (*it)->x + (*it)->w > elem.RightMargin )
-            elem.RightMargin = ((*it)->x + (*it)->w);
-        if( (*it)->y + (*it)->h > elem.BottomMargin )
-            elem.BottomMargin = ((*it)->y + (*it)->h);
+        if( rxChild->x < elem.LeftMargin )
+            elem.LeftMargin = rxChild->x;
+        if( rxChild->y < elem.TopMargin )
+            elem.TopMargin = rxChild->y;
+        if( rxChild->x + rxChild->w > elem.RightMargin )
+            elem.RightMargin = (rxChild->x + rxChild->w);
+        if( rxChild->y + rxChild->h > elem.BottomMargin )
+            elem.BottomMargin = (rxChild->y + rxChild->h);
     }
 
     // transform margins to mm
diff --git a/sdext/source/pdfimport/tree/genericelements.cxx b/sdext/source/pdfimport/tree/genericelements.cxx
index d4eb7dcc34d8..152366d6b4bf 100644
--- a/sdext/source/pdfimport/tree/genericelements.cxx
+++ b/sdext/source/pdfimport/tree/genericelements.cxx
@@ -188,15 +188,14 @@ void ParagraphElement::visitedBy( ElementTreeVisitor&                          r
 
 bool ParagraphElement::isSingleLined( PDFIProcessor const & rProc ) const
 {
-    auto it = Children.begin();
     TextElement* pText = nullptr, *pLastText = nullptr;
-    while( it != Children.end() )
+    for( auto& rxChild : Children )
     {
         // a paragraph containing subparagraphs cannot be single lined
-        if( dynamic_cast< ParagraphElement* >(it->get()) != nullptr )
+        if( dynamic_cast< ParagraphElement* >(rxChild.get()) != nullptr )
             return false;
 
-        pText = dynamic_cast< TextElement* >(it->get());
+        pText = dynamic_cast< TextElement* >(rxChild.get());
         if( pText )
         {
             const FontAttributes& rFont = rProc.getFont( pText->FontId );
@@ -211,7 +210,6 @@ bool ParagraphElement::isSingleLined( PDFIProcessor const & rProc ) const
             else
                 pLastText = pText;
         }
-        ++it;
     }
 
     // a paragraph without a single text is not considered single lined
@@ -221,9 +219,9 @@ bool ParagraphElement::isSingleLined( PDFIProcessor const & rProc ) const
 double ParagraphElement::getLineHeight( PDFIProcessor& rProc ) const
 {
     double line_h = 0;
-    for( auto it = Children.begin(); it != Children.end(); ++it )
+    for( auto& rxChild : Children )
     {
-        ParagraphElement* pPara = dynamic_cast< ParagraphElement* >(it->get());
+        ParagraphElement* pPara = dynamic_cast< ParagraphElement* >(rxChild.get());
         TextElement* pText = nullptr;
         if( pPara )
         {
@@ -231,7 +229,7 @@ double ParagraphElement::getLineHeight( PDFIProcessor& rProc ) const
             if( lh > line_h )
                 line_h = lh;
         }
-        else if( (pText = dynamic_cast< TextElement* >( it->get() )) != nullptr )
+        else if( (pText = dynamic_cast< TextElement* >( rxChild.get() )) != nullptr )
         {
             const FontAttributes& rFont = rProc.getFont( pText->FontId );
             double lh = pText->h;
@@ -247,11 +245,10 @@ double ParagraphElement::getLineHeight( PDFIProcessor& rProc ) const
 TextElement* ParagraphElement::getFirstTextChild() const
 {
     TextElement* pText = nullptr;
-    for( auto it = Children.begin();
-         it != Children.end() && ! pText; ++it )
-    {
+    auto it = std::find_if(Children.begin(), Children.end(),
+        [](const std::unique_ptr<Element>& rxElem) { return dynamic_cast<TextElement*>(rxElem.get()) != nullptr; });
+    if (it != Children.end())
         pText = dynamic_cast<TextElement*>(it->get());
-    }
     return pText;
 }
 
@@ -378,10 +375,9 @@ void PageElement::resolveUnderlines( PDFIProcessor const & rProc )
             u_y = r_x; r_x = l_x; l_x = u_y;
         }
         u_y = aPoly.getB2DPoint(0).getY();
-        for( auto it = Children.begin();
-             it != Children.end(); ++it )
+        for( auto& rxChild : Children )
         {
-            Element* pEle = it->get();
+            Element* pEle = rxChild.get();
             if( pEle->y <= u_y && pEle->y + pEle->h*1.1 >= u_y )
             {
                 // first: is the element underlined completely ?
diff --git a/sdext/source/pdfimport/tree/style.cxx b/sdext/source/pdfimport/tree/style.cxx
index a4314fe61ab9..87d0479a564a 100644
--- a/sdext/source/pdfimport/tree/style.cxx
+++ b/sdext/source/pdfimport/tree/style.cxx
@@ -210,17 +210,16 @@ void StyleContainer::emit( EmitContext&        rContext,
                            ElementTreeVisitor& rContainedElemVisitor )
 {
     std::vector< sal_Int32 > aMasterPageSection, aAutomaticStyleSection, aOfficeStyleSection;
-    for( std::unordered_map< sal_Int32, RefCountedHashedStyle >::iterator it = m_aIdToStyle.begin();
-         it != m_aIdToStyle.end(); ++it )
+    for( const auto& rEntry : m_aIdToStyle )
     {
-        if( ! it->second.style.IsSubStyle )
+        if( ! rEntry.second.style.IsSubStyle )
         {
-            if( it->second.style.Name == "style:master-page" )
-                aMasterPageSection.push_back( it->first );
-            else if( getStyleName( it->first ) == "standard" )
-                aOfficeStyleSection.push_back( it->first );
+            if( rEntry.second.style.Name == "style:master-page" )
+                aMasterPageSection.push_back( rEntry.first );
+            else if( getStyleName( rEntry.first ) == "standard" )
+                aOfficeStyleSection.push_back( rEntry.first );
             else
-                aAutomaticStyleSection.push_back( it->first );
+                aAutomaticStyleSection.push_back( rEntry.first );
         }
     }
 
diff --git a/sdext/source/pdfimport/tree/style.hxx b/sdext/source/pdfimport/tree/style.hxx
index 332fdfb65c80..1eda41ea07a4 100644
--- a/sdext/source/pdfimport/tree/style.hxx
+++ b/sdext/source/pdfimport/tree/style.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SDEXT_SOURCE_PDFIMPORT_TREE_STYLE_HXX
 
 #include <pdfihelper.hxx>
+#include <numeric>
 #include <unordered_map>
 #include <vector>
 #include <rtl/ustring.hxx>
@@ -65,13 +66,10 @@ namespace pdfi
 
             size_t hashCode() const
             {
-                size_t nRet = size_t(Name.hashCode());
-                for( PropertyMap::const_iterator it = Properties.begin();
-                     it != Properties.end(); ++it )
-                {
-                     nRet ^= size_t(it->first.hashCode());
-                     nRet ^= size_t(it->second.hashCode());
-                }
+                size_t nRet = std::accumulate(Properties.begin(), Properties.end(), size_t(Name.hashCode()),
+                    [](const size_t& sum, const PropertyMap::value_type& rEntry) {
+                        return sum ^ size_t(rEntry.first.hashCode()) ^ size_t(rEntry.second.hashCode());
+                    });
                 nRet ^= size_t(Contents.hashCode());
                 nRet ^= size_t(ContainedElement);
                 for( size_t n = 0; n < SubStyles.size(); ++n )
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index 2e83a9b30316..6e37899fbd55 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -321,9 +321,9 @@ void WriterXmlEmitter::visit( DocumentElement& elem, const std::list< std::uniqu
     m_rEmitContext.rEmitter.beginTag( "office:body", PropertyMap() );
     m_rEmitContext.rEmitter.beginTag( "office:text", PropertyMap() );
 
-    for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it )
+    for( auto& rxChild : elem.Children )
     {
-        PageElement* pPage = dynamic_cast<PageElement*>(it->get());
+        PageElement* pPage = dynamic_cast<PageElement*>(rxChild.get());
         if( pPage )
         {
             // emit only page anchored objects
@@ -512,10 +512,9 @@ void WriterXmlOptimizer::visit( PageElement& elem, const std::list< std::unique_
             // adjust line height and text items
             fCurLineHeight = 0.0;
             nCurLineElements = 0;
-            for( auto it = pCurPara->Children.begin();
-                 it != pCurPara->Children.end(); ++it )
+            for( auto& rxChild : pCurPara->Children )
             {
-                TextElement* pTestText = dynamic_cast<TextElement*>(it->get());
+                TextElement* pTestText = dynamic_cast<TextElement*>(rxChild.get());
                 if( pTestText )
                 {
                     fCurLineHeight = (fCurLineHeight*double(nCurLineElements) + pTestText->h)/double(nCurLineElements+1);
@@ -669,60 +668,54 @@ void WriterXmlOptimizer::checkHeaderAndFooter( PageElement& rElem )
      *  - at least lineheight below the previous paragraph
      */
 
+    auto isParagraphElement = [](std::unique_ptr<Element>& rxChild) -> bool {
+        return dynamic_cast<ParagraphElement*>(rxChild.get()) != nullptr;
+    };
+
     // detect header
     // Note: the following assumes that the pages' children have been
     // sorted geometrically
-    auto it = rElem.Children.begin();
-    while( it != rElem.Children.end() )
+    auto it = std::find_if(rElem.Children.begin(), rElem.Children.end(), isParagraphElement);
+    if (it != rElem.Children.end())
     {
         ParagraphElement* pPara = dynamic_cast<ParagraphElement*>(it->get());
-        if( pPara )
+        if( pPara->y+pPara->h < rElem.h*0.15 && pPara->isSingleLined( m_rProcessor ) )
         {
-            if( pPara->y+pPara->h < rElem.h*0.15 && pPara->isSingleLined( m_rProcessor ) )
+            auto next_it = it;
+            ParagraphElement* pNextPara = nullptr;
+            while( ++next_it != rElem.Children.end() && pNextPara == nullptr )
             {
-                auto next_it = it;
-                ParagraphElement* pNextPara = nullptr;
-                while( ++next_it != rElem.Children.end() && pNextPara == nullptr )
-                {
-                    pNextPara = dynamic_cast<ParagraphElement*>(next_it->get());
-                }
-                if( pNextPara && pNextPara->y > pPara->y+pPara->h*2 )
-                {
-                    rElem.HeaderElement = std::move(*it);
-                    pPara->Parent = nullptr;
-                    rElem.Children.erase( it );
-                }
+                pNextPara = dynamic_cast<ParagraphElement*>(next_it->get());
+            }
+            if( pNextPara && pNextPara->y > pPara->y+pPara->h*2 )
+            {
+                rElem.HeaderElement = std::move(*it);
+                pPara->Parent = nullptr;
+                rElem.Children.erase( it );
             }
-            break;
         }
-        ++it;
     }
 
     // detect footer
-    std::list< std::unique_ptr<Element> >::reverse_iterator rit = rElem.Children.rbegin();
-    while( rit != rElem.Children.rend() )
+    auto rit = std::find_if(rElem.Children.rbegin(), rElem.Children.rend(), isParagraphElement);
+    if (rit != rElem.Children.rend())
     {
         ParagraphElement* pPara = dynamic_cast<ParagraphElement*>(rit->get());
-        if( pPara )
+        if( pPara->y > rElem.h*0.85 && pPara->isSingleLined( m_rProcessor ) )
         {
-            if( pPara->y > rElem.h*0.85 && pPara->isSingleLined( m_rProcessor ) )
+            std::list< std::unique_ptr<Element> >::reverse_iterator next_it = rit;
+            ParagraphElement* pNextPara = nullptr;
+            while( ++next_it != rElem.Children.rend() && pNextPara == nullptr )
             {
-                std::list< std::unique_ptr<Element> >::reverse_iterator next_it = rit;
-                ParagraphElement* pNextPara = nullptr;
-                while( ++next_it != rElem.Children.rend() && pNextPara == nullptr )
-                {
-                    pNextPara = dynamic_cast<ParagraphElement*>(next_it->get());
-                }
-                if( pNextPara && pNextPara->y < pPara->y-pPara->h*2 )
-                {
-                    rElem.FooterElement = std::move(*rit);
-                    pPara->Parent = nullptr;
-                    rElem.Children.erase( std::next(rit).base() );
-                }
+                pNextPara = dynamic_cast<ParagraphElement*>(next_it->get());
+            }
+            if( pNextPara && pNextPara->y < pPara->y-pPara->h*2 )
+            {
+                rElem.FooterElement = std::move(*rit);
+                pPara->Parent = nullptr;
+                rElem.Children.erase( std::next(rit).base() );
             }
-            break;
         }
-        ++rit;
     }
 }
 
@@ -1099,20 +1092,20 @@ void WriterXmlFinalizer::visit( PageElement& elem, const std::list< std::unique_
     elem.RightMargin = 0;
     // first element should be a paragraph
     ParagraphElement* pFirstPara = nullptr;
-    for( auto it = elem.Children.begin(); it != elem.Children.end(); ++it )
+    for( auto& rxChild : elem.Children )
     {
-        if( dynamic_cast<ParagraphElement*>( it->get() ) )
+        if( dynamic_cast<ParagraphElement*>( rxChild.get() ) )
         {
-            if( (*it)->x < elem.LeftMargin )
-                elem.LeftMargin = (*it)->x;
-            if( (*it)->y < elem.TopMargin )
-                elem.TopMargin = (*it)->y;
-            if( (*it)->x + (*it)->w > elem.w - elem.RightMargin )
-                elem.RightMargin = elem.w - ((*it)->x + (*it)->w);
-            if( (*it)->y + (*it)->h > elem.h - elem.BottomMargin )
-                elem.BottomMargin = elem.h - ((*it)->y + (*it)->h);
+            if( rxChild->x < elem.LeftMargin )
+                elem.LeftMargin = rxChild->x;
+            if( rxChild->y < elem.TopMargin )
+                elem.TopMargin = rxChild->y;
+            if( rxChild->x + rxChild->w > elem.w - elem.RightMargin )
+                elem.RightMargin = elem.w - (rxChild->x + rxChild->w);
+            if( rxChild->y + rxChild->h > elem.h - elem.BottomMargin )
+                elem.BottomMargin = elem.h - (rxChild->y + rxChild->h);
             if( ! pFirstPara )
-                pFirstPara = dynamic_cast<ParagraphElement*>( it->get() );
+                pFirstPara = dynamic_cast<ParagraphElement*>( rxChild.get() );
         }
     }
     if( elem.HeaderElement && elem.HeaderElement->y < elem.TopMargin )
diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx
index 08dcb4ea18be..8eccf5ff63e3 100644
--- a/sdext/source/presenter/PresenterAccessibility.cxx
+++ b/sdext/source/presenter/PresenterAccessibility.cxx
@@ -1159,21 +1159,17 @@ void PresenterAccessible::AccessibleObject::FireAccessibleEvent (
     aEventObject.OldValue = rOldValue;
 
     ::std::vector<Reference<XAccessibleEventListener> > aListenerCopy(maListeners);
-    for (::std::vector<Reference<XAccessibleEventListener> >::const_iterator
-             iListener(aListenerCopy.begin()),
-             iEnd(aListenerCopy.end());
-         iListener!=iEnd;
-         ++iListener)
+    for (const auto& rxListener : aListenerCopy)
     {
         try
         {
-            (*iListener)->notifyEvent(aEventObject);
+            rxListener->notifyEvent(aEventObject);
         }
         catch (const lang::DisposedException&)
         {
             // Listener has been disposed and should have been removed
             // already.
-            removeAccessibleEventListener(*iListener);
+            removeAccessibleEventListener(rxListener);
         }
         catch (const Exception&)
         {
@@ -1314,25 +1310,16 @@ AccessibleRelation SAL_CALL AccessibleRelationSet::getRelation (sal_Int32 nIndex
 
 sal_Bool SAL_CALL AccessibleRelationSet::containsRelation (sal_Int16 nRelationType)
 {
-    for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
-         iRelation!=maRelations.end();
-         ++iRelation)
-    {
-        if (iRelation->RelationType == nRelationType)
-            return true;
-    }
-    return false;
+    return std::any_of(maRelations.begin(), maRelations.end(),
+        [nRelationType](const AccessibleRelation& rRelation) { return rRelation.RelationType == nRelationType; });
 }
 
 AccessibleRelation SAL_CALL AccessibleRelationSet::getRelationByType (sal_Int16 nRelationType)
 {
-    for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
-         iRelation!=maRelations.end();
-         ++iRelation)
-    {
-        if (iRelation->RelationType == nRelationType)
-            return *iRelation;
-    }
+    auto iRelation = std::find_if(maRelations.begin(), maRelations.end(),
+        [nRelationType](const AccessibleRelation& rRelation) { return rRelation.RelationType == nRelationType; });
+    if (iRelation != maRelations.end())
+        return *iRelation;
     return AccessibleRelation();
 }
 
@@ -1727,12 +1714,9 @@ void AccessibleNotes::SetTextView (
 
         // Dispose the old children. (This will remove them from the focus
         // manager).
-        for (std::vector<rtl::Reference<AccessibleObject> >::const_iterator
-                 iChild(aChildren.begin()), iEnd(aChildren.end());
-             iChild!=iEnd;
-             ++iChild)
+        for (const auto& rxChild : aChildren)
         {
-            Reference<lang::XComponent> xComponent (static_cast<XWeak*>(iChild->get()), UNO_QUERY);
+            Reference<lang::XComponent> xComponent (static_cast<XWeak*>(rxChild.get()), UNO_QUERY);
             if (xComponent.is())
                 xComponent->dispose();
         }
@@ -1756,13 +1740,9 @@ void AccessibleNotes::SetWindow (
 
     // Set the windows at the children as well, so that every paragraph can
     // setup its geometry.
-    for (::std::vector<rtl::Reference<AccessibleObject> >::const_iterator
-             iChild(maChildren.begin()),
-             iEnd(maChildren.end());
-         iChild!=iEnd;
-         ++iChild)
+    for (auto& rxChild : maChildren)
     {
-        (*iChild)->SetWindow(rxContentWindow, rxBorderWindow);
+        rxChild->SetWindow(rxContentWindow, rxBorderWindow);
     }
 }
 
@@ -1853,14 +1833,10 @@ void AccessibleFocusManager::FocusObject (
     const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
 {
     // Remove the focus of any of the other focusable objects.
-    for (::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::const_iterator
-             iObject (maFocusableObjects.begin()),
-             iEnd (maFocusableObjects.end());
-         iObject != iEnd;
-         ++iObject)
+    for (auto& rxObject : maFocusableObjects)
     {
-        if (*iObject!=rpObject)
-            (*iObject)->SetIsFocused(false);
+        if (rxObject!=rpObject)
+            rxObject->SetIsFocused(false);
     }
 
     if (rpObject.is())
diff --git a/sdext/source/presenter/PresenterController.cxx b/sdext/source/presenter/PresenterController.cxx
index dd00b3955e64..1a1c6bbc9b08 100644
--- a/sdext/source/presenter/PresenterController.cxx
+++ b/sdext/source/presenter/PresenterController.cxx
@@ -361,14 +361,13 @@ void PresenterController::UpdatePaneTitles()
     }
 
     // Replace the placeholders with their current values.
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
+    for (auto& rxPane : mpPaneContainer->maPanes)
     {
-        OSL_ASSERT(*iPane != nullptr);
+        OSL_ASSERT(rxPane != nullptr);
 
         OUString sTemplate (IsAccessibilityActive()
-            ? (*iPane)->msAccessibleTitleTemplate
-            : (*iPane)->msTitleTemplate);
+            ? rxPane->msAccessibleTitleTemplate
+            : rxPane->msTitleTemplate);
         if (sTemplate.isEmpty())
             continue;
 
@@ -406,19 +405,18 @@ void PresenterController::UpdatePaneTitles()
             }
         }
 
-        (*iPane)->msTitle = sResult.makeStringAndClear();
-        if ((*iPane)->mxPane.is())
-            (*iPane)->mxPane->SetTitle((*iPane)->msTitle);
+        rxPane->msTitle = sResult.makeStringAndClear();
+        if (rxPane->mxPane.is())
+            rxPane->mxPane->SetTitle(rxPane->msTitle);
     }
 }
 
 void PresenterController::UpdateViews()
 {
     // Tell all views about the slides they should display.
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
+    for (const auto& rxPane : mpPaneContainer->maPanes)
     {
-        Reference<drawing::XDrawView> xDrawView ((*iPane)->mxView, UNO_QUERY);
+        Reference<drawing::XDrawView> xDrawView (rxPane->mxView, UNO_QUERY);
         if (xDrawView.is())
             xDrawView->setCurrentPage(mxCurrentSlide);
     }
@@ -667,12 +665,10 @@ void PresenterController::RequestViews (
     const bool bIsNotesViewActive,
     const bool bIsHelpViewActive)
 {
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
+    for (const auto& rxPane : mpPaneContainer->maPanes)
     {
         bool bActivate (true);
-        const OUString sViewURL ((*iPane)->msViewURL);
+        const OUString sViewURL (rxPane->msViewURL);
         if (sViewURL == PresenterViewFactory::msNotesViewURL)
         {
             bActivate = bIsNotesViewActive && !bIsSlideSorterActive && !bIsHelpViewActive;
@@ -825,13 +821,12 @@ void SAL_CALL PresenterController::frameAction (
 void SAL_CALL PresenterController::keyPressed (const awt::KeyEvent& rEvent)
 {
     // Tell all views about the unhandled key event.
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
+    for (const auto& rxPane : mpPaneContainer->maPanes)
     {
-        if ( ! (*iPane)->mbIsActive)
+        if ( ! rxPane->mbIsActive)
             continue;
 
-        Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
+        Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
         if (xKeyListener.is())
             xKeyListener->keyPressed(rEvent);
     }
@@ -978,13 +973,12 @@ void SAL_CALL PresenterController::keyReleased (const awt::KeyEvent& rEvent)
 
         default:
             // Tell all views about the unhandled key event.
-            PresenterPaneContainer::PaneList::const_iterator iPane;
-            for (iPane=mpPaneContainer->maPanes.begin(); iPane!=mpPaneContainer->maPanes.end(); ++iPane)
+            for (const auto& rxPane : mpPaneContainer->maPanes)
             {
-                if ( ! (*iPane)->mbIsActive)
+                if ( ! rxPane->mbIsActive)
                     continue;
 
-                Reference<awt::XKeyListener> xKeyListener ((*iPane)->mxView, UNO_QUERY);
+                Reference<awt::XKeyListener> xKeyListener (rxPane->mxView, UNO_QUERY);
                 if (xKeyListener.is())
                     xKeyListener->keyReleased(rEvent);
             }
diff --git a/sdext/source/presenter/PresenterHelpView.cxx b/sdext/source/presenter/PresenterHelpView.cxx
index 03f68efd8e03..0bce7633dcec 100644
--- a/sdext/source/presenter/PresenterHelpView.cxx
+++ b/sdext/source/presenter/PresenterHelpView.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/rendering/TextDirection.hpp>
 #include <com/sun/star/util/Color.hpp>
 #include <algorithm>
+#include <numeric>
 #include <vector>
 
 using namespace ::com::sun::star;
@@ -295,9 +296,7 @@ void PresenterHelpView::Paint (const awt::Rectangle& rUpdateBox)
 
     // Paint text.
     double nY (gnVerticalBorder);
-    TextContainer::const_iterator iBlock (mpTextContainer->begin());
-    TextContainer::const_iterator iBlockEnd (mpTextContainer->end());
-    for ( ; iBlock!=iBlockEnd; ++iBlock)
+    for (const auto& rxBlock : *mpTextContainer)
     {
         sal_Int32 LeftX1 = gnHorizontalGap;
         sal_Int32 LeftX2 = aWindowBox.Width/2 - gnHorizontalGap;
@@ -313,7 +312,7 @@ void PresenterHelpView::Paint (const awt::Rectangle& rUpdateBox)
             RightX2 = aWindowBox.Width/2 - gnHorizontalGap;
         }
         const double nLeftHeight (
-            (*iBlock)->maLeft.Paint(mxCanvas,
+            rxBlock->maLeft.Paint(mxCanvas,
                 geometry::RealRectangle2D(
                         LeftX1,
                         nY,
@@ -324,7 +323,7 @@ void PresenterHelpView::Paint (const awt::Rectangle& rUpdateBox)
                 aRenderState,
                 mpFont->mxFont));
         const double nRightHeight (
-            (*iBlock)->maRight.Paint(mxCanvas,
+            rxBlock->maRight.Paint(mxCanvas,
                 geometry::RealRectangle2D(
                         RightX1,
                         nY,
@@ -388,13 +387,12 @@ void PresenterHelpView::CheckFontSize()
     // small enough.  Restrict the number of loops.
     for (int nLoopCount=0; nLoopCount<5; ++nLoopCount)
     {
-        double nY (0.0);
-        TextContainer::iterator iBlock (mpTextContainer->begin());
-        TextContainer::const_iterator iBlockEnd (mpTextContainer->end());
-        for ( ; iBlock!=iBlockEnd; ++iBlock)
-            nY += ::std::max(
-                (*iBlock)->maLeft.GetHeight(),
-                (*iBlock)->maRight.GetHeight());
+        double nY = std::accumulate(mpTextContainer->begin(), mpTextContainer->end(), double(0),
+            [](const double& sum, const std::shared_ptr<Block>& rxBlock) {
+                return sum + std::max(
+                    rxBlock->maLeft.GetHeight(),
+                    rxBlock->maRight.GetHeight());
+            });
 
         const double nHeightDifference (nY - (mnSeparatorY-gnVerticalBorder));
         if (nHeightDifference <= 0 && nHeightDifference > -50)
@@ -418,8 +416,8 @@ void PresenterHelpView::CheckFontSize()
         mpFont->PrepareFont(mxCanvas);
 
         // Reformat blocks.
-        for (iBlock=mpTextContainer->begin(); iBlock!=iBlockEnd; ++iBlock)
-            (*iBlock)->Update(mpFont->mxFont, mnMaximalWidth);
+        for (auto& rxBlock : *mpTextContainer)
+            rxBlock->Update(mpFont->mxFont, mnMaximalWidth);
     }
 
     if (nBestSize != mpFont->mnSize)
@@ -429,13 +427,9 @@ void PresenterHelpView::CheckFontSize()
         mpFont->PrepareFont(mxCanvas);
 
         // Reformat blocks.
-        for (TextContainer::iterator
-                 iBlock (mpTextContainer->begin()),
-                 iEnd (mpTextContainer->end());
-             iBlock!=iEnd;
-             ++iBlock)
+        for (auto& rxBlock : *mpTextContainer)
         {
-            (*iBlock)->Update(mpFont->mxFont, mnMaximalWidth);
+            rxBlock->Update(mpFont->mxFont, mnMaximalWidth);
         }
     }
 }
@@ -564,9 +558,7 @@ double LineDescriptorList::Paint(
         return 0;
 
     double nY (rBBox.Y1);
-    vector<LineDescriptor>::const_iterator iLine (mpLineDescriptors->begin());
-    vector<LineDescriptor>::const_iterator iEnd (mpLineDescriptors->end());
-    for ( ; iLine!=iEnd; ++iLine)
+    for (const auto& rLine : *mpLineDescriptors)
     {
         double nX;
         /// check whether RTL interface or not
@@ -574,18 +566,18 @@ double LineDescriptorList::Paint(
         {
             nX = rBBox.X1;
             if ( ! bFlushLeft)
-                nX = rBBox.X2 - iLine->maSize.Width;
+                nX = rBBox.X2 - rLine.maSize.Width;
         }
         else
         {
-            nX=rBBox.X2 - iLine->maSize.Width;
+            nX=rBBox.X2 - rLine.maSize.Width;
             if ( ! bFlushLeft)
                 nX = rBBox.X1;
         }
         rRenderState.AffineTransform.m02 = nX;
-        rRenderState.AffineTransform.m12 = nY + iLine->maSize.Height - iLine->mnVerticalOffset;
+        rRenderState.AffineTransform.m12 = nY + rLine.maSize.Height - rLine.mnVerticalOffset;
 
-        const rendering::StringContext aContext (iLine->msLine, 0, iLine->msLine.getLength());
+        const rendering::StringContext aContext (rLine.msLine, 0, rLine.msLine.getLength());
         Reference<rendering::XTextLayout> xLayout (
         rxFont->createTextLayout(aContext, rendering::TextDirection::WEAK_LEFT_TO_RIGHT, 0));
         rxCanvas->drawTextLayout (
@@ -593,7 +585,7 @@ double LineDescriptorList::Paint(
             rViewState,
             rRenderState);
 
-        nY += iLine->maSize.Height * 1.2;
+        nY += rLine.maSize.Height * 1.2;
     }
 
     return nY - rBBox.Y1;
@@ -601,13 +593,10 @@ double LineDescriptorList::Paint(
 
 double LineDescriptorList::GetHeight() const
 {
-    double nHeight (0);
-    vector<LineDescriptor>::const_iterator iLine (mpLineDescriptors->begin());
-    vector<LineDescriptor>::const_iterator iEnd (mpLineDescriptors->end());
-    for ( ; iLine!=iEnd; ++iLine)
-        nHeight += iLine->maSize.Height * 1.2;
-
-    return nHeight;
+    return std::accumulate(mpLineDescriptors->begin(), mpLineDescriptors->end(), double(0),
+        [](const double& nHeight, const LineDescriptor& rLine) {
+            return nHeight + rLine.maSize.Height * 1.2;
+        });
 }
 
 void LineDescriptorList::Update (
diff --git a/sdext/source/presenter/PresenterPaneContainer.cxx b/sdext/source/presenter/PresenterPaneContainer.cxx
index 1fe6c15deb38..5078ff08bf57 100644
--- a/sdext/source/presenter/PresenterPaneContainer.cxx
+++ b/sdext/source/presenter/PresenterPaneContainer.cxx
@@ -94,11 +94,9 @@ void PresenterPaneContainer::PreparePane (
 
 void SAL_CALL PresenterPaneContainer::disposing()
 {
-    PaneList::iterator iPane (maPanes.begin());
-    PaneList::const_iterator iEnd (maPanes.end());
-    for ( ; iPane!=iEnd; ++iPane)
-        if ((*iPane)->mxPaneId.is())
-            RemovePane((*iPane)->mxPaneId);
+    for (const auto& rxPane : maPanes)
+        if (rxPane->mxPaneId.is())
+            RemovePane(rxPane->mxPaneId);
 }
 
 PresenterPaneContainer::SharedPaneDescriptor
@@ -242,69 +240,53 @@ PresenterPaneContainer::SharedPaneDescriptor
 PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindBorderWindow (
     const Reference<awt::XWindow>& rxBorderWindow)
 {
-    PaneList::const_iterator iPane;
-    PaneList::iterator iEnd (maPanes.end());
-    for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-    {
-        if ((*iPane)->mxBorderWindow == rxBorderWindow)
-            return *iPane;
-    }
+    auto iPane = std::find_if(maPanes.begin(), maPanes.end(),
+        [&rxBorderWindow](const SharedPaneDescriptor& rxPane) { return rxPane->mxBorderWindow == rxBorderWindow; });
+    if (iPane != maPanes.end())
+        return *iPane;
     return SharedPaneDescriptor();
 }
 
 PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindContentWindow (
     const Reference<awt::XWindow>& rxContentWindow)
 {
-    PaneList::const_iterator iPane;
-    PaneList::iterator iEnd (maPanes.end());
-    for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-    {
-        if ((*iPane)->mxContentWindow == rxContentWindow)
-            return *iPane;
-    }
+    auto iPane = std::find_if(maPanes.begin(), maPanes.end(),
+        [&rxContentWindow](const SharedPaneDescriptor& rxPane) { return rxPane->mxContentWindow == rxContentWindow; });
+    if (iPane != maPanes.end())
+        return *iPane;
     return SharedPaneDescriptor();
 }
 
 PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindPaneURL (
     const OUString& rsPaneURL)
 {
-    PaneList::const_iterator iPane;
-    PaneList::const_iterator iEnd (maPanes.end());
-    for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-    {
-        if ((*iPane)->mxPaneId->getResourceURL() == rsPaneURL)
-            return *iPane;
-    }
+    auto iPane = std::find_if(maPanes.begin(), maPanes.end(),
+        [&rsPaneURL](const SharedPaneDescriptor& rxPane) { return rxPane->mxPaneId->getResourceURL() == rsPaneURL; });
+    if (iPane != maPanes.end())
+        return *iPane;
     return SharedPaneDescriptor();
 }
 
 PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindPaneId (
     const Reference<XResourceId>& rxPaneId)
 {
-    PaneList::iterator iEnd (maPanes.end());
-
     if ( ! rxPaneId.is())
         return SharedPaneDescriptor();
 
-    PaneList::iterator iPane;
-    for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-    {
-        if (rxPaneId->compareTo((*iPane)->mxPaneId) == 0)
-            return *iPane;
-    }
+    auto iPane = std::find_if(maPanes.begin(), maPanes.end(),
+        [&rxPaneId](const SharedPaneDescriptor& rxPane) { return rxPaneId->compareTo(rxPane->mxPaneId) == 0; });
+    if (iPane != maPanes.end())
+        return *iPane;
     return SharedPaneDescriptor();
 }
 
 PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::FindViewURL (
     const OUString& rsViewURL)
 {
-    PaneList::iterator iEnd (maPanes.end());
-    PaneList::iterator iPane;
-    for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-    {
-        if (rsViewURL == (*iPane)->msViewURL)
-            return *iPane;
-    }
+    auto iPane = std::find_if(maPanes.begin(), maPanes.end(),
+        [&rsViewURL](const SharedPaneDescriptor& rxPane) { return rsViewURL == rxPane->msViewURL; });
+    if (iPane != maPanes.end())
+        return *iPane;
     return SharedPaneDescriptor();
 }
 
@@ -322,11 +304,9 @@ void PresenterPaneContainer::ToTop (const SharedPaneDescriptor& rpDescriptor)
     if (rpDescriptor.get() != nullptr)
     {
         // Find iterator for pDescriptor.
-        PaneList::iterator iPane;
         PaneList::iterator iEnd (maPanes.end());
-        for (iPane=maPanes.begin(); iPane!=iEnd; ++iPane)
-            if (iPane->get() == rpDescriptor.get())
-                break;
+        auto iPane = std::find_if(maPanes.begin(), iEnd,
+            [&rpDescriptor](SharedPaneDescriptor& rxPane) { return rxPane.get() == rpDescriptor.get(); });
         OSL_ASSERT(iPane!=iEnd);
         if (iPane == iEnd)
             return;
diff --git a/sdext/source/presenter/PresenterPaneFactory.cxx b/sdext/source/presenter/PresenterPaneFactory.cxx
index 8160b9431745..9041de148bee 100644
--- a/sdext/source/presenter/PresenterPaneFactory.cxx
+++ b/sdext/source/presenter/PresenterPaneFactory.cxx
@@ -121,11 +121,9 @@ void SAL_CALL PresenterPaneFactory::disposing()
     // Dispose the panes in the cache.
     if (mpResourceCache != nullptr)
     {
-        ResourceContainer::const_iterator iPane (mpResourceCache->begin());
-        ResourceContainer::const_iterator iEnd (mpResourceCache->end());
-        for ( ; iPane!=iEnd; ++iPane)
+        for (const auto& rxPane : *mpResourceCache)
         {
-            Reference<lang::XComponent> xPaneComponent (iPane->second, UNO_QUERY);
+            Reference<lang::XComponent> xPaneComponent (rxPane.second, UNO_QUERY);
             if (xPaneComponent.is())
                 xPaneComponent->dispose();
         }
diff --git a/sdext/source/presenter/PresenterTextView.cxx b/sdext/source/presenter/PresenterTextView.cxx
index 731aee81e911..b99a482cda82 100644
--- a/sdext/source/presenter/PresenterTextView.cxx
+++ b/sdext/source/presenter/PresenterTextView.cxx
@@ -24,6 +24,7 @@
 
 #include <algorithm>
 #include <cmath>
+#include <numeric>
 
 #include <sal/log.hxx>
 
@@ -148,13 +149,9 @@ void PresenterTextView::SetLocation (const css::geometry::RealPoint2D& rLocation
 {
     maLocation = rLocation;
 
-    for (::std::vector<SharedPresenterTextParagraph>::iterator
-             iParagraph(maParagraphs.begin()),
-             iEnd(maParagraphs.end());
-         iParagraph!=iEnd;
-         ++iParagraph)
+    for (auto& rxParagraph : maParagraphs)
     {
-        (*iParagraph)->SetOrigin(
+        rxParagraph->SetOrigin(
             maLocation.X - mnLeftOffset,
             maLocation.Y - mnTopOffset);
     }
@@ -168,8 +165,6 @@ void PresenterTextView::SetSize (const css::geometry::RealSize2D& rSize)
 
 double PresenterTextView::GetTotalTextHeight()
 {
-    double nTotalHeight (0);
-
     if (mbIsFormatPending)
     {
         if ( ! mpFont->PrepareFont(mxCanvas))
@@ -177,16 +172,10 @@ double PresenterTextView::GetTotalTextHeight()
         Format();
     }
 
-    for (::std::vector<SharedPresenterTextParagraph>::iterator
-             iParagraph(maParagraphs.begin()),
-             iEnd(maParagraphs.end());
-         iParagraph!=iEnd;
-         ++iParagraph)
-    {
-        nTotalHeight += (*iParagraph)->GetTotalTextHeight();
-    }
-
-    return nTotalHeight;
+    return std::accumulate(maParagraphs.begin(), maParagraphs.end(), double(0),
+        [](const double& nTotalHeight, const SharedPresenterTextParagraph& rxParagraph) {
+            return nTotalHeight + rxParagraph->GetTotalTextHeight();
+        });
 }
 
 void PresenterTextView::SetFont (const PresenterTheme::SharedFontDescriptor& rpFont)
@@ -337,13 +326,9 @@ void PresenterTextView::Paint (
         rendering::CompositeOperation::SOURCE);
     PresenterCanvasHelper::SetDeviceColor(aRenderState, mpFont->mnColor);
 
-    for (::std::vector<SharedPresenterTextParagraph>::const_iterator
-             iParagraph(maParagraphs.begin()),
-             iEnd(maParagraphs.end());
-         iParagraph!=iEnd;
-         ++iParagraph)
+    for (const auto& rxParagraph : maParagraphs)
     {
-        (*iParagraph)->Paint(
+        rxParagraph->Paint(
             mxCanvas,
             maSize,
             mpFont,
@@ -421,14 +406,10 @@ void PresenterTextView::Format()
     mbIsFormatPending = false;
 
     double nY (0);
-    for (::std::vector<SharedPresenterTextParagraph>::const_iterator
-             iParagraph(maParagraphs.begin()),
-             iEnd(maParagraphs.end());
-         iParagraph!=iEnd;
-         ++iParagraph)
+    for (const auto& rxParagraph : maParagraphs)
     {
-        (*iParagraph)->Format(nY, maSize.Width, mpFont);
-        nY += (*iParagraph)->GetTotalTextHeight();
+        rxParagraph->Format(nY, maSize.Width, mpFont);
+        nY += rxParagraph->GetTotalTextHeight();
     }
 
     if (maTextChangeBroadcaster)
@@ -821,21 +802,16 @@ TextSegment PresenterTextParagraph::GetTextSegment (
 
         case AccessibleTextType::LINE:
         {
-            for (::std::vector<Line>::const_iterator
-                     iLine(maLines.begin()),
-                     iEnd(maLines.end());
-                 iLine!=iEnd;
-                 ++iLine)
+            auto iLine = std::find_if(maLines.begin(), maLines.end(),
+                [nIndex](const Line& rLine) { return nIndex < rLine.mnLineEndCharacterIndex; });
+            if (iLine != maLines.end())
             {
-                if (nIndex < iLine->mnLineEndCharacterIndex)
-                {
-                    return TextSegment(
-                        msParagraphText.copy(
-                            iLine->mnLineStartCharacterIndex,
-                            iLine->mnLineEndCharacterIndex - iLine->mnLineStartCharacterIndex),
+                return TextSegment(
+                    msParagraphText.copy(
                         iLine->mnLineStartCharacterIndex,
-                        iLine->mnLineEndCharacterIndex);
-                }
+                        iLine->mnLineEndCharacterIndex - iLine->mnLineStartCharacterIndex),
+                    iLine->mnLineStartCharacterIndex,
+                    iLine->mnLineEndCharacterIndex);
             }
         }
         break;
diff --git a/sdext/source/presenter/PresenterTheme.cxx b/sdext/source/presenter/PresenterTheme.cxx
index 6e5270b91432..bb80862ebc30 100644
--- a/sdext/source/presenter/PresenterTheme.cxx
+++ b/sdext/source/presenter/PresenterTheme.cxx
@@ -851,13 +851,10 @@ void PaneStyleContainer::ProcessPaneStyle(
     if (rValues[1] >>= sParentStyleName)
     {
         // Find parent style.
-        ::std::vector<SharedPaneStyle>::const_iterator iStyle;
-        for (iStyle=mStyles.begin(); iStyle!=mStyles.end(); ++iStyle)
-            if ((*iStyle)->msStyleName == sParentStyleName)
-            {
-                pStyle->mpParentStyle = *iStyle;
-                break;
-            }
+        auto iStyle = std::find_if(mStyles.begin(), mStyles.end(),
+            [&sParentStyleName](const SharedPaneStyle& rxStyle) { return rxStyle->msStyleName == sParentStyleName; });
+        if (iStyle != mStyles.end())
+            pStyle->mpParentStyle = *iStyle;
     }
 
     Reference<container::XHierarchicalNameAccess> xFontNode (rValues[2], UNO_QUERY);
@@ -891,10 +888,10 @@ void PaneStyleContainer::ProcessPaneStyle(
 
 SharedPaneStyle PaneStyleContainer::GetPaneStyle (const OUString& rsStyleName) const
 {
-    ::std::vector<SharedPaneStyle>::const_iterator iEnd (mStyles.end());
-    for (::std::vector<SharedPaneStyle>::const_iterator iStyle=mStyles.begin(); iStyle!=iEnd; ++iStyle)
-        if ((*iStyle)->msStyleName == rsStyleName)
-            return *iStyle;
+    auto iStyle = std::find_if(mStyles.begin(), mStyles.end(),
+        [&rsStyleName](const SharedPaneStyle& rxStyle) { return rxStyle->msStyleName == rsStyleName; });
+    if (iStyle != mStyles.end())
+        return *iStyle;
     return SharedPaneStyle();
 }
 
@@ -971,15 +968,14 @@ void ViewStyleContainer::ProcessViewStyle(
         >>= sParentStyleName)
     {
         // Find parent style.
-        ::std::vector<SharedViewStyle>::const_iterator iStyle;
-        for (iStyle=mStyles.begin(); iStyle!=mStyles.end(); ++iStyle)
-            if ((*iStyle)->msStyleName == sParentStyleName)
-            {
-                pStyle->mpParentStyle = *iStyle;
-                pStyle->mpFont = (*iStyle)->mpFont;
-                pStyle->mpBackground = (*iStyle)->mpBackground;
-                break;
-            }
+        auto iStyle = std::find_if(mStyles.begin(), mStyles.end(),
+            [&sParentStyleName](const SharedViewStyle& rxStyle) { return rxStyle->msStyleName == sParentStyleName; });
+        if (iStyle != mStyles.end())
+        {
+            pStyle->mpParentStyle = *iStyle;
+            pStyle->mpFont = (*iStyle)->mpFont;
+            pStyle->mpBackground = (*iStyle)->mpBackground;
+        }
     }
 
     const OUString sPathToFont; // empty string
@@ -1007,10 +1003,10 @@ void ViewStyleContainer::ProcessViewStyle(
 
 SharedViewStyle ViewStyleContainer::GetViewStyle (const OUString& rsStyleName) const
 {
-    ::std::vector<SharedViewStyle>::const_iterator iEnd (mStyles.end());
-    for (::std::vector<SharedViewStyle>::const_iterator iStyle=mStyles.begin(); iStyle!=iEnd; ++iStyle)
-        if ((*iStyle)->msStyleName == rsStyleName)
-            return *iStyle;
+    auto iStyle = std::find_if(mStyles.begin(), mStyles.end(),
+        [&rsStyleName](const SharedViewStyle& rxStyle) { return rxStyle->msStyleName == rsStyleName; });
+    if (iStyle != mStyles.end())
+        return *iStyle;
     return SharedViewStyle();
 }
 
diff --git a/sdext/source/presenter/PresenterTimer.cxx b/sdext/source/presenter/PresenterTimer.cxx
index d63ebd8068a9..7a1d74217a4e 100644
--- a/sdext/source/presenter/PresenterTimer.cxx
+++ b/sdext/source/presenter/PresenterTimer.cxx
@@ -240,16 +240,10 @@ void TimerScheduler::CancelTask (const sal_Int32 nTaskId)
     // cancel.
     {
         ::osl::MutexGuard aGuard (maTaskContainerMutex);
-        TaskContainer::iterator iTask (maScheduledTasks.begin());
-        TaskContainer::const_iterator iEnd (maScheduledTasks.end());
-        for ( ; iTask!=iEnd; ++iTask)
-        {
-            if ((*iTask)->mnTaskId == nTaskId)
-            {
-                maScheduledTasks.erase(iTask);
-                break;
-            }
-        }
+        auto iTask = std::find_if(maScheduledTasks.begin(), maScheduledTasks.end(),
+            [nTaskId](const SharedTimerTask& rxTask) { return rxTask->mnTaskId == nTaskId; });
+        if (iTask != maScheduledTasks.end())
+            maScheduledTasks.erase(iTask);
     }
 
     // The task that is to be canceled may be currently about to be
@@ -577,14 +571,9 @@ void SAL_CALL PresenterClockTimer::notify (const css::uno::Any&)
             ::std::back_inserter(aListenerCopy));
     }
 
-    if (!aListenerCopy.empty())
+    for (const auto& rxListener : aListenerCopy)
     {
-        ListenerContainer::const_iterator iListener;
-        ListenerContainer::const_iterator iEnd (aListenerCopy.end());
-        for (iListener=aListenerCopy.begin(); iListener!=iEnd; ++iListener)
-        {
-            (*iListener)->TimeHasChanged(maDateTime);
-        }
+        rxListener->TimeHasChanged(maDateTime);
     }
 }
 
diff --git a/sdext/source/presenter/PresenterToolBar.cxx b/sdext/source/presenter/PresenterToolBar.cxx
index 33fb79220f70..37e5bc3a3da1 100644
--- a/sdext/source/presenter/PresenterToolBar.cxx
+++ b/sdext/source/presenter/PresenterToolBar.cxx
@@ -416,18 +416,13 @@ void SAL_CALL PresenterToolBar::disposing()
     }
 
     // Dispose tool bar elements.
-    ElementContainer::iterator iPart (maElementContainer.begin());
-    ElementContainer::const_iterator iEnd (maElementContainer.end());
-    for ( ; iPart!=iEnd; ++iPart)
+    for (const auto& rxPart : maElementContainer)
     {
-        OSL_ASSERT(*iPart != nullptr);
-        ElementContainerPart::iterator iElement ((*iPart)->begin());
-        ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
-        for ( ; iElement!=iPartEnd; ++iElement)
+        OSL_ASSERT(rxPart != nullptr);
+        for (rtl::Reference<Element>& pElement : *rxPart)
         {
-            if (iElement->get() != nullptr)
+            if (pElement.get() != nullptr)
             {
-                ::rtl::Reference<Element> pElement (*iElement);
                 Reference<lang::XComponent> xComponent (
                     static_cast<XWeak*>(pElement.get()), UNO_QUERY);
                 if (xComponent.is())
@@ -688,27 +683,24 @@ void PresenterToolBar::Layout (
     mbIsLayoutPending = false;
 
     const awt::Rectangle aWindowBox (mxWindow->getPosSize());
-    ElementContainer::iterator iPart;
-    ElementContainer::iterator iEnd (maElementContainer.end());
-    ElementContainer::iterator iBegin (maElementContainer.begin());
     ::std::vector<geometry::RealSize2D> aPartSizes (maElementContainer.size());
     geometry::RealSize2D aTotalSize (0,0);
     bool bIsHorizontal (true);
-    sal_Int32 nIndex;
+    sal_Int32 nIndex (0);
     double nTotalHorizontalGap (0);
     sal_Int32 nGapCount (0);
-    for (iPart=maElementContainer.begin(),nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
+    for (const auto& rxPart : maElementContainer)
     {
-        geometry::RealSize2D aSize (CalculatePartSize(rxCanvas, *iPart, bIsHorizontal));
+        geometry::RealSize2D aSize (CalculatePartSize(rxCanvas, rxPart, bIsHorizontal));
 
         // Remember the size of each part for later.
         aPartSizes[nIndex] = aSize;
 
         // Add gaps between elements.
-        if ((*iPart)->size()>1 && bIsHorizontal)
+        if (rxPart->size()>1 && bIsHorizontal)
         {
-            nTotalHorizontalGap += ((*iPart)->size() - 1) * gnGapSize;
-            nGapCount += (*iPart)->size()-1;
+            nTotalHorizontalGap += (rxPart->size() - 1) * gnGapSize;
+            nGapCount += rxPart->size() - 1;
         }
 
         // Orientation changes for each part.
@@ -717,6 +709,7 @@ void PresenterToolBar::Layout (
         aTotalSize.Width += aSize.Width;
         // Height is the maximum height of all parts.
         aTotalSize.Height = ::std::max(aTotalSize.Height, aSize.Height);
+        ++nIndex;
     }
     // Add gaps between parts.
     if (maElementContainer.size() > 1)
@@ -754,23 +747,27 @@ void PresenterToolBar::Layout (
     /* push front or back ? ... */
     /// check whether RTL interface or not
     if(!AllSettings::GetLayoutRTL()){
-        for (iPart=maElementContainer.begin(), nIndex=0; iPart!=iEnd; ++iPart,++nIndex)
+        nIndex = 0;
+        for (const auto& rxPart : maElementContainer)
         {
             geometry::RealRectangle2D aBoundingBox(
                 nX, nY,
                 nX+aPartSizes[nIndex].Width, nY+aTotalSize.Height);
 
             // Add space for gaps between elements.
-            if ((*iPart)->size() > 1)
+            if (rxPart->size() > 1)
                 if (bIsHorizontal)
-                    aBoundingBox.X2 += ((*iPart)->size()-1) * nGapWidth;
+                    aBoundingBox.X2 += (rxPart->size() - 1) * nGapWidth;
 
-            LayoutPart(rxCanvas, *iPart, aBoundingBox, aPartSizes[nIndex], bIsHorizontal);
+            LayoutPart(rxCanvas, rxPart, aBoundingBox, aPartSizes[nIndex], bIsHorizontal);
             bIsHorizontal = !bIsHorizontal;
             nX += aBoundingBox.X2 - aBoundingBox.X1 + nGapWidth;
+            ++nIndex;
         }
     }
     else {
+        ElementContainer::iterator iPart;
+        ElementContainer::iterator iBegin (maElementContainer.begin());
         for (iPart=maElementContainer.end()-1, nIndex=2; iPart!=iBegin-1; --iPart, --nIndex)
         {
             geometry::RealRectangle2D aBoundingBox(
@@ -805,13 +802,12 @@ geometry::RealSize2D PresenterToolBar::CalculatePartSize (
     if (mxWindow.is())
     {
         // Calculate the summed width of all elements.
-        ElementContainerPart::const_iterator iElement;
-        for (iElement=rpPart->begin(); iElement!=rpPart->end(); ++iElement)
+        for (const auto& rxElement : *rpPart)
         {
-            if (iElement->get() == nullptr)
+            if (rxElement.get() == nullptr)
                 continue;
 
-            const awt::Size aBSize ((*iElement)->GetBoundingSize(rxCanvas));
+            const awt::Size aBSize (rxElement->GetBoundingSize(rxCanvas));
             if (bIsHorizontal)
             {
                 aTotalSize.Width += aBSize.Width;
@@ -849,45 +845,45 @@ void PresenterToolBar::LayoutPart (
     double nX (rBoundingBox.X1);
     double nY (rBoundingBox.Y1);
 
-    ElementContainerPart::const_iterator iElement;
-    ElementContainerPart::const_iterator iEnd (rpPart->end());
-    ElementContainerPart::const_iterator iBegin (rpPart->begin());
-
     /// check whether RTL interface or not
     if(!AllSettings::GetLayoutRTL()){
-        for (iElement=rpPart->begin(); iElement!=iEnd; ++iElement)
+        for (auto& rxElement : *rpPart)
         {
-            if (iElement->get() == nullptr)
+            if (rxElement.get() == nullptr)
                 continue;
 
-            const awt::Size aElementSize ((*iElement)->GetBoundingSize(rxCanvas));
+            const awt::Size aElementSize (rxElement->GetBoundingSize(rxCanvas));
             if (bIsHorizontal)
             {
-                if ((*iElement)->IsFilling())
+                if (rxElement->IsFilling())
                 {
                     nY = rBoundingBox.Y1;
-                    (*iElement)->SetSize(geometry::RealSize2D(aElementSize.Width, rBoundingBox.Y2 - rBoundingBox.Y1));
+                    rxElement->SetSize(geometry::RealSize2D(aElementSize.Width, rBoundingBox.Y2 - rBoundingBox.Y1));
                 }
                 else
                     nY = rBoundingBox.Y1 + (rBoundingBox.Y2-rBoundingBox.Y1 - aElementSize.Height) / 2;
-                (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
+                rxElement->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
                 nX += aElementSize.Width + nGap;
             }
             else
             {
-                if ((*iElement)->IsFilling())
+                if (rxElement->IsFilling())
                 {
                     nX = rBoundingBox.X1;
-                    (*iElement)->SetSize(geometry::RealSize2D(rBoundingBox.X2 - rBoundingBox.X1, aElementSize.Height));
+                    rxElement->SetSize(geometry::RealSize2D(rBoundingBox.X2 - rBoundingBox.X1, aElementSize.Height));
                 }
                 else
                     nX = rBoundingBox.X1 + (rBoundingBox.X2-rBoundingBox.X1 - aElementSize.Width) / 2;
-                (*iElement)->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
+                rxElement->SetLocation(awt::Point(sal_Int32(0.5 + nX), sal_Int32(0.5 + nY)));
                 nY += aElementSize.Height + nGap;
             }
         }
     }
     else {
+        ElementContainerPart::const_iterator iElement;
+        ElementContainerPart::const_iterator iEnd (rpPart->end());
+        ElementContainerPart::const_iterator iBegin (rpPart->begin());
+
         for (iElement=rpPart->end()-1; iElement!=iBegin-1; --iElement)
         {
             if (iElement->get() == nullptr)
@@ -934,7 +930,6 @@ void PresenterToolBar::LayoutPart (
             }
         }
     }
-
 }
 
 void PresenterToolBar::Paint (
@@ -943,18 +938,14 @@ void PresenterToolBar::Paint (
 {
     OSL_ASSERT(mxCanvas.is());
 
-    ElementContainer::iterator iPart;
-    ElementContainer::const_iterator iEnd (maElementContainer.end());
-    for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
+    for (const auto& rxPart : maElementContainer)
     {
-        ElementContainerPart::iterator iElement;
-        ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
-        for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
+        for (auto& rxElement : *rxPart)
         {
-            if (iElement->get() != nullptr)
+            if (rxElement.get() != nullptr)
             {
-                if ( ! (*iElement)->IsOutside(rUpdateBox))
-                    (*iElement)->Paint(mxCanvas, rViewState);
+                if ( ! rxElement->IsOutside(rUpdateBox))
+                    rxElement->Paint(mxCanvas, rViewState);
             }
         }
     }
@@ -964,16 +955,12 @@ void PresenterToolBar::UpdateSlideNumber()
 {
     if( mxSlideShowController.is() )
     {
-        ElementContainer::iterator iPart;
-        ElementContainer::const_iterator iEnd (maElementContainer.end());
-        for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
+        for (const auto& rxPart : maElementContainer)
         {
-            ElementContainerPart::iterator iElement;
-            ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
-            for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
+            for (auto& rxElement : *rxPart)
             {
-                if (iElement->get() != nullptr)
-                    (*iElement)->CurrentSlideHasChanged();
+                if (rxElement.get() != nullptr)
+                    rxElement->CurrentSlideHasChanged();
             }
         }
     }
@@ -989,24 +976,20 @@ void PresenterToolBar::CheckMouseOver (
         awt::Rectangle aWindowBox = mxWindow->getPosSize();
         rTemp.X=aWindowBox.Width-rTemp.X;
     }
-    ElementContainer::iterator iPart;
-    ElementContainer::const_iterator iEnd (maElementContainer.end());
-    for (iPart=maElementContainer.begin(); iPart!=iEnd; ++iPart)
+    for (const auto& rxPart : maElementContainer)
     {
-        ElementContainerPart::iterator iElement;
-        ElementContainerPart::const_iterator iPartEnd ((*iPart)->end());
-        for (iElement=(*iPart)->begin(); iElement!=iPartEnd; ++iElement)
+        for (auto& rxElement : *rxPart)
         {
-            if (iElement->get() == nullptr)
+            if (rxElement.get() == nullptr)
                 continue;
 
-            awt::Rectangle aBox ((*iElement)->GetBoundingBox());
+            awt::Rectangle aBox (rxElement->GetBoundingBox());
             const bool bIsOver = bOverWindow
                 && aBox.X <= rTemp.X
                 && aBox.Width+aBox.X-1 >= rTemp.X
                 && aBox.Y <= rTemp.Y
                 && aBox.Height+aBox.Y-1 >= rTemp.Y;
-            (*iElement)->SetState(
+            rxElement->SetState(
                 bIsOver,
                 bIsOver && rTemp.Buttons!=0 && bMouseDown && rTemp.ClickCount>0);
         }
diff --git a/sdext/source/presenter/PresenterViewFactory.cxx b/sdext/source/presenter/PresenterViewFactory.cxx
index f8f8c5ed8e0c..b797b1132833 100644
--- a/sdext/source/presenter/PresenterViewFactory.cxx
+++ b/sdext/source/presenter/PresenterViewFactory.cxx
@@ -181,13 +181,11 @@ void SAL_CALL PresenterViewFactory::disposing()
     if (mpResourceCache != nullptr)
     {
         // Dispose all views in the cache.
-        ResourceContainer::const_iterator iView (mpResourceCache->begin());
-        ResourceContainer::const_iterator iEnd (mpResourceCache->end());
-        for ( ; iView!=iEnd; ++iView)
+        for (const auto& rView : *mpResourceCache)
         {
             try
             {
-                Reference<lang::XComponent> xComponent (iView->second.first, UNO_QUERY);
+                Reference<lang::XComponent> xComponent (rView.second.first, UNO_QUERY);
                 if (xComponent.is())
                     xComponent->dispose();
             }
diff --git a/sdext/source/presenter/PresenterWindowManager.cxx b/sdext/source/presenter/PresenterWindowManager.cxx
index 1337da2abbe5..dcfa6664e74f 100644
--- a/sdext/source/presenter/PresenterWindowManager.cxx
+++ b/sdext/source/presenter/PresenterWindowManager.cxx
@@ -100,15 +100,13 @@ void SAL_CALL PresenterWindowManager::disposing()
         xComponent->dispose();
     mxPaneBorderManager = nullptr;
 
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
+    for (const auto& rxPane : mpPaneContainer->maPanes)
     {
-        if ((*iPane)->mxBorderWindow.is())
+        if (rxPane->mxBorderWindow.is())
         {
-            (*iPane)->mxBorderWindow->removeWindowListener(this);
-            (*iPane)->mxBorderWindow->removeFocusListener(this);
-            (*iPane)->mxBorderWindow->removeMouseListener(this);
+            rxPane->mxBorderWindow->removeWindowListener(this);
+            rxPane->mxBorderWindow->removeFocusListener(this);
+            rxPane->mxBorderWindow->removeMouseListener(this);
         }
     }
 }
@@ -322,22 +320,20 @@ void PresenterWindowManager::PaintChildren (const awt::PaintEvent& rEvent) const
 {
     // Call windowPaint on all children that lie in or touch the
     // update rectangle.
-    PresenterPaneContainer::PaneList::const_iterator iPane;
-    PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
+    for (const auto& rxPane : mpPaneContainer->maPanes)
     {
         try
         {
             // Make sure that the pane shall and can be painted.
-            if ( ! (*iPane)->mbIsActive)
+            if ( ! rxPane->mbIsActive)
                 continue;
-            if ((*iPane)->mbIsSprite)
+            if (rxPane->mbIsSprite)
                 continue;
-            if ( ! (*iPane)->mxPane.is())
+            if ( ! rxPane->mxPane.is())
                 continue;
-            if ( ! (*iPane)->mxBorderWindow.is())
+            if ( ! rxPane->mxBorderWindow.is())
                 continue;
-            Reference<awt::XWindow> xBorderWindow ((*iPane)->mxBorderWindow);
+            Reference<awt::XWindow> xBorderWindow (rxPane->mxBorderWindow);
             if ( ! xBorderWindow.is())
                 continue;
 
@@ -537,17 +533,10 @@ void PresenterWindowManager::AddLayoutListener (
 void PresenterWindowManager::RemoveLayoutListener (
     const Reference<document::XEventListener>& rxListener)
 {
-    LayoutListenerContainer::iterator iListener (maLayoutListeners.begin());
-    LayoutListenerContainer::iterator iEnd (maLayoutListeners.end());
-    for ( ; iListener!=iEnd; ++iListener)
-    {
-        if (*iListener == rxListener)
-        {
-            maLayoutListeners.erase(iListener);
-            // Assume that there are no multiple entries.
-            break;
-        }
-    }
+    // Assume that there are no multiple entries.
+    auto iListener = std::find(maLayoutListeners.begin(), maLayoutListeners.end(), rxListener);
+    if (iListener != maLayoutListeners.end())
+        maLayoutListeners.erase(iListener);
 }
 
 void PresenterWindowManager::Layout()
@@ -845,19 +834,17 @@ void PresenterWindowManager::NotifyLayoutModeChange()
     aEvent.Source = Reference<XInterface>(static_cast<XWeak*>(this));
 
     LayoutListenerContainer aContainerCopy (maLayoutListeners);
-    LayoutListenerContainer::iterator iListener (aContainerCopy.begin());
-    LayoutListenerContainer::iterator iEnd (aContainerCopy.end());
-    for ( ; iListener!=iEnd; ++iListener)
+    for (const auto& rxListener : aContainerCopy)
     {
-        if (iListener->is())
+        if (rxListener.is())
         {
             try
             {
-                (*iListener)->notifyEvent(aEvent);
+                rxListener->notifyEvent(aEvent);
             }
             catch (lang::DisposedException&)
             {
-                RemoveLayoutListener(*iListener);
+                RemoveLayoutListener(rxListener);
             }
             catch (RuntimeException&)
             {
@@ -873,15 +860,13 @@ void PresenterWindowManager::NotifyDisposing()
 
     LayoutListenerContainer aContainer;
     aContainer.swap(maLayoutListeners);
-    LayoutListenerContainer::iterator iListener (aContainer.begin());
-    LayoutListenerContainer::iterator iEnd (aContainer.end());
-    for ( ; iListener!=iEnd; ++iListener)
+    for (auto& rxListener : aContainer)
     {
-        if (iListener->is())
+        if (rxListener.is())
         {
             try
             {
-                (*iListener)->disposing(aEvent);
+                rxListener->disposing(aEvent);
             }
             catch (lang::DisposedException&)
             {
@@ -1016,10 +1001,8 @@ Reference<rendering::XPolyPolygon2D> PresenterWindowManager::CreateClipPolyPolyg
     aRectangles.reserve(1+nPaneCount);
     aRectangles.push_back(mxParentWindow->getPosSize());
     PresenterPaneContainer::PaneList::const_iterator iPane;
-    PresenterPaneContainer::PaneList::const_iterator iEnd (mpPaneContainer->maPanes.end());
-    for (iPane=mpPaneContainer->maPanes.begin(); iPane!=iEnd; ++iPane)
+    for (const auto& pDescriptor : mpPaneContainer->maPanes)
     {
-        PresenterPaneContainer::SharedPaneDescriptor pDescriptor (*iPane);
         if ( ! pDescriptor->mbIsActive)
             continue;
         if ( ! pDescriptor->mbIsOpaque)


More information about the Libreoffice-commits mailing list