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>
This commit is contained in:
Jochen Nitschke
2016-07-12 22:42:42 +02:00
committed by Noel Grandin
parent de162ef3c7
commit 800a196718
9 changed files with 35 additions and 64 deletions

View File

@@ -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();
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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 )

View File

@@ -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 )

View File

@@ -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,8 +1284,6 @@ 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";
@@ -1294,7 +1292,7 @@ void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStre
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;

View File

@@ -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;
}