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

Julien Nabet serval2412 at yahoo.fr
Tue Mar 13 08:11:07 UTC 2018


 extensions/source/abpilot/fieldmappingimpl.cxx               |   13 -
 extensions/source/abpilot/tableselectionpage.cxx             |    7 
 extensions/source/abpilot/typeselectionpage.cxx              |   39 +--
 extensions/source/dbpilots/groupboxwiz.cxx                   |   14 -
 extensions/source/propctrlr/browserlistbox.cxx               |   41 +--
 extensions/source/propctrlr/cellbindinghandler.cxx           |    7 
 extensions/source/propctrlr/composeduiupdate.cxx             |    7 
 extensions/source/propctrlr/eformshelper.cxx                 |   30 +-
 extensions/source/propctrlr/eventhandler.cxx                 |   37 +--
 extensions/source/propctrlr/formcomponenthandler.cxx         |    9 
 extensions/source/propctrlr/formgeometryhandler.cxx          |    9 
 extensions/source/propctrlr/handlerhelper.cxx                |    7 
 extensions/source/propctrlr/propcontroller.cxx               |  127 ++++-------
 extensions/source/propctrlr/propertycomposer.cxx             |   47 +---
 extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx |    9 
 extensions/source/update/check/updatecheck.cxx               |   30 +-
 16 files changed, 164 insertions(+), 269 deletions(-)

New commits:
commit 71f2669b7fbbf3f51f43286dd64608a75ce95ad7
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Mar 13 00:45:01 2018 +0100

    Modernize a bit extensions
    
    mainly by using for-range loops
    
    Change-Id: I297275748ffdce0576e51f63294d7e5b21729af7
    Reviewed-on: https://gerrit.libreoffice.org/51182
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/extensions/source/abpilot/fieldmappingimpl.cxx b/extensions/source/abpilot/fieldmappingimpl.cxx
index 183d68f6596a..fda8c194103c 100644
--- a/extensions/source/abpilot/fieldmappingimpl.cxx
+++ b/extensions/source/abpilot/fieldmappingimpl.cxx
@@ -256,18 +256,15 @@ namespace abp
 
             // now everything remaining in aFieldAssignment marks a mapping entry which was not present
             // in the config before
-            for (   MapString2String::const_iterator aNewMapping = aFieldAssignment.begin();
-                    aNewMapping != aFieldAssignment.end();
-                    ++aNewMapping
-                )
+            for (auto const& elem : aFieldAssignment)
             {
-                DBG_ASSERT( !aFields.hasByName( aNewMapping->first ),
+                DBG_ASSERT( !aFields.hasByName( elem.first ),
                     "fieldmapping::writeTemplateAddressFieldMapping: inconsistence!" );
                     // in case the config node for the fields already has the node named <aNewMapping->first>,
                     // the entry should have been removed from aNewMapping (in the above loop)
-                OConfigurationNode aNewField =  aFields.createNode( aNewMapping->first );
-                aNewField.setNodeValue( sProgrammaticNodeName, makeAny( aNewMapping->first ) );
-                aNewField.setNodeValue( sAssignedNodeName, makeAny( aNewMapping->second ) );
+                OConfigurationNode aNewField =  aFields.createNode( elem.first );
+                aNewField.setNodeValue( sProgrammaticNodeName, makeAny( elem.first ) );
+                aNewField.setNodeValue( sAssignedNodeName, makeAny( elem.second ) );
             }
 
             // commit the changes done
diff --git a/extensions/source/abpilot/tableselectionpage.cxx b/extensions/source/abpilot/tableselectionpage.cxx
index d6882a0f6644..da4c5b3ee058 100644
--- a/extensions/source/abpilot/tableselectionpage.cxx
+++ b/extensions/source/abpilot/tableselectionpage.cxx
@@ -69,11 +69,8 @@ namespace abp
             // this page should never bother the user if there is 1 or less tables.
 
         // fill the list
-        for (   StringBag::const_iterator aTables = aTableNames.begin();
-                aTables != aTableNames.end();
-                ++aTables
-            )
-            m_pTableList->InsertEntry( *aTables );
+        for (auto const& tableName : aTableNames)
+            m_pTableList->InsertEntry(tableName);
 
         // initially select the proper table
         m_pTableList->SelectEntry( rSettings.sSelectedTable );
diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx
index 627f735f3fbc..606b4ae9df32 100644
--- a/extensions/source/abpilot/typeselectionpage.cxx
+++ b/extensions/source/abpilot/typeselectionpage.cxx
@@ -123,16 +123,14 @@ namespace abp
         m_aAllTypes.push_back( ButtonItem( m_pOther, AST_OTHER, true ) );
 
         Link<Button*,void> aTypeSelectionHandler = LINK(this, TypeSelectionPage, OnTypeSelected );
-        for ( std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
-              loop != m_aAllTypes.end(); ++loop )
+        for (auto const& elem : m_aAllTypes)
         {
-            ButtonItem aItem = *loop;
-            if (!aItem.m_bVisible)
-                aItem.m_pItem->Hide();
+            if (!elem.m_bVisible)
+                elem.m_pItem->Hide();
             else
             {
-                aItem.m_pItem->SetClickHdl( aTypeSelectionHandler );
-                aItem.m_pItem->Show();
+                elem.m_pItem->SetClickHdl( aTypeSelectionHandler );
+                elem.m_pItem->Show();
             }
         }
     }
