summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-05-28 15:57:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-05-30 09:08:31 +0200
commitc78fa391c99885492d50de12b7a6b5912229061f (patch)
treeeb0ff467a7ac1ff18105703093c75e9471cc0bdd /sw
parente98b0891d6e0f1d6be4e4a4761bd1ab16bfab85c (diff)
std::unique_ptr->std::optional
Change-Id: I7a10e9bf14d45d1fe958dc33fe96ebb8318b3bec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116393 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/node.hxx4
-rw-r--r--sw/source/core/docnode/node.cxx20
2 files changed, 12 insertions, 12 deletions
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index a65b4872c5fd..c5693ce98c87 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -107,7 +107,7 @@ private:
/// all SwFrameFormat that are anchored at the node
/// invariant: SwFrameFormat is in the list iff
/// SwFrameFormat::GetAnchor().GetContentAnchor() points to this node
- std::unique_ptr<std::vector<SwFrameFormat*>> m_pAnchoredFlys;
+ std::optional<std::vector<SwFrameFormat*>> m_xAnchoredFlys;
protected:
SwStartNode* m_pStartOfSection;
@@ -294,7 +294,7 @@ public:
sal_uInt8 HasPrevNextLayNode() const;
- std::vector<SwFrameFormat *> const* GetAnchoredFlys() const { return m_pAnchoredFlys.get(); }
+ std::vector<SwFrameFormat *> const* GetAnchoredFlys() const { return m_xAnchoredFlys ? &*m_xAnchoredFlys : nullptr; }
void AddAnchoredFly(SwFrameFormat *);
void RemoveAnchoredFly(SwFrameFormat *);
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 809ecd349c81..3b0245969246 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -347,7 +347,7 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType )
SwNode::~SwNode()
{
- assert(!m_pAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted
+ assert(!m_xAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted
InvalidateInSwCache(RES_OBJECTDYING);
assert(!IsInCache());
}
@@ -2119,11 +2119,11 @@ void SwNode::AddAnchoredFly(SwFrameFormat *const pFlyFormat)
assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this);
// check node type, cf. SwFormatAnchor::SetAnchor()
assert(IsTextNode() || IsStartNode() || IsTableNode());
- if (!m_pAnchoredFlys)
+ if (!m_xAnchoredFlys)
{
- m_pAnchoredFlys.reset(new std::vector<SwFrameFormat*>);
+ m_xAnchoredFlys.emplace();
}
- m_pAnchoredFlys->push_back(pFlyFormat);
+ m_xAnchoredFlys->push_back(pFlyFormat);
}
void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat)
@@ -2132,13 +2132,13 @@ void SwNode::RemoveAnchoredFly(SwFrameFormat *const pFlyFormat)
// cannot assert this in Remove because it is called when new anchor is already set
// assert(&pFlyFormat->GetAnchor(false).GetContentAnchor()->nNode.GetNode() == this);
assert(IsTextNode() || IsStartNode() || IsTableNode());
- assert(m_pAnchoredFlys);
- auto it(std::find(m_pAnchoredFlys->begin(), m_pAnchoredFlys->end(), pFlyFormat));
- assert(it != m_pAnchoredFlys->end());
- m_pAnchoredFlys->erase(it);
- if (m_pAnchoredFlys->empty())
+ assert(m_xAnchoredFlys);
+ auto it(std::find(m_xAnchoredFlys->begin(), m_xAnchoredFlys->end(), pFlyFormat));
+ assert(it != m_xAnchoredFlys->end());
+ m_xAnchoredFlys->erase(it);
+ if (m_xAnchoredFlys->empty())
{
- m_pAnchoredFlys.reset();
+ m_xAnchoredFlys.reset();
}
}