sw/inc/tblafmt.hxx | 6 +++--- sw/source/core/doc/tblafmt.cxx | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-)
New commits: commit d664a01f3be81572526d1136c261d86c12f5af90 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 26 14:01:14 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 28 11:31:16 2018 +0200 loplugin:useuniqueptr in SwCellStyleTable Change-Id: I9e589efa8ee8e11e6518f61f80f0e4c114867b4a Reviewed-on: https://gerrit.libreoffice.org/61001 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index f1bc805fee84..4f6275f92f1e 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -376,16 +376,16 @@ public: class SwCellStyleDescriptor { - const std::pair<OUString, SwBoxAutoFormat*>& m_rCellStyleDesc; + const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& m_rCellStyleDesc; public: - SwCellStyleDescriptor(const std::pair<OUString, SwBoxAutoFormat*>& rCellStyleDesc) : m_rCellStyleDesc(rCellStyleDesc) { } + SwCellStyleDescriptor(const std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>& rCellStyleDesc) : m_rCellStyleDesc(rCellStyleDesc) { } const OUString& GetName() { return m_rCellStyleDesc.first; } }; class SwCellStyleTable { - std::vector<std::pair<OUString, SwBoxAutoFormat*>> m_aCellStyles; + std::vector<std::pair<OUString, std::unique_ptr<SwBoxAutoFormat>>> m_aCellStyles; public: SwCellStyleTable(); ~SwCellStyleTable(); diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index ab4df0030aeb..3483b3fc5955 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -1405,8 +1405,6 @@ SwCellStyleTable::SwCellStyleTable() SwCellStyleTable::~SwCellStyleTable() { - for (size_t i=0; i < m_aCellStyles.size(); ++i) - delete m_aCellStyles[i].second; } size_t SwCellStyleTable::size() const @@ -1416,9 +1414,6 @@ size_t SwCellStyleTable::size() const void SwCellStyleTable::clear() { - for (size_t i=0; i < m_aCellStyles.size(); ++i) - delete m_aCellStyles[i].second; - m_aCellStyles.clear(); } @@ -1429,7 +1424,7 @@ SwCellStyleDescriptor SwCellStyleTable::operator[](size_t i) const void SwCellStyleTable::AddBoxFormat(const SwBoxAutoFormat& rBoxFormat, const OUString& sName) { - m_aCellStyles.emplace_back(sName, new SwBoxAutoFormat(rBoxFormat)); + m_aCellStyles.emplace_back(sName, o3tl::make_unique<SwBoxAutoFormat>(rBoxFormat)); } void SwCellStyleTable::RemoveBoxFormat(const OUString& sName) @@ -1438,7 +1433,6 @@ void SwCellStyleTable::RemoveBoxFormat(const OUString& sName) { if (iter->first == sName) { - delete iter->second; m_aCellStyles.erase(iter); return; } @@ -1450,7 +1444,7 @@ OUString SwCellStyleTable::GetBoxFormatName(const SwBoxAutoFormat& rBoxFormat) c { for (size_t i=0; i < m_aCellStyles.size(); ++i) { - if (m_aCellStyles[i].second == &rBoxFormat) + if (m_aCellStyles[i].second.get() == &rBoxFormat) return m_aCellStyles[i].first; } @@ -1463,7 +1457,7 @@ SwBoxAutoFormat* SwCellStyleTable::GetBoxFormat(const OUString& sName) const for (size_t i=0; i < m_aCellStyles.size(); ++i) { if (m_aCellStyles[i].first == sName) - return m_aCellStyles[i].second; + return m_aCellStyles[i].second.get(); } return nullptr; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits