diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index 0b4c626306b5e..48fc8b616dd72 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -232,7 +232,6 @@ enum class SfxHintId { SwRemoveUnoObject, SwHiddenParaPrint, SwFormatChange, - SwAttrSetChange, ThisIsAnSdrHint, ThisIsAnSfxEventHint diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx index a966e84049ea0..d5cbb8e5842fb 100644 --- a/sw/inc/fmtcol.hxx +++ b/sw/inc/fmtcol.hxx @@ -148,6 +148,7 @@ public: switch(nWhich) { case RES_OBJECTDYING: + case RES_ATTRSET_CHG: m_bInSwFntCache = false; } } diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index fab0a027a0aa1..3d2ae2730c539 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -30,6 +30,7 @@ class SfxStringItem; class SwFormatChg; class SwUpdateAttr; +class SwAttrSetChg; class SwFormatMeta; class SwFormatContentControl; class SvXMLAttrContainerItem; @@ -429,8 +430,7 @@ inline constexpr sal_uInt16 RES_FORMAT_MSG_BEGIN(RES_FMT_END); inline constexpr TypedWhichId RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN); // 167 inline constexpr sal_uInt16 RES_UPDATEATTR_FMT_CHG( 168); // used by SwUpdateAttr just as an ID to communicate what has changed -inline constexpr sal_uInt16 RES_UPDATEATTR_ATTRSET_CHG( - 169); // used by SwUpdateAttr just as an ID to communicate what has changed +inline constexpr TypedWhichId RES_ATTRSET_CHG(169); inline constexpr TypedWhichId RES_UPDATE_ATTR(170); // empty inline constexpr sal_uInt16 RES_FORMAT_MSG_END(190); diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index 90eb881012d8d..a1d4984b3fb08 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -40,7 +40,6 @@ class SwTableBoxFormat; class SwTableLine; class SwTableLineFormat; class SwTableBox; -class SwAttrSetChg; // Base class for all Message-Hints: // "Overhead" of SfxPoolItem is handled here @@ -320,14 +319,7 @@ class PrintHiddenParaHint final : public SfxHint public: PrintHiddenParaHint() : SfxHint(SfxHintId::SwHiddenParaPrint) {} }; -class AttrSetChangeHint final : public SfxHint -{ -public: - const SwAttrSetChg* m_pOld; - const SwAttrSetChg* m_pNew; - AttrSetChangeHint(const SwAttrSetChg* pOld, const SwAttrSetChg* pNew) : SfxHint(SfxHintId::SwAttrSetChange), m_pOld(pOld), m_pNew(pNew) {} -}; -} // namespace sw +} class SwUpdateAttr final : public SwMsgPoolItem { @@ -391,7 +383,7 @@ public: * SwAttrSetChg is sent when something has changed in the SwAttrSet rTheChgdSet. * 2 Hints are always sent, the old and the new items in the rTheChgdSet. */ -class SwAttrSetChg final +class SwAttrSetChg final : public SwMsgPoolItem { bool m_bDelSet; SwAttrSet* m_pChgSet; ///< what has changed @@ -399,7 +391,7 @@ class SwAttrSetChg final public: SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet ); SwAttrSetChg( const SwAttrSetChg& ); - ~SwAttrSetChg(); + virtual ~SwAttrSetChg() override; /// What has changed const SwAttrSet* GetChgSet() const { return m_pChgSet; } diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 6e667e30be2c7..30951a7d56bda 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -73,7 +73,6 @@ class SwFormatChangeHint; namespace sw { class TextNodeNotificationSuppressor; class RemoveUnoObjectHint; - class AttrSetChangeHint; namespace mark { enum class RestoreMode; } } @@ -244,7 +243,6 @@ public: void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex); /// for hanging TextFormatCollections somewhere else (Outline-Numbering!) void TriggerNodeUpdate(const sw::LegacyModifyHint&); - void TriggerNodeUpdate(const sw::AttrSetChangeHint&); void TriggerNodeUpdate(const sw::RemoveUnoObjectHint&); void TriggerNodeUpdate(const SwFormatChangeHint&); diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx index 10d110bca6641..d6d79d72a9b70 100644 --- a/sw/inc/swevent.hxx +++ b/sw/inc/swevent.hxx @@ -122,23 +122,24 @@ struct SwCallMouseEvent final SwClient::SwClientNotify(rMod, rHint); if (!GetRegisteredIn() || static_cast(rHint).m_pObject == PTR.pFormat) Clear(); + return; } - else if(SfxHintId::SwFormatChange == rHint.GetId()) + if(SfxHintId::SwFormatChange == rHint.GetId()) { auto pChgHint = static_cast(&rHint); assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == eType || EVENT_OBJECT_IMAGEMAP == eType); SwClient::SwClientNotify(rMod, rHint); if (!GetRegisteredIn() || pChgHint->m_pOldFormat == PTR.pFormat) Clear(); + return; } - else if (rHint.GetId() == SfxHintId::SwLegacyModify || SfxHintId::SwAttrSetChange == rHint.GetId()) - { - assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == eType || EVENT_OBJECT_IMAGEMAP == eType); - SwClient::SwClientNotify(rMod, rHint); - bool bClear = !GetRegisteredIn(); - if(bClear) - Clear(); - } + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + assert(EVENT_OBJECT_IMAGE == eType || EVENT_OBJECT_URLITEM == eType || EVENT_OBJECT_IMAGEMAP == eType); + SwClient::SwClientNotify(rMod, rHint); + bool bClear = !GetRegisteredIn(); + if(bClear) + Clear(); } }; diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 15ed54683e149..e96ea4fbe40de 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -45,7 +45,6 @@ public: void TriggerNodeUpdate(const sw::LegacyModifyHint&); void TriggerNodeUpdate(const SwFormatChangeHint&); - void TriggerNodeUpdate(const sw::AttrSetChangeHint&); // get and set TextNode pointer void ChgTextNode( SwTextNode* pNew ) { m_pTextNode = pNew; } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 4f6be8ff159e0..abfce2412516f 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1681,8 +1681,6 @@ namespace ++m_nNotifyCount; else if(dynamic_cast(&rHint)) ++m_nModifyCount; - else if(dynamic_cast(&rHint)) - ++m_nModifyCount; else if(auto pModifyChangedHint = dynamic_cast(&rHint)) { ++m_nModifyChangedCount; @@ -1698,8 +1696,6 @@ namespace { if(dynamic_cast(&rHint)) ++m_nModifyCount; - else if(dynamic_cast(&rHint)) - ++m_nModifyCount; } }; struct TestListener : SvtListener diff --git a/sw/source/core/attr/BorderCacheOwner.cxx b/sw/source/core/attr/BorderCacheOwner.cxx index 8673e57389b41..9f9c56144927d 100644 --- a/sw/source/core/attr/BorderCacheOwner.cxx +++ b/sw/source/core/attr/BorderCacheOwner.cxx @@ -26,6 +26,7 @@ void BorderCacheOwner::InvalidateInSwCache(const sal_uInt16 nWhich) switch (nWhich) { case RES_OBJECTDYING: + case RES_ATTRSET_CHG: case RES_UL_SPACE: case RES_MARGIN_FIRSTLINE: case RES_MARGIN_TEXTLEFT: diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 0351ea76b75fe..b7b552a885a42 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -218,9 +218,7 @@ sw::ClientIteratorBase* sw::ClientIteratorBase::s_pClientIters = nullptr; void SwModify::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify - && rHint.GetId() != SfxHintId::SwRemoveUnoObject - && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwRemoveUnoObject && rHint.GetId() != SfxHintId::SwRemoveUnoObject) return; DBG_TESTSOLARMUTEX(); @@ -266,7 +264,7 @@ void sw::ClientNotifyAttrChg(SwModify& rModify, const SwAttrSet& aSet, SwAttrSet { const SwAttrSetChg aChgOld(aSet, aOld); const SwAttrSetChg aChgNew(aSet, aNew); - const sw::AttrSetChangeHint aHint(&aChgOld, &aChgNew); + const sw::LegacyModifyHint aHint(&aChgOld, &aChgNew); rModify.SwClientNotify(rModify, aHint); } diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 1ec609f0748da..5c4683a078977 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -171,7 +171,7 @@ void SwFormat::CopyAttrs( const SwFormat& rFormat ) SwAttrSetChg aChgOld( m_aSet, aOld ); SwAttrSetChg aChgNew( m_aSet, aNew ); - SwClientNotify(*this, sw::AttrSetChangeHint(&aChgOld, &aChgNew)); // send all modified ones + SwClientNotify(*this, sw::LegacyModifyHint(&aChgOld, &aChgNew)); // send all modified ones } } @@ -234,36 +234,6 @@ void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) SwModify::SwClientNotify(*this, rHint); return; } - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - std::optional oOldClientChg, oNewClientChg; - std::optional oDependsHint(std::in_place, pChangeHint->m_pOld, pChangeHint->m_pNew); - InvalidateInSwCache(); - // NB: this still notifies depends even if this condition is not met, which seems non-obvious - auto pOldAttrSetChg = pChangeHint->m_pOld; - auto pNewAttrSetChg = pChangeHint->m_pNew; - if (pOldAttrSetChg && pNewAttrSetChg && pOldAttrSetChg->GetTheChgdSet() != &m_aSet) - { - // pass only those that are not set... - oNewClientChg.emplace(*pNewAttrSetChg); - oNewClientChg->GetChgSet()->Differentiate(m_aSet); - if(oNewClientChg->Count()) // ... if any - { - oOldClientChg.emplace(*pOldAttrSetChg); - oOldClientChg->GetChgSet()->Differentiate(m_aSet); - oDependsHint.emplace(&*oOldClientChg, &*oNewClientChg); - } - else - oDependsHint.reset(); - } - if(oDependsHint) - { - InvalidateInSwFntCache(); - SwModify::SwClientNotify(*this, *oDependsHint); - } - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); @@ -303,6 +273,27 @@ void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) } break; } + case RES_ATTRSET_CHG: + { + // NB: this still notifies depends even if this condition is not met, which seems non-obvious + auto pOldAttrSetChg = static_cast(pLegacy->m_pOld); + auto pNewAttrSetChg = static_cast(pLegacy->m_pNew); + if (pOldAttrSetChg && pNewAttrSetChg && pOldAttrSetChg->GetTheChgdSet() != &m_aSet) + { + // pass only those that are not set... + oNewClientChg.emplace(*pNewAttrSetChg); + oNewClientChg->GetChgSet()->Differentiate(m_aSet); + if(oNewClientChg->Count()) // ... if any + { + oOldClientChg.emplace(*pOldAttrSetChg); + oOldClientChg->GetChgSet()->Differentiate(m_aSet); + oDependsHint.emplace(&*oOldClientChg, &*oNewClientChg); + } + else + oDependsHint.reset(); + } + break; + } default: // attribute is defined in this format if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false)) diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx index cc41d18a5ea56..c75930ea76a5b 100644 --- a/sw/source/core/attr/hints.cxx +++ b/sw/source/core/attr/hints.cxx @@ -85,14 +85,16 @@ SwTableFormulaUpdate::SwTableFormulaUpdate(const SwTable* pNewTable) } SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet ) - : m_bDelSet( false ), + : SwMsgPoolItem( RES_ATTRSET_CHG ), + m_bDelSet( false ), m_pChgSet( &rSet ), m_pTheChgdSet( &rTheSet ) { } SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet ) - : m_bDelSet( true ), + : SwMsgPoolItem( RES_ATTRSET_CHG ), + m_bDelSet( true ), m_pTheChgdSet( rChgSet.m_pTheChgdSet ) { m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet ); diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 162185339c474..89000ff283f47 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2907,7 +2907,7 @@ void SwCursorShell::SwClientNotify(const SwModify&, const SfxHint& rHint) m_aGrfArrivedLnk.Call(*this); return; } - if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == SfxHintId::SwAttrSetChange) + if (rHint.GetId() == SfxHintId::SwFormatChange) { if( m_bCallChgLnk ) // messages are not forwarded @@ -2925,7 +2925,8 @@ void SwCursorShell::SwClientNotify(const SwModify&, const SfxHint& rHint) nWhich = RES_OBJECTDYING; if( m_bCallChgLnk && ( !isFormatMessage(nWhich) - || nWhich == RES_UPDATE_ATTR )) + || nWhich == RES_UPDATE_ATTR + || nWhich == RES_ATTRSET_CHG )) // messages are not forwarded // #i6681#: RES_UPDATE_ATTR is implicitly unset in // SwTextNode::Insert(SwTextHint*, sal_uInt16); we react here and thus do @@ -2935,6 +2936,7 @@ void SwCursorShell::SwClientNotify(const SwModify&, const SfxHint& rHint) { EndListeningAll(); } + } /** Does the current cursor create a selection? diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 2ef3dfd0c1047..4945c9f948e83 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -662,7 +662,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet ) { SwAttrSetChg aChgOld( aOld, aOld ); SwAttrSetChg aChgNew( aNew, aNew ); - aCallMod.CallSwClientNotify(sw::AttrSetChangeHint( &aChgOld, &aChgNew )); // all changed are sent + aCallMod.CallSwClientNotify(sw::LegacyModifyHint( &aChgOld, &aChgNew )); // all changed are sent } // remove the default formats from the object again diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index b829b051248df..cbce97a20fbb4 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -249,9 +249,16 @@ void SwEndNoteInfo::SwClientNotify( const SwModify& rModify, const SfxHint& rHin if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast(&rHint); - CheckRegistration( pLegacyHint->m_pOld ); + switch(pLegacyHint->GetWhich()) + { + case RES_ATTRSET_CHG: + UpdateFormatOrAttr(); + break; + default: + CheckRegistration( pLegacyHint->m_pOld ); + } } - else if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwFormatChange) { UpdateFormatOrAttr(); } diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index cb3ad58e12773..daecd6760bd60 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -139,8 +139,7 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH CallSwClientNotify(rHint); return; } - else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange - && rHint.GetId() != SfxHintId::SwAttrSetChange) + else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange) return; if(GetDoc()->IsInDtor()) { @@ -161,9 +160,30 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH { auto pLegacy = static_cast(&rHint); const auto pNew = pLegacy->m_pNew; + const SwAttrSetChg *pNewChgSet = nullptr; switch( pLegacy->GetWhich() ) { + case RES_ATTRSET_CHG: + // Only recalculate if we're not the sender! + pNewChgSet = &pNew->StaticWhichCast(RES_ATTRSET_CHG); + pNewFirstLineIndent = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_FIRSTLINE, false); + pNewTextLeftMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_TEXTLEFT, false); + pNewRightMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_RIGHT, false); + pNewULSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_UL_SPACE, false ); + aFontSizeArr[0] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_FONTSIZE, false ); + aFontSizeArr[1] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CJK_FONTSIZE, false ); + aFontSizeArr[2] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CTL_FONTSIZE, false ); + // #i70223#, #i84745# + // check, if attribute set is applied to this paragraph style + if ( bAssignedToListLevelOfOutlineStyle && + pNewChgSet->GetTheChgdSet() == &GetAttrSet() ) + { + pNewNumRuleItem = pNewChgSet->GetChgSet()->GetItemIfSet( RES_PARATR_NUMRULE, false ); + } + + break; + case RES_MARGIN_FIRSTLINE: pNewFirstLineIndent = &pNew->StaticWhichCast(RES_MARGIN_FIRSTLINE); break; @@ -196,27 +216,6 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH break; } } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - const SwAttrSetChg *pNewChgSet = pChangeHint->m_pNew; - - // Only recalculate if we're not the sender! - pNewFirstLineIndent = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_FIRSTLINE, false); - pNewTextLeftMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_TEXTLEFT, false); - pNewRightMargin = pNewChgSet->GetChgSet()->GetItemIfSet(RES_MARGIN_RIGHT, false); - pNewULSpace = pNewChgSet->GetChgSet()->GetItemIfSet( RES_UL_SPACE, false ); - aFontSizeArr[0] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_FONTSIZE, false ); - aFontSizeArr[1] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CJK_FONTSIZE, false ); - aFontSizeArr[2] = pNewChgSet->GetChgSet()->GetItemIfSet( RES_CHRATR_CTL_FONTSIZE, false ); - // #i70223#, #i84745# - // check, if attribute set is applied to this paragraph style - if ( bAssignedToListLevelOfOutlineStyle && - pNewChgSet->GetTheChgdSet() == &GetAttrSet() ) - { - pNewNumRuleItem = pNewChgSet->GetChgSet()->GetItemIfSet( RES_PARATR_NUMRULE, false ); - } - } else // rHint.GetId() == SfxHintId::SwFormatChange { if( GetAttrSet().GetParent() ) @@ -364,13 +363,12 @@ void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rH // if the parent changed, we can't know how many properties are involved: always notify a change if (rHint.GetId() == SfxHintId::SwLegacyModify) { - if (bNewParent || !nNoNotify) - SwFormatColl::SwClientNotify(rModify, rHint); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - const SwAttrSetChg *pOldChgSet = pChangeHint->m_pOld; + auto pLegacy = static_cast(&rHint); + const auto pOld = pLegacy->m_pOld; + const SwAttrSetChg *pOldChgSet = nullptr; + + if( pLegacy->GetWhich() == RES_ATTRSET_CHG) + pOldChgSet = &pOld->StaticWhichCast(RES_ATTRSET_CHG); if (bNewParent || !nNoNotify || (pOldChgSet && pOldChgSet->GetChgSet()->Count() > nNoNotify)) SwFormatColl::SwClientNotify(rModify, rHint); diff --git a/sw/source/core/doc/lineinfo.cxx b/sw/source/core/doc/lineinfo.cxx index 8cc455b0aa827..af2094fd0c75f 100644 --- a/sw/source/core/doc/lineinfo.cxx +++ b/sw/source/core/doc/lineinfo.cxx @@ -114,9 +114,7 @@ void SwLineNumberInfo::SetCharFormat( SwCharFormat *pChFormat ) void SwLineNumberInfo::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify - && rHint.GetId() != SfxHintId::SwFormatChange - && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange) return; if (rHint.GetId() == SfxHintId::SwLegacyModify) { diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index affd0d7388ffd..a0a992982a4b0 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -756,97 +756,95 @@ void SwNoTextFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint InvalidatePrt(); SetCompletePaint(); } + return; } - else if(rHint.GetId() == SfxHintId::SwPreGraphicArrived + if(rHint.GetId() == SfxHintId::SwPreGraphicArrived || rHint.GetId() == SfxHintId::SwGraphicPieceArrived || rHint.GetId() == SfxHintId::SwLinkedGraphicStreamArrived) { OnGraphicArrived(); + return; } else if (rHint.GetId() == SfxHintId::SwFormatChange) { ClearCache(); InvalidatePrt(); SetCompletePaint(); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + sal_uInt16 nWhich = pLegacy->GetWhich(); + + SwContentFrame::SwClientNotify(rModify, rHint); + + switch( nWhich ) { - auto pChangeHint = static_cast(&rHint); - SwContentFrame::SwClientNotify(rModify, rHint); + case RES_OBJECTDYING: + break; - sal_uInt16 n; - for( n = RES_GRFATR_BEGIN; n < RES_GRFATR_END; ++n ) - if( SfxItemState::SET == pChangeHint->m_pOld->GetChgSet()-> - GetItemState( n, false )) - { - ClearCache(); + case RES_UPDATE_ATTR: + if (GetNode()->GetNodeType() != SwNodeType::Grf) { + break; + } + ClearCache(); + break; - if(RES_GRFATR_ROTATION == n) + case RES_ATTRSET_CHG: + { + sal_uInt16 n; + for( n = RES_GRFATR_BEGIN; n < RES_GRFATR_END; ++n ) + if( SfxItemState::SET == static_cast(pLegacy->m_pOld)->GetChgSet()-> + GetItemState( n, false )) { - // RotGrfFlyFrame: Update Handles in view, these may be rotation-dependent - // (e.g. crop handles) and need a visualisation update - if ( GetNode()->GetNodeType() == SwNodeType::Grf ) - { - SwGrfNode* pNd = static_cast( GetNode()); - SwViewShell *pVSh = pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); + ClearCache(); - if(pVSh) + if(RES_GRFATR_ROTATION == n) + { + // RotGrfFlyFrame: Update Handles in view, these may be rotation-dependent + // (e.g. crop handles) and need a visualisation update + if ( GetNode()->GetNodeType() == SwNodeType::Grf ) { - SdrView* pDrawView = pVSh->GetDrawView(); + SwGrfNode* pNd = static_cast( GetNode()); + SwViewShell *pVSh = pNd->GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell(); - if(pDrawView) + if(pVSh) { - pDrawView->AdjustMarkHdl(nullptr); + SdrView* pDrawView = pVSh->GetDrawView(); + + if(pDrawView) + { + pDrawView->AdjustMarkHdl(nullptr); + } } - } - // RotateFlyFrame3 - invalidate needed for ContentFrame (inner, this) - // and LayoutFrame (outer, GetUpper). It is possible to only invalidate - // the outer frame, but that leads to an in-between state that gets - // potentially painted - if(GetUpper()) - { - GetUpper()->InvalidateAll_(); - } + // RotateFlyFrame3 - invalidate needed for ContentFrame (inner, this) + // and LayoutFrame (outer, GetUpper). It is possible to only invalidate + // the outer frame, but that leads to an in-between state that gets + // potentially painted + if(GetUpper()) + { + GetUpper()->InvalidateAll_(); + } - InvalidateAll_(); + InvalidateAll_(); + } } + break; } - break; - } - if( RES_GRFATR_END == n ) // not found - return ; - - InvalidatePrt(); - SetCompletePaint(); - } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - sal_uInt16 nWhich = pLegacy->GetWhich(); - - SwContentFrame::SwClientNotify(rModify, rHint); - - switch( nWhich ) - { - case RES_OBJECTDYING: - break; - - case RES_UPDATE_ATTR: - if (GetNode()->GetNodeType() != SwNodeType::Grf) { - break; - } - ClearCache(); - break; - - default: - if ( !pLegacy->m_pNew || !isGRFATR(nWhich) ) - return; + if( RES_GRFATR_END == n ) // not found + return ; } + break; - InvalidatePrt(); - SetCompletePaint(); + default: + if ( !pLegacy->m_pNew || !isGRFATR(nWhich) ) + return; } + + InvalidatePrt(); + SetCompletePaint(); } static void lcl_correctlyAlignRect( SwRect& rAlignedGrfArea, const SwRect& rInArea, vcl::RenderContext const * pOut ) diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 5708fdbf1cb2a..f8fc67f0dab78 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -308,20 +308,23 @@ void SwNumFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) UpdateNumNodes(*const_cast(pFormat->GetDoc())); return; } - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - // Look for the NumRules object in the Doc where this NumFormat is set. - // The format does not need to exist! - const SwCharFormat* pFormat = GetCharFormat(); - - if(pFormat && !pFormat->GetDoc()->IsInDtor()) - UpdateNumNodes(*const_cast(pFormat->GetDoc())); - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); - CheckRegistration(pLegacy->m_pOld); + // Look for the NumRules object in the Doc where this NumFormat is set. + // The format does not need to exist! + const SwCharFormat* pFormat = nullptr; + switch(pLegacy->GetWhich()) + { + case RES_ATTRSET_CHG: + pFormat = GetCharFormat(); + break; + } + + if(pFormat && !pFormat->GetDoc()->IsInDtor()) + UpdateNumNodes(*const_cast(pFormat->GetDoc())); + else + CheckRegistration(pLegacy->m_pOld); } OUString SwNumFormat::GetCharFormatName() const diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index a78d72477b45b..054176a7682af 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1103,7 +1103,7 @@ void SwContentNode::UpdateAttr(const SwUpdateAttr& rUpdate) { if (GetNodes().IsDocNodes() && IsTextNode() - && RES_UPDATEATTR_ATTRSET_CHG == rUpdate.getWhichAttr()) + && RES_ATTRSET_CHG == rUpdate.getWhichAttr()) static_cast(this)->SetCalcHiddenCharFlags(); CallSwClientNotify(sw::LegacyModifyHint(&rUpdate, &rUpdate)); } @@ -1130,23 +1130,13 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint) AttrSetHandleHelper::SetParent(mpAttrSet, *this, pFormatColl, pFormatColl); CallSwClientNotify(rHint); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - InvalidateInSwCache(); - if (GetNodes().IsDocNodes() - && IsTextNode() - && pChangeHint->m_pOld - && SfxItemState::SET == pChangeHint->m_pOld->GetChgSet()->GetItemState(RES_CHRATR_HIDDEN, false)) - static_cast(this)->SetCalcHiddenCharFlags(); - CallSwClientNotify(rHint); - } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacyHint = static_cast(&rHint); const sal_uInt16 nWhich = pLegacyHint->GetWhich(); InvalidateInSwCache(nWhich); + bool bCalcHidden = false; switch(nWhich) { case RES_OBJECTDYING: @@ -1165,6 +1155,14 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint) } break; + case RES_ATTRSET_CHG: + if (GetNodes().IsDocNodes() + && IsTextNode() + && pLegacyHint->m_pOld + && SfxItemState::SET == pLegacyHint->m_pOld->StaticWhichCast(RES_ATTRSET_CHG).GetChgSet()->GetItemState(RES_CHRATR_HIDDEN, false)) + bCalcHidden = true; + break; + case RES_UPDATE_ATTR: // RES_UPDATE_ATTR _should_ always contain a SwUpdateAttr hint in old and new. // However, faking one with just a basic SfxPoolItem setting a WhichId has been observed. @@ -1185,6 +1183,8 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint) UpdateAttr(rUpdateAttr); return; } + if(bCalcHidden) + static_cast(this)->SetCalcHiddenCharFlags(); CallSwClientNotify(rHint); } else if (rHint.GetId() == SfxHintId::SwAutoFormatUsedHint) diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 9d82953715a18..fbb00098e1e9e 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -403,63 +403,19 @@ void SwSection::Notify(SfxHint const& rHint) auto rSectionHidden = static_cast(rHint); m_Data.SetHiddenFlag(rSectionHidden.m_isHidden || (m_Data.IsHidden() && m_Data.IsCondHidden())); return; - } else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + } else if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - + auto pLegacy = static_cast(&rHint); + auto pOld = pLegacy->m_pOld; + auto pNew = pLegacy->m_pNew; bool bUpdateFootnote = false; - if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - auto pOld = pLegacy->m_pOld; - auto pNew = pLegacy->m_pNew; - switch(pLegacy->GetWhich()) - { - case RES_PROTECT: - if( pNew ) - { - bool bNewFlag = - static_cast(pNew)->IsContentProtected(); - // this used to inherit the flag from the parent, but then there is - // no way to turn it off in an inner section - m_Data.SetProtectFlag( bNewFlag ); - } - return; - // edit in readonly sections - case RES_EDIT_IN_READONLY: - if( pNew ) - { - const bool bNewFlag = - static_cast(pNew)->GetValue(); - m_Data.SetEditInReadonlyFlag( bNewFlag ); - } - return; - - case RES_COL: - // Is handled by the Layout, if appropriate - break; - - case RES_FTN_AT_TXTEND: - case RES_END_AT_TXTEND: - if( pNew && pOld ) - { - bUpdateFootnote = true; - } - break; - - default: - CheckRegistration( pOld ); - break; - } - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange + switch(pLegacy->GetWhich()) { - auto pChangeHint = static_cast(&rHint); - const SwAttrSetChg* pOld = pChangeHint->m_pOld; - const SwAttrSetChg* pNew = pChangeHint->m_pNew; + case RES_ATTRSET_CHG: if (pNew && pOld) { - SfxItemSet* pNewSet = const_cast(pNew)->GetChgSet(); - SfxItemSet* pOldSet = const_cast(pOld)->GetChgSet(); + SfxItemSet* pNewSet = const_cast(static_cast(pNew))->GetChgSet(); + SfxItemSet* pOldSet = const_cast(static_cast(pOld))->GetChgSet(); if( const SvxProtectItem* pItem = pNewSet->GetItemIfSet( RES_PROTECT, false ) ) @@ -489,6 +445,43 @@ void SwSection::Notify(SfxHint const& rHint) if( !pNewSet->Count() ) return; } + break; + + case RES_PROTECT: + if( pNew ) + { + bool bNewFlag = + static_cast(pNew)->IsContentProtected(); + // this used to inherit the flag from the parent, but then there is + // no way to turn it off in an inner section + m_Data.SetProtectFlag( bNewFlag ); + } + return; + // edit in readonly sections + case RES_EDIT_IN_READONLY: + if( pNew ) + { + const bool bNewFlag = + static_cast(pNew)->GetValue(); + m_Data.SetEditInReadonlyFlag( bNewFlag ); + } + return; + + case RES_COL: + // Is handled by the Layout, if appropriate + break; + + case RES_FTN_AT_TXTEND: + case RES_END_AT_TXTEND: + if( pNew && pOld ) + { + bUpdateFootnote = true; + } + break; + + default: + CheckRegistration( pOld ); + break; } if( bUpdateFootnote ) @@ -734,15 +727,19 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) SwFrameFormat::SwClientNotify(rMod, rHint); return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + sal_uInt16 nWhich = pLegacy->GetWhich(); + auto pOld = pLegacy->m_pOld; + auto pNew = pLegacy->m_pNew; + switch( nWhich ) { - auto pChangeHint = static_cast(&rHint); - const SwAttrSetChg* pOld = pChangeHint->m_pOld; - const SwAttrSetChg* pNew = pChangeHint->m_pNew; + case RES_ATTRSET_CHG: if (HasWriterListeners() && pOld && pNew) { - SfxItemSet* pNewSet = const_cast(pNew)->GetChgSet(); - SfxItemSet* pOldSet = const_cast(pOld)->GetChgSet(); + SfxItemSet* pNewSet = const_cast(static_cast(pNew))->GetChgSet(); + SfxItemSet* pOldSet = const_cast(static_cast(pOld))->GetChgSet(); const SfxPoolItem *pItem; if( SfxItemState::SET == pNewSet->GetItemState( RES_PROTECT, false, &pItem )) @@ -775,19 +772,11 @@ void SwSectionFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) pNewSet->ClearItem( RES_END_AT_TXTEND ); pOldSet->ClearItem( RES_END_AT_TXTEND ); } - if( !pOld->GetChgSet()->Count() ) + if( !static_cast(pOld)->GetChgSet()->Count() ) return; } - SwFrameFormat::SwClientNotify(rMod, rHint); - } - else if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - auto pLegacy = static_cast(&rHint); - sal_uInt16 nWhich = pLegacy->GetWhich(); - auto pOld = pLegacy->m_pOld; - auto pNew = pLegacy->m_pNew; - switch( nWhich ) - { + break; + case RES_FTN_AT_TXTEND: case RES_END_AT_TXTEND: case RES_PROTECT: diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 63dbcae0373c8..74edb2d3051aa 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1398,16 +1398,17 @@ namespace { sal_uInt16 nWhich = _rItem.Which(); const SwFormatAnchor* pAnchorFormat = nullptr; - if ( RES_ANCHOR == nWhich ) + if ( RES_ATTRSET_CHG == nWhich ) + { + pAnchorFormat = static_cast(_rItem).GetChgSet()-> + GetItemIfSet( RES_ANCHOR, false ); + } + else if ( RES_ANCHOR == nWhich ) { pAnchorFormat = &static_cast(_rItem); } return pAnchorFormat; } - const SwFormatAnchor* lcl_getAnchorFormat( const SwAttrSetChg& _rItem ) - { - return _rItem.GetChgSet()->GetItemIfSet( RES_ANCHOR, false ); - } } void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) @@ -1425,30 +1426,14 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) // #i51474# GetAnchoredObj(nullptr)->ResetLayoutProcessBools(); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify) { + auto pLegacyHint = static_cast(&rHint); SAL_WARN_IF(mbDisconnectInProgress, "sw.core", " called during disconnection."); - const SwFormatAnchor* pNewAnchorFormat = nullptr; - const SwFormatAnchor* pOldAnchorFormat = nullptr; - if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacyHint = static_cast(&rHint); - if (pLegacyHint->m_pNew) - pNewAnchorFormat = lcl_getAnchorFormat(*pLegacyHint->m_pNew); - if (pLegacyHint->m_pOld) - pOldAnchorFormat = lcl_getAnchorFormat(*pLegacyHint->m_pOld); - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if (pChangeHint->m_pNew) - pNewAnchorFormat = lcl_getAnchorFormat(*pChangeHint->m_pNew); - if (pChangeHint->m_pOld) - pOldAnchorFormat = lcl_getAnchorFormat(*pChangeHint->m_pOld); - } - - if(pNewAnchorFormat) + const SfxPoolItem* pNew = pLegacyHint->m_pNew; + sal_uInt16 nWhich = pNew ? pNew->Which() : 0; + if(const SwFormatAnchor* pNewAnchorFormat = pNew ? lcl_getAnchorFormat(*pNew) : nullptr) { // Do not respond to a Reset Anchor! if(GetFormat()->GetAttrSet().GetItemState(RES_ANCHOR, false) == SfxItemState::SET) @@ -1473,6 +1458,7 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) lcl_NotifyBackgroundOfObj(*this, *GetMaster(), pOldRect); NotifyBackgroundOfAllVirtObjs(pOldRect); + const SwFormatAnchor* pOldAnchorFormat = pLegacyHint->m_pOld ? lcl_getAnchorFormat(*pLegacyHint->m_pOld) : nullptr; if(!pOldAnchorFormat || (pOldAnchorFormat->GetAnchorId() != pNewAnchorFormat->GetAnchorId())) { if(maAnchoredDrawObj.DrawObj()) @@ -1494,40 +1480,34 @@ void SwDrawContact::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) maAnchoredDrawObj.GetDrawObj()->GetUserCall() ) { bool bUpdateSortedObjsList(false); - if (rHint.GetId() == SfxHintId::SwLegacyModify) + switch(nWhich) { - auto pLegacyHint = static_cast(&rHint); - sal_uInt16 nWhich = pLegacyHint->m_pNew ? pLegacyHint->m_pNew->Which() : 0; - switch(nWhich) + case RES_UL_SPACE: + case RES_LR_SPACE: + case RES_HORI_ORIENT: + case RES_VERT_ORIENT: + case RES_FOLLOW_TEXT_FLOW: // #i28701# - add attribute 'Follow text flow' + break; + case RES_SURROUND: + case RES_OPAQUE: + case RES_WRAP_INFLUENCE_ON_OBJPOS: + // --> #i28701# - on change of wrapping style, hell|heaven layer, + // or wrapping style influence an update of the list, + // the drawing object is registered in, has to be performed. This is triggered + // by the 1st parameter of method call . + bUpdateSortedObjsList = true; + break; + case RES_ATTRSET_CHG: // #i35443# { - case RES_UL_SPACE: - case RES_LR_SPACE: - case RES_HORI_ORIENT: - case RES_VERT_ORIENT: - case RES_FOLLOW_TEXT_FLOW: // #i28701# - add attribute 'Follow text flow' - break; - case RES_SURROUND: - case RES_OPAQUE: - case RES_WRAP_INFLUENCE_ON_OBJPOS: - // --> #i28701# - on change of wrapping style, hell|heaven layer, - // or wrapping style influence an update of the list, - // the drawing object is registered in, has to be performed. This is triggered - // by the 1st parameter of method call . + auto pChgSet = static_cast(pNew)->GetChgSet(); + if(pChgSet->GetItemState(RES_SURROUND, false) == SfxItemState::SET || + pChgSet->GetItemState(RES_OPAQUE, false) == SfxItemState::SET || + pChgSet->GetItemState(RES_WRAP_INFLUENCE_ON_OBJPOS, false) == SfxItemState::SET) bUpdateSortedObjsList = true; - break; - default: - assert(!" - unhandled attribute?"); } - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange) - { - // #i35443# - auto pChangeHint = static_cast(&rHint); - auto pChgSet = pChangeHint->m_pNew->GetChgSet(); - if(pChgSet->GetItemState(RES_SURROUND, false) == SfxItemState::SET || - pChgSet->GetItemState(RES_OPAQUE, false) == SfxItemState::SET || - pChgSet->GetItemState(RES_WRAP_INFLUENCE_ON_OBJPOS, false) == SfxItemState::SET) - bUpdateSortedObjsList = true; + break; + default: + assert(!" - unhandled attribute?"); } lcl_NotifyBackgroundOfObj(*this, *GetMaster(), nullptr); NotifyBackgroundOfAllVirtObjs(nullptr); diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx index 5987cb3851cd1..b990f2d846bcc 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -85,9 +85,7 @@ SwDDETable::~SwDDETable() void SwDDETable::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwAutoFormatUsedHint - || rHint.GetId() == SfxHintId::SwAttrSetChange) + if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwAutoFormatUsedHint) { SwTable::SwClientNotify(rModify, rHint); } diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index c6ce1a7469226..cced5f6802765 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -2266,14 +2266,9 @@ void SwRefPageGetFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint CallSwClientNotify(rHint); return; } - if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - const sw::LegacyModifyHint* pLegacy = nullptr; - const sw::AttrSetChangeHint* pChangeHint = nullptr; - if (rHint.GetId() == SfxHintId::SwLegacyModify) - pLegacy = static_cast(&rHint); - else // rHint.GetId() == SfxHintId::SwAttrSetChange - pChangeHint = static_cast(&rHint); + auto pLegacy = static_cast(&rHint); auto const ModifyImpl = [this](SwRootFrame const*const pLayout) { // first collect all SetPageRefFields @@ -2288,8 +2283,7 @@ void SwRefPageGetFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint }; // update all GetReference fields - if( (pLegacy && !pLegacy->m_pNew && !pLegacy->m_pOld && HasWriterListeners()) - || (!pChangeHint->m_pNew && !pChangeHint->m_pOld && HasWriterListeners())) + if( !pLegacy->m_pNew && !pLegacy->m_pOld && HasWriterListeners() ) { SwRootFrame const* pLayout(nullptr); SwRootFrame const* pLayoutRLHidden(nullptr); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 496aabffedb17..a063586b482f6 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -1165,19 +1165,6 @@ void SwGetRefFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint) CallSwClientNotify(rHint); return; } - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(!pChangeHint->m_pNew && !pChangeHint->m_pOld) - // update to all GetReference fields - // hopefully, this codepath is soon dead code, and - // UpdateGetReferences gets only called directly - UpdateGetReferences(); - else - // forward to text fields, they "expand" the text - CallSwClientNotify(rHint); - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx index e9b50826c5857..9e170b73b2614 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -223,12 +223,6 @@ void SwUserFieldType::SwClientNotify(const SwModify&, const SfxHint& rHint) if (!pLegacy->m_pOld && !pLegacy->m_pNew) m_bValidValue = false; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if (!pChangeHint->m_pOld && !pChangeHint->m_pNew) - m_bValidValue = false; - } CallSwClientNotify(rHint); // update input fields that might be connected to the user field diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx index f599fa86b8888..dc1ce0abc3fd5 100644 --- a/sw/source/core/inc/flyfrm.hxx +++ b/sw/source/core/inc/flyfrm.hxx @@ -96,7 +96,6 @@ protected: // Predecessor/Successor for chaining with text flow SwFlyFrame *m_pPrevLink, *m_pNextLink; static const SwFormatAnchor* GetAnchorFromPoolItem(const SfxPoolItem& rItem); - static const SwFormatAnchor* GetAnchorFromPoolItem(const SwAttrSetChg& rItem); private: // It must be possible to block Content-bound flys so that they will be not diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index d67d2e5a4d433..98f41721d89bd 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2765,73 +2765,77 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) SwFormat::SwClientNotify(rMod, rHint); return; } - else if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + else if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - + auto pLegacy = static_cast(&rHint); + const sal_uInt16 nNewWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0; + const SwAttrSetChg* pNewAttrSetChg = nullptr; const SwFormatHeader* pH = nullptr; const SwFormatFooter* pF = nullptr; SwNode* pNewAnchorNode = nullptr; - SwNode* pOldAnchorNode = nullptr; - if (rHint.GetId() == SfxHintId::SwLegacyModify) + switch(nNewWhich) { - auto pLegacy = static_cast(&rHint); - const sal_uInt16 nNewWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0; - switch(nNewWhich) + case RES_ATTRSET_CHG: { - case RES_HEADER: - pH = static_cast(pLegacy->m_pNew); - break; - case RES_FOOTER: - pF = static_cast(pLegacy->m_pNew); - break; - case RES_ANCHOR: - pNewAnchorNode = static_cast(pLegacy->m_pNew)->GetAnchorNode(); - break; - } - const sal_uInt16 nOldWhich = pLegacy->m_pOld ? pLegacy->m_pOld->Which() : 0; - switch(nOldWhich) - { - case RES_ANCHOR: - pOldAnchorNode = static_cast(pLegacy->m_pOld)->GetAnchorNode(); - break; - } - assert(nOldWhich == nNewWhich || !nOldWhich || !nNewWhich); - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange - { - auto pChangeHint = static_cast(&rHint); - const SwAttrSetChg* pNewAttrSetChg = pChangeHint->m_pNew; - pH = pNewAttrSetChg->GetChgSet()->GetItem(RES_HEADER, false); - pF = pNewAttrSetChg->GetChgSet()->GetItem(RES_FOOTER, false); + pNewAttrSetChg = static_cast(pLegacy->m_pNew); + pH = pNewAttrSetChg->GetChgSet()->GetItem(RES_HEADER, false); + pF = pNewAttrSetChg->GetChgSet()->GetItem(RES_FOOTER, false); - // reset fill information - if(maFillAttributes && supportsFullDrawingLayerFillAttributeSet()) - { - SfxItemIter aIter(*pNewAttrSetChg->GetChgSet()); - for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) + // reset fill information + if(maFillAttributes && supportsFullDrawingLayerFillAttributeSet()) { - if(!IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST) + SfxItemIter aIter(*pNewAttrSetChg->GetChgSet()); + for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) { - maFillAttributes.reset(); - break; + if(!IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST) + { + maFillAttributes.reset(); + break; + } } } + const SwFormatAnchor* pAnchor = pNewAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false); + if(pAnchor) + { + pNewAnchorNode = pAnchor->GetAnchorNode(); + assert(pNewAnchorNode == nullptr || // style's set must not contain position! + pNewAttrSetChg->GetTheChgdSet() == &m_aSet); + } + break; } - if (const SwFormatAnchor* pAnchor = pNewAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false)) - { - pNewAnchorNode = pAnchor->GetAnchorNode(); - assert(pNewAnchorNode == nullptr || // style's set must not contain position! - pNewAttrSetChg->GetTheChgdSet() == &m_aSet); - } - const SwAttrSetChg* pOldAttrSetChg = pChangeHint->m_pOld; - if (const SwFormatAnchor* pAnchor = pOldAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false)) + case RES_HEADER: + pH = static_cast(pLegacy->m_pNew); + break; + case RES_FOOTER: + pF = static_cast(pLegacy->m_pNew); + break; + case RES_ANCHOR: + pNewAnchorNode = static_cast(pLegacy->m_pNew)->GetAnchorNode(); + break; + } + const sal_uInt16 nOldWhich = pLegacy->m_pOld ? pLegacy->m_pOld->Which() : 0; + SwNode* pOldAnchorNode = nullptr; + switch(nOldWhich) + { + case RES_ATTRSET_CHG: { - pOldAnchorNode = pAnchor->GetAnchorNode(); - assert(pOldAnchorNode == nullptr || // style's set must not contain position! - pOldAttrSetChg->GetTheChgdSet() == &m_aSet); + const SwAttrSetChg* pOldAttrSetChg = nullptr; + pOldAttrSetChg = static_cast(pLegacy->m_pOld); + const SwFormatAnchor* pAnchor = pOldAttrSetChg->GetChgSet()->GetItem(RES_ANCHOR, false); + if(pAnchor) + { + pOldAnchorNode = pAnchor->GetAnchorNode(); + assert(pOldAnchorNode == nullptr || // style's set must not contain position! + pOldAttrSetChg->GetTheChgdSet() == &m_aSet); + } + break; } + case RES_ANCHOR: + pOldAnchorNode = static_cast(pLegacy->m_pOld)->GetAnchorNode(); + break; } + assert(nOldWhich == nNewWhich || !nOldWhich || !nNewWhich); if(pH && pH->IsActive() && !pH->GetHeaderFormat()) { //If he doesn't have one, I'll add one SwFrameFormat* pFormat = GetDoc()->getIDocumentLayoutAccess().MakeLayoutFormat(RndStdIds::HEADER, nullptr); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 86cac25337de5..60317b17ec284 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -801,8 +801,7 @@ bool SwFlyFrame::FrameSizeChg( const SwFormatFrameSize &rFrameSize ) void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { if (rHint.GetId() == SfxHintId::SwFormatChange || - rHint.GetId() == SfxHintId::SwLegacyModify || - rHint.GetId() == SfxHintId::SwAttrSetChange) + rHint.GetId() == SfxHintId::SwLegacyModify) { SwFlyFrameInvFlags eInvFlags = SwFlyFrameInvFlags::NONE; if (rHint.GetId() == SfxHintId::SwFormatChange) @@ -810,17 +809,17 @@ void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) auto pChangeHint = static_cast(&rHint); UpdateAttrForFormatChange(pChangeHint->m_pOldFormat, pChangeHint->m_pNewFormat, eInvFlags); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + else // rHint.GetId() == SfxHintId::SwLegacyModify { - auto pChangeHint = static_cast(&rHint); - if(pChangeHint->m_pNew && pChangeHint->m_pOld) + auto pLegacy = static_cast(&rHint); + if(pLegacy->m_pNew && pLegacy->m_pOld && RES_ATTRSET_CHG == pLegacy->m_pNew->Which()) { - SfxItemIter aNIter(*pChangeHint->m_pNew->GetChgSet()); - SfxItemIter aOIter(*pChangeHint->m_pOld->GetChgSet()); + SfxItemIter aNIter(*static_cast(pLegacy->m_pNew)->GetChgSet()); + SfxItemIter aOIter(*static_cast(pLegacy->m_pOld)->GetChgSet()); const SfxPoolItem* pNItem = aNIter.GetCurItem(); const SfxPoolItem* pOItem = aOIter.GetCurItem(); - SwAttrSetChg aOldSet(*pChangeHint->m_pOld); - SwAttrSetChg aNewSet(*pChangeHint->m_pNew); + SwAttrSetChg aOldSet(*static_cast(pLegacy->m_pOld)); + SwAttrSetChg aNewSet(*static_cast(pLegacy->m_pNew)); do { UpdateAttr_(pOItem, pNItem, eInvFlags, &aOldSet, &aNewSet); @@ -828,13 +827,10 @@ void SwFlyFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) pOItem = aOIter.NextItem(); } while(pNItem); if(aOldSet.Count() || aNewSet.Count()) - SwLayoutFrame::SwClientNotify(rMod, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); + SwLayoutFrame::SwClientNotify(rMod, sw::LegacyModifyHint(&aOldSet, &aNewSet)); } - } - else // rHint.GetId() == SfxHintId::SwLegacyModify - { - auto pLegacy = static_cast(&rHint); - UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); + else + UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); } if(eInvFlags == SwFlyFrameInvFlags::NONE) @@ -3503,6 +3499,8 @@ const SwFormatAnchor* SwFlyFrame::GetAnchorFromPoolItem(const SfxPoolItem& rItem { switch(rItem.Which()) { + case RES_ATTRSET_CHG: + return rItem.StaticWhichCast(RES_ATTRSET_CHG).GetChgSet()->GetItem(RES_ANCHOR, false); case RES_ANCHOR: return static_cast(&rItem); default: @@ -3510,11 +3508,6 @@ const SwFormatAnchor* SwFlyFrame::GetAnchorFromPoolItem(const SfxPoolItem& rItem } } -const SwFormatAnchor* SwFlyFrame::GetAnchorFromPoolItem(const SwAttrSetChg& rItem) -{ - return rItem.GetChgSet()->GetItem(RES_ANCHOR, false); -} - const SwFlyFrame* SwFlyFrame::DynCastFlyFrame() const { return this; diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index eb34e63caacc3..03d95c979f11c 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -100,22 +100,13 @@ SwFlyAtContentFrame::~SwFlyAtContentFrame() void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify) { SwFlyFrame::SwClientNotify(rMod, rHint); return; } - const SwFormatAnchor* pAnch; - if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - pAnch = pLegacy->m_pNew ? GetAnchorFromPoolItem(*pLegacy->m_pNew) : nullptr; - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange - { - auto pChangeHint = static_cast(&rHint); - pAnch = pChangeHint->m_pNew ? GetAnchorFromPoolItem(*pChangeHint->m_pNew) : nullptr; - } + auto pLegacy = static_cast(&rHint); + const SwFormatAnchor* pAnch = pLegacy->m_pNew ? GetAnchorFromPoolItem(*pLegacy->m_pNew) : nullptr; if(!pAnch) { SwFlyFrame::SwClientNotify(rMod, rHint); diff --git a/sw/source/core/layout/flyincnt.cxx b/sw/source/core/layout/flyincnt.cxx index 712ee61884c0f..ed249c322bd0f 100644 --- a/sw/source/core/layout/flyincnt.cxx +++ b/sw/source/core/layout/flyincnt.cxx @@ -107,44 +107,36 @@ void SwFlyInContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rH AnchorFrame()->Prepare(PrepareHint::FlyFrameAttributesChanged, GetFormat()); return; } - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - std::pair, std::unique_ptr> aTweakedChgs; - std::pair aSuperArgs(nullptr, nullptr); - const SwAttrSetChg* pOldAttrSetChg = pChangeHint->m_pOld; - const SwAttrSetChg* pNewAttrSetChg = pChangeHint->m_pNew; - if(pOldAttrSetChg - && pNewAttrSetChg - && ((SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_SURROUND, false)) - || (SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_FRMMACRO, false)))) - { - aTweakedChgs.second = std::make_unique(*pOldAttrSetChg); - aTweakedChgs.second->ClearItem(RES_SURROUND); - aTweakedChgs.second->ClearItem(RES_FRMMACRO); - if(aTweakedChgs.second->Count()) - { - aTweakedChgs.first = std::make_unique(*pOldAttrSetChg); - aTweakedChgs.first->ClearItem(RES_SURROUND); - aTweakedChgs.first->ClearItem(RES_FRMMACRO); - aSuperArgs = std::pair(aTweakedChgs.first.get(), aTweakedChgs.second.get()); - } - } else if (pNewAttrSetChg && pNewAttrSetChg->GetChgSet()->Count()) - aSuperArgs = std::pair(pChangeHint->m_pOld, pChangeHint->m_pNew); - if(aSuperArgs.second) - { - SwFlyFrame::SwClientNotify(rMod, sw::AttrSetChangeHint(aSuperArgs.first, aSuperArgs.second)); - if(GetAnchorFrame()) - AnchorFrame()->Prepare(PrepareHint::FlyFrameAttributesChanged, GetFormat()); - } - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); + std::pair, std::unique_ptr> aTweakedChgs; std::pair aSuperArgs(nullptr, nullptr); switch(pLegacy->GetWhich()) { + case RES_ATTRSET_CHG: + { + auto pOldAttrSetChg = static_cast(pLegacy->m_pOld); + auto pNewAttrSetChg = static_cast(pLegacy->m_pNew); + if(pOldAttrSetChg + && pNewAttrSetChg + && ((SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_SURROUND, false)) + || (SfxItemState::SET == pNewAttrSetChg->GetChgSet()->GetItemState(RES_FRMMACRO, false)))) + { + aTweakedChgs.second = std::make_unique(*pOldAttrSetChg); + aTweakedChgs.second->ClearItem(RES_SURROUND); + aTweakedChgs.second->ClearItem(RES_FRMMACRO); + if(aTweakedChgs.second->Count()) + { + aTweakedChgs.first = std::make_unique(*pOldAttrSetChg); + aTweakedChgs.first->ClearItem(RES_SURROUND); + aTweakedChgs.first->ClearItem(RES_FRMMACRO); + aSuperArgs = std::pair(aTweakedChgs.first.get(), aTweakedChgs.second.get()); + } + } else if (pNewAttrSetChg && pNewAttrSetChg->GetChgSet()->Count()) + aSuperArgs = std::pair(pLegacy->m_pOld, pLegacy->m_pNew); + break; + } case RES_SURROUND: case RES_FRMMACRO: break; diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 51e5a2b873872..f157a80134bf0 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -751,24 +751,12 @@ void SwFlyLayFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) SwFlyFrame::SwClientNotify(rMod, rHint); return; } - if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify) return; - - const SwFormatAnchor* pAnch; - if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - if(!pLegacy->m_pNew) - return; - pAnch = GetAnchorFromPoolItem(*pLegacy->m_pNew); - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange - { - auto pChangeHint = static_cast(&rHint); - if(!pChangeHint->m_pNew) - return; - pAnch = GetAnchorFromPoolItem(*pChangeHint->m_pNew); - } + auto pLegacy = static_cast(&rHint); + if(!pLegacy->m_pNew) + return; + const auto pAnch = GetAnchorFromPoolItem(*pLegacy->m_pNew); if(!pAnch) { diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index cc7fac4b1bba3..9f61bb081bc3b 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -539,8 +539,7 @@ void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) static_cast(rHint).SetUsed(); return; } - else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange) { if(auto pSh = getRootFrame()->GetCurrShell()) pSh->SetFirstVisPageInvalid(); @@ -549,15 +548,10 @@ void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&rHint); - UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(pChangeHint->m_pNew) + if(pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which()) { - const SwAttrSetChg& rOldSetChg = *pChangeHint->m_pOld; - const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew; + auto& rOldSetChg = *static_cast(pLegacy->m_pOld); + auto& rNewSetChg = *static_cast(pLegacy->m_pNew); SfxItemIter aOIter(*rOldSetChg.GetChgSet()); SfxItemIter aNIter(*rNewSetChg.GetChgSet()); const SfxPoolItem* pOItem = aOIter.GetCurItem(); @@ -571,8 +565,10 @@ void SwPageFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) pNItem = aNIter.NextItem(); } while(pNItem); if(aOldSet.Count() || aNewSet.Count()) - SwLayoutFrame::SwClientNotify(rModify, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); + SwLayoutFrame::SwClientNotify(rModify, sw::LegacyModifyHint(&aOldSet, &aNewSet)); } + else + UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); } else // rHint.GetId() == SfxHintId::SwFormatChange { diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 24b4e8d40fa7a..8f8762109ac0e 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -290,7 +290,7 @@ void SwPageDesc::RegisterChange() /// special handling if the style of the grid alignment changes void SwPageDesc::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwFormatChange || rHint.GetId() == SfxHintId::SwAttrSetChange) + if (rHint.GetId() == SfxHintId::SwFormatChange) { CallSwClientNotify(rHint); RegisterChange(); @@ -304,7 +304,8 @@ void SwPageDesc::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) ? pLegacyHint->m_pNew->Which() : 0; CallSwClientNotify(rHint); - if(isCHRATR(nWhich) + if((RES_ATTRSET_CHG == nWhich) + || isCHRATR(nWhich) || (RES_PARATR_LINESPACING == nWhich)) RegisterChange(); } diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx index 4af70165c67d0..de707f27da922 100644 --- a/sw/source/core/layout/sectfrm.cxx +++ b/sw/source/core/layout/sectfrm.cxx @@ -2731,22 +2731,16 @@ void SwSectionFrame::Notify(SfxHint const& rHint) void SwSectionFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange) { SwSectionFrameInvFlags eInvFlags = SwSectionFrameInvFlags::NONE; if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&rHint); - UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(pChangeHint->m_pNew) + if(pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which()) { - const SwAttrSetChg& rOldSetChg = *pChangeHint->m_pOld; - const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew; + auto& rOldSetChg = *static_cast(pLegacy->m_pOld); + auto& rNewSetChg = *static_cast(pLegacy->m_pNew); SfxItemIter aOIter(*rOldSetChg.GetChgSet()); SfxItemIter aNIter(*rNewSetChg.GetChgSet()); const SfxPoolItem* pOItem = aOIter.GetCurItem(); @@ -2760,8 +2754,10 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) pOItem = aOIter.NextItem(); } while (pNItem); if(aOldSet.Count() || aNewSet.Count()) - SwLayoutFrame::SwClientNotify(rMod, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); + SwLayoutFrame::SwClientNotify(rMod, sw::LegacyModifyHint(&aOldSet, &aNewSet)); } + else + UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); } else // rHint.GetId() == SfxHintId::SwFormatChange) { diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 24225b332ef0a..683eb18dd7c15 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -4005,6 +4005,7 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) if(rHint.GetId() == SfxHintId::SwTableHeadingChange) { HandleTableHeadlineChange(); + return; } else if(rHint.GetId() == SfxHintId::SwVirtPageNumHint) { @@ -4013,39 +4014,36 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) return; if(const SwPageFrame* pPage = FindPageFrame()) pPage->UpdateVirtPageNumInfo(rVirtPageNumHint, this); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - SwTabFrameInvFlags eInvFlags = SwTabFrameInvFlags::NONE; - if(pChangeHint->m_pNew) + else if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + SwTabFrameInvFlags eInvFlags = SwTabFrameInvFlags::NONE; + bool bAttrSetChg = pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which(); + + if(bAttrSetChg) + { + auto& rOldSetChg = *static_cast(pLegacy->m_pOld); + auto& rNewSetChg = *static_cast(pLegacy->m_pNew); + SfxItemIter aOIter(*rOldSetChg.GetChgSet()); + SfxItemIter aNIter(*rNewSetChg.GetChgSet()); + const SfxPoolItem* pOItem = aOIter.GetCurItem(); + const SfxPoolItem* pNItem = aNIter.GetCurItem(); + SwAttrSetChg aOldSet(rOldSetChg); + SwAttrSetChg aNewSet(rNewSetChg); + do { - const SwAttrSetChg& rOldSetChg = *pChangeHint->m_pOld; - const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew; - SfxItemIter aOIter(*rOldSetChg.GetChgSet()); - SfxItemIter aNIter(*rNewSetChg.GetChgSet()); - const SfxPoolItem* pOItem = aOIter.GetCurItem(); - const SfxPoolItem* pNItem = aNIter.GetCurItem(); - SwAttrSetChg aOldSet(rOldSetChg); - SwAttrSetChg aNewSet(rNewSetChg); - do - { - UpdateAttr_(pOItem, pNItem, eInvFlags, &aOldSet, &aNewSet); - pNItem = aNIter.NextItem(); - pOItem = aOIter.NextItem(); - } while(pNItem); - if(aOldSet.Count() || aNewSet.Count()) - SwLayoutFrame::SwClientNotify(rMod, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); - } - Invalidate(eInvFlags); + UpdateAttr_(pOItem, pNItem, eInvFlags, &aOldSet, &aNewSet); + pNItem = aNIter.NextItem(); + pOItem = aOIter.NextItem(); + } while(pNItem); + if(aOldSet.Count() || aNewSet.Count()) + SwLayoutFrame::SwClientNotify(rMod, sw::LegacyModifyHint(&aOldSet, &aNewSet)); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - SwTabFrameInvFlags eInvFlags = SwTabFrameInvFlags::NONE; + else UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); - Invalidate(eInvFlags); - } + Invalidate(eInvFlags); } void SwTabFrame::HandleTableHeadlineChange() @@ -4665,26 +4663,6 @@ void SwRowFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) ReinitializeFrameSizeAttrFlags(); return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(!pChangeHint->m_pNew) - { - // possibly not needed? - SwLayoutFrame::SwClientNotify(rModify, rHint); - return; - } - const SwAttrSet* pChgSet = pChangeHint->m_pNew->GetChgSet(); - const SfxPoolItem* pItem = nullptr; - pChgSet->GetItemState(RES_FRM_SIZE, false, &pItem); - if(!pItem) - pChgSet->GetItemState(RES_ROW_SPLIT, false, &pItem); - if(pItem) - OnFrameSize(*pItem); - else - SwLayoutFrame::SwClientNotify(rModify, rHint); // possibly not needed? - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); @@ -4696,6 +4674,19 @@ void SwRowFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) } switch(pLegacy->m_pNew->Which()) { + case RES_ATTRSET_CHG: + { + const SwAttrSet* pChgSet = static_cast(pLegacy->m_pNew)->GetChgSet(); + const SfxPoolItem* pItem = nullptr; + pChgSet->GetItemState(RES_FRM_SIZE, false, &pItem); + if(!pItem) + pChgSet->GetItemState(RES_ROW_SPLIT, false, &pItem); + if(pItem) + OnFrameSize(*pItem); + else + SwLayoutFrame::SwClientNotify(rModify, rHint); // possibly not needed? + return; + } case RES_FRM_SIZE: case RES_ROW_SPLIT: OnFrameSize(*static_cast(pLegacy->m_pNew)); @@ -6277,46 +6268,43 @@ void SwCellFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { SwLayoutFrame::SwClientNotify(rMod, rHint); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify) { + auto pLegacy = static_cast(&rHint); const SfxPoolItem* pVertOrientItem = nullptr; #if !ENABLE_WASM_STRIP_ACCESSIBILITY const SfxPoolItem* pProtectItem = nullptr; #endif const SfxPoolItem* pFrameDirItem = nullptr; const SfxPoolItem* pBoxItem = nullptr; - if (rHint.GetId() == SfxHintId::SwLegacyModify) + const auto nWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0; + switch(nWhich) { - auto pLegacy = static_cast(&rHint); - const auto nWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0; - switch(nWhich) + case RES_ATTRSET_CHG: { - case RES_VERT_ORIENT: - pVertOrientItem = pLegacy->m_pNew; - break; - case RES_PROTECT: - #if !ENABLE_WASM_STRIP_ACCESSIBILITY - pProtectItem = pLegacy->m_pNew; - #endif - break; - case RES_FRAMEDIR: - pFrameDirItem = pLegacy->m_pNew; - break; - case RES_BOX: - pBoxItem = pLegacy->m_pNew; - break; + auto& rChgSet = *static_cast(pLegacy->m_pNew)->GetChgSet(); + pVertOrientItem = rChgSet.GetItemIfSet(RES_VERT_ORIENT, false); +#if !ENABLE_WASM_STRIP_ACCESSIBILITY + pProtectItem = rChgSet.GetItemIfSet(RES_PROTECT, false); +#endif + pFrameDirItem = rChgSet.GetItemIfSet(RES_FRAMEDIR, false); + pBoxItem = rChgSet.GetItemIfSet(RES_BOX, false); + break; } - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange - { - auto pChangeHint = static_cast(&rHint); - auto& rChgSet = *pChangeHint->m_pNew->GetChgSet(); - pVertOrientItem = rChgSet.GetItemIfSet(RES_VERT_ORIENT, false); + case RES_VERT_ORIENT: + pVertOrientItem = pLegacy->m_pNew; + break; + case RES_PROTECT: #if !ENABLE_WASM_STRIP_ACCESSIBILITY - pProtectItem = rChgSet.GetItemIfSet(RES_PROTECT, false); + pProtectItem = pLegacy->m_pNew; #endif - pFrameDirItem = rChgSet.GetItemIfSet(RES_FRAMEDIR, false); - pBoxItem = rChgSet.GetItemIfSet(RES_BOX, false); + break; + case RES_FRAMEDIR: + pFrameDirItem = pLegacy->m_pNew; + break; + case RES_BOX: + pBoxItem = pLegacy->m_pNew; + break; } if(pVertOrientItem) { diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx index 6941a4af2b5c3..45b87bc4688a2 100644 --- a/sw/source/core/layout/wsfrm.cxx +++ b/sw/source/core/layout/wsfrm.cxx @@ -511,23 +511,17 @@ void SwTextFrame::CheckDirection( bool bVert ) void SwFrame::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange - && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange) return; SwFrameInvFlags eInvFlags = SwFrameInvFlags::NONE; if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&rHint); - UpdateAttrFrame(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(pChangeHint->m_pOld && pChangeHint->m_pNew) + if(pLegacy->m_pOld && pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which()) { - SfxItemIter aNIter(*pChangeHint->m_pNew->GetChgSet()); - SfxItemIter aOIter(*pChangeHint->m_pOld->GetChgSet()); + SfxItemIter aNIter(*static_cast(pLegacy->m_pNew)->GetChgSet()); + SfxItemIter aOIter(*static_cast(pLegacy->m_pOld)->GetChgSet()); const SfxPoolItem* pNItem = aNIter.GetCurItem(); const SfxPoolItem* pOItem = aOIter.GetCurItem(); do @@ -537,6 +531,8 @@ void SwFrame::SwClientNotify(const SwModify&, const SfxHint& rHint) pOItem = aOIter.NextItem(); } while (pNItem); } + else + UpdateAttrFrame(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); } else // rHint.GetId() == SfxHintId::SwFormatChange { @@ -2411,23 +2407,17 @@ SwTwips SwContentFrame::ShrinkFrame( SwTwips nDist, bool bTst, bool bInfo ) void SwContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange - && rHint.GetId() != SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange) return; SwContentFrameInvFlags eInvFlags = SwContentFrameInvFlags::NONE; if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&rHint); - UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(pChangeHint->m_pNew && pChangeHint->m_pOld) + if(pLegacy->m_pNew && RES_ATTRSET_CHG == pLegacy->m_pNew->Which() && pLegacy->m_pOld) { - const SwAttrSetChg& rOldSetChg = *pChangeHint->m_pOld; - const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew; + auto& rOldSetChg = *static_cast(pLegacy->m_pOld); + auto& rNewSetChg = *static_cast(pLegacy->m_pNew); SfxItemIter aOIter(*rOldSetChg.GetChgSet()); SfxItemIter aNIter(*rNewSetChg.GetChgSet()); const SfxPoolItem* pNItem = aNIter.GetCurItem(); @@ -2441,8 +2431,10 @@ void SwContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) pOItem = aOIter.NextItem(); } while(pNItem); if(aOldSet.Count() || aNewSet.Count()) - SwFrame::SwClientNotify(rMod, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); + SwFrame::SwClientNotify(rMod, sw::LegacyModifyHint(&aOldSet, &aNewSet)); } + else + UpdateAttr_(pLegacy->m_pOld, pLegacy->m_pNew, eInvFlags); } else // rHint.GetId() == SfxHintId::SwFormatChange { diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 6c2484fa4f906..26fced61f58f2 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -322,46 +322,41 @@ static void lcl_ModifyBoxes( SwTableBoxes &rBoxes, const tools::Long nOld, void SwTable::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if(rHint.GetId() == SfxHintId::SwAutoFormatUsedHint) - { + if(rHint.GetId() == SfxHintId::SwAutoFormatUsedHint) { auto& rAutoFormatUsedHint = static_cast(rHint); rAutoFormatUsedHint.CheckNode(GetTableNode()); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - // catch SSize changes, to adjust the lines/boxes - const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr; - if (pChangeHint->m_pOld && pChangeHint->m_pNew - && (pNewSize = pChangeHint->m_pNew->GetChgSet()->GetItemIfSet( - RES_FRM_SIZE, - false))) - { - pOldSize = &pChangeHint->m_pOld->GetChgSet()->GetFrameSize(); - } - if (pOldSize && pNewSize && !m_bModifyLocked) - AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth()); - } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - // catch SSize changes, to adjust the lines/boxes - const sal_uInt16 nWhich = pLegacy->GetWhich(); - const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr; - switch(nWhich) - { - case RES_FRM_SIZE: + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + // catch SSize changes, to adjust the lines/boxes + const sal_uInt16 nWhich = pLegacy->GetWhich(); + const SwFormatFrameSize* pNewSize = nullptr, *pOldSize = nullptr; + switch(nWhich) + { + case RES_ATTRSET_CHG: + { + if (pLegacy->m_pOld && pLegacy->m_pNew + && (pNewSize = static_cast(pLegacy->m_pNew)->GetChgSet()->GetItemIfSet( + RES_FRM_SIZE, + false))) { - pOldSize = static_cast(pLegacy->m_pOld); - pNewSize = static_cast(pLegacy->m_pNew); + pOldSize = &static_cast(pLegacy->m_pOld)->GetChgSet()->GetFrameSize(); } - break; - default: - CheckRegistration(pLegacy->m_pOld); } - if (pOldSize && pNewSize && !m_bModifyLocked) - AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth()); + break; + case RES_FRM_SIZE: + { + pOldSize = static_cast(pLegacy->m_pOld); + pNewSize = static_cast(pLegacy->m_pNew); + } + break; + default: + CheckRegistration(pLegacy->m_pOld); } + if (pOldSize && pNewSize && !m_bModifyLocked) + AdjustWidths(pOldSize->GetWidth(), pNewSize->GetWidth()); } void SwTable::AdjustWidths( const tools::Long nOld, const tools::Long nNew ) @@ -2755,45 +2750,41 @@ SwTableBox* SwTableBoxFormat::SwTableBoxFormat::GetTableBox() // for detection of modifications (mainly TableBoxAttribute) void SwTableBoxFormat::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) { - if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange - && rHint.GetId() != SfxHintId::SwAttrSetChange) + if(rHint.GetId() != SfxHintId::SwLegacyModify && rHint.GetId() != SfxHintId::SwFormatChange) return; if(IsModifyLocked() || !GetDoc() || GetDoc()->IsInDtor() || rHint.GetId() == SfxHintId::SwFormatChange) { SwFrameFormat::SwClientNotify(rMod, rHint); return; } + auto pLegacy = static_cast(&rHint); const SwTableBoxNumFormat* pNewFormat = nullptr; const SwTableBoxFormula* pNewFormula = nullptr; const SwTableBoxValue* pNewVal = nullptr; sal_uLong nOldFormat = getSwDefaultTextFormat(); - if(rHint.GetId() == SfxHintId::SwLegacyModify) + switch(pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0) { - auto pLegacy = static_cast(&rHint); - switch(pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0) + case RES_ATTRSET_CHG: { - case RES_BOXATR_FORMAT: - pNewFormat = static_cast(pLegacy->m_pNew); - nOldFormat = static_cast(pLegacy->m_pOld)->GetValue(); - break; - case RES_BOXATR_FORMULA: - pNewFormula = static_cast(pLegacy->m_pNew); - break; - case RES_BOXATR_VALUE: - pNewVal = static_cast(pLegacy->m_pNew); - break; + const SfxItemSet& rSet = *static_cast(pLegacy->m_pNew)->GetChgSet(); + pNewFormat = rSet.GetItemIfSet( RES_BOXATR_FORMAT, false); + if(pNewFormat) + nOldFormat = static_cast(pLegacy->m_pOld)->GetChgSet()->Get(RES_BOXATR_FORMAT).GetValue(); + pNewFormula = rSet.GetItemIfSet(RES_BOXATR_FORMULA, false); + pNewVal = rSet.GetItemIfSet(RES_BOXATR_VALUE, false); + break; } - } - else // rHint.GetId() == SfxHintId::SwAttrSetChange - { - auto pChangeHint = static_cast(&rHint); - const SfxItemSet& rSet = *pChangeHint->m_pNew->GetChgSet(); - pNewFormat = rSet.GetItemIfSet( RES_BOXATR_FORMAT, false); - if(pNewFormat) - nOldFormat = pChangeHint->m_pOld->GetChgSet()->Get(RES_BOXATR_FORMAT).GetValue(); - pNewFormula = rSet.GetItemIfSet(RES_BOXATR_FORMULA, false); - pNewVal = rSet.GetItemIfSet(RES_BOXATR_VALUE, false); + case RES_BOXATR_FORMAT: + pNewFormat = static_cast(pLegacy->m_pNew); + nOldFormat = static_cast(pLegacy->m_pOld)->GetValue(); + break; + case RES_BOXATR_FORMULA: + pNewFormula = static_cast(pLegacy->m_pNew); + break; + case RES_BOXATR_VALUE: + pNewVal = static_cast(pLegacy->m_pNew); + break; } // something changed and some BoxAttribute remained in the set! diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index f351d2047a7e2..6e76e610f7e5e 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -2187,7 +2187,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) sw::RedlineDelText const* pRedlineDelText(nullptr); sw::RedlineUnDelText const* pRedlineUnDelText(nullptr); SwFormatChangeHint const * pFormatChangedHint(nullptr); - sw::AttrSetChangeHint const* pAttrSetChangeHint(nullptr); sal_uInt16 nWhich = 0; if (rHint.GetId() == SfxHintId::SwLegacyModify) @@ -2248,10 +2247,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) { pFormatChangedHint = static_cast(&rHint); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - pAttrSetChangeHint = static_cast(&rHint); - } else { assert(!"unexpected hint"); @@ -2278,7 +2273,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) return; } } - SwContentFrame::SwClientNotify(rModify, rHint); + SwContentFrame::SwClientNotify(rModify, sw::LegacyModifyHint(pOld, pNew)); if( pFormatChangedHint && getRootFrame()->GetCurrShell() ) { // collection has changed @@ -2475,242 +2470,6 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) lcl_ModifyOfst(*this, nPos, nLen, &o3tl::operator-); } } - else if (pAttrSetChangeHint) - { - InvalidateLineNum(); - - const SwAttrSet& rNewSet = *pAttrSetChangeHint->m_pNew->GetChgSet(); - int nClear = 0; - sal_uInt16 nCount = rNewSet.Count(); - - if( const SwFormatFootnote* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FTN, false ) ) - { - nPos = MapModelToView(&rNode, pItem->GetTextFootnote()->GetStart()); - if (IsIdxInside(nPos, TextFrameIndex(1))) - Prepare( PrepareHint::FootnoteInvalidation, pAttrSetChangeHint->m_pNew ); - nClear = 0x01; - --nCount; - } - - if( const SwFormatField* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FIELD, false ) ) - { - nPos = MapModelToView(&rNode, pItem->GetTextField()->GetStart()); - if (IsIdxInside(nPos, TextFrameIndex(1))) - { - const SwFormatField* pOldItem = pAttrSetChangeHint->m_pOld ? - &(pAttrSetChangeHint->m_pOld->GetChgSet()->Get(RES_TXTATR_FIELD)) : nullptr; - if (SfxPoolItem::areSame( pItem, pOldItem )) - { - InvalidatePage(); - SetCompletePaint(); - } - else - InvalidateRange_(SwCharRange(nPos, TextFrameIndex(1))); - } - nClear |= 0x02; - --nCount; - } - bool bLineSpace = SfxItemState::SET == rNewSet.GetItemState( - RES_PARATR_LINESPACING, false ), - bRegister = SfxItemState::SET == rNewSet.GetItemState( - RES_PARATR_REGISTER, false ); - if ( bLineSpace || bRegister ) - { - if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) - { - Prepare( bRegister ? PrepareHint::Register : PrepareHint::AdjustSizeWithoutFormatting ); - CalcLineSpace(); - InvalidateSize(); - InvalidatePrt_(); - - // i#11859 - // (1) Also invalidate next frame on next page/column. - // (2) Skip empty sections and hidden paragraphs - // Thus, use method - InvalidateNextPrtArea(); - - SetCompletePaint(); - } - nClear |= 0x04; - if ( bLineSpace ) - { - --nCount; - if ((!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) - && IsInSct() && !GetPrev()) - { - SwSectionFrame *pSect = FindSctFrame(); - if( pSect->ContainsAny() == this ) - pSect->InvalidatePrt(); - } - } - if ( bRegister ) - --nCount; - } - if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT, - false )) - { - if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) - { - if (GetPrev()) - CheckKeep(); - Prepare(); - InvalidateSize(); - } - nClear |= 0x08; - --nCount; - } - - if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false) - && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) - && !IsFollow() && GetDrawObjs() ) - { - SwSortedObjs *pObjs = GetDrawObjs(); - for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i ) - { - SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; - if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) - { - if( !pFly->IsFlyInContentFrame() ) - { - const SvxBrushItem &rBack = - pFly->GetAttrSet()->GetBackground(); - // #GetTransChg# - // following condition determines, if the fly frame - // "inherites" the background color of text frame. - // This is the case, if fly frame background - // color is "no fill"/"auto fill" and if the fly frame - // has no background graphic. - // Thus, check complete fly frame background - // color and *not* only its transparency value - if ( (rBack.GetColor() == COL_TRANSPARENT) && - rBack.GetGraphicPos() == GPOS_NONE ) - { - pFly->SetCompletePaint(); - pFly->InvalidatePage(); - } - } - } - } - } - - if ( SfxItemState::SET == - rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) ) - { - lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false ); - lcl_SetScriptInval( *this, TextFrameIndex(0) ); - } - else if ( SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) || - SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) || - SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) ) - lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false ); - else if ( SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_FONT, false ) || - SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) || - SfxItemState::SET == - rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) ) - lcl_SetScriptInval( *this, TextFrameIndex(0) ); - else if ( SfxItemState::SET == - rNewSet.GetItemState( RES_FRAMEDIR, false ) - && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)) - { - SetDerivedR2L( false ); - CheckDirChange(); - // Force complete paint due to existing indents. - SetCompletePaint(); - } - - if( nCount ) - { - if( getRootFrame()->GetCurrShell() ) - { - Prepare(); - InvalidatePrt_(); - } - - if (nClear || (m_pMergedPara && - (m_pMergedPara->pParaPropsNode != &rModify || - m_pMergedPara->pFirstNode != &rModify))) - { - assert(pAttrSetChangeHint->m_pOld); - SwAttrSetChg aOldSet( *pAttrSetChangeHint->m_pOld ); - SwAttrSetChg aNewSet( *pAttrSetChangeHint->m_pNew ); - - if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify) - { - for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i) - { - if (i != RES_BREAK && i != RES_PAGEDESC) - { - aOldSet.ClearItem(i); - aNewSet.ClearItem(i); - } - } - for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i) - { - aOldSet.ClearItem(i); - aNewSet.ClearItem(i); - } - } - if (m_pMergedPara && m_pMergedPara->pFirstNode != &rModify) - { - aOldSet.ClearItem(RES_BREAK); - aNewSet.ClearItem(RES_BREAK); - aOldSet.ClearItem(RES_PAGEDESC); - aNewSet.ClearItem(RES_PAGEDESC); - } - - if( 0x01 & nClear ) - { - aOldSet.ClearItem( RES_TXTATR_FTN ); - aNewSet.ClearItem( RES_TXTATR_FTN ); - } - if( 0x02 & nClear ) - { - aOldSet.ClearItem( RES_TXTATR_FIELD ); - aNewSet.ClearItem( RES_TXTATR_FIELD ); - } - if ( 0x04 & nClear ) - { - if ( bLineSpace ) - { - aOldSet.ClearItem( RES_PARATR_LINESPACING ); - aNewSet.ClearItem( RES_PARATR_LINESPACING ); - } - if ( bRegister ) - { - aOldSet.ClearItem( RES_PARATR_REGISTER ); - aNewSet.ClearItem( RES_PARATR_REGISTER ); - } - } - if ( 0x08 & nClear ) - { - aOldSet.ClearItem( RES_PARATR_SPLIT ); - aNewSet.ClearItem( RES_PARATR_SPLIT ); - } - if (aOldSet.Count() || aNewSet.Count()) - { - SwContentFrame::SwClientNotify(rModify, sw::AttrSetChangeHint(&aOldSet, &aNewSet)); - } - } - else - SwContentFrame::SwClientNotify(rModify, rHint); - } - -#if !ENABLE_WASM_STRIP_ACCESSIBILITY - if (isA11yRelevantAttribute(nWhich)) - { - SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr; - if ( pViewSh ) - { - pViewSh->InvalidateAccessibleParaAttrs( *this ); - } - } -#endif - } else switch (nWhich) { case RES_LINENUMBER: @@ -2741,7 +2500,7 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) const sal_uInt16 nTmp = pNewUpdate->getWhichAttr(); if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_INETFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp || - RES_UPDATEATTR_FMT_CHG == nTmp || RES_UPDATEATTR_ATTRSET_CHG == nTmp ) + RES_UPDATEATTR_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp ) { lcl_SetWrong( *this, rNode, nNPos, nNPos + nNLen, false ); lcl_SetScriptInval( *this, nPos ); @@ -2828,6 +2587,243 @@ void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint) break; } + case RES_ATTRSET_CHG: + { + InvalidateLineNum(); + + const SwAttrSet& rNewSet = *static_cast(pNew)->GetChgSet(); + int nClear = 0; + sal_uInt16 nCount = rNewSet.Count(); + + if( const SwFormatFootnote* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FTN, false ) ) + { + nPos = MapModelToView(&rNode, pItem->GetTextFootnote()->GetStart()); + if (IsIdxInside(nPos, TextFrameIndex(1))) + Prepare( PrepareHint::FootnoteInvalidation, pNew ); + nClear = 0x01; + --nCount; + } + + if( const SwFormatField* pItem = rNewSet.GetItemIfSet( RES_TXTATR_FIELD, false ) ) + { + nPos = MapModelToView(&rNode, pItem->GetTextField()->GetStart()); + if (IsIdxInside(nPos, TextFrameIndex(1))) + { + const SfxPoolItem* pOldItem = pOld ? + &(static_cast(pOld)->GetChgSet()->Get(RES_TXTATR_FIELD)) : nullptr; + if (SfxPoolItem::areSame( pItem, pOldItem )) + { + InvalidatePage(); + SetCompletePaint(); + } + else + InvalidateRange_(SwCharRange(nPos, TextFrameIndex(1))); + } + nClear |= 0x02; + --nCount; + } + bool bLineSpace = SfxItemState::SET == rNewSet.GetItemState( + RES_PARATR_LINESPACING, false ), + bRegister = SfxItemState::SET == rNewSet.GetItemState( + RES_PARATR_REGISTER, false ); + if ( bLineSpace || bRegister ) + { + if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) + { + Prepare( bRegister ? PrepareHint::Register : PrepareHint::AdjustSizeWithoutFormatting ); + CalcLineSpace(); + InvalidateSize(); + InvalidatePrt_(); + + // i#11859 + // (1) Also invalidate next frame on next page/column. + // (2) Skip empty sections and hidden paragraphs + // Thus, use method + InvalidateNextPrtArea(); + + SetCompletePaint(); + } + nClear |= 0x04; + if ( bLineSpace ) + { + --nCount; + if ((!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) + && IsInSct() && !GetPrev()) + { + SwSectionFrame *pSect = FindSctFrame(); + if( pSect->ContainsAny() == this ) + pSect->InvalidatePrt(); + } + } + if ( bRegister ) + --nCount; + } + if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT, + false )) + { + if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) + { + if (GetPrev()) + CheckKeep(); + Prepare(); + InvalidateSize(); + } + nClear |= 0x08; + --nCount; + } + + if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false) + && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify) + && !IsFollow() && GetDrawObjs() ) + { + SwSortedObjs *pObjs = GetDrawObjs(); + for ( size_t i = 0; GetDrawObjs() && i < pObjs->size(); ++i ) + { + SwAnchoredObject* pAnchoredObj = (*pObjs)[i]; + if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) + { + if( !pFly->IsFlyInContentFrame() ) + { + const SvxBrushItem &rBack = + pFly->GetAttrSet()->GetBackground(); + // #GetTransChg# + // following condition determines, if the fly frame + // "inherites" the background color of text frame. + // This is the case, if fly frame background + // color is "no fill"/"auto fill" and if the fly frame + // has no background graphic. + // Thus, check complete fly frame background + // color and *not* only its transparency value + if ( (rBack.GetColor() == COL_TRANSPARENT) && + rBack.GetGraphicPos() == GPOS_NONE ) + { + pFly->SetCompletePaint(); + pFly->InvalidatePage(); + } + } + } + } + } + + if ( SfxItemState::SET == + rNewSet.GetItemState( RES_TXTATR_CHARFMT, false ) ) + { + lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false ); + lcl_SetScriptInval( *this, TextFrameIndex(0) ); + } + else if ( SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_LANGUAGE, false ) || + SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_CJK_LANGUAGE, false ) || + SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_CTL_LANGUAGE, false ) ) + lcl_SetWrong( *this, rNode, 0, COMPLETE_STRING, false ); + else if ( SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_FONT, false ) || + SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_CJK_FONT, false ) || + SfxItemState::SET == + rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) ) + lcl_SetScriptInval( *this, TextFrameIndex(0) ); + else if ( SfxItemState::SET == + rNewSet.GetItemState( RES_FRAMEDIR, false ) + && (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)) + { + SetDerivedR2L( false ); + CheckDirChange(); + // Force complete paint due to existing indents. + SetCompletePaint(); + } + + if( nCount ) + { + if( getRootFrame()->GetCurrShell() ) + { + Prepare(); + InvalidatePrt_(); + } + + if (nClear || (m_pMergedPara && + (m_pMergedPara->pParaPropsNode != &rModify || + m_pMergedPara->pFirstNode != &rModify))) + { + assert(pOld); + SwAttrSetChg aOldSet( *static_cast(pOld) ); + SwAttrSetChg aNewSet( *static_cast(pNew) ); + + if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify) + { + for (sal_uInt16 i = RES_PARATR_BEGIN; i != RES_FRMATR_END; ++i) + { + if (i != RES_BREAK && i != RES_PAGEDESC) + { + aOldSet.ClearItem(i); + aNewSet.ClearItem(i); + } + } + for (sal_uInt16 i = XATTR_FILL_FIRST; i <= XATTR_FILL_LAST; ++i) + { + aOldSet.ClearItem(i); + aNewSet.ClearItem(i); + } + } + if (m_pMergedPara && m_pMergedPara->pFirstNode != &rModify) + { + aOldSet.ClearItem(RES_BREAK); + aNewSet.ClearItem(RES_BREAK); + aOldSet.ClearItem(RES_PAGEDESC); + aNewSet.ClearItem(RES_PAGEDESC); + } + + if( 0x01 & nClear ) + { + aOldSet.ClearItem( RES_TXTATR_FTN ); + aNewSet.ClearItem( RES_TXTATR_FTN ); + } + if( 0x02 & nClear ) + { + aOldSet.ClearItem( RES_TXTATR_FIELD ); + aNewSet.ClearItem( RES_TXTATR_FIELD ); + } + if ( 0x04 & nClear ) + { + if ( bLineSpace ) + { + aOldSet.ClearItem( RES_PARATR_LINESPACING ); + aNewSet.ClearItem( RES_PARATR_LINESPACING ); + } + if ( bRegister ) + { + aOldSet.ClearItem( RES_PARATR_REGISTER ); + aNewSet.ClearItem( RES_PARATR_REGISTER ); + } + } + if ( 0x08 & nClear ) + { + aOldSet.ClearItem( RES_PARATR_SPLIT ); + aNewSet.ClearItem( RES_PARATR_SPLIT ); + } + if (aOldSet.Count() || aNewSet.Count()) + { + SwContentFrame::SwClientNotify(rModify, sw::LegacyModifyHint(&aOldSet, &aNewSet)); + } + } + else + SwContentFrame::SwClientNotify(rModify, sw::LegacyModifyHint(pOld, pNew)); + } + +#if !ENABLE_WASM_STRIP_ACCESSIBILITY + if (isA11yRelevantAttribute(nWhich)) + { + SwViewShell* pViewSh = getRootFrame() ? getRootFrame()->GetCurrShell() : nullptr; + if ( pViewSh ) + { + pViewSh->InvalidateAccessibleParaAttrs( *this ); + } + } +#endif + } + break; case RES_PARATR_SPLIT: if ( GetPrev() ) CheckKeep(); diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 10111d6613834..09522e6288156 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -253,9 +253,7 @@ void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHin rDoc.getIDocumentContentOperations().DeleteRange( *pPaM ); rDoc.getIDocumentContentOperations().InsertString( *pPaM, aEntry ); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange) { if(!mpTextField) return; @@ -423,14 +421,16 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint) } if(bExpand) mpTextField->ExpandTextField(false); + return; } else if(SfxHintId::SwRemoveUnoObject == rHint.GetId()) { // invalidate cached UNO object m_wXTextField.clear(); // ??? why does this Modify method not already do this? CallSwClientNotify(rHint); + return; } - else if (rHint.GetId() == SfxHintId::SwFormatChange) + if (rHint.GetId() == SfxHintId::SwFormatChange) { auto pChangeHint = static_cast(&rHint); if (!IsFieldInDoc()) @@ -442,64 +442,51 @@ void SwFormatField::UpdateTextNode(const SfxHint& rHint) bool bTriggerNode = pChangeHint->m_pNewFormat != nullptr; if(bTriggerNode) pTextNd->TriggerNodeUpdate(*pChangeHint); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + if(SfxHintId::SwLegacyModify != rHint.GetId()) + return; + auto pLegacy = static_cast(&rHint); + auto pOld = pLegacy->m_pOld; + auto pNew = pLegacy->m_pNew; + if (pOld == nullptr && pNew == nullptr) { - auto pChangeHint = static_cast(&rHint); - auto pOld = pChangeHint->m_pOld; - auto pNew = pChangeHint->m_pNew; - if (pOld == nullptr && pNew == nullptr) - { - ForceUpdateTextNode(); - return; - } - - if (!IsFieldInDoc()) - return; - - SwTextNode* pTextNd = &mpTextField->GetTextNode(); - OSL_ENSURE(pTextNd, "Where is my Node?"); - - bool bTriggerNode = pNew != nullptr; - if(bTriggerNode) - pTextNd->TriggerNodeUpdate(sw::AttrSetChangeHint(pOld, pNew)); + ForceUpdateTextNode(); + return; } - else if(SfxHintId::SwLegacyModify == rHint.GetId()) - { - auto pLegacy = static_cast(&rHint); - auto pOld = pLegacy->m_pOld; - auto pNew = pLegacy->m_pNew; - if (pOld == nullptr && pNew == nullptr) - { - ForceUpdateTextNode(); - return; - } - if (!IsFieldInDoc()) - return; + if (!IsFieldInDoc()) + return; - // don't do anything, especially not expand! - if( pNew && pNew->Which() == RES_OBJECTDYING ) - return; + // don't do anything, especially not expand! + if( pNew && pNew->Which() == RES_OBJECTDYING ) + return; - SwTextNode* pTextNd = &mpTextField->GetTextNode(); - OSL_ENSURE(pTextNd, "Where is my Node?"); + SwTextNode* pTextNd = &mpTextField->GetTextNode(); + OSL_ENSURE(pTextNd, "Where is my Node?"); - bool bTriggerNode = pNew != nullptr; - bool bExpand = false; - if(pNew) + bool bTriggerNode = pNew != nullptr; + bool bExpand = false; + if(pNew) + { + switch(pNew->Which()) { - auto pType = mpField->GetTyp(); - lcl_EnsureUserFieldValid(*pType); - bTriggerNode = lcl_TriggerNode(pType->Which()); - bExpand = lcl_ExpandField(pType->Which()); - pOld = nullptr; + case RES_ATTRSET_CHG: + break; + default: + { + auto pType = mpField->GetTyp(); + lcl_EnsureUserFieldValid(*pType); + bTriggerNode = lcl_TriggerNode(pType->Which()); + bExpand = lcl_ExpandField(pType->Which()); + pOld = nullptr; + } } - if(bTriggerNode) - pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(pOld, pNew)); - if(bExpand) - mpTextField->ExpandTextField(false); } + if(bTriggerNode) + pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(pOld, pNew)); + if(bExpand) + mpTextField->ExpandTextField(false); } bool SwFormatField::IsFieldInDoc() const diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index d452b726615db..c0920b382cefb 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -271,8 +271,7 @@ void SwContentControl::SwClientNotify(const SwModify&, const SfxHint& rHint) GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); } else if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + || rHint.GetId() == SfxHintId::SwFormatChange) { CallSwClientNotify(rHint); GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); diff --git a/sw/source/core/txtnode/attrlinebreak.cxx b/sw/source/core/txtnode/attrlinebreak.cxx index 5ba26c5f4cf89..33df722392ebc 100644 --- a/sw/source/core/txtnode/attrlinebreak.cxx +++ b/sw/source/core/txtnode/attrlinebreak.cxx @@ -66,8 +66,7 @@ void SwFormatLineBreak::SwClientNotify(const SwModify&, const SfxHint& rHint) SetXLineBreak(nullptr); } else if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + || rHint.GetId() == SfxHintId::SwFormatChange) CallSwClientNotify(rHint); } diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 6e9eead823ab8..82ae6caf48549 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -102,12 +102,6 @@ void SwFormatCharFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) if(m_pTextAttribute) m_pTextAttribute->TriggerNodeUpdate(*pChangeHint); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(m_pTextAttribute) - m_pTextAttribute->TriggerNodeUpdate(*pChangeHint); - } else if (rHint.GetId() == SfxHintId::SwLegacyModify) { auto pLegacy = static_cast(&rHint); @@ -738,9 +732,7 @@ void Meta::SwClientNotify(const SwModify&, const SfxHint& rHint) SetXMeta(nullptr); GetNotifier().Broadcast(SfxHint(SfxHintId::Deinitializing)); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify - || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange) { CallSwClientNotify(rHint); GetNotifier().Broadcast(SfxHint(SfxHintId::DataChanged)); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 87904fe92abcf..74981b929be9e 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -3948,6 +3948,32 @@ namespace { OUString sOldNumRule; switch ( nWhich ) { + case RES_ATTRSET_CHG: + { + const SwNumRule* pFormerNumRuleAtTextNode = + rTextNode.GetNum() ? rTextNode.GetNum()->GetNumRule() : nullptr; + if ( pFormerNumRuleAtTextNode ) + { + sOldNumRule = pFormerNumRuleAtTextNode->GetName(); + } + + const SwAttrSetChg* pSet = dynamic_cast(pNewValue); + if ( pSet && pSet->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, false ) == + SfxItemState::SET ) + { + // #i70748# + rTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr(); + bNumRuleSet = true; + } + // #i70748# + // The new list style set at the paragraph. + const SwNumRule* pNumRuleAtTextNode = rTextNode.GetNumRule(); + if ( pNumRuleAtTextNode ) + { + sNumRule = pNumRuleAtTextNode->GetName(); + } + break; + } case RES_PARATR_NUMRULE: { if ( rTextNode.GetNodes().IsDocNodes() ) @@ -3980,37 +4006,6 @@ namespace { } // End of method - void HandleModifyAtTextNode( SwTextNode& rTextNode, - const SwAttrSetChg* /*pOldValue*/, - const SwAttrSetChg* pNewValue ) - { - bool bNumRuleSet = false; - OUString sNumRule; - OUString sOldNumRule; - const SwNumRule* pFormerNumRuleAtTextNode = - rTextNode.GetNum() ? rTextNode.GetNum()->GetNumRule() : nullptr; - if ( pFormerNumRuleAtTextNode ) - { - sOldNumRule = pFormerNumRuleAtTextNode->GetName(); - } - - if ( pNewValue && pNewValue->GetChgSet()->GetItemState( RES_PARATR_NUMRULE, false ) == - SfxItemState::SET ) - { - // #i70748# - rTextNode.ResetEmptyListStyleDueToResetOutlineLevelAttr(); - bNumRuleSet = true; - } - // #i70748# - // The new list style set at the paragraph. - const SwNumRule* pNumRuleAtTextNode = rTextNode.GetNumRule(); - if ( pNumRuleAtTextNode ) - { - sNumRule = pNumRuleAtTextNode->GetName(); - } - HandleApplyTextNodeFormatChange(rTextNode, sNumRule, sOldNumRule, bNumRuleSet, /*bParagraphStyleChanged*/false); - } - // Helper method for special handling of modified attributes at text node. // The following is handled: // (1) on changing the paragraph style - RES_FMT_CHG: @@ -5542,40 +5537,20 @@ void SwTextNode::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) { sw::TextNodeNotificationSuppressor(*this); - if ( !mbInSetOrResetAttr ) - { - HandleModifyAtTextNode( *this, pOldValue, pNewValue ); - } - - SwContentNode::SwClientNotify(*this, rHint); - - SwDoc& rDoc = GetDoc(); - // #125329# - assure that text node is in document nodes array - if ( !rDoc.IsInDtor() && &rDoc.GetNodes() == &GetNodes() ) - { - rDoc.GetNodes().UpdateOutlineNode(*this); - } - } -} - -void SwTextNode::TriggerNodeUpdate(const sw::AttrSetChangeHint& rHint) -{ - const SwAttrSetChg* pOldValue = rHint.m_pOld; - const SwAttrSetChg* pNewValue = rHint.m_pNew; - { - sw::TextNodeNotificationSuppressor(*this); - // reset fill information if (maFillAttributes && pNewValue) { + const sal_uInt16 nWhich = pNewValue->Which(); bool bReset(false); - // ..on ItemChange from DrawingLayer FillAttributes - SfxItemIter aIter(*pNewValue->GetChgSet()); - - for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem && !bReset; pItem = aIter.NextItem()) + if(RES_ATTRSET_CHG == nWhich) // ..on ItemChange from DrawingLayer FillAttributes { - bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST; + SfxItemIter aIter(*static_cast(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; + } } if(bReset) @@ -5674,11 +5649,6 @@ void SwTextNode::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) auto pLegacyHint = static_cast(&rHint); TriggerNodeUpdate(*pLegacyHint); } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - TriggerNodeUpdate(*pChangeHint); - } else if (rHint.GetId() == SfxHintId::SwFormatChange) { auto pChangeHint = static_cast(&rHint); diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index e571694fe1987..3f89cec8bd23c 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -76,7 +76,8 @@ void SwTextCharFormat::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) { const auto nWhich = rHint.GetWhich(); assert( (isCHRATR(nWhich) || - RES_OBJECTDYING == nWhich) && "SwTextCharFormat::TriggerNodeUpdate: unknown hint type"); + RES_OBJECTDYING == nWhich || + RES_ATTRSET_CHG == nWhich) && "SwTextCharFormat::TriggerNodeUpdate: unknown hint type"); if(m_pTextNode) { @@ -88,18 +89,6 @@ void SwTextCharFormat::TriggerNodeUpdate(const sw::LegacyModifyHint& rHint) } } -void SwTextCharFormat::TriggerNodeUpdate(const sw::AttrSetChangeHint& /*rHint*/) -{ - if(m_pTextNode) - { - SwUpdateAttr aUpdateAttr( - GetStart(), - *GetEnd(), - RES_UPDATEATTR_ATTRSET_CHG); - m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); - } -} - void SwTextCharFormat::TriggerNodeUpdate(const SwFormatChangeHint&) { if(m_pTextNode) @@ -208,24 +197,21 @@ void SwTextINetFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) return; const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_FMT_CHG); m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - if(!m_pTextNode) - return; - const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_ATTRSET_CHG); - m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); - } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - const auto nWhich = pLegacy->GetWhich(); - assert((isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich)) && "SwTextINetFormat::SwClientNotify: unknown hint."); - if(!m_pTextNode) - return; - const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); - m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); - } + + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + const auto nWhich = pLegacy->GetWhich(); + assert((isCHRATR(nWhich) || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich)) && + "SwTextINetFormat::SwClientNotify: unknown hint."); + if(!m_pTextNode) + return; + + const SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); + m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); } bool SwTextINetFormat::IsProtect( ) const @@ -260,25 +246,19 @@ void SwTextRuby::SwClientNotify(const SwModify&, const SfxHint& rHint) return; SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_FMT_CHG); m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); + return; } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_ATTRSET_CHG); - m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); - } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - const auto nWhich = pLegacy->GetWhich(); - assert( (isCHRATR(nWhich) - || (RES_OBJECTDYING == nWhich)) && "SwTextRuby::SwClientNotify(): unknown legacy hint"); - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); - m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); - } + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + const auto nWhich = pLegacy->GetWhich(); + assert( (isCHRATR(nWhich) + || (RES_OBJECTDYING == nWhich) + || (RES_ATTRSET_CHG == nWhich)) && "SwTextRuby::SwClientNotify(): unknown legacy hint"); + if(!m_pTextNode) + return; + SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); + m_pTextNode->TriggerNodeUpdate(sw::LegacyModifyHint(&aUpdateAttr, &aUpdateAttr)); } SwCharFormat* SwTextRuby::GetCharFormat() diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 630a09796ce0e..fdf3dc8f10d6d 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -1388,37 +1388,6 @@ SwRegHistory::SwRegHistory( const SwNode& rNd, SwHistory* pHst ) void SwRegHistory::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if ( !(m_pHistory && pChangeHint->m_pNew && pChangeHint->m_pOld != pChangeHint->m_pNew) ) - return; - if (pChangeHint->m_pOld) - { - std::unique_ptr pNewHstr; - const SfxItemSet& rSet = *pChangeHint->m_pOld->GetChgSet(); - - if ( 1 < rSet.Count() ) - { - pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) ); - } - else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem()) - { - if ( m_WhichIdSet.count( pItem->Which() ) ) - { - pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) ); - } - else - { - pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) ); - } - } - - if (pNewHstr) - m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) ); - } - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacyHint = static_cast(&rHint); @@ -1436,6 +1405,30 @@ void SwRegHistory::SwClientNotify(const SwModify&, const SfxHint& rHint) OSL_ENSURE(false, "Unexpected update attribute (!)"); } } + else if (pLegacyHint->m_pOld && RES_ATTRSET_CHG == pLegacyHint->m_pNew->Which()) + { + std::unique_ptr pNewHstr; + const SfxItemSet& rSet = *static_cast< const SwAttrSetChg* >(pLegacyHint->m_pOld)->GetChgSet(); + + if ( 1 < rSet.Count() ) + { + pNewHstr.reset( new SwHistorySetAttrSet( rSet, m_nNodeIndex, m_WhichIdSet ) ); + } + else if (const SfxPoolItem* pItem = SfxItemIter(rSet).GetCurItem()) + { + if ( m_WhichIdSet.count( pItem->Which() ) ) + { + pNewHstr.reset( new SwHistorySetFormat( pItem, m_nNodeIndex ) ); + } + else + { + pNewHstr.reset( new SwHistoryResetFormat( pItem, m_nNodeIndex ) ); + } + } + + if (pNewHstr) + m_pHistory->m_SwpHstry.push_back( std::move(pNewHstr) ); + } } void SwRegHistory::AddHint( SwTextAttr* pHt, const bool bNew ) diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index 5a7db042029d4..4b6a8f2a8abfb 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -68,25 +68,6 @@ SwUndoFormatAttrHelper::SwUndoFormatAttrHelper(SwFormat& rFormat, bool bSvDrwPt) void SwUndoFormatAttrHelper::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwAttrSetChange) - { - auto pChangeHint = static_cast(&rHint); - if(!pChangeHint->m_pOld) - return; - if(!pChangeHint->m_pNew) - return; - const SwDoc& rDoc = *m_rFormat.GetDoc(); - auto pOld = pChangeHint->m_pOld; - auto& rChgSet = *pOld->GetChgSet(); - if(!GetUndo()) - m_pUndo.reset(new SwUndoFormatAttr(SfxItemSet(rChgSet), m_rFormat, m_bSaveDrawPt)); - else { - SfxItemIter aIter(rChgSet); - for(auto pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) - m_pUndo->PutAttr(*pItem, rDoc); - } - return; - } if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast(&rHint); @@ -97,12 +78,20 @@ void SwUndoFormatAttrHelper::SwClientNotify(const SwModify&, const SfxHint& rHin return; const SwDoc& rDoc = *m_rFormat.GetDoc(); auto pOld = pLegacy->m_pOld; - if(POOLATTR_END >= pLegacy->m_pOld->Which()) - { + if(POOLATTR_END >= pLegacy->m_pOld->Which()) { if(!GetUndo()) m_pUndo.reset(new SwUndoFormatAttr(*pOld, m_rFormat, m_bSaveDrawPt)); else m_pUndo->PutAttr(*pOld, rDoc); + } else if(RES_ATTRSET_CHG == pOld->Which()) { + auto& rChgSet = *static_cast(pOld)->GetChgSet(); + if(!GetUndo()) + m_pUndo.reset(new SwUndoFormatAttr(SfxItemSet(rChgSet), m_rFormat, m_bSaveDrawPt)); + else { + SfxItemIter aIter(rChgSet); + for(auto pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) + m_pUndo->PutAttr(*pItem, rDoc); + } } } diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 17b4a5e816391..6d6c641a353f2 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -700,24 +700,20 @@ void SwUndoSetFlyFormat::PutAttr( sal_uInt16 nWhich, const SfxPoolItem* pItem ) void SwUndoSetFlyFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) { - if (rHint.GetId() == SfxHintId::SwAttrSetChange) + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + if(!pLegacy->m_pOld) + return; + const sal_uInt16 nWhich = pLegacy->m_pOld->Which(); + if(nWhich < POOLATTR_END) + PutAttr(nWhich, pLegacy->m_pOld); + else if(RES_ATTRSET_CHG == nWhich) { - auto pChangeHint = static_cast(&rHint); - if(!pChangeHint->m_pOld) - return; - SfxItemIter aIter(*pChangeHint->m_pOld->GetChgSet()); + SfxItemIter aIter(*static_cast(pLegacy->m_pOld)->GetChgSet()); for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) PutAttr(pItem->Which(), pItem); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast(&rHint); - if(!pLegacy->m_pOld) - return; - const sal_uInt16 nWhich = pLegacy->m_pOld->Which(); - if(nWhich < POOLATTR_END) - PutAttr(nWhich, pLegacy->m_pOld); - } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx index 0245e793c5fbd..0814a1b071c3f 100644 --- a/sw/source/core/unocore/unochart.cxx +++ b/sw/source/core/unocore/unochart.cxx @@ -2150,8 +2150,7 @@ void SwChartDataSequence::Notify( const SfxHint& rHint) m_pTableCursor.reset(nullptr); dispose(); } - else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange - || rHint.GetId() == SfxHintId::SwAttrSetChange) + else if (rHint.GetId() == SfxHintId::SwLegacyModify || rHint.GetId() == SfxHintId::SwFormatChange) { setModified( true ); }