diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-11 15:11:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-20 08:33:17 +0200 |
commit | 433fd79e00ee8fb935482f13ca5b270939aefa99 (patch) | |
tree | 9499ea7e4bfcbe72178611c8220684860a9a33a4 /cui | |
parent | ece3faf9a02fc2449150b066214eb84a87bd2aa8 (diff) |
loplugin:useuniqueptr in TPGalleryThemeProperties
Change-Id: I4a288f9bd1b8abd7c588c1c895c8b6a8ef399fc2
Reviewed-on: https://gerrit.libreoffice.org/56099
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/cuigaldlg.cxx | 28 | ||||
-rw-r--r-- | cui/source/inc/cuigaldlg.hxx | 2 |
2 files changed, 13 insertions, 17 deletions
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index 90c8d01a0b0d..fe99c5373ede 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -756,9 +756,6 @@ void TPGalleryThemeProperties::dispose() xMediaPlayer.clear(); xDialogListener.clear(); - for (FilterEntry* i : aFilterEntryList) { - delete i; - } aFilterEntryList.clear(); m_pCbbFileType.clear(); @@ -794,7 +791,6 @@ void TPGalleryThemeProperties::FillFilterList() GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter(); OUString aExt; OUString aName; - FilterEntry* pFilterEntry; sal_uInt16 i, nKeyCount; // graphic filters @@ -803,7 +799,7 @@ void TPGalleryThemeProperties::FillFilterList() aExt = rFilter.GetImportFormatShortName( i ); aName = rFilter.GetImportFormatName( i ); size_t entryIndex = 0; - FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : aFilterEntryList[ entryIndex ]; + FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : aFilterEntryList[ entryIndex ].get(); bool bInList = false; OUString aExtensions; @@ -831,17 +827,17 @@ void TPGalleryThemeProperties::FillFilterList() break; } pTestEntry = ( ++entryIndex < aFilterEntryList.size() ) - ? aFilterEntryList[ entryIndex ] : nullptr; + ? aFilterEntryList[ entryIndex ].get() : nullptr; } if ( !bInList ) { - pFilterEntry = new FilterEntry; + std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); pFilterEntry->aFilterName = aExt; size_t pos = m_pCbbFileType->InsertEntry( aName ); if ( pos < aFilterEntryList.size() ) { - aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry ); + aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) ); } else { - aFilterEntryList.push_back( pFilterEntry ); + aFilterEntryList.push_back( std::move(pFilterEntry) ); } } } @@ -857,7 +853,7 @@ void TPGalleryThemeProperties::FillFilterList() { OUString aFilterWildcard( aWildcard ); - pFilterEntry = new FilterEntry; + std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex ); nFirstExtFilterPos = m_pCbbFileType->InsertEntry( addExtension( @@ -868,10 +864,10 @@ void TPGalleryThemeProperties::FillFilterList() if ( nFirstExtFilterPos < aFilterEntryList.size() ) { aFilterEntryList.insert( aFilterEntryList.begin() + nFirstExtFilterPos, - pFilterEntry + std::move(pFilterEntry) ); } else { - aFilterEntryList.push_back( pFilterEntry ); + aFilterEntryList.push_back( std::move(pFilterEntry) ); } } } @@ -915,16 +911,16 @@ void TPGalleryThemeProperties::FillFilterList() aExtensions = "*.*"; #endif - pFilterEntry = new FilterEntry; + std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry); pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES); pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions ); size_t pos = m_pCbbFileType->InsertEntry( pFilterEntry->aFilterName, 0 ); + m_pCbbFileType->SetText( pFilterEntry->aFilterName ); if ( pos < aFilterEntryList.size() ) { - aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry ); + aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) ); } else { - aFilterEntryList.push_back( pFilterEntry ); + aFilterEntryList.push_back( std::move(pFilterEntry) ); } - m_pCbbFileType->SetText( pFilterEntry->aFilterName ); } IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, ComboBox&, void) diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx index bc82540bc3e3..d00a30b819c0 100644 --- a/cui/source/inc/cuigaldlg.hxx +++ b/cui/source/inc/cuigaldlg.hxx @@ -246,7 +246,7 @@ class TPGalleryThemeProperties : public SfxTabPage ExchangeData* pData; std::vector<OUString> aFoundList; - std::vector< FilterEntry* > + std::vector< std::unique_ptr<FilterEntry> > aFilterEntryList; Timer aPreviewTimer; OUString aLastFilterName; |