[Libreoffice-commits] core.git: 2 commits - cui/source include/svx
Noel Grandin
noel.grandin at collabora.co.uk
Mon Jun 25 07:12:25 UTC 2018
cui/source/inc/cuitabline.hxx | 8 ++-
cui/source/inc/numpages.hxx | 24 ++++-----
cui/source/tabpages/numpages.cxx | 96 ++++++++++++++-------------------------
cui/source/tabpages/tpline.cxx | 25 +++-------
include/svx/numvset.hxx | 5 --
5 files changed, 62 insertions(+), 96 deletions(-)
New commits:
commit 39e6bae2c4be24a3aad5ef8cd37d3d83c41a4abe
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jun 21 10:04:46 2018 +0200
loplugin:useuniqueptr in cui numpages
Change-Id: I22eaeecb06bcf46cc494e8a0326922600e131cf3
Reviewed-on: https://gerrit.libreoffice.org/56324
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx
index d5e92dc13be8..cac9a110959c 100644
--- a/cui/source/inc/numpages.hxx
+++ b/cui/source/inc/numpages.hxx
@@ -89,8 +89,8 @@ class SvxSingleNumPickTabPage final : public SfxTabPage
VclPtr<SvxNumValueSet> m_pExamplesVS;
SvxNumSettingsArr_Impl aNumSettingsArr;
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
sal_uInt16 nActNumLvl;
bool bModified : 1;
bool bPreset : 1;
@@ -122,8 +122,8 @@ class SvxBulletPickTabPage final : public SfxTabPage
using TabPage::DeactivatePage;
VclPtr<SvxNumValueSet> m_pExamplesVS;
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
sal_uInt16 nActNumLvl;
bool bModified : 1;
bool bPreset : 1;
@@ -164,8 +164,8 @@ class SvxNumPickTabPage final : public SfxTabPage
SvxNumSettingsArr_Impl aNumSettingsArrays[NUM_VALUSET_COUNT]; // is initialized with the five formats
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
sal_uInt16 nActNumLvl;
sal_uInt16 nNumItemId;
bool bModified : 1;
@@ -207,8 +207,8 @@ class SvxBitmapPickTabPage final : public SfxTabPage
std::vector<OUString> aGrfNames;
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
sal_uInt16 nActNumLvl;
sal_uInt16 nNumItemId;
MapUnit eCoreUnit;
@@ -283,8 +283,8 @@ class SvxNumOptionsTabPage : public SfxTabPage
Timer aInvalidateTimer;
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
Size aInitSize[SVX_MAX_NUM];
@@ -391,8 +391,8 @@ class SvxNumPositionTabPage : public SfxTabPage
VclPtr<SvxNumberingPreview> m_pPreviewWIN;
- SvxNumRule* pActNum;
- SvxNumRule* pSaveNum;
+ std::unique_ptr<SvxNumRule> pActNum;
+ std::unique_ptr<SvxNumRule> pSaveNum;
sal_uInt16 nActNumLvl;
sal_uInt16 nNumItemId;
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 439f1db1b656..60642f9d555f 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -220,10 +220,8 @@ SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage()
void SvxSingleNumPickTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pExamplesVS.clear();
SfxTabPage::dispose();
}
@@ -261,8 +259,7 @@ void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
if(pActNum && *pSaveNum != *pActNum)
{
@@ -270,7 +267,7 @@ void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
m_pExamplesVS->SetNoSelection();
}
- if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
+ if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
{
m_pExamplesVS->SelectItem(1);
NumSelectHdl_Impl(m_pExamplesVS);
@@ -306,11 +303,10 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet )
}
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
}
@@ -386,10 +382,8 @@ SvxBulletPickTabPage::~SvxBulletPickTabPage()
void SvxBulletPickTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pExamplesVS.clear();
SfxTabPage::dispose();
}
@@ -426,8 +420,7 @@ void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
if(pActNum && *pSaveNum != *pActNum)
{
@@ -435,7 +428,7 @@ void SvxBulletPickTabPage::ActivatePage(const SfxItemSet& rSet)
m_pExamplesVS->SetNoSelection();
}
- if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
+ if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
{
m_pExamplesVS->SelectItem(1);
NumSelectHdl_Impl(m_pExamplesVS);
@@ -470,11 +463,10 @@ void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet )
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
}
@@ -585,10 +577,8 @@ SvxNumPickTabPage::~SvxNumPickTabPage()
void SvxNumPickTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pExamplesVS.clear();
SfxTabPage::dispose();
}
@@ -625,8 +615,7 @@ void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
if(pActNum && *pSaveNum != *pActNum)
{
@@ -634,7 +623,7 @@ void SvxNumPickTabPage::ActivatePage(const SfxItemSet& rSet)
m_pExamplesVS->SetNoSelection();
}
- if(pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset))
+ if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset))
{
m_pExamplesVS->SelectItem(1);
NumSelectHdl_Impl(m_pExamplesVS);
@@ -669,11 +658,10 @@ void SvxNumPickTabPage::Reset( const SfxItemSet* rSet )
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
@@ -835,10 +823,8 @@ SvxBitmapPickTabPage::~SvxBitmapPickTabPage()
void SvxBitmapPickTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pBtBrowseFile.clear();
m_pErrorText.clear();
m_pExamplesVS.clear();
@@ -866,8 +852,7 @@ void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
if(pActNum && *pSaveNum != *pActNum)
{
@@ -876,7 +861,7 @@ void SvxBitmapPickTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(!aGrfNames.empty() &&
- (pActNum && (!lcl_IsNumFmtSet(pActNum, nActNumLvl) || bIsPreset)))
+ (pActNum && (lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset)))
{
m_pExamplesVS->SelectItem(1);
NumSelectHdl_Impl(m_pExamplesVS);
@@ -927,11 +912,10 @@ void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet )
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
}
@@ -1195,10 +1179,8 @@ SvxNumOptionsTabPage::~SvxNumOptionsTabPage()
void SvxNumOptionsTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pLevelLB.clear();
m_pFmtLB.clear();
m_pSeparatorFT.clear();
@@ -1264,8 +1246,7 @@ void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
bModified = (!pActNum->Get( 0 ) || bPreset);
@@ -1329,8 +1310,7 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
// insert levels
if(!m_pLevelLB->GetEntryCount())
@@ -1366,10 +1346,10 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
m_pLevelLB->SetUpdateMode(true);
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
- m_pPreviewWIN->SetNumRule(pActNum);
+ m_pPreviewWIN->SetNumRule(pActNum.get());
m_pSameLevelCB->Check(pActNum->IsContinuousNumbering());
SfxObjectShell* pShell;
@@ -2674,10 +2654,8 @@ SvxNumPositionTabPage::~SvxNumPositionTabPage()
void SvxNumPositionTabPage::dispose()
{
- delete pActNum;
- pActNum = nullptr;
- delete pSaveNum;
- pSaveNum = nullptr;
+ pActNum.reset();
+ pSaveNum.reset();
m_pLevelLB.clear();
m_pDistBorderFT.clear();
m_pDistBorderMF.clear();
@@ -2935,8 +2913,7 @@ void SvxNumPositionTabPage::ActivatePage(const SfxItemSet& rSet)
}
if(SfxItemState::SET == rSet.GetItemState(nNumItemId, false, &pItem))
{
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
}
bModified = (!pActNum->Get( 0 ) || bPreset);
if(*pSaveNum != *pActNum ||
@@ -3010,8 +2987,7 @@ void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet )
}
DBG_ASSERT(eState == SfxItemState::SET, "no item found!");
- delete pSaveNum;
- pSaveNum = new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule());
+ pSaveNum.reset( new SvxNumRule(*static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule()) );
// insert levels
if(!m_pLevelLB->GetEntryCount())
@@ -3048,10 +3024,10 @@ void SvxNumPositionTabPage::Reset( const SfxItemSet* rSet )
m_pLevelLB->SetUpdateMode(true);
if(!pActNum)
- pActNum = new SvxNumRule(*pSaveNum);
+ pActNum.reset( new SvxNumRule(*pSaveNum) );
else if(*pSaveNum != *pActNum)
*pActNum = *pSaveNum;
- m_pPreviewWIN->SetNumRule(pActNum);
+ m_pPreviewWIN->SetNumRule(pActNum.get());
InitPosAndSpaceMode();
ShowControlsDependingOnPosAndSpaceMode();
commit 592cbb6cdb1691e205d5bea3dd95d370fd119aa8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Jun 21 10:01:21 2018 +0200
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 <noel.grandin at collabora.co.uk>
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<SvxBrushItem> pBrushItem;
+ sal_uInt16 nItemId;
+};
class SvxLineTabPage : public SvxTabPage
{
@@ -132,7 +136,7 @@ private:
VclPtr<MetricField> m_pSymbolHeightMF;
VclPtr<CheckBox> m_pSymbolRatioCB;
std::vector<OUString> m_aGrfNames;
- std::vector< SvxBmpItemInfo* >
+ std::vector< std::unique_ptr<SvxBmpItemInfo> >
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<sal_uInt16>(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<SvxBmpItemInfo>(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<sal_uInt16>(MN_GALLERY_ENTRY + i + m_nNumMenuGalleryItems);
if ( static_cast<size_t>(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<SvxBmpItemInfo>(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
{
More information about the Libreoffice-commits
mailing list