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) ...@@ -222,9 +222,9 @@ void ScreenshotTest::dumpDialogToPath(const OString& rUIXMLDescription)
void ScreenshotTest::processAllKnownDialogs() 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) if (pDlg)
{ {
......
...@@ -63,10 +63,9 @@ void XDataPilotTable2::testGetDrillDownData() ...@@ -63,10 +63,9 @@ void XDataPilotTable2::testGetDrillDownData()
buildDataFields(xDPTable); buildDataFields(xDPTable);
buildResultCells(xDPTable); buildResultCells(xDPTable);
for (std::vector<table::CellAddress>::iterator itr = maResultCells.begin(); for (const auto& rResultCell : maResultCells)
itr != maResultCells.end(); ++itr)
{ {
sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(*itr); sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(rResultCell);
Any aTempAny = aPosData.PositionData; Any aTempAny = aPosData.PositionData;
sheet::DataPilotTableResultData aResData; sheet::DataPilotTableResultData aResData;
CPPUNIT_ASSERT(aTempAny >>= aResData); CPPUNIT_ASSERT(aTempAny >>= aResData);
...@@ -74,7 +73,7 @@ void XDataPilotTable2::testGetDrillDownData() ...@@ -74,7 +73,7 @@ void XDataPilotTable2::testGetDrillDownData()
sheet::DataResult aRes = aResData.Result; sheet::DataResult aRes = aResData.Result;
double nVal = aRes.Value; double nVal = aRes.Value;
Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(*itr); Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(rResultCell);
double sum = 0; double sum = 0;
if( aData.getLength() > 1 ) if( aData.getLength() > 1 )
......
...@@ -1146,18 +1146,16 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs ) ...@@ -1146,18 +1146,16 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
sal_Int32 nPos = 60; sal_Int32 nPos = 60;
out( "[direct in process]", stream, nPos ); out( "[direct in process]", stream, nPos );
t_TimingSheetMap::const_iterator iSheets( aSheets.begin() ); for ( const auto& rSheet : aSheets )
for ( ; iSheets != aSheets.end(); ++iSheets )
{ {
nPos += 40; nPos += 40;
out( "[", stream, nPos ); out( "[", stream, nPos );
out( (*iSheets).first.c_str(), stream ); out( rSheet.first.c_str(), stream );
out( "]", stream ); out( "]", stream );
} }
for ( t_TimeEntryMap::const_iterator iTopics( aDirect._entries.begin() ); for ( const auto& rTopics : aDirect._entries )
iTopics != aDirect._entries.end(); ++iTopics )
{ {
const std::string & rTopic = (*iTopics).first; const std::string & rTopic = rTopics.first;
out( "\n", stream ); out( "\n", stream );
out( rTopic.c_str(), stream ); out( rTopic.c_str(), stream );
...@@ -1166,7 +1164,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs ) ...@@ -1166,7 +1164,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
sal_Int32 nPos = 60; sal_Int32 nPos = 60;
double secs = (*iTopics).second.secPerCall(); double secs = rTopics.second.secPerCall();
if (secs > 0.0) if (secs > 0.0)
{ {
out( secs * 1000, stream, nPos ); out( secs * 1000, stream, nPos );
...@@ -1177,11 +1175,10 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs ) ...@@ -1177,11 +1175,10 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
out( "NA", stream, nPos ); out( "NA", stream, nPos );
} }
iSheets = aSheets.begin(); for ( const auto& rSheet : aSheets )
for ( ; iSheets != aSheets.end(); ++iSheets )
{ {
const t_TimeEntryMap::const_iterator iFind( (*iSheets).second._entries.find( rTopic ) ); const t_TimeEntryMap::const_iterator iFind( rSheet.second._entries.find( rTopic ) );
OSL_ENSURE( iFind != (*iSheets).second._entries.end(), "####" ); OSL_ENSURE( iFind != rSheet.second._entries.end(), "####" );
nPos += 40; nPos += 40;
...@@ -1192,7 +1189,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs ) ...@@ -1192,7 +1189,7 @@ sal_Int32 TestImpl::run( const Sequence< OUString > & rArgs )
out( "ms", stream ); out( "ms", stream );
out( " (", stream ); out( " (", stream );
double ratio = (*iFind).second.ratio( (*iTopics).second ); double ratio = (*iFind).second.ratio( rTopics.second );
if (ratio != 0.0) if (ratio != 0.0)
{ {
out( ratio, stream ); out( ratio, stream );
......
...@@ -247,13 +247,10 @@ namespace toolkit ...@@ -247,13 +247,10 @@ namespace toolkit
::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] ); ::std::vector< CachedImage > const& rImageSet( i_data.aCachedImageSets[ nPreferredSet ] );
aImages.resize( rImageSet.size() ); aImages.resize( rImageSet.size() );
sal_Int32 imageIndex = 0; sal_Int32 imageIndex = 0;
for ( ::std::vector< CachedImage >::const_iterator cachedImage = rImageSet.begin(); for ( const auto& rCachedImage : rImageSet )
cachedImage != rImageSet.end();
++cachedImage, ++imageIndex
)
{ {
lcl_ensureImage_throw( xGraphicProvider, isHighContrast, *cachedImage ); lcl_ensureImage_throw( xGraphicProvider, isHighContrast, rCachedImage );
aImages[ imageIndex ] = Image(cachedImage->xGraphic); aImages[ imageIndex++ ] = Image(rCachedImage.xGraphic);
} }
} }
pThrobber->setImageList( aImages ); pThrobber->setImageList( aImages );
......
...@@ -69,13 +69,9 @@ VCLXGraphics::~VCLXGraphics() ...@@ -69,13 +69,9 @@ VCLXGraphics::~VCLXGraphics()
std::vector< VCLXGraphics* > *pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : nullptr; std::vector< VCLXGraphics* > *pLst = mpOutputDevice ? mpOutputDevice->GetUnoGraphicsList() : nullptr;
if ( pLst ) if ( pLst )
{ {
for( std::vector< VCLXGraphics* >::iterator it = pLst->begin(); it != pLst->end(); ++it ) auto it = std::find(pLst->begin(), pLst->end(), this);
{ if (it != pLst->end())
if( *it == this ) { pLst->erase( it );
pLst->erase( it );
break;
}
}
} }
mpClipRegion.reset(); mpClipRegion.reset();
......
...@@ -148,9 +148,9 @@ css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles() ...@@ -148,9 +148,9 @@ css::uno::Sequence< css::awt::Rectangle > VCLXRegion::getRectangles()
css::uno::Sequence< css::awt::Rectangle > aRects(aRectangles.size()); css::uno::Sequence< css::awt::Rectangle > aRects(aRectangles.size());
sal_uInt32 a(0); 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; //Rectangle aRect;
......
...@@ -125,15 +125,13 @@ Reference< css::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageBy ...@@ -125,15 +125,13 @@ Reference< css::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageBy
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
Reference< css::awt::tab::XTabPage > xTabPage; Reference< css::awt::tab::XTabPage > xTabPage;
::std::vector< Reference< css::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin(); for(const auto& rTabPage : m_aTabPages)
::std::vector< Reference< css::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end();
for(;aIter != aEnd;++aIter)
{ {
Reference< awt::XControl > xControl(*aIter,UNO_QUERY ); Reference< awt::XControl > xControl(rTabPage,UNO_QUERY );
Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
if ( tabPageID == xP->getTabPageID() ) if ( tabPageID == xP->getTabPageID() )
{ {
xTabPage = *aIter; xTabPage = rTabPage;
break; break;
} }
} }
......
...@@ -291,12 +291,9 @@ IMPL_LINK_NOARG(VCLXWindowImpl, OnProcessCallbacks, void*, void) ...@@ -291,12 +291,9 @@ IMPL_LINK_NOARG(VCLXWindowImpl, OnProcessCallbacks, void*, void)
{ {
SAL_INFO("toolkit.controls", "OnProcessCallbacks relinquished solarmutex"); SAL_INFO("toolkit.controls", "OnProcessCallbacks relinquished solarmutex");
SolarMutexReleaser aReleaseSolar; SolarMutexReleaser aReleaseSolar;
for ( CallbackArray::const_iterator loop = aCallbacksCopy.begin(); for (const auto& rCallback : aCallbacksCopy)
loop != aCallbacksCopy.end();
++loop
)
{ {
(*loop)(); rCallback();
} }
} }
} }
...@@ -1330,20 +1327,16 @@ void VCLXWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds, bool bWith ...@@ -1330,20 +1327,16 @@ void VCLXWindow::ImplGetPropertyIds( std::vector< sal_uInt16 > &rIds, bool bWith
// lovely hack from: // lovely hack from:
// void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId ) // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
std::vector< sal_uInt16 >::const_iterator iter; if( std::find(rIds.begin(), rIds.end(), BASEPROPERTY_FONTDESCRIPTOR) != rIds.end() )
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.
// some properties are not included in the FontDescriptor, but every time // => Easier to register the here, instead everywhere where I register the FontDescriptor...
// 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_TEXTCOLOR ); rIds.push_back( BASEPROPERTY_FONTRELIEF );
rIds.push_back( BASEPROPERTY_TEXTLINECOLOR ); rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
rIds.push_back( BASEPROPERTY_FONTRELIEF );
rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
break;
}
} }
} }
......
...@@ -707,10 +707,9 @@ Sequence< Reference< XControlModel > > SAL_CALL ControlModelContainerBase::getCo ...@@ -707,10 +707,9 @@ Sequence< Reference< XControlModel > > SAL_CALL ControlModelContainerBase::getCo
::std::vector< Reference< XControlModel > > aUnindexedModels; ::std::vector< Reference< XControlModel > > aUnindexedModels;
// will be the container of all models which do not have a tab index property // will be the container of all models which do not have a tab index property
UnoControlModelHolderVector::const_iterator aLoop = maModels.begin(); for ( const auto& rModel : maModels )
for ( ; aLoop != maModels.end(); ++aLoop )
{ {
Reference< XControlModel > xModel( aLoop->first ); Reference< XControlModel > xModel( rModel.first );
// see if the model has a TabIndex property // see if the model has a TabIndex property
Reference< XPropertySet > xControlProps( xModel, UNO_QUERY ); Reference< XPropertySet > xControlProps( xModel, UNO_QUERY );
......
...@@ -287,32 +287,23 @@ private: ...@@ -287,32 +287,23 @@ private:
} }
// fire removal notifications // fire removal notifications
for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); for (const auto& rEvent : aRemovedColumns)
event != aRemovedColumns.end();
++event
)
{ {
m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event ); m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, rEvent );
} }
// fire insertion notifications // fire insertion notifications
for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin(); for (const auto& rEvent : aInsertedColumns)
event != aInsertedColumns.end();
++event
)
{ {
m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event ); m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, rEvent );
} }
// dispose removed columns // dispose removed columns
for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); for (const auto& rEvent : aRemovedColumns)
event != aRemovedColumns.end();
++event
)
{ {
try try
{ {
const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW ); const Reference< XComponent > xColComp( rEvent.Element, UNO_QUERY_THROW );
xColComp->dispose(); xColComp->dispose();
} }
catch( const Exception& ) catch( const Exception& )
......
...@@ -444,8 +444,8 @@ private: ...@@ -444,8 +444,8 @@ private:
::comphelper::ComponentGuard aGuard( *this, rBHelper ); ::comphelper::ComponentGuard aGuard( *this, rBHelper );
RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount ); RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
for ( RowData::iterator cell = rRowData.begin(); cell != rRowData.end(); ++cell ) for ( auto& rCell : rRowData )
cell->second = i_value; rCell.second = i_value;
} }
......
...@@ -375,13 +375,10 @@ void lcl_clear( STLCONTAINER& i_container ) ...@@ -375,13 +375,10 @@ void lcl_clear( STLCONTAINER& i_container )
void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold )
{ {
for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); for ( auto& rIndex : io_indexMap )
loop != io_indexMap.end();
++loop
)
{ {
if ( *loop >= i_threshold ) if ( rIndex >= i_threshold )
--*loop; --rIndex;
} }
} }
......
...@@ -232,9 +232,9 @@ static void lcl_throwIndexOutOfBoundsException( ) ...@@ -232,9 +232,9 @@ static void lcl_throwIndexOutOfBoundsException( )
while ( bIncrement ) while ( bIncrement )
{ {
bIncrement = false; 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 ); Reference< XPropertySet > xPropertySet( CurRoadmapItem, UNO_QUERY );
aAny = xPropertySet->getPropertyValue("ID"); aAny = xPropertySet->getPropertyValue("ID");
aAny >>= n_CurItemID; aAny >>= n_CurItemID;
......
...@@ -264,9 +264,8 @@ MutableTreeNode::MutableTreeNode( const MutableTreeDataModelRef& xModel, const A ...@@ -264,9 +264,8 @@ MutableTreeNode::MutableTreeNode( const MutableTreeDataModelRef& xModel, const A
MutableTreeNode::~MutableTreeNode() MutableTreeNode::~MutableTreeNode()
{ {
TreeNodeVector::iterator aIter( maChildren.begin() ); for( auto& rChild : maChildren )
while( aIter != maChildren.end() ) rChild->setParent(nullptr);
(*aIter++)->setParent(nullptr);
} }
void MutableTreeNode::setParent( MutableTreeNode* pParent ) void MutableTreeNode::setParent( MutableTreeNode* pParent )
...@@ -336,8 +335,7 @@ void SAL_CALL MutableTreeNode::insertChildByIndex( sal_Int32 nChildIndex, const ...@@ -336,8 +335,7 @@ void SAL_CALL MutableTreeNode::insertChildByIndex( sal_Int32 nChildIndex, const
xImpl->mbIsInserted = true; xImpl->mbIsInserted = true;
TreeNodeVector::iterator aIter( maChildren.begin() ); TreeNodeVector::iterator aIter( maChildren.begin() );
while( (nChildIndex-- > 0) && (aIter != maChildren.end()) ) std::advance(aIter, nChildIndex);
++aIter;
maChildren.insert( aIter, xImpl ); maChildren.insert( aIter, xImpl );
xImpl->setParent( this ); xImpl->setParent( this );
......
...@@ -644,13 +644,9 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent ...@@ -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 // 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. // 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 // To prevent deadlocks resulting from this, we do this without our own mutex locked
std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end(); for (const auto& rProp : aPeerPropertiesToSet)
for ( std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin();
aLoop != aEnd;
++aLoop
)
{ {
ImplSetPeerProperty( aLoop->Name, aLoop->Value ); ImplSetPeerProperty( rProp.Name, rProp.Value );
} }
} }
......
...@@ -175,11 +175,11 @@ void UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XCon ...@@ -175,11 +175,11 @@ void UnoControlHolderList::getControls( uno::Sequence< uno::Reference< awt::XCon
{ {
_out_rControls.realloc( maControls.size() ); _out_rControls.realloc( maControls.size() );
uno::Reference< awt::XControl >* pControls = _out_rControls.getArray(); uno::Reference< awt::XControl >* pControls = _out_rControls.getArray();
for ( ControlMap::const_iterator loop = maControls.begin(); for (const auto& rEntry : maControls)
loop != maControls.end(); {
++loop, ++pControls *pControls = rEntry.second->getControl();
) ++pControls;
*pControls = loop->second->getControl(); }
} }
...@@ -187,36 +187,30 @@ void UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIde ...@@ -187,36 +187,30 @@ void UnoControlHolderList::getIdentifiers( uno::Sequence< sal_Int32 >& _out_rIde
{ {
_out_rIdentifiers.realloc( maControls.size() ); _out_rIdentifiers.realloc( maControls.size() );
sal_Int32* pIndentifiers = _out_rIdentifiers.getArray(); sal_Int32* pIndentifiers = _out_rIdentifiers.getArray();
for ( ControlMap::const_iterator loop = maControls.begin(); for (const auto& rEntry : maControls)
loop != maControls.end(); {
++loop, ++pIndentifiers *pIndentifiers = rEntry.first;
) ++pIndentifiers;
*pIndentifiers = loop->first; }
} }
uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const OUString& _rName ) const uno::Reference< awt::XControl > UnoControlHolderList::getControlForName( const OUString& _rName ) const
{ {
for ( ControlMap::const_iterator loop = maControls.begin(); auto loop = std::find_if(maControls.begin(), maControls.end(),
loop != maControls.end(); [&_rName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == _rName; });
++loop if (loop != maControls.end())
) return loop->second->getControl();
if ( loop->second->getName() == _rName )
return loop->second->getControl();
return uno::Reference< awt::XControl >(); return uno::Reference< awt::XControl >();
} }
UnoControlHolderList::ControlIdentifier UnoControlHolderList::getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl ) UnoControlHolderList::ControlIdentifier UnoControlHolderList::getControlIdentifier( const uno::Reference< awt::XControl >& _rxControl )
{ {
for ( ControlMap::iterator loop = maControls.begin(); auto loop = std::find_if(maControls.begin(), maControls.end(),
loop != maControls.end(); [&_rxControl](const ControlMap::value_type& rEntry) { return rEntry.second->getControl().get() == _rxControl.get(); });
++loop if (loop != maControls.end())
) return loop->first;
{
if ( loop->second->getControl().get() == _rxControl.get() )
return loop->first;
}
return -1; return -1;
} }
...@@ -284,13 +278,8 @@ OUString UnoControlHolderList::impl_getFreeName_throw() ...@@ -284,13 +278,8 @@ OUString UnoControlHolderList::impl_getFreeName_throw()
for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId ) for ( ControlIdentifier candidateId = 0; candidateId < ::std::numeric_limits< ControlIdentifier >::max(); ++candidateId )
{ {
OUString candidateName( "control_" + OUString::number( candidateId ) ); OUString candidateName( "control_" + OUString::number( candidateId ) );
ControlMap::const_iterator loop = maControls.begin(); if ( std::none_of(maControls.begin(), maControls.end(),
for ( ; loop != maControls.end(); ++loop ) [&candidateName](const ControlMap::value_type& rEntry) { return rEntry.second->getName() == candidateName; }) )
{
if ( loop->second->getName() == candidateName )
break;
}
if ( loop == maControls.end() )
return candidateName; return candidateName;
} }
throw uno::RuntimeException("out of identifiers" ); throw uno::RuntimeException("out of identifiers" );
......
...@@ -140,8 +140,8 @@ css::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const ...@@ -140,8 +140,8 @@ css::uno::Sequence<sal_Int32> UnoControlModel::ImplGetPropertyIds() const
css::uno::Sequence<sal_Int32> aIDs( nIDs ); css::uno::Sequence<sal_Int32> aIDs( nIDs );
sal_Int32* pIDs = aIDs.getArray(); sal_Int32* pIDs = aIDs.getArray();
sal_uInt32 n = 0; sal_uInt32 n = 0;
for ( ImplPropertyTable::const_iterator it = maData.begin(); it != maData.end(); ++it ) for ( const auto& rData : maData )
pIDs[n++] = it->first; pIDs[n++] = rData.first;
return aIDs; return aIDs;
} }
...@@ -408,11 +408,10 @@ void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId ) ...@@ -408,11 +408,10 @@ void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
void UnoControlModel::ImplRegisterProperties( const std::vector< sal_uInt16 > &rIds ) void UnoControlModel::ImplRegisterProperties( const std::vector< sal_uInt16 > &rIds )
{ {
std::vector< sal_uInt16 >::const_iterator iter; for (const auto& rId : rIds)
for( iter = rIds.begin(); iter != rIds.end(); ++iter)
{ {
if( !ImplHasProperty( *iter ) ) if( !ImplHasProperty( rId ) )
ImplRegisterProperty( *iter, ImplGetDefaultValue( *iter ) ); ImplRegisterProperty( rId, ImplGetDefaultValue( rId ) );
} }
} }
...@@ -538,12 +537,12 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt ...@@ -538,12 +537,12 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
std::set<sal_uInt16> aProps; 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 ) if ( ( ( GetPropertyAttribs( rData.first ) & css::beans::PropertyAttribute::TRANSIENT ) == 0 )
&& ( getPropertyState( GetPropertyName( it->first ) ) != css::beans::PropertyState_DEFAULT_VALUE ) ) && ( 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 ...@@ -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 // Save FontProperty always in the old format (due to missing distinction
// between 5.0 and 5.1) // between 5.0 and 5.1)
OutStream->writeLong( ( aProps.find( BASEPROPERTY_FONTDESCRIPTOR ) != aProps.end() ) ? ( nProps + 3 ) : nProps ); 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(); sal_Int32 nPropDataBeginMark = xMark->createMark();
OutStream->writeLong( 0 ); // DataLen OutStream->writeLong( 0 ); // DataLen
const css::uno::Any* pProp = &(maData[*it]); const css::uno::Any* pProp = &(maData[rProp]);
OutStream->writeShort( *it ); OutStream->writeShort( rProp );
bool bVoid = pProp->getValueType().getTypeClass() == css::uno::TypeClass_VOID; bool bVoid = pProp->getValueType().getTypeClass() == css::uno::TypeClass_VOID;
...@@ -687,7 +686,7 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt ...@@ -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 '" SAL_WARN( "toolkit", "UnoControlModel::write: don't know how to handle a property of type '"
<< rType.getTypeName() << rType.getTypeName()
<< "'.\n(Currently handling property '" << "'.\n(Currently handling property '"
<< GetPropertyName( *it ) << GetPropertyName( rProp )
<< "'.)"); << "'.)");
} }
#endif #endif
......
...@@ -292,19 +292,17 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId, ...@@ -292,19 +292,17 @@ void ButtonDialog::AddButton( StandardButtonType eType, sal_uInt16 nId,
void ButtonDialog::RemoveButton( sal_uInt16 nId ) void ButtonDialog::RemoveButton( sal_uInt16 nId )
{ {
for (std::vector<std::unique_ptr<ImplBtnDlgItem>>::iterator it auto it = std::find_if(m_ItemList.begin(), m_ItemList.end(),
= m_ItemList.begin(); it != m_ItemList.end(); ++it) [&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->Hide(); (*it)->mpPushButton.disposeAndClear();
if ((*it)->mbOwnButton) else
(*it)->mpPushButton.disposeAndClear(); (*it)->mpPushButton.clear();
else m_ItemList.erase(it);
(*it)->mpPushButton.clear(); return;
m_ItemList.erase(it);
return;
}
} }
SAL_WARN( "vcl.window", "ButtonDialog::RemoveButton(): ButtonId invalid" ); SAL_WARN( "vcl.window", "ButtonDialog::RemoveButton(): ButtonId invalid" );
......
...@@ -36,9 +36,8 @@ UnoPropertyArrayHelper::UnoPropertyArrayHelper( const css::uno::Sequence<sal_Int ...@@ -36,9 +36,8 @@ UnoPropertyArrayHelper::UnoPropertyArrayHelper( const css::uno::Sequence<sal_Int
UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::vector< sal_uInt16 > &rIDs ) UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::vector< sal_uInt16 > &rIDs )
{ {
std::vector< sal_uInt16 >::const_iterator iter; for (const auto& rId : rIDs)
for( iter = rIDs.begin(); iter != rIDs.end(); ++iter) maIDs.insert( rId );
maIDs.insert( *iter );
} }
bool UnoPropertyArrayHelper::ImplHasProperty( sal_uInt16 nPropId ) const bool UnoPropertyArrayHelper::ImplHasProperty( sal_uInt16 nPropId ) const
...@@ -69,9 +68,9 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties ...@@ -69,9 +68,9 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties
// Sort by names ... // Sort by names ...
std::map<sal_Int32, sal_uInt16> aSortedPropsIds; 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; aSortedPropsIds[ 1+GetPropertyOrderNr( nId ) ] = nId;
if ( nId == BASEPROPERTY_FONTDESCRIPTOR ) if ( nId == BASEPROPERTY_FONTDESCRIPTOR )
...@@ -86,14 +85,15 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties ...@@ -86,14 +85,15 @@ css::uno::Sequence< css::beans::Property > UnoPropertyArrayHelper::getProperties
css::uno::Sequence< css::beans::Property> aProps( nProps ); css::uno::Sequence< css::beans::Property> aProps( nProps );
css::beans::Property* pProps = aProps.getArray(); css::beans::Property* pProps = aProps.getArray();
std::map<sal_Int32, sal_uInt16>::const_iterator it = aSortedPropsIds.begin(); sal_uInt32 n = 0;
for ( sal_uInt32 n = 0; n < nProps; n++, ++it ) for ( const auto& rPropIds : aSortedPropsIds )
{ {
sal_uInt16 nId = it->second; sal_uInt16 nId = rPropIds.second;
pProps[n].Name = GetPropertyName( nId ); pProps[n].Name = GetPropertyName( nId );
pProps[n].Handle = nId; pProps[n].Handle = nId;
pProps[n].Type = *GetPropertyType( nId ); pProps[n].Type = *GetPropertyType( nId );
pProps[n].Attributes = GetPropertyAttribs( nId ); pProps[n].Attributes = GetPropertyAttribs( nId );
++n;
} }
return aProps; return aProps;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <algorithm>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -110,33 +111,25 @@ bool lockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream* pSt ...@@ -110,33 +111,25 @@ bool lockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream* pSt
osl::MutexGuard aGuard( LockMutex::get() ); osl::MutexGuard aGuard( LockMutex::get() );
std::vector<InternalStreamLock> &rLockList = LockList::get(); std::vector<InternalStreamLock> &rLockList = LockList::get();
for( std::vector<InternalStreamLock>::const_iterator i = rLockList.begin(); for( const auto& rLock : rLockList )
i != rLockList.end(); )
{ {
if( aItem.isIdenticalTo( i->m_aItem ) ) if( aItem.isIdenticalTo( rLock.m_aItem ) )
{ {
bool bDenyByOptions = false; StreamMode nLockMode = rLock.m_pStream->GetStreamMode();
StreamMode nLockMode = i->m_pStream->GetStreamMode();
StreamMode nNewMode = pStream->GetStreamMode(); StreamMode nNewMode = pStream->GetStreamMode();
bool bDenyByOptions = (nLockMode & StreamMode::SHARE_DENYALL) ||
if( nLockMode & StreamMode::SHARE_DENYALL ) ( (nLockMode & StreamMode::SHARE_DENYWRITE) && (nNewMode & StreamMode::WRITE) ) ||
bDenyByOptions = true; ( (nLockMode & StreamMode::SHARE_DENYREAD) && (nNewMode & StreamMode::READ) );
else if( ( nLockMode & StreamMode::SHARE_DENYWRITE ) &&
( nNewMode & StreamMode::WRITE ) )
bDenyByOptions = true;
else if( ( nLockMode &StreamMode::SHARE_DENYREAD ) &&
( nNewMode & StreamMode::READ ) )
bDenyByOptions = true;
if( bDenyByOptions ) 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; return false;
if( nStart == 0 && nEnd == 0) // cannot lock whole file if( nStart == 0 && nEnd == 0) // cannot lock whole file
return false; return false;
if( ( nStart < i->m_nStartPos && nEnd > i->m_nStartPos ) || if( ( nStart < rLock.m_nStartPos && nEnd > rLock.m_nStartPos ) ||
( nStart < i->m_nEndPos && nEnd > i->m_nEndPos ) ) ( nStart < rLock.m_nEndPos && nEnd > rLock.m_nEndPos ) )
return false; return false;
} }
} }
...@@ -149,20 +142,12 @@ void unlockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream co ...@@ -149,20 +142,12 @@ void unlockFile( sal_uInt64 const nStart, sal_uInt64 const nEnd, SvFileStream co
{ {
osl::MutexGuard aGuard( LockMutex::get() ); osl::MutexGuard aGuard( LockMutex::get() );
std::vector<InternalStreamLock> &rLockList = LockList::get(); std::vector<InternalStreamLock> &rLockList = LockList::get();
for( std::vector<InternalStreamLock>::iterator i = rLockList.begin(); rLockList.erase(std::remove_if(rLockList.begin(), rLockList.end(),
i != rLockList.end(); ) [&pStream, &nStart, &nEnd](const InternalStreamLock& rLock) {
{ return rLock.m_pStream == pStream
if ( i->m_pStream == pStream && ((nStart == 0 && nEnd == 0)
&& ( ( nStart == 0 && nEnd == 0 ) || (rLock.m_nStartPos == nStart && rLock.m_nEndPos == nEnd));
|| ( i->m_nStartPos == nStart && i->m_nEndPos == nEnd ) ) ) }), rLockList.end());
{
i = rLockList.erase(i);
}
else
{
++i;
}
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment