summaryrefslogtreecommitdiff
path: root/cui/source/customize
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-13 11:57:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-13 12:40:42 +0100
commit00431a8afcad08da11835131c2cd423d7f8cd115 (patch)
tree784ae98f19af2d303e9141d6cfe5c9151864a558 /cui/source/customize
parentfd877edc1822816be04b2e2fa0f883c00b5d2fb0 (diff)
loplugin:useuniqueptr in SvxEntries
Change-Id: I4e105326ddba11822beb9affe97196c77a5baf4b Reviewed-on: https://gerrit.libreoffice.org/51203 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/SvxMenuConfigPage.cxx2
-rw-r--r--cui/source/customize/cfg.cxx41
2 files changed, 15 insertions, 28 deletions
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 75fbaa16378b..202ffaebef8c 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -320,7 +320,7 @@ IMPL_LINK( SvxMenuConfigPage, GearHdl, MenuButton *, pButton, void )
if ( pDialog->Execute() == RET_OK )
{
- GetSaveInData()->SetEntries( pDialog->GetEntries() );
+ GetSaveInData()->SetEntries( pDialog->ReleaseEntries() );
ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
GetSaveInData()->SetModified();
}
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index e90bfa358621..5762979a7528 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -440,13 +440,9 @@ MenuSaveInData::GetEntries()
}
void
-MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
+MenuSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
{
- // delete old menu hierarchy first
- delete pRootEntry->GetEntries();
-
- // now set new menu hierarchy
- pRootEntry->SetEntries( pNewEntries );
+ pRootEntry->SetEntries( std::move(pNewEntries) );
}
bool SaveInData::LoadSubMenus( const uno::Reference< container::XIndexAccess >& xMenuSettings,
@@ -849,10 +845,9 @@ SvxEntries* ContextMenuSaveInData::GetEntries()
return m_pRootEntry->GetEntries();
}
-void ContextMenuSaveInData::SetEntries( SvxEntries* pNewEntries )
+void ContextMenuSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
{
- delete m_pRootEntry->GetEntries();
- m_pRootEntry->SetEntries( pNewEntries );
+ m_pRootEntry->SetEntries( std::move(pNewEntries) );
}
bool ContextMenuSaveInData::HasURL( const OUString& rURL )
@@ -1900,7 +1895,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
// Copy the entries list passed in
if ( entries != nullptr )
{
- mpEntries = new SvxEntries;
+ mpEntries.reset( new SvxEntries );
for (auto const& entry : *entries)
{
SvTreeListEntry* pLBEntry =
@@ -1921,7 +1916,7 @@ SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
OUString prefix = CuiResId( RID_SVXSTR_NEW_MENU );
OUString newname = SvxConfigPageHelper::generateCustomName( prefix, entries );
- OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries );
+ OUString newurl = SvxConfigPageHelper::generateCustomMenuURL( mpEntries.get() );
SvxConfigEntry* pNewEntryData =
new SvxConfigEntry( newname, newurl, true, /*bParentData*/false );
@@ -2036,9 +2031,9 @@ IMPL_LINK( SvxMainMenuOrganizerDialog, MoveHdl, Button *, pButton, void )
SvxConfigEntry* pTargetData =
static_cast<SvxConfigEntry*>(pTargetEntry->GetUserData());
- SvxEntries::iterator iter1 = GetEntries()->begin();
- SvxEntries::iterator iter2 = GetEntries()->begin();
- SvxEntries::const_iterator end = GetEntries()->end();
+ SvxEntries::iterator iter1 = mpEntries->begin();
+ SvxEntries::iterator iter2 = mpEntries->begin();
+ SvxEntries::const_iterator end = mpEntries->end();
// Advance the iterators to the positions of the source and target
while (*iter1 != pSourceData && ++iter1 != end) ;
@@ -2084,19 +2079,15 @@ SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
{
if (bPopUp)
{
- mpEntries = new SvxEntries;
+ mpEntries.reset( new SvxEntries );
}
}
SvxConfigEntry::~SvxConfigEntry()
{
- if ( mpEntries != nullptr )
+ for (auto const& entry : *mpEntries)
{
- for (auto const& entry : *mpEntries)
- {
- delete entry;
- }
- delete mpEntries;
+ delete entry;
}
}
@@ -2406,13 +2397,9 @@ SvxEntries* ToolbarSaveInData::GetEntries()
}
void
-ToolbarSaveInData::SetEntries( SvxEntries* pNewEntries )
+ToolbarSaveInData::SetEntries( std::unique_ptr<SvxEntries> pNewEntries )
{
- // delete old menu hierarchy first
- delete pRootEntry->GetEntries();
-
- // now set new menu hierarchy
- pRootEntry->SetEntries( pNewEntries );
+ pRootEntry->SetEntries( std::move(pNewEntries) );
}
bool