summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-28 15:04:18 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-05 07:28:15 +0100
commit151bd68854795b3588f01083cf3ca75826c6df1f (patch)
tree7f5d2eac8e4247b0b3f73456f7611eb2e0044c2f /svx
parent3a561cac82bcccda4f5685645f865e3176e6a005 (diff)
loplugin:useuniqueptr in ImpXPolygon
Change-Id: I5bb3f0661f5d62527bb5a8d24035c46a6a11e185 Reviewed-on: https://gerrit.libreoffice.org/50691 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/inc/xpolyimp.hxx2
-rw-r--r--svx/source/xoutdev/_xpoly.cxx32
2 files changed, 17 insertions, 17 deletions
diff --git a/svx/inc/xpolyimp.hxx b/svx/inc/xpolyimp.hxx
index fd0fe2905d8b..4b73dd6fe556 100644
--- a/svx/inc/xpolyimp.hxx
+++ b/svx/inc/xpolyimp.hxx
@@ -29,7 +29,7 @@ class Point;
class ImpXPolygon
{
public:
- Point* pPointAry;
+ std::unique_ptr<Point[]> pPointAry;
std::unique_ptr<PolyFlags[]>
pFlagAry;
Point* pOldPointAry;
diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx
index 05fe65b17d89..a4024a061954 100644
--- a/svx/source/xoutdev/_xpoly.cxx
+++ b/svx/source/xoutdev/_xpoly.cxx
@@ -65,13 +65,13 @@ ImpXPolygon::ImpXPolygon( const ImpXPolygon& rImpXPoly )
// copy
nPoints = rImpXPoly.nPoints;
- memcpy( pPointAry, rImpXPoly.pPointAry, nSize*sizeof( Point ) );
+ memcpy( pPointAry.get(), rImpXPoly.pPointAry.get(), nSize*sizeof( Point ) );
memcpy( pFlagAry.get(), rImpXPoly.pFlagAry.get(), nSize );
}
ImpXPolygon::~ImpXPolygon()
{
- delete[] pPointAry;
+ pPointAry.reset();
if ( bDeleteOldPoints )
{
delete[] pOldPointAry;
@@ -83,7 +83,7 @@ bool ImpXPolygon::operator==(const ImpXPolygon& rImpXPoly) const
{
return nPoints==rImpXPoly.nPoints &&
(nPoints==0 ||
- (memcmp(pPointAry, rImpXPoly.pPointAry, nPoints*sizeof(Point))==0 &&
+ (memcmp(pPointAry.get(), rImpXPoly.pPointAry.get(), nPoints*sizeof(Point))==0 &&
memcmp(pFlagAry.get(), rImpXPoly.pFlagAry.get(), nPoints)==0));
}
@@ -104,7 +104,7 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints )
sal_uInt16 nOldSize = nSize;
CheckPointDelete();
- pOldPointAry = pPointAry;
+ pOldPointAry = pPointAry.release();
// Round the new size to a multiple of nResize, if
// the object was not newly created (nSize != 0)
@@ -115,7 +115,7 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints )
}
// create point array
nSize = nNewSize;
- pPointAry = new Point[ nSize ];
+ pPointAry.reset( new Point[ nSize ] );
// create flag array
pFlagAry.reset( new PolyFlags[ nSize ] );
@@ -126,12 +126,12 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints )
{
if( nOldSize < nSize )
{
- memcpy( pPointAry, pOldPointAry, nOldSize*sizeof( Point ) );
+ memcpy( pPointAry.get(), pOldPointAry, nOldSize*sizeof( Point ) );
memcpy( pFlagAry.get(), pOldFlagAry, nOldSize );
}
else
{
- memcpy( pPointAry, pOldPointAry, nSize*sizeof( Point ) );
+ memcpy( pPointAry.get(), pOldPointAry, nSize*sizeof( Point ) );
memcpy( pFlagAry.get(), pOldFlagAry, nSize );
// adjust number of valid points
@@ -168,7 +168,7 @@ void ImpXPolygon::InsertSpace( sal_uInt16 nPos, sal_uInt16 nCount )
nMove * sizeof(Point) );
memmove( &pFlagAry[nPos+nCount], &pFlagAry[nPos], nMove );
}
- std::fill(pPointAry + nPos, pPointAry + nPos + nCount, Point());
+ std::fill(pPointAry.get() + nPos, pPointAry.get() + nPos + nCount, Point());
memset( &pFlagAry [nPos], 0, nCount );
nPoints = nPoints + nCount;
@@ -188,7 +188,7 @@ void ImpXPolygon::Remove( sal_uInt16 nPos, sal_uInt16 nCount )
nMove * sizeof(Point) );
memmove( &pFlagAry[nPos], &pFlagAry[nPos+nCount], nMove );
}
- std::fill(pPointAry + (nPoints - nCount), pPointAry + nPoints, Point());
+ std::fill(pPointAry.get() + (nPoints - nCount), pPointAry.get() + nPoints, Point());
memset( &pFlagAry [nPoints - nCount], 0, nCount );
nPoints = nPoints - nCount;
}
@@ -348,7 +348,7 @@ void XPolygon::SetPointCount( sal_uInt16 nPoints )
{
sal_uInt16 nSize = pImpXPolygon->nPoints - nPoints;
std::fill(
- pImpXPolygon->pPointAry + nPoints, pImpXPolygon->pPointAry + nPoints + nSize, Point());
+ pImpXPolygon->pPointAry.get() + nPoints, pImpXPolygon->pPointAry.get() + nPoints + nSize, Point());
memset( &pImpXPolygon->pFlagAry [nPoints], 0, nSize );
}
pImpXPolygon->nPoints = nPoints;
@@ -383,7 +383,7 @@ void XPolygon::Insert( sal_uInt16 nPos, const XPolygon& rXPoly )
pImpXPolygon->InsertSpace( nPos, nPoints );
memcpy( &(pImpXPolygon->pPointAry[nPos]),
- rXPoly.pImpXPolygon->pPointAry,
+ rXPoly.pImpXPolygon->pPointAry.get(),
nPoints*sizeof( Point ) );
memcpy( &(pImpXPolygon->pFlagAry[nPos]),
rXPoly.pImpXPolygon->pFlagAry.get(),
@@ -516,7 +516,7 @@ double XPolygon::CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2)
void XPolygon::SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT)
{
- Point* pPoints = pImpXPolygon->pPointAry;
+ Point* pPoints = pImpXPolygon->pPointAry.get();
double fT2 = fT * fT;
double fT3 = fT * fT2;
double fU = 1.0 - fT;
@@ -565,7 +565,7 @@ void XPolygon::GenBezArc(const Point& rCenter, long nRx, long nRy,
long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd,
sal_uInt16 nQuad, sal_uInt16 nFirst)
{
- Point* pPoints = pImpXPolygon->pPointAry;
+ Point* pPoints = pImpXPolygon->pPointAry.get();
pPoints[nFirst ] = rCenter;
pPoints[nFirst+3] = rCenter;
@@ -647,7 +647,7 @@ void XPolygon::CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 n
nDrag = nPnt;
nPnt = nTmp;
}
- Point* pPoints = pImpXPolygon->pPointAry;
+ Point* pPoints = pImpXPolygon->pPointAry.get();
Point aDiff = pPoints[nDrag] - pPoints[nCenter];
double fDiv = CalcDistance(nCenter, nDrag);
@@ -703,7 +703,7 @@ void XPolygon::PointsToBezier(sal_uInt16 nFirst)
double fX0, fY0, fX1, fY1, fX2, fY2, fX3, fY3;
double fTx1, fTx2, fTy1, fTy2;
double fT1, fU1, fT2, fU2, fV;
- Point* pPoints = pImpXPolygon->pPointAry;
+ Point* pPoints = pImpXPolygon->pPointAry.get();
if ( nFirst > pImpXPolygon->nPoints - 4 || IsControl(nFirst) ||
IsControl(nFirst+1) || IsControl(nFirst+2) || IsControl(nFirst+3) )
@@ -842,7 +842,7 @@ basegfx::B2DPolygon XPolygon::getB2DPolygon() const
// #i74631# use tools Polygon class for conversion to not have the code doubled
// here. This needs one more conversion but avoids different convertors in
// the long run
- const tools::Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry, pImpXPolygon->pFlagAry.get());
+ const tools::Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry.get(), pImpXPolygon->pFlagAry.get());
return aSource.getB2DPolygon();
}