[Libreoffice-commits] core.git: test/source testtools/source toolkit/source tools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 24 12:45:49 UTC 2018
test/source/screenshot_test.cxx | 4 -
test/source/sheet/xdatapilottable2.cxx | 7 --
testtools/source/performance/ubtest.cxx | 21 ++----
toolkit/source/awt/animatedimagespeer.cxx | 9 --
toolkit/source/awt/vclxgraphics.cxx | 10 ---
toolkit/source/awt/vclxregion.cxx | 4 -
toolkit/source/awt/vclxtabpagecontainer.cxx | 8 --
toolkit/source/awt/vclxwindow.cxx | 31 +++------
toolkit/source/controls/controlmodelcontainerbase.cxx | 5 -
toolkit/source/controls/grid/defaultgridcolumnmodel.cxx | 21 +-----
toolkit/source/controls/grid/defaultgriddatamodel.cxx | 4 -
toolkit/source/controls/grid/sortablegriddatamodel.cxx | 9 --
toolkit/source/controls/roadmapcontrol.cxx | 4 -
toolkit/source/controls/tree/treedatamodel.cxx | 8 --
toolkit/source/controls/unocontrol.cxx | 8 --
toolkit/source/controls/unocontrolcontainer.cxx | 51 ++++++----------
toolkit/source/controls/unocontrolmodel.cxx | 27 ++++----
toolkit/source/helper/btndlg.cxx | 22 +++---
toolkit/source/helper/unopropertyarrayhelper.cxx | 16 ++---
tools/source/stream/strmunx.cxx | 47 +++++---------
20 files changed, 124 insertions(+), 192 deletions(-)
New commits:
commit 86192438d16ec160d6b59d08735e770ee05ac113
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Wed Oct 24 00:49:27 2018 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Oct 24 14:45:19 2018 +0200
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 at collabora.co.uk>
diff --git a/test/source/screenshot_test.cxx b/test/source/screenshot_test.cxx
index fbe6ca10b501..fc4bf5acf447 100644
--- a/test/source/screenshot_test.cxx
+++ b/test/source/screenshot_test.cxx
@@ -222,9 +222,9 @@ void ScreenshotTest::dumpDialogToPath(const OString& rUIXMLDescription)
void ScreenshotTest::processAllKnownDialogs()
{
- for (mapType::const_iterator i = getKnownDialogs().begin(); i != getKnownDialogs().end(); ++i)
+ for (const auto& rDialog : getKnownDialogs())
{
- ScopedVclPtr<VclAbstractDialog> pDlg(createDialogByID((*i).second));
+ ScopedVclPtr<VclAbstractDialog> pDlg(createDialogByID(rDialog.second));
if (pDlg)
{
diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx
index d54a12f425bb..dc23c1045cb4 100644
--- a/test/source/sheet/xdatapilottable2.cxx
+++ b/test/source/sheet/xdatapilottable2.cxx
@@ -63,10 +63,9 @@ void XDataPilotTable2::testGetDrillDownData()
buildDataFields(xDPTable);
buildResultCells(xDPTable);
- for (std::vector<table::CellAddress>::iterator itr = maResultCells.begin();
- itr != maResultCells.end(); ++itr)
+ for (const auto& rResultCell : maResultCells)
{
- sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(*itr);
+ sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(rResultCell);
Any aTempAny = aPosData.PositionData;
sheet::DataPilotTableResultData aResData;
CPPUNIT_ASSERT(aTempAny >>= aResData);
@@ -74,7 +73,7 @@ void XDataPilotTable2::testGetDrillDownData()
sheet::DataResult aRes = aResData.Result;
double nVal = aRes.Value;
- Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(*itr);
+ Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(rResultCell);
double sum = 0;
if( aData.getLength() > 1 )
diff --git a/testtools/source/performance/ubtest.cxx b/testtools/source/performance/ubtest.cxx
index 9b342d657d5a..cc17f097d1b8 100644
--- a/testtools/source/performance/ubtest.cxx
+++ b/testtools/source/performance/ubtest.cxx
@@ -1146,18 +1146,16 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
sal_Int32 nPos = 60;
out( "[direct in process]", stream, nPos );
- t_TimingSheetMap::const_iterator iSheets( aSheets.begin() );
- for ( ; iSheets != aSheets.end(); ++iSheets )
+ for ( const auto& rSheet : aSheets )
{
nPos += 40;
out( "[", stream, nPos );
- out( (*iSheets).first.c_str(), stream );
+ out( rSheet.first.c_str(), stream );
out( "]", stream );
}
- for ( t_TimeEntryMap::const_iterator iTopics( aDirect._entries.begin() );
- iTopics != aDirect._entries.end(); ++iTopics )
+ for ( const auto& rTopics : aDirect._entries )
{
- const std::string & rTopic = (*iTopics).first;
+ const std::string & rTopic = rTopics.first;
out( "\n", stream );
out( rTopic.c_str(), stream );
@@ -1166,7 +1164,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
sal_Int32 nPos = 60;
- double secs = (*iTopics).second.secPerCall();
+ double secs = rTopics.second.secPerCall();
if (secs > 0.0)
{
out( secs * 1000, stream, nPos );
@@ -1177,11 +1175,10 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
out( "NA", stream, nPos );
}
- iSheets = aSheets.begin();
- for ( ; iSheets != aSheets.end(); ++iSheets )
+ for ( const auto& rSheet : aSheets )
{
- const t_TimeEntryMap::const_iterator iFind( (*iSheets).second._entries.find( rTopic ) );
- OSL_ENSURE( iFind != (*iSheets).second._entries.end(), "####" );
+ const t_TimeEntryMap::const_iterator iFind( rSheet.second._entries.find( rTopic ) );
+ OSL_ENSURE( iFind != rSheet.second._entries.end(), "####" );
nPos += 40;
@@ -1192,7 +1189,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
out( "ms", stream );
out( " (", stream );
- double ratio = (*iFind).second.ratio( (*iTopics).second );
+ double ratio = (*iFind).second.ratio( rTopics.second );
if (ratio != 0.0)
{
out( ratio, stream );
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx
index a0fa5cc71567..8221d5a21082 100644
--- a/toolkit/source/awt/animatedimagespeer.cxx
+++ b/toolkit/source/awt/animatedimagespeer.cxx
@@ -247,13 +247,10 @@ namespace toolkit
::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] );
aImages.resize( rImageSet.size() );
sal_Int32 imageIndex = 0;
- for ( ::std::vector< CachedImage >::const_iterator cachedImage = rImageSet.begin();
- cachedImage != rImageSet.end();
- ++cachedImage, ++imageIndex
- )
+ for ( const auto& rCachedImage : rImageSet )
{
- lcl_ensureImage_throw( xGraphicProvider, isHighContrast, *cachedImage );
- aImages[ imageIndex ] = Image(cachedImage->xGraphic);
+ lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rCachedImage );
+ aImages[ imageIndex++ ] = Image(rCachedImage.xGraphic);
}
}
pThrobber->setImageList( aImages );
diff --git a/toolkit/source/awt/vclxgraphics.cxx b/toolkit/source/awt/vclxgraphics.cxx
index 533e03449e0c..65386f1fba48 100644
--- a/toolkit/source/awt/vclxgraphics.cxx
+++ b/toolkit/source/awt/vclxgraphics.cxx
@@ -69,13 +69,9 @@ VCLXGraphics::~VCLXGraphics()
std::vector< VCLXGraphics* > *pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : nullptr;
if ( pLst )
{
- for( std::vector< VCLXGraphics* >::iterator it = pLst->begin(); it != pLst->end(); ++it )
- {
- if( *it == this ) {
- pLst->erase( it );
- break;
- }
- }
+ auto it = std::find(pLst->begin(), pLst->end(), this);
+ if (it != pLst->end())
+ pLst->erase( it );
}
mpClipRegion.reset();
diff --git a/toolkit/source/awt/vclxregion.cxx b/toolkit/source/awt/vclxregion.cxx
index 3922483ee9a9..a7ebd722debf 100644
--- a/toolkit/source/awt/vclxregion.cxx
+++ b/toolkit/source/awt/vclxregion.cxx
@@ -148,9 +148,9 @@ css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles()
css::uno::Sequence< css::awt::Rectangle > aRects(aRectangles.size());
sal_uInt32 a(0);
- for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
+ for(const auto& rRect : aRectangles)
{
- aRects.getArray()[a++] = AWTRectangle(*aRectIter);
+ aRects.getArray()[a++] = AWTRectangle(rRect);
}
//Rectangle aRect;
diff --git a/toolkit/source/awt/vclxtabpagecontainer.cxx b/toolkit/source/awt/vclxtabpagecontainer.cxx
index 391072f1cd47..5ef02d4e2919 100644
--- a/toolkit/source/awt/vclxtabpagecontainer.cxx
+++ b/toolkit/source/awt/vclxtabpagecontainer.cxx
@@ -125,15 +125,13 @@ Reference< css::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageBy
{
SolarMutexGuard aGuard;
Reference< css::awt::tab::XTabPage > xTabPage;
- ::std::vector< Reference< css::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin();
- ::std::vector< Reference< css::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end();
- for(;aIter != aEnd;++aIter)
+ for(const auto& rTabPage : m_aTabPages)
{
- Reference< awt::XControl > xControl(*aIter,UNO_QUERY );
+ Reference< awt::XControl > xControl(rTabPage,UNO_QUERY );
Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
if ( tabPageID == xP->getTabPageID() )
{
- xTabPage = *aIter;
+ xTabPage = rTabPage;
break;
}
}
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index eb3df832c972..9843cd863cd2 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -291,12 +291,9 @@ IMPL_LINK_NOARG(VCLXWindowImpl, OnProcessCallbacks, void*, void)
{
SAL_INFO("toolkit.controls", "OnProcessCallbacks relinquished solarmutex");
SolarMutexReleaser aReleaseSolar;
- for ( CallbackArray::const_iterator loop = aCallbacksCopy.begin();
- loop != aCallbacksCopy.end();
- ++loop
- )
+ for (const auto& rCallback : aCallbacksCopy)
{
- (*loop)();
+ rCallback();
}
}
}
@@ -1330,20 +1327,16 @@ void VCLXWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds, bool bWith
// lovely hack from:
// void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
- std::vector< sal_uInt16 >::const_iterator iter;
- for( iter = rIds.begin(); iter != rIds.end(); ++iter) {
- if( *iter == BASEPROPERTY_FONTDESCRIPTOR )
- {
- // some properties are not included in the FontDescriptor, but every time
- // when we have a FontDescriptor we want to have these properties too.
- // => Easier to register the here, instead everywhere where I register the FontDescriptor...
-
- rIds.push_back( BASEPROPERTY_TEXTCOLOR );
- rIds.push_back( BASEPROPERTY_TEXTLINECOLOR );
- rIds.push_back( BASEPROPERTY_FONTRELIEF );
- rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
- break;
- }
+ if( std::find(rIds.begin(), rIds.end(), BASEPROPERTY_FONTDESCRIPTOR) != rIds.end() )
+ {
+ // some properties are not included in the FontDescriptor, but every time
+ // when we have a FontDescriptor we want to have these properties too.
+ // => Easier to register the here, instead everywhere where I register the FontDescriptor...
+
+ rIds.push_back( BASEPROPERTY_TEXTCOLOR );
+ rIds.push_back( BASEPROPERTY_TEXTLINECOLOR );
+ rIds.push_back( BASEPROPERTY_FONTRELIEF );
+ rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
}
}
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 69bc6b94fb48..1235e6c09889 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -707,10 +707,9 @@ Sequence< Reference< XControlModel > > SAL_CALL ControlModelContainerBase::getCo
::std::vector< Reference< XControlModel > > aUnindexedModels;
// will be the container of all models which do not have a tab index property
- UnoControlModelHolderVector::const_iterator aLoop = maModels.begin();
- for ( ; aLoop != maModels.end(); ++aLoop )
+ for ( const auto& rModel : maModels )
{
- Reference< XControlModel > xModel( aLoop->first );
+ Reference< XControlModel > xModel( rModel.first );
// see if the model has a TabIndex property
Reference< XPropertySet > xControlProps( xModel, UNO_QUERY );
diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
index d6eb98d3b0bd..00a34fc696c2 100644
--- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
+++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx
@@ -287,32 +287,23 @@ private:
}
// fire removal notifications
- for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin();
- event != aRemovedColumns.end();
- ++event
- )
+ for (const auto& rEvent : aRemovedColumns)
{
- m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event );
+ m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, rEvent );
}
// fire insertion notifications
- for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin();
- event != aInsertedColumns.end();
- ++event
- )
+ for (const auto& rEvent : aInsertedColumns)
{
- m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event );
+ m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, rEvent );
}
// dispose removed columns
- for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin();
- event != aRemovedColumns.end();
- ++event
- )
+ for (const auto& rEvent : aRemovedColumns)
{
try
{
- const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW );
+ const Reference< XComponent > xColComp( rEvent.Element, UNO_QUERY_THROW );
xColComp->dispose();
}
catch( const Exception& )
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index e613878a3166..35252453c2cc 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -444,8 +444,8 @@ private:
::comphelper::ComponentGuard aGuard( *this, rBHelper );
RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
- for ( RowData::iterator cell = rRowData.begin(); cell != rRowData.end(); ++cell )
- cell->second = i_value;
+ for ( auto& rCell : rRowData )
+ rCell.second = i_value;
}
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
index 9f7edd97a369..f17ae53c14c0 100644
--- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
@@ -375,13 +375,10 @@ void lcl_clear( STLCONTAINER& i_container )
void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold )
{
- for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin();
- loop != io_indexMap.end();
- ++loop
- )
+ for ( auto& rIndex : io_indexMap )
{
- if ( *loop >= i_threshold )
- --*loop;
+ if ( rIndex >= i_threshold )
+ --rIndex;
}
}
diff --git a/toolkit/source/controls/roadmapcontrol.cxx b/toolkit/source/controls/roadmapcontrol.cxx
index 48e7902b2a93..1807c2200394 100644
--- a/toolkit/source/controls/roadmapcontrol.cxx
+++ b/toolkit/source/controls/roadmapcontrol.cxx
@@ -232,9 +232,9 @@ static void lcl_throwIndexOutOfBoundsException( )
while ( bIncrement )
{
bIncrement = false;
- for ( RoadmapItemHolderList::iterator i = maRoadmapItems.begin(); i < maRoadmapItems.end(); ++i )
+ for ( const auto& rRoadmapItem : maRoadmapItems )
{
- CurRoadmapItem = *i;
+ CurRoadmapItem = rRoadmapItem;
Reference< XPropertySet > xPropertySet( CurRoadmapItem, UNO_QUERY );
aAny = xPropertySet->getPropertyValue("ID");
aAny >>= n_CurItemID;
diff --git a/toolkit/source/controls/tree/treedatamodel.cxx b/toolkit/source/controls/tree/treedatamodel.cxx
index 0c5cd4347b6b..84838061cbdd 100644
--- a/toolkit/source/controls/tree/treedatamodel.cxx
+++ b/toolkit/source/controls/tree/treedatamodel.cxx
@@ -264,9 +264,8 @@ MutableTreeNode::MutableTreeNode( const MutableTreeDataModelRef& xModel, const A
MutableTreeNode::~MutableTreeNode()
{
- TreeNodeVector::iterator aIter( maChildren.begin() );
- while( aIter != maChildren.end() )
- (*aIter++)->setParent(nullptr);
+ for( auto& rChild : maChildren )
+ rChild->setParent(nullptr);
}
void MutableTreeNode::setParent( MutableTreeNode* pParent )
@@ -336,8 +335,7 @@ void SAL_CALL MutableTreeNode::insertChildByIndex( sal_Int32 nChildIndex, const
xImpl->mbIsInserted = true;
TreeNodeVector::iterator aIter( maChildren.begin() );
- while( (nChildIndex-- > 0) && (aIter != maChildren.end()) )
- ++aIter;
+ std::advance(aIter, nChildIndex);
maChildren.insert( aIter, xImpl );
xImpl->setParent( this );
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index 28dac1716889..a52eaf80e6fc 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -644,13 +644,9 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
// setting peer properties may result in an attempt to acquire the solar mutex, 'cause the peers
// usually don't have an own mutex but use the SolarMutex instead.
// To prevent deadlocks resulting from this, we do this without our own mutex locked
- std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end();
- for ( std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin();
- aLoop != aEnd;
- ++aLoop
- )
+ for (const auto& rProp : aPeerPropertiesToSet)
{
- ImplSetPeerProperty( aLoop->Name, aLoop->Value );
+ ImplSetPeerProperty( rProp.Name, rProp.Value );
}
}
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index 7311a184ed48..86ad983ff8e1 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -175,11 +175,11 @@ void UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XCon
{
_out_rControls.realloc( maControls.size() );
uno::Reference< awt::XControl >* pControls = _out_rControls.getArray();
- for ( ControlMap::const_iterator loop = maControls.begin();
- loop != maControls.end();
- ++loop, ++pControls
- )
- *pControls = loop->second->getControl();
+ for (const auto& rEntry : maControls)
+ {
+ *pControls = rEntry.second->getControl();
+ ++pControls;
+ }
}
@@ -187,36 +187,30 @@ void UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIde
{
_out_rIdentifiers.realloc( maControls.size() );
sal_Int32* pIndentifiers = _out_rIdentifiers.getArray();
- for ( ControlMap::const_iterator loop = maControls.begin();
- loop != maControls.end();
- ++loop, ++pIndentifiers
- )
- *pIndentifiers = loop->first;
+ for (const auto& rEntry : maControls)
+ {
+ *pIndentifiers = rEntry.first;
+ ++pIndentifiers;
+ }
}
uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const OUString& _rName ) const
{
- for ( ControlMap::const_iterator loop = maControls.begin();
- loop != maControls.end();
- ++loop
- )
- if ( loop->second->getName() == _rName )
- return loop->second->getControl();
+ auto loop = std::find_if(maControls.begin(), maControls.end(),
+ [&_rName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == _rName; });
+ if (loop != maControls.end())
+ return loop->second->getControl();
return uno::Reference< awt::XControl >();
}
UnoControlHolderList::ControlIdentifier UnoControlHolderList::getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl )
{
- for ( ControlMap::iterator loop = maControls.begin();
- loop != maControls.end();
- ++loop
- )
- {
- if ( loop->second->getControl().get() == _rxControl.get() )
- return loop->first;
- }
+ auto loop = std::find_if(maControls.begin(), maControls.end(),
+ [&_rxControl](const ControlMap::value_type& rEntry) { return rEntry.second->getControl().get() == _rxControl.get(); });
+ if (loop != maControls.end())
+ return loop->first;
return -1;
}
@@ -284,13 +278,8 @@ OUString UnoControlHolderList::impl_getFreeName_throw()
for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
{
OUString candidateName( "control_" + OUString::number( candidateId ) );
- ControlMap::const_iterator loop = maControls.begin();
- for ( ; loop != maControls.end(); ++loop )
- {
- if ( loop->second->getName() == candidateName )
- break;
- }
- if ( loop == maControls.end() )
+ if ( std::none_of(maControls.begin(), maControls.end(),
+ [&candidateName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == candidateName; }) )
return candidateName;
}
throw uno::RuntimeException("out of identifiers" );
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index e27ec6da790e..b59d4ce0e22d 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -140,8 +140,8 @@ css::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const
css::uno::Sequence<sal_Int32> aIDs( nIDs );
sal_Int32* pIDs = aIDs.getArray();
sal_uInt32 n = 0;
- for ( ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
- pIDs[n++] = it->first;
+ for ( const auto& rData : maData )
+ pIDs[n++] = rData.first;
return aIDs;
}
@@ -408,11 +408,10 @@ void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
void UnoControlModel::ImplRegisterProperties( const std::vector< sal_uInt16 > &rIds )
{
- std::vector< sal_uInt16 >::const_iterator iter;
- for( iter = rIds.begin(); iter != rIds.end(); ++iter)
+ for (const auto& rId : rIds)
{
- if( !ImplHasProperty( *iter ) )
- ImplRegisterProperty( *iter, ImplGetDefaultValue( *iter ) );
+ if( !ImplHasProperty( rId ) )
+ ImplRegisterProperty( rId, ImplGetDefaultValue( rId ) );
}
}
@@ -538,12 +537,12 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
std::set<sal_uInt16> aProps;
- for (ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it )
+ for (const auto& rData : maData)
{
- if ( ( ( GetPropertyAttribs( it->first ) & css::beans::PropertyAttribute::TRANSIENT ) == 0 )
- && ( getPropertyState( GetPropertyName( it->first ) ) != css::beans::PropertyState_DEFAULT_VALUE ) )
+ if ( ( ( GetPropertyAttribs( rData.first ) & css::beans::PropertyAttribute::TRANSIENT ) == 0 )
+ && ( getPropertyState( GetPropertyName( rData.first ) ) != css::beans::PropertyState_DEFAULT_VALUE ) )
{
- aProps.insert( it->first );
+ aProps.insert( rData.first );
}
}
@@ -552,13 +551,13 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
// Save FontProperty always in the old format (due to missing distinction
// between 5.0 and 5.1)
OutStream->writeLong( ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() ) ? ( nProps + 3 ) : nProps );
- for ( std::set<sal_uInt16>::const_iterator it = aProps.begin(); it != aProps.end(); ++it )
+ for ( const auto& rProp : aProps )
{
sal_Int32 nPropDataBeginMark = xMark->createMark();
OutStream->writeLong( 0 ); // DataLen
- const css::uno::Any* pProp = &(maData[*it]);
- OutStream->writeShort( *it );
+ const css::uno::Any* pProp = &(maData[rProp]);
+ OutStream->writeShort( rProp );
bool bVoid = pProp->getValueType().getTypeClass() == css::uno::TypeClass_VOID;
@@ -687,7 +686,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
SAL_WARN( "toolkit", "UnoControlModel::write: don't know how to handle a property of type '"
<< rType.getTypeName()
<< "'.\n(Currently handling property '"
- << GetPropertyName( *it )
+ << GetPropertyName( rProp )
<< "'.)");
}
#endif
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;
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index 77c30850a1ba..c682071a112c 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
@@ -110,33 +111,25 @@ bool lockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream* pSt
osl::MutexGuard aGuard( LockMutex::get() );
std::vector<InternalStreamLock> &rLockList = LockList::get();
- for( std::vector<InternalStreamLock>::const_iterator i = rLockList.begin();
- i != rLockList.end(); )
+ for( const auto& rLock : rLockList )
{
- if( aItem.isIdenticalTo( i->m_aItem ) )
+ if( aItem.isIdenticalTo( rLock.m_aItem ) )
{
- bool bDenyByOptions = false;
- StreamMode nLockMode = i->m_pStream->GetStreamMode();
+ StreamMode nLockMode = rLock.m_pStream->GetStreamMode();
StreamMode nNewMode = pStream->GetStreamMode();
-
- if( nLockMode & StreamMode::SHARE_DENYALL )
- bDenyByOptions = true;
- else if( ( nLockMode & StreamMode::SHARE_DENYWRITE ) &&
- ( nNewMode & StreamMode::WRITE ) )
- bDenyByOptions = true;
- else if( ( nLockMode &StreamMode::SHARE_DENYREAD ) &&
- ( nNewMode & StreamMode::READ ) )
- bDenyByOptions = true;
+ bool bDenyByOptions = (nLockMode & StreamMode::SHARE_DENYALL) ||
+ ( (nLockMode & StreamMode::SHARE_DENYWRITE) && (nNewMode & StreamMode::WRITE) ) ||
+ ( (nLockMode & StreamMode::SHARE_DENYREAD) && (nNewMode & StreamMode::READ) );
if( bDenyByOptions )
{
- if( i->m_nStartPos == 0 && i->m_nEndPos == 0 ) // whole file is already locked
+ if( rLock.m_nStartPos == 0 && rLock.m_nEndPos == 0 ) // whole file is already locked
return false;
if( nStart == 0 && nEnd == 0) // cannot lock whole file
return false;
- if( ( nStart < i->m_nStartPos && nEnd > i->m_nStartPos ) ||
- ( nStart < i->m_nEndPos && nEnd > i->m_nEndPos ) )
+ if( ( nStart < rLock.m_nStartPos && nEnd > rLock.m_nStartPos ) ||
+ ( nStart < rLock.m_nEndPos && nEnd > rLock.m_nEndPos ) )
return false;
}
}
@@ -149,20 +142,12 @@ void unlockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream co
{
osl::MutexGuard aGuard( LockMutex::get() );
std::vector<InternalStreamLock> &rLockList = LockList::get();
- for( std::vector<InternalStreamLock>::iterator i = rLockList.begin();
- i != rLockList.end(); )
- {
- if ( i->m_pStream == pStream
- && ( ( nStart == 0 && nEnd == 0 )
- || ( i->m_nStartPos == nStart && i->m_nEndPos == nEnd ) ) )
- {
- i = rLockList.erase(i);
- }
- else
- {
- ++i;
- }
- }
+ rLockList.erase(std::remove_if(rLockList.begin(), rLockList.end(),
+ [&pStream, &nStart, &nEnd](const InternalStreamLock& rLock) {
+ return rLock.m_pStream == pStream
+ && ((nStart == 0 && nEnd == 0)
+ || (rLock.m_nStartPos == nStart && rLock.m_nEndPos == nEnd));
+ }), rLockList.end());
}
}
More information about the Libreoffice-commits
mailing list