You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2012/06/22 12:01:56 UTC

svn commit: r1352828 - /incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx

Author: orw
Date: Fri Jun 22 10:01:55 2012
New Revision: 1352828

URL: http://svn.apache.org/viewvc?rev=1352828&view=rev
Log:
#119954# - method <SwEditShell::TableToText(..)>
           - 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>

Modified:
    incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx

Modified: incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx?rev=1352828&r1=1352827&r2=1352828&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/edit/edtab.cxx Fri Jun 22 10:01:55 2012
@@ -61,6 +61,42 @@ using namespace ::com::sun::star::uno;
 
 extern void ClearFEShellTabCols();
 
+//Added for bug 119954: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( sal_uInt16 n = 0; n < rTableLines.Count(); ++n )
+	{
+		SwTableLine* pTableLine = rTableLines[ n ];
+		for( sal_uInt16 i = 0; i < pTableLine->GetTabBoxes().Count(); ++i )
+		{
+			SwTableBox* pTableBox = pTableLine->GetTabBoxes()[ i ];
+			if ( !pTableBox->GetTabLines().Count() )
+			{			
+				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 119954
 const SwTable& SwEditShell::InsertTable( const SwInsertTableOptions& rInsTblOpts,
                                          sal_uInt16 nRows, sal_uInt16 nCols,
                                          sal_Int16 eAdj,
@@ -138,7 +174,11 @@ sal_Bool SwEditShell::TableToText( sal_U
 	pCrsr->SetMark();
 	pCrsr->DeleteMark();
 
-	bRet = GetDoc()->TableToText( pTblNd, cCh );
+	//Modified for bug 119954:Application crashed if undo/redo covert nest table to text
+	StartUndo();//UNDO_START
+	bRet = ConvertTableToText( pTblNd, cCh ); 
+	EndUndo();//UNDO_END
+	//End  for bug 119954
 	pCrsr->GetPoint()->nNode = aTabIdx;
 
 	SwCntntNode* pCNd = pCrsr->GetCntntNode();