@@ -145,10 +143,9 @@ namespace abp
 
     void TypeSelectionPage::dispose()
     {
-        for ( std::vector< ButtonItem >::iterator loop = m_aAllTypes.begin();
-              loop != m_aAllTypes.end(); ++loop )
+        for (auto & elem : m_aAllTypes)
         {
-            loop->m_bVisible = false;
+            elem.m_bVisible = false;
         }
         m_pEvolution.clear();
         m_pEvolutionGroupwise.clear();
@@ -166,13 +163,11 @@ namespace abp
     {
         AddressBookSourcePage::ActivatePage();
 
-        for ( std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
-              loop != m_aAllTypes.end(); ++loop )
+        for (auto const& elem : m_aAllTypes)
         {
-            const ButtonItem& rItem = (*loop);
-            if( rItem.m_pItem->IsChecked() && rItem.m_bVisible )
+            if( elem.m_pItem->IsChecked() && elem.m_bVisible )
             {
-                rItem.m_pItem->GrabFocus();
+                elem.m_pItem->GrabFocus();
                 break;
             }
         }
@@ -190,23 +185,19 @@ namespace abp
 
     void TypeSelectionPage::selectType( AddressSourceType _eType )
     {
-        for ( std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
-              loop != m_aAllTypes.end(); ++loop )
+        for (auto const& elem : m_aAllTypes)
         {
-            ButtonItem aItem = (*loop);
-            aItem.m_pItem->Check( _eType == aItem.m_eType );
+            elem.m_pItem->Check( _eType == elem.m_eType );
         }
     }
 
 
     AddressSourceType TypeSelectionPage::getSelectedType() const
     {
-        for ( std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
-              loop != m_aAllTypes.end(); ++loop )
+        for (auto const& elem : m_aAllTypes)
         {
-            ButtonItem aItem = (*loop);
-            if ( aItem.m_pItem->IsChecked() && aItem.m_bVisible )
-                return aItem.m_eType;
+            if ( elem.m_pItem->IsChecked() && elem.m_bVisible )
+                return elem.m_eType;
         }
 
         return AST_INVALID;
diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx
index 606f6fec94d8..c7d81548a6ce 100644
--- a/extensions/source/dbpilots/groupboxwiz.cxx
+++ b/extensions/source/dbpilots/groupboxwiz.cxx
@@ -351,11 +351,8 @@ namespace dbp
 
         // fill the listbox
         m_pDefSelection->Clear();
-        for (   StringArray::const_iterator aLoop = rSettings.aLabels.begin();
-                aLoop != rSettings.aLabels.end();
-                ++aLoop
-            )
-            m_pDefSelection->InsertEntry(*aLoop);
+        for (auto const& label : rSettings.aLabels)
+            m_pDefSelection->InsertEntry(label);
 
 
         implInitialize(rSettings.sDefaultField);
@@ -434,11 +431,8 @@ namespace dbp
         // fill the list with all available options
         m_pOptions->Clear();
         m_nLastSelection = -1;
-        for (   StringArray::const_iterator aLoop = rSettings.aLabels.begin();
-                aLoop != rSettings.aLabels.end();
-                ++aLoop
-            )
-            m_pOptions->InsertEntry(*aLoop);
+        for (auto const& label : rSettings.aLabels)
+            m_pOptions->InsertEntry(label);
 
         // remember the values ... can't set them directly in the settings without the explicit commit call
         // so we need have a copy of the values
diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx
index 98ea5c3e5729..b6fa5fe5130f 100644
--- a/extensions/source/propctrlr/browserlistbox.cxx
+++ b/extensions/source/propctrlr/browserlistbox.cxx
@@ -639,16 +639,14 @@ namespace pcr
     sal_uInt16 OBrowserListBox::GetPropertyPos( const OUString& _rEntryName ) const
     {
         sal_uInt16 nRet = EDITOR_LIST_ENTRY_NOTFOUND;
-        for ( ListBoxLines::const_iterator linePos = m_aLines.begin();
-              linePos != m_aLines.end();
-              ++linePos
-            )
+        sal_uInt16 nPos = 0;
+        for (auto const& line : m_aLines)
         {
-            if ( linePos->aName == _rEntryName )
+            if ( line.aName == _rEntryName )
             {
-                nRet = static_cast<sal_uInt16>( linePos - m_aLines.begin() );
-                break;
+                return nPos;
             }
+            ++nPos;
         }
 
         return nRet;
@@ -700,10 +698,14 @@ namespace pcr
         BrowserLinePointer pBrowserLine( new OBrowserLine( _rPropertyData.sName, m_aLinesPlayground.get() ) );
 
         // check that the name is unique
-        ListBoxLines::iterator it = m_aLines.begin();
-        for ( ; it != m_aLines.end() && ( it->aName != _rPropertyData.sName ); ++it )
-            ;
-        OSL_ENSURE( it == m_aLines.end(), "OBrowserListBox::InsertEntry: already have another line for this name!" );
+        for (auto const& line : m_aLines)
+        {
+            if (line.aName == _rPropertyData.sName)
+            {
+                // already have another line for this name!
+                assert(false);
+            }
+        }
 
         ListBoxLine aNewLine( _rPropertyData.sName, pBrowserLine, _rPropertyData.xPropertyHandler );
         ListBoxLines::size_type nInsertPos = _nPos;
@@ -909,10 +911,13 @@ namespace pcr
 
     sal_uInt16 OBrowserListBox::impl_getControlPos( const Reference< XPropertyControl >& _rxControl ) const
     {
-        for ( ListBoxLines::const_iterator search = m_aLines.begin(); search != m_aLines.end(); ++search )
-            if ( search->pLine->getControl().get() == _rxControl.get() )
-                return sal_uInt16( search - m_aLines.begin() );
-
+        sal_uInt16 nPos = 0;
+        for (auto const& search : m_aLines)
+        {
+            if ( search.pLine->getControl().get() == _rxControl.get() )
+                return nPos;
+            ++nPos;
+        }
         OSL_FAIL( "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" );
         return sal_uInt16(-1);
     }
@@ -1001,12 +1006,12 @@ namespace pcr
 
     void OBrowserListBox::Clear()
     {
-        for ( ListBoxLines::iterator loop = m_aLines.begin(); loop != m_aLines.end(); ++loop )
+        for (auto const& line : m_aLines)
         {
             // hide the line
-            loop->pLine->Hide();
+            line.pLine->Hide();
             // reset the listener
-            lcl_implDisposeControl_nothrow( loop->pLine->getControl() );
+            lcl_implDisposeControl_nothrow( line.pLine->getControl() );
         }
 
         clearContainer( m_aLines );
diff --git a/extensions/source/propctrlr/cellbindinghandler.cxx b/extensions/source/propctrlr/cellbindinghandler.cxx
index e636aa2a44d9..bd7cbe3ed117 100644
--- a/extensions/source/propctrlr/cellbindinghandler.cxx
+++ b/extensions/source/propctrlr/cellbindinghandler.cxx
@@ -189,12 +189,9 @@ namespace pcr
             OSL_FAIL( "CellBindingPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
         }
 
-        for ( std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
-              loopAffected != aDependentProperties.end();
-              ++loopAffected
-            )
+        for (auto const& dependentProperty : aDependentProperties)
         {
-            impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+            impl_updateDependentProperty_nothrow( dependentProperty, _rxInspectorUI );
         }
     }
 
diff --git a/extensions/source/propctrlr/composeduiupdate.cxx b/extensions/source/propctrlr/composeduiupdate.cxx
index 86e6bb8f670a..c01418382843 100644
--- a/extensions/source/propctrlr/composeduiupdate.cxx
+++ b/extensions/source/propctrlr/composeduiupdate.cxx
@@ -754,12 +754,9 @@ namespace pcr
 
         OSL_ENSURE( m_nSuspendCounter == 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" );
 
-        for ( ImplMapHandlerToUI::const_iterator singleUI = m_pCollectedUIs->aHandlers.begin();
-              singleUI != m_pCollectedUIs->aHandlers.end();
-              ++singleUI
-            )
+        for (auto const& singleUI : m_pCollectedUIs->aHandlers)
         {
-            singleUI->second->dispose();
+            singleUI.second->dispose();
         }
         m_pCollectedUIs.reset();
         m_xDelegatorUI.set( nullptr );
diff --git a/extensions/source/propctrlr/eformshelper.cxx b/extensions/source/propctrlr/eformshelper.cxx
index 047022f53994..608f64fcf17c 100644
--- a/extensions/source/propctrlr/eformshelper.cxx
+++ b/extensions/source/propctrlr/eformshelper.cxx
@@ -655,12 +655,9 @@ namespace pcr
             _rElementNames.reserve( aModels.size() * 2 );    // heuristics
 
             // for every model, obtain the element
-            for ( std::vector< OUString >::const_iterator pModelName = aModels.begin();
-                  pModelName != aModels.end();
-                  ++pModelName
-                )
+            for (auto const& modelName : aModels)
             {
-                Reference< xforms::XModel > xModel = getFormModelByName( *pModelName );
+                Reference< xforms::XModel > xModel = getFormModelByName(modelName);
                 OSL_ENSURE( xModel.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
                 Reference< xforms::XFormsUIHelper1 > xHelper( xModel, UNO_QUERY );
 
@@ -687,7 +684,7 @@ namespace pcr
                     }
 #endif
                     OUString sElementName = ( _eType == Submission ) ? xHelper->getSubmissionName( xElement, true ) : xHelper->getBindingName( xElement, true );
-                    OUString sUIName = composeModelElementUIName( *pModelName, sElementName );
+                    OUString sUIName = composeModelElementUIName( modelName, sElementName );
 
                     OSL_ENSURE( rMapUINameToElement.find( sUIName ) == rMapUINameToElement.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
                     rMapUINameToElement.emplace( sUIName, xElement );
@@ -742,23 +739,20 @@ namespace pcr
             Reference< XPropertySetInfo > xOldInfo = collectPropertiesGetInfo( _rxOldProps, aProperties );
             Reference< XPropertySetInfo > xNewInfo = collectPropertiesGetInfo( _rxNewProps, aProperties );
 
-            for ( PropertyBag::const_iterator aProp = aProperties.begin();
-                  aProp != aProperties.end();
-                  ++aProp
-                )
+            for (auto const& property : aProperties)
             {
-                if ( _rFilter.find( aProp->Name ) != _rFilter.end() )
+                if ( _rFilter.find( property.Name ) != _rFilter.end() )
                     continue;
 
-                Any aOldValue( nullptr, aProp->Type );
-                if ( xOldInfo.is() && xOldInfo->hasPropertyByName( aProp->Name ) )
-                    aOldValue = _rxOldProps->getPropertyValue( aProp->Name );
+                Any aOldValue( nullptr, property.Type );
+                if ( xOldInfo.is() && xOldInfo->hasPropertyByName( property.Name ) )
+                    aOldValue = _rxOldProps->getPropertyValue( property.Name );
 
-                Any aNewValue( nullptr, aProp->Type );
-                if ( xNewInfo.is() && xNewInfo->hasPropertyByName( aProp->Name ) )
-                    aNewValue = _rxNewProps->getPropertyValue( aProp->Name );
+                Any aNewValue( nullptr, property.Type );
+                if ( xNewInfo.is() && xNewInfo->hasPropertyByName( property.Name ) )
+                    aNewValue = _rxNewProps->getPropertyValue( property.Name );
 
-                firePropertyChange( aProp->Name, aOldValue, aNewValue );
+                firePropertyChange( property.Name, aOldValue, aNewValue );
             }
         }
         catch( const Exception& )
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
index 3e8b006bb95d..f09f8a6054f6 100644
--- a/extensions/source/propctrlr/eventhandler.cxx
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -414,11 +414,11 @@ namespace pcr
         // of the implementation.
         // Well, it means we're forced to return the events in getElementNames in exactly the same as they
         // appear in the property browser UI.
-        for (   EventMapIndexAccess::const_iterator loop = m_aEventIndexAccess.begin();
-                loop != m_aEventIndexAccess.end();
-                ++loop, ++pReturn
-            )
-            *pReturn = loop->second->first;
+        for (auto const& elem : m_aEventIndexAccess)
+        {
+            *pReturn = elem.second->first;
+            ++pReturn;
+        }
         return aReturn;
     }
 
@@ -735,13 +735,10 @@ namespace pcr
 
         // sort them by ID - this is the relative ordering in the UI
         std::map< EventId, Property > aOrderedProperties;
-        for (   EventMap::const_iterator loop = m_aEvents.begin();
-                loop != m_aEvents.end();
-                ++loop
-            )
+        for (auto const& event : m_aEvents)
         {
-            aOrderedProperties[ loop->second.nId ] = Property(
-                loop->first, loop->second.nId,
+            aOrderedProperties[ event.second.nId ] = Property(
+                event.first, event.second.nId,
                 ::cppu::UnoType<OUString>::get(),
                 PropertyAttribute::BOUND );
         }
@@ -802,14 +799,11 @@ namespace pcr
         // SvxMacroAssignDlg-compatible structure holding all event/assignments
         ::rtl::Reference< EventHolder >  pEventHolder( new EventHolder );
 
-        for (   EventMap::const_iterator event = m_aEvents.begin();
-                event != m_aEvents.end();
-                ++event
-            )
+        for (auto const& event : m_aEvents)
         {
             // the script which is assigned to the current event (if any)
-            ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( event->second, aAllAssignedEvents );
-            pEventHolder->addEvent( event->second.nId, event->second.sListenerMethodName, aAssignedScript );
+            ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( event.second, aAllAssignedEvents );
+            pEventHolder->addEvent( event.second.nId, event.second.sListenerMethodName, aAssignedScript );
         }
 
         // the initial selection in the dialog
@@ -840,16 +834,13 @@ namespace pcr
 
         try
         {
-            for (   EventMap::const_iterator event = m_aEvents.begin();
-                    event != m_aEvents.end();
-                    ++event
-                )
+            for (auto const& event : m_aEvents)
             {
-                ScriptEventDescriptor aScriptDescriptor( pEventHolder->getNormalizedDescriptorByName( event->second.sListenerMethodName ) );
+                ScriptEventDescriptor aScriptDescriptor( pEventHolder->getNormalizedDescriptorByName( event.second.sListenerMethodName ) );
 
                 // set the new "property value"
                 setPropertyValue(
-                    lcl_getEventPropertyName( event->second.sListenerClassName, event->second.sListenerMethodName ),
+                    lcl_getEventPropertyName( event.second.sListenerClassName, event.second.sListenerMethodName ),
                     makeAny( aScriptDescriptor )
                 );
             }
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index 77123d2c3b51..b03350023168 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -1724,13 +1724,10 @@ namespace pcr
 
         }   // switch ( nActuatingPropId )
 
-        for ( std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
-              loopAffected != aDependentProperties.end();
-              ++loopAffected
-            )
+        for (auto const& dependentProperty : aDependentProperties)
         {
-            if ( impl_isSupportedProperty_nothrow( *loopAffected ) )
-                impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+            if ( impl_isSupportedProperty_nothrow(dependentProperty) )
+                impl_updateDependentProperty_nothrow(dependentProperty, _rxInspectorUI);
         }
     }
 
diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx
index 28097d3623a6..e9c13b2307ba 100644
--- a/extensions/source/propctrlr/formgeometryhandler.cxx
+++ b/extensions/source/propctrlr/formgeometryhandler.cxx
@@ -750,13 +750,10 @@ namespace pcr
         aTranslatedEvent.Source = m_rParent;
 
         aGuard.clear();
-        for ( std::vector< EventTranslation >::const_iterator t = aEventTranslations.begin();
-              t != aEventTranslations.end();
-              ++t
-            )
+        for (auto const& eventTranslation : aEventTranslations)
         {
-            aTranslatedEvent.PropertyName = t->sPropertyName;
-            aTranslatedEvent.NewValue = t->aNewPropertyValue;
+            aTranslatedEvent.PropertyName = eventTranslation.sPropertyName;
+            aTranslatedEvent.NewValue = eventTranslation.aNewPropertyValue;
             m_aPropertyChangeListeners.notifyEach( &XPropertyChangeListener::propertyChange, aTranslatedEvent );
         }
     }
diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx
index ddebb7de3632..a9555e21b092 100644
--- a/extensions/source/propctrlr/handlerhelper.cxx
+++ b/extensions/source/propctrlr/handlerhelper.cxx
@@ -129,11 +129,8 @@ namespace pcr
             if ( _bSorted )
                 std::sort( aInitialEntries.begin(), aInitialEntries.end() );
 
-            for (   std::vector< OUString >::const_iterator loop = aInitialEntries.begin();
-                    loop != aInitialEntries.end();
-                    ++loop
-                )
-                xListControl->appendListEntry( *loop );
+            for (auto const& initialEntry : aInitialEntries)
+                xListControl->appendListEntry(initialEntry);
             return xListControl.get();
         }
     }
diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx
index 6b19672c004b..5a62dbc29c85 100644
--- a/extensions/source/propctrlr/propcontroller.cxx
+++ b/extensions/source/propctrlr/propcontroller.cxx
@@ -412,26 +412,20 @@ namespace pcr
     bool OPropertyBrowserController::suspendPropertyHandlers_nothrow( bool _bSuspend )
     {
         PropertyHandlerArray aAllHandlers;  // will contain every handler exactly once
-        for (   PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.begin();
-                handler != m_aPropertyHandlers.end();
-                ++handler
-            )
+        for (auto const& propertyHandler : m_aPropertyHandlers)
         {
-            if ( std::find( aAllHandlers.begin(), aAllHandlers.end(), handler->second ) != aAllHandlers.end() )
+            if ( std::find( aAllHandlers.begin(), aAllHandlers.end(), propertyHandler.second ) != aAllHandlers.end() )
                 // already visited this particular handler (m_aPropertyHandlers usually contains
                 // the same handler more than once)
                 continue;
-            aAllHandlers.push_back( handler->second );
+            aAllHandlers.push_back(propertyHandler.second);
         }
 
-        for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
-              loop != aAllHandlers.end();
-              ++loop
-            )
+        for (auto const& handler : aAllHandlers)
         {
             try
             {
-                if ( !(*loop)->suspend( _bSuspend ) )
+                if ( !handler->suspend( _bSuspend ) )
                     if ( _bSuspend )
                         // if we're not suspending, but reactivating, ignore the error
                         return false;
@@ -636,14 +630,11 @@ namespace pcr
         const sal_uInt16 nCurrentPage = m_pView->getActivaPage();
         if ( sal_uInt16(-1) != nCurrentPage )
         {
-            for (   HashString2Int16::const_iterator pageId = m_aPageIds.begin();
-                    pageId != m_aPageIds.end();
-                    ++pageId
-                )
+            for (auto const& pageId : m_aPageIds)
             {
-                if ( nCurrentPage == pageId->second )
+                if ( nCurrentPage == pageId.second )
                 {
-                    m_sPageSelection = pageId->first;
+                    m_sPageSelection = pageId.first;
                     break;
                 }
             }
@@ -822,14 +813,11 @@ namespace pcr
 
     void OPropertyBrowserController::impl_toggleInspecteeListening_nothrow( bool _bOn )
     {
-        for (   InterfaceArray::const_iterator loop = m_aInspectedObjects.begin();
-                loop != m_aInspectedObjects.end();
-                ++loop
-            )
+        for (auto const& inspectedObject : m_aInspectedObjects)
         {
             try
             {
-                Reference< XComponent > xComp( *loop, UNO_QUERY );
+                Reference< XComponent > xComp( inspectedObject, UNO_QUERY );
                 if ( xComp.is() )
                 {
                     if ( _bOn )
@@ -865,11 +853,8 @@ namespace pcr
         if ( haveView() )
         {
             // remove the pages
-            for (   HashString2Int16::const_iterator erase = m_aPageIds.begin();
-                    erase != m_aPageIds.end();
-                    ++erase
-                )
-                getPropertyBox().RemovePage( erase->second );
+            for (auto const& pageId : m_aPageIds)
+                getPropertyBox().RemovePage( pageId.second );
             clearContainer( m_aPageIds );
         }
 
@@ -885,22 +870,16 @@ namespace pcr
 
         // clean up the property handlers
         PropertyHandlerArray aAllHandlers;  // will contain every handler exactly once
-        for ( PropertyHandlerRepository::const_iterator aHandler = m_aPropertyHandlers.begin();
-              aHandler != m_aPropertyHandlers.end();
-              ++aHandler
-            )
-            if ( std::find( aAllHandlers.begin(), aAllHandlers.end(), aHandler->second ) == aAllHandlers.end() )
-                aAllHandlers.push_back( aHandler->second );
+        for (auto const& propertyHandler : m_aPropertyHandlers)
+            if ( std::find( aAllHandlers.begin(), aAllHandlers.end(), propertyHandler.second ) == aAllHandlers.end() )
+                aAllHandlers.push_back( propertyHandler.second );
 
-        for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
-              loop != aAllHandlers.end();
-              ++loop
-            )
+        for (auto const& handler : aAllHandlers)
         {
             try
             {
-                (*loop)->removePropertyChangeListener( this );
-                (*loop)->dispose();
+                handler->removePropertyChangeListener( this );
+                handler->dispose();
             }
             catch( const DisposedException& )
             {
@@ -1056,15 +1035,14 @@ namespace pcr
             m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( getInspectorUI(), this ) );
 
             // sort the properties by relative position, as indicated by the model
-            for (   std::vector< Property >::const_iterator sourceProps = aProperties.begin();
-                    sourceProps != aProperties.end();
-                    ++sourceProps
-                )
+            sal_Int32 nPos = 0;
+            for (auto const& sourceProps : aProperties)
             {
-                sal_Int32 nRelativePropertyOrder = sourceProps - aProperties.begin();
+                sal_Int32 nRelativePropertyOrder = nPos;
                 if ( m_xModel.is() )
-                    nRelativePropertyOrder = m_xModel->getPropertyOrderIndex( sourceProps->Name );
-                m_aProperties.emplace(nRelativePropertyOrder, *sourceProps);
+                    nRelativePropertyOrder = m_xModel->getPropertyOrderIndex( sourceProps.Name );
+                m_aProperties.emplace(nRelativePropertyOrder, sourceProps);
+                ++nPos;
             }
 
             // be notified when one of our inspectees dies
@@ -1153,16 +1131,13 @@ namespace pcr
         if ( m_xModel.is() )
             aCategories = StlSyntaxSequence< PropertyCategoryDescriptor >(m_xModel->describeCategories());
 
-        for (   StlSyntaxSequence< PropertyCategoryDescriptor >::const_iterator category = aCategories.begin();
-                category != aCategories.end();
-                ++category
-            )
+        for (auto const& category : aCategories)
         {
-            OSL_ENSURE( m_aPageIds.find( category->ProgrammaticName ) == m_aPageIds.end(),
+            OSL_ENSURE( m_aPageIds.find( category.ProgrammaticName ) == m_aPageIds.end(),
                 "OPropertyBrowserController::impl_buildCategories_throw: duplicate programmatic name!" );
 
-            m_aPageIds[ category->ProgrammaticName ] =
-                getPropertyBox().AppendPage( category->UIName, HelpIdUrl::getHelpId( category->HelpURL ) );
+            m_aPageIds[ category.ProgrammaticName ] =
+                getPropertyBox().AppendPage( category.UIName, HelpIdUrl::getHelpId( category.HelpURL ) );
         }
     }
 
@@ -1191,17 +1166,16 @@ namespace pcr
 
             // ask the handlers to describe the property UI, and insert the resulting
             // entries into our list boxes
-            OrderedPropertyMap::const_iterator property( m_aProperties.begin() );
-            for ( ; property != m_aProperties.end(); ++property )
+            for (auto const& property : m_aProperties)
             {
                 OLineDescriptor aDescriptor;
-                describePropertyLine( property->second, aDescriptor );
+                describePropertyLine( property.second, aDescriptor );
 
-                bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( property->second.Name );
+                bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( property.second.Name );
 
                 SAL_WARN_IF( aDescriptor.Category.isEmpty(), "extensions.propctrlr",
                         "OPropertyBrowserController::UpdateUI: empty category provided for property '"
-                        << property->second.Name << "'!");
+                        << property.second.Name << "'!");
                 // finally insert this property control
                 sal_uInt16 nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
                 if ( nTargetPageId == sal_uInt16(-1) )
@@ -1219,30 +1193,29 @@ namespace pcr
                 // if it's an actuating property, remember it
                 if ( bIsActuatingProperty )
                 {
-                    aActuatingProperties.push_back( property->second.Name );
-                    aActuatingPropertyValues.push_back( impl_getPropertyValue_throw( property->second.Name ) );
+                    aActuatingProperties.push_back( property.second.Name );
+                    aActuatingPropertyValues.push_back( impl_getPropertyValue_throw( property.second.Name ) );
                 }
             }
 
             // update any dependencies for the actuating properties which we encountered
             {
-                std::vector< OUString >::const_iterator aProperty = aActuatingProperties.begin();
                 std::vector< Any >::const_iterator aPropertyValue = aActuatingPropertyValues.begin();
-                for ( ; aProperty != aActuatingProperties.end(); ++aProperty, ++aPropertyValue )
-                    impl_broadcastPropertyChange_nothrow( *aProperty, *aPropertyValue, *aPropertyValue, true );
+                for (auto const& actuatingProperty : aActuatingProperties)
+                {
+                    impl_broadcastPropertyChange_nothrow( actuatingProperty, *aPropertyValue, *aPropertyValue, true );
+                    ++aPropertyValue;
+                }
             }
 
             // remove any unused pages (which we did not encounter properties for)
             HashString2Int16 aSurvivingPageIds;
-            for (   HashString2Int16::iterator pageId = m_aPageIds.begin();
-                    pageId != m_aPageIds.end();
-                    ++pageId
-                )
+            for (auto const& pageId : m_aPageIds)
             {
-                if ( aUsedPages.find( pageId->second ) == aUsedPages.end() )
-                    getPropertyBox().RemovePage( pageId->second );
+                if ( aUsedPages.find( pageId.second ) == aUsedPages.end() )
+                    getPropertyBox().RemovePage( pageId.second );
                 else
-                    aSurvivingPageIds.insert( *pageId );
+                    aSurvivingPageIds.insert(pageId);
             }
             m_aPageIds.swap( aSurvivingPageIds );
 
@@ -1321,11 +1294,8 @@ namespace pcr
 
     bool OPropertyBrowserController::hasPropertyByName( const OUString& _rName )
     {
-        for (   OrderedPropertyMap::const_iterator search = m_aProperties.begin();
-                search != m_aProperties.end();
-                ++search
-            )
-            if ( search->second.Name == _rName )
+        for (auto const& property : m_aProperties)
+            if ( property.second.Name == _rName )
                 return true;
         return false;
     }
@@ -1473,15 +1443,12 @@ namespace pcr
                 std::vector< Reference< XPropertyHandler > > aSingleHandlers( _rObjects.size() );
                 std::vector< Reference< XPropertyHandler > >::iterator pHandler = aSingleHandlers.begin();
 
-                InterfaceArray::const_iterator pObject = _rObjects.begin();
-                InterfaceArray::const_iterator pObjectEnd = _rObjects.end();
-
-                for ( ; pObject != pObjectEnd; ++pObject )
+                for (auto const& elem : _rObjects)
                 {
                     *pHandler = lcl_createHandler( m_xContext, handlerFactory );
                     if ( pHandler->is() )
                     {
-                        (*pHandler)->inspect( *pObject );
+                        (*pHandler)->inspect(elem);
                         ++pHandler;
                     }
                 }
diff --git a/extensions/source/propctrlr/propertycomposer.cxx b/extensions/source/propctrlr/propertycomposer.cxx
index 2628cb03fc56..b42d5880c16a 100644
--- a/extensions/source/propctrlr/propertycomposer.cxx
+++ b/extensions/source/propctrlr/propertycomposer.cxx
@@ -95,14 +95,11 @@ namespace pcr
         osl_atomic_increment( &m_refCount );
         {
             Reference< XPropertyChangeListener > xMeMyselfAndI( this );
-            for (   HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
-                    loop != m_aSlaveHandlers.end();
-                    ++loop
-                )
+            for (auto const& slaveHandler : m_aSlaveHandlers)
             {
-                if ( !loop->is() )
+                if ( !slaveHandler.is() )
                     throw NullPointerException();
-                (*loop)->addPropertyChangeListener( xMeMyselfAndI );
+                slaveHandler->addPropertyChangeListener( xMeMyselfAndI );
             }
         }
         osl_atomic_decrement( &m_refCount );
@@ -113,12 +110,9 @@ namespace pcr
     {
         MethodGuard aGuard( *this );
 
-        for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
-              loop != m_aSlaveHandlers.end();
-              ++loop
-            )
+        for (auto const& slaveHandler : m_aSlaveHandlers)
         {
-            (*loop)->inspect( _rxIntrospectee );
+            slaveHandler->inspect( _rxIntrospectee );
         }
     }
 
@@ -243,9 +237,7 @@ namespace pcr
                 bool bIsComposable = isComposable( check->Name );
                 if ( !bIsComposable )
                 {
-                    PropertyBag::iterator next = check; ++next;
-                    m_aSupportedProperties.erase( check );
-                    check = next;
+                    check = m_aSupportedProperties.erase( check );
                 }
                 else
                     ++check;
@@ -264,12 +256,9 @@ namespace pcr
         std::set< OUString > aUnitedBag;
 
         Sequence< OUString > aThisRound;
-        for ( PropertyComposer::HandlerArray::const_iterator loop = _rHandlers.begin();
-              loop != _rHandlers.end();
-              ++loop
-            )
+        for (auto const& handler : _rHandlers)
         {
-            aThisRound = (loop->get()->*pGetter)();
+            aThisRound = (handler.get()->*pGetter)();
             putIntoBag( aThisRound, aUnitedBag );
         }
 
@@ -387,19 +376,16 @@ namespace pcr
 
         // ask all handlers which expressed interest in this particular property, and "compose" their
         // commands for the UIUpdater
-        for (   HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
-                loop != m_aSlaveHandlers.end();
-                ++loop
-            )
+        for (auto const& slaveHandler : m_aSlaveHandlers)
         {
             // TODO: make this cheaper (cache it?)
-            const StlSyntaxSequence< OUString > aThisHandlersActuatingProps( (*loop)->getActuatingProperties() );
+            const StlSyntaxSequence< OUString > aThisHandlersActuatingProps( slaveHandler->getActuatingProperties() );
             for (const auto & aThisHandlersActuatingProp : aThisHandlersActuatingProps)
             {
                 if ( aThisHandlersActuatingProp == _rActuatingPropertyName )
                 {
-                    (*loop)->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
-                        m_pUIRequestComposer->getUIForPropertyHandler( *loop ),
+                    slaveHandler->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
+                        m_pUIRequestComposer->getUIForPropertyHandler(slaveHandler),
                         _bFirstTimeInit );
                     break;
                 }
@@ -416,13 +402,10 @@ namespace pcr
         MethodGuard aGuard( *this );
 
         // dispose our slave handlers
-        for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
-              loop != m_aSlaveHandlers.end();
-              ++loop
-            )
+        for (auto const& slaveHandler : m_aSlaveHandlers)
         {
-            (*loop)->removePropertyChangeListener( this );
-            (*loop)->dispose();
+            slaveHandler->removePropertyChangeListener( this );
+            slaveHandler->dispose();
         }
 
         clearContainer( m_aSlaveHandlers );
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
index ad398327b989..37eb19bdf6da 100644
--- a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
@@ -655,14 +655,11 @@ namespace pcr
         _rNames.reserve( aAllTypes.size() );
 
         // then allow only those which are "compatible" with our control
-        for ( std::vector< OUString >::const_iterator dataType = aAllTypes.begin();
-              dataType != aAllTypes.end();
-              ++dataType
-            )
+        for (auto const& dataType : aAllTypes)
         {
-            ::rtl::Reference< XSDDataType > pType = m_pHelper->getDataTypeByName( *dataType );
+            ::rtl::Reference< XSDDataType > pType = m_pHelper->getDataTypeByName(dataType);
             if ( pType.is() && m_pHelper->canBindToDataType( pType->classify() ) )
-                _rNames.push_back( *dataType );
+                _rNames.push_back(dataType);
         }
     }
 
diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx
index e09eee8f97ed..ecb36ecaf28a 100644
--- a/extensions/source/update/check/updatecheck.cxx
+++ b/extensions/source/update/check/updatecheck.cxx
@@ -65,18 +65,15 @@ namespace uno = com::sun::star::uno ;
 // Returns the URL of the release note for the given position
 OUString getReleaseNote(const UpdateInfo& rInfo, sal_uInt8 pos, bool autoDownloadEnabled)
 {
-    std::vector< ReleaseNote >::const_iterator iter = rInfo.ReleaseNotes.begin();
-    while( iter != rInfo.ReleaseNotes.end() )
+    for (auto const& elem : rInfo.ReleaseNotes)
     {
-        if( pos == iter->Pos )
+        if( pos == elem.Pos )
         {
-            if( (pos > 2) || !autoDownloadEnabled || iter->URL2.isEmpty() )
-                return iter->URL;
+            if( (pos > 2) || !autoDownloadEnabled || elem.URL2.isEmpty() )
+                return elem.URL;
         }
-        else if( (pos == iter->Pos2) && ((1 == iter->Pos) || (2 == iter->Pos)) && autoDownloadEnabled )
-            return iter->URL2;
-
-        ++iter;
+        else if( (pos == elem.Pos2) && ((1 == elem.Pos) || (2 == elem.Pos)) && autoDownloadEnabled )
+            return elem.URL2;
     }
 
     return OUString();
@@ -1249,18 +1246,15 @@ UpdateCheck::setUpdateInfo(const UpdateInfo& aInfo)
     // Decide whether to use alternate release note pos ..
     bool autoDownloadEnabled = rModel->isAutoDownloadEnabled();
 
-    std::vector< ReleaseNote >::iterator iter2 = m_aUpdateInfo.ReleaseNotes.begin();
-    while( iter2 != m_aUpdateInfo.ReleaseNotes.end() )
+    for (auto & elem : m_aUpdateInfo.ReleaseNotes)
     {
-        if( ((1 == iter2->Pos) || (2 == iter2->Pos)) && autoDownloadEnabled && !iter2->URL2.isEmpty())
+        if( ((1 == elem.Pos) || (2 == elem.Pos)) && autoDownloadEnabled && !elem.URL2.isEmpty())
         {
-            iter2->URL = iter2->URL2;
-            iter2->URL2.clear();
-            iter2->Pos = iter2->Pos2;
-            iter2->Pos2 = 0;
+            elem.URL = elem.URL2;
+            elem.URL2.clear();
+            elem.Pos = elem.Pos2;
+            elem.Pos2 = 0;
         }
-
-        ++iter2;
     }
 
     // do not move below store/clear ..


More information about the Libreoffice-commits mailing list