diff options
-rw-r--r-- | include/svtools/imap.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/bastyp/sfxhtml.cxx | 24 | ||||
-rw-r--r-- | svtools/source/misc/imap.cxx | 4 | ||||
-rw-r--r-- | svtools/source/uno/unoimap.cxx | 17 |
4 files changed, 25 insertions, 21 deletions
diff --git a/include/svtools/imap.hxx b/include/svtools/imap.hxx index af094cbab817..e0129bffce07 100644 --- a/include/svtools/imap.hxx +++ b/include/svtools/imap.hxx @@ -77,6 +77,7 @@ public: // a new IMap object is inserted at the end of the Map void InsertIMapObject( const IMapObject& rIMapObject ); + void InsertIMapObject( std::unique_ptr<IMapObject> rIMapObject ); // access to the single ImapObjects; the objects may // not be destroyed from outside diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index e64dd7ed714e..40095fdbb7fb 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -182,22 +182,22 @@ IMAPOBJ_SETEVENT: { tools::Rectangle aRect( aCoords[0], aCoords[1], aCoords[2], aCoords[3] ); - IMapRectangleObject aMapRObj( aRect, aHRef, aAlt, OUString(), aTarget, aName, - !bNoHRef ); + std::unique_ptr<IMapRectangleObject> pMapRObj( new IMapRectangleObject(aRect, aHRef, aAlt, OUString(), aTarget, aName, + !bNoHRef )); if( !aMacroTbl.empty() ) - aMapRObj.SetMacroTable( aMacroTbl ); - pImageMap->InsertIMapObject( aMapRObj ); + pMapRObj->SetMacroTable( aMacroTbl ); + pImageMap->InsertIMapObject( std::move(pMapRObj) ); } break; case IMAP_OBJ_CIRCLE: if( aCoords.size() >=3 ) { Point aPoint( aCoords[0], aCoords[1] ); - IMapCircleObject aMapCObj( aPoint, aCoords[2],aHRef, aAlt, OUString(), - aTarget, aName, !bNoHRef ); + std::unique_ptr<IMapCircleObject> pMapCObj(new IMapCircleObject(aPoint, aCoords[2],aHRef, aAlt, OUString(), + aTarget, aName, !bNoHRef )); if( !aMacroTbl.empty() ) - aMapCObj.SetMacroTable( aMacroTbl ); - pImageMap->InsertIMapObject( aMapCObj ); + pMapCObj->SetMacroTable( aMacroTbl ); + pImageMap->InsertIMapObject( std::move(pMapCObj) ); } break; case IMAP_OBJ_POLYGON: @@ -207,11 +207,11 @@ IMAPOBJ_SETEVENT: tools::Polygon aPoly( nCount ); for( sal_uInt16 i=0; i<nCount; i++ ) aPoly[i] = Point( aCoords[2*i], aCoords[2*i+1] ); - IMapPolygonObject aMapPObj( aPoly, aHRef, aAlt, OUString(), aTarget, aName, - !bNoHRef ); + std::unique_ptr<IMapPolygonObject> pMapPObj(new IMapPolygonObject( aPoly, aHRef, aAlt, OUString(), aTarget, aName, + !bNoHRef )); if( !aMacroTbl.empty() ) - aMapPObj.SetMacroTable( aMacroTbl ); - pImageMap->InsertIMapObject( aMapPObj ); + pMapPObj->SetMacroTable( aMacroTbl ); + pImageMap->InsertIMapObject( std::move(pMapPObj) ); } break; default: 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) ); } } |