summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-15 00:49:33 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-15 11:01:31 +0200
commit96775f3e3c33a92722ee0595fb29e987029ad646 (patch)
tree14f9523f729399bbc92ccafa8e81945d54dfa52d /drawinglayer
parenta2e25af0ec427d9c86228ecec349ea2d303abbe1 (diff)
loplugin:useuniqueptr in basic..cppcanvas
Porting over b0e05f9ade9e93c569c6a62c59ac1819e615f27b to copies of emfpp*.[ch]xx Change-Id: I059d2cc371f24ce3d43fc2e255b1dc1c227cf555
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/tools/emfppath.cxx8
-rw-r--r--drawinglayer/source/tools/emfppath.hxx5
-rw-r--r--drawinglayer/source/tools/emfppen.cxx23
-rw-r--r--drawinglayer/source/tools/emfppen.hxx7
4 files changed, 14 insertions, 29 deletions
diff --git a/drawinglayer/source/tools/emfppath.cxx b/drawinglayer/source/tools/emfppath.cxx
index 64b3411e4b49..d68fd425994c 100644
--- a/drawinglayer/source/tools/emfppath.cxx
+++ b/drawinglayer/source/tools/emfppath.cxx
@@ -50,18 +50,14 @@ namespace emfplushelper
}
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/drawinglayer/source/tools/emfppath.hxx b/drawinglayer/source/tools/emfppath.hxx
index 64c7c39c7438..1e8c69771f59 100644
--- a/drawinglayer/source/tools/emfppath.hxx
+++ b/drawinglayer/source/tools/emfppath.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_DRAWINGLAYER_SOURCE_TOOLS_EMFPPATH_HXX
#include <emfphelperdata.hxx>
+#include <memory>
namespace emfplushelper
{
@@ -28,8 +29,8 @@ namespace emfplushelper
{
::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/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index cb8bbf4cb8d5..9bc66e6716af 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -77,11 +77,7 @@ namespace emfplushelper
, dashStyle(0)
, dashCap(0)
, dashOffset(0.0)
- , dashPatternLen(0)
- , dashPattern(nullptr)
, alignment(0)
- , compoundArrayLen(0)
- , compoundArray(nullptr)
, customStartCapLen(0)
, customStartCap(nullptr)
, customEndCapLen(0)
@@ -91,8 +87,6 @@ namespace emfplushelper
EMFPPen::~EMFPPen()
{
- delete[] dashPattern;
- delete[] compoundArray;
delete customStartCap;
delete customEndCap;
}
@@ -159,7 +153,7 @@ namespace emfplushelper
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)
@@ -256,6 +250,8 @@ namespace emfplushelper
if (penDataFlags & PenDataDashedLine)
{
dashStyle = EmfPlusLineStyleCustom;
+ sal_Int32 dashPatternLen;
+
s.ReadInt32(dashPatternLen);
SAL_INFO("cppcanvas.emf", "EMF+\t\tdashPatternLen: " << dashPatternLen);
@@ -264,7 +260,7 @@ namespace emfplushelper
dashPatternLen = SAL_MAX_INT32 / sizeof(float);
}
- dashPattern = new float[dashPatternLen];
+ dashPattern.resize( dashPatternLen );
for (i = 0; i < dashPatternLen; i++)
{
@@ -272,10 +268,6 @@ namespace emfplushelper
SAL_INFO("cppcanvas.emf", "EMF+\t\t\tdashPattern[" << i << "]: " << dashPattern[i]);
}
}
- else
- {
- dashPatternLen = 0;
- }
if (penDataFlags & PenDataNonCenter)
{
@@ -288,6 +280,7 @@ namespace emfplushelper
if (penDataFlags & PenDataCompoundLine)
{
+ sal_Int32 compoundArrayLen;
s.ReadInt32(compoundArrayLen);
if (compoundArrayLen<0 || sal_uInt32(compoundArrayLen)>SAL_MAX_INT32 / sizeof(float))
@@ -295,17 +288,13 @@ namespace emfplushelper
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/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx
index c4a260f6e4a3..c338fef62029 100644
--- a/drawinglayer/source/tools/emfppen.hxx
+++ b/drawinglayer/source/tools/emfppen.hxx
@@ -22,6 +22,7 @@
#include <emfpbrush.hxx>
#include <com/sun/star/rendering/StrokeAttributes.hpp>
+#include <vector>
namespace emfplushelper
{
@@ -46,11 +47,9 @@ namespace emfplushelper
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;