diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2012-06-22 09:01:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-11 20:43:29 +0100 |
commit | a0bd65d2e0e6813f47221ae52092cdb4e748c0e6 (patch) | |
tree | 3155481bcd06c45db770f1eb0397ab7169635b8b /sw/source/core/edit/edtab.cxx | |
parent | 97f1db8cdb645ab906b469452cc2dd82f7e06913 (diff) |
Resolves: #i119954# fix nest tables to text conversion crash
- assure that conversion of nested tables are performed correctly.
Found by: Yang Ji <yanji.yj at gmail dot com>
Patch by: kang jian <jane73_kang at hotmail dot com>
Review by: Oliver <orw at apache dot org>
(cherry picked from commit 48538700cdafaa4becfe74a1d3d93179aed9d764)
Change-Id: Iaefbf6f75d526ef8c0c4302d8b39096becc183e8
Diffstat (limited to 'sw/source/core/edit/edtab.cxx')
-rw-r--r-- | sw/source/core/edit/edtab.cxx | 42 |
1 files changed, 41 insertions, 1 deletions
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(); |