summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2020-11-21 15:48:41 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2020-11-21 21:50:01 +0100
commitcfc04e5fc3ab6c5ee98af04805f3840ba3f3fa67 (patch)
treea36ef6021e331291cc8d73291130ac259447cbab
parent3828a5b35f9ac4006461fa46cbe30e4dde01d01f (diff)
SaveTable: Replace SwClientNotifyCall
Change-Id: I0e961844836d60e96bcda178612fc0372a55cef1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106319 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
-rw-r--r--sw/inc/frmfmt.hxx2
-rw-r--r--sw/source/core/layout/atrfrm.cxx13
-rw-r--r--sw/source/core/undo/untbl.cxx71
3 files changed, 48 insertions, 38 deletions
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index d739925f81f4..0fb32c34d190 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -37,6 +37,7 @@ class IMapObject;
class SwRect;
class SdrObject;
class SwRootFrame;
+class SwTableBox;
namespace sw
{
@@ -178,6 +179,7 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const;
virtual void SetName( const OUString& rNewName, bool bBroadcast=false ) override;
+ void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
};
// The FlyFrame-Format
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index e3ee7fa334b8..84076a24ced6 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -92,6 +92,7 @@
#include <svl/itemiter.hxx>
#include <wrtsh.hxx>
#include <txtfld.hxx>
+#include <cellatr.hxx>
using namespace ::com::sun::star;
@@ -3560,6 +3561,18 @@ drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFrameFormat::getSdrAllF
return maFillAttributes;
}
+void SwFrameFormat::MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat)
+{
+ Add(&rTableBox);
+ if(!pOldFormat)
+ return;
+ const auto& rOld = pOldFormat->GetFormatAttr(RES_BOXATR_FORMAT);
+ const auto& rNew = GetFormatAttr(RES_BOXATR_FORMAT);
+ if(rOld != rNew)
+ SwClientNotify(*this, sw::LegacyModifyHint(&rOld, &rNew));
+}
+
+
namespace sw {
bool IsFlyFrameFormatInHeader(const SwFrameFormat& rFormat)
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index f46961cfedca..a07d8cb7df69 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -95,6 +95,12 @@ namespace {
class SaveBox;
class SaveLine;
+void KillEmptyFrameFormat(SwFrameFormat& rFormat)
+{
+ if(!rFormat.HasWriterListeners())
+ delete &rFormat;
+};
+
}
class SaveTable
@@ -113,14 +119,15 @@ class SaveTable
SaveTable(const SaveTable&) = delete;
SaveTable& operator=(const SaveTable&) = delete;
+ SwFrameFormat& CreateNewFormat(SwFrameFormat& rFormat, sal_uInt16 nFormatPos);
public:
SaveTable( const SwTable& rTable, sal_uInt16 nLnCnt = USHRT_MAX,
bool bSaveFormula = true );
sal_uInt16 AddFormat( SwFrameFormat* pFormat, bool bIsLine );
- void NewFrameFormat( const SwTableLine* , const SwTableBox*, sal_uInt16 nFormatPos,
- SwFrameFormat* pOldFormat );
+ void NewFrameFormatForLine(const SwTableLine&, sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat);
+ void NewFrameFormatForBox(const SwTableBox&, sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat);
void RestoreAttr( SwTable& rTable, bool bModifyBox = false );
void SaveContentAttrs( SwDoc* pDoc );
@@ -1072,43 +1079,31 @@ void SaveTable::CreateNew( SwTable& rTable, bool bCreateFrames,
}
}
-void SaveTable::NewFrameFormat( const SwTableLine* pTableLn, const SwTableBox* pTableBx,
- sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat )
+SwFrameFormat& SaveTable::CreateNewFormat(SwFrameFormat& rFormat, sal_uInt16 nFormatPos)
{
- SwDoc* pDoc = pOldFormat->GetDoc();
-
- SwFrameFormat* pFormat = m_aFrameFormats[ nFormatPos ];
- if( !pFormat )
- {
- if( pTableLn )
- pFormat = pDoc->MakeTableLineFormat();
- else
- pFormat = pDoc->MakeTableBoxFormat();
- pFormat->SetFormatAttr(*m_aSets[nFormatPos]);
- m_aFrameFormats[nFormatPos] = pFormat;
- }
-
- // first re-assign Frames
- 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 );
- else if ( pTableBx )
- const_cast<SwTableBox*>(pTableBx)->RegisterToFormat( *pFormat );
+ rFormat.SetFormatAttr(*m_aSets[nFormatPos]);
+ m_aFrameFormats[nFormatPos] = &rFormat;
+ return rFormat;
+}
- if (m_bModifyBox && !pTableLn)
- {
- const SfxPoolItem& rOld = pOldFormat->GetFormatAttr( RES_BOXATR_FORMAT ),
- & rNew = pFormat->GetFormatAttr( RES_BOXATR_FORMAT );
- if( rOld != rNew )
- pFormat->SwClientNotifyCall(*pFormat, sw::LegacyModifyHint(&rOld, &rNew));
- }
+void SaveTable::NewFrameFormatForLine(const SwTableLine& rTableLn, sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat)
+{
+ SwFrameFormat* pFormat = m_aFrameFormats[nFormatPos];
+ if(!pFormat)
+ pFormat = &CreateNewFormat(*pOldFormat->GetDoc()->MakeTableLineFormat(), nFormatPos);
+ pOldFormat->CallSwClientNotify(sw::MoveTableLineHint(*pFormat, rTableLn));
+ pFormat->Add(const_cast<SwTableLine*>(&rTableLn));
+ KillEmptyFrameFormat(*pOldFormat);
+}
- if( !pOldFormat->HasWriterListeners() )
- delete pOldFormat;
+void SaveTable::NewFrameFormatForBox(const SwTableBox& rTableBx, sal_uInt16 nFormatPos, SwFrameFormat* pOldFormat)
+{
+ SwFrameFormat* pFormat = m_aFrameFormats[nFormatPos];
+ if(!pFormat)
+ pFormat = &CreateNewFormat(*pOldFormat->GetDoc()->MakeTableBoxFormat(), nFormatPos);
+ pOldFormat->CallSwClientNotify(sw::MoveTableBoxHint(*pFormat, rTableBx));
+ pFormat->MoveTableBox(*const_cast<SwTableBox*>(&rTableBx), m_bModifyBox ? pOldFormat : nullptr);
+ KillEmptyFrameFormat(*pOldFormat);
}
SaveLine::SaveLine( SaveLine* pPrev, const SwTableLine& rLine, SaveTable& rSTable )
@@ -1133,7 +1128,7 @@ SaveLine::~SaveLine()
void SaveLine::RestoreAttr( SwTableLine& rLine, SaveTable& rSTable )
{
- rSTable.NewFrameFormat( &rLine, nullptr, nItemSet, rLine.GetFrameFormat() );
+ rSTable.NewFrameFormatForLine( rLine, nItemSet, rLine.GetFrameFormat() );
SaveBox* pBx = pBox;
for( size_t n = 0; n < rLine.GetTabBoxes().size(); ++n, pBx = pBx->pNext )
@@ -1210,7 +1205,7 @@ SaveBox::~SaveBox()
void SaveBox::RestoreAttr( SwTableBox& rBox, SaveTable& rSTable )
{
- rSTable.NewFrameFormat( nullptr, &rBox, nItemSet, rBox.GetFrameFormat() );
+ rSTable.NewFrameFormatForBox( rBox, nItemSet, rBox.GetFrameFormat() );
if( ULONG_MAX == nSttNode ) // no EndBox
{