From 4e144751f12a06e358e4f7efa7c8f13954e6cfd7 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 17 Dec 2017 23:00:24 +0300 Subject: loplugin:unusedindex Change-Id: I256a807dd2a4c81126b5a76f3d472e31b8224146 Reviewed-on: https://gerrit.libreoffice.org/46652 Tested-by: Jenkins Reviewed-by: Noel Grandin --- forms/source/component/ComboBox.cxx | 25 +++++++++---------------- forms/source/component/DatabaseForm.cxx | 25 +++++++++---------------- forms/source/component/GroupManager.cxx | 8 +++----- forms/source/misc/InterfaceContainer.cxx | 18 +++++++----------- 4 files changed, 28 insertions(+), 48 deletions(-) (limited to 'forms/source') diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index 5df2b3572de8..615970106d19 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -417,10 +417,8 @@ void SAL_CALL OComboBoxModel::read(const Reference& m_aListSource.clear(); css::uno::Sequence aListSource; _rxInStream >> aListSource; - const OUString* pToken = aListSource.getConstArray(); - sal_Int32 nLen = aListSource.getLength(); - for (sal_Int32 i = 0; i < nLen; ++i, ++pToken) - m_aListSource += *pToken; + for (const OUString& rToken : aListSource) + m_aListSource += rToken; } sal_Int16 nListSourceType; @@ -647,12 +645,8 @@ void OComboBoxModel::loadData( bool _bForce ) Reference xFieldNames = getTableFields(xConnection, m_aListSource); if (xFieldNames.is()) { - css::uno::Sequence seqNames = xFieldNames->getElementNames(); - sal_Int32 nFieldsCount = seqNames.getLength(); - const OUString* pustrNames = seqNames.getConstArray(); - - for (sal_Int32 k=0; kgetElementNames()) + aStringList.push_back(rustrNames); } } break; @@ -770,20 +764,19 @@ bool OComboBoxModel::commitControlValueToDbColumn( bool _bPostReset ) css::uno::Sequence aStringItemList; if ( getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList ) { - const OUString* pStringItems = aStringItemList.getConstArray(); - sal_Int32 i; - for (i=0; i add - if (i >= aStringItemList.getLength()) + if (!bFound) { sal_Int32 nOldLen = aStringItemList.getLength(); aStringItemList.realloc( nOldLen + 1 ); - aStringItemList.getArray()[ nOldLen ] = sNewValue; + aStringItemList[ nOldLen ] = sNewValue; setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( aStringItemList ) ); setFastPropertyValue( PROPERTY_ID_TYPEDITEMLIST, makeAny( css::uno::Sequence() ) ); diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 2c154ac795b8..7a026b688e92 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -645,16 +645,12 @@ void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const Referenc Reference xControlContainer(rxSubmitButton->getContext(), UNO_QUERY); if( !xControlContainer.is() ) break; - Sequence > aControlSeq = xControlContainer->getControls(); - Reference xControl; - // Find the right control - sal_Int32 i; - for( i=0; igetControls() ) { - xControl = aControlSeq.getConstArray()[i]; Reference xModel(xControl->getModel(), UNO_QUERY); - if (xModel == xComponentSet) + if ((bFound = xModel == xComponentSet)) { Reference xTextComponent(xControl, UNO_QUERY); if( xTextComponent.is() ) @@ -663,7 +659,7 @@ void ODatabaseForm::AppendComponent(HtmlSuccessfulObjList& rList, const Referenc } } // Couldn't find control or it does not exist (edit in the grid) - if (i == aControlSeq.getLength()) + if (!bFound) xComponentSet->getPropertyValue( PROPERTY_TEXT ) >>= sText; } else @@ -2410,17 +2406,15 @@ void SAL_CALL ODatabaseForm::setControlModels(const Sequence* pControls = rControls.getConstArray(); sal_Int32 nCount = getCount(); - sal_Int32 nNewCount = rControls.getLength(); // HiddenControls and forms are not listed - if (nNewCount <= nCount) + if (rControls.getLength() <= nCount) { sal_Int16 nTabIndex = 1; - for (sal_Int32 i=0; i < nNewCount; ++i, ++pControls) + for (auto const& rControl : rControls) { - Reference xComp(*pControls, UNO_QUERY); + Reference xComp(rControl, UNO_QUERY); if (xComp.is()) { // Find component in the list @@ -2455,13 +2449,12 @@ void SAL_CALL ODatabaseForm::setGroup( const Sequence > // The controls are grouped by adjusting their names to the name of the // first control of the sequence - const Reference* pControls = _rGroup.getConstArray(); Reference< XPropertySet > xSet; OUString sGroupName( Name ); - for( sal_Int32 i=0; i<_rGroup.getLength(); ++i, ++pControls ) + for( auto const& rControl : _rGroup ) { - xSet.set(*pControls, css::uno::UNO_QUERY); + xSet.set(rControl, css::uno::UNO_QUERY); if ( !xSet.is() ) { // can't throw an exception other than a RuntimeException (which would not be appropriate), diff --git a/forms/source/component/GroupManager.cxx b/forms/source/component/GroupManager.cxx index 94620bbb1313..d801ac6d425e 100644 --- a/forms/source/component/GroupManager.cxx +++ b/forms/source/component/GroupManager.cxx @@ -172,14 +172,12 @@ void OGroup::RemoveComponent( const Reference& rxElement ) Sequence< Reference > OGroup::GetControlModels() const { - sal_Int32 nLen = m_aCompArray.size(); - Sequence > aControlModelSeq( nLen ); + Sequence > aControlModelSeq( m_aCompArray.size() ); Reference* pModels = aControlModelSeq.getArray(); - OGroupCompArr::const_iterator aGroupComps = m_aCompArray.begin(); - for (sal_Int32 i = 0; i < nLen; ++i, ++pModels, ++aGroupComps) + for (auto const& rGroupComp : m_aCompArray) { - *pModels = aGroupComps->GetControlModel(); + *pModels++ = rGroupComp.GetControlModel(); } return aControlModelSeq; } diff --git a/forms/source/misc/InterfaceContainer.cxx b/forms/source/misc/InterfaceContainer.cxx index 6c4885260afb..3d5ffd73083b 100644 --- a/forms/source/misc/InterfaceContainer.cxx +++ b/forms/source/misc/InterfaceContainer.cxx @@ -81,11 +81,9 @@ namespace bool lcl_hasVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents ) { - const ScriptEventDescriptor* pDesc = sEvents.getConstArray(); - const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() ); - for ( ; pDesc != pEnd; ++pDesc ) + for ( auto const& rDesc : sEvents ) { - if ( pDesc->ScriptType == "VBAInterop" ) + if ( rDesc.ScriptType == "VBAInterop" ) return true; } return false; @@ -95,19 +93,17 @@ Sequence< ScriptEventDescriptor > lcl_stripVbaEvents( const Sequence< ScriptEventDescriptor >& sEvents ) { Sequence< ScriptEventDescriptor > sStripped( sEvents.getLength() ); + ScriptEventDescriptor* pStripped = sStripped.getArray(); - const ScriptEventDescriptor* pDesc = sEvents.getConstArray(); - const ScriptEventDescriptor* pEnd = ( pDesc + sEvents.getLength() ); sal_Int32 nCopied = 0; - for ( ; pDesc != pEnd; ++pDesc ) + for ( auto const& rDesc : sEvents ) { - if ( pDesc->ScriptType != "VBAInterop" ) + if ( rDesc.ScriptType != "VBAInterop" ) { - sStripped[ nCopied++ ] = *pDesc; + pStripped[ nCopied++ ] = rDesc; } } - if ( nCopied ) - sStripped.realloc( nCopied ); + sStripped.realloc( nCopied ); return sStripped; } -- cgit