[Libreoffice-commits] core.git: 2 commits - extensions/source fpicker/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Feb 19 06:13:57 UTC 2018
extensions/source/bibliography/bibconfig.cxx | 20 +++++++++-----------
extensions/source/bibliography/bibconfig.hxx | 2 +-
fpicker/source/office/OfficeFilePicker.cxx | 19 +++++--------------
fpicker/source/office/OfficeFilePicker.hxx | 6 ++++--
fpicker/source/office/iodlg.cxx | 9 ++++-----
fpicker/source/office/iodlgimp.cxx | 2 +-
fpicker/source/office/iodlgimp.hxx | 2 +-
7 files changed, 25 insertions(+), 35 deletions(-)
New commits:
commit 9ee96d942603ff45370558c55ff989700b64045e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Feb 7 12:36:25 2018 +0200
loplugin:useuniqueptr in filepicker
Change-Id: I367bea33bdb9ea3132d3ed079a16b516498b4fcc
Reviewed-on: https://gerrit.libreoffice.org/49947
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx
index 82f9dca8bf12..23aabac5962b 100644
--- a/fpicker/source/office/OfficeFilePicker.cxx
+++ b/fpicker/source/office/OfficeFilePicker.cxx
@@ -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;
diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx
index 27e761f39f05..af60daa9ee0b 100644
--- a/fpicker/source/office/OfficeFilePicker.hxx
+++ b/fpicker/source/office/OfficeFilePicker.hxx
@@ -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;
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index f8b5e1dd5d7f..873b5ccd2f76 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -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 );
diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx
index 6328c7a44d19..63f93699b1cb 100644
--- a/fpicker/source/office/iodlgimp.cxx
+++ b/fpicker/source/office/iodlgimp.cxx
@@ -215,7 +215,7 @@ SvtExpFileDlg_Impl::SvtExpFileDlg_Impl() :
SvtExpFileDlg_Impl::~SvtExpFileDlg_Impl()
{
_pBtnUp.disposeAndClear();
- delete _pUserFilter;
+ _pUserFilter.reset();
_pPlaces.disposeAndClear();
}
diff --git a/fpicker/source/office/iodlgimp.hxx b/fpicker/source/office/iodlgimp.hxx
index 2146900e15df..099cf0575d8d 100644
--- a/fpicker/source/office/iodlgimp.hxx
+++ b/fpicker/source/office/iodlgimp.hxx
@@ -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;
commit e5fe9cbb421dfc0f373e5ea56c93aab2a149ddcc
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Feb 7 12:32:55 2018 +0200
loplugin:useuniqueptr in BibConfig
Change-Id: I35a75bc9b4bb49dc3505fdc02167a8e62ece2f2e
Reviewed-on: https://gerrit.libreoffice.org/49946
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/extensions/source/bibliography/bibconfig.cxx b/extensions/source/bibliography/bibconfig.cxx
index cd8f2709187a..bf3ea97bdd58 100644
--- a/extensions/source/bibliography/bibconfig.cxx
+++ b/extensions/source/bibliography/bibconfig.cxx
@@ -60,7 +60,6 @@ Sequence<OUString> const & BibConfig::GetPropertyNames()
BibConfig::BibConfig()
: ConfigItem("Office.DataAccess/Bibliography", ConfigItemMode::DelayedUpdate)
, nTblOrQuery(0)
- , pMappingsArr(new MappingArray)
, nBeamerSize(0)
, nViewSize(0)
, bShowColumnAssignmentWarning(false)
@@ -181,7 +180,7 @@ BibConfig::BibConfig()
pMapping->aColumnPairs[nSetMapping++].sRealColumnName = sTempReal;
}
}
- pMappingsArr->push_back(std::unique_ptr<Mapping>(pMapping));
+ mvMappings.push_back(std::unique_ptr<Mapping>(pMapping));
}
}
}
@@ -189,7 +188,6 @@ BibConfig::BibConfig()
BibConfig::~BibConfig()
{
assert(!IsModified()); // should have been committed
- delete pMappingsArr;
}
BibDBDescriptor BibConfig::GetBibliographyURL()
@@ -223,13 +221,13 @@ void BibConfig::ImplCommit()
css::uno::Any(sQueryField),
css::uno::Any(bShowColumnAssignmentWarning)});
ClearNodeSet(cDataSourceHistory);
- Sequence< PropertyValue > aNodeValues(pMappingsArr->size() * 3);
+ Sequence< PropertyValue > aNodeValues(mvMappings.size() * 3);
PropertyValue* pNodeValues = aNodeValues.getArray();
sal_Int32 nIndex = 0;
- for(sal_Int32 i = 0; i < static_cast<sal_Int32>(pMappingsArr->size()); i++)
+ for(sal_Int32 i = 0; i < static_cast<sal_Int32>(mvMappings.size()); i++)
{
- const Mapping* pMapping = (*pMappingsArr)[i].get();
+ const Mapping* pMapping = mvMappings[i].get();
OUString sPrefix(cDataSourceHistory);
sPrefix += "/_";
sPrefix += OUString::number(i);
@@ -270,7 +268,7 @@ void BibConfig::ImplCommit()
const Mapping* BibConfig::GetMapping(const BibDBDescriptor& rDesc) const
{
- for(std::unique_ptr<Mapping> & i : *pMappingsArr)
+ for(std::unique_ptr<Mapping> const & i : mvMappings)
{
Mapping& rMapping = *i.get();
bool bURLEqual = rDesc.sDataSource == rMapping.sURL;
@@ -282,17 +280,17 @@ const Mapping* BibConfig::GetMapping(const BibDBDescriptor& rDesc) const
void BibConfig::SetMapping(const BibDBDescriptor& rDesc, const Mapping* pSetMapping)
{
- for(size_t i = 0; i < pMappingsArr->size(); i++)
+ for(size_t i = 0; i < mvMappings.size(); i++)
{
- Mapping& rMapping = *(*pMappingsArr)[i].get();
+ Mapping& rMapping = *mvMappings[i];
bool bURLEqual = rDesc.sDataSource == rMapping.sURL;
if(rDesc.sTableOrQuery == rMapping.sTableName && bURLEqual)
{
- pMappingsArr->erase(pMappingsArr->begin()+i);
+ mvMappings.erase(mvMappings.begin()+i);
break;
}
}
- pMappingsArr->push_back(o3tl::make_unique<Mapping>(*pSetMapping));
+ mvMappings.push_back(o3tl::make_unique<Mapping>(*pSetMapping));
SetModified();
}
diff --git a/extensions/source/bibliography/bibconfig.hxx b/extensions/source/bibliography/bibconfig.hxx
index 2b1ed8ceb880..73240e94efc8 100644
--- a/extensions/source/bibliography/bibconfig.hxx
+++ b/extensions/source/bibliography/bibconfig.hxx
@@ -94,7 +94,7 @@ class BibConfig : public utl::ConfigItem
OUString sQueryField;
OUString sQueryText;
- MappingArray* pMappingsArr;
+ MappingArray mvMappings;
long nBeamerSize;
long nViewSize;
bool bShowColumnAssignmentWarning;
More information about the Libreoffice-commits
mailing list