diff -Nurp old/sw/inc/undobj.hxx new/sw/inc/undobj.hxx --- old/sw/inc/undobj.hxx 2009-08-27 10:36:40.000000000 +0800 +++ new/sw/inc/undobj.hxx 2009-10-28 15:24:16.000000000 +0800 @@ -1845,7 +1845,7 @@ class SwUndoRedlineSort : public SwUndoR virtual void _Redo( SwUndoIter& ); public: - SwUndoRedlineSort( const SwPaM& rRange, const SwSortOptions& rOpt ); + SwUndoRedlineSort( const SwPaM& rRangeWhole, const SwPaM& rRangeSel,const SwSortOptions& rOpt ); virtual ~SwUndoRedlineSort(); virtual void Repeat( SwUndoIter& ); diff -Nurp old/sw/source/core/doc/docsort.cxx new/sw/source/core/doc/docsort.cxx --- old/sw/source/core/doc/docsort.cxx 2009-10-12 09:30:54.000000000 +0800 +++ new/sw/source/core/doc/docsort.cxx 2009-10-28 15:26:00.000000000 +0800 @@ -386,7 +386,7 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, { if( bUndo ) { - pRedlUndo = new SwUndoRedlineSort( rPaM, rOpt ); + pRedlUndo = new SwUndoRedlineSort( *pRedlPam, rPaM,rOpt ); DoUndo( FALSE ); } // erst den Bereich kopieren, dann @@ -476,6 +476,11 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, // der Kopierte Bereich ist das Geloeschte AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_DELETE, *pRedlPam ), true); + if( pRedlUndo ) + { + pRedlUndo->SetValues( rPaM ); + } + // das sortierte ist das Eingefuegte pRedlPam->GetPoint()->nNode = aSttIdx; SwCntntNode* pCNd = aSttIdx.GetNode().GetCntntNode(); diff -Nurp old/sw/source/core/undo/unredln.cxx new/sw/source/core/undo/unredln.cxx --- old/sw/source/core/undo/unredln.cxx 2008-04-11 00:09:08.000000000 +0800 +++ new/sw/source/core/undo/unredln.cxx 2009-10-28 15:27:42.000000000 +0800 @@ -228,9 +228,10 @@ BOOL SwUndoRedlineDelete::CanGrouping( c /* */ -SwUndoRedlineSort::SwUndoRedlineSort( const SwPaM& rRange, +SwUndoRedlineSort::SwUndoRedlineSort( const SwPaM& rRangeWhole, + const SwPaM& rRangeSel, const SwSortOptions& rOpt ) - : SwUndoRedline( UNDO_SORT_TXT, rRange ), + : SwUndoRedline( UNDO_SORT_TXT, rRangeWhole ), pOpt( new SwSortOptions( rOpt ) ), nSaveEndNode( nEndNode ), nOffset( 0 ), nSaveEndCntnt( nEndCntnt ) { @@ -247,6 +248,12 @@ void SwUndoRedlineSort::_Undo( SwUndoIte // im aSaveRange steht der kopierte, sprich der originale. SwDoc& rDoc = rIter.GetDoc(); + SwPosition* pStart = rIter.pAktPam->Start(); + SwPosition* pEnd = rIter.pAktPam->End(); + + SwNodeIndex aPrevIdx( pStart->nNode, -1 ); + ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); + if( 0 == ( nsRedlineMode_t::REDLINE_SHOW_DELETE & rDoc.GetRedlineMode()) ) { // die beiden Redline Objecte suchen und diese dann anzeigen lassen, @@ -254,17 +261,17 @@ void SwUndoRedlineSort::_Undo( SwUndoIte // das Geloeschte ist versteckt, also suche das INSERT // Redline Object. Dahinter steht das Geloeschte USHORT nFnd = rDoc.GetRedlinePos( - *rDoc.GetNodes()[ nSttNode + nOffset + 1 ], + *rDoc.GetNodes()[ nSttNode + 1 ], nsRedlineType_t::REDLINE_INSERT ); ASSERT( USHRT_MAX != nFnd && nFnd+1 < rDoc.GetRedlineTbl().Count(), "kein Insert Object gefunden" ); ++nFnd; - rDoc.GetRedlineTbl()[nFnd]->Show(); - SetPaM( *rIter.pAktPam ); + rDoc.GetRedlineTbl()[nFnd]->Show( 1 ); } { SwPaM aTmp( *rIter.pAktPam->GetMark() ); + aTmp.GetMark()->nContent = 0; aTmp.SetMark(); aTmp.GetPoint()->nNode = nSaveEndNode; aTmp.GetPoint()->nContent.Assign( aTmp.GetCntntNode(), nSaveEndCntnt ); @@ -272,13 +279,52 @@ void SwUndoRedlineSort::_Undo( SwUndoIte } rDoc.DelFullPara( *rIter.pAktPam ); + + SwPaM* pPam = rIter.pAktPam; + pPam->DeleteMark(); + pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode* pCNd = pPam->GetCntntNode(); + pPam->GetPoint()->nContent.Assign(pCNd, 0 ); + pPam->SetMark(); + + pPam->GetPoint()->nNode += nOffsetTemp; + pCNd = pPam->GetCntntNode(); + pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + + SetValues( *pPam ); + SetPaM( *rIter.pAktPam ); } void SwUndoRedlineSort::_Redo( SwUndoIter& rIter ) { SwPaM& rPam = *rIter.pAktPam; + + SwPaM* pPam = &rPam; + SwPosition* pStart = pPam->Start(); + SwPosition* pEnd = pPam->End(); + + SwNodeIndex aPrevIdx( pStart->nNode, -1 ); + ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); + xub_StrLen nCntStt = pStart->nContent.GetIndex(); + rIter.GetDoc().SortText( rPam, *pOpt ); + + pPam->DeleteMark(); + pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); + SwCntntNode* pCNd = pPam->GetCntntNode(); + xub_StrLen nLen = pCNd->Len(); + if( nLen > nCntStt ) + nLen = nCntStt; + pPam->GetPoint()->nContent.Assign(pCNd, nLen ); + pPam->SetMark(); + + pPam->GetPoint()->nNode += nOffsetTemp; + pCNd = pPam->GetCntntNode(); + pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); + + SetValues( rPam ); + SetPaM( rPam ); rPam.GetPoint()->nNode = nSaveEndNode; rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSaveEndCntnt );