sw/inc/SwNodeNum.hxx | 2 - sw/inc/SwNumberTree.hxx | 21 +++++------ sw/inc/list.hxx | 12 +++--- sw/inc/numrule.hxx | 2 - sw/source/core/SwNumberTree/SwNodeNum.cxx | 2 - sw/source/core/SwNumberTree/SwNumberTree.cxx | 49 +++++++++++++------------- sw/source/core/doc/DocumentSettingManager.cxx | 2 - sw/source/core/doc/docnum.cxx | 2 - sw/source/core/doc/list.cxx | 16 ++++---- sw/source/core/doc/number.cxx | 4 +- sw/source/core/txtnode/ndtxt.cxx | 30 +++++++++------ sw/source/core/unocore/unosett.cxx | 4 +- 12 files changed, 78 insertions(+), 68 deletions(-)
New commits: commit 34fcf3b6e0f32f9327c905e2e2507427e7ef4f91 Author: Caolán McNamara <[email protected]> AuthorDate: Sun Jul 4 16:35:24 2021 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Jul 4 21:46:34 2021 +0200 add a const SwDoc& arg for a follow up optimization Change-Id: Ib18e6c93e35fc3021a874f4313cf38fbb99d696a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118380 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/inc/SwNodeNum.hxx b/sw/inc/SwNodeNum.hxx index 81809630d3b8..7ad85271c9fa 100644 --- a/sw/inc/SwNodeNum.hxx +++ b/sw/inc/SwNodeNum.hxx @@ -91,7 +91,7 @@ private: virtual bool IsCountPhantoms() const override; - virtual bool IsNotifiable() const override; + virtual bool IsNotifiable(const SwDoc& rDoc) const override; virtual void NotifyNode() override; }; diff --git a/sw/inc/SwNumberTree.hxx b/sw/inc/SwNumberTree.hxx index ad45fae21910..39575e8aa46d 100644 --- a/sw/inc/SwNumberTree.hxx +++ b/sw/inc/SwNumberTree.hxx @@ -23,6 +23,7 @@ #include <vector> #include "SwNumberTreeTypes.hxx" +class SwDoc; class SwNumberTreeNode; bool SwNumberTreeNodeLessThan(const SwNumberTreeNode* pA, const SwNumberTreeNode* pB); @@ -125,19 +126,19 @@ public: @param pChild child to add @param nDepth depth in which to add the child */ - void AddChild(SwNumberTreeNode* pChild, const int nDepth); + void AddChild(SwNumberTreeNode* pChild, const int nDepth, const SwDoc& rDoc); /** Remove a child. @param pChild child to be removed */ - void RemoveChild(SwNumberTreeNode* pChild); + void RemoveChild(SwNumberTreeNode* pChild, const SwDoc& rDoc); /** Remove this child from the tree. */ - void RemoveMe(); + void RemoveMe(const SwDoc& rDoc); /** Returns the parent of this node. @@ -222,7 +223,7 @@ public: precondition: node is already member of a list tree */ - void SetLevelInListTree(const int nLevel); + void SetLevelInListTree(const int nLevel, const SwDoc& rDoc); /** Return level of this node. @@ -261,7 +262,7 @@ public: Notifies all invalid children of this node. #i83479# - made public */ - void NotifyInvalidChildren(); + void NotifyInvalidChildren(const SwDoc& rDoc); /** Notifies the node. @@ -278,7 +279,7 @@ public: void ValidateMe(); /** Notifies all invalid siblings of this node. */ - void NotifyInvalidSiblings(); + void NotifyInvalidSiblings(const SwDoc& rDoc); /** notification of all nodes in the list tree on certain list level */ void NotifyNodesOnListLevel(const int nListLevel); @@ -289,12 +290,12 @@ public: Usage: on <IsCounted()> state change it's needed to invalidate the complete numbering tree due to wide influence of this change. */ - void InvalidateAndNotifyTree() + void InvalidateAndNotifyTree(const SwDoc& rDoc) { if (GetRoot()) { GetRoot()->InvalidateTree(); - GetRoot()->Notify(); + GetRoot()->Notify(rDoc); } } @@ -452,7 +453,7 @@ protected: @retval true This node is notifiable. @retval false else */ - virtual bool IsNotifiable() const = 0; + virtual bool IsNotifiable(const SwDoc& rDoc) const = 0; /** Notifies the node. @@ -462,7 +463,7 @@ protected: virtual void NotifyNode() = 0; /** Notifies this node (NotifyNode) and all descendants.*/ - void Notify(); + void Notify(const SwDoc& rDoc); /** notification of children nodes on certain depth */ void NotifyChildrenOnDepth(const int nDepth); diff --git a/sw/inc/list.hxx b/sw/inc/list.hxx index ddde0bb299e1..a329165c1da2 100644 --- a/sw/inc/list.hxx +++ b/sw/inc/list.hxx @@ -28,6 +28,7 @@ #include "swdllapi.h" +class SwDoc; class SwNumRule; class SwNodes; @@ -45,13 +46,14 @@ class SwList void SetDefaultListStyleName(OUString const&); - void InsertListItem( SwNodeNum& rNodeNum, - bool isHiddenRedlines, - const int nLevel ); - static void RemoveListItem( SwNodeNum& rNodeNum ); + void InsertListItem(SwNodeNum& rNodeNum, + bool isHiddenRedlines, + const int nLevel, + const SwDoc& rDoc); + static void RemoveListItem(SwNodeNum& rNodeNum, const SwDoc& rDoc); void InvalidateListTree(); - void ValidateListTree(); + void ValidateListTree(const SwDoc& rDoc); void MarkListLevel( const int nListLevel, const bool bValue ); diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx index fd333da0d864..1e23a8818163 100644 --- a/sw/inc/numrule.hxx +++ b/sw/inc/numrule.hxx @@ -269,7 +269,7 @@ public: indents accordingly */ void SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent ); - void Validate(); + void Validate(const SwDoc& rDoc); void dumpAsXml(xmlTextWriterPtr w) const; void GetGrabBagItem(css::uno::Any& rVal) const; void SetGrabBagItem(const css::uno::Any& rVal); diff --git a/sw/source/core/SwNumberTree/SwNodeNum.cxx b/sw/source/core/SwNumberTree/SwNodeNum.cxx index af92fe21ddc8..c83b29f086b7 100644 --- a/sw/source/core/SwNumberTree/SwNodeNum.cxx +++ b/sw/source/core/SwNumberTree/SwNodeNum.cxx @@ -122,7 +122,7 @@ void SwNodeNum::PostRemove() } } -bool SwNodeNum::IsNotifiable() const +bool SwNodeNum::IsNotifiable(const SwDoc& /*rDoc*/) const { bool aResult = true; diff --git a/sw/source/core/SwNumberTree/SwNumberTree.cxx b/sw/source/core/SwNumberTree/SwNumberTree.cxx index ba15af2c0f90..e695df5622be 100644 --- a/sw/source/core/SwNumberTree/SwNumberTree.cxx +++ b/sw/source/core/SwNumberTree/SwNumberTree.cxx @@ -413,8 +413,9 @@ void SwNumberTreeNode::MoveChildren(SwNumberTreeNode * pDest) #endif } -void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild, - const int nDepth ) +void SwNumberTreeNode::AddChild(SwNumberTreeNode* pChild, + const int nDepth, + const SwDoc& rDoc) { /* Algorithm: @@ -468,12 +469,12 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild, SetLastValid(mChildren.end()); if (pNew) - pNew->AddChild(pChild, nDepth - 1); + pNew->AddChild(pChild, nDepth - 1, rDoc); } else { --aInsertDeepIt; - (*aInsertDeepIt)->AddChild(pChild, nDepth - 1); + (*aInsertDeepIt)->AddChild(pChild, nDepth - 1, rDoc); } } @@ -553,9 +554,9 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild, if ( !IsCounted() ) { InvalidateMe(); - NotifyInvalidSiblings(); + NotifyInvalidSiblings(rDoc); } - NotifyInvalidChildren(); + NotifyInvalidChildren(rDoc); } } } @@ -565,7 +566,7 @@ void SwNumberTreeNode::AddChild( SwNumberTreeNode * pChild, #endif } -void SwNumberTreeNode::RemoveChild(SwNumberTreeNode * pChild) +void SwNumberTreeNode::RemoveChild(SwNumberTreeNode* pChild, const SwDoc& rDoc) { /* Algorithm: @@ -614,7 +615,7 @@ void SwNumberTreeNode::RemoveChild(SwNumberTreeNode * pChild) { pRemove->MoveChildren(*aItPred); (*aItPred)->InvalidateTree(); - (*aItPred)->NotifyInvalidChildren(); + (*aItPred)->NotifyInvalidChildren(rDoc); } // #i60652# @@ -628,7 +629,7 @@ void SwNumberTreeNode::RemoveChild(SwNumberTreeNode * pChild) mChildren.erase(aRemoveIt); - NotifyInvalidChildren(); + NotifyInvalidChildren(rDoc); } else { @@ -638,14 +639,14 @@ void SwNumberTreeNode::RemoveChild(SwNumberTreeNode * pChild) pChild->PostRemove(); } -void SwNumberTreeNode::RemoveMe() +void SwNumberTreeNode::RemoveMe(const SwDoc& rDoc) { if (!mpParent) return; SwNumberTreeNode * pSavedParent = mpParent; - pSavedParent->RemoveChild(this); + pSavedParent->RemoveChild(this, rDoc); while (pSavedParent && pSavedParent->IsPhantom() && pSavedParent->HasOnlyPhantoms()) @@ -794,7 +795,7 @@ bool SwNumberTreeNode::IsFirst() const return bResult; } -void SwNumberTreeNode::SetLevelInListTree( const int nLevel ) +void SwNumberTreeNode::SetLevelInListTree(const int nLevel, const SwDoc& rDoc) { if ( nLevel < 0 ) { @@ -812,8 +813,8 @@ void SwNumberTreeNode::SetLevelInListTree( const int nLevel ) OSL_ENSURE( pRootTreeNode, "<SwNumberTreeNode::SetLevelInListTree(..)> - no root tree node found. Serious defect." ); - RemoveMe(); - pRootTreeNode->AddChild( this, nLevel ); + RemoveMe(rDoc); + pRootTreeNode->AddChild(this, nLevel, rDoc); } } } @@ -1059,21 +1060,21 @@ void SwNumberTreeNode::ValidateMe() mpParent->Validate(this); } -void SwNumberTreeNode::Notify() +void SwNumberTreeNode::Notify(const SwDoc& rDoc) { - if (IsNotifiable()) + if (IsNotifiable(rDoc)) { if (! IsPhantom()) NotifyNode(); for (auto& rpChild : mChildren) - rpChild->Notify(); + rpChild->Notify(rDoc); } } -void SwNumberTreeNode::NotifyInvalidChildren() +void SwNumberTreeNode::NotifyInvalidChildren(const SwDoc& rDoc) { - if (IsNotifiable()) + if (IsNotifiable(rDoc)) { tSwNumberTreeChildren::const_iterator aIt = mItLastValid; @@ -1084,7 +1085,7 @@ void SwNumberTreeNode::NotifyInvalidChildren() while (aIt != mChildren.end()) { - (*aIt)->Notify(); + (*aIt)->Notify(rDoc); ++aIt; } @@ -1099,7 +1100,7 @@ void SwNumberTreeNode::NotifyInvalidChildren() SwNumberTreeNode* pNextNode( *aParentChildIt ); if ( !pNextNode->IsCounted() ) { - pNextNode->NotifyInvalidChildren(); + pNextNode->NotifyInvalidChildren(rDoc); } } } @@ -1107,13 +1108,13 @@ void SwNumberTreeNode::NotifyInvalidChildren() } if (IsContinuous() && mpParent) - mpParent->NotifyInvalidChildren(); + mpParent->NotifyInvalidChildren(rDoc); } -void SwNumberTreeNode::NotifyInvalidSiblings() +void SwNumberTreeNode::NotifyInvalidSiblings(const SwDoc& rDoc) { if (mpParent != nullptr) - mpParent->NotifyInvalidChildren(); + mpParent->NotifyInvalidChildren(rDoc); } // #i81002# diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index 7752b97705fd..8d9959631d7c 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -287,7 +287,7 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo SwNumRule *pOutlineRule = m_rDoc.GetOutlineNumRule(); if (pOutlineRule) { - pOutlineRule->Validate(); + pOutlineRule->Validate(m_rDoc); // counting of phantoms depends on <IsOldNumbering()> pOutlineRule->SetCountPhantoms( !mbOldNumbering ); } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 9a7740a735e4..fad2322f07d9 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2577,7 +2577,7 @@ void SwDoc::UpdateNumRule() const SwNumRuleTable& rNmTable = GetNumRuleTable(); for( size_t n = 0; n < rNmTable.size(); ++n ) if( rNmTable[ n ]->IsInvalidRule() ) - rNmTable[ n ]->Validate(); + rNmTable[ n ]->Validate(*this); } void SwDoc::MarkListLevel( const OUString& sListId, diff --git a/sw/source/core/doc/list.cxx b/sw/source/core/doc/list.cxx index 4192cab749ad..a26a677619d9 100644 --- a/sw/source/core/doc/list.cxx +++ b/sw/source/core/doc/list.cxx @@ -75,8 +75,8 @@ bool SwList::HasNodes() const return false; } -void SwList::InsertListItem( SwNodeNum& rNodeNum, bool const isHiddenRedlines, - const int nLevel ) +void SwList::InsertListItem(SwNodeNum& rNodeNum, bool const isHiddenRedlines, + const int nLevel, const SwDoc& rDoc) { const SwPosition aPosOfNodeNum( rNodeNum.GetPosition() ); const SwNodes* pNodesOfNodeNum = &(aPosOfNodeNum.nNode.GetNode().GetNodes()); @@ -93,15 +93,15 @@ void SwList::InsertListItem( SwNodeNum& rNodeNum, bool const isHiddenRedlines, auto const& pRoot(isHiddenRedlines ? rNumberTree.pRootRLHidden : rNumberTree.pRoot); - pRoot->AddChild(&rNodeNum, nLevel); + pRoot->AddChild(&rNodeNum, nLevel, rDoc); break; } } } -void SwList::RemoveListItem( SwNodeNum& rNodeNum ) +void SwList::RemoveListItem(SwNodeNum& rNodeNum, const SwDoc& rDoc) { - rNodeNum.RemoveMe(); + rNodeNum.RemoveMe(rDoc); } void SwList::InvalidateListTree() @@ -113,12 +113,12 @@ void SwList::InvalidateListTree() } } -void SwList::ValidateListTree() +void SwList::ValidateListTree(const SwDoc& rDoc) { for ( auto& rNumberTree : maListTrees ) { - rNumberTree.pRoot->NotifyInvalidChildren(); - rNumberTree.pRootRLHidden->NotifyInvalidChildren(); + rNumberTree.pRoot->NotifyInvalidChildren(rDoc); + rNumberTree.pRootRLHidden->NotifyInvalidChildren(rDoc); } } diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 045d58f63fde..656b4aca04d5 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -1037,7 +1037,7 @@ void SwNumRule::SetIndentOfFirstListLevelAndChangeOthers( const short nNewIndent } } -void SwNumRule::Validate() +void SwNumRule::Validate(const SwDoc& rDoc) { o3tl::sorted_vector< SwList* > aLists; for ( const SwTextNode* pTextNode : maTextNodeList ) @@ -1045,7 +1045,7 @@ void SwNumRule::Validate() aLists.insert( pTextNode->GetDoc().getIDocumentListsAccess().getListByName( pTextNode->GetListId() ) ); } for ( auto aList : aLists ) - aList->ValidateListTree(); + aList->ValidateListTree(rDoc); SetInvalidRule(false); } diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index c1387a1fe2b9..e75a8f42b682 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4267,7 +4267,7 @@ void SwTextNode::AddToList() assert(!mpNodeNum); mpNodeNum.reset(new SwNodeNum(this, false)); - pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel()); + pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel(), GetDoc()); // iterate all frames & if there's one with hidden layout... SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> iter(*this); for (SwTextFrame* pFrame = iter.First(); pFrame; pFrame = iter.Next()) @@ -4297,7 +4297,7 @@ void SwTextNode::AddToListRLHidden() { assert(!mpNodeNumRLHidden); mpNodeNumRLHidden.reset(new SwNodeNum(this, true)); - pList->InsertListItem(*mpNodeNumRLHidden, true, GetAttrListLevel()); + pList->InsertListItem(*mpNodeNumRLHidden, true, GetAttrListLevel(), GetDoc()); } } @@ -4307,7 +4307,7 @@ void SwTextNode::RemoveFromList() RemoveFromListRLHidden(); if ( IsInList() ) { - SwList::RemoveListItem( *mpNodeNum ); + SwList::RemoveListItem(*mpNodeNum, GetDoc()); mpNodeNum.reset(); SetWordCountDirty( true ); @@ -4319,7 +4319,7 @@ void SwTextNode::RemoveFromListRLHidden() if (mpNodeNumRLHidden) // direct access because RemoveFromList doesn't have layout { assert(mpNodeNumRLHidden->GetParent() || !GetNodes().IsDocNodes()); - SwList::RemoveListItem(*mpNodeNumRLHidden); + SwList::RemoveListItem(*mpNodeNumRLHidden, GetDoc()); mpNodeNumRLHidden.reset(); SetWordCountDirty( true ); @@ -4831,16 +4831,18 @@ namespace { if ( mbUpdateListLevel && mrTextNode.IsInList() ) { auto const nLevel(mrTextNode.GetAttrListLevel()); + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); }); + [nLevel, &rDoc](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel, rDoc); }); } if ( mbUpdateListRestart && mrTextNode.IsInList() ) { + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [](SwNodeNum & rNum) { + [&rDoc](SwNodeNum & rNum) { rNum.InvalidateMe(); - rNum.NotifyInvalidSiblings(); + rNum.NotifyInvalidSiblings(rDoc); }); } @@ -4848,8 +4850,9 @@ namespace { { // Repaint all text frames that belong to this numbering to avoid outdated generated // numbers. + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); }); + [&rDoc](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(rDoc); }); } } @@ -5084,23 +5087,26 @@ namespace { if ( mbUpdateListLevel ) { auto const nLevel(mrTextNode.GetAttrListLevel()); + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [nLevel](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel); }); + [nLevel, &rDoc](SwNodeNum & rNum) { rNum.SetLevelInListTree(nLevel, rDoc); }); } if ( mbUpdateListRestart ) { + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [](SwNodeNum & rNum) { + [&rDoc](SwNodeNum & rNum) { rNum.InvalidateMe(); - rNum.NotifyInvalidSiblings(); + rNum.NotifyInvalidSiblings(rDoc); }); } if ( mbUpdateListCount ) { + const SwDoc& rDoc(mrTextNode.GetDoc()); mrTextNode.DoNum( - [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); }); + [&rDoc](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(rDoc); }); } } // End of class <HandleResetAttrAtTextNode> diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 101a70f10ada..91cdb37a8c53 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1177,7 +1177,7 @@ void SwXNumberingRules::replaceByIndex(sal_Int32 nIndex, const uno::Any& rElemen SwXNumberingRules::SetNumberingRuleByIndex( *pRule, *rProperties, nIndex); - pRule->Validate(); + pRule->Validate(*m_pDoc); } else throw uno::RuntimeException(); @@ -2025,7 +2025,7 @@ void SwXNumberingRules::setPropertyValue( const OUString& rPropertyName, const A } else if(pCreatedRule) { - pCreatedRule->Validate(); + pCreatedRule->Validate(*m_pDoc); } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
