summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/tools/OPropertySet.cxx17
-rw-r--r--chart2/source/view/charttypes/Splines.cxx24
2 files changed, 18 insertions, 23 deletions
diff --git a/chart2/source/tools/OPropertySet.cxx b/chart2/source/tools/OPropertySet.cxx
index aa4ca406bd5e..09a5686cf6e3 100644
--- a/chart2/source/tools/OPropertySet.cxx
+++ b/chart2/source/tools/OPropertySet.cxx
@@ -25,6 +25,7 @@
#include <vector>
#include <algorithm>
+#include <boost/scoped_array.hpp>
using namespace ::com::sun::star;
@@ -147,11 +148,11 @@ Sequence< beans::PropertyState > SAL_CALL
{
cppu::IPropertyArrayHelper & rPH = getInfoHelper();
- sal_Int32 * pHandles = new sal_Int32[ aPropertyName.getLength() ];
- rPH.fillHandles( pHandles, aPropertyName );
+ boost::scoped_array<sal_Int32> pHandles(new sal_Int32[ aPropertyName.getLength() ]);
+ rPH.fillHandles( pHandles.get(), aPropertyName );
- ::std::vector< sal_Int32 > aHandles( pHandles, pHandles + aPropertyName.getLength());
- delete[] pHandles;
+ ::std::vector< sal_Int32 > aHandles( pHandles.get(), pHandles.get() + aPropertyName.getLength());
+ pHandles.reset();
return m_pImplProperties->GetPropertyStatesByHandle( aHandles );
}
@@ -198,11 +199,11 @@ void SAL_CALL
{
cppu::IPropertyArrayHelper & rPH = getInfoHelper();
- sal_Int32 * pHandles = new sal_Int32[ aPropertyNames.getLength() ];
- rPH.fillHandles( pHandles, aPropertyNames );
+ boost::scoped_array<sal_Int32> pHandles(new sal_Int32[ aPropertyNames.getLength() ]);
+ rPH.fillHandles( pHandles.get(), aPropertyNames );
- ::std::vector< sal_Int32 > aHandles( pHandles, pHandles + aPropertyNames.getLength());
- delete[] pHandles;
+ ::std::vector< sal_Int32 > aHandles( pHandles.get(), pHandles.get() + aPropertyNames.getLength());
+ pHandles.reset();
m_pImplProperties->SetPropertiesToDefault( aHandles );
}
diff --git a/chart2/source/view/charttypes/Splines.cxx b/chart2/source/view/charttypes/Splines.cxx
index e770b4b15c60..419fb9a8b82d 100644
--- a/chart2/source/view/charttypes/Splines.cxx
+++ b/chart2/source/view/charttypes/Splines.cxx
@@ -23,6 +23,7 @@
#include <vector>
#include <algorithm>
#include <functional>
+#include <boost/scoped_array.hpp>
#define MAX_BSPLINE_DEGREE 15
@@ -727,30 +728,29 @@ void SplineCalculater::CalculateBSplines(
continue; // need at least 2 points, degree p needs at least n+1 points
// next piece of series
- double* t = new double [n+1];
- if (!createParameterT(aPointsIn, t))
+ boost::scoped_array<double> t(new double [n+1]);
+ if (!createParameterT(aPointsIn, t.get()))
{
- delete[] t;
continue; // next piece of series
}
lcl_tSizeType m = n + p + 1;
- double* u = new double [m+1];
- createKnotVector(n, p, t, u);
+ boost::scoped_array<double> u(new double [m+1]);
+ createKnotVector(n, p, t.get(), u.get());
// The matrix N contains the B-spline basis functions applied to parameters.
// In each row only p+1 adjacent elements are non-zero. The starting
// column in a higher row is equal or greater than in the lower row.
// To store this matrix the non-zero elements are shifted to column 0
// and the amount of shifting is remembered in an array.
- double** aMatN = new double*[n+1];
+ boost::scoped_array<double*> aMatN(new double*[n+1]);
for (lcl_tSizeType row = 0; row <=n; ++row)
{
aMatN[row] = new double[p+1];
for (sal_uInt32 col = 0; col <= p; ++col)
aMatN[row][col] = 0.0;
}
- lcl_tSizeType* aShift = new lcl_tSizeType[n+1];
+ boost::scoped_array<lcl_tSizeType> aShift(new lcl_tSizeType[n+1]);
aMatN[0][0] = 1.0; //all others are zero
aShift[0] = 0;
aMatN[n][0] = 1.0;
@@ -770,7 +770,7 @@ void SplineCalculater::CalculateBSplines(
// index in reduced matrix aMatN = (index in full matrix N) - (i-p)
aShift[k] = i - p;
- applyNtoParameterT(i, t[k], p, u, aMatN[k]);
+ applyNtoParameterT(i, t[k], p, u.get(), aMatN[k]);
} // next row k
// Get matrix C of control points from the matrix equation aMatN * C = aPointsIn
@@ -886,7 +886,7 @@ void SplineCalculater::CalculateBSplines(
pNewX[nNewSize -1 ] = aPointsIn[n].first;
pNewY[nNewSize -1 ] = aPointsIn[n].second;
pNewZ[nNewSize -1 ] = fZCoordinate;
- double* aP = new double[m+1];
+ boost::scoped_array<double> aP(new double[m+1]);
lcl_tSizeType nLow = 0;
for ( lcl_tSizeType nTIndex = 0; nTIndex <= n-1; ++nTIndex)
{
@@ -939,17 +939,11 @@ void SplineCalculater::CalculateBSplines(
pNewZ[nNewIndex] = fZCoordinate;
}
}
- delete[] aP;
}
- delete[] aShift;
for (lcl_tSizeType row = 0; row <=n; ++row)
{
delete[] aMatN[row];
}
- delete[] aMatN;
- delete[] u;
- delete[] t;
-
} // next piece of the series
}