Kaydet (Commit) 86192438 authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

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: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6f50961e
......@@ -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)
{
......
......@@ -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 )
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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 );
}
}
......
......@@ -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 );
......
......@@ -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& )
......
......@@ -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;
}
......
......@@ -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;
}
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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 );
}
}
......
......@@ -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" );
......
......@@ -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
......
......@@ -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" );
......
......@@ -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