Kaydet (Commit) 453b90a4 authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide: replace SwTextFrame::Modify() with SwClientNotify()

This is critical because it needs to know what SwTextNode sent the hint.

Fortunately it looks like we can just convert this one implementation
and the backward compat stuff in SwClient will keep the other
SwFrames working as before with their Modify().

Change-Id: I16f0bf7495002e7393148429640262cb38dc4849
üst ab26ca25
...@@ -263,7 +263,7 @@ class SW_DLLPUBLIC SwTextFrame: public SwContentFrame ...@@ -263,7 +263,7 @@ class SW_DLLPUBLIC SwTextFrame: public SwContentFrame
virtual ~SwTextFrame() override; virtual ~SwTextFrame() override;
protected: protected:
virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; virtual void SwClientNotify(SwModify const& rModify, SfxHint const& rHint) override;
public: public:
......
...@@ -1272,13 +1272,41 @@ static bool isA11yRelevantAttribute(sal_uInt16 nWhich) ...@@ -1272,13 +1272,41 @@ static bool isA11yRelevantAttribute(sal_uInt16 nWhich)
return nWhich != RES_CHRATR_RSID; return nWhich != RES_CHRATR_RSID;
} }
void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) // Note: for now this overrides SwClient::SwClientNotify; the intermediary
// classes still override SwClient::Modify, which should continue to work
// as their implementation of SwClientNotify is SwClient's which calls Modify.
// Therefore we also don't need to call SwClient::SwClientNotify(rModify, rHint)
// because that's all it does, and this implementation calls
// SwContentFrame::Modify() when appropriate.
void SwTextFrame::SwClientNotify(SwModify const& rModify, SfxHint const& rHint)
{ {
auto const pHint(dynamic_cast<sw::LegacyModifyHint const*>(&rHint));
assert(pHint); // TODO this is the only type expected here for now
SfxPoolItem const*const pOld(pHint->m_pOld);
SfxPoolItem const*const pNew(pHint->m_pNew);
if (m_pMergedPara)
{
assert(m_pMergedPara->listener.IsListeningTo(&rModify));
}
const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
// modifications concerning frame attributes are processed by the base class // modifications concerning frame attributes are processed by the base class
if( IsInRange( aFrameFormatSetRange, nWhich ) || RES_FMT_CHG == nWhich ) if( IsInRange( aFrameFormatSetRange, nWhich ) || RES_FMT_CHG == nWhich )
{ {
if (m_pMergedPara)
{ // ignore item set changes that don't apply
SwTextNode const*const pAttrNode(
(nWhich == RES_PAGEDESC || nWhich == RES_BREAK)
? m_pMergedPara->pFirstNode
: m_pMergedPara->pParaPropsNode);
if (pAttrNode != &rModify)
{
return;
}
}
SwContentFrame::Modify( pOld, pNew ); SwContentFrame::Modify( pOld, pNew );
if( nWhich == RES_FMT_CHG && getRootFrame()->GetCurrShell() ) if( nWhich == RES_FMT_CHG && getRootFrame()->GetCurrShell() )
{ {
...@@ -1295,6 +1323,14 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1295,6 +1323,14 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
return; return;
} }
if (m_pMergedPara && m_pMergedPara->pParaPropsNode != &rModify)
{
if (isPARATR(nWhich) || isPARATR_LIST(nWhich)) // FRMATR handled above
{
return; // ignore it
}
}
// while locked ignore all modifications // while locked ignore all modifications
if( IsLocked() ) if( IsLocked() )
return; return;
...@@ -1310,6 +1346,7 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1310,6 +1346,7 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
{ {
case RES_LINENUMBER: case RES_LINENUMBER:
{ {
assert(false); // should have been forwarded to SwContentFrame
InvalidateLineNum(); InvalidateLineNum();
} }
break; break;
...@@ -1492,23 +1529,27 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1492,23 +1529,27 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
RES_PARATR_REGISTER, false ); RES_PARATR_REGISTER, false );
if ( bLineSpace || bRegister ) if ( bLineSpace || bRegister )
{ {
Prepare( bRegister ? PREP_REGISTER : PREP_ADJUST_FRM ); if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
CalcLineSpace(); {
InvalidateSize(); Prepare( bRegister ? PREP_REGISTER : PREP_ADJUST_FRM );
InvalidatePrt_(); CalcLineSpace();
InvalidateSize();
InvalidatePrt_();
// i#11859 // i#11859
// (1) Also invalidate next frame on next page/column. // (1) Also invalidate next frame on next page/column.
// (2) Skip empty sections and hidden paragraphs // (2) Skip empty sections and hidden paragraphs
// Thus, use method <InvalidateNextPrtArea()> // Thus, use method <InvalidateNextPrtArea()>
InvalidateNextPrtArea(); InvalidateNextPrtArea();
SetCompletePaint(); SetCompletePaint();
}
nClear |= 0x04; nClear |= 0x04;
if ( bLineSpace ) if ( bLineSpace )
{ {
--nCount; --nCount;
if( IsInSct() && !GetPrev() ) if ((!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
&& IsInSct() && !GetPrev())
{ {
SwSectionFrame *pSect = FindSctFrame(); SwSectionFrame *pSect = FindSctFrame();
if( pSect->ContainsAny() == this ) if( pSect->ContainsAny() == this )
...@@ -1521,15 +1562,19 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1521,15 +1562,19 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT, if ( SfxItemState::SET == rNewSet.GetItemState( RES_PARATR_SPLIT,
false )) false ))
{ {
if ( GetPrev() ) if (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
CheckKeep(); {
Prepare(); if (GetPrev())
InvalidateSize(); CheckKeep();
Prepare();
InvalidateSize();
}
nClear |= 0x08; nClear |= 0x08;
--nCount; --nCount;
} }
if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false) if( SfxItemState::SET == rNewSet.GetItemState( RES_BACKGROUND, false)
&& (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify)
&& !IsFollow() && GetDrawObjs() ) && !IsFollow() && GetDrawObjs() )
{ {
SwSortedObjs *pObjs = GetDrawObjs(); SwSortedObjs *pObjs = GetDrawObjs();
...@@ -1583,7 +1628,8 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1583,7 +1628,8 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) ) rNewSet.GetItemState( RES_CHRATR_CTL_FONT, false ) )
lcl_SetScriptInval( *this, 0 ); lcl_SetScriptInval( *this, 0 );
else if ( SfxItemState::SET == else if ( SfxItemState::SET ==
rNewSet.GetItemState( RES_FRAMEDIR, false ) ) rNewSet.GetItemState( RES_FRAMEDIR, false )
&& (!m_pMergedPara || m_pMergedPara->pParaPropsNode == &rModify))
{ {
SetDerivedR2L( false ); SetDerivedR2L( false );
CheckDirChange(); CheckDirChange();
...@@ -1599,11 +1645,32 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1599,11 +1645,32 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
InvalidatePrt_(); InvalidatePrt_();
} }
if( nClear ) if (nClear || (m_pMergedPara &&
(m_pMergedPara->pParaPropsNode != &rModify ||
m_pMergedPara->pFirstNode != &rModify)))
{ {
SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) ); SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) ); SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(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);
}
}
}
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 ) if( 0x01 & nClear )
{ {
aOldSet.ClearItem( RES_TXTATR_FTN ); aOldSet.ClearItem( RES_TXTATR_FTN );
...@@ -1671,6 +1738,7 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) ...@@ -1671,6 +1738,7 @@ void SwTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
bSetFieldsDirty = true; bSetFieldsDirty = true;
break; break;
case RES_FRAMEDIR : case RES_FRAMEDIR :
assert(false); // should have been forwarded to SwContentFrame
SetDerivedR2L( false ); SetDerivedR2L( false );
CheckDirChange(); CheckDirChange();
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment