Skip to content

Commit

Permalink
Revert "convert RES_ATTRSET_CHG to SfxHint"
Browse files Browse the repository at this point in the history
This reverts commit 404fbec.

Reason for revert: It's follow-up fix bbb5399
"fix ubsan failure" had to be reverted (because it conflicted with a revert of
cc56bf5 "convert RES_OBJECTDYING to SfxHint",
which in turn is known broken and thus needed to be reverted for now), so revert
this known-broken commit for now as well.

Change-Id: I4e65c7113e1e5bfdb9841c98bee3712a1beb12ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179941
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <[email protected]>
  • Loading branch information
stbergmann committed Jan 8, 2025
1 parent 0d71b29 commit bea1ab8
Show file tree
Hide file tree
Showing 49 changed files with 905 additions and 1,148 deletions.
1 change: 0 additions & 1 deletion include/svl/hint.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ enum class SfxHintId {
SwRemoveUnoObject,
SwHiddenParaPrint,
SwFormatChange,
SwAttrSetChange,

ThisIsAnSdrHint,
ThisIsAnSfxEventHint
Expand Down
1 change: 1 addition & 0 deletions sw/inc/fmtcol.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public:
switch(nWhich)
{
case RES_OBJECTDYING:
case RES_ATTRSET_CHG:
m_bInSwFntCache = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions sw/inc/hintids.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
class SfxStringItem;
class SwFormatChg;
class SwUpdateAttr;
class SwAttrSetChg;
class SwFormatMeta;
class SwFormatContentControl;
class SvXMLAttrContainerItem;
Expand Down Expand Up @@ -429,8 +430,7 @@ inline constexpr sal_uInt16 RES_FORMAT_MSG_BEGIN(RES_FMT_END);
inline constexpr TypedWhichId<SwPtrMsgPoolItem> 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<SwAttrSetChg> RES_ATTRSET_CHG(169);
inline constexpr TypedWhichId<SwUpdateAttr> RES_UPDATE_ATTR(170);
// empty
inline constexpr sal_uInt16 RES_FORMAT_MSG_END(190);
Expand Down
14 changes: 3 additions & 11 deletions sw/inc/hints.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -391,15 +383,15 @@ 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
const SwAttrSet* m_pTheChgdSet; ///< is only used to compare
public:
SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet );
SwAttrSetChg( const SwAttrSetChg& );
~SwAttrSetChg();
virtual ~SwAttrSetChg() override;

/// What has changed
const SwAttrSet* GetChgSet() const { return m_pChgSet; }
Expand Down
2 changes: 0 additions & 2 deletions sw/inc/ndtxt.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class SwFormatChangeHint;
namespace sw {
class TextNodeNotificationSuppressor;
class RemoveUnoObjectHint;
class AttrSetChangeHint;
namespace mark { enum class RestoreMode; }
}

Expand Down Expand Up @@ -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&);

Expand Down
19 changes: 10 additions & 9 deletions sw/inc/swevent.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,24 @@ struct SwCallMouseEvent final
SwClient::SwClientNotify(rMod, rHint);
if (!GetRegisteredIn() || static_cast<const sw::RemoveUnoObjectHint&>(rHint).m_pObject == PTR.pFormat)
Clear();
return;
}
else if(SfxHintId::SwFormatChange == rHint.GetId())
if(SfxHintId::SwFormatChange == rHint.GetId())
{
auto pChgHint = static_cast<const SwFormatChangeHint*>(&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();
}
};

Expand Down
1 change: 0 additions & 1 deletion sw/inc/txtatr.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 0 additions & 4 deletions sw/qa/core/uwriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1681,8 +1681,6 @@ namespace
++m_nNotifyCount;
else if(dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
++m_nModifyCount;
else if(dynamic_cast<const sw::AttrSetChangeHint*>(&rHint))
++m_nModifyCount;
else if(auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
{
++m_nModifyChangedCount;
Expand All @@ -1698,8 +1696,6 @@ namespace
{
if(dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
++m_nModifyCount;
else if(dynamic_cast<const sw::AttrSetChangeHint*>(&rHint))
++m_nModifyCount;
}
};
struct TestListener : SvtListener
Expand Down
1 change: 1 addition & 0 deletions sw/source/core/attr/BorderCacheOwner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions sw/source/core/attr/calbck.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down
53 changes: 22 additions & 31 deletions sw/source/core/attr/format.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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<const sw::AttrSetChangeHint*>(&rHint);
std::optional<SwAttrSetChg> oOldClientChg, oNewClientChg;
std::optional<sw::AttrSetChangeHint> 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<const sw::LegacyModifyHint*>(&rHint);
Expand Down Expand Up @@ -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<const SwAttrSetChg*>(pLegacy->m_pOld);
auto pNewAttrSetChg = static_cast<const SwAttrSetChg*>(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))
Expand Down
6 changes: 4 additions & 2 deletions sw/source/core/attr/hints.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 4 additions & 2 deletions sw/source/core/crsr/crsrsh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -2935,6 +2936,7 @@ void SwCursorShell::SwClientNotify(const SwModify&, const SfxHint& rHint)
{
EndListeningAll();
}

}

/** Does the current cursor create a selection?
Expand Down
2 changes: 1 addition & 1 deletion sw/source/core/doc/docfmt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions sw/source/core/doc/docftn.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,16 @@ void SwEndNoteInfo::SwClientNotify( const SwModify& rModify, const SfxHint& rHin
if (rHint.GetId() == SfxHintId::SwLegacyModify)
{
auto pLegacyHint = static_cast<const sw::LegacyModifyHint*>(&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();
}
Expand Down
Loading

0 comments on commit bea1ab8

Please sign in to comment.