diff -uNr sw.old/source/core/doc/docredln.cxx sw.new/source/core/doc/docredln.cxx --- sw.old/source/core/doc/docredln.cxx 2007-07-24 09:48:56.000000000 +0800 +++ sw.new/source/core/doc/docredln.cxx 2007-11-28 17:10:40.000000000 +0800 @@ -1620,6 +1620,18 @@ return 0; } +SwStartNode* lcl_StartExceptSection( SwNode* pNd ) +{ + if ( pNd ) + { + SwStartNode* pTmpNd = pNd->StartOfSectionNode(); + while( pTmpNd->IsSectionNode() ) + pTmpNd = pTmpNd->StartOfSectionNode(); + return pTmpNd; + } + return 0; +} + typedef BOOL (*Fn_AcceptReject)( const SwRootFrm& rLayout, SwRedlineTbl& rArr, USHORT& rPos,//modify by lijian 070719 BOOL bCallDelete, const SwPosition* pSttRng, @@ -1743,6 +1755,26 @@ if( pDelStt && pDelEnd ) { + //#i73682# see comments below + if ( pDelEnd->nContent == 0 && !pDelEnd->nNode.GetNode().IsTxtNode() ) + { + SwNodeIndex aSttIdx = pDelStt->nNode, aEndIdx = pDelEnd->nNode; + SwNodes& rNds = aSttIdx.GetNode().GetNodes(); + SwCntntNode *pCNdBfStt = rNds.GoPrevious( &aSttIdx ), + *pCNdAfEnd = rNds.GoNext( &aEndIdx ); + if( !(pCNdBfStt && lcl_StartExceptSection(pCNdBfStt) == lcl_StartExceptSection(&pDelStt->nNode.GetNode()) || + pCNdAfEnd && lcl_StartExceptSection(pCNdAfEnd) == lcl_StartExceptSection(&pDelEnd->nNode.GetNode())) ) + { + SwPosition aTmpDelEnd = *pDelEnd; + aTmpDelEnd.nNode--; + SwCntntNode *pCNd = aTmpDelEnd.nNode.GetNode().GetCntntNode(); + if ( pCNd ) + { + aTmpDelEnd.nContent.Assign( pCNd, pCNd->Len() ); + pDelEnd = &aTmpDelEnd; + } + } + } SwPaM aPam( *pDelStt, *pDelEnd ); SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode(); SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode(); @@ -1852,6 +1884,31 @@ } if( pDelStt && pDelEnd ) { + //#i73682# We should see if there is only one paragraph in the document, + //and this paragraph will be deleted. If so and the pDelEnd points to non-txtNd, + //we must keep that there will be one paragraph at least. + if ( pDelEnd->nContent == 0 && !pDelEnd->nNode.GetNode().IsTxtNode() ) + { + SwNodeIndex aSttIdx = pDelStt->nNode, aEndIdx = pDelEnd->nNode; + SwNodes& rNds = aSttIdx.GetNode().GetNodes(); + //to see if there are paragraphs before or after this deletion-redline + //paragraph + SwCntntNode *pCNdBfStt = rNds.GoPrevious( &aSttIdx ), + *pCNdAfEnd = rNds.GoNext( &aEndIdx ); + //if only this paragraph and has to be deleted + if( !(pCNdBfStt && lcl_StartExceptSection(pCNdBfStt) == lcl_StartExceptSection(&pDelStt->nNode.GetNode()) || + pCNdAfEnd && lcl_StartExceptSection(pCNdAfEnd) == lcl_StartExceptSection(&pDelEnd->nNode.GetNode())) ) + { + SwPosition aTmpDelEnd = *pDelEnd; + aTmpDelEnd.nNode--; + SwCntntNode *pCNd = aTmpDelEnd.nNode.GetNode().GetCntntNode(); + if ( pCNd ) + { + aTmpDelEnd.nContent.Assign( pCNd, pCNd->Len() ); + pDelEnd = &aTmpDelEnd; + } + } + } SwPaM aPam( *pDelStt, *pDelEnd ); SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();