summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/swtblfmt.hxx6
-rw-r--r--sw/source/core/doc/swtblfmt.cxx61
-rw-r--r--sw/source/core/doc/tblafmt.cxx4
-rw-r--r--sw/source/core/docnode/ndtbl.cxx2
-rw-r--r--sw/source/core/undo/untbl.cxx4
5 files changed, 30 insertions, 47 deletions
diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx
index d49396ac002c..0443cbdb5e5c 100644
--- a/sw/inc/swtblfmt.hxx
+++ b/sw/inc/swtblfmt.hxx
@@ -121,10 +121,8 @@ public:
sal_Bool GetRowSplit() const;
sal_uInt16 GetRepeatHeading() const;
- void RestoreTableProperties( SwTable &table ) const;
- void StoreTableProperties( const SwTable &table );
-
- void CopyTableFormatInfo( const SwTableFmt* pTableFormat );
+ static void RestoreTableProperties( SwTableFmt* pSrcFmt, SwTable &table );
+ static SwTableFmt* StoreTableProperties( const SwTable &table );
sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, SwDoc* pDoc, sal_uInt16 nVal );
diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx
index e4a3a89a037f..15c63c7bfe1b 100644
--- a/sw/source/core/doc/swtblfmt.cxx
+++ b/sw/source/core/doc/swtblfmt.cxx
@@ -241,57 +241,42 @@ sal_uInt16 SwTableFmt::GetRepeatHeading() const
return (static_cast<const SfxUInt16Item&>( GetFmtAttr( FN_PARAM_TABLE_HEADLINE ) )).GetValue();
}
-void SwTableFmt::RestoreTableProperties(SwTable &table) const
+void SwTableFmt::RestoreTableProperties( SwTableFmt* pSrcFmt, SwTable &table )
{
- SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
- if (!pFormat)
+ SwTableFmt *pHardFmt = table.GetTableFmt();
+ if( !pHardFmt )
return;
- SwDoc *pDoc = pFormat->GetDoc();
- if (!pDoc)
+ SwDoc *pDoc = pHardFmt->GetDoc();
+ if( !pDoc )
return;
- pFormat->CopyTableFormatInfo( this );
+ SwTableFmt *pTableStyle = (SwTableFmt*)pHardFmt->GetRegisteredIn();
+ sal_Bool bRowSplit = sal_True;
+ sal_uInt16 nRepeatHeading = 0;
- SwEditShell *pShell = pDoc->GetEditShell();
- pDoc->SetRowSplit( *pShell->getShellCrsr( false ), SwFmtRowSplit( GetRowSplit() ) );
-
- table.SetRowsToRepeat( GetRepeatHeading() );
-}
-
-void SwTableFmt::StoreTableProperties(const SwTable &table)
-{
- SwTableFmt *pFormat = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
- if (!pFormat)
- return;
-
- SwDoc *pDoc = pFormat->GetDoc();
- if (!pDoc)
- return;
+ if( pSrcFmt )
+ {
+ pHardFmt->RegisterToFormat( *pSrcFmt );
+ bRowSplit = pSrcFmt->GetRowSplit();
+ nRepeatHeading = pSrcFmt->GetRepeatHeading();
+ }
+ else
+ pTableStyle->Remove( pHardFmt );
SwEditShell *pShell = pDoc->GetEditShell();
- SwFmtRowSplit *pRowSplit = 0;
- pDoc->GetRowSplit( *pShell->getShellCrsr( false ), pRowSplit );
- SetRowSplit( pRowSplit ? pRowSplit->GetValue() : sal_False );
- delete pRowSplit;
- pRowSplit = 0;
+ pDoc->SetRowSplit( *pShell->getShellCrsr( false ), SwFmtRowSplit( bRowSplit ) );
- CopyTableFormatInfo( pFormat );
+ table.SetRowsToRepeat( nRepeatHeading );
}
-void SwTableFmt::CopyTableFormatInfo( const SwTableFmt* pTableFormat )
+SwTableFmt* SwTableFmt::StoreTableProperties( const SwTable &table )
{
- SetFmtAttr( pTableFormat->GetAttrSet() );
-
- m_pFstLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetFirstLineFmt() ) );
- m_pLstLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetLastLineFmt() ) );
- m_pOddLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetOddLineFmt() ) );
- m_pEvnLineFmt.reset( new SwTableLineFmt ( *pTableFormat->GetEvenLineFmt() ) );
+ SwTableFmt *pHardFmt = table.GetTableFmt();
+ if( !pHardFmt )
+ return NULL;
- m_pFstColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetFirstColFmt() ) );
- m_pLstColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetLastColFmt() ) );
- m_pOddColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetOddColFmt() ) );
- m_pEvnColFmt.reset( new SwTableLineFmt ( *pTableFormat->GetEvenColFmt() ) );
+ return (SwTableFmt*)pHardFmt->GetRegisteredIn();
}
SwTableLineFmt::SwTableLineFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index ef80167f12d6..88815539a54f 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -751,12 +751,12 @@ void SwTableAutoFmt::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
void SwTableAutoFmt::RestoreTableProperties(SwTable &table) const
{
- m_pTableStyle->RestoreTableProperties( table );
+ SwTableFmt::RestoreTableProperties( m_pTableStyle, table );
}
void SwTableAutoFmt::StoreTableProperties(const SwTable &table)
{
- m_pTableStyle->StoreTableProperties( table );
+ m_pTableStyle = SwTableFmt::StoreTableProperties( table );
}
sal_Bool SwTableFmt::Load( SvStream& rStream, const SwAfVersions& rVersions, SwDoc* pDoc, sal_uInt16 nVal )
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 60254e5ef791..a8635a33cac3 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3564,7 +3564,7 @@ sal_Bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt&
GetIDocumentUndoRedo().DoUndo(false);
}
- rNew.GetTableStyle()->RestoreTableProperties(table);
+ rNew.RestoreTableProperties(table);
if( pUndo )
{
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 4157e5343400..8c30a5021ef0 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1428,12 +1428,12 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
OSL_ENSURE( pTblNd, "no TableNode" );
SwTable& table = pTblNd->GetTable();
- SwTableFmt* pOrig = new SwTableFmt( *(SwTableFmt*)table.GetTableFmt()->GetRegisteredIn() );
+ SwTableFmt* pOrig = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
if( bUndo )
table.SetRowsToRepeat( m_nRepeatHeading );
- pSaveFmt->RestoreTableProperties( table );
+ SwTableFmt::RestoreTableProperties( pSaveFmt, table );
delete pSaveFmt;
pSaveFmt = pOrig;
}