diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-10-30 19:21:00 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-10-31 12:37:41 +0100 |
commit | 50e08fe9b0f78badc55fce2ac392de9724ff8906 (patch) | |
tree | edebaaf3601750f13f96e125bd787730fd48d3b4 /sw/source | |
parent | 787d4d6dcac18da6205fe4762a99f44966fd49a5 (diff) |
atrfld: ModifyNotification no more ...
Change-Id: I9a5dc35a71725969bc4b75f0444ba663271e3228
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105079
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/txtnode/atrfld.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 103 |
2 files changed, 57 insertions, 58 deletions
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index a2008e7c4393..da3ef375c304 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -373,9 +373,7 @@ void SwFormatField::UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* p } } if(bTriggerNode) - { - pTextNd->ModifyNotification(pNodeOld, pNodeNew); - } + pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(pNodeOld, pNodeNew)); if(bExpand) { mpTextField->ExpandTextField( pOld == nullptr && pNew == nullptr ); @@ -476,9 +474,7 @@ void SwTextField::ExpandTextField(const bool bForceNotify) const if ( bSameExpandSimpleNotification ) { if( bHiddenParaChanged ) - { - m_pTextNode->ModifyNotification( nullptr, nullptr ); - } + m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, nullptr)); if ( !bForceNotify ) { // done, if no further notification forced. @@ -559,9 +555,7 @@ void SwTextField::NotifyContentChange(SwFormatField& rFormatField) { //if not in undo section notify the change if (m_pTextNode && m_pTextNode->GetNodes().IsDocNodes()) - { - m_pTextNode->ModifyNotification(nullptr, &rFormatField); - } + m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(nullptr, &rFormatField)); } /*static*/ diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index b2141ba2a7b9..f3e93f934c10 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -5238,71 +5238,76 @@ bool SwTextNode::IsInContent() const return !GetDoc().IsInHeaderFooter( SwNodeIndex(*this) ); } -void SwTextNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) +void SwTextNode::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) { - if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) + const auto pOldValue = rHint.m_pOld; + const auto pNewValue = rHint.m_pNew; + bool bWasNotifiable = m_bNotifiable; + m_bNotifiable = false; + + // Override Modify so that deleting styles works properly (outline + // numbering!). + // Never call ChgTextCollUpdateNum for Nodes in Undo. + if( pOldValue + && pNewValue + && RES_FMT_CHG == pOldValue->Which() + && GetRegisteredIn() == static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat + && GetNodes().IsDocNodes() ) { - bool bWasNotifiable = m_bNotifiable; - m_bNotifiable = false; + ChgTextCollUpdateNum( + static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat), + static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat) ); + } - const auto pOldValue = pLegacyHint->m_pOld; - const auto pNewValue = pLegacyHint->m_pNew; - // Override Modify so that deleting styles works properly (outline - // numbering!). - // Never call ChgTextCollUpdateNum for Nodes in Undo. - if( pOldValue - && pNewValue - && RES_FMT_CHG == pOldValue->Which() - && GetRegisteredIn() == static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat - && GetNodes().IsDocNodes() ) - { - ChgTextCollUpdateNum( - static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat), - static_cast<const SwTextFormatColl*>(static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat) ); - } + // reset fill information + if (maFillAttributes && pNewValue) + { + const sal_uInt16 nWhich = pNewValue->Which(); + bool bReset(RES_FMT_CHG == nWhich); // ..on format change (e.g. style changed) - // reset fill information - if (maFillAttributes && pNewValue) + if(!bReset && RES_ATTRSET_CHG == nWhich) // ..on ItemChange from DrawingLayer FillAttributes { - const sal_uInt16 nWhich = pNewValue->Which(); - bool bReset(RES_FMT_CHG == nWhich); // ..on format change (e.g. style changed) - - if(!bReset && RES_ATTRSET_CHG == nWhich) // ..on ItemChange from DrawingLayer FillAttributes - { - SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pNewValue)->GetChgSet()); - - for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem && !bReset; pItem = aIter.NextItem()) - { - bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST; - } - } + SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pNewValue)->GetChgSet()); - if(bReset) + for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem && !bReset; pItem = aIter.NextItem()) { - maFillAttributes.reset(); + bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST; } } - if ( !mbInSetOrResetAttr ) + if(bReset) { - HandleModifyAtTextNode( *this, pOldValue, pNewValue ); + maFillAttributes.reset(); } + } - SwContentNode::SwClientNotify(rModify, rHint); + if ( !mbInSetOrResetAttr ) + { + HandleModifyAtTextNode( *this, pOldValue, pNewValue ); + } - SwDoc& rDoc = GetDoc(); - // #125329# - assure that text node is in document nodes array - if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() ) - { - rDoc.GetNodes().UpdateOutlineNode(*this); - } + SwContentNode::SwClientNotify(*this, rHint); - m_bNotifiable = bWasNotifiable; + SwDoc& rDoc = GetDoc(); + // #125329# - assure that text node is in document nodes array + if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() ) + { + rDoc.GetNodes().UpdateOutlineNode(*this); + } - if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) - { // invalidate cached uno object - SetXParagraph(css::uno::Reference<css::text::XTextContent>(nullptr)); - } + m_bNotifiable = bWasNotifiable; + + if (pOldValue && (RES_REMOVE_UNO_OBJECT == pOldValue->Which())) + { // invalidate cached uno object + SetXParagraph(css::uno::Reference<css::text::XTextContent>(nullptr)); + } +} + +void SwTextNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) +{ + if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) + { + TriggerNodeUpdate(*pLegacyHint); } else if (dynamic_cast<const SwAttrHint*>(&rHint)) { |