summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-01-27 21:47:04 +0100
committerJulien Nabet <serval2412@yahoo.fr>2018-01-27 23:51:14 +0100
commitea89dabf8b6363972190a6b50c527c418d51c2c7 (patch)
treef0ddc43ee7126ea1e6e3ba08945b2242659cca51 /forms
parent1841fcf896f50b7df1375d431857ecddd5f5b392 (diff)
Modernize a bit forms
by using for-range loops + use returned iterator by erase call Change-Id: Ia41c9fae190dbad6a25b62a9b15ad51e89dd2906 Reviewed-on: https://gerrit.libreoffice.org/48759 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/imgprod.cxx28
-rw-r--r--forms/source/helper/formnavigation.cxx90
-rw-r--r--forms/source/solar/control/navtoolbar.cxx20
-rw-r--r--forms/source/xforms/binding.cxx39
-rw-r--r--forms/source/xforms/collection.hxx18
-rw-r--r--forms/source/xforms/model.cxx4
-rw-r--r--forms/source/xforms/model_ui.cxx6
7 files changed, 80 insertions, 125 deletions
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx
index cd5bcb602fb9..44cb05d36715 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -277,10 +277,10 @@ void ImageProducer::startProduction()
ConsumerList_t aTmp = maConsList;
// iterate through interfaces
- for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
+ for (auto const& elem : aTmp)
{
- (*iter)->init( 0, 0 );
- (*iter)->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
+ elem->init( 0, 0 );
+ elem->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
}
maDoneHdl.Call( nullptr );
@@ -321,8 +321,8 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic )
mbConsInit = false;
// iterate through interfaces
- for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
- (*iter)->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
+ for (auto const& elem : aTmp)
+ elem->complete( css::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
}
}
@@ -385,10 +385,10 @@ void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
ConsumerList_t aTmp = maConsList;
// iterate through interfaces
- for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
+ for (auto const& elem : aTmp)
{
- (*iter)->init( pBmpAcc->Width(), pBmpAcc->Height() );
- (*iter)->setColorModel( pBmpAcc->GetBitCount(),aRGBPal, nRMask, nGMask, nBMask, nAMask );
+ elem->init( pBmpAcc->Width(), pBmpAcc->Height() );
+ elem->setColorModel( pBmpAcc->GetBitCount(),aRGBPal, nRMask, nGMask, nBMask, nAMask );
}
Bitmap::ReleaseAccess( pBmpAcc );
@@ -448,8 +448,8 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
}
// iterate through interfaces
- for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
- (*iter)->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
+ for (auto const& elem : aTmp)
+ elem->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
}
else
{
@@ -468,8 +468,8 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
}
// iterate through interfaces
- for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
- (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
+ for (auto const& elem : aTmp)
+ elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
}
}
else
@@ -494,8 +494,8 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
}
// iterate through interfaces
- for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
- (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
+ for (auto const& elem : aTmp)
+ elem->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
}
Bitmap::ReleaseAccess( pBmpAcc );
diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx
index 89f2e7a6ad66..7c7186e11905 100644
--- a/forms/source/helper/formnavigation.cxx
+++ b/forms/source/helper/formnavigation.cxx
@@ -93,22 +93,19 @@ namespace frm
void SAL_CALL OFormNavigationHelper::statusChanged( const FeatureStateEvent& _rState )
{
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
+ for (auto & feature : m_aSupportedFeatures)
{
- if ( aFeature->second.aURL.Main == _rState.FeatureURL.Main )
+ if ( feature.second.aURL.Main == _rState.FeatureURL.Main )
{
- if ( ( aFeature->second.bCachedState != bool(_rState.IsEnabled) )
- || ( aFeature->second.aCachedAdditionalState != _rState.State )
+ if ( ( feature.second.bCachedState != bool(_rState.IsEnabled) )
+ || ( feature.second.aCachedAdditionalState != _rState.State )
)
{
// change the cached state
- aFeature->second.bCachedState = _rState.IsEnabled;
- aFeature->second.aCachedAdditionalState = _rState.State;
+ feature.second.bCachedState = _rState.IsEnabled;
+ feature.second.aCachedAdditionalState = _rState.State;
// tell derivees what happened
- featureStateChanged( aFeature->first, _rState.IsEnabled );
+ featureStateChanged( feature.first, _rState.IsEnabled );
}
return;
}
@@ -124,20 +121,17 @@ namespace frm
// was it one of our external dispatchers?
if ( m_nConnectedFeatures )
{
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
+ for (auto & feature : m_aSupportedFeatures)
{
- if ( aFeature->second.xDispatcher == _rSource.Source )
+ if ( feature.second.xDispatcher == _rSource.Source )
{
- aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
- aFeature->second.xDispatcher = nullptr;
- aFeature->second.bCachedState = false;
- aFeature->second.aCachedAdditionalState.clear();
+ feature.second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL );
+ feature.second.xDispatcher = nullptr;
+ feature.second.bCachedState = false;
+ feature.second.aCachedAdditionalState.clear();
--m_nConnectedFeatures;
- featureStateChanged( aFeature->first, false );
+ featureStateChanged( feature.first, false );
break;
}
}
@@ -160,29 +154,26 @@ namespace frm
Reference< XDispatch > xNewDispatcher;
Reference< XDispatch > xCurrentDispatcher;
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
+ for (auto & feature : m_aSupportedFeatures)
{
- xNewDispatcher = queryDispatch( aFeature->second.aURL );
- xCurrentDispatcher = aFeature->second.xDispatcher;
+ xNewDispatcher = queryDispatch( feature.second.aURL );
+ xCurrentDispatcher = feature.second.xDispatcher;
if ( xNewDispatcher != xCurrentDispatcher )
{
// the dispatcher for this particular URL changed
if ( xCurrentDispatcher.is() )
- xCurrentDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
+ xCurrentDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL );
- xCurrentDispatcher = aFeature->second.xDispatcher = xNewDispatcher;
+ xCurrentDispatcher = feature.second.xDispatcher = xNewDispatcher;
if ( xCurrentDispatcher.is() )
- xCurrentDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
+ xCurrentDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL );
}
if ( xCurrentDispatcher.is() )
++m_nConnectedFeatures;
else
- aFeature->second.bCachedState = false;
+ feature.second.bCachedState = false;
}
// notify derivee that (potentially) all features changed their state
@@ -202,18 +193,15 @@ namespace frm
m_nConnectedFeatures = 0;
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
+ for (auto & feature : m_aSupportedFeatures)
{
- aFeature->second.bCachedState = false;
- aFeature->second.aCachedAdditionalState.clear();
- aFeature->second.xDispatcher = queryDispatch( aFeature->second.aURL );
- if ( aFeature->second.xDispatcher.is() )
+ feature.second.bCachedState = false;
+ feature.second.aCachedAdditionalState.clear();
+ feature.second.xDispatcher = queryDispatch( feature.second.aURL );
+ if ( feature.second.xDispatcher.is() )
{
++m_nConnectedFeatures;
- aFeature->second.xDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
+ feature.second.xDispatcher->addStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL );
}
}
@@ -226,17 +214,14 @@ namespace frm
{
if ( m_nConnectedFeatures )
{
- for ( FeatureMap::iterator aFeature = m_aSupportedFeatures.begin();
- aFeature != m_aSupportedFeatures.end();
- ++aFeature
- )
+ for (auto & feature : m_aSupportedFeatures)
{
- if ( aFeature->second.xDispatcher.is() )
- aFeature->second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), aFeature->second.aURL );
+ if ( feature.second.xDispatcher.is() )
+ feature.second.xDispatcher->removeStatusListener( static_cast< XStatusListener* >( this ), feature.second.aURL );
- aFeature->second.xDispatcher = nullptr;
- aFeature->second.bCachedState = false;
- aFeature->second.aCachedAdditionalState.clear();
+ feature.second.xDispatcher = nullptr;
+ feature.second.bCachedState = false;
+ feature.second.aCachedAdditionalState.clear();
}
m_nConnectedFeatures = 0;
@@ -257,20 +242,17 @@ namespace frm
OFormNavigationMapper aUrlMapper( m_xORB );
- for ( ::std::vector< sal_Int16 >::const_iterator aLoop = aFeatureIds.begin();
- aLoop != aFeatureIds.end();
- ++aLoop
- )
+ for (auto const& feature : aFeatureIds)
{
FeatureInfo aFeatureInfo;
bool bKnownId =
- aUrlMapper.getFeatureURL( *aLoop, aFeatureInfo.aURL );
+ aUrlMapper.getFeatureURL( feature, aFeatureInfo.aURL );
DBG_ASSERT( bKnownId, "OFormNavigationHelper::initializeSupportedFeatures: unknown feature id!" );
if ( bKnownId )
// add to our map
- m_aSupportedFeatures.emplace( *aLoop, aFeatureInfo );
+ m_aSupportedFeatures.emplace( feature, aFeatureInfo );
}
}
}
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index 7cf16894b710..1cc3c42f8690 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -151,8 +151,8 @@ namespace frm
void NavigationToolBar::dispose()
{
- for (auto i = m_aChildWins.begin(); i != m_aChildWins.end(); ++i)
- i->disposeAndClear();
+ for (auto & childWin : m_aChildWins)
+ childWin.disposeAndClear();
m_aChildWins.clear();
m_pToolbar.disposeAndClear();
vcl::Window::dispose();
@@ -358,12 +358,10 @@ namespace frm
// translate them into command URLs
css::uno::Sequence< OUString > aCommandURLs( aFormFeatures.size() );
- for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin();
- formFeature != aFormFeatures.end();
- ++formFeature
- )
+ size_t i = 0;
+ for (auto const& formFeature : aFormFeatures)
{
- aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature );
+ aCommandURLs[i++] = lcl_getCommandURL(formFeature);
}
// retrieve the images for the command URLs
@@ -371,12 +369,10 @@ namespace frm
// and set them at the toolbar
CommandImages::const_iterator commandImage = aCommandImages.begin();
- for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin();
- formFeature != aFormFeatures.end();
- ++formFeature, ++commandImage
- )
+ for (auto const& formFeature : aFormFeatures)
{
- m_pToolbar->SetItemImage( *formFeature, *commandImage );
+ m_pToolbar->SetItemImage( formFeature, *commandImage );
+ ++commandImage;
}
// parts of our layout is dependent on the size of our icons
diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx
index 16276212a27e..05d40430d28e 100644
--- a/forms/source/xforms/binding.cxx
+++ b/forms/source/xforms/binding.cxx
@@ -524,15 +524,12 @@ static void lcl_removeListenerFromNode( const Reference<XNode>& xNode,
// EvaluationContext for each
PathExpression::NodeVector_t aNodes = maBindingExpression.getNodeList();
::std::vector<EvaluationContext> aVector;
- sal_Int32 nCount = 0; // count nodes for context position
- for( PathExpression::NodeVector_t::iterator aIter = aNodes.begin();
- aIter != aNodes.end();
- ++aIter, ++nCount )
+ for (auto const& node : aNodes)
{
- OSL_ENSURE( aIter->is(), "no node?" );
+ OSL_ENSURE( node.is(), "no node?" );
// create proper evaluation context for this MIP
- aVector.emplace_back( *aIter, getModel(), getBindingNamespaces() );
+ aVector.emplace_back( node, getModel(), getBindingNamespaces() );
}
return aVector;
}
@@ -578,23 +575,17 @@ void Binding::bind( bool bForceRebind )
// 2) register suitable listeners on the instance (and remove old ones)
if( maEventNodes.empty() || bForceRebind )
{
- for( auto aIter = maEventNodes.begin();
- aIter != maEventNodes.end();
- ++aIter )
- lcl_removeListenerFromNode( *aIter, this );
+ for (auto const& eventNode : maEventNodes)
+ lcl_removeListenerFromNode( eventNode, this );
maEventNodes.clear();
if( isSimpleBinding() )
- for( PathExpression::NodeVector_t::iterator aIter = aNodes.begin();
- aIter != aNodes.end();
- ++aIter )
- maEventNodes.push_back( *aIter );
+ for (auto const& node : aNodes)
+ maEventNodes.push_back(node);
else
maEventNodes.emplace_back( aContext.mxContextNode->getOwnerDocument(),
UNO_QUERY_THROW );
- for( PathExpression::NodeVector_t::iterator aIter2 = maEventNodes.begin();
- aIter2 != maEventNodes.end();
- ++aIter2 )
- lcl_addListenerToNode( *aIter2, this );
+ for (auto const& eventNode : maEventNodes)
+ lcl_addListenerToNode( eventNode, this );
}
// 3) remove old MIPs defined by this binding
@@ -604,11 +595,9 @@ void Binding::bind( bool bForceRebind )
// 4) calculate all MIPs
::std::vector<EvaluationContext> aMIPContexts = _getMIPEvaluationContexts();
- for( ::std::vector<EvaluationContext>::iterator aIter = aMIPContexts.begin();
- aIter != aMIPContexts.end();
- ++aIter )
+ for (auto & context : aMIPContexts)
{
- EvaluationContext& rContext = *aIter;
+ EvaluationContext& rContext = context;
// evaluate calculate expression (and push value into instance)
// (prevent recursion using mbInCalculate
@@ -812,10 +801,8 @@ void Binding::clear()
pModel->removeMIPs( this );
// remove all references
- for( auto aIter = maEventNodes.begin();
- aIter != maEventNodes.end();
- ++aIter )
- lcl_removeListenerFromNode( *aIter, this );
+ for (auto const& eventNode : maEventNodes)
+ lcl_removeListenerFromNode( eventNode, this );
maEventNodes.clear();
// clear expressions
diff --git a/forms/source/xforms/collection.hxx b/forms/source/xforms/collection.hxx
index f38d75ce458c..3ffc1f7e3e2e 100644
--- a/forms/source/xforms/collection.hxx
+++ b/forms/source/xforms/collection.hxx
@@ -245,11 +245,9 @@ protected:
css::uno::makeAny( nPos ),
css::uno::makeAny( getItem( nPos ) ),
css::uno::Any() );
- for( Listeners_t::iterator aIter = maListeners.begin();
- aIter != maListeners.end();
- ++aIter )
+ for (auto const& listener : maListeners)
{
- (*aIter)->elementInserted( aEvent );
+ listener->elementInserted( aEvent );
}
}
@@ -260,11 +258,9 @@ protected:
css::uno::Any(),
css::uno::makeAny( aOld ),
css::uno::Any() );
- for( Listeners_t::iterator aIter = maListeners.begin();
- aIter != maListeners.end();
- ++aIter )
+ for (auto const& listener : maListeners)
{
- (*aIter)->elementRemoved( aEvent );
+ listener->elementRemoved( aEvent );
}
}
@@ -276,11 +272,9 @@ protected:
css::uno::makeAny( nPos ),
css::uno::makeAny( getItem( nPos ) ),
css::uno::makeAny( aNew ) );
- for( Listeners_t::iterator aIter = maListeners.begin();
- aIter != maListeners.end();
- ++aIter )
+ for (auto const& listener : maListeners)
{
- (*aIter)->elementReplaced( aEvent );
+ listener->elementReplaced( aEvent );
}
}
diff --git a/forms/source/xforms/model.cxx b/forms/source/xforms/model.cxx
index c714d5b053dc..ad6ccbcece3d 100644
--- a/forms/source/xforms/model.cxx
+++ b/forms/source/xforms/model.cxx
@@ -207,9 +207,7 @@ void Model::removeMIPs( void const * pTag )
{
if( aIter->second.first == pTag )
{
- MIPs_t::iterator next( aIter ); ++next;
- maMIPs.erase( aIter );
- aIter = next;
+ aIter = maMIPs.erase( aIter );
}
else
++aIter;
diff --git a/forms/source/xforms/model_ui.cxx b/forms/source/xforms/model_ui.cxx
index c66bdfe99d3d..f6da0ce70803 100644
--- a/forms/source/xforms/model_ui.cxx
+++ b/forms/source/xforms/model_ui.cxx
@@ -881,11 +881,9 @@ OUString Model::getResultForExpression(
// MIP (not binding): iterate over bindings contexts
std::vector<EvaluationContext> aContext =
pBinding->getMIPEvaluationContexts();
- for( std::vector<EvaluationContext>::iterator aIter = aContext.begin();
- aIter != aContext.end();
- ++aIter )
+ for (auto const& elem : aContext)
{
- aExpression.evaluate( *aIter );
+ aExpression.evaluate(elem);
aBuffer.append( lcl_serializeForDisplay(aExpression.getXPath()) );
aBuffer.append( '\n' );
}