summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ivan <alexnivan@yahoo.com>2013-07-18 18:45:14 +0300
committerJan Holesovsky <kendy@collabora.com>2015-09-24 01:00:07 +0200
commitdfcacd347568086d99ea633e5413322b607408f6 (patch)
treef7df4feb8a2be42a542086075d71e3b3121f76eb
parentc570f3ca398d3e696ba7900ae8c88eabdac856ec (diff)
Modify undo mechanism for applying table format
Undo object no longer reconstructs table, but changes the table style back to the original. The actual modification _should_ become visible once the proper modifications to the rendering of the table are done. Change-Id: Ife10f52077c9b13d5cf4f44fa1194fe414661cd1
-rw-r--r--sw/source/core/inc/UndoTable.hxx11
-rw-r--r--sw/source/core/undo/untbl.cxx44
2 files changed, 13 insertions, 42 deletions
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 8a75054c3c4e..905789100f19 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -42,6 +42,7 @@ class SwTable;
class SwTableBox;
class SwStartNode;
class SwTableNode;
+class SwTableFormat;
class SwTableAutoFormat;
class SwTableSortBoxes;
@@ -144,9 +145,7 @@ class SwUndoTableNumFormat;
class SwUndoTableAutoFormat : public SwUndo
{
sal_uLong nSttNode;
- _SaveTable* pSaveTable;
- std::vector< std::shared_ptr<SwUndoTableNumFormat> > m_Undos;
- bool bSaveContentAttr;
+ SwTableFormat* pSaveFormat;
sal_uInt16 m_nRepeatHeading;
void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext);
@@ -156,10 +155,8 @@ public:
virtual ~SwUndoTableAutoFormat();
- virtual void UndoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
- virtual void RedoImpl( ::sw::UndoRedoContext & ) SAL_OVERRIDE;
-
- void SaveBoxContent( const SwTableBox& rBox );
+ virtual void UndoImpl( ::sw::UndoRedoContext & );
+ virtual void RedoImpl( ::sw::UndoRedoContext & );
};
class SwUndoTableNdsChg : public SwUndo, private boost::noncopyable
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 6589657b28ed..995a07792e82 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1407,29 +1407,14 @@ SwUndoTableAutoFormat::SwUndoTableAutoFormat( const SwTableNode& rTableNd,
const SwTableAutoFormat& rAFormat )
: SwUndo( UNDO_TABLE_AUTOFMT ),
nSttNode( rTableNd.GetIndex() ),
- bSaveContentAttr( false )
- , m_nRepeatHeading(rTableNd.GetTable().GetRowsToRepeat())
+ m_nRepeatHeading(rTableNd.GetTable().GetRowsToRepeat())
{
- pSaveTable = new _SaveTable( rTableNd.GetTable() );
-
- if( rAFormat.IsFont() || rAFormat.IsJustify() )
- {
- // than also go over the ContentNodes of the EndBoxes and collect
- // all paragraph attributes
- pSaveTable->SaveContentAttrs( const_cast<SwDoc*>(rTableNd.GetDoc()) );
- bSaveContentAttr = true;
- }
+ pSaveFormat = new SwTableFormat( *rAFormat.GetTableStyle() );
}
SwUndoTableAutoFormat::~SwUndoTableAutoFormat()
{
- delete pSaveTable;
-}
-
-void SwUndoTableAutoFormat::SaveBoxContent( const SwTableBox& rBox )
-{
- std::shared_ptr<SwUndoTableNumFormat> const p(new SwUndoTableNumFormat(rBox));
- m_Undos.push_back(p);
+ delete pSaveFormat;
}
void
@@ -1440,25 +1425,14 @@ SwUndoTableAutoFormat::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rConte
OSL_ENSURE( pTableNd, "no TableNode" );
SwTable& table = pTableNd->GetTable();
- _SaveTable* pOrig = new _SaveTable( table );
- // than go also over the ContentNodes of the EndBoxes and collect
- // all paragraph attributes
- if( bSaveContentAttr )
- pOrig->SaveContentAttrs( &rDoc );
+ SwTableFormat* pOrig = new SwTableFormat( *static_cast<SwTableFormat*>(table.GetFrameFormat()->GetRegisteredIn()) );
- if (bUndo)
- {
- for (size_t n = m_Undos.size(); 0 < n; --n)
- {
- m_Undos.at(n-1)->UndoImpl(rContext);
- }
+ if( bUndo )
+ table.SetRowsToRepeat( m_nRepeatHeading );
- table.SetRowsToRepeat(m_nRepeatHeading);
- }
-
- pSaveTable->RestoreAttr( pTableNd->GetTable(), !bUndo );
- delete pSaveTable;
- pSaveTable = pOrig;
+ pSaveFormat->RestoreTableProperties( table );
+ delete pSaveFormat;
+ pSaveFormat = pOrig;
}
void SwUndoTableAutoFormat::UndoImpl(::sw::UndoRedoContext & rContext)