diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-02-20 01:10:07 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-20 07:17:38 +0100 |
commit | 6a143985bdc5d12d1f9e8cf8592440282986c099 (patch) | |
tree | 346e09d6ba1146b52a6a484a2883f3e898184648 /extensions | |
parent | d707a5e64ba53ddb7669cca725915527aa788a6b (diff) |
Simplify containers iterations in desktop, dtrans, editeng, extensions
Use range-based loop or replace with STL functions
Change-Id: Ic5389d123d0a6a32a8bb46b081165e94a7c55292
Reviewed-on: https://gerrit.libreoffice.org/68036
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/dbpilots/gridwizard.cxx | 11 | ||||
-rw-r--r-- | extensions/source/inc/componentmodule.cxx | 17 | ||||
-rw-r--r-- | extensions/source/propctrlr/browserlistbox.cxx | 17 | ||||
-rw-r--r-- | extensions/source/propctrlr/buttonnavigationhandler.cxx | 2 | ||||
-rw-r--r-- | extensions/source/propctrlr/cellbindinghandler.cxx | 2 | ||||
-rw-r--r-- | extensions/source/propctrlr/editpropertyhandler.cxx | 6 | ||||
-rw-r--r-- | extensions/source/propctrlr/eformspropertyhandler.cxx | 4 | ||||
-rw-r--r-- | extensions/source/propctrlr/formcomponenthandler.cxx | 4 | ||||
-rw-r--r-- | extensions/source/propctrlr/formgeometryhandler.cxx | 2 | ||||
-rw-r--r-- | extensions/source/propctrlr/propcontroller.cxx | 21 | ||||
-rw-r--r-- | extensions/source/propctrlr/propertyeditor.cxx | 7 | ||||
-rw-r--r-- | extensions/source/propctrlr/submissionhandler.cxx | 2 | ||||
-rw-r--r-- | extensions/source/update/check/updatecheck.cxx | 10 |
13 files changed, 41 insertions, 64 deletions
diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx index 617d2504f8d4..7a3ab8374979 100644 --- a/extensions/source/dbpilots/gridwizard.cxx +++ b/extensions/source/dbpilots/gridwizard.cxx @@ -178,20 +178,18 @@ namespace dbp { Reference< XNameAccess > xExistenceChecker(xColumnContainer.get()); - std::vector< OUString >::const_iterator pColumnServiceName = aColumnServiceNames.begin(); std::vector< OUString >::const_iterator pColumnLabelPostfix = aColumnLabelPostfixes.begin(); std::vector< OUString >::const_iterator pFormFieldName = aFormFieldNames.begin(); - std::vector< OUString >::const_iterator pColumnServiceNameEnd = aColumnServiceNames.end(); - for (;pColumnServiceName < pColumnServiceNameEnd; ++pColumnServiceName, ++pColumnLabelPostfix, ++pFormFieldName) + for (const auto& rColumnServiceName : aColumnServiceNames) { // create a (grid)column for the (resultset)column try { - Reference< XPropertySet > xColumn( xColumnFactory->createColumn(*pColumnServiceName), UNO_SET_THROW ); + Reference< XPropertySet > xColumn( xColumnFactory->createColumn(rColumnServiceName), UNO_SET_THROW ); Reference< XPropertySetInfo > xColumnPSI( xColumn->getPropertySetInfo(), UNO_SET_THROW ); - OUString sColumnName(*pColumnServiceName); + OUString sColumnName(rColumnServiceName); disambiguateName(xExistenceChecker, sColumnName); // the data field the column should be bound to @@ -213,6 +211,9 @@ namespace dbp "unexpected exception while creating the grid column for field " << *pFormFieldName ); } + + ++pColumnLabelPostfix; + ++pFormFieldName; } } } diff --git a/extensions/source/inc/componentmodule.cxx b/extensions/source/inc/componentmodule.cxx index 92f7bb45cc1c..18f589c77ccc 100644 --- a/extensions/source/inc/componentmodule.cxx +++ b/extensions/source/inc/componentmodule.cxx @@ -91,17 +91,14 @@ namespace compmodule && (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()), "OModule::revokeComponent : inconsistent state !"); - sal_Int32 nLen = s_pImplementationNames->size(); - for (sal_Int32 i=0; i<nLen; ++i) + auto it = std::find(s_pImplementationNames->begin(), s_pImplementationNames->end(), _rImplementationName); + if (it != s_pImplementationNames->end()) { - if ((*s_pImplementationNames)[i] == _rImplementationName) - { - s_pImplementationNames->erase(s_pImplementationNames->begin() + i); - s_pSupportedServices->erase(s_pSupportedServices->begin() + i); - s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i); - s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i); - break; - } + sal_Int32 i = static_cast<sal_Int32>(std::distance(s_pImplementationNames->begin(), it)); + s_pImplementationNames->erase(it); + s_pSupportedServices->erase(s_pSupportedServices->begin() + i); + s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i); + s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i); } if (s_pImplementationNames->empty()) diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx index dcac53bdf98a..7a3b226b2434 100644 --- a/extensions/source/propctrlr/browserlistbox.cxx +++ b/extensions/source/propctrlr/browserlistbox.cxx @@ -621,9 +621,8 @@ namespace pcr void OBrowserListBox::SetPropertyValue(const OUString& _rEntryName, const Any& _rValue, bool _bUnknownValue ) { - ListBoxLines::iterator line = m_aLines.begin(); - for ( ; line != m_aLines.end() && ( line->aName != _rEntryName ); ++line ) - ; + ListBoxLines::iterator line = std::find_if(m_aLines.begin(), m_aLines.end(), + [&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; }); if ( line != m_aLines.end() ) { @@ -658,9 +657,8 @@ namespace pcr bool OBrowserListBox::impl_getBrowserLineForName( const OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const { - ListBoxLines::const_iterator line = m_aLines.begin(); - for ( ; line != m_aLines.end() && ( line->aName != _rEntryName ); ++line ) - ; + ListBoxLines::const_iterator line = std::find_if(m_aLines.begin(), m_aLines.end(), + [&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; }); if ( line != m_aLines.end() ) _out_rpLine = line->pLine; @@ -1023,14 +1021,13 @@ namespace pcr bool OBrowserListBox::RemoveEntry( const OUString& _rName ) { - ListBoxLines::size_type nPos = 0; - ListBoxLines::iterator it = m_aLines.begin(); - for ( ; it != m_aLines.end() && ( it->aName != _rName ); ++it, ++nPos ) - ; + ListBoxLines::iterator it = std::find_if(m_aLines.begin(), m_aLines.end(), + [&_rName](const ListBoxLine& rLine) { return rLine.aName == _rName; }); if ( it == m_aLines.end() ) return false; + ListBoxLines::size_type nPos = static_cast<ListBoxLines::size_type>(std::distance(m_aLines.begin(), it)); m_aLines.erase( it ); m_aOutOfDateLines.erase( m_aLines.size() ); diff --git a/extensions/source/propctrlr/buttonnavigationhandler.cxx b/extensions/source/propctrlr/buttonnavigationhandler.cxx index 8ffe59cc144d..5488d9b5428b 100644 --- a/extensions/source/propctrlr/buttonnavigationhandler.cxx +++ b/extensions/source/propctrlr/buttonnavigationhandler.cxx @@ -185,7 +185,7 @@ namespace pcr if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } diff --git a/extensions/source/propctrlr/cellbindinghandler.cxx b/extensions/source/propctrlr/cellbindinghandler.cxx index ea8f9924e1bc..5df2611537b1 100644 --- a/extensions/source/propctrlr/cellbindinghandler.cxx +++ b/extensions/source/propctrlr/cellbindinghandler.cxx @@ -477,7 +477,7 @@ namespace pcr if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx index 643e43870640..a1016e2075cd 100644 --- a/extensions/source/propctrlr/editpropertyhandler.cxx +++ b/extensions/source/propctrlr/editpropertyhandler.cxx @@ -222,7 +222,7 @@ namespace pcr if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } @@ -242,7 +242,7 @@ namespace pcr } if ( aSuperseded.empty() ) return Sequence< OUString >(); - return Sequence< OUString >( &(*aSuperseded.begin()), aSuperseded.size() ); + return comphelper::containerToSequence(aSuperseded); } @@ -253,7 +253,7 @@ namespace pcr if ( implHaveTextTypeProperty() ) aInterestingActuatingProps.push_back( PROPERTY_TEXTTYPE ); aInterestingActuatingProps.push_back( PROPERTY_MULTILINE ); - return Sequence< OUString >( &(*aInterestingActuatingProps.begin()), aInterestingActuatingProps.size() ); + return comphelper::containerToSequence(aInterestingActuatingProps); } diff --git a/extensions/source/propctrlr/eformspropertyhandler.cxx b/extensions/source/propctrlr/eformspropertyhandler.cxx index 328c8bf025b7..d074a7e64fed 100644 --- a/extensions/source/propctrlr/eformspropertyhandler.cxx +++ b/extensions/source/propctrlr/eformspropertyhandler.cxx @@ -310,7 +310,7 @@ namespace pcr if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } @@ -392,7 +392,7 @@ namespace pcr std::vector< OUString > aInterestedInActuations( 2 ); aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL; aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME; - return Sequence< OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() ); + return comphelper::containerToSequence(aInterestedInActuations); } diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index 7dfa51afabcf..78719cce93d6 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -858,7 +858,7 @@ namespace pcr if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } Sequence< OUString > SAL_CALL FormComponentPropertyHandler::getSupersededProperties( ) @@ -892,7 +892,7 @@ namespace pcr aInterestingProperties.push_back( PROPERTY_FORMATKEY ); aInterestingProperties.push_back( PROPERTY_EMPTY_IS_NULL ); aInterestingProperties.push_back( PROPERTY_TOGGLE ); - return Sequence< OUString >( &(*aInterestingProperties.begin()), aInterestingProperties.size() ); + return comphelper::containerToSequence(aInterestingProperties); } LineDescriptor SAL_CALL FormComponentPropertyHandler::describePropertyLine( const OUString& _rPropertyName, diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx index 1edeacbf230b..2c81fc76e4bb 100644 --- a/extensions/source/propctrlr/formgeometryhandler.cxx +++ b/extensions/source/propctrlr/formgeometryhandler.cxx @@ -555,7 +555,7 @@ namespace pcr if ( impl_haveSheetAnchorType_nothrow() ) addInt32PropertyDescription( aProperties, PROPERTY_SHEET_ANCHOR_TYPE ); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index 062df51c042c..9f6fa9fcbaed 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -596,17 +596,10 @@ namespace pcr m_pView = nullptr; } - for ( InterfaceArray::iterator loop = m_aInspectedObjects.begin(); - loop != m_aInspectedObjects.end(); - ++loop - ) - { - if ( *loop == _rSource.Source ) - { - m_aInspectedObjects.erase( loop ); - break; - } - } + auto it = std::find_if(m_aInspectedObjects.begin(), m_aInspectedObjects.end(), + [&_rSource](const InterfaceArray::value_type& rxObj) { return rxObj == _rSource.Source; }); + if (it != m_aInspectedObjects.end()) + m_aInspectedObjects.erase(it); } @@ -1462,10 +1455,8 @@ namespace pcr bool OPropertyBrowserController::impl_findObjectProperty_nothrow( const OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty ) { - OrderedPropertyMap::const_iterator search = m_aProperties.begin(); - for ( ; search != m_aProperties.end(); ++search ) - if ( search->second.Name == _rName ) - break; + OrderedPropertyMap::const_iterator search = std::find_if(m_aProperties.begin(), m_aProperties.end(), + [&_rName](const OrderedPropertyMap::value_type& rEntry) { return rEntry.second.Name == _rName; }); if ( _pProperty ) *_pProperty = search; return ( search != m_aProperties.end() ); diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx index f960ee3232ad..40c88d82cc52 100644 --- a/extensions/source/propctrlr/propertyeditor.cxx +++ b/extensions/source/propctrlr/propertyeditor.cxx @@ -97,11 +97,8 @@ namespace pcr m_aPropertyPageIds.swap( aEmpty ); } - while ( !m_aHiddenPages.empty() ) - { - m_aHiddenPages.begin()->second.pPage.disposeAndClear(); - m_aHiddenPages.erase( m_aHiddenPages.begin() ); - } + for (auto& rEntry : m_aHiddenPages) + rEntry.second.pPage.disposeAndClear(); m_aHiddenPages.clear(); } diff --git a/extensions/source/propctrlr/submissionhandler.cxx b/extensions/source/propctrlr/submissionhandler.cxx index 191c17451dbd..d525ad5a821d 100644 --- a/extensions/source/propctrlr/submissionhandler.cxx +++ b/extensions/source/propctrlr/submissionhandler.cxx @@ -269,7 +269,7 @@ namespace pcr } if ( aProperties.empty() ) return Sequence< Property >(); - return Sequence< Property >( &(*aProperties.begin()), aProperties.size() ); + return comphelper::containerToSequence(aProperties); } diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx index dd07258df128..47ef6e18093e 100644 --- a/extensions/source/update/check/updatecheck.cxx +++ b/extensions/source/update/check/updatecheck.cxx @@ -1225,14 +1225,8 @@ UpdateCheck::setUpdateInfo(const UpdateInfo& aInfo) OSL_ASSERT(DISABLED == m_eState || CHECK_SCHEDULED == m_eState); // Ignore leading non direct download if we get direct ones - std::vector< DownloadSource >::iterator iter = m_aUpdateInfo.Sources.begin(); - while( iter != m_aUpdateInfo.Sources.end() ) - { - if( iter->IsDirect ) - break; - - ++iter; - } + std::vector< DownloadSource >::iterator iter = std::find_if(m_aUpdateInfo.Sources.begin(), m_aUpdateInfo.Sources.end(), + [](const DownloadSource& rSource) { return rSource.IsDirect; }); if( (iter != m_aUpdateInfo.Sources.begin()) && (iter != m_aUpdateInfo.Sources.end()) && |