summaryrefslogtreecommitdiff
path: root/cppcanvas
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-05 08:57:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-05 11:30:12 +0200
commitb0e05f9ade9e93c569c6a62c59ac1819e615f27b (patch)
tree61cbf40294b73e5dbc92213c23f1d89dd8998092 /cppcanvas
parent1a637473b5aa6a43acb4d1f820044fba962cc6a4 (diff)
loplugin:useuniqueptr in basic..cppcanvas
Change-Id: Ib40241eb794607154ae52f8aa68fbf5ea5e944af Reviewed-on: https://gerrit.libreoffice.org/39551 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppcanvas')
-rw-r--r--cppcanvas/source/mtfrenderer/emfppath.cxx8
-rw-r--r--cppcanvas/source/mtfrenderer/emfppath.hxx6
-rwxr-xr-xcppcanvas/source/mtfrenderer/emfppen.cxx21
-rwxr-xr-xcppcanvas/source/mtfrenderer/emfppen.hxx7
4 files changed, 16 insertions, 26 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfppath.cxx b/cppcanvas/source/mtfrenderer/emfppath.cxx
index d924ce61d816..749bc900cc62 100644
--- a/cppcanvas/source/mtfrenderer/emfppath.cxx
+++ b/cppcanvas/source/mtfrenderer/emfppath.cxx
@@ -50,17 +50,13 @@ namespace cppcanvas
if( _nPoints<0 || sal_uInt32(_nPoints)>SAL_MAX_INT32/(2*sizeof(float)) )
_nPoints = SAL_MAX_INT32/(2*sizeof(float));
nPoints = _nPoints;
- pPoints = new float [nPoints*2];
+ pPoints.reset( new float [nPoints*2] );
if (!bLines)
- pPointTypes = new sal_uInt8 [_nPoints];
- else
- pPointTypes = nullptr;
+ pPointTypes.reset( new sal_uInt8 [_nPoints] );
}
EMFPPath::~EMFPPath ()
{
- delete [] pPoints;
- delete [] pPointTypes;
}
// TODO: remove rR argument when debug code is no longer needed
diff --git a/cppcanvas/source/mtfrenderer/emfppath.hxx b/cppcanvas/source/mtfrenderer/emfppath.hxx
index 7ced476358e9..f4e92937e432 100644
--- a/cppcanvas/source/mtfrenderer/emfppath.hxx
+++ b/cppcanvas/source/mtfrenderer/emfppath.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPATH_HXX
#define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPATH_HXX
+#include <memory>
+
namespace cppcanvas
{
namespace internal
@@ -28,8 +30,8 @@ namespace cppcanvas
{
::basegfx::B2DPolyPolygon aPolygon;
sal_Int32 nPoints;
- float* pPoints;
- sal_uInt8* pPointTypes;
+ std::unique_ptr<float[]> pPoints;
+ std::unique_ptr<sal_uInt8[]> pPointTypes;
EMFPPath(sal_Int32 _nPoints, bool bLines = false);
diff --git a/cppcanvas/source/mtfrenderer/emfppen.cxx b/cppcanvas/source/mtfrenderer/emfppen.cxx
index b3b0c97dcb8a..36cf63acdf72 100755
--- a/cppcanvas/source/mtfrenderer/emfppen.cxx
+++ b/cppcanvas/source/mtfrenderer/emfppen.cxx
@@ -81,11 +81,7 @@ namespace cppcanvas
, dashStyle(0)
, dashCap(0)
, dashOffset(0.0)
- , dashPatternLen(0)
- , dashPattern(nullptr)
, alignment(0)
- , compoundArrayLen(0)
- , compoundArray(nullptr)
, customStartCapLen(0)
, customStartCap(nullptr)
, customEndCapLen(0)
@@ -95,8 +91,6 @@ namespace cppcanvas
EMFPPen::~EMFPPen()
{
- delete[] dashPattern;
- delete[] compoundArray;
delete customStartCap;
delete customEndCap;
}
@@ -162,7 +156,7 @@ namespace cppcanvas
case EmfPlusLineStyleDot: nLen = SAL_N_ELEMENTS(dot); pPattern = dot; break;
case EmfPlusLineStyleDashDot: nLen = SAL_N_ELEMENTS(dashdot); pPattern = dashdot; break;
case EmfPlusLineStyleDashDotDot: nLen = SAL_N_ELEMENTS(dashdotdot); pPattern = dashdotdot; break;
- case EmfPlusLineStyleCustom: nLen = dashPatternLen; pPattern = dashPattern; break;
+ case EmfPlusLineStyleCustom: nLen = dashPattern.size(); pPattern = dashPattern.data(); break;
}
if (nLen > 0)
{
@@ -236,37 +230,36 @@ namespace cppcanvas
if (penDataFlags & PenDataDashedLine)
{
dashStyle = EmfPlusLineStyleCustom;
+ sal_Int32 dashPatternLen;
s.ReadInt32(dashPatternLen);
SAL_INFO("cppcanvas.emf", "EMF+\t\tdashPatternLen: " << dashPatternLen);
if (dashPatternLen<0 || sal_uInt32(dashPatternLen)>SAL_MAX_INT32 / sizeof(float))
dashPatternLen = SAL_MAX_INT32 / sizeof(float);
- dashPattern = new float[dashPatternLen];
+ dashPattern.resize( dashPatternLen );
for (i = 0; i < dashPatternLen; i++)
{
s.ReadFloat(dashPattern[i]);
SAL_INFO("cppcanvas.emf", "EMF+\t\t\tdashPattern[" << i << "]: " << dashPattern[i]);
}
}
- else
- dashPatternLen = 0;
if (penDataFlags & PenDataNonCenter)
s.ReadInt32(alignment);
else
alignment = 0;
- if (penDataFlags & PenDataCompoundLine) {
+ if (penDataFlags & PenDataCompoundLine)
+ {
+ sal_Int32 compoundArrayLen;
s.ReadInt32(compoundArrayLen);
if (compoundArrayLen<0 || sal_uInt32(compoundArrayLen)>SAL_MAX_INT32 / sizeof(float))
compoundArrayLen = SAL_MAX_INT32 / sizeof(float);
- compoundArray = new float[compoundArrayLen];
+ compoundArray.resize(compoundArrayLen);
for (i = 0; i < compoundArrayLen; i++)
s.ReadFloat(compoundArray[i]);
}
- else
- compoundArrayLen = 0;
if (penDataFlags & PenDataCustomStartCap)
{
diff --git a/cppcanvas/source/mtfrenderer/emfppen.hxx b/cppcanvas/source/mtfrenderer/emfppen.hxx
index f4b1650b0bf1..7e2bd9e8e7db 100755
--- a/cppcanvas/source/mtfrenderer/emfppen.hxx
+++ b/cppcanvas/source/mtfrenderer/emfppen.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_CPPCANVAS_SOURCE_MTFRENDERER_EMFPPEN_HXX
#include <emfpbrush.hxx>
+#include <vector>
namespace cppcanvas
{
@@ -47,11 +48,9 @@ namespace cppcanvas
sal_Int32 dashStyle;
sal_Int32 dashCap;
float dashOffset;
- sal_Int32 dashPatternLen;
- float *dashPattern;
+ std::vector<float> dashPattern;
sal_Int32 alignment;
- sal_Int32 compoundArrayLen;
- float *compoundArray;
+ std::vector<float> compoundArray;
sal_Int32 customStartCapLen;
EMFPCustomLineCap *customStartCap;
sal_Int32 customEndCapLen;