diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2018-10-28 19:55:47 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2018-10-28 19:55:47 +0100 |
commit | 5fe12d600adc3e2ddfe80ac7acfd1c12ba945605 (patch) | |
tree | 6a4f47f0479cc7337b4ebc473573d9ff60b680ea | |
parent | sd: fix incorrect visible center calculation (diff) | |
download | core-private/Sweetshark/multilistenerfix.tar.gz core-private/Sweetshark/multilistenerfix.zip |
compiles
private/Sweetshark/multilistenerfix
Change-Id: Ief5a8074882666e6f2ac9a250f0be39894ac6c10
-rw-r--r-- | sw/inc/ftninfo.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/doc/docftn.cxx | 36 | ||||
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 8 |
3 files changed, 30 insertions, 19 deletions
diff --git a/sw/inc/ftninfo.hxx b/sw/inc/ftninfo.hxx index 9a6982a81893..4e59635af394 100644 --- a/sw/inc/ftninfo.hxx +++ b/sw/inc/ftninfo.hxx @@ -33,7 +33,9 @@ class SwDoc; class SW_DLLPUBLIC SwEndNoteInfo : public SwClient { SwDepend aPageDescDep; - SwDepend aCharFormatDep, aAnchorCharFormatDep; + sw::WriterMultiListener aCharFormatDep; + mutable SwCharFormat* pCharFormat; + SwDepend aAnchorCharFormatDep; OUString sPrefix; OUString sSuffix; protected: @@ -54,7 +56,6 @@ public: SwCharFormat* GetCharFormat(SwDoc &rDoc) const; void SetCharFormat( SwCharFormat* ); - SwClient *GetCharFormatDep() const { return const_cast<SwClient*>(static_cast<SwClient const *>(&aCharFormatDep)); } SwCharFormat* GetAnchorCharFormat(SwDoc &rDoc) const; void SetAnchorCharFormat( SwCharFormat* ); diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index 3ddfcf96c9ee..97ec6670f679 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -41,7 +41,10 @@ SwEndNoteInfo& SwEndNoteInfo::operator=(const SwEndNoteInfo& rInfo) { StartListeningToSameModifyAs(rInfo); aPageDescDep.StartListeningToSameModifyAs(rInfo.aPageDescDep); - aCharFormatDep.StartListeningToSameModifyAs(rInfo.aCharFormatDep); + pCharFormat = rInfo.pCharFormat; + aCharFormatDep.EndListeningAll(); + aCharFormatDep.StartListening(pCharFormat); + //TODO: aCharFormatDep.StartListeningToSameModifyAs(rInfo.aCharFormatDep); aAnchorCharFormatDep.StartListeningToSameModifyAs(rInfo.aAnchorCharFormatDep); aFormat = rInfo.aFormat; @@ -56,8 +59,9 @@ bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const { return aPageDescDep.GetRegisteredIn() == rInfo.aPageDescDep.GetRegisteredIn() && - aCharFormatDep.GetRegisteredIn() == - rInfo.aCharFormatDep.GetRegisteredIn() && +// aCharFormatDep.GetRegisteredIn() == +// rInfo.aCharFormatDep.GetRegisteredIn() && + pCharFormat == rInfo.pCharFormat && aAnchorCharFormatDep.GetRegisteredIn() == rInfo.aAnchorCharFormatDep.GetRegisteredIn() && GetFootnoteTextColl() == rInfo.GetFootnoteTextColl() && @@ -71,7 +75,8 @@ bool SwEndNoteInfo::operator==( const SwEndNoteInfo& rInfo ) const SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) : SwClient( rInfo.GetFootnoteTextColl() ), aPageDescDep( this, nullptr ), - aCharFormatDep( this, nullptr ), + aCharFormatDep( *this ), + pCharFormat(rInfo.pCharFormat), aAnchorCharFormatDep( this, nullptr ), sPrefix( rInfo.sPrefix ), sSuffix( rInfo.sSuffix ), @@ -80,14 +85,15 @@ SwEndNoteInfo::SwEndNoteInfo(const SwEndNoteInfo& rInfo) : nFootnoteOffset( rInfo.nFootnoteOffset ) { aPageDescDep.StartListeningToSameModifyAs(rInfo.aPageDescDep); - aCharFormatDep.StartListeningToSameModifyAs(rInfo.aCharFormatDep); + aCharFormatDep.StartListening(pCharFormat); aAnchorCharFormatDep.StartListeningToSameModifyAs(rInfo.aAnchorCharFormatDep); } SwEndNoteInfo::SwEndNoteInfo() : SwClient(nullptr), aPageDescDep( this, nullptr ), - aCharFormatDep( this, nullptr ), + aCharFormatDep( *this ), + pCharFormat(nullptr), aAnchorCharFormatDep( this, nullptr ), m_bEndNote( true ), nFootnoteOffset( 0 ) @@ -129,19 +135,23 @@ void SwEndNoteInfo::SetFootnoteTextColl(SwTextFormatColl& rFormat) SwCharFormat* SwEndNoteInfo::GetCharFormat(SwDoc &rDoc) const { - if ( !aCharFormatDep.GetRegisteredIn() ) + if ( !pCharFormat ) { - SwCharFormat* pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>( + pCharFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( static_cast<sal_uInt16>( m_bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE ) ); - pFormat->Add( &const_cast<SwClient&>(static_cast<const SwClient&>(aCharFormatDep)) ); + auto pDep = const_cast<sw::WriterMultiListener*>(&aCharFormatDep); + pDep->EndListeningAll(); + pDep->StartListening(pCharFormat); } - return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(aCharFormatDep.GetRegisteredIn())); + return pCharFormat; } void SwEndNoteInfo::SetCharFormat( SwCharFormat* pChFormat ) { OSL_ENSURE(pChFormat, "no CharFormat?"); - pChFormat->Add( &static_cast<SwClient&>(aCharFormatDep) ); + pCharFormat = pChFormat; + aCharFormatDep.EndListeningAll(); + aCharFormatDep.StartListening(pCharFormat); } SwCharFormat* SwEndNoteInfo::GetAnchorCharFormat(SwDoc &rDoc) const @@ -169,8 +179,8 @@ void SwEndNoteInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) RES_FMT_CHG == nWhich ) { SwDoc* pDoc; - if( aCharFormatDep.GetRegisteredIn() ) - pDoc = static_cast<SwFormat*>(aCharFormatDep.GetRegisteredIn())->GetDoc(); + if( pCharFormat ) + pDoc = pCharFormat->GetDoc(); else pDoc = static_cast<SwFormat*>(aAnchorCharFormatDep.GetRegisteredIn())->GetDoc(); SwFootnoteIdxs& rFootnoteIdxs = pDoc->GetFootnoteIdxs(); diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 2e0a8fbc131b..16f336481a57 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -498,8 +498,8 @@ uno::Any SwXFootnoteProperties::getPropertyValue(const OUString& rPropertyName) } else { - if( rFootnoteInfo.GetCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rFootnoteInfo.GetCharFormat(*pDoc); + if( SwCharFormat* pFormat = rFootnoteInfo.GetCharFormat(*pDoc) ) + pCharFormat = pFormat; } if( pCharFormat ) { @@ -721,8 +721,8 @@ uno::Any SwXEndnoteProperties::getPropertyValue(const OUString& rPropertyName) } else { - if( rEndInfo.GetCharFormatDep()->GetRegisteredIn() ) - pCharFormat = rEndInfo.GetCharFormat(*pDoc); + if( auto pFormat = rEndInfo.GetCharFormat(*pDoc) ) + pCharFormat = pFormat; } if( pCharFormat ) { |