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-16 11:31:46.000000000 +0800 @@ -1743,6 +1743,27 @@ 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 && !pCNdAfEnd ) + { + SwPosition *pTmpDelEnd = const_cast( pDelEnd ); + pTmpDelEnd->nNode--; + SwNode *pNd = &pTmpDelEnd->nNode.GetNode(); + if ( pNd->IsTxtNode() ) + { + SwTxtNode *pTxtNd = (SwTxtNode *)pNd; + ULONG nLen = pTxtNd->GetTxt().Len(); + pTmpDelEnd->nContent = nLen; + pDelEnd = pTmpDelEnd; + } + } + } SwPaM aPam( *pDelStt, *pDelEnd ); SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode(); SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode(); @@ -1852,6 +1873,33 @@ } 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 && !pCNdAfEnd ) + { + SwPosition *pTmpDelEnd = const_cast( pDelEnd ); + pTmpDelEnd->nNode--; + SwNode *pNd = &pTmpDelEnd->nNode.GetNode(); + //move the nContent to the end of the previous paragraph + if ( pNd->IsTxtNode() ) + { + SwTxtNode *pTxtNd = (SwTxtNode *)pNd; + ULONG nLen = pTxtNd->GetTxt().Len(); + pTmpDelEnd->nContent = nLen; + pDelEnd = pTmpDelEnd; + } + } + } SwPaM aPam( *pDelStt, *pDelEnd ); SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();