summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2018-02-09 02:08:14 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2018-02-09 02:08:14 +0100
commit13edc0e3cd13b74ef6f47c6943d8e16635cac51a (patch)
treed40c9619b4828d8be2ae4fbdeedea8878e25dbca
parent8eb13932c89642c5b2bf8774f8174b75b05fcc2e (diff)
kill SwDepend in SwPageDesc
Change-Id: I8c0eb038aa334d8f32c12ef0ca1af425f6c71292
-rw-r--r--sw/inc/pagedesc.hxx5
-rw-r--r--sw/source/core/layout/pagedesc.cxx62
2 files changed, 47 insertions, 20 deletions
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 60e5958de00e..0056abaa4e7b 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -146,7 +146,8 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify
// FIXME epicycles growing here - page margins need to be stored differently
SwFrameFormat m_FirstMaster;
SwFrameFormat m_FirstLeft;
- SwDepend m_Depend; ///< Because of grid alignment (Registerhaltigkeit).
+ SwMultiDepend m_aDepends; ///< Because of grid alignment (Registerhaltigkeit).
+ mutable const SwTextFormatColl* m_pTextFormatColl;
SwPageDesc *m_pFollow;
sal_uInt16 m_nRegHeight; ///< Sentence spacing and fontascent of style.
sal_uInt16 m_nRegAscent; ///< For grid alignment (Registerhaltigkeit).
@@ -177,7 +178,7 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify
};
protected:
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) override;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
public:
const OUString& GetName() const { return m_StyleName; }
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index 26cfde205d6f..7021990a75b7 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -43,7 +43,7 @@ SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat *pFormat, SwDoc *con
, m_Left( pDoc->GetAttrPool(), rName, pFormat )
, m_FirstMaster( pDoc->GetAttrPool(), rName, pFormat )
, m_FirstLeft( pDoc->GetAttrPool(), rName, pFormat )
- , m_Depend( this, nullptr )
+ , m_aDepends(*this)
, m_pFollow( this )
, m_nRegHeight( 0 )
, m_nRegAscent( 0 )
@@ -63,7 +63,8 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy )
, m_Left( rCpy.GetLeft() )
, m_FirstMaster( rCpy.GetFirstMaster() )
, m_FirstLeft( rCpy.GetFirstLeft() )
- , m_Depend( this, const_cast<SwModify*>(rCpy.m_Depend.GetRegisteredIn()) )
+ , m_aDepends(*this)
+ , m_pTextFormatColl(nullptr)
, m_pFollow( rCpy.m_pFollow )
, m_nRegHeight( rCpy.GetRegHeight() )
, m_nRegAscent( rCpy.GetRegAscent() )
@@ -74,6 +75,11 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy )
, m_IsFootnoteInfo( rCpy.GetFootnoteInfo() )
, m_pdList( nullptr )
{
+ if(rCpy.m_pTextFormatColl && const_cast<SwMultiDepend*>(&rCpy.m_aDepends)->IsListeningTo(rCpy.m_pTextFormatColl))
+ {
+ m_pTextFormatColl = rCpy.m_pTextFormatColl;
+ m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
+ }
}
SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
@@ -84,6 +90,14 @@ SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
m_Left = rSrc.m_Left;
m_FirstMaster = rSrc.m_FirstMaster;
m_FirstLeft = rSrc.m_FirstLeft;
+ m_aDepends.EndListeningAll();
+ if(rSrc.m_pTextFormatColl && const_cast<SwMultiDepend*>(&rSrc.m_aDepends)->IsListeningTo(rSrc.m_pTextFormatColl))
+ {
+ m_pTextFormatColl = rSrc.m_pTextFormatColl;
+ m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
+ }
+ else
+ m_pTextFormatColl = nullptr;
if (rSrc.m_pFollow == &rSrc)
m_pFollow = this;
@@ -165,15 +179,13 @@ bool SwPageDesc::GetInfo( SfxPoolItem & rInfo ) const
}
/// set the style for the grid alignment
-void SwPageDesc::SetRegisterFormatColl( const SwTextFormatColl* pFormat )
+void SwPageDesc::SetRegisterFormatColl(const SwTextFormatColl* pFormat)
{
- if( pFormat != GetRegisterFormatColl() )
+ if(pFormat != m_pTextFormatColl)
{
- if( pFormat )
- const_cast<SwTextFormatColl*>(pFormat)->Add(&m_Depend);
- else
- const_cast<SwTextFormatColl*>(GetRegisterFormatColl())->Remove(&m_Depend);
-
+ m_aDepends.EndListeningAll();
+ m_pTextFormatColl = pFormat;
+ m_aDepends.StartListening(const_cast<SwTextFormatColl*>(m_pTextFormatColl));
RegisterChange();
}
}
@@ -181,8 +193,9 @@ void SwPageDesc::SetRegisterFormatColl( const SwTextFormatColl* pFormat )
/// retrieve the style for the grid alignment
const SwTextFormatColl* SwPageDesc::GetRegisterFormatColl() const
{
- const SwModify* pReg = m_Depend.GetRegisteredIn();
- return static_cast<const SwTextFormatColl*>(pReg);
+ if(!const_cast<SwMultiDepend*>(&m_aDepends)->IsListeningTo(m_pTextFormatColl))
+ m_pTextFormatColl = nullptr;
+ return m_pTextFormatColl;
}
/// notify all affected page frames
@@ -238,15 +251,28 @@ void SwPageDesc::RegisterChange()
}
/// special handling if the style of the grid alignment changes
-void SwPageDesc::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
+void SwPageDesc::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
- NotifyClients( pOld, pNew );
-
- if ( (RES_ATTRSET_CHG == nWhich) || (RES_FMT_CHG == nWhich)
- || isCHRATR(nWhich) || (RES_PARATR_LINESPACING == nWhich) )
+ if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{
- RegisterChange();
+ const sal_uInt16 nWhich = pLegacyHint->m_pOld
+ ? pLegacyHint->m_pOld->Which()
+ : pLegacyHint->m_pNew
+ ? pLegacyHint->m_pNew->Which()
+ : 0;
+ NotifyClients(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
+ if((RES_ATTRSET_CHG == nWhich)
+ || (RES_FMT_CHG == nWhich)
+ || isCHRATR(nWhich)
+ || (RES_PARATR_LINESPACING == nWhich))
+ RegisterChange();
+ }
+ else if (auto pModifyChangedHint = dynamic_cast<const sw::ModifyChangedHint*>(&rHint))
+ {
+ if(m_pTextFormatColl == &rModify)
+ m_pTextFormatColl = static_cast<const SwTextFormatColl*>(pModifyChangedHint->m_pNew);
+ else
+ assert(false);
}
}