summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ivan <alexnivan@yahoo.com>2013-08-12 20:02:17 +0300
committerAlex Ivan <alexnivan@yahoo.com>2013-08-12 20:02:17 +0300
commit6538a97573635fe9d8cfa595963d7d18394a25c6 (patch)
treee19a8ecf54e482a80daa989919c7c83a88915b32
parent8d9905db69b2693cde5e80e53ccab521f4b8040f (diff)
Store table style in Undo by name
Undo object no longer stores a pointer to the style, but rather the name of the respective table style. Change-Id: I1f6f196569d33353a9075489d136df9e5075d36b
-rw-r--r--sw/source/core/doc/swtblfmt.cxx2
-rw-r--r--sw/source/core/doc/tblafmt.cxx4
-rw-r--r--sw/source/core/inc/UndoTable.hxx3
-rw-r--r--sw/source/core/undo/untbl.cxx23
4 files changed, 24 insertions, 8 deletions
diff --git a/sw/source/core/doc/swtblfmt.cxx b/sw/source/core/doc/swtblfmt.cxx
index 276c37a0f6a3..965f3e87dc96 100644
--- a/sw/source/core/doc/swtblfmt.cxx
+++ b/sw/source/core/doc/swtblfmt.cxx
@@ -250,7 +250,7 @@ void SwTableFmt::RestoreTableProperties( SwTableFmt* pSrcFmt, SwTable &rTable )
bRowSplit = pSrcFmt->GetRowSplit();
nRepeatHeading = pSrcFmt->GetRepeatHeading();
}
- else
+ else if( pTableStyle )
pTableStyle->Remove( pHardFmt );
AssignFormatParents( pSrcFmt, rTable );
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index 88815539a54f..976aa0a0144e 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -846,7 +846,7 @@ SwTableAutoFmt* SwTableAutoFmt::Load( SvStream& rStream, const SwAfVersions& rVe
// ideal, the table styles are created with the document
SwTableFmt* pStyle = pDoc->FindTblFmtByName(aName);
if ( !pStyle )
- pStyle = pDoc->MakeTblFrmFmt(aName, NULL);
+ pStyle = pDoc->MakeTblFrmFmt( aName, pDoc->GetDfltFrmFmt() );
pRet = new SwTableAutoFmt( aName, pStyle );
pRet->nStrResId = nStrResId;
@@ -967,7 +967,7 @@ SwTableAutoFmtTbl::SwTableAutoFmtTbl(SwDoc* pDoc)
sNm = SwStyleNameMapper::GetUIName( RES_POOLCOLL_STANDARD, sNm );
SwTableFmt* pStyle = pDoc->FindTblFmtByName(sNm);
if ( !pStyle )
- pStyle = pDoc->MakeTblFrmFmt(sNm, NULL);
+ pStyle = pDoc->MakeTblFrmFmt( sNm, pDoc->GetDfltFrmFmt() );
SwTableAutoFmt* pNewTableAutoFmt = new SwTableAutoFmt( sNm, pStyle );
SwTableBoxFmt* pNewBoxFmt = pDoc->MakeTableBoxFmt();
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 09bed01ae94c..4170c219e5f9 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -147,7 +147,8 @@ class SwUndoTblNumFmt;
class SwUndoTblAutoFmt : public SwUndo
{
sal_uLong nSttNode;
- SwTableFmt* pSaveFmt;
+ String sSaveFmtName;
+ //String sEmptyStr;
sal_uInt16 m_nRepeatHeading;
void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 5ddb001861ba..6aca5e7e7776 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1411,7 +1411,9 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd )
nSttNode( rTblNd.GetIndex() ),
m_nRepeatHeading(rTblNd.GetTable().GetRowsToRepeat())
{
- pSaveFmt = (SwTableFmt*)rTblNd.GetTable().GetTableFmt()->GetRegisteredIn();
+ SwTableFmt* pSaveFmt = (SwTableFmt*)rTblNd.GetTable().GetTableFmt()->GetRegisteredIn();
+ if( pSaveFmt )
+ sSaveFmtName = pSaveFmt->GetName();
}
void
@@ -1422,13 +1424,26 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext)
OSL_ENSURE( pTblNd, "no TableNode" );
SwTable& table = pTblNd->GetTable();
- SwTableFmt* pOrig = (SwTableFmt*)table.GetTableFmt()->GetRegisteredIn();
+ String sOrigFmtName;
+ SwTableFmt* pStyle;
+ SwTableFmt* pSaveFmt = (SwTableFmt*)pTblNd->GetTable().GetTableFmt()->GetRegisteredIn();
+ if( pSaveFmt )
+ sOrigFmtName = pSaveFmt->GetName();
+ else
+ sOrigFmtName = UniString::EmptyString();
if( bUndo )
table.SetRowsToRepeat( m_nRepeatHeading );
- SwTableFmt::RestoreTableProperties( pSaveFmt, table );
- pSaveFmt = pOrig;
+ if( !sSaveFmtName.Len() )
+ SwTableFmt::RestoreTableProperties( NULL, table );
+ else
+ {
+ pStyle = rDoc.FindTblFmtByName( sSaveFmtName, sal_True );
+ SwTableFmt::RestoreTableProperties( pStyle, table );
+ }
+
+ sSaveFmtName = sOrigFmtName;
}
void SwUndoTblAutoFmt::UndoImpl(::sw::UndoRedoContext & rContext)