From 20571c472528c4f98fe3f55700d134915d32a49a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 10 Jul 2017 16:12:07 +0200 Subject: use more range-for on uno::Sequence Change-Id: Ifad32425d79be5a22d33d721bdc5fb993f699759 Reviewed-on: https://gerrit.libreoffice.org/39763 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- sc/source/filter/xml/xmlexprt.cxx | 22 ++++++++++------------ sc/source/ui/unoobj/chartuno.cxx | 5 +---- sc/source/ui/vba/vbawsfunction.cxx | 34 ++++++++++++++++------------------ 3 files changed, 27 insertions(+), 34 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 8cdfb63c1d05..d341e582cac4 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2113,15 +2113,14 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference& x nIndex = pCellStyles->GetIndexOfStyleName(sName, XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX, bIsAutoStyle); uno::Sequence aAddresses(xCellRanges->getRangeAddresses()); - table::CellRangeAddress* pAddresses(aAddresses.getArray()); bool bGetMerge(true); - for (sal_Int32 i = 0; i < aAddresses.getLength(); ++i, ++pAddresses) + for (table::CellRangeAddress const & address : aAddresses) { - pSharedData->SetLastColumn(nTable, pAddresses->EndColumn); - pSharedData->SetLastRow(nTable, pAddresses->EndRow); - pCellStyles->AddRangeStyleName(*pAddresses, nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat); + pSharedData->SetLastColumn(nTable, address.EndColumn); + pSharedData->SetLastRow(nTable, address.EndRow); + pCellStyles->AddRangeStyleName(address, nIndex, bIsAutoStyle, nValidationIndex, nNumberFormat); if (bGetMerge) - bGetMerge = GetMerged(pAddresses, xTable); + bGetMerge = GetMerged(&address, xTable); } } } @@ -2137,17 +2136,16 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference& x if ( !pOldName ) { uno::Sequence aAddresses(xCellRanges->getRangeAddresses()); - table::CellRangeAddress* pAddresses(aAddresses.getArray()); bool bGetMerge(true); - for (sal_Int32 i = 0; i < aAddresses.getLength(); ++i, ++pAddresses) + for (table::CellRangeAddress const & address : aAddresses) { if (bGetMerge) - bGetMerge = GetMerged(pAddresses, xTable); - pCellStyles->AddRangeStyleName(*pAddresses, nIndex, false, nValidationIndex, nNumberFormat); + bGetMerge = GetMerged(&address, xTable); + pCellStyles->AddRangeStyleName(address, nIndex, false, nValidationIndex, nNumberFormat); if( sStyleName != "Default" || nValidationIndex != -1 ) { - pSharedData->SetLastColumn(nTable, pAddresses->EndColumn); - pSharedData->SetLastRow(nTable, pAddresses->EndRow); + pSharedData->SetLastColumn(nTable, address.EndColumn); + pSharedData->SetLastRow(nTable, address.EndRow); } } } diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx index c9da280e6955..cc38b7059892 100644 --- a/sc/source/ui/unoobj/chartuno.cxx +++ b/sc/source/ui/unoobj/chartuno.cxx @@ -527,11 +527,8 @@ void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno: if ( rValue >>= aCellRanges ) { ScRangeListRef rRangeList = new ScRangeList(); - const table::CellRangeAddress* pCellRanges = aCellRanges.getArray(); - sal_Int32 nCount = aCellRanges.getLength(); - for ( sal_Int32 i = 0; i < nCount; ++i ) + for ( table::CellRangeAddress const & aCellRange : aCellRanges ) { - table::CellRangeAddress aCellRange = pCellRanges[ i ]; ScRange aRange; ScUnoConversion::FillScRange( aRange, aCellRange ); rRangeList->Append( aRange ); diff --git a/sc/source/ui/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx index ca7cf6dadc08..dba387baf3cd 100644 --- a/sc/source/ui/vba/vbawsfunction.cxx +++ b/sc/source/ui/vba/vbawsfunction.cxx @@ -84,55 +84,53 @@ ScVbaWSFunction::invoke(const OUString& FunctionName, const uno::Sequence< uno:: uno::Sequence< uno::Any > aParamTemp( Params ); if( aParamTemp.hasElements() ) { - uno::Any* pArray = aParamTemp.getArray(); - uno::Any* pArrayEnd = pArray + aParamTemp.getLength(); - for( ; pArray < pArrayEnd; ++pArray ) + for( uno::Any & rArray : aParamTemp ) { - switch( pArray->getValueType().getTypeClass() ) + switch( rArray.getValueType().getTypeClass() ) { case uno::TypeClass_BOOLEAN: - lclConvertBooleanToDouble( *pArray ); + lclConvertBooleanToDouble( rArray ); break; case uno::TypeClass_INTERFACE: { - uno::Reference< excel::XRange > myRange( *pArray, uno::UNO_QUERY ); + uno::Reference< excel::XRange > myRange( rArray, uno::UNO_QUERY ); if( myRange.is() ) - *pArray = myRange->getCellRange(); + rArray = myRange->getCellRange(); } break; case uno::TypeClass_SEQUENCE: { // the sheet.FunctionAccess service doesn't deal with Sequences, only Sequences of Sequence - uno::Type aType = pArray->getValueType(); + uno::Type aType = rArray.getValueType(); if ( aType.equals( cppu::UnoType>::get() ) ) { uno::Sequence< uno::Sequence< sal_Int16 > > aTmp(1); - (*pArray) >>= aTmp[ 0 ]; - (*pArray) <<= aTmp; + rArray >>= aTmp[ 0 ]; + rArray <<= aTmp; } else if ( aType.equals( cppu::UnoType>::get() ) ) { uno::Sequence< uno::Sequence< sal_Int32 > > aTmp(1); - (*pArray) >>= aTmp[ 0 ]; - (*pArray) <<= aTmp; + rArray >>= aTmp[ 0 ]; + rArray <<= aTmp; } else if ( aType.equals( cppu::UnoType>::get() ) ) { uno::Sequence< uno::Sequence< double > > aTmp(1); - (*pArray) >>= aTmp[ 0 ]; - (*pArray) <<= aTmp; + rArray >>= aTmp[ 0 ]; + rArray <<= aTmp; } else if ( aType.equals( cppu::UnoType>::get() ) ) { uno::Sequence< uno::Sequence< OUString > > aTmp(1); - (*pArray) >>= aTmp[ 0 ]; - (*pArray) <<= aTmp; + rArray >>= aTmp[ 0 ]; + rArray <<= aTmp; } else if ( aType.equals( cppu::UnoType>::get() ) ) { uno::Sequence< uno::Sequence > aTmp(1); - (*pArray) >>= aTmp[ 0 ]; - (*pArray) <<= aTmp; + rArray >>= aTmp[ 0 ]; + rArray <<= aTmp; } } break; -- cgit