summaryrefslogtreecommitdiff
path: root/extensions/source/propctrlr
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-20 01:10:07 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-20 07:17:38 +0100
commit6a143985bdc5d12d1f9e8cf8592440282986c099 (patch)
tree346e09d6ba1146b52a6a484a2883f3e898184648 /extensions/source/propctrlr
parentd707a5e64ba53ddb7669cca725915527aa788a6b (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/source/propctrlr')
-rw-r--r--extensions/source/propctrlr/browserlistbox.cxx17
-rw-r--r--extensions/source/propctrlr/buttonnavigationhandler.cxx2
-rw-r--r--extensions/source/propctrlr/cellbindinghandler.cxx2
-rw-r--r--extensions/source/propctrlr/editpropertyhandler.cxx6
-rw-r--r--extensions/source/propctrlr/eformspropertyhandler.cxx4
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx4
-rw-r--r--extensions/source/propctrlr/formgeometryhandler.cxx2
-rw-r--r--extensions/source/propctrlr/propcontroller.cxx21
-rw-r--r--extensions/source/propctrlr/propertyeditor.cxx7
-rw-r--r--extensions/source/propctrlr/submissionhandler.cxx2
10 files changed, 26 insertions, 41 deletions
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);
}