diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-12-17 23:00:24 +0300 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-12-18 07:36:32 +0100 |
commit | 4e144751f12a06e358e4f7efa7c8f13954e6cfd7 (patch) | |
tree | c6df66d58d02ecaf5caa437a944665fe83959402 /forms | |
parent | 39c618caf5aa19da95285bec6cab7108bee3984c (diff) |
loplugin:unusedindex
Change-Id: I256a807dd2a4c81126b5a76f3d472e31b8224146
Reviewed-on: https://gerrit.libreoffice.org/46652
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/component/ComboBox.cxx | 25 | ||||
-rw-r--r-- | forms/source/component/DatabaseForm.cxx | 25 | ||||
-rw-r--r-- | forms/source/component/GroupManager.cxx | 8 | ||||
-rw-r--r-- | forms/source/misc/InterfaceContainer.cxx | 18 |
4 files changed, 28 insertions, 48 deletions
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<css::io::XObjectInputStream>& m_aListSource.clear(); css::uno::Sequence<OUString> 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<XNameAccess> xFieldNames = getTableFields(xConnection, m_aListSource); if (xFieldNames.is()) { - css::uno::Sequence<OUString> seqNames = xFieldNames->getElementNames(); - sal_Int32 nFieldsCount = seqNames.getLength(); - const OUString* pustrNames = seqNames.getConstArray(); - - for (sal_Int32 k=0; k<nFieldsCount; ++k) - aStringList.push_back(pustrNames[k]); + for (const OUString& rustrNames : xFieldNames->getElementNames()) + aStringList.push_back(rustrNames); } } break; @@ -770,20 +764,19 @@ bool OComboBoxModel::commitControlValueToDbColumn( bool _bPostReset ) css::uno::Sequence<OUString> aStringItemList; if ( getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aStringItemList ) { - const OUString* pStringItems = aStringItemList.getConstArray(); - sal_Int32 i; - for (i=0; i<aStringItemList.getLength(); ++i, ++pStringItems) + bool bFound = false; + for (const OUString& rStringItem : aStringItemList) { - if ( *pStringItems == sNewValue ) + if ( (bFound = rStringItem == sNewValue) ) break; } // not found -> 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<css::uno::Any>() ) ); 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> xControlContainer(rxSubmitButton->getContext(), UNO_QUERY); if( !xControlContainer.is() ) break; - Sequence<Reference<XControl> > aControlSeq = xControlContainer->getControls(); - Reference<XControl> xControl; - // Find the right control - sal_Int32 i; - for( i=0; i<aControlSeq.getLength(); i++ ) + bool bFound = false; + for( auto const& xControl : xControlContainer->getControls() ) { - xControl = aControlSeq.getConstArray()[i]; Reference<XPropertySet> xModel(xControl->getModel(), UNO_QUERY); - if (xModel == xComponentSet) + if ((bFound = xModel == xComponentSet)) { Reference<XTextComponent> 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<Reference<XControlM ::osl::ResettableMutexGuard aGuard(m_aMutex); // Set TabIndex in the order of the sequence - const Reference<XControlModel>* 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<XFormComponent> xComp(*pControls, UNO_QUERY); + Reference<XFormComponent> xComp(rControl, UNO_QUERY); if (xComp.is()) { // Find component in the list @@ -2455,13 +2449,12 @@ void SAL_CALL ODatabaseForm::setGroup( const Sequence<Reference<XControlModel> > // The controls are grouped by adjusting their names to the name of the // first control of the sequence - const Reference<XControlModel>* 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<XPropertySet>& rxElement ) Sequence< Reference<XControlModel> > OGroup::GetControlModels() const { - sal_Int32 nLen = m_aCompArray.size(); - Sequence<Reference<XControlModel> > aControlModelSeq( nLen ); + Sequence<Reference<XControlModel> > aControlModelSeq( m_aCompArray.size() ); Reference<XControlModel>* 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; } |