summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docredln.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/doc/docredln.cxx')
-rw-r--r--sw/source/core/doc/docredln.cxx1906
1 files changed, 0 insertions, 1906 deletions
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index ae671ba0e066..03e937283607 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -158,90 +158,6 @@ TYPEINIT1(SwRedlineHint, SfxHint);
SV_IMPL_OP_PTRARR_SORT( _SwRedlineTbl, SwRedlinePtr )
-RedlineMode_t SwDoc::GetRedlineMode() const
-{
- return eRedlineMode;
-}
-
-void SwDoc::SetRedlineMode( RedlineMode_t eMode )
-{
- if( eRedlineMode != eMode )
- {
- if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode)
- || 0 == (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode) )
- {
- bool bSaveInXMLImportFlag = IsInXMLImport();
- SetInXMLImport( false );
- // and then hide/display everything
- void (SwRedline::*pFnc)( sal_uInt16 ) = 0;
-
- switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eMode )
- {
- case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE :
- pFnc = &SwRedline::Show;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_INSERT:
- pFnc = &SwRedline::Hide;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_DELETE:
- pFnc = &SwRedline::ShowOriginal;
- break;
-
- default:
- pFnc = &SwRedline::Hide;
- eMode = (RedlineMode_t)(eMode | nsRedlineMode_t::REDLINE_SHOW_INSERT);
- break;
- }
-
- _CHECK_REDLINE( this )
-
- if( pFnc )
- for( sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop )
- for( sal_uInt16 i = 0; i < pRedlineTbl->Count(); ++i )
- ((*pRedlineTbl)[ i ]->*pFnc)( nLoop );
- _CHECK_REDLINE( this )
- SetInXMLImport( bSaveInXMLImportFlag );
- }
- eRedlineMode = eMode;
- SetModified();
- }
-}
-
-bool SwDoc::IsRedlineOn() const
-{
- return IDocumentRedlineAccess::IsRedlineOn(eRedlineMode);
-}
-
-bool SwDoc::IsIgnoreRedline() const
-{
- return (nsRedlineMode_t::REDLINE_IGNORE & eRedlineMode);
-}
-
-void SwDoc::SetRedlineMode_intern(RedlineMode_t eMode)
-{
- eRedlineMode = eMode;
-}
-
-const SwRedlineTbl& SwDoc::GetRedlineTbl() const
-{
- return *pRedlineTbl;
-}
-
-bool SwDoc::IsRedlineMove() const
-{
- return mbIsRedlineMove;
-}
-
-void SwDoc::SetRedlineMove(bool bFlag)
-{
- mbIsRedlineMove = bFlag;
-}
-
-const uno::Sequence <sal_Int8>& SwDoc::GetRedlinePassword() const
-{
- return aRedlinePasswd;
-}
-
inline bool IsPrevPos( const SwPosition rPos1, const SwPosition rPos2 )
{
const SwCntntNode* pCNd;
@@ -305,1281 +221,6 @@ Behaviour of Delete-Redline:
the Delete
*/
-bool SwDoc::AppendRedline( SwRedline* pNewRedl, bool bCallDelete )
-{
- bool bError = true;
- _CHECK_REDLINE( this )
-
- if( IsRedlineOn() && !IsShowOriginal( eRedlineMode ) &&
- pNewRedl->GetAuthorString().Len() )
- {
- pNewRedl->InvalidateRange();
-
- if( mbIsAutoFmtRedline )
- {
- pNewRedl->SetAutoFmtFlag();
- if( pAutoFmtRedlnComment && pAutoFmtRedlnComment->Len() )
- {
- pNewRedl->SetComment( *pAutoFmtRedlnComment );
- pNewRedl->SetSeqNo( nAutoFmtRedlnCommentNo );
- }
- }
-
- SwPosition* pStt = pNewRedl->Start(),
- * pEnd = pStt == pNewRedl->GetPoint() ? pNewRedl->GetMark()
- : pNewRedl->GetPoint();
- {
- SwTxtNode* pTxtNode = pStt->nNode.GetNode().GetTxtNode();
- if( pTxtNode == NULL )
- {
- if( pStt->nContent > 0 )
- {
- OSL_ENSURE( false, "Redline start: non-text-node with content" );
- pStt->nContent = 0;
- }
- }
- else
- {
- if( pStt->nContent > pTxtNode->Len() )
- {
- OSL_ENSURE( false, "Redline start: index behind text" );
- pStt->nContent = pTxtNode->Len();
- }
- }
- pTxtNode = pEnd->nNode.GetNode().GetTxtNode();
- if( pTxtNode == NULL )
- {
- if( pEnd->nContent > 0 )
- {
- OSL_ENSURE( false, "Redline end: non-text-node with content" );
- pEnd->nContent = 0;
- }
- }
- else
- {
- if( pEnd->nContent > pTxtNode->Len() )
- {
- OSL_ENSURE( false, "Redline end: index behind text" );
- pEnd->nContent = pTxtNode->Len();
- }
- }
- }
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- { // Do not insert empty redlines
- delete pNewRedl;
- return sal_False;
- }
- sal_Bool bCompress = sal_False;
- sal_uInt16 n = 0;
- // look up the first Redline for the starting position
- if( !GetRedline( *pStt, &n ) && n )
- --n;
- bool bDec = false;
-
- for( ; pNewRedl && n < pRedlineTbl->Count(); bDec ? n : ++n )
- {
- bDec = false;
-
- SwRedline* pRedl = (*pRedlineTbl)[ n ];
- SwPosition* pRStt = pRedl->Start(),
- * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
- : pRedl->GetPoint();
-
- // #i8518# remove empty redlines while we're at it
- if( ( *pRStt == *pREnd ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy(n);
- continue;
- }
-
- SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
-
- switch( pNewRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- if( pRedl->IsOwnRedline( *pNewRedl ) )
- {
- bool bDelete = false;
-
- // Merge if applicable?
- if( (( POS_BEHIND == eCmpPos &&
- IsPrevPos( *pREnd, *pStt ) ) ||
- ( POS_COLLIDE_START == eCmpPos ) ||
- ( POS_OVERLAP_BEHIND == eCmpPos ) ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- ( n+1 >= pRedlineTbl->Count() ||
- ( *(*pRedlineTbl)[ n+1 ]->Start() >= *pEnd &&
- *(*pRedlineTbl)[ n+1 ]->Start() != *pREnd ) ) )
- {
- pRedl->SetEnd( *pEnd, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
-
- bError = false;
- bDelete = true;
- }
- else if( (( POS_BEFORE == eCmpPos &&
- IsPrevPos( *pEnd, *pRStt ) ) ||
- ( POS_COLLIDE_END == eCmpPos ) ||
- ( POS_OVERLAP_BEFORE == eCmpPos ) ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- ( !n ||
- *(*pRedlineTbl)[ n-1 ]->End() != *pRStt ))
- {
- pRedl->SetStart( *pStt, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
-
- bError = false;
- bDelete = true;
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // own insert-over-insert redlines:
- // just scrap the inside ones
- pRedlineTbl->Remove( n );
- bDec = true;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- {
- *pStt = *pREnd;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- bDelete = true;
- }
- else if( POS_OVERLAP_BEFORE == eCmpPos )
- {
- *pEnd = *pRStt;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- bDelete = true;
- }
- else if( POS_INSIDE == eCmpPos || POS_EQUAL == eCmpPos)
- bDelete = true;
-
- if( bDelete )
- {
- delete pNewRedl, pNewRedl = 0;
- bCompress = sal_True;
- }
- }
- else if( POS_INSIDE == eCmpPos )
- {
- // split up
- if( *pEnd != *pREnd )
- {
- SwRedline* pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- pRedlineTbl->Insert( pCpy );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
-
- // split up the new redline, since it covers the
- // existing redline. Insert the first part, and
- // progress with the remainder as usual
- SwRedline* pSplit = new SwRedline( *pNewRedl );
- pSplit->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd );
- pRedlineTbl->Insert( pSplit );
- if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- else if ( POS_OVERLAP_BEHIND == eCmpPos )
- {
- // handle overlapping redlines in broken documents
- pNewRedl->SetStart( *pREnd );
- }
- else if ( POS_OVERLAP_BEFORE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
- *pEnd = *pRStt;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- break;
- case nsRedlineType_t::REDLINE_DELETE:
- if( POS_INSIDE == eCmpPos )
- {
- // split up
- if( *pEnd != *pREnd )
- {
- SwRedline* pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- pRedlineTbl->Insert( pCpy );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
-
- // split up the new redline, since it covers the
- // existing redline. Insert the first part, and
- // progress with the remainder as usual
- SwRedline* pSplit = new SwRedline( *pNewRedl );
- pSplit->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd );
- pRedlineTbl->Insert( pSplit );
- if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- else if ( POS_EQUAL == eCmpPos )
- {
- // handle identical redlines in broken documents
- // delete old (delete) redline
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if ( POS_OVERLAP_BEHIND == eCmpPos )
- { // Another workaround for broken redlines
- pNewRedl->SetStart( *pREnd );
- }
- break;
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->SetEnd( *pStt, pREnd );
- if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
-
- case POS_EQUAL:
- case POS_OUTSIDE:
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- break;
-
- case POS_INSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
- pRedlineTbl->DeleteAndDestroy( n );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_DELETE:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_DELETE:
- switch( eCmpPos )
- {
- case POS_OUTSIDE:
- {
- // Overlaps the current one completely,
- // split the new one
- if( *pEnd != *pREnd )
- {
- SwRedline* pNew = new SwRedline( *pNewRedl );
- pNew->SetStart( *pREnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- }
- break;
-
- case POS_INSIDE:
- case POS_EQUAL:
- delete pNewRedl, pNewRedl = 0;
- bCompress = sal_True;
- break;
-
- case POS_OVERLAP_BEFORE:
- case POS_OVERLAP_BEHIND:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
-// 1 == pRedl->GetStackCount() &&
- pRedl->CanCombine( *pNewRedl ))
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pREnd, pStt );
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_COLLIDE_START:
- case POS_COLLIDE_END:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) )
- {
- if( IsHideChanges( eRedlineMode ))
- {
- // Before we can merge, we make it visible!
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Show();
- pRedlineTbl->Remove( pRedlineTbl->GetPos(pNewRedl ));
- pRStt = pRedl->Start();
- pREnd = pRedl->End();
- }
-
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_COLLIDE_START == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
-
- // delete current (below), and restart process with
- // previous
- sal_uInt16 nToBeDeleted = n;
- bDec = true;
-
- if( *(pNewRedl->Start()) <= *pREnd )
- {
- // Whoooah, we just extended the new 'redline'
- // beyond previous redlines, so better start
- // again. Of course this is not supposed to
- // happen, and in an ideal world it doesn't,
- // but unfortunately this code is buggy and
- // totally rotten so it does happen and we
- // better fix it.
- n = 0;
- bDec = true;
- }
-
- pRedlineTbl->DeleteAndDestroy( nToBeDeleted );
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_INSERT:
- {
- // b62341295: Do not throw away redlines
- // even if they are not allowed to be combined
- RedlineMode_t eOld = eRedlineMode;
- if( !( eOld & nsRedlineMode_t::REDLINE_DONTCOMBINE_REDLINES ) &&
- pRedl->IsOwnRedline( *pNewRedl ) )
- {
-
- // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
- // The ShowMode needs to be retained!
- eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
- switch( eCmpPos )
- {
- case POS_EQUAL:
- bCompress = sal_True;
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- // no break!
-
- case POS_INSIDE:
- if( bCallDelete )
- {
- eRedlineMode = (RedlineMode_t)(eRedlineMode | nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES);
-
- // DeleteAndJoin does not yield the
- // desired result if there is no paragraph to
- // join with, i.e. at the end of the document.
- // For this case, we completely delete the
- // paragraphs (if, of course, we also start on
- // a paragraph boundary).
- if( (pStt->nContent == 0) &&
- pEnd->nNode.GetNode().IsEndNode() )
- {
- pEnd->nNode--;
- pEnd->nContent.Assign(
- pEnd->nNode.GetNode().GetTxtNode(), 0);
- DelFullPara( *pNewRedl );
- }
- else
- DeleteAndJoin( *pNewRedl );
-
- bCompress = sal_True;
- }
- delete pNewRedl, pNewRedl = 0;
- break;
-
- case POS_OUTSIDE:
- {
- pRedlineTbl->Remove( n );
- bDec = true;
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- if( bCallDelete )
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( *pRedl );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- }
- delete pRedl;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- {
- SwPaM aPam( *pRStt, *pEnd );
-
- if( *pEnd == *pREnd )
- pRedlineTbl->DeleteAndDestroy( n );
- else
- {
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
-
- if( bCallDelete )
- {
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( aPam );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- n = 0; // re-initialize
- }
- bDec = true;
- }
- break;
-
- case POS_OVERLAP_BEHIND:
- {
- SwPaM aPam( *pStt, *pREnd );
-
- if( *pStt == *pRStt )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
-
- if( bCallDelete )
- {
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( aPam );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- n = 0; // re-initialize
- bDec = true;
- }
- }
- break;
- default:
- break;
- }
-
- eRedlineMode = eOld;
- }
- else
- {
- // it may be necessary to split the existing redline in
- // two. In this case, pRedl will be changed to cover
- // only part of it's former range, and pNew will cover
- // the remainder.
- SwRedline* pNew = 0;
-
- switch( eCmpPos )
- {
- case POS_EQUAL:
- {
- pRedl->PushData( *pNewRedl );
- delete pNewRedl, pNewRedl = 0;
- if( IsHideChanges( eRedlineMode ))
- pRedl->Hide();
- bCompress = sal_True;
- }
- break;
-
- case POS_INSIDE:
- {
- if( *pRStt == *pStt )
- {
- // #i97421#
- // redline w/out extent loops
- if (*pStt != *pEnd)
- {
- pNewRedl->PushData( *pRedl, sal_False );
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- }
- }
- else
- {
- pNewRedl->PushData( *pRedl, sal_False );
- if( *pREnd != *pEnd )
- {
- pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
- }
- }
- break;
-
- case POS_OUTSIDE:
- {
- pRedl->PushData( *pNewRedl );
- if( *pEnd == *pREnd )
- pNewRedl->SetEnd( *pRStt, pEnd );
- else
- {
- pNew = new SwRedline( *pNewRedl );
- pNew->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd, pStt );
- }
- bCompress = sal_True;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- {
- if( *pEnd == *pREnd )
- {
- pRedl->PushData( *pNewRedl );
- pNewRedl->SetEnd( *pRStt, pEnd );
- if( IsHideChanges( eRedlineMode ))
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Hide();
- pRedlineTbl->Remove(
- pRedlineTbl->GetPos(pNewRedl ));
- }
- }
- else
- {
- pNew = new SwRedline( *pRedl );
- pNew->PushData( *pNewRedl );
- pNew->SetEnd( *pEnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- pRedl->SetStart( *pNew->End(), pRStt ) ;
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- bDec = true;
- }
- }
- break;
-
- case POS_OVERLAP_BEHIND:
- {
- if( *pStt == *pRStt )
- {
- pRedl->PushData( *pNewRedl );
- pNewRedl->SetStart( *pREnd, pStt );
- if( IsHideChanges( eRedlineMode ))
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Hide();
- pRedlineTbl->Remove(
- pRedlineTbl->GetPos(pNewRedl ));
- }
- }
- else
- {
- pNew = new SwRedline( *pRedl );
- pNew->PushData( *pNewRedl );
- pNew->SetStart( *pStt );
- pNewRedl->SetStart( *pREnd, pStt );
- pRedl->SetEnd( *pNew->Start(), pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
- }
- }
- break;
- default:
- break;
- }
-
- // insert the pNew part (if it exists)
- if( pNew )
- {
- pRedlineTbl->Insert( pNew );
-
- // pNew must be deleted if Insert() wasn't
- // successful. But that can't happen, since pNew is
- // part of the original pRedl redline.
- // OSL_ENSURE( bRet, "Can't insert existing redline?" );
-
- // restart (now with pRedl being split up)
- n = 0;
- bDec = true;
- }
- }
- }
- break;
-
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->SetEnd( *pStt, pREnd );
- break;
-
- case POS_EQUAL:
- case POS_OUTSIDE:
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- break;
-
- case POS_INSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- pRedlineTbl->DeleteAndDestroy( n );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- case nsRedlineType_t::REDLINE_DELETE:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_OVERLAP_BEHIND:
- pNewRedl->SetStart( *pREnd, pStt );
- break;
-
- case POS_EQUAL:
- case POS_INSIDE:
- delete pNewRedl, pNewRedl = 0;
- break;
-
- case POS_OUTSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pNewRedl );
- pNew->SetStart( *pREnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
- default:
- break;
- }
- break;
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OUTSIDE:
- case POS_EQUAL:
- {
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
-
- case POS_INSIDE:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ))
- // own one can be ignored completely
- delete pNewRedl, pNewRedl = 0;
-
- else if( *pREnd == *pEnd )
- // or else only shorten the current one
- pRedl->SetEnd( *pStt, pREnd );
- else if( *pRStt == *pStt )
- {
- // or else only shorten the current one
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- }
- else
- {
- // If it lies completely within the current one
- // we need to split it
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- case POS_OVERLAP_BEHIND:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ))
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = 0;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pREnd, pStt );
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_COLLIDE_END:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) && n &&
- *(*pRedlineTbl)[ n-1 ]->End() < *pStt )
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
- case POS_COLLIDE_START:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- n+1 < pRedlineTbl->Count() &&
- *(*pRedlineTbl)[ n+1 ]->Start() < *pEnd )
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- pNewRedl->SetStart( *pRStt, pStt );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
-
- case nsRedlineType_t::REDLINE_FMTCOLL:
- // How should we behave here?
- // insert as is
- break;
- default:
- break;
- }
- }
-
- if( pNewRedl )
- {
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- { // Do not insert empty redlines
- delete pNewRedl;
- pNewRedl = 0;
- }
- else
- pRedlineTbl->Insert( pNewRedl );
- }
-
- if( bCompress )
- CompressRedlines();
- }
- else
- {
- if( bCallDelete && nsRedlineType_t::REDLINE_DELETE == pNewRedl->GetType() )
- {
- RedlineMode_t eOld = eRedlineMode;
- // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
- // The ShowMode needs to be retained!
- eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
- DeleteAndJoin( *pNewRedl );
- eRedlineMode = eOld;
- }
- delete pNewRedl, pNewRedl = 0;
- }
- _CHECK_REDLINE( this )
-
- return ( 0 != pNewRedl ) || !bError;
-}
-
-void SwDoc::CompressRedlines()
-{
- _CHECK_REDLINE( this )
-
- void (SwRedline::*pFnc)(sal_uInt16) = 0;
- switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode )
- {
- case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE:
- pFnc = &SwRedline::Show;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_INSERT:
- pFnc = &SwRedline::Hide;
- break;
- }
-
- // Try to merge identical ones
- for( sal_uInt16 n = 1; n < pRedlineTbl->Count(); ++n )
- {
- SwRedline* pPrev = (*pRedlineTbl)[ n-1 ],
- * pCur = (*pRedlineTbl)[ n ];
- const SwPosition* pPrevStt = pPrev->Start(),
- * pPrevEnd = pPrevStt == pPrev->GetPoint()
- ? pPrev->GetMark() : pPrev->GetPoint();
- const SwPosition* pCurStt = pCur->Start(),
- * pCurEnd = pCurStt == pCur->GetPoint()
- ? pCur->GetMark() : pCur->GetPoint();
- if( *pPrevEnd == *pCurStt && pPrev->CanCombine( *pCur ) &&
- pPrevStt->nNode.GetNode().StartOfSectionNode() ==
- pCurEnd->nNode.GetNode().StartOfSectionNode() &&
- !pCurEnd->nNode.GetNode().StartOfSectionNode()->IsTableNode() )
- {
- // we then can merge them
- pPrev->Show();
- pCur->Show();
-
- pPrev->SetEnd( *pCur->End() );
- pRedlineTbl->DeleteAndDestroy( n );
- --n;
- if( pFnc )
- (pPrev->*pFnc)(0);
- }
- }
- _CHECK_REDLINE( this )
-}
-
-bool SwDoc::SplitRedline( const SwPaM& rRange )
-{
- sal_Bool bChg = sal_False;
- sal_uInt16 n = 0;
- const SwPosition* pStt = rRange.Start(),
- * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
- : rRange.GetPoint();
- GetRedline( *pStt, &n );
- for( ; n < pRedlineTbl->Count() ; ++n )
- {
- SwRedline* pTmp = (*pRedlineTbl)[ n ];
- SwPosition* pTStt = pTmp->Start(),
- * pTEnd = pTStt == pTmp->GetPoint() ? pTmp->GetMark()
- : pTmp->GetPoint();
- if( *pTStt <= *pStt && *pStt <= *pTEnd &&
- *pTStt <= *pEnd && *pEnd <= *pTEnd )
- {
- bChg = sal_True;
- int nn = 0;
- if( *pStt == *pTStt )
- nn += 1;
- if( *pEnd == *pTEnd )
- nn += 2;
-
- SwRedline* pNew = 0;
- switch( nn )
- {
- case 0:
- pNew = new SwRedline( *pTmp );
- pTmp->SetEnd( *pStt, pTEnd );
- pNew->SetStart( *pEnd );
- break;
-
- case 1:
- *pTStt = *pEnd;
- break;
-
- case 2:
- *pTEnd = *pStt;
- break;
-
- case 3:
- pTmp->InvalidateRange();
- pRedlineTbl->DeleteAndDestroy( n-- );
- pTmp = 0;
- break;
- }
- if( pTmp && !pTmp->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pTmp, n );
- }
- if( pNew )
- pRedlineTbl->Insert( pNew, n );
- }
- else if( *pEnd < *pTStt )
- break;
- }
- return bChg;
-}
-
-bool SwDoc::DeleteRedline( const SwPaM& rRange, bool bSaveInUndo,
- sal_uInt16 nDelType )
-{
- if( nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES & eRedlineMode ||
- !rRange.HasMark() || *rRange.GetMark() == *rRange.GetPoint() )
- return sal_False;
-
- sal_Bool bChg = sal_False;
-
- if (bSaveInUndo && GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndoRedline* pUndo = new SwUndoRedline( UNDO_REDLINE, rRange );
- if( pUndo->GetRedlSaveCount() )
- {
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- else
- delete pUndo;
- }
-
- const SwPosition* pStt = rRange.Start(),
- * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
- : rRange.GetPoint();
- sal_uInt16 n = 0;
- GetRedline( *pStt, &n );
- for( ; n < pRedlineTbl->Count() ; ++n )
- {
- SwRedline* pRedl = (*pRedlineTbl)[ n ];
- if( USHRT_MAX != nDelType && nDelType != pRedl->GetType() )
- continue;
-
- SwPosition* pRStt = pRedl->Start(),
- * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
- : pRedl->GetPoint();
- switch( ComparePosition( *pStt, *pEnd, *pRStt, *pREnd ) )
- {
- case POS_EQUAL:
- case POS_OUTSIDE:
- pRedl->InvalidateRange();
- pRedlineTbl->DeleteAndDestroy( n-- );
- bChg = sal_True;
- break;
-
- case POS_OVERLAP_BEFORE:
- pRedl->InvalidateRange();
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->InvalidateRange();
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- break;
-
- case POS_INSIDE:
- {
- // this one needs to be splitted
- pRedl->InvalidateRange();
- if( *pRStt == *pStt )
- {
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- else
- {
- SwRedline* pCpy;
- if( *pREnd != *pEnd )
- {
- pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- }
- else
- pCpy = 0;
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( pRedlineTbl->GetPos( pRedl ));
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- if( pCpy )
- pRedlineTbl->Insert( pCpy );
- }
- }
- break;
-
- case POS_COLLIDE_END:
- case POS_BEFORE:
- n = pRedlineTbl->Count();
- break;
- default:
- break;
- }
- }
-
- if( bChg )
- SetModified();
-
- return bChg;
-}
-
-bool SwDoc::DeleteRedline( const SwStartNode& rNode, bool bSaveInUndo,
- sal_uInt16 nDelType )
-{
- SwPaM aTemp(*rNode.EndOfSectionNode(), rNode);
- return DeleteRedline(aTemp, bSaveInUndo, nDelType);
-}
-
-sal_uInt16 SwDoc::GetRedlinePos( const SwNode& rNd, sal_uInt16 nType ) const
-{
- const sal_uLong nNdIdx = rNd.GetIndex();
- for( sal_uInt16 n = 0; n < pRedlineTbl->Count() ; ++n )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ n ];
- sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
- nMk = pTmp->GetMark()->nNode.GetIndex();
- if( nPt < nMk ) { long nTmp = nMk; nMk = nPt; nPt = nTmp; }
-
- if( ( USHRT_MAX == nType || nType == pTmp->GetType()) &&
- nMk <= nNdIdx && nNdIdx <= nPt )
- return n;
-
- if( nMk > nNdIdx )
- break;
- }
- return USHRT_MAX;
-}
-
-const SwRedline* SwDoc::GetRedline( const SwPosition& rPos,
- sal_uInt16* pFndPos ) const
-{
- sal_uInt16 nO = pRedlineTbl->Count(), nM, nU = 0;
- if( nO > 0 )
- {
- nO--;
- while( nU <= nO )
- {
- nM = nU + ( nO - nU ) / 2;
- const SwRedline* pRedl = (*pRedlineTbl)[ nM ];
- const SwPosition* pStt = pRedl->Start();
- const SwPosition* pEnd = pStt == pRedl->GetPoint()
- ? pRedl->GetMark()
- : pRedl->GetPoint();
- if( pEnd == pStt
- ? *pStt == rPos
- : ( *pStt <= rPos && rPos < *pEnd ) )
- {
- while( nM && rPos == *(*pRedlineTbl)[ nM - 1 ]->End() &&
- rPos == *(*pRedlineTbl)[ nM - 1 ]->Start() )
- {
- --nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- // if there are format and insert changes in the same position
- // show insert change first.
- // since the redlines are sorted by position, only check the redline
- // before and after the current redline
- if( nsRedlineType_t::REDLINE_FORMAT == pRedl->GetType() )
- {
- if( nM && rPos >= *(*pRedlineTbl)[ nM - 1 ]->Start() &&
- rPos <= *(*pRedlineTbl)[ nM - 1 ]->End() &&
- ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM - 1 ]->GetType() ) )
- {
- --nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- else if( ( nM + 1 ) <= nO && rPos >= *(*pRedlineTbl)[ nM + 1 ]->Start() &&
- rPos <= *(*pRedlineTbl)[ nM + 1 ]->End() &&
- ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM + 1 ]->GetType() ) )
- {
- ++nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- }
-
- if( pFndPos )
- *pFndPos = nM;
- return pRedl;
- }
- else if( *pEnd <= rPos )
- nU = nM + 1;
- else if( nM == 0 )
- {
- if( pFndPos )
- *pFndPos = nU;
- return 0;
- }
- else
- nO = nM - 1;
- }
- }
- if( pFndPos )
- *pFndPos = nU;
- return 0;
-}
-
typedef sal_Bool (*Fn_AcceptReject)( SwRedlineTbl& rArr, sal_uInt16& rPos,
sal_Bool bCallDelete,
const SwPosition* pSttRng,
@@ -2060,542 +701,6 @@ void lcl_AdjustRedlineRange( SwPaM& rPam )
}
-bool SwDoc::AcceptRedline( sal_uInt16 nPos, bool bCallDelete )
-{
- sal_Bool bRet = sal_False;
-
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwRewriter aRewriter;
-
- aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr());
- GetIDocumentUndoRedo().StartUndo(UNDO_ACCEPT_REDLINE, &aRewriter);
- }
-
- int nLoopCnt = 2;
- sal_uInt16 nSeqNo = pTmp->GetSeqNo();
-
- do {
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndo *const pUndo( new SwUndoAcceptRedline(*pTmp) );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- bRet |= lcl_AcceptRedline( *pRedlineTbl, nPos, bCallDelete );
-
- if( nSeqNo )
- {
- if( USHRT_MAX == nPos )
- nPos = 0;
- sal_uInt16 nFndPos = 2 == nLoopCnt
- ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
- : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
- if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
- USHRT_MAX != ( nFndPos =
- pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
- pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
- else
- nLoopCnt = 0;
- }
- else
- nLoopCnt = 0;
-
- } while( nLoopCnt );
-
- if( bRet )
- {
- CompressRedlines();
- SetModified();
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
- }
- }
- return bRet;
-}
-
-bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete )
-{
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- // The Selection is only in the ContentSection. If there are Redlines
- // to Non-ContentNodes before or after that, then the Selections
- // expand to them.
- SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
- lcl_AdjustRedlineRange( aPam );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_ACCEPT_REDLINE, NULL );
- GetIDocumentUndoRedo().AppendUndo( new SwUndoAcceptRedline( aPam ));
- }
-
- int nRet = lcl_AcceptRejectRedl( lcl_AcceptRedline, *pRedlineTbl,
- bCallDelete, aPam );
- if( nRet > 0 )
- {
- CompressRedlines();
- SetModified();
- }
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- String aTmpStr;
-
- {
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, String::CreateFromInt32(nRet));
- aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
- }
-
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, aTmpStr);
-
- GetIDocumentUndoRedo().EndUndo( UNDO_ACCEPT_REDLINE, &aRewriter );
- }
- return nRet != 0;
-}
-
-bool SwDoc::RejectRedline( sal_uInt16 nPos, bool bCallDelete )
-{
- sal_Bool bRet = sal_False;
-
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwRewriter aRewriter;
-
- aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr());
- GetIDocumentUndoRedo().StartUndo(UNDO_REJECT_REDLINE, &aRewriter);
- }
-
- int nLoopCnt = 2;
- sal_uInt16 nSeqNo = pTmp->GetSeqNo();
-
- do {
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndo *const pUndo( new SwUndoRejectRedline( *pTmp ) );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- bRet |= lcl_RejectRedline( *pRedlineTbl, nPos, bCallDelete );
-
- if( nSeqNo )
- {
- if( USHRT_MAX == nPos )
- nPos = 0;
- sal_uInt16 nFndPos = 2 == nLoopCnt
- ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
- : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
- if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
- USHRT_MAX != ( nFndPos =
- pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
- pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
- else
- nLoopCnt = 0;
- }
- else
- nLoopCnt = 0;
-
- } while( nLoopCnt );
-
- if( bRet )
- {
- CompressRedlines();
- SetModified();
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
- }
- }
- return bRet;
-}
-
-bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete )
-{
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- // The Selection is only in the ContentSection. If there are Redlines
- // to Non-ContentNodes before or after that, then the Selections
- // expand to them.
- SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
- lcl_AdjustRedlineRange( aPam );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_REJECT_REDLINE, NULL );
- GetIDocumentUndoRedo().AppendUndo( new SwUndoRejectRedline(aPam) );
- }
-
- int nRet = lcl_AcceptRejectRedl( lcl_RejectRedline, *pRedlineTbl,
- bCallDelete, aPam );
- if( nRet > 0 )
- {
- CompressRedlines();
- SetModified();
- }
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- String aTmpStr;
-
- {
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, String::CreateFromInt32(nRet));
- aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
- }
-
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, aTmpStr);
-
- GetIDocumentUndoRedo().EndUndo( UNDO_REJECT_REDLINE, &aRewriter );
- }
-
- return nRet != 0;
-}
-
-const SwRedline* SwDoc::SelNextRedline( SwPaM& rPam ) const
-{
- rPam.DeleteMark();
- rPam.SetMark();
-
- SwPosition& rSttPos = *rPam.GetPoint();
- SwPosition aSavePos( rSttPos );
- sal_Bool bRestart;
-
- // If the starting positon points to the last valid ContentNode,
- // we take the next Redline in any case.
- sal_uInt16 n = 0;
- const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_True );
- if( pFnd )
- {
- const SwPosition* pEnd = pFnd->End();
- if( !pEnd->nNode.GetNode().IsCntntNode() )
- {
- SwNodeIndex aTmp( pEnd->nNode );
- SwCntntNode* pCNd = GetNodes().GoPrevSection( &aTmp );
- if( !pCNd || ( aTmp == rSttPos.nNode &&
- pCNd->Len() == rSttPos.nContent.GetIndex() ))
- pFnd = 0;
- }
- if( pFnd )
- rSttPos = *pFnd->End();
- }
-
- do {
- bRestart = sal_False;
-
- for( ; !pFnd && n < pRedlineTbl->Count(); ++n )
- {
- pFnd = (*pRedlineTbl)[ n ];
- if( pFnd->HasMark() && pFnd->IsVisible() )
- {
- *rPam.GetMark() = *pFnd->Start();
- rSttPos = *pFnd->End();
- break;
- }
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- // Merge all of the same type and author that are
- // consecutive into one Selection.
- const SwPosition* pPrevEnd = pFnd->End();
- while( ++n < pRedlineTbl->Count() )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ n ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- const SwPosition *pRStt;
- if( pFnd->GetType() == pTmp->GetType() &&
- pFnd->GetAuthor() == pTmp->GetAuthor() &&
- ( *pPrevEnd == *( pRStt = pTmp->Start() ) ||
- IsPrevPos( *pPrevEnd, *pRStt )) )
- {
- pPrevEnd = pTmp->End();
- rSttPos = *pPrevEnd;
- }
- else
- break;
- }
- }
- }
-
- if( pFnd )
- {
- const SwRedline* pSaveFnd = pFnd;
-
- SwCntntNode* pCNd;
- SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
- {
- if( *pIdx <= rPam.GetPoint()->nNode )
- rPam.GetMark()->nContent.Assign( pCNd, 0 );
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- pIdx = &rPam.GetPoint()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
- {
- if( *pIdx >= rPam.GetMark()->nNode )
- rPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
- else
- pFnd = 0;
- }
- }
-
- if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
- {
- if( n < pRedlineTbl->Count() )
- {
- bRestart = sal_True;
- *rPam.GetPoint() = *pSaveFnd->End();
- }
- else
- {
- rPam.DeleteMark();
- *rPam.GetPoint() = aSavePos;
- }
- pFnd = 0;
- }
- }
- } while( bRestart );
-
- return pFnd;
-}
-
-const SwRedline* SwDoc::SelPrevRedline( SwPaM& rPam ) const
-{
- rPam.DeleteMark();
- rPam.SetMark();
-
- SwPosition& rSttPos = *rPam.GetPoint();
- SwPosition aSavePos( rSttPos );
- sal_Bool bRestart;
-
- // If the starting positon points to the last valid ContentNode,
- // we take the previous Redline in any case.
- sal_uInt16 n = 0;
- const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_False );
- if( pFnd )
- {
- const SwPosition* pStt = pFnd->Start();
- if( !pStt->nNode.GetNode().IsCntntNode() )
- {
- SwNodeIndex aTmp( pStt->nNode );
- SwCntntNode* pCNd = GetNodes().GoNextSection( &aTmp );
- if( !pCNd || ( aTmp == rSttPos.nNode &&
- !rSttPos.nContent.GetIndex() ))
- pFnd = 0;
- }
- if( pFnd )
- rSttPos = *pFnd->Start();
- }
-
- do {
- bRestart = sal_False;
-
- while( !pFnd && 0 < n )
- {
- pFnd = (*pRedlineTbl)[ --n ];
- if( pFnd->HasMark() && pFnd->IsVisible() )
- {
- *rPam.GetMark() = *pFnd->End();
- rSttPos = *pFnd->Start();
- }
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- // Merge all of the same type and author that are
- // consecutive into one Selection.
- const SwPosition* pNextStt = pFnd->Start();
- while( 0 < n )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ --n ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- const SwPosition *pREnd;
- if( pFnd->GetType() == pTmp->GetType() &&
- pFnd->GetAuthor() == pTmp->GetAuthor() &&
- ( *pNextStt == *( pREnd = pTmp->End() ) ||
- IsPrevPos( *pREnd, *pNextStt )) )
- {
- pNextStt = pTmp->Start();
- rSttPos = *pNextStt;
- }
- else
- {
- ++n;
- break;
- }
- }
- }
- }
-
- if( pFnd )
- {
- const SwRedline* pSaveFnd = pFnd;
-
- SwCntntNode* pCNd;
- SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
- {
- if( *pIdx >= rPam.GetPoint()->nNode )
- rPam.GetMark()->nContent.Assign( pCNd, pCNd->Len() );
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- pIdx = &rPam.GetPoint()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
- {
- if( *pIdx <= rPam.GetMark()->nNode )
- rPam.GetPoint()->nContent.Assign( pCNd, 0 );
- else
- pFnd = 0;
- }
- }
-
- if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
- {
- if( n )
- {
- bRestart = sal_True;
- *rPam.GetPoint() = *pSaveFnd->Start();
- }
- else
- {
- rPam.DeleteMark();
- *rPam.GetPoint() = aSavePos;
- }
- pFnd = 0;
- }
- }
- } while( bRestart );
-
- return pFnd;
-}
-
-// Set comment at the Redline
-bool SwDoc::SetRedlineComment( const SwPaM& rPaM, const String& rS )
-{
- sal_Bool bRet = sal_False;
- const SwPosition* pStt = rPaM.Start(),
- * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark()
- : rPaM.GetPoint();
- sal_uInt16 n = 0;
- if( lcl_FindCurrRedline( *pStt, n, sal_True ) )
- {
- for( ; n < pRedlineTbl->Count(); ++n )
- {
- bRet = sal_True;
- SwRedline* pTmp = (*pRedlineTbl)[ n ];
- if( pStt != pEnd && *pTmp->Start() > *pEnd )
- break;
-
- pTmp->SetComment( rS );
- if( *pTmp->End() >= *pEnd )
- break;
- }
- }
- if( bRet )
- SetModified();
-
- return bRet;
-}
-
-// Create a new author if necessary
-sal_uInt16 SwDoc::GetRedlineAuthor()
-{
- return SW_MOD()->GetRedlineAuthor();
-}
-
-// Insert new author into the Table for the Readers etc.
-sal_uInt16 SwDoc::InsertRedlineAuthor( const String& rNew )
-{
- return SW_MOD()->InsertRedlineAuthor(rNew);
-}
-
-void SwDoc::UpdateRedlineAttr()
-{
- const SwRedlineTbl& rTbl = GetRedlineTbl();
- for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
- {
- SwRedline* pRedl = rTbl[ n ];
- if( pRedl->IsVisible() )
- pRedl->InvalidateRange();
- }
-}
-
-// Set comment text for the Redline, which is inserted later on via
-// AppendRedline. Is used by Autoformat.
-// A null pointer resets the mode. The pointer is not copied, so it
-// needs to stay valid!
-void SwDoc::SetAutoFmtRedlineComment( const String* pTxt, sal_uInt16 nSeqNo )
-{
- mbIsAutoFmtRedline = 0 != pTxt;
- if( pTxt )
- {
- if( !pAutoFmtRedlnComment )
- pAutoFmtRedlnComment = new String( *pTxt );
- else
- *pAutoFmtRedlnComment = *pTxt;
- }
- else
- delete pAutoFmtRedlnComment, pAutoFmtRedlnComment = 0;
-
- nAutoFmtRedlnCommentNo = nSeqNo;
-}
-
-void SwDoc::SetRedlinePassword(
- /*[in]*/const uno::Sequence <sal_Int8>& rNewPassword)
-{
- aRedlinePasswd = rNewPassword;
- SetModified();
-}
-
-
sal_Bool SwRedlineTbl::Insert( SwRedlinePtr& p, sal_Bool bIns )
{
sal_Bool bRet = sal_False;
@@ -3819,15 +1924,4 @@ String SwRedline::GetDescr(sal_uInt16 nPos)
return aResult;
}
-
-bool SwDoc::IsInRedlines(const SwNode & rNode) const
-{
- SwPosition aPos(rNode);
- SwNode & rEndOfRedlines = GetNodes().GetEndOfRedlines();
- SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()),
- SwPosition(rEndOfRedlines));
-
- return aPam.ContainsPosition(aPos) ? true : false;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */