summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-30 13:39:03 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-06-30 17:17:49 +0200
commit172a5e3306edbef3d40d9850c446dba00b7ada06 (patch)
treec0a18bb6138c1f0909386801abc4e5a2ba08b7d9 /toolkit
parentb2fe75d13e8cf7bf1deabfb232fd907f0894996e (diff)
Simplify Sequence iterations in toolkit
Use range-based loops or replace with STL functions Change-Id: I8129ca201dd7017fc4064b04834f41d69cc01274 Reviewed-on: https://gerrit.libreoffice.org/74926 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/awt/animatedimagespeer.cxx4
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx24
-rw-r--r--toolkit/source/awt/vclxwindow1.cxx12
-rw-r--r--toolkit/source/awt/vclxwindows.cxx22
-rw-r--r--toolkit/source/controls/controlmodelcontainerbase.cxx91
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx11
-rw-r--r--toolkit/source/controls/geometrycontrolmodel.cxx24
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx18
-rw-r--r--toolkit/source/controls/stdtabcontroller.cxx108
-rw-r--r--toolkit/source/controls/stdtabcontrollermodel.cxx10
-rw-r--r--toolkit/source/controls/tabpagecontainer.cxx6
-rw-r--r--toolkit/source/controls/tabpagemodel.cxx10
-rw-r--r--toolkit/source/controls/unocontrol.cxx32
-rw-r--r--toolkit/source/controls/unocontrolcontainer.cxx32
-rw-r--r--toolkit/source/controls/unocontrolmodel.cxx44
-rw-r--r--toolkit/source/controls/unocontrols.cxx53
-rw-r--r--toolkit/source/helper/formpdfexport.cxx9
-rw-r--r--toolkit/source/helper/unopropertyarrayhelper.cxx6
-rw-r--r--toolkit/source/helper/vclunohelper.cxx5
19 files changed, 214 insertions, 307 deletions
diff --git a/toolkit/source/awt/animatedimagespeer.cxx b/toolkit/source/awt/animatedimagespeer.cxx
index 4d1be4be96e7..5277841af3e6 100644
--- a/toolkit/source/awt/animatedimagespeer.cxx
+++ b/toolkit/source/awt/animatedimagespeer.cxx
@@ -169,9 +169,9 @@ namespace toolkit
o_images.resize(0);
size_t count = size_t( i_imageURLs.getLength() );
o_images.reserve( count );
- for ( size_t i = 0; i < count; ++i )
+ for ( const auto& rImageURL : i_imageURLs )
{
- o_images.emplace_back( i_imageURLs[i] );
+ o_images.emplace_back( rImageURL );
}
}
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 904f95fd5e38..42c135c7b889 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -1413,14 +1413,12 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
css::uno::Sequence< css::beans::NamedValue > aProps;
if( anyHandle >>= aProps )
{
- const int nProps = aProps.getLength();
- const css::beans::NamedValue* pProps = aProps.getConstArray();
- for( int i = 0; i < nProps; i++ )
+ for( const css::beans::NamedValue& rProp : aProps )
{
- if ( pProps[i].Name == "WINDOW" )
- pProps[i].Value >>= nWindowHandle;
- else if ( pProps[i].Name == "XEMBED" )
- pProps[i].Value >>= bXEmbed;
+ if ( rProp.Name == "WINDOW" )
+ rProp.Value >>= nWindowHandle;
+ else if ( rProp.Name == "XEMBED" )
+ rProp.Value >>= bXEmbed;
}
}
else
@@ -1645,14 +1643,12 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::createSystemChild( con
css::uno::Sequence< css::beans::NamedValue > aProps;
if( Parent >>= aProps )
{
- const int nProps = aProps.getLength();
- const css::beans::NamedValue* pProps = aProps.getConstArray();
- for( int i = 0; i < nProps; i++ )
+ for( const css::beans::NamedValue& rProp : aProps )
{
- if ( pProps[i].Name == "WINDOW" )
- pProps[i].Value >>= nWindowHandle;
- else if ( pProps[i].Name == "XEMBED" )
- pProps[i].Value >>= bXEmbed;
+ if ( rProp.Name == "WINDOW" )
+ rProp.Value >>= nWindowHandle;
+ else if ( rProp.Name == "XEMBED" )
+ rProp.Value >>= bXEmbed;
}
}
else
diff --git a/toolkit/source/awt/vclxwindow1.cxx b/toolkit/source/awt/vclxwindow1.cxx
index f774ab13ab51..16f696a1c138 100644
--- a/toolkit/source/awt/vclxwindow1.cxx
+++ b/toolkit/source/awt/vclxwindow1.cxx
@@ -55,14 +55,12 @@ void VCLXWindow::SetSystemParent_Impl( const css::uno::Any& rHandle )
css::uno::Sequence< css::beans::NamedValue > aProps;
if( rHandle >>= aProps )
{
- const int nProps = aProps.getLength();
- const css::beans::NamedValue* pProps = aProps.getConstArray();
- for( int i = 0; i < nProps; i++ )
+ for( const css::beans::NamedValue& rProp : aProps )
{
- if ( pProps[i].Name == "WINDOW" )
- pProps[i].Value >>= nHandle;
- else if ( pProps[i].Name == "XEMBED" )
- pProps[i].Value >>= bXEmbed;
+ if ( rProp.Name == "WINDOW" )
+ rProp.Value >>= nHandle;
+ else if ( rProp.Name == "XEMBED" )
+ rProp.Value >>= bXEmbed;
}
}
else
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index f7281ced9c1d..8d96999406a3 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -2156,14 +2156,14 @@ void SAL_CALL VCLXListBox::itemListChanged( const EventObject& i_rEvent )
Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
- for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
+ for ( const auto& rItem : aItems )
{
- OUString aLocalizationKey( aItems[i].First );
+ OUString aLocalizationKey( rItem.First );
if ( xStringResourceResolver.is() && aLocalizationKey.startsWith("&") )
{
aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
}
- pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( aItems[i].Second ) );
+ pListBox->InsertEntry( aLocalizationKey, lcl_getImageFromURL( rItem.Second ) );
}
}
@@ -2660,10 +2660,10 @@ void SAL_CALL VCLXMultiPage::setTabProps( sal_Int32 ID, const uno::Sequence< bea
if ( pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( ID ) ) == nullptr )
throw lang::IndexOutOfBoundsException();
- for (sal_Int32 i = 0; i < Properties.getLength(); ++i)
+ for (const auto& rProp : Properties)
{
- const OUString &name = Properties[i].Name;
- const uno::Any &value = Properties[i].Value;
+ const OUString &name = rProp.Name;
+ const uno::Any &value = rProp.Value;
if (name == "Title")
{
@@ -4247,9 +4247,9 @@ void VCLXComboBox::addItems( const css::uno::Sequence< OUString>& aItems, sal_In
if ( pBox )
{
sal_uInt16 nP = nPos;
- for ( sal_Int32 n = 0; n < aItems.getLength(); n++ )
+ for ( const auto& rItem : aItems )
{
- pBox->InsertEntry( aItems.getConstArray()[n], nP );
+ pBox->InsertEntry( rItem, nP );
if ( nP == 0xFFFF )
{
OSL_FAIL( "VCLXComboBox::addItems: too many entries!" );
@@ -4616,15 +4616,15 @@ void SAL_CALL VCLXComboBox::itemListChanged( const EventObject& i_rEvent )
Reference< XItemList > xItemList( i_rEvent.Source, uno::UNO_QUERY_THROW );
uno::Sequence< beans::Pair< OUString, OUString > > aItems = xItemList->getAllItems();
- for ( sal_Int32 i=0; i<aItems.getLength(); ++i )
+ for ( const auto& rItem : aItems )
{
- OUString aLocalizationKey( aItems[i].First );
+ OUString aLocalizationKey( rItem.First );
if ( xStringResourceResolver.is() && !aLocalizationKey.isEmpty() && aLocalizationKey[0] == '&' )
{
aLocalizationKey = xStringResourceResolver->resolveString(aLocalizationKey.copy( 1 ));
}
pComboBox->InsertEntryWithImage(aLocalizationKey,
- lcl_getImageFromURL(aItems[i].Second));
+ lcl_getImageFromURL(rItem.Second));
}
}
void SAL_CALL VCLXComboBox::disposing( const EventObject& i_rEvent )
diff --git a/toolkit/source/controls/controlmodelcontainerbase.cxx b/toolkit/source/controls/controlmodelcontainerbase.cxx
index 10da911540e2..64472d39ea18 100644
--- a/toolkit/source/controls/controlmodelcontainerbase.cxx
+++ b/toolkit/source/controls/controlmodelcontainerbase.cxx
@@ -915,8 +915,6 @@ void ControlModelContainerBase::implUpdateGroupStructure()
maGroups.clear();
Sequence< Reference< XControlModel > > aControlModels = getControlModels();
- const Reference< XControlModel >* pControlModels = aControlModels.getConstArray();
- const Reference< XControlModel >* pControlModelsEnd = pControlModels + aControlModels.getLength();
// in extreme we have as much groups as controls
maGroups.reserve( aControlModels.getLength() );
@@ -927,10 +925,10 @@ void ControlModelContainerBase::implUpdateGroupStructure()
sal_Int32 nCurrentGroupStep = -1; // the step which all controls of the current group belong to
- for ( ; pControlModels != pControlModelsEnd; ++pControlModels )
+ for ( const Reference< XControlModel >& rControlModel : aControlModels )
{
// we'll need this in every state
- xModelSI.set(*pControlModels, css::uno::UNO_QUERY);
+ xModelSI.set(rControlModel, css::uno::UNO_QUERY);
// is it a radio button?
bool bIsRadioButton = xModelSI.is() && xModelSI->supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" );
@@ -948,10 +946,10 @@ void ControlModelContainerBase::implUpdateGroupStructure()
maGroups.resize( nGroups + 1 );
aCurrentGroup = maGroups.begin() + nGroups;
// and add the (only, til now) member
- aCurrentGroup->push_back( *pControlModels );
+ aCurrentGroup->push_back( rControlModel );
// get the step which all controls of this group now have to belong to
- nCurrentGroupStep = lcl_getDialogStep( *pControlModels );
+ nCurrentGroupStep = lcl_getDialogStep( rControlModel );
// new state: looking for further members
eState = eExpandingGroup;
@@ -968,13 +966,13 @@ void ControlModelContainerBase::implUpdateGroupStructure()
}
// it is a radio button - is it on the proper page?
- const sal_Int32 nThisModelStep = lcl_getDialogStep( *pControlModels );
+ const sal_Int32 nThisModelStep = lcl_getDialogStep( rControlModel );
if ( ( nThisModelStep == nCurrentGroupStep ) // the current button is on the same dialog page
|| ( 0 == nThisModelStep ) // the current button appears on all pages
)
{
// -> it belongs to the same group
- aCurrentGroup->push_back( *pControlModels );
+ aCurrentGroup->push_back( rControlModel );
// state still is eExpandingGroup - we're looking for further elements
eState = eExpandingGroup;
@@ -990,7 +988,7 @@ void ControlModelContainerBase::implUpdateGroupStructure()
maGroups.resize( nGroups + 1 );
aCurrentGroup = maGroups.begin() + nGroups;
// and add the (only, til now) member
- aCurrentGroup->push_back( *pControlModels );
+ aCurrentGroup->push_back( rControlModel );
nCurrentGroupStep = nThisModelStep;
@@ -1445,11 +1443,9 @@ sal_Bool ControlContainerBase::setModel( const Reference< XControlModel >& rxMod
if ( getModel().is() )
{
Sequence< Reference< XControl > > aControls = getControls();
- const Reference< XControl >* pCtrls = aControls.getConstArray();
- const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
- for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
- removeControl( *pCtrls );
+ for ( const Reference< XControl >& rCtrl : aControls )
+ removeControl( rCtrl );
// will implicitly call removingControl, which will remove the PropertyChangeListener
// (which we formerly did herein)
// 08.01.2001 - 96008 - fs@openoffice.org
@@ -1471,14 +1467,12 @@ sal_Bool ControlContainerBase::setModel( const Reference< XControlModel >& rxMod
if ( xNA.is() )
{
Sequence< OUString > aNames = xNA->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_uInt32 nCtrls = aNames.getLength();
Reference< XControlModel > xCtrlModel;
- for( sal_uInt32 n = 0; n < nCtrls; ++n, ++pNames )
+ for( const OUString& rName : aNames )
{
- xNA->getByName( *pNames ) >>= xCtrlModel;
- ImplInsertControl( xCtrlModel, *pNames );
+ xNA->getByName( rName ) >>= xCtrlModel;
+ ImplInsertControl( xCtrlModel, rName );
}
}
@@ -1509,10 +1503,8 @@ void ControlContainerBase::setDesignMode( sal_Bool bOn )
UnoControl::setDesignMode( bOn );
Sequence< Reference< XControl > > xCtrls = getControls();
- sal_Int32 nControls = xCtrls.getLength();
- Reference< XControl >* pControls = xCtrls.getArray();
- for ( sal_Int32 n = 0; n < nControls; n++ )
- pControls[n]->setDesignMode( bOn );
+ for ( Reference< XControl >& rControl : xCtrls )
+ rControl->setDesignMode( bOn );
// #109067# in design mode the tab controller is not notified about
// tab index changes, therefore the tab order must be activated
@@ -1610,33 +1602,31 @@ void ControlContainerBase::ImplModelPropertiesChanged( const Sequence< PropertyC
{
if( !isDesignMode() && !mbCreatingCompatiblePeer )
{
- sal_Int32 nLen = rEvents.getLength();
- for( sal_Int32 i = 0; i < nLen; i++ )
+ auto pEvt = std::find_if(rEvents.begin(), rEvents.end(),
+ [](const PropertyChangeEvent& rEvt) {
+ return rEvt.PropertyName == "PositionX"
+ || rEvt.PropertyName == "PositionY"
+ || rEvt.PropertyName == "Width"
+ || rEvt.PropertyName == "Height";
+ });
+ if (pEvt != rEvents.end())
{
- const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
- Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
+ Reference< XControlModel > xModel( pEvt->Source, UNO_QUERY );
bool bOwnModel = xModel.get() == getModel().get();
- if ( ( rEvt.PropertyName == "PositionX" ) ||
- ( rEvt.PropertyName == "PositionY" ) ||
- ( rEvt.PropertyName == "Width" ) ||
- ( rEvt.PropertyName == "Height" ) )
+ if ( bOwnModel )
{
- if ( bOwnModel )
+ if ( !mbPosModified && !mbSizeModified )
{
- if ( !mbPosModified && !mbSizeModified )
- {
- // Don't set new pos/size if we get new values from window listener
- Reference< XControl > xThis( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY );
- ImplSetPosSize( xThis );
- }
+ // Don't set new pos/size if we get new values from window listener
+ Reference< XControl > xThis( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY );
+ ImplSetPosSize( xThis );
}
- else
- {
- Sequence<Reference<XControl> > aControlSequence(getControls());
- Reference<XControl> aControlRef( StdTabController::FindControl( aControlSequence, xModel ) );
- ImplSetPosSize( aControlRef );
- }
- break;
+ }
+ else
+ {
+ Sequence<Reference<XControl> > aControlSequence(getControls());
+ Reference<XControl> aControlRef( StdTabController::FindControl( aControlSequence, xModel ) );
+ ImplSetPosSize( aControlRef );
}
}
}
@@ -1700,9 +1690,8 @@ static void lcl_ApplyResolverToNestedContainees( const Reference< resource::XSt
Sequence< OUString > aPropNames { aPropName };
const Sequence< Reference< awt::XControl > > aSeq = xContainer->getControls();
- for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+ for ( const Reference< XControl >& xControl : aSeq )
{
- Reference< XControl > xControl( aSeq[i] );
Reference< XPropertySet > xPropertySet;
if ( xControl.is() )
@@ -1836,8 +1825,8 @@ ControlModelContainerBase::updateUserFormChildren( const Reference< XNameContain
if ( xProps.is() )
xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( uno::Reference< XNameContainer >() ) );
Sequence< OUString > aChildNames = xChildContainer->getElementNames();
- for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index )
- updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, Reference< XControlModel > () );
+ for ( const auto& rName : aChildNames )
+ updateUserFormChildren( xAllChildren, rName, Operation, Reference< XControlModel > () );
}
}
else if ( Operation == Insert )
@@ -1852,10 +1841,10 @@ ControlModelContainerBase::updateUserFormChildren( const Reference< XNameContain
if ( xProps.is() )
xProps->setPropertyValue( GetPropertyName( BASEPROPERTY_USERFORMCONTAINEES ), uno::makeAny( xAllChildren ) );
Sequence< OUString > aChildNames = xChildContainer->getElementNames();
- for ( sal_Int32 index=0; index< aChildNames.getLength(); ++index )
+ for ( const auto& rName : aChildNames )
{
- Reference< XControlModel > xChildTarget( xChildContainer->getByName( aChildNames[ index ] ), UNO_QUERY );
- updateUserFormChildren( xAllChildren, aChildNames[ index ], Operation, xChildTarget );
+ Reference< XControlModel > xChildTarget( xChildContainer->getByName( rName ), UNO_QUERY );
+ updateUserFormChildren( xAllChildren, rName, Operation, xChildTarget );
}
}
}
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index ef23735bdc25..328b62d07905 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -612,10 +612,8 @@ void SAL_CALL UnoDialogControl::modified(
void UnoDialogControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents )
{
- sal_Int32 nLen = rEvents.getLength();
- for( sal_Int32 i = 0; i < nLen; i++ )
+ for( const PropertyChangeEvent& rEvt : rEvents )
{
- const PropertyChangeEvent& rEvt = rEvents.getConstArray()[i];
Reference< XControlModel > xModel( rEvt.Source, UNO_QUERY );
bool bOwnModel = xModel.get() == getModel().get();
if ( bOwnModel && rEvt.PropertyName == "ImageURL" )
@@ -795,9 +793,8 @@ void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, c
UnoControlContainer::createPeer( rxToolkit, rParentPeer );
uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
- sal_uInt32 nCtrls = aCtrls.getLength();
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
- bindPage( aCtrls[ n ] );
+ for( const auto& rCtrl : aCtrls )
+ bindPage( rCtrl );
sal_Int32 nActiveTab(0);
Reference< XPropertySet > xMultiProps( getModel(), UNO_QUERY );
xMultiProps->getPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ) ) >>= nActiveTab;
@@ -806,7 +803,7 @@ void UnoMultiPageControl::createPeer( const Reference< XToolkit > & rxToolkit, c
if ( xTabCntrl.is() )
{
xTabCntrl->addTabListener( this );
- if ( nActiveTab && nCtrls ) // Ensure peer is initialise with correct activated tab
+ if ( nActiveTab && aCtrls.hasElements() ) // Ensure peer is initialise with correct activated tab
{
xTabCntrl->activateTab( nActiveTab );
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTIPAGEVALUE ), uno::makeAny( nActiveTab ), true );
diff --git a/toolkit/source/controls/geometrycontrolmodel.cxx b/toolkit/source/controls/geometrycontrolmodel.cxx
index 5d183f09aa41..53a12342d8de 100644
--- a/toolkit/source/controls/geometrycontrolmodel.cxx
+++ b/toolkit/source/controls/geometrycontrolmodel.cxx
@@ -402,12 +402,9 @@
css::uno::Sequence< OUString > aNames =
xEventCont->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 i, nNameCount = aNames.getLength();
- for( i = 0 ; i < nNameCount ; i++ )
+ for( const OUString& aName : aNames )
{
- OUString aName = pNames[ i ];
css::uno::Any aElement = xEventCont->getByName( aName );
xCloneEventCont->insertByName( aName, aElement );
}
@@ -534,29 +531,20 @@
aAggregateProps.end(),
PropertyNameLess()
);
- const Property* pAggProps = aAggregateProps.getConstArray();
- const Property* pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
// now loop through our own props
- const Property* pProp = aProps.getConstArray();
- const Property* pPropEnd = aProps.getConstArray() + aProps.getLength();
- while ( pProp < pPropEnd )
+ for ( const Property& rProp : aProps )
{
// look for the current property in the properties of our aggregate
- const Property* pAggPropPos = ::std::find_if( pAggProps, pAggPropsEnd, PropertyNameEqual( pProp->Name ) );
- if ( pAggPropPos != pAggPropsEnd )
+ const Property* pAggPropPos = ::std::find_if( aAggregateProps.begin(), aAggregateProps.end(), PropertyNameEqual( rProp.Name ) );
+ if ( pAggPropPos != aAggregateProps.end() )
{ // found a duplicate
// -> remove from the aggregate property sequence
- ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - pAggProps );
- // which means we have to adjust the pointers
- pAggProps = aAggregateProps.getConstArray();
- pAggPropsEnd = aAggregateProps.getConstArray() + aAggregateProps.getLength();
+ ::comphelper::removeElementAt( aAggregateProps, pAggPropPos - aAggregateProps.begin() );
// and additionally, remember the id of this property
- rDuplicateIds.push_back( pProp->Handle );
+ rDuplicateIds.push_back( rProp.Handle );
}
-
- ++pProp;
}
// now, finally, sort the duplicates
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
index 892685fd74f9..ae08e1da9a6a 100644
--- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx
+++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx
@@ -243,8 +243,11 @@ private:
// create new data row
RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() );
RowData::iterator cellData = newRow.begin();
- for ( const Any* pData = i_rowData.begin(); pData != i_rowData.end(); ++pData, ++cellData )
- cellData->first = *pData;
+ for ( const Any& rData : i_rowData )
+ {
+ cellData->first = rData;
+ ++cellData;
+ }
// insert data row
m_aData.insert( m_aData.begin() + i_position, newRow );
@@ -301,10 +304,9 @@ private:
return;
// determine max col count in the new data
- sal_Int32 maxColCount = 0;
- for ( sal_Int32 row=0; row<rowCount; ++row )
- if ( i_data[row].getLength() > maxColCount )
- maxColCount = i_data[row].getLength();
+ auto pData = std::max_element(i_data.begin(), i_data.end(),
+ [](const Sequence< Any >& a, const Sequence< Any >& b) { return a.getLength() < b.getLength(); });
+ sal_Int32 maxColCount = pData->getLength();
if ( maxColCount < m_nColumnCount )
maxColCount = m_nColumnCount;
@@ -386,9 +388,9 @@ private:
if ( columnCount == 0 )
return;
- for ( sal_Int32 col = 0; col < columnCount; ++col )
+ for ( sal_Int32 const columnIndex : i_columnIndexes )
{
- if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) )
+ if ( ( columnIndex < 0 ) || ( columnIndex > m_nColumnCount ) )
throw IndexOutOfBoundsException( OUString(), *this );
}
diff --git a/toolkit/source/controls/stdtabcontroller.cxx b/toolkit/source/controls/stdtabcontroller.cxx
index f7debf9f0c1a..7f89093a8dde 100644
--- a/toolkit/source/controls/stdtabcontroller.cxx
+++ b/toolkit/source/controls/stdtabcontroller.cxx
@@ -62,22 +62,19 @@ bool StdTabController::ImplCreateComponentSequence(
Sequence< Any>* pTabStops,
bool bPeerComponent )
{
- bool bOK = true;
-
// Get only the requested controls
sal_Int32 nModels = rModels.getLength();
if (nModels != rControls.getLength())
{
Sequence< Reference< XControl > > aSeq( nModels );
- const Reference< XControlModel >* pModels = rModels.getConstArray();
Reference< XControl > xCurrentControl;
sal_Int32 nRealControls = 0;
- for (sal_Int32 n = 0; n < nModels; ++n, ++pModels)
+ for (const Reference< XControlModel >& rModel : rModels)
{
- xCurrentControl = FindControl(rControls, *pModels);
+ xCurrentControl = FindControl(rControls, rModel);
if (xCurrentControl.is())
- aSeq.getArray()[nRealControls++] = xCurrentControl;
+ aSeq[nRealControls++] = xCurrentControl;
}
aSeq.realloc(nRealControls);
rControls = aSeq;
@@ -86,8 +83,7 @@ bool StdTabController::ImplCreateComponentSequence(
// there may be less controls than models, but never more controls than models
assert(rControls.getLength() <= rModels.getLength());
- const Reference< XControl > * pControls = rControls.getConstArray();
- sal_uInt32 nCtrls = rControls.getLength();
+ sal_Int32 nCtrls = rControls.getLength();
rComponents.realloc( nCtrls );
Reference< XWindow > * pComps = rComponents.getArray();
Any* pTabs = nullptr;
@@ -99,36 +95,37 @@ bool StdTabController::ImplCreateComponentSequence(
pTabs = pTabStops->getArray();
}
- for ( sal_uInt32 n = 0; bOK && ( n < nCtrls ); n++ )
+ bool bOK = true;
+ for ( const Reference< XControl >& xCtrl : rControls )
{
// Get the matching control for this model
- Reference< XControl > xCtrl(pControls[n]);
- if ( xCtrl.is() )
+ if ( !xCtrl.is() )
{
- if (bPeerComponent)
- pComps[n].set(xCtrl->getPeer(), UNO_QUERY);
- else
- pComps[n].set(xCtrl, UNO_QUERY);
-
- // TabStop-Property
- if ( pTabs )
- {
- // opt: Constant String for TabStop name
- static const char aTabStopName[] = "Tabstop";
-
- Reference< XPropertySet > xPSet( xCtrl->getModel(), UNO_QUERY );
- Reference< XPropertySetInfo > xInfo = xPSet->getPropertySetInfo();
- if( xInfo->hasPropertyByName( aTabStopName ) )
- *pTabs++ = xPSet->getPropertyValue( aTabStopName );
- else
- ++pTabs;
- }
+ SAL_WARN("toolkit", "Control not found" );
+ bOK = false;
+ break;
}
+
+ if (bPeerComponent)
+ pComps->set(xCtrl->getPeer(), UNO_QUERY);
else
+ pComps->set(xCtrl, UNO_QUERY);
+
+ // TabStop-Property
+ if ( pTabs )
{
- SAL_WARN("toolkit", "Control not found" );
- bOK = false;
+ // opt: Constant String for TabStop name
+ static const char aTabStopName[] = "Tabstop";
+
+ Reference< XPropertySet > xPSet( xCtrl->getModel(), UNO_QUERY );
+ Reference< XPropertySetInfo > xInfo = xPSet->getPropertySetInfo();
+ if( xInfo->hasPropertyByName( aTabStopName ) )
+ *pTabs++ = xPSet->getPropertyValue( aTabStopName );
+ else
+ ++pTabs;
}
+
+ ++pComps;
}
return bOK;
}
@@ -221,19 +218,14 @@ Sequence< Reference< XControl > > StdTabController::getControls( )
if ( mxControlContainer.is() )
{
Sequence< Reference< XControlModel > > aModels = mxModel->getControlModels();
- const Reference< XControlModel > * pModels = aModels.getConstArray();
Sequence< Reference< XControl > > xCtrls = mxControlContainer->getControls();
- sal_uInt32 nCtrls = aModels.getLength();
+ sal_Int32 nCtrls = aModels.getLength();
aSeq = Sequence< Reference< XControl > >( nCtrls );
- for ( sal_uInt32 n = 0; n < nCtrls; n++ )
- {
- Reference< XControlModel > xCtrlModel = pModels[n];
- // Search matching Control for this Model
- Reference< XControl > xCtrl = FindControl( xCtrls, xCtrlModel );
- aSeq.getArray()[n] = xCtrl;
- }
+ std::transform(aModels.begin(), aModels.end(), aSeq.begin(),
+ [&xCtrls](const Reference< XControlModel >& xCtrlModel) -> Reference< XControl > {
+ return FindControl( xCtrls, xCtrlModel ); });
}
return aSeq;
}
@@ -265,14 +257,13 @@ void StdTabController::autoTabOrder( )
return;
sal_uInt32 nCtrls = aCompSeq.getLength();
- Reference< XWindow > * pComponents = aCompSeq.getArray();
// insert sort algorithm
std::vector< ComponentEntry > aCtrls;
aCtrls.reserve(nCtrls);
- for ( size_t n = 0; n < nCtrls; n++ )
+ for ( const Reference< XWindow >& rComponent : aCompSeq )
{
- XWindow* pC = pComponents[n].get();
+ XWindow* pC = rComponent.get();
ComponentEntry newEntry;
newEntry.pComponent = pC;
awt::Rectangle aPosSize = pC->getPosSize();
@@ -295,12 +286,11 @@ void StdTabController::autoTabOrder( )
}
Sequence< Reference< XControlModel > > aNewSeq( nCtrls );
- for ( size_t n = 0; n < nCtrls; n++ )
- {
- ComponentEntry& rEntry = aCtrls[ n ];
- Reference< XControl > xUC( rEntry.pComponent, UNO_QUERY );
- aNewSeq.getArray()[n] = xUC->getModel();
- }
+ std::transform(aCtrls.begin(), aCtrls.end(), aNewSeq.begin(),
+ [](const ComponentEntry& rEntry) -> Reference< XControlModel > {
+ Reference< XControl > xUC( rEntry.pComponent, UNO_QUERY );
+ return xUC->getModel();
+ });
mxModel->setControlModels( aNewSeq );
}
@@ -400,17 +390,17 @@ Reference< XControl > StdTabController::FindControl( Sequence< Reference< XCont
throw lang::IllegalArgumentException("No valid XControlModel",
uno::Reference<uno::XInterface>(), 0);
- const Reference< XControl > * pCtrls = rCtrls.getConstArray();
- sal_Int32 nCtrls = rCtrls.getLength();
- for ( sal_Int32 n = 0; n < nCtrls; n++ )
+ auto pCtrl = std::find_if(rCtrls.begin(), rCtrls.end(),
+ [&rxCtrlModel](const Reference< XControl >& rCtrl) {
+ Reference< XControlModel > xModel(rCtrl.is() ? rCtrl->getModel() : Reference< XControlModel > ());
+ return xModel.get() == rxCtrlModel.get();
+ });
+ if (pCtrl != rCtrls.end())
{
- Reference< XControlModel > xModel(pCtrls[n].is() ? pCtrls[n]->getModel() : Reference< XControlModel > ());
- if ( xModel.get() == rxCtrlModel.get() )
- {
- Reference< XControl > xCtrl( pCtrls[n] );
- ::comphelper::removeElementAt( rCtrls, n );
- return xCtrl;
- }
+ auto n = static_cast<sal_Int32>(std::distance(rCtrls.begin(), pCtrl));
+ Reference< XControl > xCtrl( *pCtrl );
+ ::comphelper::removeElementAt( rCtrls, n );
+ return xCtrl;
}
return Reference< XControl > ();
}
diff --git a/toolkit/source/controls/stdtabcontrollermodel.cxx b/toolkit/source/controls/stdtabcontrollermodel.cxx
index 81fde2af0fef..17b5d8144480 100644
--- a/toolkit/source/controls/stdtabcontrollermodel.cxx
+++ b/toolkit/source/controls/stdtabcontrollermodel.cxx
@@ -132,14 +132,12 @@ void StdTabControllerModel::ImplGetControlModels( css::uno::Reference< css::awt:
void StdTabControllerModel::ImplSetControlModels( UnoControlModelEntryList& rList, const css::uno::Sequence< css::uno::Reference< css::awt::XControlModel > >& Controls )
{
- const css::uno::Reference< css::awt::XControlModel > * pRefs = Controls.getConstArray();
- sal_uInt32 nControls = Controls.getLength();
- for ( sal_uInt32 n = 0; n < nControls; n++ )
+ for ( const css::uno::Reference< css::awt::XControlModel >& rRef : Controls )
{
UnoControlModelEntry* pNewEntry = new UnoControlModelEntry;
pNewEntry->bGroup = false;
pNewEntry->pxControl = new css::uno::Reference< css::awt::XControlModel > ;
- *pNewEntry->pxControl = pRefs[n];
+ *pNewEntry->pxControl = rRef;
rList.push_back( pNewEntry );
}
}
@@ -166,10 +164,8 @@ static void ImplWriteControls( const css::uno::Reference< css::io::XObjectOutput
OutStream->writeLong( 0 ); // DataLen
OutStream->writeLong( 0 ); // nStoredControls
- sal_uInt32 nCtrls = rCtrls.getLength();
- for ( sal_uInt32 n = 0; n < nCtrls; n++ )
+ for ( const css::uno::Reference< css::awt::XControlModel >& xI : rCtrls )
{
- const css::uno::Reference< css::awt::XControlModel > xI = rCtrls.getConstArray()[n];
css::uno::Reference< css::io::XPersistObject > xPO( xI, css::uno::UNO_QUERY );
DBG_ASSERT( xPO.is(), "write: Control doesn't support XPersistObject" );
if ( xPO.is() )
diff --git a/toolkit/source/controls/tabpagecontainer.cxx b/toolkit/source/controls/tabpagecontainer.cxx
index 18bda42e9e11..61f17296a348 100644
--- a/toolkit/source/controls/tabpagecontainer.cxx
+++ b/toolkit/source/controls/tabpagecontainer.cxx
@@ -309,12 +309,10 @@ void UnoControlTabPageContainer::updateFromModel()
ContainerEvent aEvent;
aEvent.Source = getModel();
Sequence< Reference< XControl > > aControls = getControls();
- const Reference< XControl >* pCtrls = aControls.getConstArray();
- const Reference< XControl >* pCtrlsEnd = pCtrls + aControls.getLength();
- for ( ; pCtrls < pCtrlsEnd; ++pCtrls )
+ for ( const Reference< XControl >& rCtrl : aControls )
{
- aEvent.Element <<= *pCtrls;
+ aEvent.Element <<= rCtrl;
xContainerListener->elementInserted( aEvent );
}
}
diff --git a/toolkit/source/controls/tabpagemodel.cxx b/toolkit/source/controls/tabpagemodel.cxx
index afbd535692ce..334557a9ff1e 100644
--- a/toolkit/source/controls/tabpagemodel.cxx
+++ b/toolkit/source/controls/tabpagemodel.cxx
@@ -131,15 +131,13 @@ void SAL_CALL UnoControlTabPageModel::initialize (const Sequence<Any>& rArgument
if ( xDialogModel.is() )
{
Sequence< OUString> aNames = xDialogModel->getElementNames();
- const OUString* pIter = aNames.getConstArray();
- const OUString* pEnd = pIter + aNames.getLength();
- for(;pIter != pEnd;++pIter)
+ for(const OUString& rName : aNames)
{
try
{
- Any aElement(xDialogModel->getByName(*pIter));
- xDialogModel->removeByName(*pIter);
- insertByName(*pIter,aElement);
+ Any aElement(xDialogModel->getByName(rName));
+ xDialogModel->removeByName(rName);
+ insertByName(rName,aElement);
}
catch(const Exception&) {}
}
diff --git a/toolkit/source/controls/unocontrol.cxx b/toolkit/source/controls/unocontrol.cxx
index 8207e31fc095..038a615cc228 100644
--- a/toolkit/source/controls/unocontrol.cxx
+++ b/toolkit/source/controls/unocontrol.cxx
@@ -86,10 +86,8 @@ static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiProp
Sequence< Property> aProps = xPSInf->getProperties();
sal_Int32 nLen = aProps.getLength();
aNames = Sequence< OUString>( nLen );
- OUString* pNames = aNames.getArray();
- const Property* pProps = aProps.getConstArray();
- for ( sal_Int32 n = 0; n < nLen; ++n, ++pProps, ++pNames)
- *pNames = pProps->Name;
+ std::transform(aProps.begin(), aProps.end(), aNames.begin(),
+ [](const Property& rProp) -> OUString { return rProp.Name; });
}
return aNames;
}
@@ -275,8 +273,8 @@ void UnoControl::ImplSetPeerProperty( const OUString& rPropName, const Any& rVal
}
else if ( aConvertedValue >>= aSeqValue )
{
- for ( sal_Int32 i = 0; i < aSeqValue.getLength(); i++ )
- ImplCheckLocalize( aSeqValue[i] );
+ for ( auto& rValue : aSeqValue )
+ ImplCheckLocalize( rValue );
aConvertedValue <<= aSeqValue;
}
}
@@ -478,28 +476,26 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY );
OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" );
- const PropertyChangeEvent* pEvents = rEvents.getConstArray();
-
sal_Int32 nLen = rEvents.getLength();
aPeerPropertiesToSet.reserve(nLen);
- for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents )
+ for( const PropertyChangeEvent& rEvent : rEvents )
{
- Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY );
+ Reference< XControlModel > xModel( rEvent.Source, UNO_QUERY );
bool bOwnModel = xModel.get() == xOwnModel.get();
if ( !bOwnModel )
continue;
// Detect changes on our resource resolver which invalidates
// automatically some language dependent properties.
- if ( pEvents->PropertyName == "ResourceResolver" )
+ if ( rEvent.PropertyName == "ResourceResolver" )
{
Reference< resource::XStringResourceResolver > xStrResolver;
- if ( pEvents->NewValue >>= xStrResolver )
+ if ( rEvent.NewValue >>= xStrResolver )
bResourceResolverSet = xStrResolver.is();
}
- sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName );
+ sal_uInt16 nPType = GetPropertyId( rEvent.PropertyName );
if ( mbDesignMode && mbDisposePeer && !mbRefreshingPeer && !mbCreatingPeer )
{
// if we're in design mode, then some properties can change which
@@ -518,7 +514,7 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
|| ( nPType == BASEPROPERTY_ALIGN )
|| ( nPType == BASEPROPERTY_PAINTTRANSPARENT );
else
- bNeedNewPeer = requiresNewPeer( pEvents->PropertyName );
+ bNeedNewPeer = requiresNewPeer( rEvent.PropertyName );
if ( bNeedNewPeer )
break;
@@ -529,7 +525,7 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
// Add properties with dependencies on other properties last
// since they're dependent on properties added later (such as
// VALUE dependency on VALUEMIN/MAX)
- aPeerPropertiesToSet.emplace_back(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE);
+ aPeerPropertiesToSet.emplace_back(rEvent.PropertyName, 0, rEvent.NewValue, PropertyState_DIRECT_VALUE);
}
else
{
@@ -541,7 +537,7 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
// resolver. We don't need to handle a special order for these two props.
aPeerPropertiesToSet.insert(
aPeerPropertiesToSet.begin(),
- PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
+ PropertyValue( rEvent.PropertyName, 0, rEvent.NewValue, PropertyState_DIRECT_VALUE ) );
++nIndependentPos;
}
else if ( nPType == BASEPROPERTY_NATIVE_WIDGET_LOOK )
@@ -555,13 +551,13 @@ void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent
// defaults.
aPeerPropertiesToSet.insert(
aPeerPropertiesToSet.begin(),
- PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
+ PropertyValue( rEvent.PropertyName, 0, rEvent.NewValue, PropertyState_DIRECT_VALUE ) );
++nIndependentPos;
}
else
{
aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos,
- PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
+ PropertyValue(rEvent.PropertyName, 0, rEvent.NewValue, PropertyState_DIRECT_VALUE));
++nIndependentPos;
}
}
diff --git a/toolkit/source/controls/unocontrolcontainer.cxx b/toolkit/source/controls/unocontrolcontainer.cxx
index ccdea4e41a76..eacaffbc0ee1 100644
--- a/toolkit/source/controls/unocontrolcontainer.cxx
+++ b/toolkit/source/controls/unocontrolcontainer.cxx
@@ -297,13 +297,9 @@ static void implUpdateVisibility
{
uno::Sequence< uno::Reference< awt::XControl > >
aCtrls = xControlContainer->getControls();
- const uno::Reference< awt::XControl >* pCtrls = aCtrls.getConstArray();
- sal_uInt32 nCtrls = aCtrls.getLength();
bool bCompleteVisible = (nDialogStep == 0);
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ for( const uno::Reference< awt::XControl >& xControl : aCtrls )
{
- uno::Reference< awt::XControl > xControl = pCtrls[ n ];
-
bool bVisible = bCompleteVisible;
if( !bVisible )
{
@@ -389,11 +385,10 @@ UnoControlContainer::~UnoControlContainer()
void UnoControlContainer::ImplActivateTabControllers()
{
- sal_uInt32 nCount = maTabControllers.getLength();
- for ( sal_uInt32 n = 0; n < nCount; n++ )
+ for ( auto& rTabController : maTabControllers )
{
- maTabControllers.getArray()[n]->setContainer( this );
- maTabControllers.getArray()[n]->activateTabOrder();
+ rTabController->setContainer( this );
+ rTabController->activateTabOrder();
}
}
@@ -708,15 +703,13 @@ void UnoControlContainer::removeTabController( const uno::Reference< awt::XTabCo
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- sal_uInt32 nCount = maTabControllers.getLength();
- const uno::Reference< awt::XTabController >* pLoop = maTabControllers.getConstArray();
- for ( sal_uInt32 n = 0; n < nCount; ++n, ++pLoop )
+ auto pTabController = std::find_if(maTabControllers.begin(), maTabControllers.end(),
+ [&TabController](const uno::Reference< awt::XTabController >& rTabController) {
+ return rTabController.get() == TabController.get(); });
+ if (pTabController != maTabControllers.end())
{
- if( pLoop->get() == TabController.get() )
- {
- ::comphelper::removeElementAt( maTabControllers, n );
- break;
- }
+ auto n = static_cast<sal_Int32>(std::distance(maTabControllers.begin(), pTabController));
+ ::comphelper::removeElementAt( maTabControllers, n );
}
}
@@ -759,9 +752,8 @@ void UnoControlContainer::createPeer( const uno::Reference< awt::XToolkit >& rxT
}
uno::Sequence< uno::Reference< awt::XControl > > aCtrls = getControls();
- sal_uInt32 nCtrls = aCtrls.getLength();
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
- aCtrls.getArray()[n]->createPeer( rxToolkit, getPeer() );
+ for( auto& rCtrl : aCtrls )
+ rCtrl->createPeer( rxToolkit, getPeer() );
uno::Reference< awt::XVclContainerPeer > xC( getPeer(), uno::UNO_QUERY );
if ( xC.is() )
diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx
index cae4b6fee156..8a287b710109 100644
--- a/toolkit/source/controls/unocontrolmodel.cxx
+++ b/toolkit/source/controls/unocontrolmodel.cxx
@@ -345,33 +345,35 @@ css::uno::Any UnoControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
// look for the currency entry (for this language) which has the given bank symbol
Sequence< Currency2 > aAllCurrencies = aLocaleInfo.getAllCurrencies();
- const Currency2* pAllCurrencies = aAllCurrencies.getConstArray();
- const Currency2* pAllCurrenciesEnd = pAllCurrencies + aAllCurrencies.getLength();
OUString sCurrencySymbol = aLocaleInfo.getCurrSymbol();
if ( sBankSymbol.isEmpty() )
{
- DBG_ASSERT( pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: no currencies at all!" );
- if ( pAllCurrencies != pAllCurrenciesEnd )
+ DBG_ASSERT( aAllCurrencies.hasElements(), "UnoControlModel::ImplGetDefaultValue: no currencies at all!" );
+ if ( aAllCurrencies.hasElements() )
{
- sBankSymbol = pAllCurrencies->BankSymbol;
- sCurrencySymbol = pAllCurrencies->Symbol;
+ sBankSymbol = aAllCurrencies[0].BankSymbol;
+ sCurrencySymbol = aAllCurrencies[0].Symbol;
}
}
if ( !sBankSymbol.isEmpty() )
{
bool bLegacy = false;
- for ( ;pAllCurrencies != pAllCurrenciesEnd; ++pAllCurrencies )
- if ( pAllCurrencies->BankSymbol == sBankSymbol )
+ bool bFound = false;
+ for ( const Currency2& rCurrency : aAllCurrencies )
+ if ( rCurrency.BankSymbol == sBankSymbol )
{
- sCurrencySymbol = pAllCurrencies->Symbol;
- if ( pAllCurrencies->LegacyOnly )
+ sCurrencySymbol = rCurrency.Symbol;
+ if ( rCurrency.LegacyOnly )
bLegacy = true;
else
+ {
+ bFound = true;
break;
+ }
}
- DBG_ASSERT( bLegacy || pAllCurrencies != pAllCurrenciesEnd, "UnoControlModel::ImplGetDefaultValue: did not find the given bank symbol!" );
+ DBG_ASSERT( bLegacy || bFound, "UnoControlModel::ImplGetDefaultValue: did not find the given bank symbol!" );
}
aDefault <<= sCurrencySymbol;
@@ -504,14 +506,12 @@ css::uno::Sequence< css::beans::PropertyState > UnoControlModel::getPropertyStat
{
::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
- sal_uInt32 nNames = PropertyNames.getLength();
- const OUString* pNames = PropertyNames.getConstArray();
+ sal_Int32 nNames = PropertyNames.getLength();
css::uno::Sequence< css::beans::PropertyState > aStates( nNames );
- css::beans::PropertyState* pStates = aStates.getArray();
- for ( sal_uInt32 n = 0; n < nNames; n++ )
- pStates[n] = getPropertyState( pNames[n] );
+ std::transform(PropertyNames.begin(), PropertyNames.end(), aStates.begin(),
+ [this](const OUString& rName) -> css::beans::PropertyState { return getPropertyState(rName); });
return aStates;
}
@@ -670,8 +670,8 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
rValue >>= aSeq;
long nEntries = aSeq.getLength();
OutStream->writeLong( nEntries );
- for ( long n = 0; n < nEntries; n++ )
- OutStream->writeUTF( aSeq.getConstArray()[n] );
+ for ( const auto& rVal : aSeq )
+ OutStream->writeUTF( rVal );
}
else if ( rType == cppu::UnoType< cppu::UnoSequenceType<cppu::UnoUnsignedShortType> >::get() )
{
@@ -679,8 +679,8 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
rValue >>= aSeq;
long nEntries = aSeq.getLength();
OutStream->writeLong( nEntries );
- for ( long n = 0; n < nEntries; n++ )
- OutStream->writeShort( aSeq.getConstArray()[n] );
+ for ( const auto nVal : aSeq )
+ OutStream->writeShort( nVal );
}
else if ( rType == cppu::UnoType< css::uno::Sequence<sal_Int16> >::get() )
{
@@ -688,8 +688,8 @@ void UnoControlModel::write( const css::uno::Reference< css::io::XObjectOutputSt
rValue >>= aSeq;
long nEntries = aSeq.getLength();
OutStream->writeLong( nEntries );
- for ( long n = 0; n < nEntries; n++ )
- OutStream->writeShort( aSeq.getConstArray()[n] );
+ for ( const auto nVal : aSeq )
+ OutStream->writeShort( nVal );
}
else if ( rType.getTypeClass() == TypeClass_ENUM )
{
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index e6ec3492bb74..46866c803e50 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -2410,12 +2410,7 @@ void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< OUString >&
getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
OSL_VERIFY( aPropValue >>= aStringItemList );
- o_rStringItems.resize( size_t( aStringItemList.getLength() ) );
- ::std::copy(
- aStringItemList.begin(),
- aStringItemList.end(),
- o_rStringItems.begin()
- );
+ comphelper::sequenceToContainer(o_rStringItems, aStringItemList);
}
@@ -2693,24 +2688,18 @@ void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_In
sal_uInt16 nNewLen = nOldLen + nNewItems;
uno::Sequence< OUString> aNewSeq( nNewLen );
- OUString* pNewData = aNewSeq.getArray();
- OUString* pOldData = aSeq.getArray();
if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
nPos = nOldLen;
- sal_uInt16 n;
// Items before the Paste-Position
- for ( n = 0; n < nPos; n++ )
- pNewData[n] = pOldData[n];
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
// New Items
- for ( n = 0; n < nNewItems; n++ )
- pNewData[nPos+n] = aItems.getConstArray()[n];
+ std::copy(aItems.begin(), aItems.end(), std::next(aNewSeq.begin(), nPos));
// Rest of old Items
- for ( n = nPos; n < nOldLen; n++ )
- pNewData[nNewItems+n] = pOldData[n];
+ std::copy(std::next(aSeq.begin(), nPos), aSeq.end(), std::next(aNewSeq.begin(), nPos + nNewItems));
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
}
@@ -2729,17 +2718,12 @@ void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
sal_uInt16 nNewLen = nOldLen - nCount;
uno::Sequence< OUString> aNewSeq( nNewLen );
- OUString* pNewData = aNewSeq.getArray();
- OUString* pOldData = aSeq.getArray();
- sal_uInt16 n;
// Items before the Remove-Position
- for ( n = 0; n < nPos; n++ )
- pNewData[n] = pOldData[n];
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
// Rest of Items
- for ( n = nPos; n < (nOldLen-nCount); n++ )
- pNewData[n] = pOldData[n+nCount];
+ std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
}
@@ -2760,7 +2744,7 @@ OUString UnoListBoxControl::getItem( sal_Int16 nPos )
uno::Sequence< OUString> aSeq;
aVal >>= aSeq;
if ( nPos < aSeq.getLength() )
- aItem = aSeq.getConstArray()[nPos];
+ aItem = aSeq[nPos];
return aItem;
}
@@ -3304,24 +3288,18 @@ void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_I
sal_uInt16 nNewLen = nOldLen + nNewItems;
uno::Sequence< OUString> aNewSeq( nNewLen );
- OUString* pNewData = aNewSeq.getArray();
- const OUString* pOldData = aSeq.getConstArray();
if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
nPos = nOldLen;
- sal_uInt16 n;
// items before the insert position
- for ( n = 0; n < nPos; n++ )
- pNewData[n] = pOldData[n];
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
// New items
- for ( n = 0; n < nNewItems; n++ )
- pNewData[nPos+n] = aItems.getConstArray()[n];
+ std::copy(aItems.begin(), aItems.end(), std::next(aNewSeq.begin(), nPos));
// remainder of old items
- for ( n = nPos; n < nOldLen; n++ )
- pNewData[nNewItems+n] = pOldData[n];
+ std::copy(std::next(aSeq.begin(), nPos), aSeq.end(), std::next(aNewSeq.begin(), nPos + nNewItems));
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), Any(aNewSeq), true );
}
@@ -3340,17 +3318,12 @@ void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount )
sal_uInt16 nNewLen = nOldLen - nCount;
uno::Sequence< OUString> aNewSeq( nNewLen );
- OUString* pNewData = aNewSeq.getArray();
- OUString* pOldData = aSeq.getArray();
- sal_uInt16 n;
// items before the deletion position
- for ( n = 0; n < nPos; n++ )
- pNewData[n] = pOldData[n];
+ std::copy(aSeq.begin(), std::next(aSeq.begin(), nPos), aNewSeq.begin());
// remainder of old items
- for ( n = nPos; n < (nOldLen-nCount); n++ )
- pNewData[n] = pOldData[n+nCount];
+ std::copy(std::next(aSeq.begin(), nPos + nCount), aSeq.end(), std::next(aNewSeq.begin(), nPos));
ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), uno::Any(aNewSeq), true );
}
@@ -3371,7 +3344,7 @@ OUString UnoComboBoxControl::getItem( sal_Int16 nPos )
uno::Sequence< OUString> aSeq;
aVal >>= aSeq;
if ( nPos < aSeq.getLength() )
- aItem = aSeq.getConstArray()[nPos];
+ aItem = aSeq[nPos];
return aItem;
}
diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx
index 24cd1e02ccf6..821e06eae211 100644
--- a/toolkit/source/helper/formpdfexport.cxx
+++ b/toolkit/source/helper/formpdfexport.cxx
@@ -614,12 +614,9 @@ namespace toolkitform
if( aSelectIndices.hasElements() )
{
pListWidget->SelectedEntries.resize( 0 );
- for( sal_Int32 i = 0; i < aSelectIndices.getLength(); i++ )
- {
- sal_Int16 nIndex = aSelectIndices.getConstArray()[i];
- if( nIndex >= 0 && nIndex < static_cast<sal_Int16>(pListWidget->Entries.size()) )
- pListWidget->SelectedEntries.push_back( nIndex );
- }
+ auto nEntriesSize = static_cast<sal_Int16>(pListWidget->Entries.size());
+ std::copy_if(aSelectIndices.begin(), aSelectIndices.end(), std::back_inserter(pListWidget->SelectedEntries),
+ [&nEntriesSize](const sal_Int16 nIndex) { return nIndex >= 0 && nIndex < nEntriesSize; });
}
}
diff --git a/toolkit/source/helper/unopropertyarrayhelper.cxx b/toolkit/source/helper/unopropertyarrayhelper.cxx
index 704f797d11b1..16413d9a1e9b 100644
--- a/toolkit/source/helper/unopropertyarrayhelper.cxx
+++ b/toolkit/source/helper/unopropertyarrayhelper.cxx
@@ -28,10 +28,8 @@
UnoPropertyArrayHelper::UnoPropertyArrayHelper( const css::uno::Sequence<sal_Int32>& rIDs )
{
- sal_Int32 nIDs = rIDs.getLength();
- const sal_Int32* pIDs = rIDs.getConstArray();
- for ( sal_Int32 n = 0; n < nIDs; n++ )
- maIDs.insert( pIDs[n] );
+ for ( const sal_Int32 nID : rIDs )
+ maIDs.insert( nID );
}
UnoPropertyArrayHelper::UnoPropertyArrayHelper( const std::vector< sal_uInt16 > &rIDs )
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index 6ba0ecf1d9d6..3632ebe4ea60 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -135,9 +135,8 @@ vcl::Region VCLUnoHelper::GetRegion( const css::uno::Reference< css::awt::XRegio
else
{
css::uno::Sequence< css::awt::Rectangle > aRects = rxRegion->getRectangles();
- sal_Int32 nRects = aRects.getLength();
- for ( sal_Int32 n = 0; n < nRects; n++ )
- aRegion.Union( VCLRectangle( aRects.getArray()[n] ) );
+ for ( const auto& rRect : aRects )
+ aRegion.Union( VCLRectangle( rRect ) );
}
return aRegion;
}