From 337a9a454c1bc95214111578d3f9c0622c55c509 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 18 May 2020 09:17:04 +0200 Subject: use for-range on Sequence in chart2 Change-Id: Ief02e5d5284b0cbad26b04c0a282dccfee577b90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94398 Tested-by: Jenkins Reviewed-by: Noel Grandin --- chart2/qa/extras/chart2export.cxx | 12 +++++----- chart2/qa/extras/charttest.hxx | 50 +++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'chart2/qa') diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index f960edf8b1a0..84a38b258733 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -775,15 +775,15 @@ void Chart2ExportTest::testEmbeddingsGrabBag() const char* const testEmbeddedFileNames[] {"word/embeddings/Microsoft_Excel_Worksheet3.xlsx", "word/embeddings/Microsoft_Excel_Worksheet2.xlsx", "word/embeddings/Microsoft_Excel_Worksheet1.xlsx"}; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXEmbeddings") + if (prop.Name == "OOXEmbeddings") { bEmbeddings = true; uno::Sequence aEmbeddingsList(0); uno::Reference aEmbeddingXlsxStream; OUString aEmbeddedfileName; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aEmbeddingsList); // PropertyValue of proper type sal_Int32 length = aEmbeddingsList.getLength(); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length); for(int j = 0; j < length; ++j) @@ -1513,15 +1513,15 @@ void Chart2ExportTest::testEmbeddingsOleObjectGrabBag() CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty bool bEmbeddings = false; const char* const testEmbeddedFileNames[] = {"word/embeddings/oleObject1.bin"}; - for(int i = 0; i < aGrabBag.getLength(); ++i) + for(beans::PropertyValue const & prop : std::as_const(aGrabBag)) { - if (aGrabBag[i].Name == "OOXEmbeddings") + if (prop.Name == "OOXEmbeddings") { bEmbeddings = true; uno::Sequence aEmbeddingsList(0); uno::Reference aEmbeddingXlsxStream; OUString aEmbeddedfileName; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type + CPPUNIT_ASSERT(prop.Value >>= aEmbeddingsList); // PropertyValue of proper type sal_Int32 length = aEmbeddingsList.getLength(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); for(int j = 0; j < length; ++j) diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index ad2802773cf0..9b8e98a48f96 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -329,11 +329,11 @@ Reference< chart2::data::XDataSequence > getLabelDataSequenceFromDoc( getDataSeriesFromDoc( xChartDoc, nDataSeries, nChartType ); CPPUNIT_ASSERT(xDataSeries.is()); Reference< chart2::data::XDataSource > xDataSource( xDataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = + const Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = xDataSource->getDataSequences(); - for(sal_Int32 i = 0; i < xDataSequences.getLength(); ++i) + for(auto const & lds : xDataSequences) { - Reference< chart2::data::XDataSequence> xLabelSeq = xDataSequences[i]->getLabel(); + Reference< chart2::data::XDataSequence> xLabelSeq = lds->getLabel(); if(!xLabelSeq.is()) continue; @@ -351,11 +351,11 @@ Reference< chart2::data::XDataSequence > getDataSequenceFromDocByRole( getDataSeriesFromDoc( xChartDoc, nDataSeries, nChartType ); CPPUNIT_ASSERT(xDataSeries.is()); Reference< chart2::data::XDataSource > xDataSource( xDataSeries, uno::UNO_QUERY_THROW ); - Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = + const Sequence< Reference< chart2::data::XLabeledDataSequence > > xDataSequences = xDataSource->getDataSequences(); - for(sal_Int32 i = 0; i < xDataSequences.getLength(); ++i) + for(auto const & lds : xDataSequences) { - Reference< chart2::data::XDataSequence> xLabelSeq = xDataSequences[i]->getValues(); + Reference< chart2::data::XDataSequence> xLabelSeq = lds->getValues(); uno::Reference< beans::XPropertySet > xProps(xLabelSeq, uno::UNO_QUERY); if(!xProps.is()) continue; @@ -389,20 +389,20 @@ std::vector > getDataSeriesYValuesFromChartType( const Refer { Reference xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); - Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); + const Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); double fNan; rtl::math::setNan(&fNan); std::vector > aRet; - for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + for (uno::Reference const & ds : aDataSeriesSeq) { - uno::Reference xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + uno::Reference xDSrc(ds, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSrc.is()); - uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); - for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + const uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); + for (auto const & lds : aDataSeqs) { - Reference xValues = aDataSeqs[j]->getValues(); + Reference xValues = lds->getValues(); CPPUNIT_ASSERT(xValues.is()); Reference xPropSet(xValues, uno::UNO_QUERY); if (!xPropSet.is()) @@ -412,13 +412,13 @@ std::vector > getDataSeriesYValuesFromChartType( const Refer xPropSet->getPropertyValue("Role") >>= aRoleName; if (aRoleName == "values-y") { - uno::Sequence aData = xValues->getData(); + const uno::Sequence aData = xValues->getData(); std::vector aValues; aValues.reserve(aData.getLength()); - for (sal_Int32 nVal = 0; nVal < aData.getLength(); ++nVal) + for (uno::Any const & any : aData) { double fVal; - if (aData[nVal] >>= fVal) + if (any >>= fVal) aValues.push_back(fVal); else aValues.push_back(fNan); @@ -437,17 +437,17 @@ std::vector > getDataSeriesLabelsFromChartType( const Re Reference xDSCont(xCT, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSCont.is()); - Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); + const Sequence > aDataSeriesSeq = xDSCont->getDataSeries(); std::vector > aRet; - for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i) + for (auto const & ds : aDataSeriesSeq) { - uno::Reference xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY); + uno::Reference xDSrc(ds, uno::UNO_QUERY); CPPUNIT_ASSERT(xDSrc.is()); - uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); - for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j) + const uno::Sequence > aDataSeqs = xDSrc->getDataSequences(); + for (auto const & lds : aDataSeqs) { - Reference xValues = aDataSeqs[j]->getValues(); + Reference xValues = lds->getValues(); CPPUNIT_ASSERT(xValues.is()); Reference xPropSet(xValues, uno::UNO_QUERY); if (!xPropSet.is()) @@ -457,7 +457,7 @@ std::vector > getDataSeriesLabelsFromChartType( const Re xPropSet->getPropertyValue("Role") >>= aRoleName; if (aRoleName == aLabelRole) { - Reference xLabel = aDataSeqs[j]; + Reference xLabel = lds; CPPUNIT_ASSERT(xLabel.is()); Reference xDS2 = xLabel->getLabel(); CPPUNIT_ASSERT(xDS2.is()); @@ -544,10 +544,10 @@ OUString getTitleString( const Reference& xTitled ) { uno::Reference xTitle = xTitled->getTitleObject(); CPPUNIT_ASSERT(xTitle.is()); - uno::Sequence > aFSSeq = xTitle->getText(); + const uno::Sequence > aFSSeq = xTitle->getText(); OUString aText; - for (sal_Int32 i = 0; i < aFSSeq.getLength(); ++i) - aText += aFSSeq[i]->getString(); + for (auto const & fs : aFSSeq) + aText += fs->getString(); return aText; } -- cgit