summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-11 10:22:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-15 10:24:28 +0200
commitf71f16b742faa75fe0cab6b899b99ee42d5ec6c7 (patch)
tree04aad55b6ba9d5b5f9dbd577efd6bfb04c4e3d78 /svx
parenta84abd9e29b1920af87a1c7510bd92355594f9af (diff)
loplugin:useuniqueptr pass SgaObject around by std::unique_ptr
Change-Id: I88ef5de94f83cd8f7a7d2a60b072cc23bd147b27 Reviewed-on: https://gerrit.libreoffice.org/59009 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/gallery2/galbrws2.cxx4
-rw-r--r--svx/source/gallery2/galctrl.cxx9
-rw-r--r--svx/source/gallery2/galexpl.cxx3
-rw-r--r--svx/source/gallery2/galtheme.cxx27
-rw-r--r--svx/source/unogallery/unogalitem.cxx6
5 files changed, 17 insertions, 32 deletions
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
index 920057674fd8..342d041d7643 100644
--- a/svx/source/gallery2/galbrws2.cxx
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -1110,7 +1110,7 @@ void GalleryBrowser2::Execute(const OString &rIdent)
}
else if (rIdent == "title")
{
- SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
+ std::unique_ptr<SgaObject> pObj = mpCurTheme->AcquireObject( mnCurActionPos );
if( pObj )
{
@@ -1131,8 +1131,6 @@ void GalleryBrowser2::Execute(const OString &rIdent)
mpCurTheme->InsertObject( *pObj );
}
}
-
- GalleryTheme::ReleaseObject( pObj );
}
}
else if (rIdent == "copy")
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
index aa7a7c807b41..a41d820da345 100644
--- a/svx/source/gallery2/galctrl.cxx
+++ b/svx/source/gallery2/galctrl.cxx
@@ -323,7 +323,7 @@ void GalleryIconView::UserDraw(const UserDrawEvent& rUDEvt)
if (bNeedToCreate)
{
- SgaObject* pObj = mpTheme->AcquireObject(nId - 1);
+ std::unique_ptr<SgaObject> pObj = mpTheme->AcquireObject(nId - 1);
if(pObj)
{
@@ -331,7 +331,6 @@ void GalleryIconView::UserDraw(const UserDrawEvent& rUDEvt)
aItemTextTitle = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GalleryItemFlags::Title);
mpTheme->SetPreviewBitmapExAndStrings(nId - 1, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
- GalleryTheme::ReleaseObject(pObj);
}
}
@@ -441,12 +440,11 @@ OUString GalleryListView::GetCellText(long _nRow, sal_uInt16 /*nColumnId*/) cons
OUString sRet;
if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) )
{
- SgaObject* pObj = mpTheme->AcquireObject( _nRow );
+ std::unique_ptr<SgaObject> pObj = mpTheme->AcquireObject( _nRow );
if( pObj )
{
sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj, GalleryItemFlags::Title );
- GalleryTheme::ReleaseObject( pObj );
}
}
@@ -505,7 +503,7 @@ void GalleryListView::PaintField(vcl::RenderContext& rDev, const tools::Rectangl
if(bNeedToCreate)
{
- SgaObject* pObj = mpTheme->AcquireObject(mnCurRow);
+ std::unique_ptr<SgaObject> pObj = mpTheme->AcquireObject(mnCurRow);
if(pObj)
{
@@ -514,7 +512,6 @@ void GalleryListView::PaintField(vcl::RenderContext& rDev, const tools::Rectangl
aItemTextPath = GalleryBrowser2::GetItemText(*mpTheme, *pObj, GalleryItemFlags::Path);
mpTheme->SetPreviewBitmapExAndStrings(mnCurRow, aBitmapEx, aSize, aItemTextTitle, aItemTextPath);
- GalleryTheme::ReleaseObject(pObj);
}
}
diff --git a/svx/source/gallery2/galexpl.cxx b/svx/source/gallery2/galexpl.cxx
index 8379b616ba2f..ce8dea401515 100644
--- a/svx/source/gallery2/galexpl.cxx
+++ b/svx/source/gallery2/galexpl.cxx
@@ -93,12 +93,11 @@ bool GalleryExplorer::FillObjListTitle( const sal_uInt32 nThemeId, std::vector<
{
for( sal_uInt32 i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
{
- SgaObject* pObj = pTheme->AcquireObject( i );
+ std::unique_ptr<SgaObject> pObj = pTheme->AcquireObject( i );
if ( pObj )
{
OUString aTitle( pObj->GetTitle() );
rList.push_back( aTitle );
- GalleryTheme::ReleaseObject( pObj );
}
}
pGal->ReleaseTheme( pTheme, aListener );
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index b3d83ca70150..31fac1269a4d 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -146,9 +146,9 @@ bool GalleryTheme::ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, Ga
return bRet;
}
-SgaObject* GalleryTheme::ImplReadSgaObject( GalleryObject const * pEntry )
+std::unique_ptr<SgaObject> GalleryTheme::ImplReadSgaObject( GalleryObject const * pEntry )
{
- SgaObject* pSgaObj = nullptr;
+ std::unique_ptr<SgaObject> pSgaObj;
if( pEntry )
{
@@ -168,11 +168,11 @@ SgaObject* GalleryTheme::ImplReadSgaObject( GalleryObject const * pEntry )
switch( pEntry->eObjKind )
{
- case SgaObjKind::Bitmap: pSgaObj = new SgaObjectBmp(); break;
- case SgaObjKind::Animation: pSgaObj = new SgaObjectAnim(); break;
- case SgaObjKind::Inet: pSgaObj = new SgaObjectINet(); break;
- case SgaObjKind::SvDraw: pSgaObj = new SgaObjectSvDraw(); break;
- case SgaObjKind::Sound: pSgaObj = new SgaObjectSound(); break;
+ case SgaObjKind::Bitmap: pSgaObj.reset(new SgaObjectBmp()); break;
+ case SgaObjKind::Animation: pSgaObj.reset(new SgaObjectAnim()); break;
+ case SgaObjKind::Inet: pSgaObj.reset(new SgaObjectINet()); break;
+ case SgaObjKind::SvDraw: pSgaObj.reset(new SgaObjectSvDraw()); break;
+ case SgaObjKind::Sound: pSgaObj.reset(new SgaObjectSound()); break;
default:
break;
@@ -409,7 +409,7 @@ bool GalleryTheme::InsertObject(const SgaObject& rObj, sal_uInt32 nInsertPos)
return true;
}
-SgaObject* GalleryTheme::AcquireObject(sal_uInt32 nPos)
+std::unique_ptr<SgaObject> GalleryTheme::AcquireObject(sal_uInt32 nPos)
{
return ImplReadSgaObject(ImplGetGalleryObject(nPos));
}
@@ -448,11 +448,6 @@ void GalleryTheme::SetPreviewBitmapExAndStrings(sal_uInt32 nPos, const BitmapEx&
}
}
-void GalleryTheme::ReleaseObject( SgaObject* pObject )
-{
- delete pObject;
-}
-
void GalleryTheme::RemoveObject(sal_uInt32 nPos)
{
GalleryObject* pEntry = nullptr;
@@ -752,13 +747,12 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, bo
bool GalleryTheme::GetThumb(sal_uInt32 nPos, BitmapEx& rBmp)
{
- SgaObject* pObj = AcquireObject( nPos );
+ std::unique_ptr<SgaObject> pObj = AcquireObject( nPos );
bool bRet = false;
if( pObj )
{
rBmp = pObj->GetThumbBmp();
- ReleaseObject( pObj );
bRet = true;
}
@@ -816,7 +810,7 @@ bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
case SgaObjKind::Sound:
{
- SgaObject* pObj = AcquireObject( nPos );
+ std::unique_ptr<SgaObject> pObj = AcquireObject( nPos );
if( pObj )
{
@@ -824,7 +818,6 @@ bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
//Bitmap aBmp( pObj->GetThumbBmp() );
//aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
//rGraphic = aBmp;
- ReleaseObject( pObj );
bRet = true;
}
}
diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx
index 361edc2f9a55..89a2b316c269 100644
--- a/svx/source/unogallery/unogalitem.cxx
+++ b/svx/source/unogallery/unogalitem.cxx
@@ -272,12 +272,11 @@ void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEnt
if( pGalTheme )
{
- SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
+ std::unique_ptr<SgaObject> pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
if( pObj )
{
*pValue <<= pObj->GetTitle();
- ::GalleryTheme::ReleaseObject( pObj );
}
}
}
@@ -289,7 +288,7 @@ void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEnt
if( pGalTheme )
{
- SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
+ std::unique_ptr<SgaObject> pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
if( pObj )
{
@@ -301,7 +300,6 @@ void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEnt
aThumbnail = pObj->GetThumbMtf();
*pValue <<= aThumbnail.GetXGraphic();
- ::GalleryTheme::ReleaseObject( pObj );
}
}
}