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-13 12:05:08.000000000 +0800 @@ -1840,6 +1840,8 @@ class SwUndoRedlineSort : public SwUndoR SwSortOptions* pOpt; ULONG nSaveEndNode, nOffset; xub_StrLen nSaveEndCntnt; + xub_StrLen nSttCharIndex; + xub_StrLen nEndCharIndex; virtual void _Undo( SwUndoIter& ); virtual void _Redo( SwUndoIter& ); @@ -1851,6 +1853,7 @@ public: void SetSaveRange( const SwPaM& rRange ); void SetOffset( const SwNodeIndex& rIdx ); + void SetCharIndex( const SwPaM& rRange ); }; class SwUndoAcceptRedline : public SwUndoRedline 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-12 15:30:30.000000000 +0800 @@ -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-12 15:39:32.000000000 +0800 @@ -234,6 +234,7 @@ SwUndoRedlineSort::SwUndoRedlineSort( co pOpt( new SwSortOptions( rOpt ) ), nSaveEndNode( nEndNode ), nOffset( 0 ), nSaveEndCntnt( nEndCntnt ) { + SetCharIndex( rRange ); } SwUndoRedlineSort::~SwUndoRedlineSort() @@ -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, nSttCharIndex ); + pPam->SetMark(); + + pPam->GetPoint()->nNode += nOffsetTemp; + pCNd = pPam->GetCntntNode(); + pPam->GetPoint()->nContent.Assign( pCNd, nEndCharIndex ); + + 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 ); @@ -301,6 +347,14 @@ void SwUndoRedlineSort::SetOffset( const nOffset = rIdx.GetIndex() - nSttNode; } +void SwUndoRedlineSort::SetCharIndex( const SwPaM& rRange ) +{ + const SwPosition* pPos = rRange.Start(); + nSttCharIndex = pPos->nContent.GetIndex(); + pPos = rRange.End(); + nEndCharIndex = pPos->nContent.GetIndex(); +} + /* */ SwUndoAcceptRedline::SwUndoAcceptRedline( const SwPaM& rRange )