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

loplugin:useuniqueptr in filepicker

Change-Id: I367bea33bdb9ea3132d3ed079a16b516498b4fcc
Reviewed-on: https://gerrit.libreoffice.org/49947Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e5fe9cbb
......@@ -407,7 +407,7 @@ void SvtFilePicker::ensureFilterList( const OUString& _rInitialCurrentFilter )
{
if ( !m_pFilterList )
{
m_pFilterList = new FilterList;
m_pFilterList.reset( new FilterList );
// set the first filter to the current filter
if ( m_aCurrentFilter.isEmpty() )
......@@ -419,22 +419,13 @@ void SvtFilePicker::ensureFilterList( const OUString& _rInitialCurrentFilter )
// class SvtFilePicker
SvtFilePicker::SvtFilePicker()
:m_pFilterList ( nullptr )
,m_pElemList ( nullptr )
,m_bMultiSelection ( false )
:m_bMultiSelection ( false )
,m_nServiceType ( TemplateDescription::FILEOPEN_SIMPLE )
{
}
SvtFilePicker::~SvtFilePicker()
{
if ( m_pFilterList && !m_pFilterList->empty() )
m_pFilterList->erase( m_pFilterList->begin(), m_pFilterList->end() );
delete m_pFilterList;
if ( m_pElemList && !m_pElemList->empty() )
m_pElemList->erase( m_pElemList->begin(), m_pElemList->end() );
delete m_pElemList;
}
......@@ -629,7 +620,7 @@ void SAL_CALL SvtFilePicker::setValue( sal_Int16 nElementID,
else
{
if ( !m_pElemList )
m_pElemList = new ElementList;
m_pElemList.reset( new ElementList );
bool bFound = false;
ElementList::iterator aListIter;
......@@ -705,7 +696,7 @@ void SAL_CALL SvtFilePicker::setLabel( sal_Int16 nLabelID, const OUString& rValu
else
{
if ( !m_pElemList )
m_pElemList = new ElementList;
m_pElemList.reset( new ElementList );
bool bFound = false;
ElementList::iterator aListIter;
......@@ -776,7 +767,7 @@ void SAL_CALL SvtFilePicker::enableControl( sal_Int16 nElementID, sal_Bool bEnab
else
{
if ( !m_pElemList )
m_pElemList = new ElementList;
m_pElemList.reset( new ElementList );
bool bFound = false;
ElementList::iterator aListIter;
......
......@@ -61,8 +61,10 @@ class SvtFilePicker :public SvtFilePicker_Base
,public ::svt::IFilePickerListener
{
protected:
FilterList* m_pFilterList;
ElementList* m_pElemList;
std::unique_ptr<FilterList>
m_pFilterList;
std::unique_ptr<ElementList>
m_pElemList;
bool m_bMultiSelection;
sal_Int16 m_nServiceType;
......
......@@ -119,7 +119,7 @@ namespace
OUString getMostCurrentFilter( std::unique_ptr<SvtExpFileDlg_Impl> const & pImpl )
{
assert( pImpl && "invalid impl pointer" );
const SvtFileDialogFilter_Impl* pFilter = pImpl->_pUserFilter;
const SvtFileDialogFilter_Impl* pFilter = pImpl->_pUserFilter.get();
if ( !pFilter )
pFilter = pImpl->GetCurFilter();
......@@ -768,8 +768,7 @@ IMPL_LINK_NOARG( SvtFileDialog, NewFolderHdl_Impl, Button*, void)
void SvtFileDialog::createNewUserFilter( const OUString& _rNewFilter )
{
// delete the old user filter and create a new one
DELETEZ( pImpl->_pUserFilter );
pImpl->_pUserFilter = new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter );
pImpl->_pUserFilter.reset( new SvtFileDialogFilter_Impl( _rNewFilter, _rNewFilter ) );
// remember the extension
bool bIsAllFiles = _rNewFilter == FILEDIALOG_FILTER_ALL;
......@@ -910,7 +909,7 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid)
// MBA->PB: ?!
if ( aFileName.isEmpty() && pVoid == pImpl->_pEdFileName && pImpl->_pUserFilter )
{
DELETEZ( pImpl->_pUserFilter );
pImpl->_pUserFilter.reset();
return;
}
......@@ -1181,7 +1180,7 @@ IMPL_LINK_NOARG( SvtFileDialog, FilterSelectHdl_Impl, ListBox&, void )
{
// Store the old filter for the auto extension handling
OUString sLastFilterExt = pImpl->GetCurFilter()->GetExtension();
DELETEZ( pImpl->_pUserFilter );
pImpl->_pUserFilter.reset();
// if applicable remove filter of the user
pImpl->SetCurFilter( pSelectedFilter, sSelectedFilterDisplayName );
......
......@@ -215,7 +215,7 @@ SvtExpFileDlg_Impl::SvtExpFileDlg_Impl() :
SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
{
_pBtnUp.disposeAndClear();
delete _pUserFilter;
_pUserFilter.reset();
_pPlaces.disposeAndClear();
}
......
......@@ -123,7 +123,7 @@ private:
public:
SvtFileDialogFilterList_Impl m_aFilter;
SvtFileDialogFilter_Impl* _pUserFilter;
std::unique_ptr<SvtFileDialogFilter_Impl> _pUserFilter;
VclPtr<FixedText> _pFtFileName;
VclPtr<SvtURLBox> _pEdFileName;
......
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