[Libreoffice-commits] core.git: sw/inc sw/source
Bjoern Michaelsen (via logerrit)
logerrit at kemper.freedesktop.org
Sat Nov 21 18:31:58 UTC 2020
sw/inc/hints.hxx | 19 ++++
sw/source/core/inc/cellfrm.hxx | 2
sw/source/core/layout/tabfrm.cxx | 150 ++++++++++++++++++++++++---------------
sw/source/core/undo/untbl.cxx | 21 +----
4 files changed, 117 insertions(+), 75 deletions(-)
New commits:
commit bc8458e9b8473ea391f8150ce7b2c1765e936fdf
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sat Nov 21 13:52:52 2020 +0100
Commit: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sat Nov 21 19:31:11 2020 +0100
Remove SwIterator hack in untable
- also move SwCellFrame from Modify to SwClientNotify
Change-Id: I9e486623a5a3245726e13552223a76610d1d3494
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106313
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
diff --git a/sw/inc/hints.hxx b/sw/inc/hints.hxx
index 51a048a271b7..25fed4c87783 100644
--- a/sw/inc/hints.hxx
+++ b/sw/inc/hints.hxx
@@ -33,6 +33,9 @@ class SwFrame;
class SwHistory;
class SwTextNode;
class SwTextFormatColl;
+class SwFrameFormat;
+class SwTableLine;
+class SwTableBox;
// Base class for all Message-Hints:
// "Overhead" of SfxPoolItem is handled here
@@ -147,6 +150,22 @@ class PreGraphicArrivedHint final : public SfxHint
class PostGraphicArrivedHint final : public SfxHint
{
};
+
+class MoveTableLineHint final : public SfxHint
+{
+public:
+ const SwFrameFormat& m_rNewFormat;
+ const SwTableLine& m_rTableLine;
+ MoveTableLineHint(const SwFrameFormat& rNewFormat, const SwTableLine& rTableLine): m_rNewFormat(rNewFormat), m_rTableLine(rTableLine) {};
+};
+
+class MoveTableBoxHint final : public SfxHint
+{
+public:
+ const SwFrameFormat& m_rNewFormat;
+ const SwTableBox& m_rTableBox;
+ MoveTableBoxHint(const SwFrameFormat& rNewFormat, const SwTableBox& rTableBox): m_rNewFormat(rNewFormat), m_rTableBox(rTableBox) {};
+};
}
class SwUpdateAttr final : public SwMsgPoolItem
diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx
index 4e4aa9b016c3..d2f8730691ed 100644
--- a/sw/source/core/inc/cellfrm.hxx
+++ b/sw/source/core/inc/cellfrm.hxx
@@ -36,7 +36,7 @@ class SwCellFrame: public SwLayoutFrame
protected:
virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr ) override;
- virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
+ virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
public:
SwCellFrame( const SwTableBox &, SwFrame*, bool bInsertContent );
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index c49b0d4d3f0b..13ba152f12fe 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3868,6 +3868,16 @@ void SwRowFrame::OnFrameSize(const SwFormatFrameSize& rSize)
void SwRowFrame::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
+ if(auto pMoveTableLineHint = dynamic_cast<const sw::MoveTableLineHint*>(&rHint))
+ {
+
+ if(GetTabLine() != &pMoveTableLineHint->m_rTableLine)
+ return;
+ const_cast<SwFrameFormat*>(&pMoveTableLineHint->m_rNewFormat)->Add(this);
+ InvalidateAll();
+ ReinitializeFrameSizeAttrFlags();
+ return;
+ }
auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
if(!pLegacy)
return;
@@ -5369,72 +5379,98 @@ void SwCellFrame::Format( vcl::RenderContext* /*pRenderContext*/, const SwBorder
}
}
-void SwCellFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
+void SwCellFrame::SwClientNotify(const SwModify&, const SfxHint& rHint)
{
- bool bAttrSetChg = pNew && RES_ATTRSET_CHG == pNew->Which();
- const SfxPoolItem *pItem = nullptr;
-
- if( bAttrSetChg )
- static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState( RES_VERT_ORIENT, false, &pItem);
- else if (pNew && RES_VERT_ORIENT == pNew->Which())
- pItem = pNew;
-
- if ( pItem )
+ if(auto pMoveTableBoxHint = dynamic_cast<const sw::MoveTableBoxHint*>(&rHint))
+ {
+ if(GetTabBox() != &pMoveTableBoxHint->m_rTableBox)
+ return;
+ const_cast<SwFrameFormat*>(&pMoveTableBoxHint->m_rNewFormat)->Add(this);
+ InvalidateAll();
+ ReinitializeFrameSizeAttrFlags();
+ SetDerivedVert(false);
+ CheckDirChange();
+ return;
+ }
+ else if(auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{
- bool bInva = true;
- if ( text::VertOrientation::NONE == static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() &&
- // OD 04.11.2003 #112910#
- Lower() && Lower()->IsContentFrame() )
+ const SfxPoolItem* pVertOrientItem = nullptr;
+ const SfxPoolItem* pProtectItem = nullptr;
+ const SfxPoolItem* pFrameDirItem = nullptr;
+ const SfxPoolItem* pBoxItem = nullptr;
+ const auto nWhich = pLegacy->m_pNew ? pLegacy->m_pNew->Which() : 0;
+ switch(nWhich)
{
- SwRectFnSet aRectFnSet(this);
- const tools::Long lYStart = aRectFnSet.GetPrtTop(*this);
- bInva = lcl_ArrangeLowers( this, lYStart, false );
+ case RES_ATTRSET_CHG:
+ {
+ auto& rChgSet = *static_cast<const SwAttrSetChg*>(pLegacy->m_pNew)->GetChgSet();
+ rChgSet.GetItemState(RES_VERT_ORIENT, false, &pVertOrientItem);
+ rChgSet.GetItemState(RES_PROTECT, false, &pProtectItem);
+ rChgSet.GetItemState(RES_FRAMEDIR, false, &pFrameDirItem);
+ rChgSet.GetItemState(RES_BOX, false, &pBoxItem);
+ break;
+ }
+ case RES_VERT_ORIENT:
+ pVertOrientItem = pLegacy->m_pNew;
+ break;
+ case RES_PROTECT:
+ pProtectItem = pLegacy->m_pNew;
+ break;
+ case RES_FRAMEDIR:
+ pFrameDirItem = pLegacy->m_pNew;
+ break;
+ case RES_BOX:
+ pBoxItem = pLegacy->m_pNew;
+ break;
}
- if ( bInva )
+ if(pVertOrientItem)
{
- SetCompletePaint();
- InvalidatePrt();
+ bool bInva = true;
+ const auto eVertOrient = static_cast<const SwFormatVertOrient*>(pVertOrientItem)->GetVertOrient();
+ if(text::VertOrientation::NONE == eVertOrient && Lower() && Lower()->IsContentFrame())
+ {
+ SwRectFnSet aRectFnSet(this);
+ const tools::Long lYStart = aRectFnSet.GetPrtTop(*this);
+ bInva = lcl_ArrangeLowers(this, lYStart, false);
+ }
+ if (bInva)
+ {
+ SetCompletePaint();
+ InvalidatePrt();
+ }
}
- }
-
- if ( ( bAttrSetChg &&
- SfxItemState::SET == static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState( RES_PROTECT, false ) ) ||
- ( pNew && RES_PROTECT == pNew->Which()) )
- {
- SwViewShell *pSh = getRootFrame()->GetCurrShell();
- if( pSh && pSh->GetLayout()->IsAnyShellAccessible() )
- pSh->Imp()->InvalidateAccessibleEditableState( true, this );
- }
-
- if ( bAttrSetChg &&
- SfxItemState::SET == static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState( RES_FRAMEDIR, false, &pItem ) )
- {
- SetDerivedVert( false );
- CheckDirChange();
- }
-
- // #i29550#
- if ( bAttrSetChg &&
- SfxItemState::SET == static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState( RES_BOX, false, &pItem ) )
- {
- SwFrame* pTmpUpper = GetUpper();
- while ( pTmpUpper->GetUpper() && !pTmpUpper->GetUpper()->IsTabFrame() )
- pTmpUpper = pTmpUpper->GetUpper();
-
- SwTabFrame* pTabFrame = static_cast<SwTabFrame*>(pTmpUpper->GetUpper());
- if ( pTabFrame->IsCollapsingBorders() )
+ if(pProtectItem)
{
- // Invalidate lowers of this and next row:
- lcl_InvalidateAllLowersPrt( static_cast<SwRowFrame*>(pTmpUpper) );
- pTmpUpper = pTmpUpper->GetNext();
- if ( pTmpUpper )
- lcl_InvalidateAllLowersPrt( static_cast<SwRowFrame*>(pTmpUpper) );
- else
- pTabFrame->InvalidatePrt();
+ SwViewShell* pSh = getRootFrame()->GetCurrShell();
+ if(pSh && pSh->GetLayout()->IsAnyShellAccessible())
+ pSh->Imp()->InvalidateAccessibleEditableState(true, this);
}
- }
+ if(pFrameDirItem)
+ {
+ SetDerivedVert(false);
+ CheckDirChange();
+ }
+ // #i29550#
+ if(pBoxItem)
+ {
+ SwFrame* pTmpUpper = GetUpper();
+ while(pTmpUpper->GetUpper() && !pTmpUpper->GetUpper()->IsTabFrame())
+ pTmpUpper = pTmpUpper->GetUpper();
- SwLayoutFrame::Modify( pOld, pNew );
+ SwTabFrame* pTabFrame = static_cast<SwTabFrame*>(pTmpUpper->GetUpper());
+ if(pTabFrame->IsCollapsingBorders())
+ {
+ // Invalidate lowers of this and next row:
+ lcl_InvalidateAllLowersPrt(static_cast<SwRowFrame*>(pTmpUpper));
+ pTmpUpper = pTmpUpper->GetNext();
+ if(pTmpUpper)
+ lcl_InvalidateAllLowersPrt(static_cast<SwRowFrame*>(pTmpUpper));
+ else
+ pTabFrame->InvalidatePrt();
+ }
+ }
+ SwLayoutFrame::Modify(pLegacy->m_pOld, pLegacy->m_pNew);
+ }
}
tools::Long SwCellFrame::GetLayoutRowSpan() const
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 462ca92b0d20..f46961cfedca 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1089,23 +1089,10 @@ void SaveTable::NewFrameFormat( const SwTableLine* pTableLn, const SwTableBox* p
}
// first re-assign Frames
- SwIterator<SwLayoutFrame,SwFormat> aIter( *pOldFormat );
- for( SwFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
- {
- if( pTableLn ? static_cast<SwRowFrame*>(pLast)->GetTabLine() == pTableLn
- : static_cast<SwCellFrame*>(pLast)->GetTabBox() == pTableBx )
- {
- pLast->RegisterToFormat(*pFormat);
- pLast->InvalidateAll();
- pLast->ReinitializeFrameSizeAttrFlags();
- if ( !pTableLn )
- {
- static_cast<SwCellFrame*>(pLast)->SetDerivedVert( false );
- static_cast<SwCellFrame*>(pLast)->CheckDirChange();
- }
- }
- }
-
+ if(pTableLn)
+ pOldFormat->CallSwClientNotify(sw::MoveTableLineHint(*pFormat, *pTableLn));
+ else
+ pOldFormat->CallSwClientNotify(sw::MoveTableBoxHint(*pFormat, *pTableBx));
// than re-assign myself
if ( pTableLn )
const_cast<SwTableLine*>(pTableLn)->RegisterToFormat( *pFormat );
More information about the Libreoffice-commits
mailing list