summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Nitschke <j.nitschke+logerrit@ok.de>2016-07-12 22:42:42 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-07-14 02:00:00 +0000
commit800a196718abbfd38d93c845e563e055ef778b04 (patch)
tree127621cd5185cc3d55f30981af90f820c47e8a72
parentde162ef3c7d447e1faf3bc8d0766fc0e34d80b49 (diff)
chart2: avoid use of realloc
by using ctor initializer list, removing redundant realloc and other small tweaks Change-Id: I73775ef3677244de5c04e8743c43228d6cb3b008 Reviewed-on: https://gerrit.libreoffice.org/27174 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--chart2/source/tools/CachedDataSequence.cxx3
-rw-r--r--chart2/source/tools/MediaDescriptorHelper.cxx15
-rw-r--r--chart2/source/view/axes/Tickmarks_Equidistant.cxx4
-rw-r--r--chart2/source/view/axes/VCartesianGrid.cxx9
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx7
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx8
-rw-r--r--chart2/source/view/charttypes/Splines.cxx18
-rw-r--r--chart2/source/view/main/ChartView.cxx22
-rw-r--r--chart2/source/view/main/DummyXShape.cxx13
9 files changed, 35 insertions, 64 deletions
diff --git a/chart2/source/tools/CachedDataSequence.cxx b/chart2/source/tools/CachedDataSequence.cxx
index 0a4c634f7040..02ddf0f0b3ee 100644
--- a/chart2/source/tools/CachedDataSequence.cxx
+++ b/chart2/source/tools/CachedDataSequence.cxx
@@ -79,10 +79,9 @@ CachedDataSequence::CachedDataSequence( const OUString & rSingleText )
: OPropertyContainer( GetBroadcastHelper()),
CachedDataSequence_Base( GetMutex()),
m_eCurrentDataType( TEXTUAL ),
+ m_aTextualSequence({rSingleText}),
m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder())
{
- m_aTextualSequence.realloc(1);
- m_aTextualSequence[0] = rSingleText;
registerProperties();
}
diff --git a/chart2/source/tools/MediaDescriptorHelper.cxx b/chart2/source/tools/MediaDescriptorHelper.cxx
index 9951b1336194..50a9b5c32901 100644
--- a/chart2/source/tools/MediaDescriptorHelper.cxx
+++ b/chart2/source/tools/MediaDescriptorHelper.cxx
@@ -51,23 +51,16 @@ if(rProp.Name == #MediaName) \
MediaDescriptorHelper::MediaDescriptorHelper( const uno::Sequence<
beans::PropertyValue > & rMediaDescriptor )
+ : m_aRegularProperties(rMediaDescriptor.getLength())
+ , m_aDeprecatedProperties(rMediaDescriptor.getLength())
+ , m_aAdditionalProperties(rMediaDescriptor.getLength())
+ , m_aModelProperties(rMediaDescriptor.getLength())
{
impl_init();
- m_aRegularProperties.realloc(0);
- m_aRegularProperties.realloc(rMediaDescriptor.getLength());
sal_Int32 nRegularCount = 0;
-
- m_aDeprecatedProperties.realloc(0);
- m_aDeprecatedProperties.realloc(rMediaDescriptor.getLength());
sal_Int32 nDeprecatedCount = 0;
-
- m_aAdditionalProperties.realloc(0);
- m_aAdditionalProperties.realloc(rMediaDescriptor.getLength());
sal_Int32 nAdditionalCount = 0;
-
- m_aModelProperties.realloc(0);
- m_aModelProperties.realloc(rMediaDescriptor.getLength());
sal_Int32 nModelCount = 0;
//read given rMediaDescriptor and store in internal structures:
diff --git a/chart2/source/view/axes/Tickmarks_Equidistant.cxx b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
index b1ddc875127d..a3f2cb5ad082 100644
--- a/chart2/source/view/axes/Tickmarks_Equidistant.cxx
+++ b/chart2/source/view/axes/Tickmarks_Equidistant.cxx
@@ -311,8 +311,6 @@ bool EquidistantTickFactory::isVisible( double fScaledValue ) const
void EquidistantTickFactory::getAllTicks( TickInfoArraysType& rAllTickInfos ) const
{
- uno::Sequence< uno::Sequence< double > > aAllTicks;
-
//create point sequences for each tick depth
sal_Int32 nDepthCount = this->getTickDepth();
sal_Int32 nMaxMajorTickCount = this->getMaxTickCount();
@@ -320,7 +318,7 @@ void EquidistantTickFactory::getAllTicks( TickInfoArraysType& rAllTickInfos ) co
if (nDepthCount <= 0 || nMaxMajorTickCount <= 0)
return;
- aAllTicks.realloc(nDepthCount);
+ uno::Sequence< uno::Sequence< double > > aAllTicks(nDepthCount);
aAllTicks[0].realloc(nMaxMajorTickCount);
sal_Int32 nRealMajorTickCount = 0;
diff --git a/chart2/source/view/axes/VCartesianGrid.cxx b/chart2/source/view/axes/VCartesianGrid.cxx
index 028ab3b1942a..0b3de68f3301 100644
--- a/chart2/source/view/axes/VCartesianGrid.cxx
+++ b/chart2/source/view/axes/VCartesianGrid.cxx
@@ -57,7 +57,10 @@ GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_In
, CuboidPlanePosition eLeftWallPos
, CuboidPlanePosition eBackWallPos
, CuboidPlanePosition eBottomPos )
- : m_nDimensionIndex(nDimensionIndex)
+ : P0(3)
+ , P1(3)
+ , P2(3)
+ , m_nDimensionIndex(nDimensionIndex)
{
double MinX = pPosHelper->getLogicMinX();
double MinY = pPosHelper->getLogicMinY();
@@ -89,10 +92,6 @@ GridLinePoints::GridLinePoints( const PlottingPositionHelper* pPosHelper, sal_In
}
bool bSwapXY = pPosHelper->isSwapXAndY();
- P0.realloc(3);
- P1.realloc(3);
- P2.realloc(3);
-
//P0: point on 'back' wall, not on 'left' wall
//P1: point on both walls
//P2: point on 'left' wall not on 'back' wall
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 379d93a56648..7cff69374e75 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
#include <comphelper/sequence.hxx>
+#include <algorithm>
#include <rtl/math.hxx>
namespace chart
@@ -152,11 +153,9 @@ void VCoordinateSystem::setTransformationSceneToScreen(
uno::Sequence< sal_Int32 > VCoordinateSystem::getCoordinateSystemResolution(
const awt::Size& rPageSize, const awt::Size& rPageResolution )
{
- uno::Sequence< sal_Int32 > aResolution(2);
+ uno::Sequence<sal_Int32> aResolution(
+ std::max<sal_Int32>(m_xCooSysModel->getDimension(), 2));
- sal_Int32 nDimensionCount = m_xCooSysModel->getDimension();
- if(nDimensionCount>2)
- aResolution.realloc(nDimensionCount);
sal_Int32 nN = 0;
for( nN = 0 ;nN<aResolution.getLength(); nN++ )
aResolution[nN]=1000;
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index 44a26bd1ba20..ece662371120 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -248,19 +248,15 @@ void lcl_removeDuplicatePoints( drawing::PolyPolygonShape3D& rPolyPoly, Plotting
bool AreaChart::create_stepped_line( drawing::PolyPolygonShape3D aStartPoly, chart2::CurveStyle eCurveStyle, PlottingPositionHelper* pPosHelper, drawing::PolyPolygonShape3D &aPoly )
{
- drawing::PolyPolygonShape3D aSteppedPoly;
-
- aSteppedPoly.SequenceX.realloc(0);
- aSteppedPoly.SequenceY.realloc(0);
- aSteppedPoly.SequenceZ.realloc(0);
-
sal_uInt32 nOuterCount = aStartPoly.SequenceX.getLength();
if ( !nOuterCount )
return false;
+ drawing::PolyPolygonShape3D aSteppedPoly;
aSteppedPoly.SequenceX.realloc(nOuterCount);
aSteppedPoly.SequenceY.realloc(nOuterCount);
aSteppedPoly.SequenceZ.realloc(nOuterCount);
+
for( sal_uInt32 nOuter = 0; nOuter < nOuterCount; ++nOuter )
{
if( aStartPoly.SequenceX[nOuter].getLength() <= 1 )
diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index 97203622aa5d..a06a76a2be8f 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -538,18 +538,15 @@ void SplineCalculater::CalculateCubicSplines(
{
OSL_PRECOND( nGranularity > 0, "Granularity is invalid" );
- rResult.SequenceX.realloc(0);
- rResult.SequenceY.realloc(0);
- rResult.SequenceZ.realloc(0);
-
sal_uInt32 nOuterCount = rInput.SequenceX.getLength();
- if( !nOuterCount )
- return;
rResult.SequenceX.realloc(nOuterCount);
rResult.SequenceY.realloc(nOuterCount);
rResult.SequenceZ.realloc(nOuterCount);
+ if( !nOuterCount )
+ return;
+
for( sal_uInt32 nOuter = 0; nOuter < nOuterCount; ++nOuter )
{
if( rInput.SequenceX[nOuter].getLength() <= 1 )
@@ -677,18 +674,15 @@ void SplineCalculater::CalculateBSplines(
// limit the b-spline degree at 15 to prevent insanely large sets of points
sal_uInt32 p = std::min<sal_uInt32>(nDegree, 15);
- rResult.SequenceX.realloc(0);
- rResult.SequenceY.realloc(0);
- rResult.SequenceZ.realloc(0);
-
sal_Int32 nOuterCount = rInput.SequenceX.getLength();
- if( !nOuterCount )
- return; // no input
rResult.SequenceX.realloc(nOuterCount);
rResult.SequenceY.realloc(nOuterCount);
rResult.SequenceZ.realloc(nOuterCount);
+ if( !nOuterCount )
+ return; // no input
+
for( sal_Int32 nOuter = 0; nOuter < nOuterCount; ++nOuter )
{
if( rInput.SequenceX[nOuter].getLength() <= 1 )
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx
index 214cf3caafbd..adc8c88769df 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1270,7 +1270,7 @@ void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStre
aProps[1].Name = "OutputStream";
aProps[1].Value <<= xOutStream;
- uno::Sequence< beans::PropertyValue > aFilterData(4);
+ uno::Sequence< beans::PropertyValue > aFilterData(8);
aFilterData[0].Name = "ExportOnlyBackground";
aFilterData[0].Value <<= false;
aFilterData[1].Name = "HighContrast";
@@ -1284,17 +1284,15 @@ void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStre
aFilterData[3].Value <<= uno::Reference< uno::XInterface >( m_xDrawPage, uno::UNO_QUERY );
//#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
- {
- aFilterData.realloc( aFilterData.getLength()+4 );
- aFilterData[4].Name = "ScaleXNumerator";
- aFilterData[4].Value = uno::makeAny( m_nScaleXNumerator );
- aFilterData[5].Name = "ScaleXDenominator";
- aFilterData[5].Value = uno::makeAny( m_nScaleXDenominator );
- aFilterData[6].Name = "ScaleYNumerator";
- aFilterData[6].Value = uno::makeAny( m_nScaleYNumerator );
- aFilterData[7].Name = "ScaleYDenominator";
- aFilterData[7].Value = uno::makeAny( m_nScaleYDenominator );
- }
+ aFilterData[4].Name = "ScaleXNumerator";
+ aFilterData[4].Value = uno::makeAny( m_nScaleXNumerator );
+ aFilterData[5].Name = "ScaleXDenominator";
+ aFilterData[5].Value = uno::makeAny( m_nScaleXDenominator );
+ aFilterData[6].Name = "ScaleYNumerator";
+ aFilterData[6].Value = uno::makeAny( m_nScaleYNumerator );
+ aFilterData[7].Name = "ScaleYDenominator";
+ aFilterData[7].Value = uno::makeAny( m_nScaleYDenominator );
+
aProps[2].Name = "FilterData";
aProps[2].Value <<= aFilterData;
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 3f5baf76b21d..544b272ea267 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -306,15 +306,10 @@ namespace {
uno::Sequence< OUString > listSupportedServices()
{
- static uno::Sequence< OUString > aSupportedServices;
- if(aSupportedServices.getLength() == 0)
- {
- aSupportedServices.realloc(3);
- aSupportedServices[0] = "com.sun.star.drawing.Shape";
- aSupportedServices[1] = "com.sun.star.container.Named";
- aSupportedServices[2] = "com.sun.star.beans.PropertySet";
- }
-
+ static const uno::Sequence< OUString > aSupportedServices{
+ "com.sun.star.drawing.Shape",
+ "com.sun.star.container.Named",
+ "com.sun.star.beans.PropertySet"};
return aSupportedServices;
}