diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2018-10-22 16:37:08 +0200 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-11-10 19:47:00 +0100 |
commit | 3466611d51c4dae1d60cac098315b32d1088f15e (patch) | |
tree | 2306f082349b841a1dcd45304ad05323ad40f053 | |
parent | b0dfdef674e548b75bda893ee153ae5719a7d34e (diff) |
sw_redlinehide_3: adapt number tree updates in SetAttr/ResetAttr
Update both of the SwNodeNums.
Change-Id: Iba8aa6cda460099f4a1086d6aaa08ac98c78f097
-rw-r--r-- | sw/inc/ndtxt.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 48 |
2 files changed, 36 insertions, 13 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 97450d63a7a6..05bdb53b2f1f 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -424,6 +424,7 @@ public: SwNumRule *GetNumRule(bool bInParent = true) const; const SwNodeNum* GetNum(SwRootFrame const* pLayout = nullptr) const; + void DoNum(std::function<void (SwNodeNum &)> const&); SwNumberTree::tNumberVector GetNumberVector(SwRootFrame const* pLayout = nullptr) const; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 657547c7766d..cf8ec5bbeccd 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3967,6 +3967,21 @@ const SwNodeNum* SwTextNode::GetNum(SwRootFrame const*const pLayout) const return pLayout && pLayout->IsHideRedlines() ? mpNodeNumRLHidden : mpNodeNum; } +void SwTextNode::DoNum(std::function<void (SwNodeNum &)> const& rFunc) +{ + // temp. clear because GetActualListLevel() may be called and the assert + // there triggered during update, which is unhelpful + SwNodeNum * pBackup(mpNodeNumRLHidden); + mpNodeNumRLHidden = nullptr; + assert(mpNodeNum); + rFunc(*mpNodeNum); + if (pBackup) + { + mpNodeNumRLHidden = pBackup; + rFunc(*mpNodeNumRLHidden); + } +} + SwNumberTree::tNumberVector SwTextNode::GetNumberVector(SwRootFrame const*const pLayout) const { @@ -4830,20 +4845,24 @@ namespace { { if ( mbUpdateListLevel && mrTextNode.IsInList() ) { - const_cast<SwNodeNum*>(mrTextNode.GetNum())->SetLevelInListTree( - mrTextNode.GetAttrListLevel() ); + auto const nLevel(mrTextNode.GetAttrListLevel()); + mrTextNode.DoNum( + [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); }); } if ( mbUpdateListRestart && mrTextNode.IsInList() ) { - SwNodeNum* pNodeNum = const_cast<SwNodeNum*>(mrTextNode.GetNum()); - pNodeNum->InvalidateMe(); - pNodeNum->NotifyInvalidSiblings(); + mrTextNode.DoNum( + [](SwNodeNum & rNum) { + rNum.InvalidateMe(); + rNum.NotifyInvalidSiblings(); + }); } if ( mbUpdateListCount && mrTextNode.IsInList() ) { - const_cast<SwNodeNum*>(mrTextNode.GetNum())->InvalidateAndNotifyTree(); + mrTextNode.DoNum( + [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); }); } } @@ -5155,21 +5174,24 @@ namespace { { if ( mbUpdateListLevel ) { - SwNodeNum* pNodeNum = const_cast<SwNodeNum*>(mrTextNode.GetNum()); - pNodeNum->SetLevelInListTree( mrTextNode.GetAttrListLevel() ); + auto const nLevel(mrTextNode.GetAttrListLevel()); + mrTextNode.DoNum( + [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); }); } if ( mbUpdateListRestart ) { - SwNodeNum* pNodeNum = const_cast<SwNodeNum*>(mrTextNode.GetNum()); - pNodeNum->InvalidateMe(); - pNodeNum->NotifyInvalidSiblings(); + mrTextNode.DoNum( + [](SwNodeNum & rNum) { + rNum.InvalidateMe(); + rNum.NotifyInvalidSiblings(); + }); } if ( mbUpdateListCount ) { - SwNodeNum* pNodeNum = const_cast<SwNodeNum*>(mrTextNode.GetNum()); - pNodeNum->InvalidateAndNotifyTree(); + mrTextNode.DoNum( + [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); }); } } } |