Kaydet (Commit) f71f16b7 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr pass SgaObject around by std::unique_ptr

Change-Id: I88ef5de94f83cd8f7a7d2a60b072cc23bd147b27
Reviewed-on: https://gerrit.libreoffice.org/59009
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a84abd9e
......@@ -31,6 +31,7 @@
#include <svtools/transfer.hxx>
#include <svx/svdmodel.hxx>
#include <svx/galmisc.hxx>
#include <memory>
#include <vector>
class SotStorage;
......@@ -90,7 +91,7 @@ private:
bool bAbortActualize;
SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
SgaObject* ImplReadSgaObject( GalleryObject const * pEntry );
std::unique_ptr<SgaObject> ImplReadSgaObject( GalleryObject const * pEntry );
SAL_DLLPRIVATE bool ImplWriteSgaObject(const SgaObject& rObj, sal_uInt32 nPos, GalleryObject* pExistentEntry);
SAL_DLLPRIVATE void ImplWrite();
SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject(sal_uInt32 nPos) const
......@@ -122,8 +123,7 @@ public:
SAL_DLLPRIVATE sal_uInt32 GetObjectCount() const { return aObjectList.size(); }
SgaObject* AcquireObject(sal_uInt32 nPos);
static void ReleaseObject(SgaObject* pObj);
std::unique_ptr<SgaObject> AcquireObject(sal_uInt32 nPos);
bool InsertObject(const SgaObject& rObj, sal_uInt32 nPos = SAL_MAX_UINT32);
void RemoveObject(sal_uInt32 nPos);
......
......@@ -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")
......
......@@ -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);
}
}
......
......@@ -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 );
......
......@@ -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;
}
}
......
......@@ -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 );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment