From 592cbb6cdb1691e205d5bea3dd95d370fd119aa8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 21 Jun 2018 10:01:21 +0200 Subject: loplugin:useuniqueptr in SvxLineTabPage and move SvxBmpItemInfo inside cui/ since it is only used there. Change-Id: Ic80a8cace9e4664af18baddce3398e826e4c4851 Reviewed-on: https://gerrit.libreoffice.org/56323 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/inc/cuitabline.hxx | 8 ++++++-- cui/source/tabpages/tpline.cxx | 25 ++++++++----------------- include/svx/numvset.hxx | 5 ----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/cui/source/inc/cuitabline.hxx b/cui/source/inc/cuitabline.hxx index 9f2ccc13ae4e..abce5666f58d 100644 --- a/cui/source/inc/cuitabline.hxx +++ b/cui/source/inc/cuitabline.hxx @@ -78,7 +78,11 @@ public: /*************************************************************************/ -struct SvxBmpItemInfo; +struct SvxBmpItemInfo +{ + std::unique_ptr pBrushItem; + sal_uInt16 nItemId; +}; class SvxLineTabPage : public SvxTabPage { @@ -132,7 +136,7 @@ private: VclPtr m_pSymbolHeightMF; VclPtr m_pSymbolRatioCB; std::vector m_aGrfNames; - std::vector< SvxBmpItemInfo* > + std::vector< std::unique_ptr > m_aGrfBrushItems; bool m_bLastWidthModified; Size m_aSymbolLastSize; diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 2dd8adbd01a0..5a633ac06dd1 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -227,11 +227,6 @@ SvxLineTabPage::~SvxLineTabPage() void SvxLineTabPage::dispose() { - for (SvxBmpItemInfo* pInfo : m_aGrfBrushItems) - { - delete pInfo->pBrushItem; - delete pInfo; - } m_aGrfBrushItems.clear(); m_pBoxColor.clear(); @@ -294,19 +289,17 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton) pUIName = &aPhysicalName; } - SvxBrushItem* pBrushItem = new SvxBrushItem(grfName, "", GPOS_AREA, SID_ATTR_BRUSH); - SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; - pInfo->pBrushItem = pBrushItem; + pInfo->pBrushItem.reset(new SvxBrushItem(grfName, "", GPOS_AREA, SID_ATTR_BRUSH)); pInfo->nItemId = static_cast(MN_GALLERY_ENTRY + i); if ( i < m_aGrfBrushItems.size() ) { - m_aGrfBrushItems.insert( m_aGrfBrushItems.begin() + i, pInfo ); + m_aGrfBrushItems.insert( m_aGrfBrushItems.begin() + i, std::unique_ptr(pInfo) ); } else { - m_aGrfBrushItems.push_back( pInfo ); + m_aGrfBrushItems.emplace_back( pInfo ); } - const Graphic* pGraphic = pBrushItem->GetGraphic(); + const Graphic* pGraphic = pInfo->pBrushItem->GetGraphic(); if(pGraphic) { @@ -393,15 +386,13 @@ void SvxLineTabPage::InitSymbols(MenuButton const * pButton) pObj=pPage->RemoveObject(1); SdrObject::Free(pObj); - SvxBrushItem* pBrushItem = new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH); - SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; - pInfo->pBrushItem = pBrushItem; + pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); pInfo->nItemId = static_cast(MN_GALLERY_ENTRY + i + m_nNumMenuGalleryItems); if ( static_cast(m_nNumMenuGalleryItems + i) < m_aGrfBrushItems.size() ) { - m_aGrfBrushItems.insert( m_aGrfBrushItems.begin() + m_nNumMenuGalleryItems + i, pInfo ); + m_aGrfBrushItems.insert( m_aGrfBrushItems.begin() + m_nNumMenuGalleryItems + i, std::unique_ptr(pInfo) ); } else { - m_aGrfBrushItems.push_back( pInfo ); + m_aGrfBrushItems.emplace_back( pInfo ); } Size aSize(aBitmapEx.GetSizePixel()); @@ -448,7 +439,7 @@ void SvxLineTabPage::SymbolSelected(MenuButton const * pButton) m_nSymbolType=SVX_SYMBOLTYPE_BRUSHITEM; bResetSize = true; } - SvxBmpItemInfo* pInfo = m_aGrfBrushItems[ nItemId - MN_GALLERY_ENTRY ]; + SvxBmpItemInfo* pInfo = m_aGrfBrushItems[ nItemId - MN_GALLERY_ENTRY ].get(); pGraphic = pInfo->pBrushItem->GetGraphic(); } else switch(nItemId) diff --git a/include/svx/numvset.hxx b/include/svx/numvset.hxx index 2485a1476a38..63eae7cd77c1 100644 --- a/include/svx/numvset.hxx +++ b/include/svx/numvset.hxx @@ -41,11 +41,6 @@ namespace com{namespace sun{ namespace star{ class SvxBrushItem; class SvxNumRule; -struct SvxBmpItemInfo -{ - SvxBrushItem* pBrushItem; - sal_uInt16 nItemId; -}; enum class NumberingPageType { -- cgit