chart2/qa/extras/PivotChartTest.cxx | 5 chart2/qa/extras/chart2_trendcalculators.cxx | 36 +++-- chart2/qa/extras/charttest.hxx | 3 chart2/source/controller/accessibility/AccessibleChartElement.cxx | 7 - chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx | 16 +- chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 5 chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 4 chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx | 9 - chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx | 9 - chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx | 11 - chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx | 15 +- chart2/source/controller/dialogs/DialogModel.cxx | 4 chart2/source/controller/dialogs/RangeSelectionHelper.cxx | 30 ++-- chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 3 chart2/source/controller/dialogs/tp_DataSource.cxx | 2 chart2/source/controller/dialogs/tp_RangeChooser.cxx | 4 chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx | 4 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx | 2 chart2/source/controller/main/ChartController.cxx | 11 - chart2/source/controller/main/ChartController_Window.cxx | 9 - chart2/source/controller/main/CommandDispatchContainer.cxx | 3 chart2/source/controller/main/ConfigurationAccess.cxx | 6 chart2/source/inc/CommonConverters.hxx | 3 chart2/source/model/filter/XMLFilter.cxx | 61 +++----- chart2/source/model/main/Axis.cxx | 3 chart2/source/model/main/ChartModel.cxx | 3 chart2/source/model/main/ChartModel_Persistence.cxx | 26 +-- chart2/source/model/template/BubbleDataInterpreter.cxx | 16 -- chart2/source/model/template/ChartTypeTemplate.cxx | 15 -- chart2/source/model/template/ColumnChartType.cxx | 6 chart2/source/model/template/ColumnLineDataInterpreter.cxx | 5 chart2/source/model/template/DataInterpreter.cxx | 7 - chart2/source/model/template/StockDataInterpreter.cxx | 47 +++--- chart2/source/model/template/XYDataInterpreter.cxx | 11 - chart2/source/tools/CommonConverters.cxx | 70 ++++++---- chart2/source/tools/DataSourceHelper.cxx | 15 -- chart2/source/tools/DiagramHelper.cxx | 18 +- chart2/source/tools/ErrorBar.cxx | 3 chart2/source/tools/ExplicitCategoriesProvider.cxx | 9 - chart2/source/tools/ExponentialRegressionCurveCalculator.cxx | 7 - chart2/source/tools/InternalData.cxx | 10 - chart2/source/tools/InternalDataProvider.cxx | 43 +++--- chart2/source/tools/LinearRegressionCurveCalculator.cxx | 7 - chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx | 7 - chart2/source/tools/MeanValueRegressionCurveCalculator.cxx | 7 - chart2/source/tools/MediaDescriptorHelper.cxx | 10 - chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx | 9 - chart2/source/tools/NameContainer.cxx | 13 - chart2/source/tools/PotentialRegressionCurveCalculator.cxx | 7 - chart2/source/tools/RangeHighlighter.cxx | 18 +- chart2/source/tools/RegressionCurveCalculator.cxx | 5 chart2/source/tools/RegressionCurveHelper.cxx | 3 chart2/source/tools/StatisticsHelper.cxx | 3 chart2/source/tools/TitleHelper.cxx | 6 chart2/source/tools/UncachedDataSequence.cxx | 2 chart2/source/tools/WrappedPropertySet.cxx | 9 - chart2/source/view/axes/Tickmarks.cxx | 17 +- chart2/source/view/axes/Tickmarks_Equidistant.cxx | 18 +- chart2/source/view/axes/VCartesianGrid.cxx | 41 ++--- chart2/source/view/axes/VCoordinateSystem.cxx | 8 - chart2/source/view/axes/VPolarCoordinateSystem.cxx | 9 - chart2/source/view/axes/VPolarGrid.cxx | 17 +- chart2/source/view/charttypes/AreaChart.cxx | 16 +- chart2/source/view/charttypes/BarChart.cxx | 6 chart2/source/view/charttypes/PieChart.cxx | 14 -- chart2/source/view/charttypes/Splines.cxx | 32 ++-- chart2/source/view/charttypes/VSeriesPlotter.cxx | 62 ++++---- chart2/source/view/main/ChartView.cxx | 63 +++------ chart2/source/view/main/Linear3DTransformation.cxx | 13 + chart2/source/view/main/PlottingPositionHelper.cxx | 17 +- chart2/source/view/main/PropertyMapper.cxx | 14 +- chart2/source/view/main/ShapeFactory.cxx | 60 ++++---- chart2/source/view/main/VDataSeries.cxx | 12 + 73 files changed, 555 insertions(+), 546 deletions(-)
New commits: commit 5b0ae3b59cd2cccfb72d991657366eb2a69bff49 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Oct 28 16:14:54 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Oct 29 11:07:27 2021 +0200 Prepare for removal of non-const operator[] from Sequence in chart2 Change-Id: I71e0b458c4dd2a85e36a485e3efa72b1077b0e54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124346 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/chart2/qa/extras/PivotChartTest.cxx b/chart2/qa/extras/PivotChartTest.cxx index 97dd41634332..ee024531e88b 100644 --- a/chart2/qa/extras/PivotChartTest.cxx +++ b/chart2/qa/extras/PivotChartTest.cxx @@ -844,13 +844,12 @@ void PivotChartTest::testPivotChartRowFieldInOutlineMode() } sheet::DataPilotFieldLayoutInfo aLayoutInfoValue; - uno::Sequence<sheet::GeneralFunction> aGeneralFunctionSequence(1); // Test case where we enable subtotals (auto) and set the outline subtotals at the bottom // We don't expect any change in data as every extra subtotal row should be ignored // Enable subtotals - set to auto - aGeneralFunctionSequence[0] = sheet::GeneralFunction_AUTO; + uno::Sequence<sheet::GeneralFunction> aGeneralFunctionSequence{ sheet::GeneralFunction_AUTO }; lclModifySubtotals(xDataPilotDescriptor, u"Country", aGeneralFunctionSequence); // Set Subtotals layout to bottom + add empty lines aLayoutInfoValue.AddEmptyLines = true; @@ -879,7 +878,7 @@ void PivotChartTest::testPivotChartRowFieldInOutlineMode() // We don't expect any change in data as every extra subtotal row should be ignored // Enable subtotals - set to auto - aGeneralFunctionSequence[0] = sheet::GeneralFunction_AUTO; + aGeneralFunctionSequence.getArray()[0] = sheet::GeneralFunction_AUTO; lclModifySubtotals(xDataPilotDescriptor, u"Country", aGeneralFunctionSequence); // Set Subtotals layout to top + add empty lines aLayoutInfoValue.AddEmptyLines = true; diff --git a/chart2/qa/extras/chart2_trendcalculators.cxx b/chart2/qa/extras/chart2_trendcalculators.cxx index 1eeea5d12e23..c13c1666725e 100644 --- a/chart2/qa/extras/chart2_trendcalculators.cxx +++ b/chart2/qa/extras/chart2_trendcalculators.cxx @@ -112,12 +112,14 @@ void Chart2TrendCalculators::testPotentialRegression1() loadCalculatorFromSheet( SHEET_POTENTIAL1 ); m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = 2.0 * pow ( d, 3 ); + pxValues[i] = d; + pyValues[i] = 2.0 * pow ( d, 3 ); } checkCalculator( xValues, yValues, "f(x) = 2 x^3"); } @@ -128,12 +130,14 @@ void Chart2TrendCalculators::testPotentialRegression2() loadCalculatorFromSheet( SHEET_POTENTIAL2 ); m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = -2.0 * pow ( d, 3 ); + pxValues[i] = d; + pyValues[i] = -2.0 * pow ( d, 3 ); } checkCalculator( xValues, yValues, "f(x) = "+ OUStringChar(aMinusSign) +" 2 x^3"); } @@ -144,12 +148,14 @@ void Chart2TrendCalculators::testLinearRegression1() loadCalculatorFromSheet( SHEET_LINEAR1 ); m_xRegressionCurveCalculator->setRegressionProperties( 1, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = - 2.0 * d - 5.0 ; + pxValues[i] = d; + pyValues[i] = - 2.0 * d - 5.0 ; } checkCalculator( xValues, yValues, "f(x) = "+ OUStringChar(aMinusSign) +" 2 x "+ OUStringChar(aMinusSign) +" 5"); } @@ -160,12 +166,14 @@ void Chart2TrendCalculators::testPolynomialRegression1() loadCalculatorFromSheet( SHEET_POLYNOMIAL1 ); m_xRegressionCurveCalculator->setRegressionProperties( 2, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = - 2.0 * d * d + 4 * d - 5; + pxValues[i] = d; + pyValues[i] = - 2.0 * d * d + 4 * d - 5; } OUString sExpectedFormula( "f(x) = "+ OUStringChar(aMinusSign) +" 2 x" + OUStringChar( aSuperscriptFigures[2] ) + " + 4 x "+ OUStringChar(aMinusSign) +" 5" ); checkCalculator( xValues, yValues, sExpectedFormula ); @@ -176,12 +184,14 @@ void Chart2TrendCalculators::testExponentialRegression1() loadCalculatorFromSheet( SHEET_EXPONENTIAL1 ); m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = 2.0 * exp ( 0.3 * d ); + pxValues[i] = d; + pyValues[i] = 2.0 * exp ( 0.3 * d ); } checkCalculator( xValues, yValues, "f(x) = 2 exp( 0.3 x )"); } @@ -191,12 +201,14 @@ void Chart2TrendCalculators::testExponentialRegression2() loadCalculatorFromSheet( SHEET_EXPONENTIAL2 ); m_xRegressionCurveCalculator->setRegressionProperties( 0, false, 0, 0, 0 ); Sequence< double > xValues( 7 ); + auto pxValues = xValues.getArray(); Sequence< double > yValues( 7 ); + auto pyValues = yValues.getArray(); for (int i=0; i<7; i++) { const double d = static_cast<double>(i); - xValues[i] = d; - yValues[i] = -2.0 * exp ( 0.3 * d ); + pxValues[i] = d; + pyValues[i] = -2.0 * exp ( 0.3 * d ); } checkCalculator( xValues, yValues, "f(x) = "+ OUStringChar(aMinusSign) + " 2 exp( 0.3 x )"); } diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 2aec79cfccb0..02ad9675d930 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -666,9 +666,10 @@ Sequence< OUString > ChartTest::getFormattedDateCategories( const Reference<char Sequence<double> aDateSeq = getDateCategories(xChartDoc); const sal_Int32 nNumCategories = aDateSeq.getLength(); Sequence<OUString> aFormattedDates(nNumCategories); + auto aFormattedDatesRange = asNonConstRange(aFormattedDates); for (sal_Int32 nIdx = 0; nIdx < nNumCategories; ++nIdx) - aFormattedDates[nIdx] = xNumFormatter->convertNumberToString(nNumFmt, aDateSeq[nIdx]); + aFormattedDatesRange[nIdx] = xNumFormatter->convertNumberToString(nNumFmt, aDateSeq[nIdx]); return aFormattedDates; } diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx index cbee2ddbb01a..efbb1f47924e 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -101,10 +101,9 @@ void AccessibleChartElement::InitTextEdit() try { Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); - Sequence< uno::Any > aArgs( 3 ); - aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); - aArgs[1] <<= Reference< XAccessible >( this ); - aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); + Sequence< uno::Any > aArgs{ uno::Any(GetInfo().m_aOID.getObjectCID()), + uno::Any(Reference< XAccessible >( this )), + uno::Any(Reference< awt::XWindow >( GetInfo().m_xWindow )) }; xInit->initialize( aArgs ); } catch( const uno::Exception & ) diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 76df74719682..0880cfba525f 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -49,14 +49,16 @@ uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Se uno::Sequence< uno::Sequence< double > > aRet; const sal_Int32 nOuterSize = rData.getLength(); aRet.realloc( nOuterSize ); + auto pRet = aRet.getArray(); for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) { sal_Int32 nInnerSize = rData[nOuter].getLength(); - aRet[nOuter].realloc( nInnerSize ); + pRet[nOuter].realloc( nInnerSize ); + auto pRet_nOuter = pRet[nOuter].getArray(); for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) { - aRet[nOuter][nInner] = rData[nOuter][nInner]; - double& rValue = aRet[nOuter][nInner]; + pRet_nOuter[nInner] = rData[nOuter][nInner]; + double& rValue = pRet_nOuter[nInner]; if( rValue == DBL_MIN ) rValue = std::numeric_limits<double>::quiet_NaN(); } @@ -69,14 +71,16 @@ uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN( const uno::Se uno::Sequence< uno::Sequence< double > > aRet; const sal_Int32 nOuterSize = rData.getLength(); aRet.realloc( nOuterSize ); + auto pRet = aRet.getArray(); for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) { sal_Int32 nInnerSize = rData[nOuter].getLength(); - aRet[nOuter].realloc( nInnerSize ); + pRet[nOuter].realloc( nInnerSize ); + auto pRet_nOuter = pRet[nOuter].getArray(); for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) { - aRet[nOuter][nInner] = rData[nOuter][nInner]; - double& rValue = aRet[nOuter][nInner]; + pRet_nOuter[nInner] = rData[nOuter][nInner]; + double& rValue = pRet_nOuter[nInner]; if( std::isnan( rValue ) ) rValue = DBL_MIN; } diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index aef26f4a483a..39ec746f3415 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -1252,9 +1252,8 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { m_xChartView = xViewInit; - Sequence< Any > aArguments(2); - aArguments[0] <<= Reference<frame::XModel>(this); - aArguments[1] <<= true; // bRefreshAddIn + Sequence< Any > aArguments{ Any(Reference<frame::XModel>(this)), + Any(true) }; // bRefreshAddIn xViewInit->initialize(aArguments); } catch (const uno::Exception&) diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index a55733ffffd8..f46abaae3027 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -1643,7 +1643,7 @@ Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< bean ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); - + auto aResultRange = asNonConstRange(aResult); sal_Int32 i = 0; for (auto const& series : aSeriesVector) { @@ -1654,7 +1654,7 @@ Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< bean xProp->getPropertyValue("AttributedDataPoints")); uno::Sequence< sal_Int32 > aSeq; if( aVal >>= aSeq ) - aResult[ i ] = aSeq; + aResultRange[ i ] = aSeq; } ++i; } diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index a0f39774b5f1..379cc408f52e 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -269,10 +269,11 @@ uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyValues( const u if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyValue( aPropertyName ); + pRetSeq[nN] = getPropertyValue( aPropertyName ); } } return aRetSeq; @@ -315,10 +316,11 @@ uno::Sequence< beans::PropertyState > SAL_CALL MinMaxLineWrapper::getPropertySta if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyState( aPropertyName ); + pRetSeq[nN] = getPropertyState( aPropertyName ); } } return aRetSeq; @@ -360,10 +362,11 @@ uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyDefault( aPropertyName ); + pRetSeq[nN] = getPropertyDefault( aPropertyName ); } } return aRetSeq; diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index ab7e5b333a2c..33c53f89a514 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -244,10 +244,11 @@ uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyValues( const un if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyValue( aPropertyName ); + pRetSeq[nN] = getPropertyValue( aPropertyName ); } } return aRetSeq; @@ -282,10 +283,11 @@ uno::Sequence< beans::PropertyState > SAL_CALL UpDownBarWrapper::getPropertyStat if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyState( aPropertyName ); + pRetSeq[nN] = getPropertyState( aPropertyName ); } } return aRetSeq; @@ -327,10 +329,11 @@ uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyDefault( aPropertyName ); + pRetSeq[nN] = getPropertyDefault( aPropertyName ); } } return aRetSeq; diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index b49c5177dc2e..867176e62e32 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -85,14 +85,13 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, tools::Long nOldLength = aBarPositionSequence.getLength(); if( nOldLength <= m_nAxisIndex ) - { aBarPositionSequence.realloc( m_nAxisIndex+1 ); - for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) - { - aBarPositionSequence[i] = m_nDefaultValue; - } + auto pBarPositionSequence = aBarPositionSequence.getArray(); + for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) + { + pBarPositionSequence[i] = m_nDefaultValue; } - aBarPositionSequence[m_nAxisIndex] = nNewValue; + pBarPositionSequence[m_nAxisIndex] = nNewValue; xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index d9ad4a3e6bb4..27e07256e51d 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -173,6 +173,7 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); double fStepHelp = 0; if( rOuterValue >>= fStepHelp ) @@ -181,14 +182,14 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons if( AxisHelper::isLogarithmic(aScaleData.Scaling) ) { sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp); - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; } else if( (fStepHelp != 0.0) && (aScaleData.IncrementData.Distance >>= fStepMain) ) { // approximate interval count sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);//cppcheck-suppress zerodiv - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; } } bSetScaleData = true; @@ -199,11 +200,12 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); sal_Int32 nIntervalCount=0; if( rOuterValue>>=nIntervalCount ) - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; else - rSubIncrements[ 0 ].IntervalCount = Any(); + pSubIncrements[ 0 ].IntervalCount = Any(); bSetScaleData = true; break; } @@ -239,11 +241,12 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); if( (rOuterValue >>= bBool) && bBool ) - rSubIncrements[ 0 ].IntervalCount = Any(); + pSubIncrements[ 0 ].IntervalCount = Any(); else - rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); + pSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); bSetScaleData = true; break; } diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index 774e395e8951..ce6da753d6c4 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -265,16 +265,18 @@ Sequence< OUString > lcl_CopyExcludingValuesFirst( Sequence< OUString > const & i_aInput ) { Sequence< OUString > aOutput( i_aInput.getLength()); + auto pOutput = aOutput.getArray(); int nSourceIndex, nDestIndex; for( nSourceIndex = nDestIndex = 0; nSourceIndex < i_aInput.getLength(); nSourceIndex++ ) { if( i_aInput[nSourceIndex] == "values-first" ) { aOutput.realloc( aOutput.getLength() - 1 ); + pOutput = aOutput.getArray(); } else { - aOutput[nDestIndex] = i_aInput[nSourceIndex]; + pOutput[nDestIndex] = i_aInput[nSourceIndex]; nDestIndex++; } } diff --git a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx index 8cd8f64c8383..3a468845dc3f 100644 --- a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx +++ b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx @@ -109,21 +109,21 @@ bool RangeSelectionHelper::chooseRange( Reference< sheet::XRangeSelection > xRangeSel( getRangeSelection()); if( xRangeSel.is()) { - Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - "InitialValue", -1, uno::Any( aCurrentRange ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - "Title", -1, - uno::Any( aUIString ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - "CloseOnMouseRelease", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - "MultiSelectionMode", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); - + Sequence< beans::PropertyValue > aArgs{ + beans::PropertyValue( + "InitialValue", -1, uno::Any( aCurrentRange ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "Title", -1, + uno::Any( aUIString ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "CloseOnMouseRelease", -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "MultiSelectionMode", -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ) + }; if( m_xRangeSelectionListener.is() ) stopRangeListening(); m_xRangeSelectionListener.set( Reference< sheet::XRangeSelectionListener >( diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 2897313ceff1..94d0e9034619 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -251,8 +251,9 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel // initialize with 1, 2, ... //first category (index 0) matches with real number 1.0 aXValues.realloc( aYValues.getLength() ); + auto pXValues = aXValues.getArray(); for( i=0; i<aXValues.getLength(); ++i ) - aXValues[i] = i+1; + pXValues[i] = i+1; bXValuesFound = true; } diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index 2694d9ca28a6..bcd48c2590df 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -132,7 +132,7 @@ void lcl_addLSequenceToDataSource( { Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences()); aData.realloc( aData.getLength() + 1 ); - aData[ aData.getLength() - 1 ] = xLSequence; + aData.getArray()[ aData.getLength() - 1 ] = xLSequence; xSink->setData( aData ); } } diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 6ef5d45ddd40..bfb214c71593 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -215,7 +215,7 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() if(bTimeBased) { aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = + aArguments.getArray()[aArguments.getLength() - 1] = beans::PropertyValue( "TimeBased", -1, uno::Any(bTimeBased), beans::PropertyState_DIRECT_VALUE ); } @@ -226,7 +226,7 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate ); aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = + aArguments.getArray()[aArguments.getLength() - 1] = beans::PropertyValue( "CellRangeRepresentation" , -1, uno::Any( m_aLastValidRangeString ), beans::PropertyState_DIRECT_VALUE ); diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 28d5cf4cabc7..6a1bb0867803 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -616,7 +616,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet if( aScale.IncrementData.SubIncrements.hasElements() && aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) { - aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount.clear(); bSetScale = true; } if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) @@ -661,7 +661,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) { OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); - aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount = aValue; bSetScale = true; } } diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index e48ba0b3f443..c531e7e2c76e 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -223,7 +223,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf pos = rBarPosition; } else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) - aBarPositionSequence[nAxisIndex] = rBarPosition; + aBarPositionSequence.getArray()[nAxisIndex] = rBarPosition; xChartTypeProps->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); bChanged = true; diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 3bd6a5946ddf..19c314da2635 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1577,10 +1577,6 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn if(!xInit.is()) return; - uno::Sequence< uno::Any > aArguments(5); - aArguments[0] <<= uno::Reference<view::XSelectionSupplier>(this); - aArguments[1] <<= getModel(); - aArguments[2] <<= m_xChartView; uno::Reference< XAccessible > xParent; { SolarMutexGuard aGuard; @@ -1592,8 +1588,11 @@ void ChartController::impl_initializeAccessible( const uno::Reference< lang::XIn xParent.set( pParentWin->GetAccessible()); } } - aArguments[3] <<= xParent; - aArguments[4] <<= m_xViewWindow; + uno::Sequence< uno::Any > aArguments{ uno::Any(uno::Reference<view::XSelectionSupplier>(this)), + uno::Any(getModel()), + uno::Any(m_xChartView), + uno::Any(xParent), + uno::Any(m_xViewWindow) }; xInit->initialize(aArguments); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 1d58ddc70b40..92a7f9f16851 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1271,10 +1271,11 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) } } - css::uno::Sequence< css::uno::Any > aArgs( 3 ); - aArgs[0] <<= comphelper::makePropertyValue( "IsContextMenu", true ); - aArgs[1] <<= comphelper::makePropertyValue( "Frame", m_xFrame ); - aArgs[2] <<= comphelper::makePropertyValue( "Value", aMenuName ); + css::uno::Sequence< css::uno::Any > aArgs{ + css::uno::Any(comphelper::makePropertyValue( "IsContextMenu", true )), + css::uno::Any(comphelper::makePropertyValue( "Frame", m_xFrame )), + css::uno::Any(comphelper::makePropertyValue( "Value", aMenuName )) + }; css::uno::Reference< css::frame::XPopupMenuController > xPopupController( m_xCC->getServiceManager()->createInstanceWithArgumentsAndContext( diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index daea97d4c7bf..69528aa67fa1 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -144,11 +144,12 @@ Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatche { sal_Int32 nCount = aDescriptors.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > aRet( nCount ); + auto aRetRange = asNonConstRange(aRet); for( sal_Int32 nPos = 0; nPos < nCount; ++nPos ) { if ( aDescriptors[ nPos ].FrameName == "_self" ) - aRet[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); + aRetRange[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); } return aRet; } diff --git a/chart2/source/controller/main/ConfigurationAccess.cxx b/chart2/source/controller/main/ConfigurationAccess.cxx index 4040c8db1b8d..54a94adfa083 100644 --- a/chart2/source/controller/main/ConfigurationAccess.cxx +++ b/chart2/source/controller/main/ConfigurationAccess.cxx @@ -64,11 +64,11 @@ FieldUnit CalcConfigItem::getFieldUnit() { FieldUnit eResult( FieldUnit::CM ); - uno::Sequence< OUString > aNames( 1 ); + uno::Sequence< OUString > aNames; if( lcl_IsMetric() ) - aNames[ 0 ] = "Other/MeasureUnit/Metric"; + aNames = { "Other/MeasureUnit/Metric" }; else - aNames[ 0 ] = "Other/MeasureUnit/NonMetric"; + aNames = { "Other/MeasureUnit/NonMetric" }; uno::Sequence< uno::Any > aResult( GetProperties( aNames )); sal_Int32 nValue = 0; diff --git a/chart2/source/inc/CommonConverters.hxx b/chart2/source/inc/CommonConverters.hxx index 7341f5c2b834..e8daa87d5c95 100644 --- a/chart2/source/inc/CommonConverters.hxx +++ b/chart2/source/inc/CommonConverters.hxx @@ -184,12 +184,13 @@ css::uno::Sequence< T > for( nOuter=0; nOuter<nOuterSize; ++nOuter ) nResultSize += aSeqSeq[nOuter].getLength(); css::uno::Sequence< T > aResult( nResultSize ); + auto aResultRange = asNonConstRange(aResult); for( nOuter=0; nOuter<nOuterSize; ++nOuter ) { const sal_Int32 nInnerSize = aSeqSeq[nOuter].getLength(); for( nInner=0; nInner<nInnerSize; ++nInner, ++nCount ) - aResult[nCount] = aSeqSeq[nOuter][nInner]; + aResultRange[nCount] = aSeqSeq[nOuter][nInner]; } return aResult; } diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index 5838647bc510..6cc27d10f127 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -96,13 +96,12 @@ uno::Reference< embed::XStorage > lcl_getWriteStorage( xStorage.set( aMDHelper.Storage ); else { - Sequence< uno::Any > aStorageArgs( 3 ); - if( aMDHelper.ISSET_OutputStream ) - aStorageArgs[0] <<= aMDHelper.OutputStream; - else - aStorageArgs[0] <<= aMDHelper.URL; - aStorageArgs[1] <<= (embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE); - aStorageArgs[2] <<= comphelper::containerToSequence( aPropertiesForStorage ); + Sequence< uno::Any > aStorageArgs{ + aMDHelper.ISSET_OutputStream ? uno::Any(aMDHelper.OutputStream) + : uno::Any(aMDHelper.URL), + uno::Any(embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE), + uno::Any(comphelper::containerToSequence( aPropertiesForStorage )) + }; xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), @@ -163,10 +162,11 @@ uno::Reference< embed::XStorage > lcl_getReadStorage( // convert XInputStream to XStorage via the storage factory Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) ); - Sequence< uno::Any > aStorageArgs( 3 ); - aStorageArgs[0] <<= xStream; - aStorageArgs[1] <<= (embed::ElementModes::READ | embed::ElementModes::NOCREATE); - aStorageArgs[2] <<= comphelper::containerToSequence( aPropertiesForStorage ); + Sequence< uno::Any > aStorageArgs{ + uno::Any(xStream), + uno::Any(embed::ElementModes::READ | embed::ElementModes::NOCREATE), + uno::Any(comphelper::containerToSequence( aPropertiesForStorage )) + }; xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW ); } @@ -301,8 +301,7 @@ ErrCode XMLFilter::impl_Import( uno::Reference<lang::XMultiServiceFactory> xServiceFactory(xFactory, uno::UNO_QUERY); if (xServiceFactory.is()) { - uno::Sequence<uno::Any> aArgs(1); - aArgs[0] <<= xStorage; + uno::Sequence<uno::Any> aArgs{ uno::Any(xStorage) }; xGraphicStorageHandler.set( xServiceFactory->createInstanceWithArguments( "com.sun.star.comp.Svx.GraphicImportHelper", aArgs), uno::UNO_QUERY); @@ -430,12 +429,13 @@ ErrCode XMLFilter::impl_ImportStream( nArgs++; uno::Sequence< uno::Any > aFilterCompArgs( nArgs ); + auto aFilterCompArgsRange = asNonConstRange(aFilterCompArgs); nArgs = 0; if( xGraphicStorageHandler.is()) - aFilterCompArgs[nArgs++] <<= xGraphicStorageHandler; + aFilterCompArgsRange[nArgs++] <<= xGraphicStorageHandler; if( xImportInfo.is()) - aFilterCompArgs[ nArgs++ ] <<= xImportInfo; + aFilterCompArgsRange[ nArgs++ ] <<= xImportInfo; // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler Reference< XInterface > xFilter = @@ -449,14 +449,10 @@ ErrCode XMLFilter::impl_ImportStream( { try { - uno::Sequence< uno::Any > aArgs(2); - beans::NamedValue aValue; - aValue.Name = "DocumentHandler"; - aValue.Value <<= xFilter; - aArgs[0] <<= aValue; - aValue.Name = "Model"; - aValue.Value <<= m_xTargetDoc; - aArgs[1] <<= aValue; + uno::Sequence< uno::Any > aArgs{ + uno::Any(beans::NamedValue("DocumentHandler", uno::Any(xFilter))), + uno::Any(beans::NamedValue("Model", uno::Any(m_xTargetDoc))) + }; xFilter = xFactory->createInstanceWithArgumentsAndContext(m_sDocumentHandler,aArgs,m_xContext); } @@ -556,14 +552,10 @@ ErrCode XMLFilter::impl_Export( { try { - uno::Sequence< uno::Any > aArgs(2); - beans::NamedValue aValue; - aValue.Name = "DocumentHandler"; - aValue.Value <<= xDocHandler; - aArgs[0] <<= aValue; - aValue.Name = "Model"; - aValue.Value <<= xDocumentComp; - aArgs[1] <<= aValue; + uno::Sequence< uno::Any > aArgs{ + uno::Any(beans::NamedValue("DocumentHandler", uno::Any(xDocHandler))), + uno::Any(beans::NamedValue("Model", uno::Any(xDocumentComp))) + }; xDocHandler.set(xServiceFactory->createInstanceWithArguments(m_sDocumentHandler,aArgs), uno::UNO_QUERY ); xSaxWriter.set(xDocHandler,uno::UNO_QUERY); @@ -602,11 +594,12 @@ ErrCode XMLFilter::impl_Export( uno::Sequence< uno::Any > aFilterProperties( nArgs ); { + auto pFilterProperties = aFilterProperties.getArray(); nArgs = 0; - aFilterProperties[ nArgs++ ] <<= xInfoSet; - aFilterProperties[ nArgs++ ] <<= xDocHandler; + pFilterProperties[ nArgs++ ] <<= xInfoSet; + pFilterProperties[ nArgs++ ] <<= xDocHandler; if( xGraphicStorageHandler.is()) - aFilterProperties[ nArgs++ ] <<= xGraphicStorageHandler; + pFilterProperties[ nArgs++ ] <<= xGraphicStorageHandler; } // export meta information diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 332ed7a5e5f7..bfdccbd54e2f 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -416,11 +416,12 @@ void Axis::AllocateSubGrids() else if( nOldSubIncCount < nNewSubIncCount ) { m_aSubGridProperties.realloc( nNewSubIncCount ); + auto pSubGridProperties = m_aSubGridProperties.getArray(); // allocate new entries for( sal_Int32 i = nOldSubIncCount; i < nNewSubIncCount; ++i ) { - m_aSubGridProperties[ i ] = new GridProperties(); + pSubGridProperties[ i ] = new GridProperties(); LinePropertiesHelper::SetLineInvisible( m_aSubGridProperties[ i ] ); LinePropertiesHelper::SetLineColor( m_aSubGridProperties[ i ], static_cast<sal_Int32>(0xdddddd) ); //gray2 aNewBroadcasters.push_back( m_aSubGridProperties[ i ] ); diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index c5bf2167184d..e5e518b63818 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -695,9 +695,8 @@ Reference< chart2::data::XDataSource > ChartModel::impl_createDefaultData() { //init internal dataprovider { - uno::Sequence< uno::Any > aArgs(1); beans::NamedValue aParam( "CreateDefaultData" ,uno::Any(true) ); - aArgs[0] <<= aParam; + uno::Sequence< uno::Any > aArgs{ uno::Any(aParam) }; xIni->initialize(aArgs); } //create data diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index efb4d0b44c31..b246aa18f2b1 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -104,7 +104,7 @@ void lcl_addStorageToMediaDescriptor( const Reference< embed::XStorage > & xStorage ) { rOutMD.realloc( rOutMD.getLength() + 1 ); - rOutMD[rOutMD.getLength() - 1] = beans::PropertyValue( + rOutMD.getArray()[rOutMD.getLength() - 1] = beans::PropertyValue( "Storage", -1, uno::Any( xStorage ), beans::PropertyState_DIRECT_VALUE ); } @@ -125,10 +125,9 @@ Reference< embed::XStorage > lcl_createStorage( uno::UNO_QUERY ); Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) ); - Sequence< uno::Any > aStorageArgs( 3 ); - aStorageArgs[0] <<= xStream; - aStorageArgs[1] <<= embed::ElementModes::READWRITE; - aStorageArgs[2] <<= rMediaDescriptor; + Sequence< uno::Any > aStorageArgs{ uno::Any(xStream), + uno::Any(embed::ElementModes::READWRITE), + uno::Any(rMediaDescriptor) }; xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW ); } @@ -396,9 +395,8 @@ void ChartModel::insertDefaultChart() bool bSupportsCategories = xTemplate->supportsCategories(); if( bSupportsCategories ) { - aParam.realloc( 1 ); - aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); + aParam = { beans::PropertyValue( "HasCategories", -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ) }; } Reference< chart2::XDiagram > xDiagram( xTemplate->createDiagramByDataSource( xDataSource, aParam ) ); @@ -510,10 +508,9 @@ void SAL_CALL ChartModel::load( if( aMDHelper.ISSET_Stream ) { // convert XStream to XStorage via the storage factory - Sequence< uno::Any > aStorageArgs( 2 ); - aStorageArgs[0] <<= aMDHelper.Stream; - // todo: check if stream is read-only - aStorageArgs[1] <<= embed::ElementModes::READ; //WRITE | embed::ElementModes::NOCREATE); + Sequence< uno::Any > aStorageArgs{ uno::Any(aMDHelper.Stream), + // todo: check if stream is read-only + uno::Any(embed::ElementModes::READ) }; //WRITE | embed::ElementModes::NOCREATE); xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW ); @@ -522,9 +519,8 @@ void SAL_CALL ChartModel::load( { OSL_ASSERT( aMDHelper.ISSET_InputStream ); // convert XInputStream to XStorage via the storage factory - Sequence< uno::Any > aStorageArgs( 2 ); - aStorageArgs[0] <<= aMDHelper.InputStream; - aStorageArgs[1] <<= embed::ElementModes::READ; + Sequence< uno::Any > aStorageArgs{ uno::Any(aMDHelper.InputStream), + uno::Any(embed::ElementModes::READ) }; xStorage.set( xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW ); diff --git a/chart2/source/model/template/BubbleDataInterpreter.cxx b/chart2/source/model/template/BubbleDataInterpreter.cxx index 83868db778e5..09fd1c25d7da 100644 --- a/chart2/source/model/template/BubbleDataInterpreter.cxx +++ b/chart2/source/model/template/BubbleDataInterpreter.cxx @@ -148,9 +148,7 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::interpretDataSource( aSeriesVec.push_back( xSeries ); } - Sequence< Sequence< Reference< XDataSeries > > > aSeries(1); - aSeries[0] = comphelper::containerToSequence( aSeriesVec ); - return InterpretedData( aSeries, xCategories ); + return InterpretedData( { comphelper::containerToSequence(aSeriesVec) }, xCategories ); } chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries( @@ -221,22 +219,16 @@ chart2::InterpretedData SAL_CALL BubbleDataInterpreter::reinterpretDataSeries( { if( xValuesX.is() ) { - aNewSequences.realloc(3); - aNewSequences[0] = xValuesX; - aNewSequences[1] = xValuesY; - aNewSequences[2] = xValuesSize; + aNewSequences = { xValuesX, xValuesY, xValuesSize }; } else { - aNewSequences.realloc(2); - aNewSequences[0] = xValuesY; - aNewSequences[1] = xValuesSize; + aNewSequences = { xValuesY, xValuesSize }; } } else { - aNewSequences.realloc(1); - aNewSequences[0] = xValuesSize; + aNewSequences = { xValuesSize }; } } diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 8aafc1fd1d8b..1f1b09cff89f 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -209,9 +209,8 @@ void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram > Sequence< beans::PropertyValue > aParam; if( aData.Categories.is()) { - aParam.realloc( 1 ); - aParam[0] = beans::PropertyValue( "HasCategories", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); + aParam = { beans::PropertyValue( "HasCategories", -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ) }; } aData = xInterpreter->interpretDataSource( xSource, aParam, aFlatSeriesSeq ); } @@ -581,8 +580,7 @@ void ChartTypeTemplate::createCoordinateSystems( } // set new coordinate systems - aCoordinateSystems.realloc( 1 ); - aCoordinateSystems[0] = xCooSys; + aCoordinateSystems = { xCooSys }; xOutCooSysCnt->setCoordinateSystems( aCoordinateSystems ); } @@ -796,10 +794,7 @@ void ChartTypeTemplate::createChartTypes( // we need a new chart type xCT.set( getChartTypeForNewSeries( aOldChartTypesSeq )); Reference< XChartTypeContainer > xCTCnt( rCoordSys[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes()); - aCTSeq.realloc( 1 ); - aCTSeq[0] = xCT; - xCTCnt->setChartTypes( aCTSeq ); + xCTCnt->setChartTypes({ xCT }); } else { @@ -813,7 +808,7 @@ void ChartTypeTemplate::createChartTypes( Sequence< Reference< XChartType > > aCTSeq( xCTCnt->getChartTypes()); if( aCTSeq.hasElements()) { - aCTSeq[0] = xCT; + aCTSeq.getArray()[0] = xCT; xCTCnt->setChartTypes( aCTSeq ); } else diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 487cf8977099..36eb72b33623 100644 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -65,12 +65,10 @@ struct StaticColumnChartTypeDefaults_Initializer private: static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) { - Sequence< sal_Int32 > aSeq(2); - - aSeq[0] = aSeq[1] = 0; + Sequence< sal_Int32 > aSeq{ 0, 0 }; ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); - aSeq[0] = aSeq[1] = 100; + aSeq = { 100, 100 }; ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); } }; diff --git a/chart2/source/model/template/ColumnLineDataInterpreter.cxx b/chart2/source/model/template/ColumnLineDataInterpreter.cxx index 6069255d3f1d..658bf2fd62d9 100644 --- a/chart2/source/model/template/ColumnLineDataInterpreter.cxx +++ b/chart2/source/model/template/ColumnLineDataInterpreter.cxx @@ -60,9 +60,10 @@ InterpretedData SAL_CALL ColumnLineDataInterpreter::interpretDataSource( { sal_Int32 nNumOfLines = std::min( m_nNumberOfLines, nNumberOfSeries - 1 ); aResult.Series.realloc(2); + auto pSeries = aResult.Series.getArray(); - Sequence< Reference< XDataSeries > > & rColumnDataSeries = aResult.Series[0]; - Sequence< Reference< XDataSeries > > & rLineDataSeries = aResult.Series[1]; + Sequence< Reference< XDataSeries > > & rColumnDataSeries = pSeries[0]; + Sequence< Reference< XDataSeries > > & rLineDataSeries = pSeries[1]; rLineDataSeries.realloc( nNumOfLines ); std::copy( std::cbegin(rColumnDataSeries) + nNumberOfSeries - nNumOfLines, std::cbegin(rColumnDataSeries) + nNumberOfSeries, diff --git a/chart2/source/model/template/DataInterpreter.cxx b/chart2/source/model/template/DataInterpreter.cxx index 67e5a0b856e4..524ce73d0d2d 100644 --- a/chart2/source/model/template/DataInterpreter.cxx +++ b/chart2/source/model/template/DataInterpreter.cxx @@ -123,9 +123,7 @@ InterpretedData SAL_CALL DataInterpreter::interpretDataSource( ++nSeriesIndex; } - Sequence< Sequence< Reference< XDataSeries > > > aSeries(1); - aSeries[0] = comphelper::containerToSequence( aSeriesVec ); - return InterpretedData( aSeries, xCategories ); + return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, xCategories ); } InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries( @@ -156,8 +154,7 @@ InterpretedData SAL_CALL DataInterpreter::reinterpretDataSeries( } if( xValuesY.is()) { - aNewSequences.realloc(1); - aNewSequences[0] = xValuesY; + aNewSequences = { xValuesY }; } Sequence< Reference< data::XLabeledDataSequence > > aSeqs( xSeriesSource->getDataSequences()); diff --git a/chart2/source/model/template/StockDataInterpreter.cxx b/chart2/source/model/template/StockDataInterpreter.cxx index 95018fad52ac..7647f475f1f8 100644 --- a/chart2/source/model/template/StockDataInterpreter.cxx +++ b/chart2/source/model/template/StockDataInterpreter.cxx @@ -88,13 +88,15 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( sal_Int32 nNumberOfGroups( bHasVolume ? 2 : 1 ); // sequences of data::XLabeledDataSequence per series per group Sequence< Sequence< Sequence< Reference< data::XLabeledDataSequence > > > > aSequences( nNumberOfGroups ); - sal_Int32 nBarGroupIndex( 0 ); - sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 ); + auto pSequences = aSequences.getArray(); + const sal_Int32 nBarGroupIndex( 0 ); + const sal_Int32 nCandleStickGroupIndex( nNumberOfGroups - 1 ); // allocate space for labeled sequences if( nRemaining > 0 ) ++nCandleStickSeries; - aSequences[nCandleStickGroupIndex].realloc( nCandleStickSeries ); + pSequences[nCandleStickGroupIndex].realloc( nCandleStickSeries ); + auto pCandleStickGroup = pSequences[nCandleStickGroupIndex].getArray(); if( bHasVolume ) { // if there are remaining sequences, the first one is taken for @@ -102,8 +104,9 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( // is used if( nRemaining > 1 ) ++nVolumeSeries; - aSequences[nBarGroupIndex].realloc( nVolumeSeries ); + pSequences[nBarGroupIndex].realloc( nVolumeSeries ); } + auto pBarGroup = pSequences[nBarGroupIndex].getArray(); // create data sal_Int32 nSourceIndex = 0; // index into aData sequence @@ -121,8 +124,8 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( // bar if( bHasVolume ) { - aSequences[nBarGroupIndex][nLabeledSeqIdx].realloc( 1 ); - aSequences[nBarGroupIndex][nLabeledSeqIdx][0].set( aData[nSourceIndex] ); + pBarGroup[nLabeledSeqIdx].realloc( 1 ); + pBarGroup[nLabeledSeqIdx].getArray()[0].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-y"); ++nSourceIndex; @@ -131,29 +134,30 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( sal_Int32 nSeqIdx = 0; if( bHasOpenValues ) { - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 4 ); - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] ); + pCandleStickGroup[nLabeledSeqIdx].realloc( 4 ); + pCandleStickGroup[nLabeledSeqIdx].getArray()[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-first"); ++nSourceIndex; ++nSeqIdx; } else - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx].realloc( 3 ); + pCandleStickGroup[nLabeledSeqIdx].realloc( 3 ); + auto pLabeledSeq = pCandleStickGroup[nLabeledSeqIdx].getArray(); - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-min"); ++nSourceIndex; ++nSeqIdx; - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-max"); ++nSourceIndex; ++nSeqIdx; - aSequences[nCandleStickGroupIndex][nLabeledSeqIdx][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-last"); ++nSourceIndex; @@ -164,11 +168,11 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( if( bHasVolume && nRemaining > 1 ) { OSL_ASSERT( nVolumeSeries > nNumOfFullSeries ); - aSequences[nBarGroupIndex][nVolumeSeries - 1].realloc( 1 ); + pBarGroup[nVolumeSeries - 1].realloc( 1 ); OSL_ASSERT( nDataCount > nSourceIndex ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-y"); - aSequences[nBarGroupIndex][nVolumeSeries - 1][0].set( aData[nSourceIndex] ); + pBarGroup[nVolumeSeries - 1].getArray()[0].set( aData[nSourceIndex] ); ++nSourceIndex; --nRemaining; OSL_ENSURE( nRemaining, "additional bar should only be used if there is at least one more sequence for a candle stick" ); @@ -179,12 +183,13 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( { OSL_ASSERT( nCandleStickSeries > nNumOfFullSeries ); const sal_Int32 nSeriesIndex = nCandleStickSeries - 1; - aSequences[nCandleStickGroupIndex][nSeriesIndex].realloc( nRemaining ); + pCandleStickGroup[nSeriesIndex].realloc( nRemaining ); + auto pLabeledSeq = pCandleStickGroup[nSeriesIndex].getArray(); OSL_ASSERT( nDataCount > nSourceIndex ); // 1. low sal_Int32 nSeqIdx( 0 ); - aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-min"); ++nSourceIndex; @@ -193,7 +198,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( // 2. high if( nSeqIdx < nRemaining ) { - aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-max"); ++nSourceIndex; @@ -204,7 +209,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( OSL_ENSURE( bHasOpenValues || nSeqIdx >= nRemaining, "could have created full series" ); if( nSeqIdx < nRemaining ) { - aSequences[nCandleStickGroupIndex][nSeriesIndex][nSeqIdx].set( aData[nSourceIndex] ); + pLabeledSeq[nSeqIdx].set( aData[nSourceIndex] ); if( aData[nSourceIndex].is()) SetRole( aData[nSourceIndex]->getValues(), "values-last"); ++nSourceIndex; @@ -217,11 +222,13 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( // create DataSeries Sequence< Sequence< Reference< XDataSeries > > > aResultSeries( nNumberOfGroups ); + auto pResultSeries = aResultSeries.getArray(); sal_Int32 nGroupIndex, nReUsedSeriesIdx = 0; for( nGroupIndex=0; nGroupIndex<nNumberOfGroups; ++nGroupIndex ) { const sal_Int32 nNumSeriesData = aSequences[nGroupIndex].getLength(); - aResultSeries[nGroupIndex].realloc( nNumSeriesData ); + pResultSeries[nGroupIndex].realloc( nNumSeriesData ); + auto pResultSerie = pResultSeries[nGroupIndex].getArray(); for( sal_Int32 nSeriesIdx = 0; nSeriesIdx < nNumSeriesData; ++nSeriesIdx, ++nReUsedSeriesIdx ) { try @@ -234,7 +241,7 @@ InterpretedData SAL_CALL StockDataInterpreter::interpretDataSource( OSL_ASSERT( xSeries.is() ); Reference< data::XDataSink > xSink( xSeries, uno::UNO_QUERY_THROW ); xSink->setData( aSequences[nGroupIndex][nSeriesIdx] ); - aResultSeries[nGroupIndex][nSeriesIdx].set( xSeries ); + pResultSerie[nSeriesIdx].set( xSeries ); } catch( const uno::Exception & ) { diff --git a/chart2/source/model/template/XYDataInterpreter.cxx b/chart2/source/model/template/XYDataInterpreter.cxx index 17e9f57cfc92..1f0480a28c39 100644 --- a/chart2/source/model/template/XYDataInterpreter.cxx +++ b/chart2/source/model/template/XYDataInterpreter.cxx @@ -132,9 +132,7 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::interpretDataSource( ++nSeriesIndex; } - Sequence< Sequence< Reference< XDataSeries > > > aSeries(1); - aSeries[0] = comphelper::containerToSequence( aSeriesVec ); - return InterpretedData( aSeries, xCategories ); + return InterpretedData( { comphelper::containerToSequence( aSeriesVec ) }, xCategories ); } chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries( @@ -190,14 +188,11 @@ chart2::InterpretedData SAL_CALL XYDataInterpreter::reinterpretDataSeries( { if( xValuesX.is()) { - aNewSequences.realloc(2); - aNewSequences[0] = xValuesX; - aNewSequences[1] = xValuesY; + aNewSequences = { xValuesX, xValuesY }; } else { - aNewSequences.realloc(1); - aNewSequences[0] = xValuesY; + aNewSequences = { xValuesY }; } } diff --git a/chart2/source/tools/CommonConverters.cxx b/chart2/source/tools/CommonConverters.cxx index 4993c749f2ca..b4b4cbf62e72 100644 --- a/chart2/source/tools/CommonConverters.cxx +++ b/chart2/source/tools/CommonConverters.cxx @@ -209,8 +209,11 @@ void addPolygon( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonSh sal_Int32 nAddOuterCount = rAdd.SequenceX.getLength(); sal_Int32 nOuterCount = rRet.SequenceX.getLength() + nAddOuterCount; rRet.SequenceX.realloc( nOuterCount ); + auto pSequenceX = rRet.SequenceX.getArray(); rRet.SequenceY.realloc( nOuterCount ); + auto pSequenceY = rRet.SequenceY.getArray(); rRet.SequenceZ.realloc( nOuterCount ); + auto pSequenceZ = rRet.SequenceZ.getArray(); sal_Int32 nIndex = 0; sal_Int32 nOuter = nOuterCount - nAddOuterCount; @@ -219,9 +222,9 @@ void addPolygon( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonSh if( nIndex >= nAddOuterCount ) break; - rRet.SequenceX[nOuter] = rAdd.SequenceX[nIndex]; - rRet.SequenceY[nOuter] = rAdd.SequenceY[nIndex]; - rRet.SequenceZ[nOuter] = rAdd.SequenceZ[nIndex]; + pSequenceX[nOuter] = rAdd.SequenceX[nIndex]; + pSequenceY[nOuter] = rAdd.SequenceY[nIndex]; + pSequenceZ[nOuter] = rAdd.SequenceZ[nIndex]; nIndex++; } @@ -231,8 +234,11 @@ void appendPoly( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonSh { sal_Int32 nOuterCount = std::max( rRet.SequenceX.getLength(), rAdd.SequenceX.getLength() ); rRet.SequenceX.realloc(nOuterCount); + auto pSequenceX = rRet.SequenceX.getArray(); rRet.SequenceY.realloc(nOuterCount); + auto pSequenceY = rRet.SequenceY.getArray(); rRet.SequenceZ.realloc(nOuterCount); + auto pSequenceZ =rRet.SequenceZ.getArray(); for( sal_Int32 nOuter=0;nOuter<nOuterCount;nOuter++ ) { @@ -245,17 +251,20 @@ void appendPoly( drawing::PolyPolygonShape3D& rRet, const drawing::PolyPolygonSh sal_Int32 nNewPointCount = nOldPointCount + nAddPointCount; - rRet.SequenceX[nOuter].realloc(nNewPointCount); - rRet.SequenceY[nOuter].realloc(nNewPointCount); - rRet.SequenceZ[nOuter].realloc(nNewPointCount); + pSequenceX[nOuter].realloc(nNewPointCount); + auto pSequenceX_nOuter = pSequenceX[nOuter].getArray(); + pSequenceY[nOuter].realloc(nNewPointCount); + auto pSequenceY_nOuter = pSequenceY[nOuter].getArray(); + pSequenceZ[nOuter].realloc(nNewPointCount); + auto pSequenceZ_nOuter = pSequenceZ[nOuter].getArray(); sal_Int32 nPointTarget=nOldPointCount; sal_Int32 nPointSource=nAddPointCount; for( ; nPointSource-- ; nPointTarget++ ) { - rRet.SequenceX[nOuter][nPointTarget] = rAdd.SequenceX[nOuter][nPointSource]; - rRet.SequenceY[nOuter][nPointTarget] = rAdd.SequenceY[nOuter][nPointSource]; - rRet.SequenceZ[nOuter][nPointTarget] = rAdd.SequenceZ[nOuter][nPointSource]; + pSequenceX_nOuter[nPointTarget] = rAdd.SequenceX[nOuter][nPointSource]; + pSequenceY_nOuter[nPointTarget] = rAdd.SequenceY[nOuter][nPointSource]; + pSequenceZ_nOuter[nPointTarget] = rAdd.SequenceZ[nOuter][nPointSource]; } } } @@ -267,16 +276,22 @@ drawing::PolyPolygonShape3D BezierToPoly( drawing::PolyPolygonShape3D aRet; aRet.SequenceX.realloc( rPointSequence.getLength() ); + auto pSequenceX = aRet.SequenceX.getArray(); aRet.SequenceY.realloc( rPointSequence.getLength() ); + auto pSequenceY = aRet.SequenceY.getArray(); aRet.SequenceZ.realloc( rPointSequence.getLength() ); + auto pSequenceZ = aRet.SequenceZ.getArray(); sal_Int32 nRealOuter = 0; for(sal_Int32 nN = 0; nN < rPointSequence.getLength(); nN++) { sal_Int32 nInnerLength = rPointSequence[nN].getLength(); - aRet.SequenceX[nN].realloc( nInnerLength ); - aRet.SequenceY[nN].realloc( nInnerLength ); - aRet.SequenceZ[nN].realloc( nInnerLength ); + pSequenceX[nRealOuter].realloc( nInnerLength ); + auto pSequenceX_nRealOuter = pSequenceX[nRealOuter].getArray(); + pSequenceY[nRealOuter].realloc( nInnerLength ); + auto pSequenceY_nRealOuter = pSequenceY[nRealOuter].getArray(); + pSequenceZ[nRealOuter].realloc( nInnerLength ); + auto pSequenceZ_nRealOuter = pSequenceZ[nRealOuter].getArray(); bool bHasOuterFlags = nN < rBezier.Flags.getLength(); @@ -287,16 +302,16 @@ drawing::PolyPolygonShape3D BezierToPoly( if( !bHasInnerFlags || (rBezier.Flags[nN][nM] == drawing::PolygonFlags_NORMAL) ) { - aRet.SequenceX[nRealOuter][nRealInner] = rPointSequence[nN][nM].X; - aRet.SequenceY[nRealOuter][nRealInner] = rPointSequence[nN][nM].Y; - aRet.SequenceZ[nRealOuter][nRealInner] = 0.0; + pSequenceX_nRealOuter[nRealInner] = rPointSequence[nN][nM].X; + pSequenceY_nRealOuter[nRealInner] = rPointSequence[nN][nM].Y; + pSequenceZ_nRealOuter[nRealInner] = 0.0; nRealInner++; } } - aRet.SequenceX[nRealOuter].realloc( nRealInner ); - aRet.SequenceY[nRealOuter].realloc( nRealInner ); - aRet.SequenceZ[nRealOuter].realloc( nRealInner ); + pSequenceX[nRealOuter].realloc( nRealInner ); + pSequenceY[nRealOuter].realloc( nRealInner ); + pSequenceZ[nRealOuter].realloc( nRealInner ); if( nRealInner>0 ) nRealOuter++; @@ -314,15 +329,17 @@ drawing::PointSequenceSequence PolyToPointSequence( { drawing::PointSequenceSequence aRet; aRet.realloc( rPolyPolygon.SequenceX.getLength() ); + auto pRet = aRet.getArray(); for(sal_Int32 nN = 0; nN < rPolyPolygon.SequenceX.getLength(); nN++) { sal_Int32 nInnerLength = rPolyPolygon.SequenceX[nN].getLength(); - aRet[nN].realloc( nInnerLength ); + pRet[nN].realloc( nInnerLength ); + auto pRet_nN = pRet[nN].getArray(); for( sal_Int32 nM = 0; nM < nInnerLength; nM++) { - aRet[nN][nM].X = static_cast<sal_Int32>(rPolyPolygon.SequenceX[nN][nM]); - aRet[nN][nM].Y = static_cast<sal_Int32>(rPolyPolygon.SequenceY[nN][nM]); + pRet_nN[nM].X = static_cast<sal_Int32>(rPolyPolygon.SequenceX[nN][nM]); + pRet_nN[nM].Y = static_cast<sal_Int32>(rPolyPolygon.SequenceY[nN][nM]); } } return aRet; @@ -337,8 +354,9 @@ void appendPointSequence( drawing::PointSequenceSequence& rTarget sal_Int32 nOldCount = rTarget.getLength(); rTarget.realloc(nOldCount+nAddCount); + auto pTarget = rTarget.getArray(); for(sal_Int32 nS=0; nS<nAddCount; nS++ ) - rTarget[nOldCount+nS]=rAdd[nS]; + pTarget[nOldCount+nS]=rAdd[nS]; } drawing::Position3D operator+( const drawing::Position3D& rPos @@ -427,10 +445,11 @@ uno::Sequence< double > DataSequenceToDoubleSequence( { uno::Sequence< uno::Any > aValues = xDataSequence->getData(); aResult.realloc(aValues.getLength()); + auto pResult = aResult.getArray(); for(sal_Int32 nN=aValues.getLength();nN--;) { - if( !(aValues[nN] >>= aResult[nN]) ) - aResult[nN] = std::numeric_limits<double>::quiet_NaN(); + if( !(aValues[nN] >>= pResult[nN]) ) + pResult[nN] = std::numeric_limits<double>::quiet_NaN(); } } @@ -453,9 +472,10 @@ uno::Sequence< OUString > DataSequenceToStringSequence( { uno::Sequence< uno::Any > aValues = xDataSequence->getData(); aResult.realloc(aValues.getLength()); + auto pResult = aResult.getArray(); for(sal_Int32 nN=aValues.getLength();nN--;) - aValues[nN] >>= aResult[nN]; + aValues[nN] >>= pResult[nN]; } return aResult; diff --git a/chart2/source/tools/DataSourceHelper.cxx b/chart2/source/tools/DataSourceHelper.cxx index 679b625948e0..cbb3976e5e90 100644 --- a/chart2/source/tools/DataSourceHelper.cxx +++ b/chart2/source/tools/DataSourceHelper.cxx @@ -170,14 +170,14 @@ uno::Sequence< beans::PropertyValue > DataSourceHelper::createArguments( { uno::Sequence< beans::PropertyValue > aArguments( createArguments( bUseColumns, bFirstCellAsLabel, bHasCategories )); aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = + aArguments.getArray()[aArguments.getLength() - 1] = beans::PropertyValue( "CellRangeRepresentation" , -1, uno::Any( rRangeRepresentation ) , beans::PropertyState_DIRECT_VALUE ); if( rSequenceMapping.hasElements() ) { aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = + aArguments.getArray()[aArguments.getLength() - 1] = beans::PropertyValue( "SequenceMapping" , -1, uno::Any( rSequenceMapping ) , beans::PropertyState_DIRECT_VALUE ); @@ -465,20 +465,17 @@ Sequence< OUString > DataSourceHelper::getRangesFromLabeledDataSequence( { if( xValues.is()) { - aResult.realloc( 2 ); - aResult[0] = xLabel->getSourceRangeRepresentation(); - aResult[1] = xValues->getSourceRangeRepresentation(); + aResult = { xLabel->getSourceRangeRepresentation(), + xValues->getSourceRangeRepresentation() }; } else { - aResult.realloc( 1 ); - aResult[0] = xLabel->getSourceRangeRepresentation(); + aResult = { xLabel->getSourceRangeRepresentation() }; } } else if( xValues.is()) { - aResult.realloc( 1 ); - aResult[0] = xValues->getSourceRangeRepresentation(); + aResult = { xValues->getSourceRangeRepresentation() }; } } return aResult; diff --git a/chart2/source/tools/DiagramHelper.cxx b/chart2/source/tools/DiagramHelper.cxx index 3a1d06bdcf24..0e7760d2711c 100644 --- a/chart2/source/tools/DiagramHelper.cxx +++ b/chart2/source/tools/DiagramHelper.cxx @@ -977,16 +977,17 @@ void lcl_switchToDateCategories( const Reference< XChartDocument >& xChartDoc, c if( xDataAccess.is() ) { Sequence< Sequence< Any > > aAnyCategories( xDataAccess->getAnyRowDescriptions() ); + auto aAnyCategoriesRange = asNonConstRange(aAnyCategories); double fTest = 0.0; sal_Int32 nN = aAnyCategories.getLength(); for( ; nN--; ) { - Sequence< Any >& rCat = aAnyCategories[nN]; + Sequence< Any >& rCat = aAnyCategoriesRange[nN]; if( rCat.getLength() > 1 ) rCat.realloc(1); if( rCat.getLength() == 1 ) { - Any& rAny = rCat[0]; + Any& rAny = rCat.getArray()[0]; if( !(rAny>>=fTest) ) { rAny <<= std::numeric_limits<double>::quiet_NaN(); @@ -1300,6 +1301,7 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed( continue; uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + auto aSeriesListRange = asNonConstRange(aSeriesList); for( sal_Int32 nS = 0; !bFound && nS < aSeriesList.getLength(); ++nS ) { @@ -1326,8 +1328,8 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed( bMovedOrMoveAllowed = true; if( bDoMove ) { - aSeriesList[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ]; - aSeriesList[ nNewSeriesIndex ] = xGivenDataSeries; + aSeriesListRange[ nOldSeriesIndex ] = aSeriesList[ nNewSeriesIndex ]; + aSeriesListRange[ nNewSeriesIndex ] = xGivenDataSeries; xDataSeriesContainer->setDataSeries( aSeriesList ); } } @@ -1347,10 +1349,10 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed( if( nOtherSeriesIndex >= 0 && nOtherSeriesIndex < aOtherSeriesList.getLength() ) { uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[nOtherSeriesIndex] ); - aOtherSeriesList[nOtherSeriesIndex] = xGivenDataSeries; + aOtherSeriesList.getArray()[nOtherSeriesIndex] = xGivenDataSeries; xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); - aSeriesList[nOldSeriesIndex]=xExchangeSeries; + aSeriesListRange[nOldSeriesIndex]=xExchangeSeries; xDataSeriesContainer->setDataSeries(aSeriesList); } } @@ -1373,10 +1375,10 @@ bool lcl_moveSeriesOrCheckIfMoveIsAllowed( if( aOtherSeriesList.hasElements() ) { uno::Reference< XDataSeries > xExchangeSeries( aOtherSeriesList[0] ); - aOtherSeriesList[0] = xGivenDataSeries; + aOtherSeriesList.getArray()[0] = xGivenDataSeries; xOtherDataSeriesContainer->setDataSeries(aOtherSeriesList); - aSeriesList[nOldSeriesIndex]=xExchangeSeries; + aSeriesListRange[nOldSeriesIndex]=xExchangeSeries; xDataSeriesContainer->setDataSeries(aSeriesList); } } diff --git a/chart2/source/tools/ErrorBar.cxx b/chart2/source/tools/ErrorBar.cxx index d894b16a3ff4..2c9b41044396 100644 --- a/chart2/source/tools/ErrorBar.cxx +++ b/chart2/source/tools/ErrorBar.cxx @@ -363,9 +363,10 @@ beans::PropertyState ErrorBar::getPropertyState( const OUString& rPropName ) uno::Sequence< beans::PropertyState > ErrorBar::getPropertyStates( const uno::Sequence< OUString >& rPropNames ) { uno::Sequence< beans::PropertyState > aRet( rPropNames.getLength() ); + auto aRetRange = asNonConstRange(aRet); for(sal_Int32 i = 0; i < rPropNames.getLength(); ++i) { - aRet[i] = getPropertyState(rPropNames[i]); + aRetRange[i] = getPropertyState(rPropNames[i]); } return aRet; } diff --git a/chart2/source/tools/ExplicitCategoriesProvider.cxx b/chart2/source/tools/ExplicitCategoriesProvider.cxx index 59ac20dd4640..2f31b9d38dde 100644 --- a/chart2/source/tools/ExplicitCategoriesProvider.cxx +++ b/chart2/source/tools/ExplicitCategoriesProvider.cxx @@ -118,8 +118,7 @@ ExplicitCategoriesProvider::ExplicitCategoriesProvider( const Reference< chart2: } if( !m_aSplitCategoriesList.hasElements() ) { - m_aSplitCategoriesList.realloc(1); - m_aSplitCategoriesList[0]=m_xOriginalCategories; + m_aSplitCategoriesList = { m_xOriginalCategories }; } } } @@ -171,6 +170,7 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< OUStr if(!nCount) return; rOutTexts.realloc(nCount); + auto pOutTexts = rOutTexts.getArray(); sal_Int32 nAxisNumberFormat = 0; Reference< XCoordinateSystem > xCooSysModel( ChartModelHelper::getFirstCoordinateSystem( rModel ) ); @@ -204,7 +204,7 @@ void ExplicitCategoriesProvider::convertCategoryAnysToText( uno::Sequence< OUStr aAny>>=aText; } } - rOutTexts[nN] = aText; + pOutTexts[nN] = aText; } } @@ -359,6 +359,7 @@ static Sequence< OUString > lcl_getExplicitSimpleCategories( if(nMaxCategoryCount) { aRet.realloc(nMaxCategoryCount); + auto pRet = aRet.getArray(); for(sal_Int32 nN=0; nN<nMaxCategoryCount; nN++) { OUStringBuffer aText; @@ -375,7 +376,7 @@ static Sequence< OUString > lcl_getExplicitSimpleCategories( } } } - aRet[nN]=aText.makeStringAndClear(); + pRet[nN]=aText.makeStringAndClear(); } } return aRet; diff --git a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx index a5063ee1039b..9c41822d3618 100644 --- a/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/ExponentialRegressionCurveCalculator.cxx @@ -135,11 +135,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL ExponentialRegressionCurveCalcul isLogarithmicScaling( xScalingY )) { // optimize result - uno::Sequence< geometry::RealPoint2D > aResult( 2 ); - aResult[0].X = min; - aResult[0].Y = getCurveValue( min ); - aResult[1].X = max; - aResult[1].Y = getCurveValue( max ); + uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) }, + { max, getCurveValue( max ) } }; return aResult; } diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx index b93dbe33ae88..3249231a6fec 100644 --- a/chart2/source/tools/InternalData.cxx +++ b/chart2/source/tools/InternalData.cxx @@ -21,6 +21,7 @@ #include <ResId.hxx> #include <strings.hrc> +#include <comphelper/sequence.hxx> #include <osl/diagnose.h> #ifdef DEBUG_CHART2_TOOLS @@ -68,11 +69,7 @@ private: template< typename T > Sequence< T > lcl_ValarrayToSequence( const std::valarray< T > & rValarray ) { - // is there a more elegant way of conversion? - Sequence< T > aResult( rValarray.size()); - for( size_t i = 0; i < rValarray.size(); ++i ) - aResult[i] = rValarray[i]; - return aResult; + return comphelper::containerToSequence(rValarray); } } // anonymous namespace @@ -147,9 +144,10 @@ void InternalData::setData( const Sequence< Sequence< double > >& rDataInRows ) Sequence< Sequence< double > > InternalData::getData() const { Sequence< Sequence< double > > aResult( m_nRowCount ); + auto aResultRange = asNonConstRange(aResult); for( sal_Int32 i=0; i<m_nRowCount; ++i ) - aResult[i] = lcl_ValarrayToSequence< tDataType::value_type >( + aResultRange[i] = lcl_ValarrayToSequence< tDataType::value_type >( m_aData[ std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] ); return aResult; diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index 0323043dbff2..794a780d5a86 100644 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -120,6 +120,7 @@ struct lcl_internalizeSeries Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences(); Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() ); + auto aNewSeriesDataRange = asNonConstRange(aNewSeriesData); for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i ) { sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() ); @@ -158,13 +159,13 @@ struct lcl_internalizeSeries comphelper::copyProperties( Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ), Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY )); - aNewSeriesData[i].set( new LabeledDataSequence( xNewValues, xNewLabel ) ); + aNewSeriesDataRange[i].set( new LabeledDataSequence( xNewValues, xNewLabel ) ); } } else { if( m_bConnectToModel ) - aNewSeriesData[i].set( new LabeledDataSequence( xNewValues ) ); + aNewSeriesDataRange[i].set( new LabeledDataSequence( xNewValues ) ); } } if( m_bConnectToModel ) @@ -780,22 +781,22 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData Sequence< beans::PropertyValue > SAL_CALL InternalDataProvider::detectArguments( const Reference< chart2::data::XDataSource >& /* xDataSource */ ) { - Sequence< beans::PropertyValue > aArguments( 4 ); - aArguments[0] = beans::PropertyValue( - "CellRangeRepresentation", -1, uno::Any( OUString(lcl_aCompleteRange) ), - beans::PropertyState_DIRECT_VALUE ); - aArguments[1] = beans::PropertyValue( - "DataRowSource", -1, uno::Any( - m_bDataInColumns - ? css::chart::ChartDataRowSource_COLUMNS - : css::chart::ChartDataRowSource_ROWS ), - beans::PropertyState_DIRECT_VALUE ); - // internal data always contains labels and categories - aArguments[2] = beans::PropertyValue( - "FirstCellAsLabel", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE ); - aArguments[3] = beans::PropertyValue( - "HasCategories", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE ); - + Sequence< beans::PropertyValue > aArguments{ + beans::PropertyValue( + "CellRangeRepresentation", -1, uno::Any( OUString(lcl_aCompleteRange) ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "DataRowSource", -1, uno::Any( + m_bDataInColumns + ? css::chart::ChartDataRowSource_COLUMNS + : css::chart::ChartDataRowSource_ROWS ), + beans::PropertyState_DIRECT_VALUE ), + // internal data always contains labels and categories + beans::PropertyValue( + "FirstCellAsLabel", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + "HasCategories", -1, uno::Any( true ), beans::PropertyState_DIRECT_VALUE ) + }; // #i85913# Sequence Mapping is not needed for internal data, as it is // applied to the data when the data source is created. @@ -1293,8 +1294,9 @@ Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const ve if( nOuterCount ) { aRet.realloc(nOuterCount); + auto pRet = aRet.getArray(); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet[nN]= comphelper::containerToSequence( rIn[nN] ); + pRet[nN]= comphelper::containerToSequence( rIn[nN] ); } return aRet; } @@ -1375,13 +1377,14 @@ Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); sal_Int32 nCount = aCategories.size(); Sequence< double > aDoubles( nCount ); + auto aDoublesRange = asNonConstRange(aDoubles); sal_Int32 nN=0; for (auto const& category : aCategories) { double fValue; if( category.empty() || !(category[0]>>=fValue) ) fValue = std::numeric_limits<double>::quiet_NaN(); - aDoubles[nN++]=fValue; + aDoublesRange[nN++]=fValue; } return aDoubles; } diff --git a/chart2/source/tools/LinearRegressionCurveCalculator.cxx b/chart2/source/tools/LinearRegressionCurveCalculator.cxx index b4ec56028ec3..ee836555b1e4 100644 --- a/chart2/source/tools/LinearRegressionCurveCalculator.cxx +++ b/chart2/source/tools/LinearRegressionCurveCalculator.cxx @@ -56,11 +56,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL LinearRegressionCurveCalculator: isLinearScaling( xScalingY )) { // optimize result - uno::Sequence< geometry::RealPoint2D > aResult( 2 ); - aResult[0].X = min; - aResult[0].Y = getCurveValue( min ); - aResult[1].X = max; - aResult[1].Y = getCurveValue( max ); + uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) }, + { max, getCurveValue( max ) } }; return aResult; } diff --git a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx index 1e84ed81d42d..58b0a66da1d1 100644 --- a/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx +++ b/chart2/source/tools/LogarithmicRegressionCurveCalculator.cxx @@ -107,11 +107,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL LogarithmicRegressionCurveCalcul isLinearScaling( xScalingY )) { // optimize result - uno::Sequence< geometry::RealPoint2D > aResult( 2 ); - aResult[0].X = min; - aResult[0].Y = getCurveValue( min ); - aResult[1].X = max; - aResult[1].Y = getCurveValue( max ); + uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) }, + { max, getCurveValue( max ) } }; return aResult; } diff --git a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx index 70c3f1822de4..aefd3f8f05aa 100644 --- a/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx +++ b/chart2/source/tools/MeanValueRegressionCurveCalculator.cxx @@ -99,11 +99,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL MeanValueRegressionCurveCalculat if( bMaySkipPointsInCalculation ) { // optimize result - uno::Sequence< geometry::RealPoint2D > aResult( 2 ); - aResult[0].X = min; - aResult[0].Y = m_fMeanValue; - aResult[1].X = max; - aResult[1].Y = m_fMeanValue; + uno::Sequence< geometry::RealPoint2D > aResult{ { min, m_fMeanValue }, + { max, m_fMeanValue } }; return aResult; } diff --git a/chart2/source/tools/MediaDescriptorHelper.cxx b/chart2/source/tools/MediaDescriptorHelper.cxx index 73c326fdcb38..bd217b0fbf8c 100644 --- a/chart2/source/tools/MediaDescriptorHelper.cxx +++ b/chart2/source/tools/MediaDescriptorHelper.cxx @@ -33,21 +33,23 @@ MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence< beans::PropertyValue > & rMediaDescriptor ) : m_aModelProperties(rMediaDescriptor.getLength()) { + auto aModelPropertiesRange = asNonConstRange(m_aModelProperties); css::uno::Sequence< css::beans::PropertyValue > aRegularProperties(rMediaDescriptor.getLength()); //these are the properties which are described in service com.sun.star.document.MediaDescriptor and not marked as deprecated + auto aRegularPropertiesRange = asNonConstRange(aRegularProperties); impl_init(); sal_Int32 nRegularCount = 0; sal_Int32 nModelCount = 0; - auto addRegularProp = [&aRegularProperties, &nRegularCount](const beans::PropertyValue& rRegularProp) + auto addRegularProp = [&aRegularPropertiesRange, &nRegularCount](const beans::PropertyValue& rRegularProp) { - aRegularProperties[nRegularCount] = rRegularProp; + aRegularPropertiesRange[nRegularCount] = rRegularProp; ++nRegularCount; }; - auto addModelProp = [this, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp) + auto addModelProp = [&aModelPropertiesRange, &nModelCount, &addRegularProp](const beans::PropertyValue& rModelProp) { addRegularProp(rModelProp); - m_aModelProperties[nModelCount] = rModelProp; + aModelPropertiesRange[nModelCount] = rModelProp; ++nModelCount; }; diff --git a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx index d21ec8d27714..227a509ad3f0 100644 --- a/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx +++ b/chart2/source/tools/MovingAverageRegressionCurveCalculator.cxx @@ -22,6 +22,7 @@ #include <ResId.hxx> #include <strings.hrc> +#include <algorithm> #include <limits> #include <com/sun/star/chart2/MovingAverageType.hpp> @@ -145,12 +146,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL MovingAverageRegressionCurveCalc { size_t nSize = std::min(aXList.size(), aYList.size()); uno::Sequence< geometry::RealPoint2D > aResult( nSize ); - - for( size_t i = 0; i < nSize; ++i ) - { - aResult[i].X = aXList[i]; - aResult[i].Y = aYList[i]; - } + std::transform(aXList.begin(), aXList.begin() + nSize, aYList.begin(), aResult.getArray(), + [](const auto& x, const auto& y) { return geometry::RealPoint2D(x, y); }); return aResult; } diff --git a/chart2/source/tools/NameContainer.cxx b/chart2/source/tools/NameContainer.cxx index 8879ededadee..3e485c624948 100644 --- a/chart2/source/tools/NameContainer.cxx +++ b/chart2/source/tools/NameContainer.cxx @@ -20,7 +20,9 @@ #include <NameContainer.hxx> #include <com/sun/star/uno/Any.hxx> - #include <cppuhelper/supportsservice.hxx> + +#include <comphelper/sequence.hxx> +#include <cppuhelper/supportsservice.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Sequence; @@ -108,14 +110,7 @@ Any SAL_CALL NameContainer::getByName( const OUString& rName ) Sequence< OUString > SAL_CALL NameContainer::getElementNames() { - sal_Int32 nCount = m_aMap.size(); - Sequence< OUString > aSeq(nCount); - sal_Int32 nN = 0; - for (auto const& elem : m_aMap) - { - aSeq[nN++]=elem.first; - } - return aSeq; + return comphelper::mapKeysToSequence(m_aMap); } sal_Bool SAL_CALL NameContainer::hasByName( const OUString& rName ) diff --git a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx index 1fa82434e0b4..01aa5b2548fb 100644 --- a/chart2/source/tools/PotentialRegressionCurveCalculator.cxx +++ b/chart2/source/tools/PotentialRegressionCurveCalculator.cxx @@ -120,11 +120,8 @@ uno::Sequence< geometry::RealPoint2D > SAL_CALL PotentialRegressionCurveCalculat isLogarithmicScaling( xScalingY )) { // optimize result - uno::Sequence< geometry::RealPoint2D > aResult( 2 ); - aResult[0].X = min; - aResult[0].Y = getCurveValue( min ); - aResult[1].X = max; - aResult[1].Y = getCurveValue( max ); + uno::Sequence< geometry::RealPoint2D > aResult{ { min, getCurveValue( min ) }, + { max, getCurveValue( max ) } }; return aResult; } diff --git a/chart2/source/tools/RangeHighlighter.cxx b/chart2/source/tools/RangeHighlighter.cxx index fb0e75f4b738..3dc667bfd043 100644 --- a/chart2/source/tools/RangeHighlighter.cxx +++ b/chart2/source/tools/RangeHighlighter.cxx @@ -52,12 +52,13 @@ void lcl_fillRanges( sal_Int32 nIndex = -1 ) { rOutRanges.realloc( aRangeStrings.getLength()); + auto pOutRanges = rOutRanges.getArray(); for( sal_Int32 i=0; i<aRangeStrings.getLength(); ++i ) { - rOutRanges[i].RangeRepresentation = aRangeStrings[i]; - rOutRanges[i].PreferredColor = sal_Int32(nPreferredColor); - rOutRanges[i].AllowMerginigWithOtherRanges = false; - rOutRanges[i].Index = nIndex; + pOutRanges[i].RangeRepresentation = aRangeStrings[i]; + pOutRanges[i].PreferredColor = sal_Int32(nPreferredColor); + pOutRanges[i].AllowMerginigWithOtherRanges = false; + pOutRanges[i].Index = nIndex; } } @@ -197,13 +198,14 @@ void RangeHighlighter::fillRangesForDiagram( const Reference< chart2::XDiagram > { Sequence< OUString > aSelectedRanges( DataSourceHelper::getUsedDataRanges( xDiagram )); m_aSelectedRanges.realloc( aSelectedRanges.getLength()); + auto pSelectedRanges = m_aSelectedRanges.getArray(); // @todo: merge ranges for( sal_Int32 i=0; i<aSelectedRanges.getLength(); ++i ) { - m_aSelectedRanges[i].RangeRepresentation = aSelectedRanges[i]; - m_aSelectedRanges[i].Index = -1; - m_aSelectedRanges[i].PreferredColor = sal_Int32(defaultPreferredColor); - m_aSelectedRanges[i].AllowMerginigWithOtherRanges = true; + pSelectedRanges[i].RangeRepresentation = aSelectedRanges[i]; + pSelectedRanges[i].Index = -1; + pSelectedRanges[i].PreferredColor = sal_Int32(defaultPreferredColor); + pSelectedRanges[i].AllowMerginigWithOtherRanges = true; } } diff --git a/chart2/source/tools/RegressionCurveCalculator.cxx b/chart2/source/tools/RegressionCurveCalculator.cxx index ff2f4d13a896..fbf5d243bdb9 100644 --- a/chart2/source/tools/RegressionCurveCalculator.cxx +++ b/chart2/source/tools/RegressionCurveCalculator.cxx @@ -145,6 +145,7 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa bDoXScaling = bDoXScaling && xInverseScaling.is(); Sequence< geometry::RealPoint2D > aResult( nPointCount ); + auto pResult = aResult.getArray(); double fMin( min ); double fFact = (max - min) / double(nPointCount-1); @@ -160,8 +161,8 @@ Sequence< geometry::RealPoint2D > SAL_CALL RegressionCurveCalculator::getCurveVa double x = fMin + nP * fFact; if( bDoXScaling ) x = xInverseScaling->doScaling( x ); - aResult[nP].X = x; - aResult[nP].Y = getCurveValue( x ); + pResult[nP].X = x; + pResult[nP].Y = getCurveValue( x ); } return aResult; diff --git a/chart2/source/tools/RegressionCurveHelper.cxx b/chart2/source/tools/RegressionCurveHelper.cxx index 61f155011664..1df7ac904da8 100644 --- a/chart2/source/tools/RegressionCurveHelper.cxx +++ b/chart2/source/tools/RegressionCurveHelper.cxx @@ -211,8 +211,9 @@ void RegressionCurveHelper::initializeCurveCalculator( // initialize with 1, 2, ... //first category (index 0) matches with real number 1.0 aXValues.realloc( aYValues.getLength()); + auto pXValues = aXValues.getArray(); for( i=0; i<aXValues.getLength(); ++i ) - aXValues[i] = i+1; + pXValues[i] = i+1; bXValuesFound = true; } diff --git a/chart2/source/tools/StatisticsHelper.cxx b/chart2/source/tools/StatisticsHelper.cxx index 332843aaa307..c8fad963deab 100644 --- a/chart2/source/tools/StatisticsHelper.cxx +++ b/chart2/source/tools/StatisticsHelper.cxx @@ -133,7 +133,8 @@ void lcl_addSequenceToDataSource( Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); aSequences.realloc( aSequences.getLength() + 1 ); - aSequences[ aSequences.getLength() - 1 ] = xLSeq; + auto pSequences = aSequences.getArray(); + pSequences[ aSequences.getLength() - 1 ] = xLSeq; xSink->setData( aSequences ); } diff --git a/chart2/source/tools/TitleHelper.cxx b/chart2/source/tools/TitleHelper.cxx index bc11c4f99c32..83a409984c66 100644 --- a/chart2/source/tools/TitleHelper.cxx +++ b/chart2/source/tools/TitleHelper.cxx @@ -351,12 +351,12 @@ void TitleHelper::setCompleteString( const OUString& rNewText aNewText = aUnstackedStr.makeStringAndClear(); } - uno::Sequence< uno::Reference< XFormattedString > > aNewStringList(1); + uno::Sequence< uno::Reference< XFormattedString > > aNewStringList; uno::Sequence< uno::Reference< XFormattedString > > aOldStringList = xTitle->getText(); if( aOldStringList.hasElements() ) { - aNewStringList[0].set( aOldStringList[0] ); + aNewStringList = { aOldStringList[0] }; aNewStringList[0]->setString( aNewText ); } else @@ -365,7 +365,7 @@ void TitleHelper::setCompleteString( const OUString& rNewText chart2::FormattedString::create( xContext ); xFormattedString->setString( aNewText ); - aNewStringList[0].set( xFormattedString ); + aNewStringList = { xFormattedString }; ... etc. - the rest is truncated