summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-08-15 12:34:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-08-15 20:22:06 +0200
commit16d7e22d78cdeac149ee874f803292b3e2634e0a (patch)
tree8e7d06758af8a478833d840d7e144ef6c7322e74
parentaea932b58bbb2346fb5c1bc02bcfed3e43dedabc (diff)
loplugin:sequenceloop in sc
Change-Id: I84e0b4784ddc66864b29e3b1f20c926aa17fc77f Reviewed-on: https://gerrit.libreoffice.org/77523 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/source/core/data/dpobject.cxx7
-rw-r--r--sc/source/core/tool/addincol.cxx2
-rw-r--r--sc/source/core/tool/appoptio.cxx2
-rw-r--r--sc/source/filter/excel/xepivotxml.cxx6
-rw-r--r--sc/source/filter/oox/formulabase.cxx4
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx4
-rw-r--r--sc/source/filter/xml/XMLCodeNameProvider.cxx2
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx4
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx2
-rw-r--r--sc/source/ui/miscdlgs/optsolver.cxx2
-rw-r--r--sc/source/ui/unoobj/PivotTableDataProvider.cxx9
-rw-r--r--sc/source/ui/unoobj/appluno.cxx2
-rw-r--r--sc/source/ui/unoobj/cellvaluebinding.cxx2
-rw-r--r--sc/source/ui/unoobj/chartuno.cxx2
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx2
-rw-r--r--sc/source/ui/unoobj/eventuno.cxx2
-rw-r--r--sc/source/ui/unoobj/shapeuno.cxx2
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx2
-rw-r--r--sc/source/ui/view/dbfunc3.cxx2
-rw-r--r--sc/source/ui/view/tabvwshb.cxx2
20 files changed, 32 insertions, 30 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 4c7d02baa957..9cfc72391e46 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -262,10 +262,11 @@ static sheet::DataPilotFieldOrientation lcl_GetDataGetOrientation( const uno::Re
sheet::DataPilotFieldOrientation nRet = sheet::DataPilotFieldOrientation_HIDDEN;
if ( xSource.is() )
{
- uno::Reference<container::XNameAccess> xDimNames = xSource->getDimensions();
- for (const OUString& rDimName: xDimNames->getElementNames())
+ uno::Reference<container::XNameAccess> xDimNameAccess = xSource->getDimensions();
+ const uno::Sequence<OUString> aDimNames = xDimNameAccess->getElementNames();
+ for (const OUString& rDimName : aDimNames)
{
- uno::Reference<beans::XPropertySet> xDimProp(xDimNames->getByName(rDimName),
+ uno::Reference<beans::XPropertySet> xDimProp(xDimNameAccess->getByName(rDimName),
uno::UNO_QUERY);
if ( xDimProp.is() )
{
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 9dbe56cb70fb..ceeb156a0a31 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -439,7 +439,7 @@ void ScUnoAddInCollection::ReadConfiguration()
uno::Sequence<beans::PropertyValue> aLocalEntries;
if ( aCompProperties[0] >>= aLocalEntries )
{
- for ( const beans::PropertyValue& rConfig : aLocalEntries )
+ for ( const beans::PropertyValue& rConfig : std::as_const(aLocalEntries) )
{
// PropertyValue name is the locale ("convert" from
// string to canonicalize)
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index d181a450b795..530a8d9438cb 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -176,7 +176,7 @@ static void lcl_SetSortList( const Any& rValue )
{
aList.clear();
- for (const auto& rStr : aSeq)
+ for (const auto& rStr : std::as_const(aSeq))
{
ScUserListData* pNew = new ScUserListData( rStr );
aList.push_back(pNew);
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index eaee25d916c5..36db55476da8 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -715,16 +715,16 @@ void WriteGrabBagItemToStream(XclExpXmlStream& rStrm, sal_Int32 tokenId, const c
css::uno::Sequence<css::xml::FastAttribute> aFastSeq;
css::uno::Sequence<css::xml::Attribute> aUnkSeq;
- for (const auto& a : aSeqs)
+ for (const auto& a : std::as_const(aSeqs))
{
if (a >>= aFastSeq)
{
- for (const auto& rAttr : aFastSeq)
+ for (const auto& rAttr : std::as_const(aFastSeq))
rStrm.WriteAttributes(rAttr.Token, rAttr.Value);
}
else if (a >>= aUnkSeq)
{
- for (const auto& rAttr : aUnkSeq)
+ for (const auto& rAttr : std::as_const(aUnkSeq))
pStrm->write(" ")
->write(rAttr.Name)
->write("=\"")
diff --git a/sc/source/filter/oox/formulabase.cxx b/sc/source/filter/oox/formulabase.cxx
index f20cfb82a679..2e49ffd94447 100644
--- a/sc/source/filter/oox/formulabase.cxx
+++ b/sc/source/filter/oox/formulabase.cxx
@@ -1238,7 +1238,7 @@ bool OpCodeProviderImpl::fillTokenMap( ApiTokenMap& orTokenMap, OpCodeEntrySeque
orTokenMap.clear();
if( fillEntrySeq( orEntrySeq, rxMapper, nMapGroup ) )
{
- for( const FormulaOpCodeMapEntry& rEntry : orEntrySeq )
+ for( const FormulaOpCodeMapEntry& rEntry : std::as_const(orEntrySeq) )
orTokenMap[ rEntry.Name ] = rEntry.Token;
}
return orEntrySeq.hasElements();
@@ -1250,7 +1250,7 @@ bool OpCodeProviderImpl::fillFuncTokenMaps( ApiTokenMap& orIntFuncTokenMap, ApiT
orExtFuncTokenMap.clear();
if( fillEntrySeq( orEntrySeq, rxMapper, css::sheet::FormulaMapGroup::FUNCTIONS ) )
{
- for( const FormulaOpCodeMapEntry& rEntry : orEntrySeq )
+ for( const FormulaOpCodeMapEntry& rEntry : std::as_const(orEntrySeq) )
((rEntry.Token.OpCode == OPCODE_EXTERNAL) ? orExtFuncTokenMap : orIntFuncTokenMap)[ rEntry.Name ] = rEntry.Token;
}
return orEntrySeq.hasElements();
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 00936636335d..5fb3dca410a1 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -733,7 +733,7 @@ void WorkbookHelper::finalizeWorkbookImport()
{
OUString sTabName;
Reference< XNameAccess > xSheetsNC;
- for (const auto& rProp : aSeq)
+ for (const auto& rProp : std::as_const(aSeq))
{
OUString sName(rProp.Name);
if (sName == SC_ACTIVETABLE)
@@ -756,7 +756,7 @@ void WorkbookHelper::finalizeWorkbookImport()
Any aAny = xSheetsNC->getByName(sTabName);
if ( aAny >>= aProperties )
{
- for (const auto& rProp : aProperties)
+ for (const auto& rProp : std::as_const(aProperties))
{
OUString sName(rProp.Name);
if (sName == SC_POSITIONLEFT)
diff --git a/sc/source/filter/xml/XMLCodeNameProvider.cxx b/sc/source/filter/xml/XMLCodeNameProvider.cxx
index 4f71732450f1..85d95e415b03 100644
--- a/sc/source/filter/xml/XMLCodeNameProvider.cxx
+++ b/sc/source/filter/xml/XMLCodeNameProvider.cxx
@@ -30,7 +30,7 @@ bool XMLCodeNameProvider::_getCodeName( const uno::Any& aAny, OUString& rCodeNam
if( !(aAny >>= aProps) )
return false;
- for( const auto& rProp : aProps )
+ for( const auto& rProp : std::as_const(aProps) )
{
if( rProp.Name == "CodeName" )
{
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index eeaca6737b22..da3bfc0f13d8 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2104,7 +2104,7 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& x
else
nIndex = pCellStyles->GetIndexOfStyleName(sName, XML_STYLE_FAMILY_TABLE_CELL_STYLES_PREFIX, bIsAutoStyle);
- uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
+ const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
bool bGetMerge(true);
for (table::CellRangeAddress const & address : aAddresses)
{
@@ -2123,7 +2123,7 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& x
pCellStyles->AddStyleName(sEncodedStyleName, nIndex, false);
if ( !pOldName )
{
- uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
+ const uno::Sequence<table::CellRangeAddress> aAddresses(xCellRanges->getRangeAddresses());
bool bGetMerge(true);
for (table::CellRangeAddress const & address : aAddresses)
{
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 5d083893f4a0..96c348d34f35 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1717,7 +1717,7 @@ void SAL_CALL ScXMLImport::endDocument()
uno::Sequence< beans::PropertyValue > aSeq;
if (xIndexAccess->getByIndex(0) >>= aSeq)
{
- for (const auto& rProp : aSeq)
+ for (const auto& rProp : std::as_const(aSeq))
{
OUString sName(rProp.Name);
if (sName == SC_ACTIVETABLE)
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index 09ad93d1a666..12c26f40fc22 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -966,7 +966,7 @@ bool ScOptSolverDlg::CallSolver() // return true -> close dialog after cal
uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
if ( xOptProp.is() )
{
- for (const beans::PropertyValue& rValue : maProperties)
+ for (const beans::PropertyValue& rValue : std::as_const(maProperties))
{
try
{
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index b3d05f7e907b..633f1b1786b3 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -107,7 +107,8 @@ std::vector<OUString> lcl_getVisiblePageMembers(const uno::Reference<uno::XInter
if (!xMembersAccess.is())
return aResult;
- for (OUString const & rMemberNames : xMembersAccess->getElementNames())
+ const css::uno::Sequence<OUString> aMembersNames = xMembersAccess->getElementNames();
+ for (OUString const & rMemberNames : aMembersNames)
{
uno::Reference<beans::XPropertySet> xProperties(xMembersAccess->getByName(rMemberNames), uno::UNO_QUERY);
if (!xProperties.is())
@@ -284,7 +285,7 @@ void PivotTableDataProvider::collectPivotTableData()
m_aFieldOutputDescriptionMap.clear();
uno::Reference<sheet::XDataPilotResults> xDPResults(pDPObject->GetSource(), uno::UNO_QUERY);
- uno::Sequence<uno::Sequence<sheet::DataResult>> xDataResultsSequence = xDPResults->getResults();
+ const uno::Sequence<uno::Sequence<sheet::DataResult>> xDataResultsSequence = xDPResults->getResults();
double fNan;
rtl::math::setNan(&fNan);
@@ -385,7 +386,7 @@ void PivotTableDataProvider::collectPivotTableData()
{
m_aColumnFields.emplace_back(xLevelName->getName(), nDim, nDimPos, bHasHiddenMember);
- uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
+ const uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
size_t i = 0;
OUString sCaption;
OUString sName;
@@ -429,7 +430,7 @@ void PivotTableDataProvider::collectPivotTableData()
{
m_aRowFields.emplace_back(xLevelName->getName(), nDim, nDimPos, bHasHiddenMember);
- uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
+ const uno::Sequence<sheet::MemberResult> aSequence = xLevelResult->getResults();
size_t i = 0;
size_t nEachIndex = 0;
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index e256ec67ba26..a2c9c2c9e227 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -349,7 +349,7 @@ void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
// ScGlobal::SetUseTabCol does not do much else
pUserList->clear();
- for (const OUString& aEntry : aSeq)
+ for (const OUString& aEntry : std::as_const(aSeq))
{
ScUserListData* pData = new ScUserListData(aEntry);
pUserList->push_back(pData);
diff --git a/sc/source/ui/unoobj/cellvaluebinding.cxx b/sc/source/ui/unoobj/cellvaluebinding.cxx
index 63012c3b9aef..de7f0fde4f71 100644
--- a/sc/source/ui/unoobj/cellvaluebinding.cxx
+++ b/sc/source/ui/unoobj/cellvaluebinding.cxx
@@ -164,7 +164,7 @@ namespace calc
checkInitialized( );
// look up in our sequence
- Sequence< Type > aSupportedTypes( getSupportedValueTypes() );
+ const Sequence< Type > aSupportedTypes( getSupportedValueTypes() );
for ( auto const & i : aSupportedTypes )
if ( aType == i )
return true;
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index 01bff2042eb8..f158fd0c7686 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -522,7 +522,7 @@ void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno:
if ( rValue >>= aCellRanges )
{
ScRangeListRef rRangeList = new ScRangeList();
- for ( table::CellRangeAddress const & aCellRange : aCellRanges )
+ for ( table::CellRangeAddress const & aCellRange : std::as_const(aCellRanges) )
{
ScRange aRange;
ScUnoConversion::FillScRange( aRange, aCellRange );
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 3a3f51600f06..26809c5190ae 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -836,7 +836,7 @@ void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aProp
aServiceDesc = *pOldDesc;
OUString aStrVal;
- for (const beans::PropertyValue& rProp : aArgSeq)
+ for (const beans::PropertyValue& rProp : std::as_const(aArgSeq))
{
OUString aPropName(rProp.Name);
diff --git a/sc/source/ui/unoobj/eventuno.cxx b/sc/source/ui/unoobj/eventuno.cxx
index 6e4eccb52d84..3aab2004dd66 100644
--- a/sc/source/ui/unoobj/eventuno.cxx
+++ b/sc/source/ui/unoobj/eventuno.cxx
@@ -85,7 +85,7 @@ void SAL_CALL ScSheetEventsObj::replaceByName( const OUString& aName, const uno:
uno::Sequence<beans::PropertyValue> aPropSeq;
if ( aElement >>= aPropSeq )
{
- for (const beans::PropertyValue& rProp : aPropSeq)
+ for (const beans::PropertyValue& rProp : std::as_const(aPropSeq))
{
if ( rProp.Name == SC_UNO_EVENTTYPE )
{
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
index 85ab26b65d98..946d1ce6bcd9 100644
--- a/sc/source/ui/unoobj/shapeuno.cxx
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -1342,7 +1342,7 @@ public:
uno::Sequence< beans::PropertyValue > aProperties;
aElement >>= aProperties;
bool isEventType = false;
- for( const beans::PropertyValue& rProperty : aProperties )
+ for( const beans::PropertyValue& rProperty : std::as_const(aProperties) )
{
if ( rProperty.Name == SC_EVENTACC_EVENTTYPE )
{
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
index f5ee2e265897..376de73ecc0b 100644
--- a/sc/source/ui/vba/vbaworksheets.cxx
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -427,7 +427,7 @@ ScVbaWorksheets::Item(const uno::Any& Index, const uno::Any& Index2)
SheetMap aSheets;
uno::Sequence< uno::Any > sIndices;
aConverted >>= sIndices;
- for( const auto& rIndex : sIndices )
+ for( const auto& rIndex : std::as_const(sIndices) )
{
uno::Reference< excel::XWorksheet > xWorkSheet( ScVbaWorksheets_BASE::Item( rIndex, Index2 ), uno::UNO_QUERY_THROW );
ScVbaWorksheet* pWorkSheet = excel::getImplFromDocModuleWrapper<ScVbaWorksheet>( xWorkSheet );
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index e2add0b814b0..751313c201eb 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1805,7 +1805,7 @@ bool ScDBFunc::DataPilotMove( const ScRange& rSource, const ScAddress& rDest )
bool bInserted = false;
- for (const OUString& aMemberStr : aMemberNames)
+ for (const OUString& aMemberStr : std::as_const(aMemberNames))
{
if ( !bInserted && aMemberStr == aDestData.MemberName )
{
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 14e011e9d331..76c330dadc50 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -114,7 +114,7 @@ public:
sal_Int32 dimensionIndex = 0;
OUString sPivotTableName("DataPilot1");
- for (beans::PropertyValue const & rProperty : aProperties)
+ for (beans::PropertyValue const & rProperty : std::as_const(aProperties))
{
if (rProperty.Name == "Rectangle")
rProperty.Value >>= xRectangle;