summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-07-05 01:53:48 +0200
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-07-09 23:28:08 +0200
commit0c8f364421014486c4e35a78a6dabca5b6a5dd26 (patch)
treee4e1e6de8b7dd8391df46ea9353c4df4f27d339b
parentdebfdcfc0b2c07319e4a754decab18a292dc227c (diff)
remove some SwIterator abuse
Change-Id: Ic95562ebb57106c733d919059ff9d042fef28f3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118392 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
-rw-r--r--sw/inc/hints.hxx9
-rw-r--r--sw/source/core/layout/tabfrm.cxx29
-rw-r--r--sw/source/core/table/swtable.cxx44
3 files changed, 42 insertions, 40 deletions
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index e83d42251882..8f978d886c2a 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -35,6 +35,7 @@ class SwTextNode;
class SwTextFormatColl;
class SwFrameFormat;
class SwTableLine;
+class SwTableLineFormat;
class SwTableBox;
// Base class for all Message-Hints:
@@ -170,6 +171,14 @@ public:
class DocumentDyingHint final : public SfxHint
{
};
+
+class TableLineFormatChanged final : public SfxHint
+{
+public:
+ const SwTableLineFormat& m_rNewFormat;
+ const SwTableLine& m_rTabLine;
+ TableLineFormatChanged(const SwTableLineFormat& rNewFormat, const SwTableLine& rTabLine) : m_rNewFormat(rNewFormat), m_rTabLine(rTabLine) {};
+};
}
class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index c54b24d59e3d..c50f4d4873eb 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3919,7 +3919,34 @@ void SwRowFrame::OnFrameSize(const SfxPoolItem& rSize)
void SwRowFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- if(auto pMoveTableLineHint = dynamic_cast<const sw::MoveTableLineHint*>(&rHint))
+ if(auto pNewFormatHint = dynamic_cast<const sw::TableLineFormatChanged*>(&rHint))
+ {
+ if(GetTabLine() != &pNewFormatHint->m_rTabLine)
+ return;
+ RegisterToFormat(const_cast<SwTableLineFormat&>(pNewFormatHint->m_rNewFormat));
+ InvalidateSize();
+ InvalidatePrt_();
+ SetCompletePaint();
+ ReinitializeFrameSizeAttrFlags();
+
+ // #i35063#
+ // consider 'split row allowed' attribute
+ SwTabFrame* pTab = FindTabFrame();
+ bool bInFollowFlowRow = false;
+ const bool bInFirstNonHeadlineRow = pTab->IsFollow() && this == pTab->GetFirstNonHeadlineRow();
+ if(bInFirstNonHeadlineRow ||
+ !GetNext() ||
+ (bInFollowFlowRow = IsInFollowFlowRow()) ||
+ nullptr != IsInSplitTableRow() )
+ {
+ if(bInFirstNonHeadlineRow || bInFollowFlowRow)
+ pTab = pTab->FindMaster();
+
+ pTab->SetRemoveFollowFlowLinePending(true);
+ pTab->InvalidatePos();
+ }
+ }
+ else if(auto pMoveTableLineHint = dynamic_cast<const sw::MoveTableLineHint*>(&rHint))
{
if(GetTabLine() != &pMoveTableLineHint->m_rTableLine)
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index c2f3b3bd9764..fe6a221daa0c 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1496,47 +1496,13 @@ SwFrameFormat* SwTableLine::ClaimFrameFormat()
return pRet;
}
-void SwTableLine::ChgFrameFormat( SwTableLineFormat *pNewFormat )
+void SwTableLine::ChgFrameFormat(SwTableLineFormat* pNewFormat)
{
- SwFrameFormat *pOld = GetFrameFormat();
- SwIterator<SwRowFrame,SwFormat> aIter( *pOld );
-
- // First, re-register the Frames.
- for( SwRowFrame* pRow = aIter.First(); pRow; pRow = aIter.Next() )
- {
- if( pRow->GetTabLine() == this )
- {
- pRow->RegisterToFormat( *pNewFormat );
-
- pRow->InvalidateSize();
- pRow->InvalidatePrt_();
- pRow->SetCompletePaint();
- pRow->ReinitializeFrameSizeAttrFlags();
-
- // #i35063#
- // consider 'split row allowed' attribute
- SwTabFrame* pTab = pRow->FindTabFrame();
- bool bInFollowFlowRow = false;
- const bool bInFirstNonHeadlineRow = pTab->IsFollow() &&
- pRow == pTab->GetFirstNonHeadlineRow();
- if ( bInFirstNonHeadlineRow ||
- !pRow->GetNext() ||
- ( bInFollowFlowRow = pRow->IsInFollowFlowRow() ) ||
- nullptr != pRow->IsInSplitTableRow() )
- {
- if ( bInFirstNonHeadlineRow || bInFollowFlowRow )
- pTab = pTab->FindMaster();
-
- pTab->SetRemoveFollowFlowLinePending( true );
- pTab->InvalidatePos();
- }
- }
- }
-
+ auto pOld = GetFrameFormat();
+ pOld->CallSwClientNotify(sw::TableLineFormatChanged(*pNewFormat, *this));
// Now, re-register self.
- pNewFormat->Add( this );
-
- if ( !pOld->HasWriterListeners() )
+ pNewFormat->Add(this);
+ if(!pOld->HasWriterListeners())
delete pOld;
}