summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-16 14:40:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-19 08:58:46 +0200
commit9653ac69f8c9fdfcd353a1b15c701139dd541e9b (patch)
tree89c1f386b73f74f71009a65545085d97bd74d934 /drawinglayer
parentfb3091bfc73cb321017f47d87dc8cb782b9a58d8 (diff)
loplugin:useuniqueptr in EMFPBrush
Change-Id: I86622a13583137605bf2b6468113da2eb5e4ee0b
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/tools/emfpbrush.cxx51
-rw-r--r--drawinglayer/source/tools/emfpbrush.hxx10
2 files changed, 16 insertions, 45 deletions
diff --git a/drawinglayer/source/tools/emfpbrush.cxx b/drawinglayer/source/tools/emfpbrush.cxx
index 68ec151a6fe8..c454c940dc03 100644
--- a/drawinglayer/source/tools/emfpbrush.cxx
+++ b/drawinglayer/source/tools/emfpbrush.cxx
@@ -64,35 +64,6 @@ namespace emfplushelper
EMFPBrush::~EMFPBrush()
{
- if (blendPositions != nullptr)
- {
- delete[] blendPositions;
- blendPositions = nullptr;
- }
-
- if (colorblendPositions != nullptr)
- {
- delete[] colorblendPositions;
- colorblendPositions = nullptr;
- }
-
- if (colorblendColors != nullptr)
- {
- delete[] colorblendColors;
- colorblendColors = nullptr;
- }
-
- if (surroundColors != nullptr)
- {
- delete[] surroundColors;
- surroundColors = nullptr;
- }
-
- if (path)
- {
- delete path;
- path = nullptr;
- }
}
void EMFPBrush::Read(SvStream& s, EmfPlusHelperData const & rR)
@@ -153,7 +124,7 @@ namespace emfplushelper
surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color);
}
- surroundColors = new ::Color[surroundColorsNumber];
+ surroundColors.reset( new ::Color[surroundColorsNumber] );
for (int i = 0; i < surroundColorsNumber; i++)
{
@@ -180,7 +151,7 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\tpath (brush path gradient)");
SAL_INFO("drawinglayer", "EMF+\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec);
- path = new EMFPPath(pathPoints);
+ path.reset( new EMFPPath(pathPoints) );
path->Read(s, pathFlags);
s.Seek(pos + pathLength);
@@ -197,7 +168,7 @@ namespace emfplushelper
sal_uInt64 const pos = s.Tell();
SAL_INFO("drawinglayer", "EMF+\t use boundary, points: " << boundaryPointCount);
- path = new EMFPPath(boundaryPointCount);
+ path.reset( new EMFPPath(boundaryPointCount) );
path->Read(s, 0x0);
s.Seek(pos + 8 * boundaryPointCount);
@@ -221,8 +192,8 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\tuse blend, points: " << blendPoints);
if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float)))
blendPoints = SAL_MAX_INT32 / (2 * sizeof(float));
- blendPositions = new float[2 * blendPoints];
- blendFactors = blendPositions + blendPoints;
+ blendPositions.reset( new float[2 * blendPoints] );
+ blendFactors = blendPositions.get() + blendPoints;
for (int i = 0; i < blendPoints; i++)
{
@@ -252,8 +223,8 @@ namespace emfplushelper
colorblendPoints = SAL_MAX_INT32 / sizeof(::Color);
}
- colorblendPositions = new float[colorblendPoints];
- colorblendColors = new ::Color[colorblendPoints];
+ colorblendPositions.reset( new float[colorblendPoints] );
+ colorblendColors.reset( new ::Color[colorblendPoints] );
for (int i = 0; i < colorblendPoints; i++)
{
@@ -302,8 +273,8 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\tuse blend, points: " << blendPoints);
if (blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32 / (2 * sizeof(float)))
blendPoints = SAL_MAX_INT32 / (2 * sizeof(float));
- blendPositions = new float[2 * blendPoints];
- blendFactors = blendPositions + blendPoints;
+ blendPositions.reset( new float[2 * blendPoints] );
+ blendFactors = blendPositions.get() + blendPoints;
for (int i = 0; i < blendPoints; i++)
{
@@ -333,8 +304,8 @@ namespace emfplushelper
colorblendPoints = sal_uInt32(SAL_MAX_INT32) / sizeof(::Color);
}
- colorblendPositions = new float[colorblendPoints];
- colorblendColors = new ::Color[colorblendPoints];
+ colorblendPositions.reset( new float[colorblendPoints] );
+ colorblendColors.reset( new ::Color[colorblendPoints] );
for (int i = 0; i < colorblendPoints; i++)
{
diff --git a/drawinglayer/source/tools/emfpbrush.hxx b/drawinglayer/source/tools/emfpbrush.hxx
index 6a03f6f50e51..b73507817de7 100644
--- a/drawinglayer/source/tools/emfpbrush.hxx
+++ b/drawinglayer/source/tools/emfpbrush.hxx
@@ -107,14 +107,14 @@ namespace emfplushelper
basegfx::B2DHomMatrix brush_transformation;
bool hasTransformation;
sal_Int32 blendPoints;
- float* blendPositions;
+ std::unique_ptr<float[]> blendPositions;
float* blendFactors;
sal_Int32 colorblendPoints;
- float* colorblendPositions;
- ::Color* colorblendColors;
+ std::unique_ptr<float[]> colorblendPositions;
+ std::unique_ptr<::Color[]> colorblendColors;
sal_Int32 surroundColorsNumber;
- ::Color* surroundColors;
- EMFPPath *path;
+ std::unique_ptr<::Color[]> surroundColors;
+ std::unique_ptr<EMFPPath> path;
EmfPlusHatchStyle hatchStyle;
EMFPBrush();