From a0bd65d2e0e6813f47221ae52092cdb4e748c0e6 Mon Sep 17 00:00:00 2001 From: Oliver-Rainer Wittmann Date: Fri, 22 Jun 2012 09:01:55 +0000 Subject: Resolves: #i119954# fix nest tables to text conversion crash - assure that conversion of nested tables are performed correctly. Found by: Yang Ji Patch by: kang jian Review by: Oliver (cherry picked from commit 48538700cdafaa4becfe74a1d3d93179aed9d764) Change-Id: Iaefbf6f75d526ef8c0c4302d8b39096becc183e8 --- sw/source/core/edit/edtab.cxx | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx index 13dc561589a4..c10e243abcd3 100644 --- a/sw/source/core/edit/edtab.cxx +++ b/sw/source/core/edit/edtab.cxx @@ -52,6 +52,42 @@ using namespace ::com::sun::star::uno; extern void ClearFEShellTabCols(); +//Added for bug #i119954# Application crashed if undo/redo covert nest table to text +sal_Bool ConvertTableToText( const SwTableNode *pTableNode, sal_Unicode cCh ); + +void ConvertNestedTablesToText( const SwTableLines &rTableLines, sal_Unicode cCh ) +{ + for (size_t n = 0; n < rTableLines.size(); ++n) + { + SwTableLine* pTableLine = rTableLines[ n ]; + for (size_t i = 0; i < pTableLine->GetTabBoxes().size(); ++i) + { + SwTableBox* pTableBox = pTableLine->GetTabBoxes()[ i ]; + if (pTableBox->GetTabLines().empty()) + { + SwNodeIndex nodeIndex( *pTableBox->GetSttNd(), 1 ); + SwNodeIndex endNodeIndex( *pTableBox->GetSttNd()->EndOfSectionNode() ); + for( ; nodeIndex < endNodeIndex ; nodeIndex++ ) + { + if ( SwTableNode* pTableNode = nodeIndex.GetNode().GetTableNode() ) + ConvertTableToText( pTableNode, cCh ); + } + } + else + { + ConvertNestedTablesToText( pTableBox->GetTabLines(), cCh ); + } + } + } +} + +sal_Bool ConvertTableToText( const SwTableNode *pConstTableNode, sal_Unicode cCh ) +{ + SwTableNode *pTableNode = const_cast< SwTableNode* >( pConstTableNode ); + ConvertNestedTablesToText( pTableNode->GetTable().GetTabLines(), cCh ); + return pTableNode->GetDoc()->TableToText( pTableNode, cCh ); +} +//End for bug #i119954# const SwTable& SwEditShell::InsertTable( const SwInsertTableOptions& rInsTblOpts, sal_uInt16 nRows, sal_uInt16 nCols, sal_Int16 eAdj, @@ -129,7 +165,11 @@ sal_Bool SwEditShell::TableToText( sal_Unicode cCh ) pCrsr->SetMark(); pCrsr->DeleteMark(); - bRet = GetDoc()->TableToText( pTblNd, cCh ); + //Modified for bug #i119954# Application crashed if undo/redo covert nest table to text + StartUndo(); + bRet = ConvertTableToText( pTblNd, cCh ); + EndUndo(); + //End for bug #i119954# pCrsr->GetPoint()->nNode = aTabIdx; SwCntntNode* pCNd = pCrsr->GetCntntNode(); -- cgit v1.2.3