diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2018-10-24 00:49:27 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-24 14:45:19 +0200 |
commit | 86192438d16ec160d6b59d08735e770ee05ac113 (patch) | |
tree | 25dbb9dde6631d49b0ea8483c8f3018def3ddd0d /toolkit/source/helper | |
parent | 6f50961e69406a17d6ec998956a6b33208b1001b (diff) |
Simplify containers iterations in test..tools
Use range-based loop or replace with STL functions.
Change-Id: If8fac9236a4696c8e56c0e81c60c429782581b96
Reviewed-on: https://gerrit.libreoffice.org/62262
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'toolkit/source/helper')
-rw-r--r-- | toolkit/source/helper/btndlg.cxx | 22 | ||||
-rw-r--r-- | toolkit/source/helper/unopropertyarrayhelper.cxx | 16 |
2 files changed, 18 insertions, 20 deletions
diff --git a/toolkit/source/helper/btndlg.cxx b/toolkit/source/helper/btndlg.cxx index 5b7683c9da86..8a19c6041506 100644 --- a/toolkit/source/helper/btndlg.cxx +++ b/toolkit/source/helper/btndlg.cxx @@ -292,19 +292,17 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId, void ButtonDialog::RemoveButton( sal_uInt16 nId ) { - for (std::vector<std::unique_ptr<ImplBtnDlgItem>>::iterator it - = m_ItemList.begin(); it != m_ItemList.end(); ++it) + auto it = std::find_if(m_ItemList.begin(), m_ItemList.end(), + [&nId](const std::unique_ptr<ImplBtnDlgItem>& rItem) { return rItem->mnId == nId; }); + if (it != m_ItemList.end()) { - if ((*it)->mnId == nId) - { - (*it)->mpPushButton->Hide(); - if ((*it)->mbOwnButton) - (*it)->mpPushButton.disposeAndClear(); - else - (*it)->mpPushButton.clear(); - m_ItemList.erase(it); - return; - } + (*it)->mpPushButton->Hide(); + if ((*it)->mbOwnButton) + (*it)->mpPushButton.disposeAndClear(); + else + (*it)->mpPushButton.clear(); + m_ItemList.erase(it); + return; } SAL_WARN( "vcl.window", "ButtonDialog::RemoveButton(): ButtonId invalid" ); diff --git a/toolkit/source/helper/unopropertyarrayhelper.cxx b/toolkit/source/helper/unopropertyarrayhelper.cxx index 8ac6f95103c8..704f797d11b1 100644 --- a/toolkit/source/helper/unopropertyarrayhelper.cxx +++ b/toolkit/source/helper/unopropertyarrayhelper.cxx @@ -36,9 +36,8 @@ UnoPropertyArrayHelper::UnoPropertyArrayHelper( const css::uno::Sequence<sal_Int UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::vector< sal_uInt16 > &rIDs ) { - std::vector< sal_uInt16 >::const_iterator iter; - for( iter = rIDs.begin(); iter != rIDs.end(); ++iter) - maIDs.insert( *iter ); + for (const auto& rId : rIDs) + maIDs.insert( rId ); } bool UnoPropertyArrayHelper::ImplHasProperty( sal_uInt16 nPropId ) const @@ -69,9 +68,9 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties // Sort by names ... std::map<sal_Int32, sal_uInt16> aSortedPropsIds; - for( std::set<sal_Int32>::const_iterator it = maIDs.begin(); it != maIDs.end(); ++it) + for (const auto& rId : maIDs) { - sal_uInt16 nId = sal::static_int_cast< sal_uInt16 >(*it); + sal_uInt16 nId = sal::static_int_cast< sal_uInt16 >(rId); aSortedPropsIds[ 1+GetPropertyOrderNr( nId ) ] = nId; if ( nId == BASEPROPERTY_FONTDESCRIPTOR ) @@ -86,14 +85,15 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties css::uno::Sequence< css::beans::Property> aProps( nProps ); css::beans::Property* pProps = aProps.getArray(); - std::map<sal_Int32, sal_uInt16>::const_iterator it = aSortedPropsIds.begin(); - for ( sal_uInt32 n = 0; n < nProps; n++, ++it ) + sal_uInt32 n = 0; + for ( const auto& rPropIds : aSortedPropsIds ) { - sal_uInt16 nId = it->second; + sal_uInt16 nId = rPropIds.second; pProps[n].Name = GetPropertyName( nId ); pProps[n].Handle = nId; pProps[n].Type = *GetPropertyType( nId ); pProps[n].Attributes = GetPropertyAttribs( nId ); + ++n; } return aProps; |