summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-26 14:01:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-28 11:31:16 +0200
commitd664a01f3be81572526d1136c261d86c12f5af90 (patch)
tree2ede73d87ec2eff6bd72e27d786d96013a8729a9 /sw
parent8dac53d5cec1984590f7ef51a4a773711ca2d01d (diff)
loplugin:useuniqueptr in SwCellStyleTable
Change-Id: I9e589efa8ee8e11e6518f61f80f0e4c114867b4a Reviewed-on: https://gerrit.libreoffice.org/61001 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/tblafmt.hxx6
-rw-r--r--sw/source/core/doc/tblafmt.cxx12
2 files changed, 6 insertions, 12 deletions
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;