summaryrefslogtreecommitdiff
path: root/cppcanvas/source/mtfrenderer/emfpbrush.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-16 14:03:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-19 08:58:46 +0200
commit6f2db2c124c3054d2895c797f2564cff51bdfdda (patch)
tree9598f9304f1fa084ecb3e9e483e35db16eaab18f /cppcanvas/source/mtfrenderer/emfpbrush.cxx
parent96c85e7d107ad0d79295349f01cd8578ce7daeba (diff)
loplugin:useuniqueptr in EMFPBrush
Change-Id: I17fc33cfd7c15734fd961fa76c676424900a4373
Diffstat (limited to 'cppcanvas/source/mtfrenderer/emfpbrush.cxx')
-rw-r--r--cppcanvas/source/mtfrenderer/emfpbrush.cxx43
1 files changed, 12 insertions, 31 deletions
diff --git a/cppcanvas/source/mtfrenderer/emfpbrush.cxx b/cppcanvas/source/mtfrenderer/emfpbrush.cxx
index fb8a41c5d846..d46ddd4698cd 100644
--- a/cppcanvas/source/mtfrenderer/emfpbrush.cxx
+++ b/cppcanvas/source/mtfrenderer/emfpbrush.cxx
@@ -67,26 +67,7 @@ namespace cppcanvas
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;
- }
+ path.reset();
}
void EMFPBrush::Read(SvStream& s, ImplRenderer const & rR)
@@ -149,7 +130,7 @@ namespace cppcanvas
if (surroundColorsNumber<0 || sal_uInt32(surroundColorsNumber)>SAL_MAX_INT32 / sizeof(::Color))
surroundColorsNumber = SAL_MAX_INT32 / sizeof(::Color);
- surroundColors = new ::Color[surroundColorsNumber];
+ surroundColors.reset( new ::Color[surroundColorsNumber] );
for (int i = 0; i < surroundColorsNumber; i++) {
s.ReadUInt32(color);
surroundColors[i] = ::Color(0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
@@ -173,7 +154,7 @@ namespace cppcanvas
SAL_INFO("cppcanvas.emf", "EMF+\tpath (brush path gradient)");
SAL_INFO("cppcanvas.emf", "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, rR);
s.Seek(pos + pathLength);
@@ -190,7 +171,7 @@ namespace cppcanvas
sal_uInt64 const pos = s.Tell();
SAL_INFO("cppcanvas.emf", "EMF+\t use boundary, points: " << boundaryPointCount);
- path = new EMFPPath(boundaryPointCount);
+ path.reset( new EMFPPath(boundaryPointCount) );
path->Read(s, 0x0, rR);
s.Seek(pos + 8 * boundaryPointCount);
@@ -216,8 +197,8 @@ namespace cppcanvas
SAL_INFO("cppcanvas.emf", "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++) {
s.ReadFloat(blendPositions[i]);
SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions[i]);
@@ -235,8 +216,8 @@ namespace cppcanvas
colorblendPoints = SAL_MAX_INT32 / sizeof(float);
if (sal_uInt32(colorblendPoints)>SAL_MAX_INT32 / sizeof(::Color))
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++) {
s.ReadFloat(colorblendPositions[i]);
SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions[i]);
@@ -288,8 +269,8 @@ namespace cppcanvas
SAL_INFO("cppcanvas.emf", "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++) {
s.ReadFloat(blendPositions[i]);
SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions[i]);
@@ -307,8 +288,8 @@ namespace cppcanvas
colorblendPoints = SAL_MAX_INT32 / sizeof(float);
if (sal_uInt32(colorblendPoints)>SAL_MAX_INT32 / sizeof(::Color))
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++) {
s.ReadFloat(colorblendPositions[i]);
SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions[i]);