summaryrefslogtreecommitdiff
path: root/chart2/qa
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-05-18 09:17:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-05-18 11:28:50 +0200
commit337a9a454c1bc95214111578d3f9c0622c55c509 (patch)
tree4eda99edf46e45ce804fcde98197cf0d96b7ac3d /chart2/qa
parent6089755d197528d071906846c58a397add0876a5 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/qa')
-rw-r--r--chart2/qa/extras/chart2export.cxx12
-rw-r--r--chart2/qa/extras/charttest.hxx50
2 files changed, 31 insertions, 31 deletions
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<beans::PropertyValue> aEmbeddingsList(0);
uno::Reference<io::XInputStream> 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<beans::PropertyValue> aEmbeddingsList(0);
uno::Reference<io::XInputStream> 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<std::vector<double> > getDataSeriesYValuesFromChartType( const Refer
{
Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDSCont.is());
- Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+ const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
double fNan;
rtl::math::setNan(&fNan);
std::vector<std::vector<double> > aRet;
- for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+ for (uno::Reference<chart2::XDataSeries> const & ds : aDataSeriesSeq)
{
- uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+ uno::Reference<chart2::data::XDataSource> xDSrc(ds, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDSrc.is());
- uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
- for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+ const uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+ for (auto const & lds : aDataSeqs)
{
- Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+ Reference<chart2::data::XDataSequence> xValues = lds->getValues();
CPPUNIT_ASSERT(xValues.is());
Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
if (!xPropSet.is())
@@ -412,13 +412,13 @@ std::vector<std::vector<double> > getDataSeriesYValuesFromChartType( const Refer
xPropSet->getPropertyValue("Role") >>= aRoleName;
if (aRoleName == "values-y")
{
- uno::Sequence<uno::Any> aData = xValues->getData();
+ const uno::Sequence<uno::Any> aData = xValues->getData();
std::vector<double> 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<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Re
Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDSCont.is());
- Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
+ const Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
std::vector<uno::Sequence<uno::Any> > aRet;
- for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)
+ for (auto const & ds : aDataSeriesSeq)
{
- uno::Reference<chart2::data::XDataSource> xDSrc(aDataSeriesSeq[i], uno::UNO_QUERY);
+ uno::Reference<chart2::data::XDataSource> xDSrc(ds, uno::UNO_QUERY);
CPPUNIT_ASSERT(xDSrc.is());
- uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
- for (sal_Int32 j = 0; j < aDataSeqs.getLength(); ++j)
+ const uno::Sequence<Reference<chart2::data::XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+ for (auto const & lds : aDataSeqs)
{
- Reference<chart2::data::XDataSequence> xValues = aDataSeqs[j]->getValues();
+ Reference<chart2::data::XDataSequence> xValues = lds->getValues();
CPPUNIT_ASSERT(xValues.is());
Reference<beans::XPropertySet> xPropSet(xValues, uno::UNO_QUERY);
if (!xPropSet.is())
@@ -457,7 +457,7 @@ std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Re
xPropSet->getPropertyValue("Role") >>= aRoleName;
if (aRoleName == aLabelRole)
{
- Reference<chart2::data::XLabeledDataSequence> xLabel = aDataSeqs[j];
+ Reference<chart2::data::XLabeledDataSequence> xLabel = lds;
CPPUNIT_ASSERT(xLabel.is());
Reference<chart2::data::XDataSequence> xDS2 = xLabel->getLabel();
CPPUNIT_ASSERT(xDS2.is());
@@ -544,10 +544,10 @@ OUString getTitleString( const Reference<chart2::XTitled>& xTitled )
{
uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject();
CPPUNIT_ASSERT(xTitle.is());
- uno::Sequence<uno::Reference<chart2::XFormattedString> > aFSSeq = xTitle->getText();
+ const uno::Sequence<uno::Reference<chart2::XFormattedString> > 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;
}