diff options
-rw-r--r-- | include/svl/hint.hxx | 2 | ||||
-rw-r--r-- | sw/inc/hintids.hxx | 2 | ||||
-rw-r--r-- | sw/inc/hints.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/access/accnotextframe.cxx | 66 | ||||
-rw-r--r-- | sw/source/core/access/acctextframe.cxx | 90 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 12 |
6 files changed, 81 insertions, 103 deletions
diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx index c3d0336ac790..b85e4f66d285 100644 --- a/include/svl/hint.hxx +++ b/include/svl/hint.hxx @@ -147,6 +147,8 @@ enum class SfxHintId { SwDeleteText, SwDeleteChar, SwSectionHidden, + SwTitleChanged, + SwDescriptionChanged, ThisIsAnSdrHint }; diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index 1119ca70dc8e..05ee37676181 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -434,8 +434,6 @@ constexpr TypedWhichId<SwPtrMsgPoolItem> RES_REMOVE_UNO_OBJECT(181); // empty constexpr TypedWhichId<SwFindNearestNode> RES_FINDNEARESTNODE(184); constexpr TypedWhichId<SwPtrMsgPoolItem> RES_CONTENT_VISIBLE(185); -constexpr TypedWhichId<SwStringMsgPoolItem> RES_TITLE_CHANGED(188); -constexpr TypedWhichId<SwStringMsgPoolItem> RES_DESCRIPTION_CHANGED(189); constexpr sal_uInt16 RES_FORMAT_MSG_END(190); // An ID for the RTF-reader. The stylesheets are treated like attributes, diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx index ea856ae5cbaf..5530ce7922f3 100644 --- a/sw/inc/hints.hxx +++ b/sw/inc/hints.hxx @@ -214,6 +214,18 @@ public: const OUString m_sNew; NameChanged(const OUString& rOld, const OUString& rNew) : SfxHint(SfxHintId::NameChanged), m_sOld(rOld), m_sNew(rNew) {}; }; +class TitleChanged final : public SfxHint +{ +public: + const OUString m_sOld; + const OUString m_sNew; + TitleChanged(const OUString& rOld, const OUString& rNew) : SfxHint(SfxHintId::SwTitleChanged), m_sOld(rOld), m_sNew(rNew) {}; +}; +class DescriptionChanged final : public SfxHint +{ +public: + DescriptionChanged() : SfxHint(SfxHintId::SwDescriptionChanged) {} +}; class SectionHidden final: public SfxHint { public: diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx index 0f1454602031..d3f7c38bae77 100644 --- a/sw/source/core/access/accnotextframe.cxx +++ b/sw/source/core/access/accnotextframe.cxx @@ -83,33 +83,23 @@ SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame() void SwAccessibleNoTextFrame::Notify(const SfxHint& rHint) { - if(rHint.GetId() == SfxHintId::Dying) - EndListeningAll(); - else if (rHint.GetId() == SfxHintId::SwLegacyModify) + const SwNoTextNode* pNd = GetNoTextNode(); + switch(rHint.GetId()) { - auto pLegacyModifyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); - const sal_uInt16 nWhich = pLegacyModifyHint->GetWhich(); - if (nWhich != RES_TITLE_CHANGED && nWhich != RES_DESCRIPTION_CHANGED) + case SfxHintId::Dying: + EndListeningAll(); return; - const SwNoTextNode* pNd = GetNoTextNode(); - switch(nWhich) - { - // #i73249# - case RES_TITLE_CHANGED: + default: + return; + case SfxHintId::SwTitleChanged: { - OUString sOldTitle, sNewTitle; - const SwStringMsgPoolItem* pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pOld); - if(pOldItem) - sOldTitle = pOldItem->GetString(); - const SwStringMsgPoolItem* pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pNew); - if(pNewItem) - sNewTitle = pNewItem->GetString(); - if(sOldTitle == sNewTitle) + auto rTitleChanged = static_cast<const sw::TitleChanged&>(rHint); + if(rTitleChanged.m_sOld == rTitleChanged.m_sNew) break; - msTitle = sNewTitle; + msTitle = rTitleChanged.m_sNew; AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldTitle; + aEvent.OldValue <<= rTitleChanged.m_sOld; aEvent.NewValue <<= msTitle; FireAccessibleEvent(aEvent); @@ -117,28 +107,22 @@ void SwAccessibleNoTextFrame::Notify(const SfxHint& rHint) break; [[fallthrough]]; } - case RES_DESCRIPTION_CHANGED: + case SfxHintId::SwDescriptionChanged: + if(pNd && GetFrame()) { - if(pNd && GetFrame()) - { - const OUString sOldDesc(msDesc); - - const OUString& rDesc = pNd->GetDescription(); - msDesc = rDesc; - if(msDesc.isEmpty() && msTitle != GetName()) - msDesc = msTitle; - - if(msDesc != sOldDesc) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= msDesc; - FireAccessibleEvent(aEvent); - } - } + const OUString sOldDesc(msDesc); + msDesc = pNd->GetDescription(); + if(msDesc.isEmpty() && msTitle != GetName()) + msDesc = msTitle; + if(msDesc == sOldDesc) + return; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent(aEvent); } - } + return; } } diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 5b29bb9bca23..6b5340ce6f34 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -63,61 +63,45 @@ SwAccessibleTextFrame::~SwAccessibleTextFrame() void SwAccessibleTextFrame::Notify(const SfxHint& rHint) { - if(rHint.GetId() == SfxHintId::Dying) - EndListeningAll(); - else if (rHint.GetId() == SfxHintId::SwLegacyModify) + const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); + const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame ? pFlyFrame->GetFormat() : nullptr; + switch(rHint.GetId()) { - auto pLegacyModifyHint = static_cast<const sw::LegacyModifyHint*>(&rHint); - const sal_uInt16 nWhich = pLegacyModifyHint->GetWhich(); - const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); - switch(nWhich) + case SfxHintId::Dying: + EndListeningAll(); + return; + default: + return; + // #i73249# + case SfxHintId::SwTitleChanged: { - // #i73249# - case RES_TITLE_CHANGED: - { - OUString sOldTitle, sNewTitle; - const SwStringMsgPoolItem *pOldItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pOld); - if(pOldItem) - sOldTitle = pOldItem->GetString(); - const SwStringMsgPoolItem *pNewItem = dynamic_cast<const SwStringMsgPoolItem*>(pLegacyModifyHint->m_pNew); - if(pNewItem) - sNewTitle = pNewItem->GetString(); - if(sOldTitle == sNewTitle) - break; - msTitle = sNewTitle; - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldTitle; - aEvent.NewValue <<= msTitle; - FireAccessibleEvent( aEvent ); - - const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); - if(!pFlyFrameFormat || !pFlyFrameFormat->GetObjDescription().isEmpty()) - break; - [[fallthrough]]; - } - case RES_DESCRIPTION_CHANGED: - { - if(pFlyFrame) - { - const OUString sOldDesc(msDesc); - - const SwFlyFrameFormat* pFlyFrameFormat = pFlyFrame->GetFormat(); - const OUString& rDesc = pFlyFrameFormat->GetObjDescription(); - msDesc = rDesc; - if(msDesc.isEmpty() && msTitle != GetName()) - msDesc = msTitle; - - if(msDesc != sOldDesc) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= msDesc; - FireAccessibleEvent(aEvent); - } - } - } + auto rTitleChanged = static_cast<const sw::TitleChanged&>(rHint); + msTitle = rTitleChanged.m_sNew; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= rTitleChanged.m_sOld; + aEvent.NewValue <<= msTitle; + FireAccessibleEvent( aEvent ); + if(!pFlyFrameFormat || !pFlyFrameFormat->GetObjDescription().isEmpty()) + break; + [[fallthrough]]; + } + case SfxHintId::SwDescriptionChanged: + { + if(!pFlyFrame) + return; + const OUString sOldDesc(msDesc); + msDesc = pFlyFrameFormat->GetObjDescription(); + if(msDesc.isEmpty() && msTitle != GetName()) + msDesc = msTitle; + if(msDesc == sOldDesc) + return; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent(aEvent); + return; } } } diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index ff0763aed532..b53683e780e2 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3204,12 +3204,11 @@ void SwFlyFrameFormat::SetObjTitle( const OUString& rTitle, bool bBroadcast ) return; } - const SwStringMsgPoolItem aOld(RES_TITLE_CHANGED, pMasterObject->GetTitle()); + const sw::TitleChanged aHint(pMasterObject->GetTitle(), rTitle); pMasterObject->SetTitle(rTitle); if(bBroadcast) { - const SwStringMsgPoolItem aNew(RES_TITLE_CHANGED, rTitle); - GetNotifier().Broadcast(sw::LegacyModifyHint(&aOld, &aNew)); + GetNotifier().Broadcast(aHint); } } @@ -3247,12 +3246,11 @@ void SwFlyFrameFormat::SetObjDescription( const OUString& rDescription, bool bBr return; } - const SwStringMsgPoolItem aOld( RES_DESCRIPTION_CHANGED, pMasterObject->GetDescription() ); - pMasterObject->SetDescription( rDescription ); + const sw::DescriptionChanged aHint; + pMasterObject->SetDescription(rDescription); if(bBroadcast) { - const SwStringMsgPoolItem aNew( RES_DESCRIPTION_CHANGED, rDescription ); - GetNotifier().Broadcast(sw::LegacyModifyHint(&aOld, &aNew)); + GetNotifier().Broadcast(aHint); } } |