summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-13 14:49:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-15 08:40:38 +0200
commit3deaeb9380d43d35cba82e1427492ca6ad0ea01f (patch)
tree39bbf725b963512d6cf9e451ec5e6e06f67ada0f /svtools
parent9467f10de690c622a210120e1963b2d755875a6b (diff)
pass IMapObject around by std::unique_ptr
and avoid some unnecessary copying Change-Id: Ieb9b1fe169a7d56197bf1e054e9af5dca7804301 Reviewed-on: https://gerrit.libreoffice.org/59019 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/misc/imap.cxx4
-rw-r--r--svtools/source/uno/unoimap.cxx17
2 files changed, 12 insertions, 9 deletions
diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx
index 5118f52db82d..4e23ef612173 100644
--- a/svtools/source/misc/imap.cxx
+++ b/svtools/source/misc/imap.cxx
@@ -758,6 +758,10 @@ void ImageMap::InsertIMapObject( const IMapObject& rIMapObject )
}
}
+void ImageMap::InsertIMapObject( std::unique_ptr<IMapObject> pNewObject )
+{
+ maList.emplace_back( std::move(pNewObject) );
+}
/******************************************************************************
|*
diff --git a/svtools/source/uno/unoimap.cxx b/svtools/source/uno/unoimap.cxx
index 4c337df681d3..2999b5aff1a3 100644
--- a/svtools/source/uno/unoimap.cxx
+++ b/svtools/source/uno/unoimap.cxx
@@ -78,7 +78,7 @@ public:
UNO3_GETIMPLEMENTATION_DECL( SvUnoImageMapObject )
- IMapObject* createIMapObject() const;
+ std::unique_ptr<IMapObject> createIMapObject() const;
rtl::Reference<SvMacroTableEventDescriptor> mxEvents;
@@ -246,7 +246,7 @@ SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const Sv
mxEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems );
}
-IMapObject* SvUnoImageMapObject::createIMapObject() const
+std::unique_ptr<IMapObject> SvUnoImageMapObject::createIMapObject() const
{
const OUString aURL( maURL );
const OUString aAltText( maAltText );
@@ -254,21 +254,21 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const
const OUString aTarget( maTarget );
const OUString aName( maName );
- IMapObject* pNewIMapObject;
+ std::unique_ptr<IMapObject> pNewIMapObject;
switch( mnType )
{
case IMAP_OBJ_RECTANGLE:
{
const tools::Rectangle aRect( maBoundary.X, maBoundary.Y, maBoundary.X + maBoundary.Width - 1, maBoundary.Y + maBoundary.Height - 1 );
- pNewIMapObject = new IMapRectangleObject( aRect, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false );
+ pNewIMapObject.reset(new IMapRectangleObject( aRect, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
}
break;
case IMAP_OBJ_CIRCLE:
{
const Point aCenter( maCenter.X, maCenter.Y );
- pNewIMapObject = new IMapCircleObject( aCenter, mnRadius, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false );
+ pNewIMapObject.reset(new IMapCircleObject( aCenter, mnRadius, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
}
break;
@@ -285,7 +285,7 @@ IMapObject* SvUnoImageMapObject::createIMapObject() const
}
aPoly.Optimize( PolyOptimizeFlags::CLOSE );
- pNewIMapObject = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false );
+ pNewIMapObject.reset(new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
}
break;
}
@@ -675,9 +675,8 @@ void SvUnoImageMap::fillImageMap( ImageMap& rMap ) const
for (auto const& elem : maObjectList)
{
- IMapObject* pNewMapObject = elem->createIMapObject();
- rMap.InsertIMapObject( *pNewMapObject );
- delete pNewMapObject;
+ std::unique_ptr<IMapObject> pNewMapObject = elem->createIMapObject();
+ rMap.InsertIMapObject( std::move(pNewMapObject) );
}
}