Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <hintids.hxx>
30 : : #include <tools/shl.hxx>
31 : : #include <svl/itemiter.hxx>
32 : : #include <sfx2/app.hxx>
33 : : #include <editeng/colritem.hxx>
34 : : #include <editeng/udlnitem.hxx>
35 : : #include <editeng/crsditem.hxx>
36 : : #include <swmodule.hxx>
37 : : #include <doc.hxx>
38 : : #include <IDocumentUndoRedo.hxx>
39 : : #include <docary.hxx>
40 : : #include <ndtxt.hxx>
41 : : #include <redline.hxx>
42 : : #include <swundo.hxx>
43 : : #include <UndoCore.hxx>
44 : : #include <UndoRedline.hxx>
45 : : #include <hints.hxx>
46 : : #include <pamtyp.hxx>
47 : : #include <poolfmt.hxx>
48 : : #include <viewsh.hxx>
49 : : #include <rootfrm.hxx>
50 : :
51 : : #include <comcore.hrc>
52 : :
53 : : using namespace com::sun::star;
54 : :
55 [ # # ][ # # ]: 0 : TYPEINIT1(SwRedlineHint, SfxHint);
56 : :
57 : : #ifdef DBG_UTIL
58 : :
59 : : #define _ERROR_PREFIX "redline table corrupted: "
60 : :
61 : : // helper function for lcl_CheckRedline
62 : : // 1. make sure that pPos->nContent points into pPos->nNode
63 : : // (or into the 'special' no-content-node-IndexReg)
64 : : // 2. check that position is valid and doesn't point behind text
65 : : void lcl_CheckPosition( const SwPosition* pPos )
66 : : {
67 : : SwPosition aComparePos( *pPos );
68 : : aComparePos.nContent.Assign(
69 : : aComparePos.nNode.GetNode().GetCntntNode(), 0 );
70 : : OSL_ENSURE( pPos->nContent.GetIdxReg() ==
71 : : aComparePos.nContent.GetIdxReg(),
72 : : _ERROR_PREFIX "illegal position" );
73 : :
74 : : SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
75 : : if( pTxtNode == NULL )
76 : : {
77 : : OSL_ENSURE( pPos->nContent == 0,
78 : : _ERROR_PREFIX "non-text-node with content" );
79 : : }
80 : : else
81 : : {
82 : : OSL_ENSURE( pPos->nContent >= 0 &&
83 : : pPos->nContent <= pTxtNode->Len(),
84 : : _ERROR_PREFIX "index behind text" );
85 : : }
86 : : }
87 : :
88 : : void lcl_CheckPam( const SwPaM* pPam )
89 : : {
90 : : OSL_ENSURE( pPam != NULL, _ERROR_PREFIX "illegal argument" );
91 : : lcl_CheckPosition( pPam->GetPoint() );
92 : : lcl_CheckPosition( pPam->GetMark() );
93 : : }
94 : :
95 : : // check validity of the redline table. Checks redline bounds, and make
96 : : // sure the redlines are sorted and non-overlapping.
97 : : void lcl_CheckRedline( const SwDoc* pDoc )
98 : : {
99 : : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
100 : :
101 : : // verify valid redline positions
102 : : for( sal_uInt16 i = 0; i < rTbl.size(); ++i )
103 : : lcl_CheckPam( rTbl[ i ] );
104 : :
105 : : for( sal_uInt16 j = 0; j < rTbl.size(); ++j )
106 : : {
107 : : // check for empty redlines
108 : : OSL_ENSURE( ( *(rTbl[j]->GetPoint()) != *(rTbl[j]->GetMark()) ) ||
109 : : ( rTbl[j]->GetContentIdx() != NULL ),
110 : : _ERROR_PREFIX "empty redline" );
111 : : }
112 : :
113 : : // verify proper redline sorting
114 : : for( sal_uInt16 n = 1; n < rTbl.size(); ++n )
115 : : {
116 : : const SwRedline* pPrev = rTbl[ n-1 ];
117 : : const SwRedline* pCurrent = rTbl[ n ];
118 : :
119 : : // check redline sorting
120 : : SAL_WARN_IF( *pPrev->Start() > *pCurrent->Start(), "sw",
121 : : _ERROR_PREFIX "not sorted correctly" );
122 : :
123 : : // check for overlapping redlines
124 : : SAL_WARN_IF( *pPrev->End() > *pCurrent->Start(), "sw",
125 : : _ERROR_PREFIX "overlapping redlines" );
126 : : }
127 : : }
128 : :
129 : : #define _CHECK_REDLINE( pDoc ) lcl_CheckRedline( pDoc );
130 : :
131 : : void lcl_DebugRedline( const SwDoc* pDoc )
132 : : {
133 : : static sal_uInt16 nWatch = 0;
134 : : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
135 : : for( sal_uInt16 n = 0; n < rTbl.size(); ++n )
136 : : {
137 : : sal_uInt16 nDummy = 0;
138 : : const SwRedline* pCurrent = rTbl[ n ];
139 : : const SwRedline* pNext = n+1 < (sal_uInt16)rTbl.size() ? rTbl[ n+1 ] : 0;
140 : : if( pCurrent == pNext )
141 : : ++nDummy;
142 : : if( n == nWatch )
143 : : ++nDummy; // Possible debugger breakpoint
144 : : }
145 : : }
146 : :
147 : : #define _DEBUG_REDLINE( pDoc ) lcl_DebugRedline( pDoc );
148 : :
149 : :
150 : : #else
151 : :
152 : : #define _CHECK_REDLINE( pDoc )
153 : : #define _DEBUG_REDLINE( pDoc )
154 : :
155 : : #endif
156 : :
157 : 173557 : RedlineMode_t SwDoc::GetRedlineMode() const
158 : : {
159 : 173557 : return eRedlineMode;
160 : : }
161 : :
162 : 783 : void SwDoc::SetRedlineMode( RedlineMode_t eMode )
163 : : {
164 [ + + ]: 783 : if( eRedlineMode != eMode )
165 : : {
166 [ + + ][ - + ]: 193 : if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode)
167 : : || 0 == (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode) )
168 : : {
169 : 163 : bool bSaveInXMLImportFlag = IsInXMLImport();
170 : 163 : SetInXMLImport( false );
171 : : // and then hide/display everything
172 : 163 : void (SwRedline::*pFnc)( sal_uInt16 ) = 0;
173 : :
174 [ + + + + ]: 163 : switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eMode )
175 : : {
176 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE :
177 : 103 : pFnc = &SwRedline::Show;
178 : 103 : break;
179 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT:
180 : 29 : pFnc = &SwRedline::Hide;
181 : 29 : break;
182 : : case nsRedlineMode_t::REDLINE_SHOW_DELETE:
183 : 11 : pFnc = &SwRedline::ShowOriginal;
184 : 11 : break;
185 : :
186 : : default:
187 : 20 : pFnc = &SwRedline::Hide;
188 : 20 : eMode = (RedlineMode_t)(eMode | nsRedlineMode_t::REDLINE_SHOW_INSERT);
189 : 20 : break;
190 : : }
191 : :
192 : : _CHECK_REDLINE( this )
193 : :
194 [ + - ]: 163 : if( pFnc )
195 [ + + ]: 489 : for( sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop )
196 [ + + ]: 332 : for( sal_uInt16 i = 0; i < pRedlineTbl->size(); ++i )
197 [ + - ][ + - ]: 6 : ((*pRedlineTbl)[ i ]->*pFnc)( nLoop );
[ + - ]
198 : : _CHECK_REDLINE( this )
199 : 163 : SetInXMLImport( bSaveInXMLImportFlag );
200 : : }
201 : 193 : eRedlineMode = eMode;
202 : 193 : SetModified();
203 : : }
204 : 783 : }
205 : :
206 : 186488 : bool SwDoc::IsRedlineOn() const
207 : : {
208 : 186488 : return IDocumentRedlineAccess::IsRedlineOn(eRedlineMode);
209 : : }
210 : :
211 : 149227 : bool SwDoc::IsIgnoreRedline() const
212 : : {
213 : 149227 : return (nsRedlineMode_t::REDLINE_IGNORE & eRedlineMode);
214 : : }
215 : :
216 : 2454 : void SwDoc::SetRedlineMode_intern(RedlineMode_t eMode)
217 : : {
218 : 2454 : eRedlineMode = eMode;
219 : 2454 : }
220 : :
221 : 285171 : const SwRedlineTbl& SwDoc::GetRedlineTbl() const
222 : : {
223 : 285171 : return *pRedlineTbl;
224 : : }
225 : :
226 : 48 : bool SwDoc::IsRedlineMove() const
227 : : {
228 : 48 : return mbIsRedlineMove;
229 : : }
230 : :
231 : 36 : void SwDoc::SetRedlineMove(bool bFlag)
232 : : {
233 : 36 : mbIsRedlineMove = bFlag;
234 : 36 : }
235 : :
236 : 104 : const uno::Sequence <sal_Int8>& SwDoc::GetRedlinePassword() const
237 : : {
238 : 104 : return aRedlinePasswd;
239 : : }
240 : :
241 : 84 : inline bool IsPrevPos( const SwPosition rPos1, const SwPosition rPos2 )
242 : : {
243 : : const SwCntntNode* pCNd;
244 : 84 : return 0 == rPos2.nContent.GetIndex() &&
245 : 0 : rPos2.nNode.GetIndex() - 1 == rPos1.nNode.GetIndex() &&
246 : 0 : 0 != ( pCNd = rPos1.nNode.GetNode().GetCntntNode() )
247 : 0 : ? rPos1.nContent.GetIndex() == pCNd->Len()
248 [ - + # # : 84 : : false;
# # # # ]
249 : : }
250 : :
251 : : #if OSL_DEBUG_LEVEL > 0
252 : : bool CheckPosition( const SwPosition* pStt, const SwPosition* pEnd )
253 : : {
254 : : int nError = 0;
255 : : SwNode* pSttNode = &pStt->nNode.GetNode();
256 : : SwNode* pEndNode = &pEnd->nNode.GetNode();
257 : : SwNode* pSttTab = pSttNode->StartOfSectionNode()->FindTableNode();
258 : : SwNode* pEndTab = pEndNode->StartOfSectionNode()->FindTableNode();
259 : : SwNode* pSttStart = pSttNode;
260 : : while( pSttStart && (!pSttStart->IsStartNode() || pSttStart->IsSectionNode() ||
261 : : pSttStart->IsTableNode() ) )
262 : : pSttStart = pSttStart->StartOfSectionNode();
263 : : SwNode* pEndStart = pEndNode;
264 : : while( pEndStart && (!pEndStart->IsStartNode() || pEndStart->IsSectionNode() ||
265 : : pEndStart->IsTableNode() ) )
266 : : pEndStart = pEndStart->StartOfSectionNode();
267 : : if( pSttTab != pEndTab )
268 : : nError = 1;
269 : : if( !pSttTab && pSttStart != pEndStart )
270 : : nError |= 2;
271 : : if( nError )
272 : : nError += 10;
273 : : return nError != 0;
274 : : }
275 : : #endif
276 : :
277 : : /*
278 : :
279 : : Text means Text not "polluted" by Redlines.
280 : :
281 : : Behaviour of Insert-Redline:
282 : :
283 : : - in the Text - insert Redline Object
284 : : - in InsertRedline (own) - ignore, existing is extended
285 : : - in InsertRedline (others) - split up InsertRedline and
286 : : insert Redline Object
287 : : - in DeleteRedline - split up DeleteRedline or
288 : : move at the end/beginning
289 : :
290 : : Behaviour of Delete-Redline:
291 : : - in the Text - insert Redline Object
292 : : - in DeleteRedline (own/others) - ignore
293 : : - in InsertRedline (own) - ignore, but delete character
294 : : - in InsertRedline (others) - split up InsertRedline and
295 : : insert Redline Object
296 : : - Text and own Insert overlap - delete Text in the own Insert,
297 : : extend in the other Text
298 : : (up to the Insert!)
299 : : - Text and other Insert overlap - insert Redline Object, the
300 : : other Insert is overlapped by
301 : : the Delete
302 : : */
303 : :
304 : 2334 : bool SwDoc::AppendRedline( SwRedline* pNewRedl, bool bCallDelete )
305 : : {
306 : 2334 : bool bError = true;
307 : : _CHECK_REDLINE( this )
308 : :
309 [ + - ]: 3900 : if( IsRedlineOn() && !IsShowOriginal( eRedlineMode ) &&
[ + + + - ]
[ + + ]
310 : 1566 : pNewRedl->GetAuthorString().Len() )
311 : : {
312 [ + - ]: 1566 : pNewRedl->InvalidateRange();
313 : :
314 [ - + ]: 1566 : if( mbIsAutoFmtRedline )
315 : : {
316 : 0 : pNewRedl->SetAutoFmtFlag();
317 [ # # ][ # # ]: 0 : if( pAutoFmtRedlnComment && pAutoFmtRedlnComment->Len() )
[ # # ]
318 : : {
319 [ # # ]: 0 : pNewRedl->SetComment( *pAutoFmtRedlnComment );
320 : 0 : pNewRedl->SetSeqNo( nAutoFmtRedlnCommentNo );
321 : : }
322 : : }
323 : :
324 [ + - ]: 1566 : SwPosition* pStt = pNewRedl->Start(),
325 : 1566 : * pEnd = pStt == pNewRedl->GetPoint() ? pNewRedl->GetMark()
326 [ + + ]: 1566 : : pNewRedl->GetPoint();
327 : : {
328 : 1566 : SwTxtNode* pTxtNode = pStt->nNode.GetNode().GetTxtNode();
329 [ - + ]: 1566 : if( pTxtNode == NULL )
330 : : {
331 [ # # ]: 0 : if( pStt->nContent > 0 )
332 : : {
333 : : OSL_ENSURE( false, "Redline start: non-text-node with content" );
334 [ # # ]: 0 : pStt->nContent = 0;
335 : : }
336 : : }
337 : : else
338 : : {
339 [ + - ][ - + ]: 1566 : if( pStt->nContent > pTxtNode->Len() )
340 : : {
341 : : OSL_ENSURE( false, "Redline start: index behind text" );
342 [ # # ][ # # ]: 0 : pStt->nContent = pTxtNode->Len();
343 : : }
344 : : }
345 : 1566 : pTxtNode = pEnd->nNode.GetNode().GetTxtNode();
346 [ - + ]: 1566 : if( pTxtNode == NULL )
347 : : {
348 [ # # ]: 0 : if( pEnd->nContent > 0 )
349 : : {
350 : : OSL_ENSURE( false, "Redline end: non-text-node with content" );
351 [ # # ]: 0 : pEnd->nContent = 0;
352 : : }
353 : : }
354 : : else
355 : : {
356 [ + - ][ - + ]: 1566 : if( pEnd->nContent > pTxtNode->Len() )
357 : : {
358 : : OSL_ENSURE( false, "Redline end: index behind text" );
359 [ # # ][ # # ]: 0 : pEnd->nContent = pTxtNode->Len();
360 : : }
361 : : }
362 : : }
363 [ + - ]: 1761 : if( ( *pStt == *pEnd ) &&
[ + + + - ]
[ + + ]
364 : 195 : ( pNewRedl->GetContentIdx() == NULL ) )
365 : : { // Do not insert empty redlines
366 [ + - ][ + - ]: 195 : delete pNewRedl;
367 : 195 : return sal_False;
368 : : }
369 : 1371 : sal_Bool bCompress = sal_False;
370 : 1371 : sal_uInt16 n = 0;
371 : : // look up the first Redline for the starting position
372 [ + - ][ + - ]: 1371 : if( !GetRedline( *pStt, &n ) && n )
[ + + ][ + + ]
373 : 1266 : --n;
374 : 1371 : bool bDec = false;
375 : :
376 [ + - ][ + + ]: 2637 : for( ; pNewRedl && n < pRedlineTbl->size(); bDec ? n : ++n )
[ + + ][ + + ]
377 : : {
378 : 1266 : bDec = false;
379 : :
380 [ + - ]: 1266 : SwRedline* pRedl = (*pRedlineTbl)[ n ];
381 [ + - ]: 1266 : SwPosition* pRStt = pRedl->Start(),
382 : 1266 : * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
383 [ - + ]: 1266 : : pRedl->GetPoint();
384 : :
385 : : // #i8518# remove empty redlines while we're at it
386 [ + - ]: 1266 : if( ( *pRStt == *pREnd ) &&
[ - + # # ]
[ - + ]
387 : 0 : ( pRedl->GetContentIdx() == NULL ) )
388 : : {
389 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy(n);
390 : 0 : continue;
391 : : }
392 : :
393 [ + - ]: 1266 : SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
394 : :
395 [ + - ][ + - : 1266 : switch( pNewRedl->GetType() )
- - - ]
396 : : {
397 : : case nsRedlineType_t::REDLINE_INSERT:
398 [ + - ]: 1266 : switch( pRedl->GetType() )
[ + - - - ]
399 : : {
400 : : case nsRedlineType_t::REDLINE_INSERT:
401 [ + - ][ + + ]: 1266 : if( pRedl->IsOwnRedline( *pNewRedl ) )
402 : : {
403 : 521 : bool bDelete = false;
404 : :
405 : : // Merge if applicable?
406 [ + + ][ + - ]: 2000 : if( (( POS_BEHIND == eCmpPos &&
[ + + ][ - + ]
[ + - - + ]
[ # # ][ # # ]
[ + + ]
407 [ + - ][ + - ]: 605 : IsPrevPos( *pREnd, *pStt ) ) ||
[ + - ][ + + ]
[ + - ][ + + ]
[ + - ]
[ # # # # ]
408 : : ( POS_COLLIDE_START == eCmpPos ) ||
409 : : ( POS_OVERLAP_BEHIND == eCmpPos ) ) &&
410 [ + - ]: 437 : pRedl->CanCombine( *pNewRedl ) &&
411 : 437 : ( n+1 >= (sal_uInt16)pRedlineTbl->size() ||
412 [ # # ][ # # ]: 0 : ( *(*pRedlineTbl)[ n+1 ]->Start() >= *pEnd &&
[ # # ]
413 [ # # ][ # # ]: 0 : *(*pRedlineTbl)[ n+1 ]->Start() != *pREnd ) ) )
[ # # ]
414 : : {
415 [ + - ]: 437 : pRedl->SetEnd( *pEnd, pREnd );
416 [ + - ][ - + ]: 437 : if( !pRedl->HasValidRange() )
417 : : {
418 : : // re-insert
419 [ # # ]: 0 : pRedlineTbl->Remove( n );
420 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
421 : : }
422 : :
423 : 437 : bError = false;
424 : 437 : bDelete = true;
425 : : }
426 [ - + ][ # # ]: 168 : else if( (( POS_BEFORE == eCmpPos &&
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ][ - + ]
427 [ # # ][ # # ]: 84 : IsPrevPos( *pEnd, *pRStt ) ) ||
[ # # ][ - + ]
[ # # ][ - + ]
[ # # ]
[ # # # # ]
428 : : ( POS_COLLIDE_END == eCmpPos ) ||
429 : : ( POS_OVERLAP_BEFORE == eCmpPos ) ) &&
430 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ) &&
431 : 0 : ( !n ||
432 [ # # ][ # # ]: 0 : *(*pRedlineTbl)[ n-1 ]->End() != *pRStt ))
[ # # ]
433 : : {
434 [ # # ]: 0 : pRedl->SetStart( *pStt, pRStt );
435 : : // re-insert
436 [ # # ]: 0 : pRedlineTbl->Remove( n );
437 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
438 : :
439 : 0 : bError = false;
440 : 0 : bDelete = true;
441 : : }
442 [ - + ]: 84 : else if ( POS_OUTSIDE == eCmpPos )
443 : : {
444 : : // own insert-over-insert redlines:
445 : : // just scrap the inside ones
446 [ # # ]: 0 : pRedlineTbl->Remove( n );
447 : 0 : bDec = true;
448 : : }
449 [ - + ]: 84 : else if( POS_OVERLAP_BEHIND == eCmpPos )
450 : : {
451 [ # # ]: 0 : *pStt = *pREnd;
452 [ # # ]: 0 : if( ( *pStt == *pEnd ) &&
[ # # # # ]
[ # # ]
453 : 0 : ( pNewRedl->GetContentIdx() == NULL ) )
454 : 0 : bDelete = true;
455 : : }
456 [ - + ]: 84 : else if( POS_OVERLAP_BEFORE == eCmpPos )
457 : : {
458 [ # # ]: 0 : *pEnd = *pRStt;
459 [ # # ]: 0 : if( ( *pStt == *pEnd ) &&
[ # # # # ]
[ # # ]
460 : 0 : ( pNewRedl->GetContentIdx() == NULL ) )
461 : 0 : bDelete = true;
462 : : }
463 [ + - ][ - + ]: 84 : else if( POS_INSIDE == eCmpPos || POS_EQUAL == eCmpPos)
464 : 0 : bDelete = true;
465 : :
466 [ + + ]: 521 : if( bDelete )
467 : : {
468 [ + - ][ + - ]: 437 : delete pNewRedl, pNewRedl = 0;
469 : 437 : bCompress = sal_True;
470 : : }
471 : : }
472 [ - + ]: 745 : else if( POS_INSIDE == eCmpPos )
473 : : {
474 : : // split up
475 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
476 : : {
477 [ # # ][ # # ]: 0 : SwRedline* pCpy = new SwRedline( *pRedl );
478 [ # # ]: 0 : pCpy->SetStart( *pEnd );
479 [ # # ]: 0 : pRedlineTbl->Insert( pCpy );
480 : : }
481 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
482 [ # # ]: 0 : if( ( *pStt == *pRStt ) &&
[ # # # # ]
[ # # ]
483 : 0 : ( pRedl->GetContentIdx() == NULL ) )
484 : : {
485 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
486 : 0 : bDec = true;
487 : : }
488 [ # # ][ # # ]: 0 : else if( !pRedl->HasValidRange() )
489 : : {
490 : : // re-insert
491 [ # # ]: 0 : pRedlineTbl->Remove( n );
492 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
493 : : }
494 : : }
495 [ - + ]: 745 : else if ( POS_OUTSIDE == eCmpPos )
496 : : {
497 : : // handle overlapping redlines in broken documents
498 : :
499 : : // split up the new redline, since it covers the
500 : : // existing redline. Insert the first part, and
501 : : // progress with the remainder as usual
502 [ # # ][ # # ]: 0 : SwRedline* pSplit = new SwRedline( *pNewRedl );
503 [ # # ]: 0 : pSplit->SetEnd( *pRStt );
504 [ # # ]: 0 : pNewRedl->SetStart( *pREnd );
505 [ # # ]: 0 : pRedlineTbl->Insert( pSplit );
506 [ # # ][ # # ]: 0 : if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
[ # # ][ # # ]
507 : : {
508 [ # # ][ # # ]: 0 : delete pNewRedl;
509 : 0 : pNewRedl = 0;
510 : 0 : bCompress = true;
511 : : }
512 : : }
513 [ - + ]: 745 : else if ( POS_OVERLAP_BEHIND == eCmpPos )
514 : : {
515 : : // handle overlapping redlines in broken documents
516 [ # # ]: 0 : pNewRedl->SetStart( *pREnd );
517 : : }
518 [ - + ]: 745 : else if ( POS_OVERLAP_BEFORE == eCmpPos )
519 : : {
520 : : // handle overlapping redlines in broken documents
521 [ # # ]: 0 : *pEnd = *pRStt;
522 [ # # ]: 0 : if( ( *pStt == *pEnd ) &&
[ # # # # ]
[ # # ]
523 : 0 : ( pNewRedl->GetContentIdx() == NULL ) )
524 : : {
525 [ # # ][ # # ]: 0 : delete pNewRedl;
526 : 0 : pNewRedl = 0;
527 : 0 : bCompress = true;
528 : : }
529 : : }
530 : 1266 : break;
531 : : case nsRedlineType_t::REDLINE_DELETE:
532 [ # # ]: 0 : if( POS_INSIDE == eCmpPos )
533 : : {
534 : : // split up
535 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
536 : : {
537 [ # # ][ # # ]: 0 : SwRedline* pCpy = new SwRedline( *pRedl );
538 [ # # ]: 0 : pCpy->SetStart( *pEnd );
539 [ # # ]: 0 : pRedlineTbl->Insert( pCpy );
540 : : }
541 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
542 [ # # ]: 0 : if( ( *pStt == *pRStt ) &&
[ # # # # ]
[ # # ]
543 : 0 : ( pRedl->GetContentIdx() == NULL ) )
544 : : {
545 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
546 : 0 : bDec = true;
547 : : }
548 [ # # ][ # # ]: 0 : else if( !pRedl->HasValidRange() )
549 : : {
550 : : // re-insert
551 [ # # ]: 0 : pRedlineTbl->Remove( n );
552 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
553 : : }
554 : : }
555 [ # # ]: 0 : else if ( POS_OUTSIDE == eCmpPos )
556 : : {
557 : : // handle overlapping redlines in broken documents
558 : :
559 : : // split up the new redline, since it covers the
560 : : // existing redline. Insert the first part, and
561 : : // progress with the remainder as usual
562 [ # # ][ # # ]: 0 : SwRedline* pSplit = new SwRedline( *pNewRedl );
563 [ # # ]: 0 : pSplit->SetEnd( *pRStt );
564 [ # # ]: 0 : pNewRedl->SetStart( *pREnd );
565 [ # # ]: 0 : pRedlineTbl->Insert( pSplit );
566 [ # # ][ # # ]: 0 : if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
[ # # ][ # # ]
567 : : {
568 [ # # ][ # # ]: 0 : delete pNewRedl;
569 : 0 : pNewRedl = 0;
570 : 0 : bCompress = true;
571 : : }
572 : : }
573 [ # # ]: 0 : else if ( POS_EQUAL == eCmpPos )
574 : : {
575 : : // handle identical redlines in broken documents
576 : : // delete old (delete) redline
577 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
578 : 0 : bDec = true;
579 : : }
580 [ # # ]: 0 : else if ( POS_OVERLAP_BEHIND == eCmpPos )
581 : : { // Another workaround for broken redlines
582 [ # # ]: 0 : pNewRedl->SetStart( *pREnd );
583 : : }
584 : 0 : break;
585 : : case nsRedlineType_t::REDLINE_FORMAT:
586 [ # # # # : 0 : switch( eCmpPos )
# ]
587 : : {
588 : : case POS_OVERLAP_BEFORE:
589 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
590 : : // re-insert
591 [ # # ]: 0 : pRedlineTbl->Remove( n );
592 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
593 : 0 : bDec = true;
594 : 0 : break;
595 : :
596 : : case POS_OVERLAP_BEHIND:
597 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
598 [ # # ][ # # ]: 0 : if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
[ # # ][ # # ]
599 : : {
600 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
601 : 0 : bDec = true;
602 : : }
603 : 0 : break;
604 : :
605 : : case POS_EQUAL:
606 : : case POS_OUTSIDE:
607 : : // Overlaps the current one completely or has the
608 : : // same dimension, delete the old one
609 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
610 : 0 : bDec = true;
611 : 0 : break;
612 : :
613 : : case POS_INSIDE:
614 : : // Overlaps the current one completely,
615 : : // split or shorten the new one
616 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
617 : : {
618 [ # # ][ # # ]: 0 : if( *pEnd != *pRStt )
619 : : {
620 [ # # ][ # # ]: 0 : SwRedline* pNew = new SwRedline( *pRedl );
621 [ # # ]: 0 : pNew->SetStart( *pEnd );
622 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
623 [ # # ][ # # ]: 0 : if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
[ # # ][ # # ]
624 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
625 [ # # ]: 0 : AppendRedline( pNew, bCallDelete );
626 : 0 : n = 0; // re-initialize
627 : 0 : bDec = true;
628 : : }
629 : : }
630 : : else
631 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
632 : 0 : break;
633 : : default:
634 : 0 : break;
635 : : }
636 : 0 : break;
637 : : default:
638 : 0 : break;
639 : : }
640 : 1266 : break;
641 : :
642 : : case nsRedlineType_t::REDLINE_DELETE:
643 [ # # ]: 0 : switch( pRedl->GetType() )
[ # # # # ]
644 : : {
645 : : case nsRedlineType_t::REDLINE_DELETE:
646 [ # # # # : 0 : switch( eCmpPos )
# ]
647 : : {
648 : : case POS_OUTSIDE:
649 : : {
650 : : // Overlaps the current one completely,
651 : : // split the new one
652 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
653 : : {
654 [ # # ][ # # ]: 0 : SwRedline* pNew = new SwRedline( *pNewRedl );
655 [ # # ]: 0 : pNew->SetStart( *pREnd );
656 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
657 [ # # ]: 0 : AppendRedline( pNew, bCallDelete );
658 : 0 : n = 0; // re-initialize
659 : 0 : bDec = true;
660 : : }
661 : : else
662 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
663 : : }
664 : 0 : break;
665 : :
666 : : case POS_INSIDE:
667 : : case POS_EQUAL:
668 [ # # ][ # # ]: 0 : delete pNewRedl, pNewRedl = 0;
669 : 0 : bCompress = sal_True;
670 : 0 : break;
671 : :
672 : : case POS_OVERLAP_BEFORE:
673 : : case POS_OVERLAP_BEHIND:
674 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # ][ # # ]
675 : : // 1 == pRedl->GetStackCount() &&
676 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ))
677 : : {
678 : : // If that's the case we can merge it, meaning
679 : : // the new one covers this well
680 [ # # ]: 0 : if( POS_OVERLAP_BEHIND == eCmpPos )
681 [ # # ]: 0 : pNewRedl->SetStart( *pRStt, pStt );
682 : : else
683 [ # # ]: 0 : pNewRedl->SetEnd( *pREnd, pEnd );
684 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
685 : 0 : bDec = true;
686 : : }
687 [ # # ]: 0 : else if( POS_OVERLAP_BEHIND == eCmpPos )
688 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
689 : : else
690 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
691 : 0 : break;
692 : :
693 : : case POS_COLLIDE_START:
694 : : case POS_COLLIDE_END:
695 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # ][ # # ]
696 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ) )
697 : : {
698 [ # # ]: 0 : if( IsHideChanges( eRedlineMode ))
699 : : {
700 : : // Before we can merge, we make it visible!
701 : : // We insert temporarily so that pNew is
702 : : // also dealt with when moving the indices.
703 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
704 [ # # ]: 0 : pRedl->Show();
705 [ # # ]: 0 : pRedlineTbl->Remove( pNewRedl );
706 [ # # ]: 0 : pRStt = pRedl->Start();
707 [ # # ]: 0 : pREnd = pRedl->End();
708 : : }
709 : :
710 : : // If that's the case we can merge it, meaning
711 : : // the new one covers this well
712 [ # # ]: 0 : if( POS_COLLIDE_START == eCmpPos )
713 [ # # ]: 0 : pNewRedl->SetStart( *pRStt, pStt );
714 : : else
715 [ # # ]: 0 : pNewRedl->SetEnd( *pREnd, pEnd );
716 : :
717 : : // delete current (below), and restart process with
718 : : // previous
719 : 0 : sal_uInt16 nToBeDeleted = n;
720 : 0 : bDec = true;
721 : :
722 [ # # ][ # # ]: 0 : if( *(pNewRedl->Start()) <= *pREnd )
[ # # ]
723 : : {
724 : : // Whoooah, we just extended the new 'redline'
725 : : // beyond previous redlines, so better start
726 : : // again. Of course this is not supposed to
727 : : // happen, and in an ideal world it doesn't,
728 : : // but unfortunately this code is buggy and
729 : : // totally rotten so it does happen and we
730 : : // better fix it.
731 : 0 : n = 0;
732 : 0 : bDec = true;
733 : : }
734 : :
735 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( nToBeDeleted );
736 : : }
737 : 0 : break;
738 : : default:
739 : 0 : break;
740 : : }
741 : 0 : break;
742 : :
743 : : case nsRedlineType_t::REDLINE_INSERT:
744 : : {
745 : : // b62341295: Do not throw away redlines
746 : : // even if they are not allowed to be combined
747 : 0 : RedlineMode_t eOld = eRedlineMode;
748 [ # # ][ # # ]: 0 : if( !( eOld & nsRedlineMode_t::REDLINE_DONTCOMBINE_REDLINES ) &&
[ # # ]
749 [ # # ]: 0 : pRedl->IsOwnRedline( *pNewRedl ) )
750 : : {
751 : :
752 : : // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
753 : : // The ShowMode needs to be retained!
754 : 0 : eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
755 [ # # # # : 0 : switch( eCmpPos )
# # ]
756 : : {
757 : : case POS_EQUAL:
758 : 0 : bCompress = sal_True;
759 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
760 : 0 : bDec = true;
761 : : // no break!
762 : :
763 : : case POS_INSIDE:
764 [ # # ]: 0 : if( bCallDelete )
765 : : {
766 : 0 : eRedlineMode = (RedlineMode_t)(eRedlineMode | nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES);
767 : :
768 : : // DeleteAndJoin does not yield the
769 : : // desired result if there is no paragraph to
770 : : // join with, i.e. at the end of the document.
771 : : // For this case, we completely delete the
772 : : // paragraphs (if, of course, we also start on
773 : : // a paragraph boundary).
774 [ # # # # ]: 0 : if( (pStt->nContent == 0) &&
[ # # ]
775 : 0 : pEnd->nNode.GetNode().IsEndNode() )
776 : : {
777 [ # # ]: 0 : pEnd->nNode--;
778 : : pEnd->nContent.Assign(
779 [ # # ][ # # ]: 0 : pEnd->nNode.GetNode().GetTxtNode(), 0);
780 [ # # ]: 0 : DelFullPara( *pNewRedl );
781 : : }
782 : : else
783 [ # # ]: 0 : DeleteAndJoin( *pNewRedl );
784 : :
785 : 0 : bCompress = sal_True;
786 : : }
787 [ # # ][ # # ]: 0 : delete pNewRedl, pNewRedl = 0;
788 : 0 : break;
789 : :
790 : : case POS_OUTSIDE:
791 : : {
792 [ # # ]: 0 : pRedlineTbl->Remove( n );
793 : 0 : bDec = true;
794 : : // We insert temporarily so that pNew is
795 : : // also dealt with when moving the indices.
796 [ # # ]: 0 : if( bCallDelete )
797 : : {
798 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
799 [ # # ]: 0 : DeleteAndJoin( *pRedl );
800 [ # # ][ # # ]: 0 : if( !pRedlineTbl->Remove( pNewRedl ) )
801 : 0 : pNewRedl = 0;
802 : : }
803 [ # # ][ # # ]: 0 : delete pRedl;
804 : : }
805 : 0 : break;
806 : :
807 : : case POS_OVERLAP_BEFORE:
808 : : {
809 [ # # ]: 0 : SwPaM aPam( *pRStt, *pEnd );
810 : :
811 [ # # ][ # # ]: 0 : if( *pEnd == *pREnd )
812 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
813 : : else
814 : : {
815 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
816 : : // re-insert
817 [ # # ]: 0 : pRedlineTbl->Remove( n );
818 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
819 : : }
820 : :
821 [ # # ]: 0 : if( bCallDelete )
822 : : {
823 : : // We insert temporarily so that pNew is
824 : : // also dealt with when moving the indices.
825 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
826 [ # # ]: 0 : DeleteAndJoin( aPam );
827 [ # # ][ # # ]: 0 : if( !pRedlineTbl->Remove( pNewRedl ) )
828 : 0 : pNewRedl = 0;
829 : 0 : n = 0; // re-initialize
830 : : }
831 [ # # ]: 0 : bDec = true;
832 : : }
833 : 0 : break;
834 : :
835 : : case POS_OVERLAP_BEHIND:
836 : : {
837 [ # # ]: 0 : SwPaM aPam( *pStt, *pREnd );
838 : :
839 [ # # ][ # # ]: 0 : if( *pStt == *pRStt )
840 : : {
841 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
842 : 0 : bDec = true;
843 : : }
844 : : else
845 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
846 : :
847 [ # # ]: 0 : if( bCallDelete )
848 : : {
849 : : // We insert temporarily so that pNew is
850 : : // also dealt with when moving the indices.
851 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
852 [ # # ]: 0 : DeleteAndJoin( aPam );
853 [ # # ][ # # ]: 0 : if( !pRedlineTbl->Remove( pNewRedl ) )
854 : 0 : pNewRedl = 0;
855 : 0 : n = 0; // re-initialize
856 : 0 : bDec = true;
857 [ # # ]: 0 : }
858 : : }
859 : 0 : break;
860 : : default:
861 : 0 : break;
862 : : }
863 : :
864 : 0 : eRedlineMode = eOld;
865 : : }
866 : : else
867 : : {
868 : : // it may be necessary to split the existing redline in
869 : : // two. In this case, pRedl will be changed to cover
870 : : // only part of it's former range, and pNew will cover
871 : : // the remainder.
872 : 0 : SwRedline* pNew = 0;
873 : :
874 [ # # # # : 0 : switch( eCmpPos )
# # ]
875 : : {
876 : : case POS_EQUAL:
877 : : {
878 [ # # ]: 0 : pRedl->PushData( *pNewRedl );
879 [ # # ][ # # ]: 0 : delete pNewRedl, pNewRedl = 0;
880 [ # # ]: 0 : if( IsHideChanges( eRedlineMode ))
881 [ # # ]: 0 : pRedl->Hide();
882 : 0 : bCompress = sal_True;
883 : : }
884 : 0 : break;
885 : :
886 : : case POS_INSIDE:
887 : : {
888 [ # # ][ # # ]: 0 : if( *pRStt == *pStt )
889 : : {
890 : : // #i97421#
891 : : // redline w/out extent loops
892 [ # # ][ # # ]: 0 : if (*pStt != *pEnd)
893 : : {
894 [ # # ]: 0 : pNewRedl->PushData( *pRedl, sal_False );
895 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
896 : : // re-insert
897 [ # # ]: 0 : pRedlineTbl->Remove( n );
898 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
899 : 0 : bDec = true;
900 : : }
901 : : }
902 : : else
903 : : {
904 [ # # ]: 0 : pNewRedl->PushData( *pRedl, sal_False );
905 [ # # ][ # # ]: 0 : if( *pREnd != *pEnd )
906 : : {
907 [ # # ][ # # ]: 0 : pNew = new SwRedline( *pRedl );
908 [ # # ]: 0 : pNew->SetStart( *pEnd );
909 : : }
910 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
911 [ # # ][ # # ]: 0 : if( !pRedl->HasValidRange() )
912 : : {
913 : : // re-insert
914 [ # # ]: 0 : pRedlineTbl->Remove( n );
915 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
916 : : }
917 : : }
918 : : }
919 : 0 : break;
920 : :
921 : : case POS_OUTSIDE:
922 : : {
923 [ # # ]: 0 : pRedl->PushData( *pNewRedl );
924 [ # # ][ # # ]: 0 : if( *pEnd == *pREnd )
925 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
926 : : else
927 : : {
928 [ # # ][ # # ]: 0 : pNew = new SwRedline( *pNewRedl );
929 [ # # ]: 0 : pNew->SetEnd( *pRStt );
930 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
931 : : }
932 : 0 : bCompress = sal_True;
933 : : }
934 : 0 : break;
935 : :
936 : : case POS_OVERLAP_BEFORE:
937 : : {
938 [ # # ][ # # ]: 0 : if( *pEnd == *pREnd )
939 : : {
940 [ # # ]: 0 : pRedl->PushData( *pNewRedl );
941 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
942 [ # # ]: 0 : if( IsHideChanges( eRedlineMode ))
943 : : {
944 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
945 [ # # ]: 0 : pRedl->Hide();
946 [ # # ]: 0 : pRedlineTbl->Remove( pNewRedl );
947 : : }
948 : : }
949 : : else
950 : : {
951 [ # # ][ # # ]: 0 : pNew = new SwRedline( *pRedl );
952 [ # # ]: 0 : pNew->PushData( *pNewRedl );
953 [ # # ]: 0 : pNew->SetEnd( *pEnd );
954 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
955 [ # # ][ # # ]: 0 : pRedl->SetStart( *pNew->End(), pRStt ) ;
956 : : // re-insert
957 [ # # ]: 0 : pRedlineTbl->Remove( n );
958 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
959 : 0 : bDec = true;
960 : : }
961 : : }
962 : 0 : break;
963 : :
964 : : case POS_OVERLAP_BEHIND:
965 : : {
966 [ # # ][ # # ]: 0 : if( *pStt == *pRStt )
967 : : {
968 [ # # ]: 0 : pRedl->PushData( *pNewRedl );
969 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
970 [ # # ]: 0 : if( IsHideChanges( eRedlineMode ))
971 : : {
972 [ # # ]: 0 : pRedlineTbl->Insert( pNewRedl );
973 [ # # ]: 0 : pRedl->Hide();
974 [ # # ]: 0 : pRedlineTbl->Remove( pNewRedl );
975 : : }
976 : : }
977 : : else
978 : : {
979 [ # # ][ # # ]: 0 : pNew = new SwRedline( *pRedl );
980 [ # # ]: 0 : pNew->PushData( *pNewRedl );
981 [ # # ]: 0 : pNew->SetStart( *pStt );
982 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
983 [ # # ][ # # ]: 0 : pRedl->SetEnd( *pNew->Start(), pREnd );
984 [ # # ][ # # ]: 0 : if( !pRedl->HasValidRange() )
985 : : {
986 : : // re-insert
987 [ # # ]: 0 : pRedlineTbl->Remove( n );
988 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
989 : : }
990 : : }
991 : : }
992 : 0 : break;
993 : : default:
994 : 0 : break;
995 : : }
996 : :
997 : : // insert the pNew part (if it exists)
998 [ # # ]: 0 : if( pNew )
999 : : {
1000 [ # # ]: 0 : pRedlineTbl->Insert( pNew );
1001 : :
1002 : : // pNew must be deleted if Insert() wasn't
1003 : : // successful. But that can't happen, since pNew is
1004 : : // part of the original pRedl redline.
1005 : : // OSL_ENSURE( bRet, "Can't insert existing redline?" );
1006 : :
1007 : : // restart (now with pRedl being split up)
1008 : 0 : n = 0;
1009 : 0 : bDec = true;
1010 : : }
1011 : : }
1012 : : }
1013 : 0 : break;
1014 : :
1015 : : case nsRedlineType_t::REDLINE_FORMAT:
1016 [ # # # # : 0 : switch( eCmpPos )
# ]
1017 : : {
1018 : : case POS_OVERLAP_BEFORE:
1019 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
1020 : : // re-insert
1021 [ # # ]: 0 : pRedlineTbl->Remove( n );
1022 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
1023 : 0 : bDec = true;
1024 : 0 : break;
1025 : :
1026 : : case POS_OVERLAP_BEHIND:
1027 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1028 : 0 : break;
1029 : :
1030 : : case POS_EQUAL:
1031 : : case POS_OUTSIDE:
1032 : : // Overlaps the current one completely or has the
1033 : : // same dimension, delete the old one
1034 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1035 : 0 : bDec = true;
1036 : 0 : break;
1037 : :
1038 : : case POS_INSIDE:
1039 : : // Overlaps the current one completely,
1040 : : // split or shorten the new one
1041 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
1042 : : {
1043 [ # # ][ # # ]: 0 : if( *pEnd != *pRStt )
1044 : : {
1045 [ # # ][ # # ]: 0 : SwRedline* pNew = new SwRedline( *pRedl );
1046 [ # # ]: 0 : pNew->SetStart( *pEnd );
1047 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1048 [ # # ]: 0 : if( ( *pStt == *pRStt ) &&
[ # # # # ]
[ # # ]
1049 : 0 : ( pRedl->GetContentIdx() == NULL ) )
1050 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1051 [ # # ]: 0 : AppendRedline( pNew, bCallDelete );
1052 : 0 : n = 0; // re-initialize
1053 : 0 : bDec = true;
1054 : : }
1055 : : }
1056 : : else
1057 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1058 : 0 : break;
1059 : : default:
1060 : 0 : break;
1061 : : }
1062 : 0 : break;
1063 : : default:
1064 : 0 : break;
1065 : : }
1066 : 0 : break;
1067 : :
1068 : : case nsRedlineType_t::REDLINE_FORMAT:
1069 [ # # ]: 0 : switch( pRedl->GetType() )
[ # # # ]
1070 : : {
1071 : : case nsRedlineType_t::REDLINE_INSERT:
1072 : : case nsRedlineType_t::REDLINE_DELETE:
1073 [ # # # # : 0 : switch( eCmpPos )
# ]
1074 : : {
1075 : : case POS_OVERLAP_BEFORE:
1076 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
1077 : 0 : break;
1078 : :
1079 : : case POS_OVERLAP_BEHIND:
1080 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
1081 : 0 : break;
1082 : :
1083 : : case POS_EQUAL:
1084 : : case POS_INSIDE:
1085 [ # # ][ # # ]: 0 : delete pNewRedl, pNewRedl = 0;
1086 : 0 : break;
1087 : :
1088 : : case POS_OUTSIDE:
1089 : : // Overlaps the current one completely,
1090 : : // split or shorten the new one
1091 [ # # ][ # # ]: 0 : if( *pEnd != *pREnd )
1092 : : {
1093 [ # # ][ # # ]: 0 : if( *pEnd != *pRStt )
1094 : : {
1095 [ # # ][ # # ]: 0 : SwRedline* pNew = new SwRedline( *pNewRedl );
1096 [ # # ]: 0 : pNew->SetStart( *pREnd );
1097 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
1098 [ # # ]: 0 : AppendRedline( pNew, bCallDelete );
1099 : 0 : n = 0; // re-initialize
1100 : 0 : bDec = true;
1101 : : }
1102 : : }
1103 : : else
1104 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
1105 : 0 : break;
1106 : : default:
1107 : 0 : break;
1108 : : }
1109 : 0 : break;
1110 : : case nsRedlineType_t::REDLINE_FORMAT:
1111 [ # # # # : 0 : switch( eCmpPos )
# # ]
1112 : : {
1113 : : case POS_OUTSIDE:
1114 : : case POS_EQUAL:
1115 : : {
1116 : : // Overlaps the current one completely or has the
1117 : : // same dimension, delete the old one
1118 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1119 : 0 : bDec = true;
1120 : : }
1121 : 0 : break;
1122 : :
1123 : : case POS_INSIDE:
1124 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # ][ # # ]
1125 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ))
1126 : : // own one can be ignored completely
1127 [ # # ][ # # ]: 0 : delete pNewRedl, pNewRedl = 0;
1128 : :
1129 [ # # ][ # # ]: 0 : else if( *pREnd == *pEnd )
1130 : : // or else only shorten the current one
1131 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1132 [ # # ][ # # ]: 0 : else if( *pRStt == *pStt )
1133 : : {
1134 : : // or else only shorten the current one
1135 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
1136 : : // re-insert
1137 [ # # ]: 0 : pRedlineTbl->Remove( n );
1138 [ # # ]: 0 : pRedlineTbl->Insert( pRedl, n );
1139 : 0 : bDec = true;
1140 : : }
1141 : : else
1142 : : {
1143 : : // If it lies completely within the current one
1144 : : // we need to split it
1145 [ # # ][ # # ]: 0 : SwRedline* pNew = new SwRedline( *pRedl );
1146 [ # # ]: 0 : pNew->SetStart( *pEnd );
1147 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1148 [ # # ]: 0 : AppendRedline( pNew, bCallDelete );
1149 : 0 : n = 0; // re-initialize
1150 : 0 : bDec = true;
1151 : : }
1152 : 0 : break;
1153 : :
1154 : : case POS_OVERLAP_BEFORE:
1155 : : case POS_OVERLAP_BEHIND:
1156 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # ][ # # ]
1157 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ))
1158 : : {
1159 : : // If that's the case we can merge it, meaning
1160 : : // the new one covers this well
1161 [ # # ]: 0 : if( POS_OVERLAP_BEHIND == eCmpPos )
1162 [ # # ]: 0 : pNewRedl->SetStart( *pRStt, pStt );
1163 : : else
1164 [ # # ]: 0 : pNewRedl->SetEnd( *pREnd, pEnd );
1165 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1166 : 0 : bDec = 0;
1167 : : }
1168 [ # # ]: 0 : else if( POS_OVERLAP_BEHIND == eCmpPos )
1169 [ # # ]: 0 : pNewRedl->SetStart( *pREnd, pStt );
1170 : : else
1171 [ # # ]: 0 : pNewRedl->SetEnd( *pRStt, pEnd );
1172 : 0 : break;
1173 : :
1174 : : case POS_COLLIDE_END:
1175 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # ][ # # ]
[ # # ][ # # ]
1176 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ) && n &&
1177 [ # # ][ # # ]: 0 : *(*pRedlineTbl)[ n-1 ]->End() < *pStt )
[ # # ]
1178 : : {
1179 : : // If that's the case we can merge it, meaning
1180 : : // the new one covers this well
1181 [ # # ]: 0 : pNewRedl->SetEnd( *pREnd, pEnd );
1182 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1183 : 0 : bDec = true;
1184 : : }
1185 : 0 : break;
1186 : : case POS_COLLIDE_START:
1187 [ # # ][ # # ]: 0 : if( pRedl->IsOwnRedline( *pNewRedl ) &&
[ # # # # ]
[ # # ][ # # ]
1188 [ # # ]: 0 : pRedl->CanCombine( *pNewRedl ) &&
1189 : 0 : n+1 < (sal_uInt16)pRedlineTbl->size() &&
1190 [ # # ][ # # ]: 0 : *(*pRedlineTbl)[ n+1 ]->Start() < *pEnd )
[ # # ]
1191 : : {
1192 : : // If that's the case we can merge it, meaning
1193 : : // the new one covers this well
1194 [ # # ]: 0 : pNewRedl->SetStart( *pRStt, pStt );
1195 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1196 : 0 : bDec = true;
1197 : : }
1198 : 0 : break;
1199 : : default:
1200 : 0 : break;
1201 : : }
1202 : 0 : break;
1203 : : default:
1204 : 0 : break;
1205 : : }
1206 : 0 : break;
1207 : :
1208 : :
1209 : : case nsRedlineType_t::REDLINE_FMTCOLL:
1210 : : // How should we behave here?
1211 : : // insert as is
1212 : 0 : break;
1213 : : default:
1214 : 0 : break;
1215 : : }
1216 : : }
1217 : :
1218 [ + + ]: 1371 : if( pNewRedl )
1219 : : {
1220 [ + - ]: 934 : if( ( *pStt == *pEnd ) &&
[ - + # # ]
[ - + ]
1221 : 0 : ( pNewRedl->GetContentIdx() == NULL ) )
1222 : : { // Do not insert empty redlines
1223 [ # # ][ # # ]: 0 : delete pNewRedl;
1224 : 0 : pNewRedl = 0;
1225 : : }
1226 : : else
1227 [ + - ]: 934 : pRedlineTbl->Insert( pNewRedl );
1228 : : }
1229 : :
1230 [ + + ]: 1371 : if( bCompress )
1231 [ + - ]: 1371 : CompressRedlines();
1232 : : }
1233 : : else
1234 : : {
1235 [ + - ][ - + ]: 768 : if( bCallDelete && nsRedlineType_t::REDLINE_DELETE == pNewRedl->GetType() )
[ - + ]
1236 : : {
1237 : 0 : RedlineMode_t eOld = eRedlineMode;
1238 : : // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
1239 : : // The ShowMode needs to be retained!
1240 : 0 : eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
1241 : 0 : DeleteAndJoin( *pNewRedl );
1242 : 0 : eRedlineMode = eOld;
1243 : : }
1244 [ + - ]: 768 : delete pNewRedl, pNewRedl = 0;
1245 : : }
1246 : : _CHECK_REDLINE( this )
1247 : :
1248 [ + + ][ + + ]: 2334 : return ( 0 != pNewRedl ) || !bError;
1249 : : }
1250 : :
1251 : 445 : void SwDoc::CompressRedlines()
1252 : : {
1253 : : _CHECK_REDLINE( this )
1254 : :
1255 : 445 : void (SwRedline::*pFnc)(sal_uInt16) = 0;
1256 [ + + - ]: 445 : switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode )
1257 : : {
1258 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE:
1259 : 150 : pFnc = &SwRedline::Show;
1260 : 150 : break;
1261 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT:
1262 : 295 : pFnc = &SwRedline::Hide;
1263 : 295 : break;
1264 : : }
1265 : :
1266 : : // Try to merge identical ones
1267 [ + + ]: 3878 : for( sal_uInt16 n = 1; n < pRedlineTbl->size(); ++n )
1268 : : {
1269 [ + - ]: 3433 : SwRedline* pPrev = (*pRedlineTbl)[ n-1 ],
1270 [ + - ]: 3433 : * pCur = (*pRedlineTbl)[ n ];
1271 [ + - ]: 3433 : const SwPosition* pPrevStt = pPrev->Start(),
1272 : 3433 : * pPrevEnd = pPrevStt == pPrev->GetPoint()
1273 [ - + ]: 3433 : ? pPrev->GetMark() : pPrev->GetPoint();
1274 [ + - ]: 3433 : const SwPosition* pCurStt = pCur->Start(),
1275 : 3433 : * pCurEnd = pCurStt == pCur->GetPoint()
1276 [ - + ]: 3433 : ? pCur->GetMark() : pCur->GetPoint();
1277 [ + - ][ + + ]: 3433 : if( *pPrevEnd == *pCurStt && pPrev->CanCombine( *pCur ) &&
[ + - ][ - +
# # # # ]
[ - + ]
1278 : 0 : pPrevStt->nNode.GetNode().StartOfSectionNode() ==
1279 : 0 : pCurEnd->nNode.GetNode().StartOfSectionNode() &&
1280 : 0 : !pCurEnd->nNode.GetNode().StartOfSectionNode()->IsTableNode() )
1281 : : {
1282 : : // we then can merge them
1283 [ # # ]: 0 : pPrev->Show();
1284 [ # # ]: 0 : pCur->Show();
1285 : :
1286 [ # # ][ # # ]: 0 : pPrev->SetEnd( *pCur->End() );
1287 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n );
1288 : 0 : --n;
1289 [ # # ]: 0 : if( pFnc )
1290 [ # # ][ # # ]: 0 : (pPrev->*pFnc)(0);
1291 : : }
1292 : : }
1293 : : _CHECK_REDLINE( this )
1294 : 445 : }
1295 : :
1296 : 0 : bool SwDoc::SplitRedline( const SwPaM& rRange )
1297 : : {
1298 : 0 : sal_Bool bChg = sal_False;
1299 : 0 : sal_uInt16 n = 0;
1300 [ # # ]: 0 : const SwPosition* pStt = rRange.Start(),
1301 : 0 : * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
1302 [ # # ]: 0 : : rRange.GetPoint();
1303 [ # # ]: 0 : GetRedline( *pStt, &n );
1304 [ # # ]: 0 : for( ; n < pRedlineTbl->size() ; ++n )
1305 : : {
1306 [ # # ]: 0 : SwRedline* pTmp = (*pRedlineTbl)[ n ];
1307 [ # # ]: 0 : SwPosition* pTStt = pTmp->Start(),
1308 : 0 : * pTEnd = pTStt == pTmp->GetPoint() ? pTmp->GetMark()
1309 [ # # ]: 0 : : pTmp->GetPoint();
1310 [ # # ][ # # ]: 0 : if( *pTStt <= *pStt && *pStt <= *pTEnd &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1311 [ # # ][ # # ]: 0 : *pTStt <= *pEnd && *pEnd <= *pTEnd )
1312 : : {
1313 : 0 : bChg = sal_True;
1314 : 0 : int nn = 0;
1315 [ # # ][ # # ]: 0 : if( *pStt == *pTStt )
1316 : 0 : nn += 1;
1317 [ # # ][ # # ]: 0 : if( *pEnd == *pTEnd )
1318 : 0 : nn += 2;
1319 : :
1320 : 0 : SwRedline* pNew = 0;
1321 [ # # # # : 0 : switch( nn )
# ]
1322 : : {
1323 : : case 0:
1324 [ # # ][ # # ]: 0 : pNew = new SwRedline( *pTmp );
1325 [ # # ]: 0 : pTmp->SetEnd( *pStt, pTEnd );
1326 [ # # ]: 0 : pNew->SetStart( *pEnd );
1327 : 0 : break;
1328 : :
1329 : : case 1:
1330 [ # # ]: 0 : *pTStt = *pEnd;
1331 : 0 : break;
1332 : :
1333 : : case 2:
1334 [ # # ]: 0 : *pTEnd = *pStt;
1335 : 0 : break;
1336 : :
1337 : : case 3:
1338 [ # # ]: 0 : pTmp->InvalidateRange();
1339 [ # # ]: 0 : pRedlineTbl->DeleteAndDestroy( n-- );
1340 : 0 : pTmp = 0;
1341 : 0 : break;
1342 : : }
1343 [ # # ][ # # ]: 0 : if( pTmp && !pTmp->HasValidRange() )
[ # # ][ # # ]
1344 : : {
1345 : : // re-insert
1346 [ # # ]: 0 : pRedlineTbl->Remove( n );
1347 [ # # ]: 0 : pRedlineTbl->Insert( pTmp, n );
1348 : : }
1349 [ # # ]: 0 : if( pNew )
1350 [ # # ]: 0 : pRedlineTbl->Insert( pNew, n );
1351 : : }
1352 [ # # ][ # # ]: 0 : else if( *pEnd < *pTStt )
1353 : 0 : break;
1354 : : }
1355 : 0 : return bChg;
1356 : : }
1357 : :
1358 : 804 : bool SwDoc::DeleteRedline( const SwPaM& rRange, bool bSaveInUndo,
1359 : : sal_uInt16 nDelType )
1360 : : {
1361 [ + - + - ]: 2412 : if( nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES & eRedlineMode ||
[ - + ][ - + ]
1362 [ + - ]: 1608 : !rRange.HasMark() || *rRange.GetMark() == *rRange.GetPoint() )
1363 : 0 : return sal_False;
1364 : :
1365 : 804 : sal_Bool bChg = sal_False;
1366 : :
1367 [ + - ][ + - ]: 804 : if (bSaveInUndo && GetIDocumentUndoRedo().DoesUndo())
[ + - ][ + + ]
[ + + ]
1368 : : {
1369 [ + - ][ + - ]: 8 : SwUndoRedline* pUndo = new SwUndoRedline( UNDO_REDLINE, rRange );
1370 [ + - ][ - + ]: 8 : if( pUndo->GetRedlSaveCount() )
1371 : : {
1372 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
1373 : : }
1374 : : else
1375 [ + - ][ + - ]: 8 : delete pUndo;
1376 : : }
1377 : :
1378 [ + - ]: 804 : const SwPosition* pStt = rRange.Start(),
1379 : 804 : * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
1380 [ + + ]: 804 : : rRange.GetPoint();
1381 : 804 : sal_uInt16 n = 0;
1382 [ + - ]: 804 : GetRedline( *pStt, &n );
1383 [ + + ]: 1656 : for( ; n < pRedlineTbl->size() ; ++n )
1384 : : {
1385 [ + - ]: 852 : SwRedline* pRedl = (*pRedlineTbl)[ n ];
1386 [ - + ][ # # ]: 852 : if( USHRT_MAX != nDelType && nDelType != pRedl->GetType() )
[ # # ][ - + ]
1387 : 0 : continue;
1388 : :
1389 [ + - ]: 852 : SwPosition* pRStt = pRedl->Start(),
1390 : 852 : * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
1391 [ - + ]: 852 : : pRedl->GetPoint();
1392 [ + - ][ + - : 852 : switch( ComparePosition( *pStt, *pEnd, *pRStt, *pREnd ) )
- - - - ]
1393 : : {
1394 : : case POS_EQUAL:
1395 : : case POS_OUTSIDE:
1396 [ + - ]: 852 : pRedl->InvalidateRange();
1397 [ + - ]: 852 : pRedlineTbl->DeleteAndDestroy( n-- );
1398 : 852 : bChg = sal_True;
1399 : 852 : break;
1400 : :
1401 : : case POS_OVERLAP_BEFORE:
1402 [ # # ]: 0 : pRedl->InvalidateRange();
1403 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
1404 : : // re-insert
1405 [ # # ]: 0 : pRedlineTbl->Remove( n );
1406 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
1407 : 0 : --n;
1408 : 0 : break;
1409 : :
1410 : : case POS_OVERLAP_BEHIND:
1411 [ # # ]: 0 : pRedl->InvalidateRange();
1412 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1413 [ # # ][ # # ]: 0 : if( !pRedl->HasValidRange() )
1414 : : {
1415 : : // re-insert
1416 [ # # ]: 0 : pRedlineTbl->Remove( n );
1417 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
1418 : 0 : --n;
1419 : : }
1420 : 0 : break;
1421 : :
1422 : : case POS_INSIDE:
1423 : : {
1424 : : // this one needs to be splitted
1425 [ # # ]: 0 : pRedl->InvalidateRange();
1426 [ # # ][ # # ]: 0 : if( *pRStt == *pStt )
1427 : : {
1428 [ # # ]: 0 : pRedl->SetStart( *pEnd, pRStt );
1429 : : // re-insert
1430 [ # # ]: 0 : pRedlineTbl->Remove( n );
1431 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
1432 : 0 : --n;
1433 : : }
1434 : : else
1435 : : {
1436 : : SwRedline* pCpy;
1437 [ # # ][ # # ]: 0 : if( *pREnd != *pEnd )
1438 : : {
1439 [ # # ][ # # ]: 0 : pCpy = new SwRedline( *pRedl );
1440 [ # # ]: 0 : pCpy->SetStart( *pEnd );
1441 : : }
1442 : : else
1443 : 0 : pCpy = 0;
1444 [ # # ]: 0 : pRedl->SetEnd( *pStt, pREnd );
1445 [ # # ][ # # ]: 0 : if( !pRedl->HasValidRange() )
1446 : : {
1447 : : // re-insert
1448 [ # # ]: 0 : pRedlineTbl->Remove( pRedl );
1449 [ # # ]: 0 : pRedlineTbl->Insert( pRedl );
1450 : 0 : --n;
1451 : : }
1452 [ # # ]: 0 : if( pCpy )
1453 [ # # ]: 0 : pRedlineTbl->Insert( pCpy );
1454 : : }
1455 : : }
1456 : 0 : break;
1457 : :
1458 : : case POS_COLLIDE_END:
1459 : : case POS_BEFORE:
1460 : 0 : n = pRedlineTbl->size();
1461 : 0 : break;
1462 : : default:
1463 : 0 : break;
1464 : : }
1465 : : }
1466 : :
1467 [ + + ]: 804 : if( bChg )
1468 [ + - ]: 90 : SetModified();
1469 : :
1470 : 804 : return bChg;
1471 : : }
1472 : :
1473 : 128 : bool SwDoc::DeleteRedline( const SwStartNode& rNode, bool bSaveInUndo,
1474 : : sal_uInt16 nDelType )
1475 : : {
1476 [ + - ]: 128 : SwPaM aTemp(*rNode.EndOfSectionNode(), rNode);
1477 [ + - ][ + - ]: 128 : return DeleteRedline(aTemp, bSaveInUndo, nDelType);
1478 : : }
1479 : :
1480 : 140335 : sal_uInt16 SwDoc::GetRedlinePos( const SwNode& rNd, sal_uInt16 nType ) const
1481 : : {
1482 : 140335 : const sal_uLong nNdIdx = rNd.GetIndex();
1483 [ + + ]: 140335 : for( sal_uInt16 n = 0; n < pRedlineTbl->size() ; ++n )
1484 : : {
1485 : 15 : const SwRedline* pTmp = (*pRedlineTbl)[ n ];
1486 : 15 : sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
1487 : 15 : nMk = pTmp->GetMark()->nNode.GetIndex();
1488 [ - + ]: 15 : if( nPt < nMk ) { long nTmp = nMk; nMk = nPt; nPt = nTmp; }
1489 : :
1490 [ - + ][ # # ]: 15 : if( ( USHRT_MAX == nType || nType == pTmp->GetType()) &&
[ + - ][ + - ]
[ + - ]
1491 : : nMk <= nNdIdx && nNdIdx <= nPt )
1492 : 15 : return n;
1493 : :
1494 [ # # ]: 0 : if( nMk > nNdIdx )
1495 : 0 : break;
1496 : : }
1497 : 140335 : return USHRT_MAX;
1498 : : }
1499 : :
1500 : 2302 : const SwRedline* SwDoc::GetRedline( const SwPosition& rPos,
1501 : : sal_uInt16* pFndPos ) const
1502 : : {
1503 : 2302 : sal_uInt16 nO = pRedlineTbl->size(), nM, nU = 0;
1504 [ + + ]: 2302 : if( nO > 0 )
1505 : : {
1506 : 1942 : nO--;
1507 [ + + ]: 8187 : while( nU <= nO )
1508 : : {
1509 : 6335 : nM = nU + ( nO - nU ) / 2;
1510 : 6335 : const SwRedline* pRedl = (*pRedlineTbl)[ nM ];
1511 : 6335 : const SwPosition* pStt = pRedl->Start();
1512 : 6335 : const SwPosition* pEnd = pStt == pRedl->GetPoint()
1513 : 0 : ? pRedl->GetMark()
1514 [ - + ]: 6335 : : pRedl->GetPoint();
1515 [ + + ]: 6335 : if( pEnd == pStt
1516 : 0 : ? *pStt == rPos
1517 [ - + ][ + + ]: 6335 : : ( *pStt <= rPos && rPos < *pEnd ) )
[ + + ]
1518 : : {
1519 [ - + ]: 14 : while( nM && rPos == *(*pRedlineTbl)[ nM - 1 ]->End() &&
[ # # # # ]
[ - + ]
1520 : 0 : rPos == *(*pRedlineTbl)[ nM - 1 ]->Start() )
1521 : : {
1522 : 0 : --nM;
1523 : 0 : pRedl = (*pRedlineTbl)[ nM ];
1524 : : }
1525 : : // if there are format and insert changes in the same position
1526 : : // show insert change first.
1527 : : // since the redlines are sorted by position, only check the redline
1528 : : // before and after the current redline
1529 [ - + ]: 14 : if( nsRedlineType_t::REDLINE_FORMAT == pRedl->GetType() )
1530 : : {
1531 [ # # ][ # # : 0 : if( nM && rPos >= *(*pRedlineTbl)[ nM - 1 ]->Start() &&
# # # # ]
[ # # ]
1532 : 0 : rPos <= *(*pRedlineTbl)[ nM - 1 ]->End() &&
1533 : 0 : ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM - 1 ]->GetType() ) )
1534 : : {
1535 : 0 : --nM;
1536 : 0 : pRedl = (*pRedlineTbl)[ nM ];
1537 : : }
1538 [ # # ][ # # : 0 : else if( ( nM + 1 ) <= nO && rPos >= *(*pRedlineTbl)[ nM + 1 ]->Start() &&
# # # # ]
[ # # ]
1539 : 0 : rPos <= *(*pRedlineTbl)[ nM + 1 ]->End() &&
1540 : 0 : ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM + 1 ]->GetType() ) )
1541 : : {
1542 : 0 : ++nM;
1543 : 0 : pRedl = (*pRedlineTbl)[ nM ];
1544 : : }
1545 : : }
1546 : :
1547 [ + - ]: 14 : if( pFndPos )
1548 : 14 : *pFndPos = nM;
1549 : 14 : return pRedl;
1550 : : }
1551 [ + + ]: 6321 : else if( *pEnd <= rPos )
1552 : 6112 : nU = nM + 1;
1553 [ + + ]: 209 : else if( nM == 0 )
1554 : : {
1555 [ + - ]: 76 : if( pFndPos )
1556 : 76 : *pFndPos = nU;
1557 : 76 : return 0;
1558 : : }
1559 : : else
1560 : 133 : nO = nM - 1;
1561 : : }
1562 : : }
1563 [ + + ]: 2212 : if( pFndPos )
1564 : 2131 : *pFndPos = nU;
1565 : 2302 : return 0;
1566 : : }
1567 : :
1568 : : typedef sal_Bool (*Fn_AcceptReject)( SwRedlineTbl& rArr, sal_uInt16& rPos,
1569 : : sal_Bool bCallDelete,
1570 : : const SwPosition* pSttRng,
1571 : : const SwPosition* pEndRng);
1572 : :
1573 : 0 : sal_Bool lcl_AcceptRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
1574 : : sal_Bool bCallDelete,
1575 : : const SwPosition* pSttRng = 0,
1576 : : const SwPosition* pEndRng = 0 )
1577 : : {
1578 : 0 : sal_Bool bRet = sal_True;
1579 : 0 : SwRedline* pRedl = rArr[ rPos ];
1580 : 0 : SwPosition *pRStt = 0, *pREnd = 0;
1581 : 0 : SwComparePosition eCmp = POS_OUTSIDE;
1582 [ # # ][ # # ]: 0 : if( pSttRng && pEndRng )
1583 : : {
1584 : 0 : pRStt = pRedl->Start();
1585 : 0 : pREnd = pRedl->End();
1586 : 0 : eCmp = ComparePosition( *pSttRng, *pEndRng, *pRStt, *pREnd );
1587 : : }
1588 : :
1589 : 0 : pRedl->InvalidateRange();
1590 : :
1591 [ # # # # ]: 0 : switch( pRedl->GetType() )
1592 : : {
1593 : : case nsRedlineType_t::REDLINE_INSERT:
1594 : : case nsRedlineType_t::REDLINE_FORMAT:
1595 : : {
1596 : 0 : sal_Bool bCheck = sal_False, bReplace = sal_False;
1597 [ # # # # : 0 : switch( eCmp )
# ]
1598 : : {
1599 : : case POS_INSIDE:
1600 [ # # ]: 0 : if( *pSttRng == *pRStt )
1601 : 0 : pRedl->SetStart( *pEndRng, pRStt );
1602 : : else
1603 : : {
1604 [ # # ]: 0 : if( *pEndRng != *pREnd )
1605 : : {
1606 : : // split up
1607 [ # # ]: 0 : SwRedline* pNew = new SwRedline( *pRedl );
1608 : 0 : pNew->SetStart( *pEndRng );
1609 : 0 : rArr.Insert( pNew ); ++rPos;
1610 : : }
1611 : 0 : pRedl->SetEnd( *pSttRng, pREnd );
1612 : 0 : bCheck = sal_True;
1613 : : }
1614 : 0 : break;
1615 : :
1616 : : case POS_OVERLAP_BEFORE:
1617 : 0 : pRedl->SetStart( *pEndRng, pRStt );
1618 : 0 : bReplace = sal_True;
1619 : 0 : break;
1620 : :
1621 : : case POS_OVERLAP_BEHIND:
1622 : 0 : pRedl->SetEnd( *pSttRng, pREnd );
1623 : 0 : bCheck = sal_True;
1624 : 0 : break;
1625 : :
1626 : : case POS_OUTSIDE:
1627 : : case POS_EQUAL:
1628 : 0 : rArr.DeleteAndDestroy( rPos-- );
1629 : 0 : break;
1630 : :
1631 : : default:
1632 : 0 : bRet = sal_False;
1633 : : }
1634 : :
1635 [ # # ][ # # ]: 0 : if( bReplace || ( bCheck && !pRedl->HasValidRange() ))
[ # # ][ # # ]
1636 : : {
1637 : : // re-insert
1638 : 0 : rArr.Remove( pRedl );
1639 : 0 : rArr.Insert( pRedl );
1640 : : }
1641 : : }
1642 : 0 : break;
1643 : : case nsRedlineType_t::REDLINE_DELETE:
1644 : : {
1645 : 0 : SwDoc& rDoc = *pRedl->GetDoc();
1646 : 0 : const SwPosition *pDelStt = 0, *pDelEnd = 0;
1647 : 0 : sal_Bool bDelRedl = sal_False;
1648 [ # # # # : 0 : switch( eCmp )
# ]
1649 : : {
1650 : : case POS_INSIDE:
1651 [ # # ]: 0 : if( bCallDelete )
1652 : : {
1653 : 0 : pDelStt = pSttRng;
1654 : 0 : pDelEnd = pEndRng;
1655 : : }
1656 : 0 : break;
1657 : :
1658 : : case POS_OVERLAP_BEFORE:
1659 [ # # ]: 0 : if( bCallDelete )
1660 : : {
1661 : 0 : pDelStt = pRStt;
1662 : 0 : pDelEnd = pEndRng;
1663 : : }
1664 : 0 : break;
1665 : : case POS_OVERLAP_BEHIND:
1666 [ # # ]: 0 : if( bCallDelete )
1667 : : {
1668 : 0 : pDelStt = pREnd;
1669 : 0 : pDelEnd = pSttRng;
1670 : : }
1671 : 0 : break;
1672 : :
1673 : : case POS_OUTSIDE:
1674 : : case POS_EQUAL:
1675 : : {
1676 : 0 : rArr.Remove( rPos-- );
1677 : 0 : bDelRedl = sal_True;
1678 [ # # ]: 0 : if( bCallDelete )
1679 : : {
1680 : 0 : pDelStt = pRedl->Start();
1681 : 0 : pDelEnd = pRedl->End();
1682 : : }
1683 : : }
1684 : 0 : break;
1685 : : default:
1686 : 0 : bRet = sal_False;
1687 : : }
1688 : :
1689 [ # # ][ # # ]: 0 : if( pDelStt && pDelEnd )
1690 : : {
1691 [ # # ]: 0 : SwPaM aPam( *pDelStt, *pDelEnd );
1692 : 0 : SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();
1693 : 0 : SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode();
1694 : :
1695 [ # # ]: 0 : if( bDelRedl )
1696 [ # # ][ # # ]: 0 : delete pRedl;
1697 : :
1698 [ # # ]: 0 : RedlineMode_t eOld = rDoc.GetRedlineMode();
1699 [ # # ]: 0 : rDoc.SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
1700 : :
1701 [ # # ][ # # ]: 0 : if( pCSttNd && pCEndNd )
1702 [ # # ]: 0 : rDoc.DeleteAndJoin( aPam );
1703 : : else
1704 : : {
1705 [ # # ]: 0 : rDoc.DeleteRange( aPam );
1706 : :
1707 [ # # ][ # # ]: 0 : if( pCSttNd && !pCEndNd )
1708 : : {
1709 [ # # ]: 0 : aPam.GetBound( sal_True ).nContent.Assign( 0, 0 );
1710 [ # # ]: 0 : aPam.GetBound( sal_False ).nContent.Assign( 0, 0 );
1711 [ # # ]: 0 : aPam.DeleteMark();
1712 [ # # ]: 0 : rDoc.DelFullPara( aPam );
1713 : : }
1714 : : }
1715 [ # # ][ # # ]: 0 : rDoc.SetRedlineMode_intern( eOld );
1716 : : }
1717 [ # # ]: 0 : else if( bDelRedl )
1718 [ # # ]: 0 : delete pRedl;
1719 : : }
1720 : 0 : break;
1721 : :
1722 : : case nsRedlineType_t::REDLINE_FMTCOLL:
1723 : 0 : rArr.DeleteAndDestroy( rPos-- );
1724 : 0 : break;
1725 : :
1726 : : default:
1727 : 0 : bRet = sal_False;
1728 : : }
1729 : 0 : return bRet;
1730 : : }
1731 : :
1732 : 0 : sal_Bool lcl_RejectRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
1733 : : sal_Bool bCallDelete,
1734 : : const SwPosition* pSttRng = 0,
1735 : : const SwPosition* pEndRng = 0 )
1736 : : {
1737 : 0 : sal_Bool bRet = sal_True;
1738 : 0 : SwRedline* pRedl = rArr[ rPos ];
1739 : 0 : SwPosition *pRStt = 0, *pREnd = 0;
1740 : 0 : SwComparePosition eCmp = POS_OUTSIDE;
1741 [ # # ][ # # ]: 0 : if( pSttRng && pEndRng )
1742 : : {
1743 : 0 : pRStt = pRedl->Start();
1744 : 0 : pREnd = pRedl->End();
1745 : 0 : eCmp = ComparePosition( *pSttRng, *pEndRng, *pRStt, *pREnd );
1746 : : }
1747 : :
1748 : 0 : pRedl->InvalidateRange();
1749 : :
1750 [ # # # # ]: 0 : switch( pRedl->GetType() )
1751 : : {
1752 : : case nsRedlineType_t::REDLINE_INSERT:
1753 : : {
1754 : 0 : SwDoc& rDoc = *pRedl->GetDoc();
1755 : 0 : const SwPosition *pDelStt = 0, *pDelEnd = 0;
1756 : 0 : sal_Bool bDelRedl = sal_False;
1757 [ # # # # : 0 : switch( eCmp )
# ]
1758 : : {
1759 : : case POS_INSIDE:
1760 [ # # ]: 0 : if( bCallDelete )
1761 : : {
1762 : 0 : pDelStt = pSttRng;
1763 : 0 : pDelEnd = pEndRng;
1764 : : }
1765 : 0 : break;
1766 : :
1767 : : case POS_OVERLAP_BEFORE:
1768 [ # # ]: 0 : if( bCallDelete )
1769 : : {
1770 : 0 : pDelStt = pRStt;
1771 : 0 : pDelEnd = pEndRng;
1772 : : }
1773 : 0 : break;
1774 : : case POS_OVERLAP_BEHIND:
1775 [ # # ]: 0 : if( bCallDelete )
1776 : : {
1777 : 0 : pDelStt = pREnd;
1778 : 0 : pDelEnd = pSttRng;
1779 : : }
1780 : 0 : break;
1781 : : case POS_OUTSIDE:
1782 : : case POS_EQUAL:
1783 : : {
1784 : : // delete the range again
1785 : 0 : rArr.Remove( rPos-- );
1786 : 0 : bDelRedl = sal_True;
1787 [ # # ]: 0 : if( bCallDelete )
1788 : : {
1789 : 0 : pDelStt = pRedl->Start();
1790 : 0 : pDelEnd = pRedl->End();
1791 : : }
1792 : : }
1793 : 0 : break;
1794 : :
1795 : : default:
1796 : 0 : bRet = sal_False;
1797 : : }
1798 [ # # ][ # # ]: 0 : if( pDelStt && pDelEnd )
1799 : : {
1800 [ # # ]: 0 : SwPaM aPam( *pDelStt, *pDelEnd );
1801 : :
1802 : 0 : SwCntntNode* pCSttNd = pDelStt->nNode.GetNode().GetCntntNode();
1803 : 0 : SwCntntNode* pCEndNd = pDelEnd->nNode.GetNode().GetCntntNode();
1804 : :
1805 [ # # ]: 0 : if( bDelRedl )
1806 [ # # ][ # # ]: 0 : delete pRedl;
1807 : :
1808 [ # # ]: 0 : RedlineMode_t eOld = rDoc.GetRedlineMode();
1809 [ # # ]: 0 : rDoc.SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
1810 : :
1811 [ # # ][ # # ]: 0 : if( pCSttNd && pCEndNd )
1812 [ # # ]: 0 : rDoc.DeleteAndJoin( aPam );
1813 : : else
1814 : : {
1815 [ # # ]: 0 : rDoc.DeleteRange( aPam );
1816 : :
1817 [ # # ][ # # ]: 0 : if( pCSttNd && !pCEndNd )
1818 : : {
1819 [ # # ]: 0 : aPam.GetBound( sal_True ).nContent.Assign( 0, 0 );
1820 [ # # ]: 0 : aPam.GetBound( sal_False ).nContent.Assign( 0, 0 );
1821 [ # # ]: 0 : aPam.DeleteMark();
1822 [ # # ]: 0 : rDoc.DelFullPara( aPam );
1823 : : }
1824 : : }
1825 [ # # ][ # # ]: 0 : rDoc.SetRedlineMode_intern( eOld );
1826 : : }
1827 [ # # ]: 0 : else if( bDelRedl )
1828 [ # # ]: 0 : delete pRedl;
1829 : : }
1830 : 0 : break;
1831 : : case nsRedlineType_t::REDLINE_DELETE:
1832 : : {
1833 : 0 : SwRedline* pNew = 0;
1834 : 0 : sal_Bool bCheck = sal_False, bReplace = sal_False;
1835 : :
1836 [ # # # # : 0 : switch( eCmp )
# ]
1837 : : {
1838 : : case POS_INSIDE:
1839 : : {
1840 [ # # ]: 0 : if( 1 < pRedl->GetStackCount() )
1841 : : {
1842 [ # # ]: 0 : pNew = new SwRedline( *pRedl );
1843 : 0 : pNew->PopData();
1844 : : }
1845 [ # # ]: 0 : if( *pSttRng == *pRStt )
1846 : : {
1847 : 0 : pRedl->SetStart( *pEndRng, pRStt );
1848 : 0 : bReplace = sal_True;
1849 [ # # ]: 0 : if( pNew )
1850 : 0 : pNew->SetEnd( *pEndRng );
1851 : : }
1852 : : else
1853 : : {
1854 [ # # ]: 0 : if( *pEndRng != *pREnd )
1855 : : {
1856 : : // split up
1857 [ # # ]: 0 : SwRedline* pCpy = new SwRedline( *pRedl );
1858 : 0 : pCpy->SetStart( *pEndRng );
1859 : 0 : rArr.Insert( pCpy ); ++rPos;
1860 [ # # ]: 0 : if( pNew )
1861 : 0 : pNew->SetEnd( *pEndRng );
1862 : : }
1863 : :
1864 : 0 : pRedl->SetEnd( *pSttRng, pREnd );
1865 : 0 : bCheck = sal_True;
1866 [ # # ]: 0 : if( pNew )
1867 : 0 : pNew->SetStart( *pSttRng );
1868 : : }
1869 : : }
1870 : 0 : break;
1871 : :
1872 : : case POS_OVERLAP_BEFORE:
1873 [ # # ]: 0 : if( 1 < pRedl->GetStackCount() )
1874 : : {
1875 [ # # ]: 0 : pNew = new SwRedline( *pRedl );
1876 : 0 : pNew->PopData();
1877 : : }
1878 : 0 : pRedl->SetStart( *pEndRng, pRStt );
1879 : 0 : bReplace = sal_True;
1880 [ # # ]: 0 : if( pNew )
1881 : 0 : pNew->SetEnd( *pEndRng );
1882 : 0 : break;
1883 : :
1884 : : case POS_OVERLAP_BEHIND:
1885 [ # # ]: 0 : if( 1 < pRedl->GetStackCount() )
1886 : : {
1887 [ # # ]: 0 : pNew = new SwRedline( *pRedl );
1888 : 0 : pNew->PopData();
1889 : : }
1890 : 0 : pRedl->SetEnd( *pSttRng, pREnd );
1891 : 0 : bCheck = sal_True;
1892 [ # # ]: 0 : if( pNew )
1893 : 0 : pNew->SetStart( *pSttRng );
1894 : 0 : break;
1895 : :
1896 : : case POS_OUTSIDE:
1897 : : case POS_EQUAL:
1898 [ # # ]: 0 : if( !pRedl->PopData() )
1899 : : // deleting the RedlineObject is enough
1900 : 0 : rArr.DeleteAndDestroy( rPos-- );
1901 : 0 : break;
1902 : :
1903 : : default:
1904 : 0 : bRet = sal_False;
1905 : : }
1906 : :
1907 [ # # ]: 0 : if( pNew )
1908 : : {
1909 : 0 : rArr.Insert( pNew ); ++rPos;
1910 : : }
1911 : :
1912 [ # # ][ # # ]: 0 : if( bReplace || ( bCheck && !pRedl->HasValidRange() ))
[ # # ][ # # ]
1913 : : {
1914 : : // re-insert
1915 : 0 : rArr.Remove( pRedl );
1916 : 0 : rArr.Insert( pRedl );
1917 : : }
1918 : : }
1919 : 0 : break;
1920 : :
1921 : : case nsRedlineType_t::REDLINE_FORMAT:
1922 : : case nsRedlineType_t::REDLINE_FMTCOLL:
1923 : : {
1924 [ # # ]: 0 : if( pRedl->GetExtraData() )
1925 : 0 : pRedl->GetExtraData()->Reject( *pRedl );
1926 : 0 : rArr.DeleteAndDestroy( rPos-- );
1927 : : }
1928 : 0 : break;
1929 : :
1930 : : default:
1931 : 0 : bRet = sal_False;
1932 : : }
1933 : 0 : return bRet;
1934 : : }
1935 : :
1936 : :
1937 : 0 : const SwRedline* lcl_FindCurrRedline( const SwPosition& rSttPos,
1938 : : sal_uInt16& rPos,
1939 : : sal_Bool bNext = sal_True )
1940 : : {
1941 : 0 : const SwRedline* pFnd = 0;
1942 : 0 : const SwRedlineTbl& rArr = rSttPos.nNode.GetNode().GetDoc()->GetRedlineTbl();
1943 [ # # ]: 0 : for( ; rPos < rArr.size() ; ++rPos )
1944 : : {
1945 : 0 : const SwRedline* pTmp = rArr[ rPos ];
1946 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
1947 : : {
1948 : 0 : const SwPosition* pRStt = pTmp->Start(),
1949 : 0 : * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark()
1950 [ # # ]: 0 : : pTmp->GetPoint();
1951 [ # # ][ # # ]: 0 : if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos )
1952 : : {
1953 [ # # ][ # # ]: 0 : if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos )
1954 : : {
1955 : 0 : pFnd = pTmp;
1956 : 0 : break;
1957 : : }
1958 : : }
1959 : : else
1960 : 0 : break;
1961 : : }
1962 : : }
1963 : 0 : return pFnd;
1964 : : }
1965 : :
1966 : 0 : int lcl_AcceptRejectRedl( Fn_AcceptReject fn_AcceptReject,
1967 : : SwRedlineTbl& rArr, sal_Bool bCallDelete,
1968 : : const SwPaM& rPam)
1969 : : {
1970 : 0 : sal_uInt16 n = 0;
1971 : 0 : int nCount = 0;
1972 : :
1973 [ # # ]: 0 : const SwPosition* pStt = rPam.Start(),
1974 : 0 : * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
1975 [ # # ]: 0 : : rPam.GetPoint();
1976 [ # # ]: 0 : const SwRedline* pFnd = lcl_FindCurrRedline( *pStt, n, sal_True );
1977 [ # # ][ # # ]: 0 : if( pFnd && // Is new a part of it?
[ # # ][ # # ]
1978 [ # # ][ # # ]: 0 : ( *pFnd->Start() != *pStt || *pFnd->End() > *pEnd ))
[ # # ][ # # ]
1979 : : {
1980 : : // Only revoke the partial selection
1981 [ # # ][ # # ]: 0 : if( (*fn_AcceptReject)( rArr, n, bCallDelete, pStt, pEnd ))
1982 : 0 : nCount++;
1983 : 0 : ++n;
1984 : : }
1985 : :
1986 [ # # ]: 0 : for( ; n < rArr.size(); ++n )
1987 : : {
1988 [ # # ]: 0 : SwRedline* pTmp = rArr[ n ];
1989 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
1990 : : {
1991 [ # # ][ # # ]: 0 : if( *pTmp->End() <= *pEnd )
[ # # ]
1992 : : {
1993 [ # # ][ # # ]: 0 : if( (*fn_AcceptReject)( rArr, n, bCallDelete, 0, 0 ))
1994 : 0 : nCount++;
1995 : : }
1996 : : else
1997 : : {
1998 [ # # ][ # # ]: 0 : if( *pTmp->Start() < *pEnd )
[ # # ]
1999 : : {
2000 : : // Only revoke the partial selection
2001 [ # # ][ # # ]: 0 : if( (*fn_AcceptReject)( rArr, n, bCallDelete, pStt, pEnd ))
2002 : 0 : nCount++;
2003 : : }
2004 : 0 : break;
2005 : : }
2006 : : }
2007 : : }
2008 : 0 : return nCount;
2009 : : }
2010 : :
2011 : 0 : void lcl_AdjustRedlineRange( SwPaM& rPam )
2012 : : {
2013 : : // The Selection is only in the ContentSection. If there are Redlines
2014 : : // to Non-ContentNodes before or after that, then the Selections
2015 : : // expand to them.
2016 : 0 : SwPosition* pStt = rPam.Start(),
2017 : 0 : * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
2018 [ # # ]: 0 : : rPam.GetPoint();
2019 : 0 : SwDoc* pDoc = rPam.GetDoc();
2020 [ # # ]: 0 : if( !pStt->nContent.GetIndex() &&
[ # # # # ]
2021 : 0 : !pDoc->GetNodes()[ pStt->nNode.GetIndex() - 1 ]->IsCntntNode() )
2022 : : {
2023 : 0 : const SwRedline* pRedl = pDoc->GetRedline( *pStt, 0 );
2024 [ # # ]: 0 : if( pRedl )
2025 : : {
2026 : 0 : const SwPosition* pRStt = pRedl->Start();
2027 [ # # ][ # # ]: 0 : if( !pRStt->nContent.GetIndex() && pRStt->nNode.GetIndex() ==
[ # # ]
2028 : 0 : pStt->nNode.GetIndex() - 1 )
2029 : 0 : *pStt = *pRStt;
2030 : : }
2031 : : }
2032 [ # # # # : 0 : if( pEnd->nNode.GetNode().IsCntntNode() &&
# # ][ # # ]
2033 : 0 : !pDoc->GetNodes()[ pEnd->nNode.GetIndex() + 1 ]->IsCntntNode() &&
2034 : 0 : pEnd->nContent.GetIndex() == pEnd->nNode.GetNode().GetCntntNode()->Len() )
2035 : : {
2036 : 0 : const SwRedline* pRedl = pDoc->GetRedline( *pEnd, 0 );
2037 [ # # ]: 0 : if( pRedl )
2038 : : {
2039 : 0 : const SwPosition* pREnd = pRedl->End();
2040 [ # # ][ # # ]: 0 : if( !pREnd->nContent.GetIndex() && pREnd->nNode.GetIndex() ==
[ # # ]
2041 : 0 : pEnd->nNode.GetIndex() + 1 )
2042 : 0 : *pEnd = *pREnd;
2043 : : }
2044 : : }
2045 : 0 : }
2046 : :
2047 : :
2048 : 0 : bool SwDoc::AcceptRedline( sal_uInt16 nPos, bool bCallDelete )
2049 : : {
2050 : 0 : sal_Bool bRet = sal_False;
2051 : :
2052 : : // Switch to visible in any case
2053 [ # # ]: 0 : if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
2054 : : (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
2055 : 0 : SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
2056 : :
2057 : 0 : SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
2058 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
2059 : : {
2060 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2061 : : {
2062 [ # # ]: 0 : SwRewriter aRewriter;
2063 : :
2064 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, pTmp->GetDescr());
[ # # ]
2065 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().StartUndo(UNDO_ACCEPT_REDLINE, &aRewriter);
[ # # ]
2066 : : }
2067 : :
2068 : 0 : int nLoopCnt = 2;
2069 : 0 : sal_uInt16 nSeqNo = pTmp->GetSeqNo();
2070 : :
2071 [ # # ]: 0 : do {
2072 : :
2073 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2074 : : {
2075 [ # # ]: 0 : SwUndo *const pUndo( new SwUndoAcceptRedline(*pTmp) );
2076 : 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
2077 : : }
2078 : :
2079 : 0 : bRet |= lcl_AcceptRedline( *pRedlineTbl, nPos, bCallDelete );
2080 : :
2081 [ # # ]: 0 : if( nSeqNo )
2082 : : {
2083 [ # # ]: 0 : if( USHRT_MAX == nPos )
2084 : 0 : nPos = 0;
2085 : : sal_uInt16 nFndPos = 2 == nLoopCnt
2086 : 0 : ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
2087 [ # # ]: 0 : : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
2088 [ # # ][ # # ]: 0 : if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
[ # # ][ # # ]
2089 : : USHRT_MAX != ( nFndPos =
2090 : 0 : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
2091 : 0 : pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
2092 : : else
2093 : 0 : nLoopCnt = 0;
2094 : : }
2095 : : else
2096 : 0 : nLoopCnt = 0;
2097 : :
2098 : : } while( nLoopCnt );
2099 : :
2100 [ # # ]: 0 : if( bRet )
2101 : : {
2102 : 0 : CompressRedlines();
2103 : 0 : SetModified();
2104 : : }
2105 : :
2106 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2107 : : {
2108 : 0 : GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
2109 : : }
2110 : : }
2111 : 0 : return bRet;
2112 : : }
2113 : :
2114 : 0 : bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete )
2115 : : {
2116 : : // Switch to visible in any case
2117 [ # # ]: 0 : if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
2118 : : (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
2119 [ # # ]: 0 : SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
2120 : :
2121 : : // The Selection is only in the ContentSection. If there are Redlines
2122 : : // to Non-ContentNodes before or after that, then the Selections
2123 : : // expand to them.
2124 [ # # ]: 0 : SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
2125 [ # # ]: 0 : lcl_AdjustRedlineRange( aPam );
2126 : :
2127 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
2128 : : {
2129 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().StartUndo( UNDO_ACCEPT_REDLINE, NULL );
2130 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo( new SwUndoAcceptRedline( aPam ));
[ # # ][ # # ]
2131 : : }
2132 : :
2133 : : int nRet = lcl_AcceptRejectRedl( lcl_AcceptRedline, *pRedlineTbl,
2134 [ # # ]: 0 : bCallDelete, aPam );
2135 [ # # ]: 0 : if( nRet > 0 )
2136 : : {
2137 [ # # ]: 0 : CompressRedlines();
2138 [ # # ]: 0 : SetModified();
2139 : : }
2140 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
2141 : : {
2142 [ # # ]: 0 : String aTmpStr;
2143 : :
2144 : : {
2145 [ # # ]: 0 : SwRewriter aRewriter;
2146 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, String::CreateFromInt32(nRet));
[ # # ]
2147 [ # # ][ # # ]: 0 : aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
[ # # ][ # # ]
[ # # ][ # # ]
2148 : : }
2149 : :
2150 [ # # ]: 0 : SwRewriter aRewriter;
2151 [ # # ]: 0 : aRewriter.AddRule(UndoArg1, aTmpStr);
2152 : :
2153 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().EndUndo( UNDO_ACCEPT_REDLINE, &aRewriter );
[ # # ][ # # ]
2154 : : }
2155 [ # # ]: 0 : return nRet != 0;
2156 : : }
2157 : :
2158 : 0 : bool SwDoc::RejectRedline( sal_uInt16 nPos, bool bCallDelete )
2159 : : {
2160 : 0 : sal_Bool bRet = sal_False;
2161 : :
2162 : : // Switch to visible in any case
2163 [ # # ]: 0 : if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
2164 : : (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
2165 : 0 : SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
2166 : :
2167 : 0 : SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
2168 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
2169 : : {
2170 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2171 : : {
2172 [ # # ]: 0 : SwRewriter aRewriter;
2173 : :
2174 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, pTmp->GetDescr());
[ # # ]
2175 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().StartUndo(UNDO_REJECT_REDLINE, &aRewriter);
[ # # ]
2176 : : }
2177 : :
2178 : 0 : int nLoopCnt = 2;
2179 : 0 : sal_uInt16 nSeqNo = pTmp->GetSeqNo();
2180 : :
2181 [ # # ]: 0 : do {
2182 : :
2183 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2184 : : {
2185 [ # # ]: 0 : SwUndo *const pUndo( new SwUndoRejectRedline( *pTmp ) );
2186 : 0 : GetIDocumentUndoRedo().AppendUndo(pUndo);
2187 : : }
2188 : :
2189 : 0 : bRet |= lcl_RejectRedline( *pRedlineTbl, nPos, bCallDelete );
2190 : :
2191 [ # # ]: 0 : if( nSeqNo )
2192 : : {
2193 [ # # ]: 0 : if( USHRT_MAX == nPos )
2194 : 0 : nPos = 0;
2195 : : sal_uInt16 nFndPos = 2 == nLoopCnt
2196 : 0 : ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
2197 [ # # ]: 0 : : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
2198 [ # # ][ # # ]: 0 : if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
[ # # ][ # # ]
2199 : : USHRT_MAX != ( nFndPos =
2200 : 0 : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
2201 : 0 : pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
2202 : : else
2203 : 0 : nLoopCnt = 0;
2204 : : }
2205 : : else
2206 : 0 : nLoopCnt = 0;
2207 : :
2208 : : } while( nLoopCnt );
2209 : :
2210 [ # # ]: 0 : if( bRet )
2211 : : {
2212 : 0 : CompressRedlines();
2213 : 0 : SetModified();
2214 : : }
2215 : :
2216 [ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
2217 : : {
2218 : 0 : GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
2219 : : }
2220 : : }
2221 : 0 : return bRet;
2222 : : }
2223 : :
2224 : 0 : bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete )
2225 : : {
2226 : : // Switch to visible in any case
2227 [ # # ]: 0 : if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
2228 : : (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
2229 [ # # ]: 0 : SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
2230 : :
2231 : : // The Selection is only in the ContentSection. If there are Redlines
2232 : : // to Non-ContentNodes before or after that, then the Selections
2233 : : // expand to them.
2234 [ # # ]: 0 : SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
2235 [ # # ]: 0 : lcl_AdjustRedlineRange( aPam );
2236 : :
2237 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
2238 : : {
2239 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().StartUndo( UNDO_REJECT_REDLINE, NULL );
2240 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().AppendUndo( new SwUndoRejectRedline(aPam) );
[ # # ][ # # ]
2241 : : }
2242 : :
2243 : : int nRet = lcl_AcceptRejectRedl( lcl_RejectRedline, *pRedlineTbl,
2244 [ # # ]: 0 : bCallDelete, aPam );
2245 [ # # ]: 0 : if( nRet > 0 )
2246 : : {
2247 [ # # ]: 0 : CompressRedlines();
2248 [ # # ]: 0 : SetModified();
2249 : : }
2250 [ # # ][ # # ]: 0 : if (GetIDocumentUndoRedo().DoesUndo())
[ # # ]
2251 : : {
2252 [ # # ]: 0 : String aTmpStr;
2253 : :
2254 : : {
2255 [ # # ]: 0 : SwRewriter aRewriter;
2256 [ # # ][ # # ]: 0 : aRewriter.AddRule(UndoArg1, String::CreateFromInt32(nRet));
[ # # ]
2257 [ # # ][ # # ]: 0 : aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
[ # # ][ # # ]
[ # # ][ # # ]
2258 : : }
2259 : :
2260 [ # # ]: 0 : SwRewriter aRewriter;
2261 [ # # ]: 0 : aRewriter.AddRule(UndoArg1, aTmpStr);
2262 : :
2263 [ # # ][ # # ]: 0 : GetIDocumentUndoRedo().EndUndo( UNDO_REJECT_REDLINE, &aRewriter );
[ # # ][ # # ]
2264 : : }
2265 : :
2266 [ # # ]: 0 : return nRet != 0;
2267 : : }
2268 : :
2269 : 0 : const SwRedline* SwDoc::SelNextRedline( SwPaM& rPam ) const
2270 : : {
2271 [ # # ]: 0 : rPam.DeleteMark();
2272 [ # # ]: 0 : rPam.SetMark();
2273 : :
2274 : 0 : SwPosition& rSttPos = *rPam.GetPoint();
2275 [ # # ]: 0 : SwPosition aSavePos( rSttPos );
2276 : : sal_Bool bRestart;
2277 : :
2278 : : // If the starting positon points to the last valid ContentNode,
2279 : : // we take the next Redline in any case.
2280 : 0 : sal_uInt16 n = 0;
2281 [ # # ]: 0 : const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_True );
2282 [ # # ]: 0 : if( pFnd )
2283 : : {
2284 [ # # ]: 0 : const SwPosition* pEnd = pFnd->End();
2285 [ # # ]: 0 : if( !pEnd->nNode.GetNode().IsCntntNode() )
2286 : : {
2287 [ # # ]: 0 : SwNodeIndex aTmp( pEnd->nNode );
2288 [ # # ][ # # ]: 0 : SwCntntNode* pCNd = GetNodes().GoPrevSection( &aTmp );
2289 [ # # ]: 0 : if( !pCNd || ( aTmp == rSttPos.nNode &&
[ # # # # ]
[ # # ]
2290 [ # # ]: 0 : pCNd->Len() == rSttPos.nContent.GetIndex() ))
2291 [ # # ]: 0 : pFnd = 0;
2292 : : }
2293 [ # # ]: 0 : if( pFnd )
2294 [ # # ][ # # ]: 0 : rSttPos = *pFnd->End();
2295 : : }
2296 : :
2297 [ # # ]: 0 : do {
2298 : 0 : bRestart = sal_False;
2299 : :
2300 [ # # ][ # # ]: 0 : for( ; !pFnd && n < pRedlineTbl->size(); ++n )
[ # # ]
2301 : : {
2302 [ # # ]: 0 : pFnd = (*pRedlineTbl)[ n ];
2303 [ # # ][ # # ]: 0 : if( pFnd->HasMark() && pFnd->IsVisible() )
[ # # ]
2304 : : {
2305 [ # # ][ # # ]: 0 : *rPam.GetMark() = *pFnd->Start();
2306 [ # # ][ # # ]: 0 : rSttPos = *pFnd->End();
2307 : 0 : break;
2308 : : }
2309 : : else
2310 : 0 : pFnd = 0;
2311 : : }
2312 : :
2313 [ # # ]: 0 : if( pFnd )
2314 : : {
2315 : : // Merge all of the same type and author that are
2316 : : // consecutive into one Selection.
2317 [ # # ]: 0 : const SwPosition* pPrevEnd = pFnd->End();
2318 [ # # ]: 0 : while( ++n < pRedlineTbl->size() )
2319 : : {
2320 [ # # ]: 0 : const SwRedline* pTmp = (*pRedlineTbl)[ n ];
2321 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
2322 : : {
2323 : : const SwPosition *pRStt;
2324 [ # # ][ # # ]: 0 : if( pFnd->GetType() == pTmp->GetType() &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2325 [ # # ][ # # ]: 0 : pFnd->GetAuthor() == pTmp->GetAuthor() &&
2326 [ # # ]: 0 : ( *pPrevEnd == *( pRStt = pTmp->Start() ) ||
2327 [ # # ][ # # ]: 0 : IsPrevPos( *pPrevEnd, *pRStt )) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2328 : : {
2329 [ # # ]: 0 : pPrevEnd = pTmp->End();
2330 [ # # ]: 0 : rSttPos = *pPrevEnd;
2331 : : }
2332 : : else
2333 : 0 : break;
2334 : : }
2335 : : }
2336 : : }
2337 : :
2338 [ # # ]: 0 : if( pFnd )
2339 : : {
2340 : 0 : const SwRedline* pSaveFnd = pFnd;
2341 : :
2342 : : SwCntntNode* pCNd;
2343 : 0 : SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
2344 [ # # ][ # # ]: 0 : if( !pIdx->GetNode().IsCntntNode() &&
[ # # ][ # # ]
2345 [ # # ]: 0 : 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
2346 : : {
2347 [ # # ]: 0 : if( *pIdx <= rPam.GetPoint()->nNode )
2348 [ # # ][ # # ]: 0 : rPam.GetMark()->nContent.Assign( pCNd, 0 );
2349 : : else
2350 : 0 : pFnd = 0;
2351 : : }
2352 : :
2353 [ # # ]: 0 : if( pFnd )
2354 : : {
2355 : 0 : pIdx = &rPam.GetPoint()->nNode;
2356 [ # # ][ # # ]: 0 : if( !pIdx->GetNode().IsCntntNode() &&
[ # # ][ # # ]
2357 [ # # ]: 0 : 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
2358 : : {
2359 [ # # ]: 0 : if( *pIdx >= rPam.GetMark()->nNode )
2360 [ # # ][ # # ]: 0 : rPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
[ # # ]
2361 : : else
2362 : 0 : pFnd = 0;
2363 : : }
2364 : : }
2365 : :
2366 [ # # ][ # # ]: 0 : if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
[ # # ][ # # ]
2367 : : {
2368 [ # # ]: 0 : if( n < pRedlineTbl->size() )
2369 : : {
2370 : 0 : bRestart = sal_True;
2371 [ # # ][ # # ]: 0 : *rPam.GetPoint() = *pSaveFnd->End();
2372 : : }
2373 : : else
2374 : : {
2375 [ # # ]: 0 : rPam.DeleteMark();
2376 [ # # ]: 0 : *rPam.GetPoint() = aSavePos;
2377 : : }
2378 : 0 : pFnd = 0;
2379 : : }
2380 : : }
2381 : : } while( bRestart );
2382 : :
2383 [ # # ]: 0 : return pFnd;
2384 : : }
2385 : :
2386 : 0 : const SwRedline* SwDoc::SelPrevRedline( SwPaM& rPam ) const
2387 : : {
2388 [ # # ]: 0 : rPam.DeleteMark();
2389 [ # # ]: 0 : rPam.SetMark();
2390 : :
2391 : 0 : SwPosition& rSttPos = *rPam.GetPoint();
2392 [ # # ]: 0 : SwPosition aSavePos( rSttPos );
2393 : : sal_Bool bRestart;
2394 : :
2395 : : // If the starting positon points to the last valid ContentNode,
2396 : : // we take the previous Redline in any case.
2397 : 0 : sal_uInt16 n = 0;
2398 [ # # ]: 0 : const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_False );
2399 [ # # ]: 0 : if( pFnd )
2400 : : {
2401 [ # # ]: 0 : const SwPosition* pStt = pFnd->Start();
2402 [ # # ]: 0 : if( !pStt->nNode.GetNode().IsCntntNode() )
2403 : : {
2404 [ # # ]: 0 : SwNodeIndex aTmp( pStt->nNode );
2405 [ # # ][ # # ]: 0 : SwCntntNode* pCNd = GetNodes().GoNextSection( &aTmp );
2406 [ # # ]: 0 : if( !pCNd || ( aTmp == rSttPos.nNode &&
[ # # # # ]
[ # # ]
2407 : 0 : !rSttPos.nContent.GetIndex() ))
2408 [ # # ]: 0 : pFnd = 0;
2409 : : }
2410 [ # # ]: 0 : if( pFnd )
2411 [ # # ][ # # ]: 0 : rSttPos = *pFnd->Start();
2412 : : }
2413 : :
2414 [ # # ]: 0 : do {
2415 : 0 : bRestart = sal_False;
2416 : :
2417 [ # # ][ # # ]: 0 : while( !pFnd && 0 < n )
[ # # ]
2418 : : {
2419 [ # # ]: 0 : pFnd = (*pRedlineTbl)[ --n ];
2420 [ # # ][ # # ]: 0 : if( pFnd->HasMark() && pFnd->IsVisible() )
[ # # ]
2421 : : {
2422 [ # # ][ # # ]: 0 : *rPam.GetMark() = *pFnd->End();
2423 [ # # ][ # # ]: 0 : rSttPos = *pFnd->Start();
2424 : : }
2425 : : else
2426 : 0 : pFnd = 0;
2427 : : }
2428 : :
2429 [ # # ]: 0 : if( pFnd )
2430 : : {
2431 : : // Merge all of the same type and author that are
2432 : : // consecutive into one Selection.
2433 [ # # ]: 0 : const SwPosition* pNextStt = pFnd->Start();
2434 [ # # ]: 0 : while( 0 < n )
2435 : : {
2436 [ # # ]: 0 : const SwRedline* pTmp = (*pRedlineTbl)[ --n ];
2437 [ # # ][ # # ]: 0 : if( pTmp->HasMark() && pTmp->IsVisible() )
[ # # ]
2438 : : {
2439 : : const SwPosition *pREnd;
2440 [ # # ][ # # ]: 0 : if( pFnd->GetType() == pTmp->GetType() &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2441 [ # # ][ # # ]: 0 : pFnd->GetAuthor() == pTmp->GetAuthor() &&
2442 [ # # ]: 0 : ( *pNextStt == *( pREnd = pTmp->End() ) ||
2443 [ # # ][ # # ]: 0 : IsPrevPos( *pREnd, *pNextStt )) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
2444 : : {
2445 [ # # ]: 0 : pNextStt = pTmp->Start();
2446 [ # # ]: 0 : rSttPos = *pNextStt;
2447 : : }
2448 : : else
2449 : : {
2450 : 0 : ++n;
2451 : 0 : break;
2452 : : }
2453 : : }
2454 : : }
2455 : : }
2456 : :
2457 [ # # ]: 0 : if( pFnd )
2458 : : {
2459 : 0 : const SwRedline* pSaveFnd = pFnd;
2460 : :
2461 : : SwCntntNode* pCNd;
2462 : 0 : SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
2463 [ # # ][ # # ]: 0 : if( !pIdx->GetNode().IsCntntNode() &&
[ # # ][ # # ]
2464 [ # # ]: 0 : 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
2465 : : {
2466 [ # # ]: 0 : if( *pIdx >= rPam.GetPoint()->nNode )
2467 [ # # ][ # # ]: 0 : rPam.GetMark()->nContent.Assign( pCNd, pCNd->Len() );
[ # # ]
2468 : : else
2469 : 0 : pFnd = 0;
2470 : : }
2471 : :
2472 [ # # ]: 0 : if( pFnd )
2473 : : {
2474 : 0 : pIdx = &rPam.GetPoint()->nNode;
2475 [ # # ][ # # ]: 0 : if( !pIdx->GetNode().IsCntntNode() &&
[ # # ][ # # ]
2476 [ # # ]: 0 : 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
2477 : : {
2478 [ # # ]: 0 : if( *pIdx <= rPam.GetMark()->nNode )
2479 [ # # ][ # # ]: 0 : rPam.GetPoint()->nContent.Assign( pCNd, 0 );
2480 : : else
2481 : 0 : pFnd = 0;
2482 : : }
2483 : : }
2484 : :
2485 [ # # ][ # # ]: 0 : if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
[ # # ][ # # ]
2486 : : {
2487 [ # # ]: 0 : if( n )
2488 : : {
2489 : 0 : bRestart = sal_True;
2490 [ # # ][ # # ]: 0 : *rPam.GetPoint() = *pSaveFnd->Start();
2491 : : }
2492 : : else
2493 : : {
2494 [ # # ]: 0 : rPam.DeleteMark();
2495 [ # # ]: 0 : *rPam.GetPoint() = aSavePos;
2496 : : }
2497 : 0 : pFnd = 0;
2498 : : }
2499 : : }
2500 : : } while( bRestart );
2501 : :
2502 [ # # ]: 0 : return pFnd;
2503 : : }
2504 : :
2505 : : // Set comment at the Redline
2506 : 0 : bool SwDoc::SetRedlineComment( const SwPaM& rPaM, const String& rS )
2507 : : {
2508 : 0 : sal_Bool bRet = sal_False;
2509 [ # # ]: 0 : const SwPosition* pStt = rPaM.Start(),
2510 : 0 : * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark()
2511 [ # # ]: 0 : : rPaM.GetPoint();
2512 : 0 : sal_uInt16 n = 0;
2513 [ # # ][ # # ]: 0 : if( lcl_FindCurrRedline( *pStt, n, sal_True ) )
2514 : : {
2515 [ # # ]: 0 : for( ; n < pRedlineTbl->size(); ++n )
2516 : : {
2517 : 0 : bRet = sal_True;
2518 [ # # ]: 0 : SwRedline* pTmp = (*pRedlineTbl)[ n ];
2519 [ # # ][ # # ]: 0 : if( pStt != pEnd && *pTmp->Start() > *pEnd )
[ # # ][ # # ]
[ # # ]
2520 : 0 : break;
2521 : :
2522 [ # # ]: 0 : pTmp->SetComment( rS );
2523 [ # # ][ # # ]: 0 : if( *pTmp->End() >= *pEnd )
[ # # ]
2524 : 0 : break;
2525 : : }
2526 : : }
2527 [ # # ]: 0 : if( bRet )
2528 [ # # ]: 0 : SetModified();
2529 : :
2530 : 0 : return bRet;
2531 : : }
2532 : :
2533 : : // Create a new author if necessary
2534 : 2334 : sal_uInt16 SwDoc::GetRedlineAuthor()
2535 : : {
2536 : 2334 : return SW_MOD()->GetRedlineAuthor();
2537 : : }
2538 : :
2539 : : // Insert new author into the Table for the Readers etc.
2540 : 49992 : sal_uInt16 SwDoc::InsertRedlineAuthor( const String& rNew )
2541 : : {
2542 : 49992 : return SW_MOD()->InsertRedlineAuthor(rNew);
2543 : : }
2544 : :
2545 : 0 : void SwDoc::UpdateRedlineAttr()
2546 : : {
2547 : 0 : const SwRedlineTbl& rTbl = GetRedlineTbl();
2548 [ # # ]: 0 : for( sal_uInt16 n = 0; n < rTbl.size(); ++n )
2549 : : {
2550 : 0 : SwRedline* pRedl = rTbl[ n ];
2551 [ # # ]: 0 : if( pRedl->IsVisible() )
2552 : 0 : pRedl->InvalidateRange();
2553 : : }
2554 : 0 : }
2555 : :
2556 : : // Set comment text for the Redline, which is inserted later on via
2557 : : // AppendRedline. Is used by Autoformat.
2558 : : // A null pointer resets the mode. The pointer is not copied, so it
2559 : : // needs to stay valid!
2560 : 0 : void SwDoc::SetAutoFmtRedlineComment( const String* pTxt, sal_uInt16 nSeqNo )
2561 : : {
2562 : 0 : mbIsAutoFmtRedline = 0 != pTxt;
2563 [ # # ]: 0 : if( pTxt )
2564 : : {
2565 [ # # ]: 0 : if( !pAutoFmtRedlnComment )
2566 [ # # ]: 0 : pAutoFmtRedlnComment = new String( *pTxt );
2567 : : else
2568 : 0 : *pAutoFmtRedlnComment = *pTxt;
2569 : : }
2570 : : else
2571 [ # # ]: 0 : delete pAutoFmtRedlnComment, pAutoFmtRedlnComment = 0;
2572 : :
2573 : 0 : nAutoFmtRedlnCommentNo = nSeqNo;
2574 : 0 : }
2575 : :
2576 : 71 : void SwDoc::SetRedlinePassword(
2577 : : /*[in]*/const uno::Sequence <sal_Int8>& rNewPassword)
2578 : : {
2579 : 71 : aRedlinePasswd = rNewPassword;
2580 : 71 : SetModified();
2581 : 71 : }
2582 : :
2583 : :
2584 : 934 : bool SwRedlineTbl::Insert( SwRedline* p, bool bIns )
2585 : : {
2586 : 934 : bool bRet = false;
2587 [ + - ]: 934 : if( p->HasValidRange() )
2588 : : {
2589 : 934 : bRet = insert( p ).second;
2590 : 934 : p->CallDisplayFunc();
2591 : : }
2592 [ # # ]: 0 : else if( bIns )
2593 : 0 : bRet = InsertWithValidRanges( p );
2594 : : else
2595 : : {
2596 : : OSL_ENSURE( !this, "Redline: wrong range" );
2597 : : }
2598 : 934 : return bRet;
2599 : : }
2600 : :
2601 : 0 : bool SwRedlineTbl::Insert( SwRedline* p, sal_uInt16& rP, bool bIns )
2602 : : {
2603 : 0 : bool bRet = false;
2604 [ # # ]: 0 : if( p->HasValidRange() )
2605 : : {
2606 [ # # ]: 0 : std::pair<_SwRedlineTbl::const_iterator, bool> rv = insert( p );
2607 [ # # ]: 0 : rP = rv.first - begin();
2608 : 0 : bRet = rv.second;
2609 [ # # ]: 0 : p->CallDisplayFunc();
2610 : : }
2611 [ # # ]: 0 : else if( bIns )
2612 : 0 : bRet = InsertWithValidRanges( p, &rP );
2613 : : else
2614 : : {
2615 : : OSL_ENSURE( !this, "Redline: wrong range" );
2616 : : }
2617 : 0 : return bRet;
2618 : : }
2619 : :
2620 : 0 : bool SwRedlineTbl::InsertWithValidRanges( SwRedline* p, sal_uInt16* pInsPos )
2621 : : {
2622 : : // Create valid "sub-ranges" from the Selection
2623 : 0 : bool bAnyIns = false;
2624 [ # # ]: 0 : SwPosition* pStt = p->Start(),
2625 [ # # ]: 0 : * pEnd = pStt == p->GetPoint() ? p->GetMark() : p->GetPoint();
2626 [ # # ]: 0 : SwPosition aNewStt( *pStt );
2627 : 0 : SwNodes& rNds = aNewStt.nNode.GetNodes();
2628 : : SwCntntNode* pC;
2629 : :
2630 [ # # ]: 0 : if( !aNewStt.nNode.GetNode().IsCntntNode() )
2631 : : {
2632 [ # # ]: 0 : pC = rNds.GoNext( &aNewStt.nNode );
2633 [ # # ]: 0 : if( pC )
2634 [ # # ][ # # ]: 0 : aNewStt.nContent.Assign( pC, 0 );
2635 : : else
2636 [ # # ]: 0 : aNewStt.nNode = rNds.GetEndOfContent();
2637 : : }
2638 : :
2639 : 0 : SwRedline* pNew = 0;
2640 : : sal_uInt16 nInsPos;
2641 : :
2642 [ # # ][ # # ]: 0 : if( aNewStt < *pEnd )
2643 [ # # ]: 0 : do {
2644 [ # # ]: 0 : if( !pNew )
2645 [ # # ][ # # ]: 0 : pNew = new SwRedline( p->GetRedlineData(), aNewStt );
[ # # ]
2646 : : else
2647 : : {
2648 [ # # ]: 0 : pNew->DeleteMark();
2649 [ # # ]: 0 : *pNew->GetPoint() = aNewStt;
2650 : : }
2651 : :
2652 [ # # ]: 0 : pNew->SetMark();
2653 [ # # ]: 0 : GoEndSection( pNew->GetPoint() );
2654 : : // i60396: If the redlines starts before a table but the table is the last member
2655 : : // of the section, the GoEndSection will end inside the table.
2656 : : // This will result in an incorrect redline, so we've to go back
2657 [ # # ]: 0 : SwNode* pTab = pNew->GetPoint()->nNode.GetNode().StartOfSectionNode()->FindTableNode();
2658 : : // We end in a table when pTab != 0
2659 [ # # ][ # # ]: 0 : if( pTab && !pNew->GetMark()->nNode.GetNode().StartOfSectionNode()->FindTableNode() )
[ # # ][ # # ]
2660 : : { // but our Mark was outside the table => Correction
2661 [ # # ]: 0 : do
2662 : : {
2663 : : // We want to be before the table
2664 [ # # ][ # # ]: 0 : *pNew->GetPoint() = SwPosition(*pTab);
[ # # ]
2665 [ # # ]: 0 : pC = GoPreviousNds( &pNew->GetPoint()->nNode, sal_False ); // here we are.
2666 [ # # ]: 0 : if( pC )
2667 [ # # ][ # # ]: 0 : pNew->GetPoint()->nContent.Assign( pC, 0 );
2668 [ # # ]: 0 : pTab = pNew->GetPoint()->nNode.GetNode().StartOfSectionNode()->FindTableNode();
2669 : : }while( pTab ); // If there is another table we have to repeat our step backwards
2670 : : }
2671 : :
2672 [ # # ][ # # ]: 0 : if( *pNew->GetPoint() > *pEnd )
2673 : : {
2674 : 0 : pC = 0;
2675 [ # # ]: 0 : if( aNewStt.nNode != pEnd->nNode )
2676 [ # # ]: 0 : do {
2677 : 0 : SwNode& rCurNd = aNewStt.nNode.GetNode();
2678 [ # # ]: 0 : if( rCurNd.IsStartNode() )
2679 : : {
2680 [ # # ]: 0 : if( rCurNd.EndOfSectionIndex() < pEnd->nNode.GetIndex() )
2681 [ # # ]: 0 : aNewStt.nNode = *rCurNd.EndOfSectionNode();
2682 : : else
2683 : 0 : break;
2684 : : }
2685 [ # # ]: 0 : else if( rCurNd.IsCntntNode() )
2686 : 0 : pC = rCurNd.GetCntntNode();
2687 [ # # ]: 0 : aNewStt.nNode++;
2688 : 0 : } while( aNewStt.nNode.GetIndex() < pEnd->nNode.GetIndex() );
2689 : :
2690 [ # # ]: 0 : if( aNewStt.nNode == pEnd->nNode )
2691 [ # # ]: 0 : aNewStt.nContent = pEnd->nContent;
2692 [ # # ]: 0 : else if( pC )
2693 : : {
2694 [ # # ]: 0 : aNewStt.nNode = *pC;
2695 [ # # ][ # # ]: 0 : aNewStt.nContent.Assign( pC, pC->Len() );
[ # # ]
2696 : : }
2697 : :
2698 [ # # ][ # # ]: 0 : if( aNewStt <= *pEnd )
2699 [ # # ]: 0 : *pNew->GetPoint() = aNewStt;
2700 : : }
2701 : : else
2702 [ # # ]: 0 : aNewStt = *pNew->GetPoint();
2703 : : #if OSL_DEBUG_LEVEL > 0
2704 : : CheckPosition( pNew->GetPoint(), pNew->GetMark() );
2705 : : #endif
2706 [ # # ][ # # ]: 0 : if( *pNew->GetPoint() != *pNew->GetMark() &&
[ # # ][ # # ]
2707 [ # # ]: 0 : Insert( pNew, nInsPos ) )
2708 : : {
2709 [ # # ]: 0 : pNew->CallDisplayFunc();
2710 : 0 : bAnyIns = true;
2711 : 0 : pNew = 0;
2712 [ # # ][ # # ]: 0 : if( pInsPos && *pInsPos < nInsPos )
2713 : 0 : *pInsPos = nInsPos;
2714 : : }
2715 : :
2716 [ # # ][ # # ]: 0 : if( aNewStt >= *pEnd ||
[ # # ][ # # ]
[ # # ]
2717 : : 0 == (pC = rNds.GoNext( &aNewStt.nNode )) )
2718 : 0 : break;
2719 : :
2720 [ # # ][ # # ]: 0 : aNewStt.nContent.Assign( pC, 0 );
2721 : :
2722 [ # # ]: 0 : } while( aNewStt < *pEnd );
2723 : :
2724 [ # # ][ # # ]: 0 : delete pNew;
2725 [ # # ][ # # ]: 0 : delete p, p = 0;
2726 [ # # ]: 0 : return bAnyIns;
2727 : : }
2728 : :
2729 : 2176 : bool CompareSwRedlineTbl::operator()(SwRedline* const &lhs, SwRedline* const &rhs) const
2730 : : {
2731 : 2176 : return *lhs < *rhs;
2732 : : }
2733 : :
2734 : 1458 : _SwRedlineTbl::~_SwRedlineTbl()
2735 : : {
2736 [ + - ]: 1458 : DeleteAndDestroyAll();
2737 : 1458 : }
2738 : :
2739 : 0 : sal_uInt16 SwRedlineTbl::GetPos(const SwRedline* p) const
2740 : : {
2741 [ # # ]: 0 : const_iterator it = find(const_cast<SwRedline* const>(p));
2742 [ # # ][ # # ]: 0 : if( it == end() )
2743 : 0 : return USHRT_MAX;
2744 [ # # ]: 0 : return it - begin();
2745 : : }
2746 : :
2747 : 0 : bool SwRedlineTbl::Remove( const SwRedline* p )
2748 : : {
2749 : 0 : sal_uInt16 nPos = GetPos(p);
2750 [ # # ]: 0 : if (nPos != USHRT_MAX)
2751 : 0 : Remove(nPos);
2752 : 0 : return nPos != USHRT_MAX;
2753 : : }
2754 : :
2755 : 0 : void SwRedlineTbl::Remove( sal_uInt16 nP )
2756 : : {
2757 : 0 : SwDoc* pDoc = 0;
2758 [ # # ][ # # ]: 0 : if( !nP && 1 == size() )
[ # # ]
2759 : 0 : pDoc = front()->GetDoc();
2760 : :
2761 [ # # ][ # # ]: 0 : erase( begin() + nP );
2762 : :
2763 : : ViewShell* pSh;
2764 [ # # ][ # # ]: 0 : if( pDoc && !pDoc->IsInDtor() &&
[ # # ][ # # ]
2765 : 0 : 0 != ( pSh = pDoc->GetCurrentViewShell()) ) //swmod 071108//swmod 071225
2766 [ # # ]: 0 : pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) );
2767 : 0 : }
2768 : :
2769 : 46 : void SwRedlineTbl::DeleteAndDestroyAll()
2770 : : {
2771 : 46 : DeleteAndDestroy(0, size());
2772 : 46 : }
2773 : :
2774 : 898 : void SwRedlineTbl::DeleteAndDestroy( sal_uInt16 nP, sal_uInt16 nL )
2775 : : {
2776 : 898 : SwDoc* pDoc = 0;
2777 [ + - ][ + + ]: 898 : if( !nP && nL && nL == size() )
[ + + ][ + + ]
2778 : 99 : pDoc = front()->GetDoc();
2779 : :
2780 [ + - ][ + - ]: 1826 : for( const_iterator it = begin() + nP; it != begin() + nP + nL; ++it )
[ + - ][ + - ]
[ + + ]
2781 [ + - ][ + - ]: 928 : delete *it;
2782 [ + - ][ + - ]: 898 : erase( begin() + nP, begin() + nP + nL );
[ + - ][ + - ]
2783 : :
2784 : : ViewShell* pSh;
2785 [ + + ][ + - ]: 898 : if( pDoc && !pDoc->IsInDtor() &&
[ - + ][ - + ]
2786 : 99 : 0 != ( pSh = pDoc->GetCurrentViewShell() ) ) //swmod 071108//swmod 071225
2787 [ # # ]: 0 : pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) );
2788 : 898 : }
2789 : :
2790 : : // Find the next or preceding Redline with the same seq.no.
2791 : : // We can limit the search using look ahead.
2792 : : // 0 or USHRT_MAX searches the whole array.
2793 : 0 : sal_uInt16 SwRedlineTbl::FindNextOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead ) const
2794 : : {
2795 : 0 : return nSttPos + 1 < (sal_uInt16)size()
2796 : 0 : ? FindNextSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos+1, nLookahead )
2797 [ # # ]: 0 : : USHRT_MAX;
2798 : : }
2799 : :
2800 : 0 : sal_uInt16 SwRedlineTbl::FindPrevOfSeqNo( sal_uInt16 nSttPos, sal_uInt16 nLookahead ) const
2801 : : {
2802 : 0 : return nSttPos ? FindPrevSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos-1, nLookahead )
2803 [ # # ]: 0 : : USHRT_MAX;
2804 : : }
2805 : :
2806 : 0 : sal_uInt16 SwRedlineTbl::FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
2807 : : sal_uInt16 nLookahead ) const
2808 : : {
2809 : 0 : sal_uInt16 nRet = USHRT_MAX, nEnd;
2810 [ # # ][ # # ]: 0 : if( nSeqNo && nSttPos < size() )
[ # # ]
2811 : : {
2812 : 0 : nEnd = size();
2813 [ # # # # ]: 0 : if( nLookahead && USHRT_MAX != nLookahead &&
[ # # ][ # # ]
2814 : 0 : static_cast<size_t>(nSttPos + nLookahead) < size() )
2815 : 0 : nEnd = nSttPos + nLookahead;
2816 : :
2817 [ # # ]: 0 : for( ; nSttPos < nEnd; ++nSttPos )
2818 [ # # ]: 0 : if( nSeqNo == operator[]( nSttPos )->GetSeqNo() )
2819 : : {
2820 : 0 : nRet = nSttPos;
2821 : 0 : break;
2822 : : }
2823 : : }
2824 : 0 : return nRet;
2825 : : }
2826 : :
2827 : 0 : sal_uInt16 SwRedlineTbl::FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
2828 : : sal_uInt16 nLookahead ) const
2829 : : {
2830 : 0 : sal_uInt16 nRet = USHRT_MAX, nEnd;
2831 [ # # ][ # # ]: 0 : if( nSeqNo && nSttPos < size() )
[ # # ]
2832 : : {
2833 : 0 : nEnd = 0;
2834 [ # # ][ # # ]: 0 : if( nLookahead && USHRT_MAX != nLookahead && nSttPos > nLookahead )
[ # # ]
2835 : 0 : nEnd = nSttPos - nLookahead;
2836 : :
2837 : 0 : ++nSttPos;
2838 [ # # ]: 0 : while( nSttPos > nEnd )
2839 [ # # ]: 0 : if( nSeqNo == operator[]( --nSttPos )->GetSeqNo() )
2840 : : {
2841 : 0 : nRet = nSttPos;
2842 : 0 : break;
2843 : : }
2844 : : }
2845 : 0 : return nRet;
2846 : : }
2847 : :
2848 : :
2849 : 0 : SwRedlineExtraData::~SwRedlineExtraData()
2850 : : {
2851 [ # # ]: 0 : }
2852 : :
2853 : 0 : void SwRedlineExtraData::Accept( SwPaM& ) const
2854 : : {
2855 : 0 : }
2856 : :
2857 : 0 : void SwRedlineExtraData::Reject( SwPaM& ) const
2858 : : {
2859 : 0 : }
2860 : :
2861 : 0 : int SwRedlineExtraData::operator == ( const SwRedlineExtraData& ) const
2862 : : {
2863 : 0 : return sal_False;
2864 : : }
2865 : :
2866 : :
2867 : 0 : SwRedlineExtraData_FmtColl::SwRedlineExtraData_FmtColl( const String& rColl,
2868 : : sal_uInt16 nPoolFmtId,
2869 : : const SfxItemSet* pItemSet )
2870 [ # # ]: 0 : : sFmtNm(rColl), pSet(0), nPoolId(nPoolFmtId)
2871 : : {
2872 [ # # ][ # # ]: 0 : if( pItemSet && pItemSet->Count() )
[ # # ]
2873 [ # # ][ # # ]: 0 : pSet = new SfxItemSet( *pItemSet );
2874 : 0 : }
2875 : :
2876 [ # # ]: 0 : SwRedlineExtraData_FmtColl::~SwRedlineExtraData_FmtColl()
2877 : : {
2878 [ # # ][ # # ]: 0 : delete pSet;
2879 [ # # ]: 0 : }
2880 : :
2881 : 0 : SwRedlineExtraData* SwRedlineExtraData_FmtColl::CreateNew() const
2882 : : {
2883 [ # # ]: 0 : return new SwRedlineExtraData_FmtColl( sFmtNm, nPoolId, pSet );
2884 : : }
2885 : :
2886 : 0 : void SwRedlineExtraData_FmtColl::Reject( SwPaM& rPam ) const
2887 : : {
2888 : 0 : SwDoc* pDoc = rPam.GetDoc();
2889 : :
2890 : : // What about Undo? Is it turned off?
2891 : : SwTxtFmtColl* pColl = USHRT_MAX == nPoolId
2892 : 0 : ? pDoc->FindTxtFmtCollByName( sFmtNm )
2893 [ # # ]: 0 : : pDoc->GetTxtCollFromPool( nPoolId );
2894 [ # # ]: 0 : if( pColl )
2895 : 0 : pDoc->SetTxtFmtColl( rPam, pColl, false );
2896 : :
2897 [ # # ]: 0 : if( pSet )
2898 : : {
2899 : 0 : rPam.SetMark();
2900 : 0 : SwPosition& rMark = *rPam.GetMark();
2901 : 0 : SwTxtNode* pTNd = rMark.nNode.GetNode().GetTxtNode();
2902 [ # # ]: 0 : if( pTNd )
2903 : : {
2904 [ # # ]: 0 : rMark.nContent.Assign( pTNd, pTNd->GetTxt().Len() );
2905 : :
2906 [ # # ]: 0 : if( pTNd->HasSwAttrSet() )
2907 : : {
2908 : : // Only set those that are not there anymore. Others
2909 : : // could have changed, but we don't touch these.
2910 [ # # ]: 0 : SfxItemSet aTmp( *pSet );
2911 [ # # ][ # # ]: 0 : aTmp.Differentiate( *pTNd->GetpSwAttrSet() );
2912 [ # # ][ # # ]: 0 : pDoc->InsertItemSet( rPam, aTmp, 0 );
2913 : : }
2914 : : else
2915 : : {
2916 : 0 : pDoc->InsertItemSet( rPam, *pSet, 0 );
2917 : : }
2918 : : }
2919 : 0 : rPam.DeleteMark();
2920 : : }
2921 : 0 : }
2922 : :
2923 : 0 : int SwRedlineExtraData_FmtColl::operator == ( const SwRedlineExtraData& r) const
2924 : : {
2925 : 0 : const SwRedlineExtraData_FmtColl& rCmp = (SwRedlineExtraData_FmtColl&)r;
2926 : 0 : return sFmtNm == rCmp.sFmtNm && nPoolId == rCmp.nPoolId &&
2927 : 0 : ( ( !pSet && !rCmp.pSet ) ||
2928 [ # # ][ # # ]: 0 : ( pSet && rCmp.pSet && *pSet == *rCmp.pSet ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2929 : : }
2930 : :
2931 : 0 : void SwRedlineExtraData_FmtColl::SetItemSet( const SfxItemSet& rSet )
2932 : : {
2933 [ # # ]: 0 : delete pSet;
2934 [ # # ]: 0 : if( rSet.Count() )
2935 [ # # ]: 0 : pSet = new SfxItemSet( rSet );
2936 : : else
2937 : 0 : pSet = 0;
2938 : 0 : }
2939 : :
2940 : :
2941 [ # # ]: 0 : SwRedlineExtraData_Format::SwRedlineExtraData_Format( const SfxItemSet& rSet )
2942 : : {
2943 [ # # ]: 0 : SfxItemIter aIter( rSet );
2944 : 0 : const SfxPoolItem* pItem = aIter.FirstItem();
2945 : 0 : while( sal_True )
2946 : : {
2947 [ # # ]: 0 : aWhichIds.push_back( pItem->Which() );
2948 [ # # ]: 0 : if( aIter.IsAtEnd() )
2949 : 0 : break;
2950 [ # # ]: 0 : pItem = aIter.NextItem();
2951 [ # # ]: 0 : }
2952 : 0 : }
2953 : :
2954 : 0 : SwRedlineExtraData_Format::SwRedlineExtraData_Format(
2955 : : const SwRedlineExtraData_Format& rCpy )
2956 [ # # ]: 0 : : SwRedlineExtraData()
2957 : : {
2958 [ # # ]: 0 : aWhichIds.insert( aWhichIds.begin(), rCpy.aWhichIds.begin(), rCpy.aWhichIds.end() );
2959 : 0 : }
2960 : :
2961 : 0 : SwRedlineExtraData_Format::~SwRedlineExtraData_Format()
2962 : : {
2963 [ # # ]: 0 : }
2964 : :
2965 : 0 : SwRedlineExtraData* SwRedlineExtraData_Format::CreateNew() const
2966 : : {
2967 [ # # ]: 0 : return new SwRedlineExtraData_Format( *this );
2968 : : }
2969 : :
2970 : 0 : void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const
2971 : : {
2972 : 0 : SwDoc* pDoc = rPam.GetDoc();
2973 : :
2974 [ # # ]: 0 : RedlineMode_t eOld = pDoc->GetRedlineMode();
2975 [ # # ]: 0 : pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
2976 : :
2977 : : // Actually we need to reset the Attribute here!
2978 : 0 : std::vector<sal_uInt16>::const_iterator it;
2979 [ # # ][ # # ]: 0 : for( it = aWhichIds.begin(); it != aWhichIds.end(); ++it )
[ # # ]
2980 : : {
2981 [ # # ][ # # ]: 0 : pDoc->InsertPoolItem( rPam, *GetDfltAttr( *it ),
2982 [ # # ]: 0 : nsSetAttrMode::SETATTR_DONTEXPAND );
2983 : : }
2984 : :
2985 [ # # ]: 0 : pDoc->SetRedlineMode_intern( eOld );
2986 : 0 : }
2987 : :
2988 : 0 : int SwRedlineExtraData_Format::operator == ( const SwRedlineExtraData& rCmp ) const
2989 : : {
2990 : 0 : int nRet = 1;
2991 : 0 : size_t nEnd = aWhichIds.size();
2992 [ # # ]: 0 : if( nEnd != ((SwRedlineExtraData_Format&)rCmp).aWhichIds.size() )
2993 : 0 : nRet = 0;
2994 : : else
2995 [ # # ]: 0 : for( size_t n = 0; n < nEnd; ++n )
2996 [ # # ]: 0 : if( ((SwRedlineExtraData_Format&)rCmp).aWhichIds[n] != aWhichIds[n])
2997 : : {
2998 : 0 : nRet = 0;
2999 : 0 : break;
3000 : : }
3001 : 0 : return nRet;
3002 : : }
3003 : :
3004 : 2334 : SwRedlineData::SwRedlineData( RedlineType_t eT, sal_uInt16 nAut )
3005 : : : pNext( 0 ), pExtraData( 0 ),
3006 : : aStamp( DateTime::SYSTEM ),
3007 [ + - ]: 2334 : eType( eT ), nAuthor( nAut ), nSeqNo( 0 )
3008 : : {
3009 [ + - ]: 2334 : aStamp.SetSec( 0 );
3010 [ + - ]: 2334 : aStamp.Set100Sec( 0 );
3011 : 2334 : }
3012 : :
3013 : 0 : SwRedlineData::SwRedlineData( const SwRedlineData& rCpy, sal_Bool bCpyNext )
3014 : : :
3015 [ # # ]: 0 : pNext( (bCpyNext && rCpy.pNext) ? new SwRedlineData( *rCpy.pNext ) : 0 ),
3016 : 0 : pExtraData( rCpy.pExtraData ? rCpy.pExtraData->CreateNew() : 0 ),
3017 : : sComment( rCpy.sComment ), aStamp( rCpy.aStamp ), eType( rCpy.eType ),
3018 [ # # ][ # # ]: 0 : nAuthor( rCpy.nAuthor ), nSeqNo( rCpy.nSeqNo )
[ # # ][ # # ]
3019 : : {
3020 : 0 : }
3021 : :
3022 : : // For sw3io: We now own pNext!
3023 : 0 : SwRedlineData::SwRedlineData(RedlineType_t eT, sal_uInt16 nAut, const DateTime& rDT,
3024 : : const String& rCmnt, SwRedlineData *pNxt, SwRedlineExtraData* pData)
3025 : : : pNext(pNxt), pExtraData(pData), sComment(rCmnt), aStamp(rDT),
3026 [ # # ]: 0 : eType(eT), nAuthor(nAut), nSeqNo(0)
3027 : : {
3028 : 0 : }
3029 : :
3030 : 2334 : SwRedlineData::~SwRedlineData()
3031 : : {
3032 [ - + ][ # # ]: 2334 : delete pExtraData;
3033 [ - + ][ # # ]: 2334 : delete pNext;
3034 : 2334 : }
3035 : :
3036 : : // ExtraData is copied. The Pointer's ownership is thus NOT transferred
3037 : : // to the Redline Object!
3038 : 0 : void SwRedlineData::SetExtraData( const SwRedlineExtraData* pData )
3039 : : {
3040 [ # # ]: 0 : delete pExtraData;
3041 : :
3042 [ # # ]: 0 : if( pData )
3043 : 0 : pExtraData = pData->CreateNew();
3044 : : else
3045 : 0 : pExtraData = 0;
3046 : 0 : }
3047 : :
3048 : 0 : String SwRedlineData::GetDescr() const
3049 : : {
3050 : 0 : String aResult;
3051 : :
3052 [ # # ][ # # ]: 0 : aResult += String(SW_RES(STR_REDLINE_INSERT + GetType()));
[ # # ]
3053 : :
3054 : 0 : return aResult;
3055 : : }
3056 : :
3057 : 2334 : SwRedline::SwRedline(RedlineType_t eTyp, const SwPaM& rPam )
3058 : 2334 : : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
3059 [ + - ][ + - ]: 4668 : pRedlineData( new SwRedlineData( eTyp, GetDoc()->GetRedlineAuthor() ) ),
3060 [ + - ]: 4668 : pCntntSect( 0 )
3061 : : {
3062 : 2334 : bDelLastPara = bIsLastParaDelete = sal_False;
3063 : 2334 : bIsVisible = sal_True;
3064 [ - + ]: 2334 : if( !rPam.HasMark() )
3065 [ # # ]: 0 : DeleteMark();
3066 : 2334 : }
3067 : :
3068 : 0 : SwRedline::SwRedline( const SwRedlineData& rData, const SwPaM& rPam )
3069 : 0 : : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
3070 [ # # ]: 0 : pRedlineData( new SwRedlineData( rData )),
3071 [ # # ]: 0 : pCntntSect( 0 )
3072 : : {
3073 : 0 : bDelLastPara = bIsLastParaDelete = sal_False;
3074 : 0 : bIsVisible = sal_True;
3075 [ # # ]: 0 : if( !rPam.HasMark() )
3076 [ # # ]: 0 : DeleteMark();
3077 : 0 : }
3078 : :
3079 : 0 : SwRedline::SwRedline( const SwRedlineData& rData, const SwPosition& rPos )
3080 : : : SwPaM( rPos ),
3081 [ # # ]: 0 : pRedlineData( new SwRedlineData( rData )),
3082 [ # # ]: 0 : pCntntSect( 0 )
3083 : : {
3084 : 0 : bDelLastPara = bIsLastParaDelete = sal_False;
3085 : 0 : bIsVisible = sal_True;
3086 : 0 : }
3087 : :
3088 : 0 : SwRedline::SwRedline( const SwRedline& rCpy )
3089 : 0 : : SwPaM( *rCpy.GetMark(), *rCpy.GetPoint() ),
3090 [ # # ]: 0 : pRedlineData( new SwRedlineData( *rCpy.pRedlineData )),
3091 [ # # ]: 0 : pCntntSect( 0 )
3092 : : {
3093 : 0 : bDelLastPara = bIsLastParaDelete = sal_False;
3094 : 0 : bIsVisible = sal_True;
3095 [ # # ]: 0 : if( !rCpy.HasMark() )
3096 [ # # ]: 0 : DeleteMark();
3097 : 0 : }
3098 : :
3099 : 2334 : SwRedline::~SwRedline()
3100 : : {
3101 [ + + ]: 2334 : if( pCntntSect )
3102 : : {
3103 : : // delete the ContentSection
3104 [ - + ]: 3 : if( !GetDoc()->IsInDtor() )
3105 [ # # ]: 0 : GetDoc()->DeleteSection( &pCntntSect->GetNode() );
3106 [ + - ][ + - ]: 3 : delete pCntntSect;
3107 : : }
3108 [ + - ][ + - ]: 2334 : delete pRedlineData;
3109 [ - + ]: 4668 : }
3110 : :
3111 : : // Do we have a valid Selection?
3112 : 1371 : sal_Bool SwRedline::HasValidRange() const
3113 : : {
3114 : 1371 : const SwNode* pPtNd = &GetPoint()->nNode.GetNode(),
3115 : 1371 : * pMkNd = &GetMark()->nNode.GetNode();
3116 [ + - + - : 5484 : if( pPtNd->StartOfSectionNode() == pMkNd->StartOfSectionNode() &&
+ - ][ + - ]
[ + - + - ]
3117 : 1371 : !pPtNd->StartOfSectionNode()->IsTableNode() &&
3118 : : // invalid if points on the end of content
3119 : : // end-of-content only invalid if no content index exists
3120 : 1371 : ( pPtNd != pMkNd || GetContentIdx() != NULL ||
3121 : 1371 : pPtNd != &pPtNd->GetNodes().GetEndOfContent() )
3122 : : )
3123 : 1371 : return sal_True;
3124 : 1371 : return sal_False;
3125 : : }
3126 : :
3127 : 934 : void SwRedline::CallDisplayFunc( sal_uInt16 nLoop )
3128 : : {
3129 [ + + - - ]: 934 : switch( nsRedlineMode_t::REDLINE_SHOW_MASK & GetDoc()->GetRedlineMode() )
3130 : : {
3131 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE:
3132 : 317 : Show( nLoop );
3133 : 317 : break;
3134 : : case nsRedlineMode_t::REDLINE_SHOW_INSERT:
3135 : 617 : Hide( nLoop );
3136 : 617 : break;
3137 : : case nsRedlineMode_t::REDLINE_SHOW_DELETE:
3138 : 0 : ShowOriginal( nLoop );
3139 : 0 : break;
3140 : : }
3141 : 934 : }
3142 : :
3143 : 317 : void SwRedline::Show( sal_uInt16 nLoop )
3144 : : {
3145 [ - + ]: 317 : if( 1 <= nLoop )
3146 : : {
3147 : 0 : SwDoc* pDoc = GetDoc();
3148 [ # # ]: 0 : RedlineMode_t eOld = pDoc->GetRedlineMode();
3149 [ # # ]: 0 : pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
3150 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
3151 : :
3152 [ # # ]: 0 : switch( GetType() )
[ # # # # ]
3153 : : {
3154 : : case nsRedlineType_t::REDLINE_INSERT: // Content has been inserted
3155 : 0 : bIsVisible = sal_True;
3156 [ # # ]: 0 : MoveFromSection();
3157 : 0 : break;
3158 : :
3159 : : case nsRedlineType_t::REDLINE_DELETE: // Content has been deleted
3160 : 0 : bIsVisible = sal_True;
3161 [ # # ]: 0 : MoveFromSection();
3162 : 0 : break;
3163 : :
3164 : : case nsRedlineType_t::REDLINE_FORMAT: // Attributes have been applied
3165 : : case nsRedlineType_t::REDLINE_TABLE: // Table structure has been modified
3166 [ # # ]: 0 : InvalidateRange();
3167 : 0 : break;
3168 : : default:
3169 : 0 : break;
3170 : : }
3171 [ # # ][ # # ]: 0 : pDoc->SetRedlineMode_intern( eOld );
3172 : : }
3173 : 317 : }
3174 : :
3175 : 623 : void SwRedline::Hide( sal_uInt16 nLoop )
3176 : : {
3177 : 623 : SwDoc* pDoc = GetDoc();
3178 [ + - ]: 623 : RedlineMode_t eOld = pDoc->GetRedlineMode();
3179 [ + - ]: 623 : pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
3180 [ + - ][ + - ]: 623 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
3181 : :
3182 [ + - ]: 623 : switch( GetType() )
[ + + - - ]
3183 : : {
3184 : : case nsRedlineType_t::REDLINE_INSERT: // Content has been inserted
3185 : 617 : bIsVisible = sal_True;
3186 [ - + ]: 617 : if( 1 <= nLoop )
3187 [ # # ]: 0 : MoveFromSection();
3188 : 617 : break;
3189 : :
3190 : : case nsRedlineType_t::REDLINE_DELETE: // Content has been deleted
3191 : 6 : bIsVisible = sal_False;
3192 [ - + + - ]: 6 : switch( nLoop )
3193 : : {
3194 [ # # ]: 0 : case 0: MoveToSection(); break;
3195 [ + - ]: 3 : case 1: CopyToSection(); break;
3196 [ + - ]: 3 : case 2: DelCopyOfSection(); break;
3197 : : }
3198 : 6 : break;
3199 : :
3200 : : case nsRedlineType_t::REDLINE_FORMAT: // Attributes have been applied
3201 : : case nsRedlineType_t::REDLINE_TABLE: // Table structure has been modified
3202 [ # # ]: 0 : if( 1 <= nLoop )
3203 [ # # ]: 0 : InvalidateRange();
3204 : 0 : break;
3205 : : default:
3206 : 0 : break;
3207 : : }
3208 [ + - ][ + - ]: 623 : pDoc->SetRedlineMode_intern( eOld );
3209 : 623 : }
3210 : :
3211 : 0 : void SwRedline::ShowOriginal( sal_uInt16 nLoop )
3212 : : {
3213 : 0 : SwDoc* pDoc = GetDoc();
3214 [ # # ]: 0 : RedlineMode_t eOld = pDoc->GetRedlineMode();
3215 : : SwRedlineData* pCur;
3216 : :
3217 [ # # ]: 0 : pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
3218 [ # # ][ # # ]: 0 : ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
3219 : :
3220 : : // Determine the Type, it's the first on Stack
3221 [ # # ]: 0 : for( pCur = pRedlineData; pCur->pNext; )
3222 : 0 : pCur = pCur->pNext;
3223 : :
3224 [ # # # # ]: 0 : switch( pCur->eType )
3225 : : {
3226 : : case nsRedlineType_t::REDLINE_INSERT: // Content has been inserted
3227 : 0 : bIsVisible = sal_False;
3228 [ # # # # ]: 0 : switch( nLoop )
3229 : : {
3230 [ # # ]: 0 : case 0: MoveToSection(); break;
3231 [ # # ]: 0 : case 1: CopyToSection(); break;
3232 [ # # ]: 0 : case 2: DelCopyOfSection(); break;
3233 : : }
3234 : 0 : break;
3235 : :
3236 : : case nsRedlineType_t::REDLINE_DELETE: // Inhalt wurde eingefuegt
3237 : 0 : bIsVisible = sal_True;
3238 [ # # ]: 0 : if( 1 <= nLoop )
3239 [ # # ]: 0 : MoveFromSection();
3240 : 0 : break;
3241 : :
3242 : : case nsRedlineType_t::REDLINE_FORMAT: // Attributes have been applied
3243 : : case nsRedlineType_t::REDLINE_TABLE: // Table structure has been modified
3244 [ # # ]: 0 : if( 1 <= nLoop )
3245 [ # # ]: 0 : InvalidateRange();
3246 : 0 : break;
3247 : : default:
3248 : 0 : break;
3249 : : }
3250 [ # # ][ # # ]: 0 : pDoc->SetRedlineMode_intern( eOld );
3251 : 0 : }
3252 : :
3253 : :
3254 : 2418 : void SwRedline::InvalidateRange() // trigger the Layout
3255 : : {
3256 : 2418 : sal_uLong nSttNd = GetMark()->nNode.GetIndex(),
3257 : 2418 : nEndNd = GetPoint()->nNode.GetIndex();
3258 : 2418 : sal_uInt16 nSttCnt = GetMark()->nContent.GetIndex(),
3259 : 2418 : nEndCnt = GetPoint()->nContent.GetIndex();
3260 : :
3261 [ + - ][ + + ]: 2418 : if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
[ + - ]
3262 : : {
3263 : 3 : sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
3264 : 3 : nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp;
3265 : : }
3266 : :
3267 [ + - ]: 2418 : SwUpdateAttr aHt( 0, 0, RES_FMT_CHG );
3268 [ + - ]: 2418 : SwNodes& rNds = GetDoc()->GetNodes();
3269 [ + + ]: 4836 : for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
3270 : : {
3271 [ + - ]: 2418 : SwNode* pNd = rNds[n];
3272 [ + - ]: 2418 : if( pNd->IsTxtNode() )
3273 : : {
3274 [ + - ]: 2418 : aHt.nStart = n == nSttNd ? nSttCnt : 0;
3275 [ - + ][ # # ]: 2418 : aHt.nEnd = n == nEndNd ? nEndCnt : ((SwTxtNode*)pNd)->GetTxt().Len();
3276 [ + - ][ + - ]: 2418 : ((SwTxtNode*)pNd)->ModifyNotification( &aHt, &aHt );
3277 : : }
3278 [ + - ]: 2418 : }
3279 : 2418 : }
3280 : :
3281 : : /*************************************************************************
3282 : : * SwRedline::CalcStartEnd()
3283 : : * Calculates the start and end position of the intersection rTmp and
3284 : : * text node nNdIdx
3285 : : *************************************************************************/
3286 : :
3287 : 15 : void SwRedline::CalcStartEnd( sal_uLong nNdIdx, sal_uInt16& nStart, sal_uInt16& nEnd ) const
3288 : : {
3289 : 15 : const SwPosition *pRStt = Start(), *pREnd = End();
3290 [ - + ]: 15 : if( pRStt->nNode < nNdIdx )
3291 : : {
3292 [ # # ]: 0 : if( pREnd->nNode > nNdIdx )
3293 : : {
3294 : 0 : nStart = 0; // Paragraph is completely enclosed
3295 : 0 : nEnd = STRING_LEN;
3296 : : }
3297 : : else
3298 : : {
3299 : : OSL_ENSURE( pREnd->nNode == nNdIdx,
3300 : : "SwRedlineItr::Seek: GetRedlinePos Error" );
3301 : 0 : nStart = 0; // Paragraph is overlapped in the beginning
3302 : 0 : nEnd = pREnd->nContent.GetIndex();
3303 : : }
3304 : : }
3305 [ + - ]: 15 : else if( pRStt->nNode == nNdIdx )
3306 : : {
3307 : 15 : nStart = pRStt->nContent.GetIndex();
3308 [ + - ]: 15 : if( pREnd->nNode == nNdIdx )
3309 : 15 : nEnd = pREnd->nContent.GetIndex(); // Within the Paragraph
3310 : : else
3311 : 0 : nEnd = STRING_LEN; // Paragraph is overlapped in the end
3312 : : }
3313 : : else
3314 : : {
3315 : 0 : nStart = STRING_LEN;
3316 : 0 : nEnd = STRING_LEN;
3317 : : }
3318 : 15 : }
3319 : :
3320 : 0 : void SwRedline::MoveToSection()
3321 : : {
3322 [ # # ]: 0 : if( !pCntntSect )
3323 : : {
3324 [ # # ]: 0 : const SwPosition* pStt = Start(),
3325 [ # # ]: 0 : * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
3326 : :
3327 : 0 : SwDoc* pDoc = GetDoc();
3328 [ # # ]: 0 : SwPaM aPam( *pStt, *pEnd );
3329 : 0 : SwCntntNode* pCSttNd = pStt->nNode.GetNode().GetCntntNode();
3330 : 0 : SwCntntNode* pCEndNd = pEnd->nNode.GetNode().GetCntntNode();
3331 : :
3332 [ # # ]: 0 : if( !pCSttNd )
3333 : : {
3334 : : // In order to not move other Redlines' indices, we set them
3335 : : // to the end (is exclusive)
3336 [ # # ]: 0 : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
3337 [ # # ]: 0 : for( sal_uInt16 n = 0; n < rTbl.size(); ++n )
3338 : : {
3339 [ # # ]: 0 : SwRedline* pRedl = rTbl[ n ];
3340 [ # # ][ # # ]: 0 : if( pRedl->GetBound(sal_True) == *pStt )
3341 [ # # ]: 0 : pRedl->GetBound(sal_True) = *pEnd;
3342 [ # # ][ # # ]: 0 : if( pRedl->GetBound(sal_False) == *pStt )
3343 [ # # ]: 0 : pRedl->GetBound(sal_False) = *pEnd;
3344 : : }
3345 : : }
3346 : :
3347 : : SwStartNode* pSttNd;
3348 [ # # ]: 0 : SwNodes& rNds = pDoc->GetNodes();
3349 [ # # ][ # # ]: 0 : if( pCSttNd || pCEndNd )
3350 : : {
3351 : 0 : SwTxtFmtColl* pColl = (pCSttNd && pCSttNd->IsTxtNode() )
3352 : : ? ((SwTxtNode*)pCSttNd)->GetTxtColl()
3353 : 0 : : (pCEndNd && pCEndNd->IsTxtNode() )
3354 : : ? ((SwTxtNode*)pCEndNd)->GetTxtColl()
3355 : : : pDoc->GetTxtCollFromPool(
3356 [ # # # # ]: 0 : RES_POOLCOLL_STANDARD );
[ # # # # ]
[ # # ]
3357 : :
3358 : 0 : pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
3359 [ # # ][ # # ]: 0 : SwNormalStartNode, pColl );
[ # # ]
3360 [ # # ]: 0 : SwTxtNode* pTxtNd = rNds[ pSttNd->GetIndex() + 1 ]->GetTxtNode();
3361 : :
3362 [ # # ]: 0 : SwNodeIndex aNdIdx( *pTxtNd );
3363 [ # # ][ # # ]: 0 : SwPosition aPos( aNdIdx, SwIndex( pTxtNd ));
[ # # ][ # # ]
3364 [ # # ][ # # ]: 0 : if( pCSttNd && pCEndNd )
3365 [ # # ]: 0 : pDoc->MoveAndJoin( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT );
3366 : : else
3367 : : {
3368 [ # # ][ # # ]: 0 : if( pCSttNd && !pCEndNd )
3369 : 0 : bDelLastPara = sal_True;
3370 : : pDoc->MoveRange( aPam, aPos,
3371 [ # # ]: 0 : IDocumentContentOperations::DOC_MOVEDEFAULT );
3372 [ # # ][ # # ]: 0 : }
3373 : : }
3374 : : else
3375 : : {
3376 : 0 : pSttNd = rNds.MakeEmptySection( SwNodeIndex( rNds.GetEndOfRedlines() ),
3377 [ # # ][ # # ]: 0 : SwNormalStartNode );
[ # # ]
3378 : :
3379 [ # # ]: 0 : SwPosition aPos( *pSttNd->EndOfSectionNode() );
3380 : : pDoc->MoveRange( aPam, aPos,
3381 [ # # ][ # # ]: 0 : IDocumentContentOperations::DOC_MOVEDEFAULT );
3382 : : }
3383 [ # # ][ # # ]: 0 : pCntntSect = new SwNodeIndex( *pSttNd );
3384 : :
3385 [ # # ]: 0 : if( pStt == GetPoint() )
3386 : 0 : Exchange();
3387 : :
3388 [ # # ][ # # ]: 0 : DeleteMark();
3389 : : }
3390 : : else
3391 : 0 : InvalidateRange();
3392 : 0 : }
3393 : :
3394 : 3 : void SwRedline::CopyToSection()
3395 : : {
3396 [ + - ]: 3 : if( !pCntntSect )
3397 : : {
3398 : 3 : const SwPosition* pStt = Start(),
3399 [ + - ]: 3 : * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
3400 : :
3401 : 3 : SwCntntNode* pCSttNd = pStt->nNode.GetNode().GetCntntNode();
3402 : 3 : SwCntntNode* pCEndNd = pEnd->nNode.GetNode().GetCntntNode();
3403 : :
3404 : : SwStartNode* pSttNd;
3405 : 3 : SwDoc* pDoc = GetDoc();
3406 : 3 : SwNodes& rNds = pDoc->GetNodes();
3407 : :
3408 : 3 : sal_Bool bSaveCopyFlag = pDoc->IsCopyIsMove(),
3409 : 3 : bSaveRdlMoveFlg = pDoc->IsRedlineMove();
3410 : 3 : pDoc->SetCopyIsMove( sal_True );
3411 : :
3412 : : // The IsRedlineMove() flag causes the behaviour of the
3413 : : // SwDoc::_CopyFlyInFly method to change, which will eventually be
3414 : : // called by the pDoc->Copy line below (through SwDoc::_Copy,
3415 : : // SwDoc::CopyWithFlyInFly). This rather obscure bugfix
3416 : : // apparently never really worked.
3417 : 3 : pDoc->SetRedlineMove( pStt->nContent == 0 );
3418 : :
3419 [ + - ]: 3 : if( pCSttNd )
3420 : : {
3421 : 3 : SwTxtFmtColl* pColl = (pCSttNd && pCSttNd->IsTxtNode() )
3422 : : ? ((SwTxtNode*)pCSttNd)->GetTxtColl()
3423 : : : pDoc->GetTxtCollFromPool(
3424 [ + - + - ]: 6 : RES_POOLCOLL_STANDARD );
[ # # ]
3425 : :
3426 : 3 : pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
3427 [ + - ][ + - ]: 3 : SwNormalStartNode, pColl );
[ + - ]
3428 : :
3429 [ + - ]: 3 : SwNodeIndex aNdIdx( *pSttNd, 1 );
3430 : 3 : SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode();
3431 [ + - ][ + - ]: 3 : SwPosition aPos( aNdIdx, SwIndex( pTxtNd ));
[ + - ][ + - ]
3432 [ + - ]: 3 : pDoc->CopyRange( *this, aPos, false );
3433 : :
3434 : : // Take over the style from the EndNode if needed
3435 : : // We don't want this in Doc::Copy
3436 [ + - ][ - + ]: 3 : if( pCEndNd && pCEndNd != pCSttNd )
3437 : : {
3438 : 0 : SwCntntNode* pDestNd = aPos.nNode.GetNode().GetCntntNode();
3439 [ # # ]: 0 : if( pDestNd )
3440 : : {
3441 [ # # ][ # # ]: 0 : if( pDestNd->IsTxtNode() && pCEndNd->IsTxtNode() )
[ # # ]
3442 : : ((SwTxtNode*)pCEndNd)->CopyCollFmt(
3443 [ # # ]: 0 : *(SwTxtNode*)pDestNd );
3444 : : else
3445 [ # # ]: 0 : pDestNd->ChgFmtColl( pCEndNd->GetFmtColl() );
3446 : : }
3447 [ + - ][ + - ]: 3 : }
3448 : : }
3449 : : else
3450 : : {
3451 : 0 : pSttNd = rNds.MakeEmptySection( SwNodeIndex( rNds.GetEndOfRedlines() ),
3452 [ # # ]: 0 : SwNormalStartNode );
3453 : :
3454 [ # # ]: 0 : if( pCEndNd )
3455 : : {
3456 [ # # ]: 0 : SwPosition aPos( *pSttNd->EndOfSectionNode() );
3457 [ # # ][ # # ]: 0 : pDoc->CopyRange( *this, aPos, false );
3458 : : }
3459 : : else
3460 : : {
3461 [ # # ]: 0 : SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() );
3462 [ # # ]: 0 : SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
3463 [ # # ][ # # ]: 0 : pDoc->CopyWithFlyInFly( aRg, 0, aInsPos );
[ # # ]
3464 : : }
3465 : : }
3466 [ + - ]: 3 : pCntntSect = new SwNodeIndex( *pSttNd );
3467 : :
3468 : 3 : pDoc->SetCopyIsMove( bSaveCopyFlag );
3469 : 3 : pDoc->SetRedlineMove( bSaveRdlMoveFlg );
3470 : : }
3471 : 3 : }
3472 : :
3473 : 3 : void SwRedline::DelCopyOfSection()
3474 : : {
3475 [ + - ]: 3 : if( pCntntSect )
3476 : : {
3477 [ + - ]: 3 : const SwPosition* pStt = Start(),
3478 [ + - ]: 3 : * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
3479 : :
3480 : 3 : SwDoc* pDoc = GetDoc();
3481 [ + - ]: 3 : SwPaM aPam( *pStt, *pEnd );
3482 : 3 : SwCntntNode* pCSttNd = pStt->nNode.GetNode().GetCntntNode();
3483 : 3 : SwCntntNode* pCEndNd = pEnd->nNode.GetNode().GetCntntNode();
3484 : :
3485 [ - + ]: 3 : if( !pCSttNd )
3486 : : {
3487 : : // In order to not move other Redlines' indices, we set them
3488 : : // to the end (is exclusive)
3489 [ # # ]: 0 : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
3490 [ # # ]: 0 : for( sal_uInt16 n = 0; n < rTbl.size(); ++n )
3491 : : {
3492 [ # # ]: 0 : SwRedline* pRedl = rTbl[ n ];
3493 [ # # ][ # # ]: 0 : if( pRedl->GetBound(sal_True) == *pStt )
3494 [ # # ]: 0 : pRedl->GetBound(sal_True) = *pEnd;
3495 [ # # ][ # # ]: 0 : if( pRedl->GetBound(sal_False) == *pStt )
3496 [ # # ]: 0 : pRedl->GetBound(sal_False) = *pEnd;
3497 : : }
3498 : : }
3499 : :
3500 [ + - ][ + - ]: 3 : if( pCSttNd && pCEndNd )
3501 : : {
3502 : : // #i100466# - force a <join next> on <delete and join> operation
3503 [ + - ]: 3 : pDoc->DeleteAndJoin( aPam, true );
3504 : : }
3505 [ # # ][ # # ]: 0 : else if( pCSttNd || pCEndNd )
3506 : : {
3507 [ # # ][ # # ]: 0 : if( pCSttNd && !pCEndNd )
3508 : 0 : bDelLastPara = sal_True;
3509 [ # # ]: 0 : pDoc->DeleteRange( aPam );
3510 : :
3511 [ # # ]: 0 : if( bDelLastPara )
3512 : : {
3513 : : // To prevent dangling references to the paragraph to
3514 : : // be deleted, redline that point into this paragraph should be
3515 : : // moved to the new end position. Since redlines in the redline
3516 : : // table are sorted and the pEnd position is an endnode (see
3517 : : // bDelLastPara condition above), only redlines before the
3518 : : // current ones can be affected.
3519 [ # # ]: 0 : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
3520 [ # # ]: 0 : sal_uInt16 n = rTbl.GetPos( this );
3521 : : OSL_ENSURE( n != USHRT_MAX, "How strange. We don't exist!" );
3522 [ # # ][ # # ]: 0 : for( sal_Bool bBreak = sal_False; !bBreak && n > 0; )
[ # # ]
3523 : : {
3524 : 0 : --n;
3525 : 0 : bBreak = sal_True;
3526 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_True) == *aPam.GetPoint() )
[ # # ]
3527 : : {
3528 [ # # ][ # # ]: 0 : rTbl[ n ]->GetBound(sal_True) = *pEnd;
3529 : 0 : bBreak = sal_False;
3530 : : }
3531 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_False) == *aPam.GetPoint() )
[ # # ]
3532 : : {
3533 [ # # ][ # # ]: 0 : rTbl[ n ]->GetBound(sal_False) = *pEnd;
3534 : 0 : bBreak = sal_False;
3535 : : }
3536 : : }
3537 : :
3538 [ # # ]: 0 : SwPosition aEnd( *pEnd );
3539 [ # # ]: 0 : *GetPoint() = *pEnd;
3540 [ # # ]: 0 : *GetMark() = *pEnd;
3541 [ # # ]: 0 : DeleteMark();
3542 : :
3543 [ # # ]: 0 : aPam.GetBound( sal_True ).nContent.Assign( 0, 0 );
3544 [ # # ]: 0 : aPam.GetBound( sal_False ).nContent.Assign( 0, 0 );
3545 [ # # ]: 0 : aPam.DeleteMark();
3546 [ # # ][ # # ]: 0 : pDoc->DelFullPara( aPam );
3547 : 0 : }
3548 : : }
3549 : : else
3550 : : {
3551 [ # # ]: 0 : pDoc->DeleteRange( aPam );
3552 : : }
3553 : :
3554 [ + - ]: 3 : if( pStt == GetPoint() )
3555 : 3 : Exchange();
3556 : :
3557 [ + - ][ + - ]: 3 : DeleteMark();
3558 : : }
3559 : 3 : }
3560 : :
3561 : 0 : void SwRedline::MoveFromSection()
3562 : : {
3563 [ # # ]: 0 : if( pCntntSect )
3564 : : {
3565 : 0 : SwDoc* pDoc = GetDoc();
3566 [ # # ]: 0 : const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
3567 [ # # ][ # # ]: 0 : std::vector<SwPosition*> aBeforeArr, aBehindArr;
3568 [ # # ]: 0 : sal_uInt16 nMyPos = rTbl.GetPos( this );
3569 : : OSL_ENSURE( this, "this is not in the array?" );
3570 : 0 : sal_Bool bBreak = sal_False;
3571 : : sal_uInt16 n;
3572 : :
3573 [ # # ][ # # ]: 0 : for( n = nMyPos+1; !bBreak && n < rTbl.size(); ++n )
[ # # ]
3574 : : {
3575 : 0 : bBreak = sal_True;
3576 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_True) == *GetPoint() )
[ # # ]
3577 : : {
3578 [ # # ][ # # ]: 0 : aBehindArr.push_back( &rTbl[ n ]->GetBound(sal_True) );
3579 : 0 : bBreak = sal_False;
3580 : : }
3581 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_False) == *GetPoint() )
[ # # ]
3582 : : {
3583 [ # # ][ # # ]: 0 : aBehindArr.push_back( &rTbl[ n ]->GetBound(sal_False) );
3584 : 0 : bBreak = sal_False;
3585 : : }
3586 : : }
3587 [ # # ][ # # ]: 0 : for( bBreak = sal_False, n = nMyPos; !bBreak && n ; )
[ # # ]
3588 : : {
3589 : 0 : --n;
3590 : 0 : bBreak = sal_True;
3591 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_True) == *GetPoint() )
[ # # ]
3592 : : {
3593 [ # # ][ # # ]: 0 : aBeforeArr.push_back( &rTbl[ n ]->GetBound(sal_True) );
3594 : 0 : bBreak = sal_False;
3595 : : }
3596 [ # # ][ # # ]: 0 : if( rTbl[ n ]->GetBound(sal_False) == *GetPoint() )
[ # # ]
3597 : : {
3598 [ # # ][ # # ]: 0 : aBeforeArr.push_back( &rTbl[ n ]->GetBound(sal_False) );
3599 : 0 : bBreak = sal_False;
3600 : : }
3601 : : }
3602 : :
3603 : 0 : const SwNode* pKeptCntntSectNode( &pCntntSect->GetNode() ); // #i95711#
3604 : : {
3605 : 0 : SwPaM aPam( pCntntSect->GetNode(),
3606 : 0 : *pCntntSect->GetNode().EndOfSectionNode(), 1,
3607 [ # # ][ # # ]: 0 : ( bDelLastPara ? -2 : -1 ) );
3608 : 0 : SwCntntNode* pCNd = aPam.GetCntntNode();
3609 [ # # ]: 0 : if( pCNd )
3610 [ # # ][ # # ]: 0 : aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
[ # # ]
3611 : : else
3612 [ # # ]: 0 : aPam.GetPoint()->nNode++;
3613 : :
3614 [ # # ]: 0 : SwFmtColl* pColl = pCNd && pCNd->Len() && aPam.GetPoint()->nNode !=
3615 : 0 : aPam.GetMark()->nNode
3616 [ # # ]: 0 : ? pCNd->GetFmtColl() : 0;
[ # # # # ]
3617 : :
3618 [ # # ]: 0 : SwNodeIndex aNdIdx( GetPoint()->nNode, -1 );
3619 : 0 : sal_uInt16 nPos = GetPoint()->nContent.GetIndex();
3620 : :
3621 [ # # ]: 0 : SwPosition aPos( *GetPoint() );
3622 [ # # ][ # # ]: 0 : if( bDelLastPara && *aPam.GetPoint() == *aPam.GetMark() )
[ # # ][ # # ]
3623 : : {
3624 [ # # ]: 0 : aPos.nNode--;
3625 : :
3626 [ # # ]: 0 : pDoc->AppendTxtNode( aPos );
3627 : : }
3628 : : else
3629 : : {
3630 : : pDoc->MoveRange( aPam, aPos,
3631 [ # # ]: 0 : IDocumentContentOperations::DOC_MOVEALLFLYS );
3632 : : }
3633 : :
3634 [ # # ]: 0 : SetMark();
3635 [ # # ]: 0 : *GetPoint() = aPos;
3636 [ # # ]: 0 : GetMark()->nNode = aNdIdx.GetIndex() + 1;
3637 : 0 : pCNd = GetMark()->nNode.GetNode().GetCntntNode();
3638 [ # # ][ # # ]: 0 : GetMark()->nContent.Assign( pCNd, nPos );
3639 : :
3640 [ # # ]: 0 : if( bDelLastPara )
3641 : : {
3642 [ # # ]: 0 : GetPoint()->nNode++;
3643 [ # # ][ # # ]: 0 : GetPoint()->nContent.Assign( pCNd = GetCntntNode(), 0 );
3644 : 0 : bDelLastPara = sal_False;
3645 : : }
3646 [ # # ]: 0 : else if( pColl )
3647 : 0 : pCNd = GetCntntNode();
3648 : :
3649 [ # # ][ # # ]: 0 : if( pColl && pCNd )
3650 [ # # ][ # # ]: 0 : pCNd->ChgFmtColl( pColl );
[ # # ][ # # ]
3651 : : }
3652 : : // #i95771#
3653 : : // Under certain conditions the previous <SwDoc::Move(..)> has already
3654 : : // removed the change tracking section of this <SwRedline> instance from
3655 : : // the change tracking nodes area.
3656 : : // Thus, check if <pCntntSect> still points to the change tracking section
3657 : : // by comparing it with the "indexed" <SwNode> instance copied before
3658 : : // perform the intrinsic move.
3659 : : // Note: Such condition is e.g. a "delete" change tracking only containing a table.
3660 [ # # ]: 0 : if ( &pCntntSect->GetNode() == pKeptCntntSectNode )
3661 : : {
3662 [ # # ]: 0 : pDoc->DeleteSection( &pCntntSect->GetNode() );
3663 : : }
3664 [ # # ][ # # ]: 0 : delete pCntntSect, pCntntSect = 0;
3665 : :
3666 : : // adjustment of redline table positions must take start and
3667 : : // end into account, not point and mark.
3668 [ # # ]: 0 : for( n = 0; n < aBeforeArr.size(); ++n )
3669 [ # # ][ # # ]: 0 : *aBeforeArr[ n ] = *Start();
[ # # ]
3670 [ # # ]: 0 : for( n = 0; n < aBehindArr.size(); ++n )
3671 [ # # ][ # # ]: 0 : *aBehindArr[ n ] = *End();
[ # # ]
3672 : : }
3673 : : else
3674 : 0 : InvalidateRange();
3675 : 0 : }
3676 : :
3677 : : // for Undo
3678 : 0 : void SwRedline::SetContentIdx( const SwNodeIndex* pIdx )
3679 : : {
3680 [ # # ][ # # ]: 0 : if( pIdx && !pCntntSect )
3681 : : {
3682 [ # # ]: 0 : pCntntSect = new SwNodeIndex( *pIdx );
3683 : 0 : bIsVisible = sal_False;
3684 : : }
3685 [ # # ][ # # ]: 0 : else if( !pIdx && pCntntSect )
3686 : : {
3687 [ # # ]: 0 : delete pCntntSect, pCntntSect = 0;
3688 : 0 : bIsVisible = sal_False;
3689 : : }
3690 : : else
3691 : : {
3692 : : OSL_FAIL("SwRedline::SetContentIdx: invalid state");
3693 : : }
3694 : 0 : }
3695 : :
3696 : 2229 : sal_Bool SwRedline::CanCombine( const SwRedline& rRedl ) const
3697 : : {
3698 : 4458 : return IsVisible() && rRedl.IsVisible() &&
3699 [ + + ]: 4458 : pRedlineData->CanCombine( *rRedl.pRedlineData );
[ + - + - ]
3700 : : }
3701 : :
3702 : 0 : void SwRedline::PushData( const SwRedline& rRedl, sal_Bool bOwnAsNext )
3703 : : {
3704 [ # # ]: 0 : SwRedlineData* pNew = new SwRedlineData( *rRedl.pRedlineData, sal_False );
3705 [ # # ]: 0 : if( bOwnAsNext )
3706 : : {
3707 : 0 : pNew->pNext = pRedlineData;
3708 : 0 : pRedlineData = pNew;
3709 : : }
3710 : : else
3711 : : {
3712 : 0 : pNew->pNext = pRedlineData->pNext;
3713 : 0 : pRedlineData->pNext = pNew;
3714 : : }
3715 : 0 : }
3716 : :
3717 : 0 : sal_Bool SwRedline::PopData()
3718 : : {
3719 [ # # ]: 0 : if( !pRedlineData->pNext )
3720 : 0 : return sal_False;
3721 : 0 : SwRedlineData* pCur = pRedlineData;
3722 : 0 : pRedlineData = pCur->pNext;
3723 : 0 : pCur->pNext = 0;
3724 [ # # ]: 0 : delete pCur;
3725 : 0 : return sal_True;
3726 : : }
3727 : :
3728 : 0 : sal_uInt16 SwRedline::GetStackCount() const
3729 : : {
3730 : 0 : sal_uInt16 nRet = 1;
3731 [ # # ]: 0 : for( SwRedlineData* pCur = pRedlineData; pCur->pNext; ++nRet )
3732 : 0 : pCur = pCur->pNext;
3733 : 0 : return nRet;
3734 : : }
3735 : :
3736 : 2532 : sal_uInt16 SwRedline::GetAuthor( sal_uInt16 nPos ) const
3737 : : {
3738 : 2532 : return GetRedlineData(nPos).nAuthor;
3739 : : }
3740 : :
3741 : 1566 : const String& SwRedline::GetAuthorString( sal_uInt16 nPos ) const
3742 : : {
3743 : 1566 : return SW_MOD()->GetRedlineAuthor(GetRedlineData(nPos).nAuthor);
3744 : : }
3745 : :
3746 : 0 : const DateTime& SwRedline::GetTimeStamp( sal_uInt16 nPos ) const
3747 : : {
3748 : 0 : return GetRedlineData(nPos).aStamp;
3749 : : }
3750 : :
3751 : 3937 : RedlineType_t SwRedline::GetRealType( sal_uInt16 nPos ) const
3752 : : {
3753 : 3937 : return GetRedlineData(nPos).eType;
3754 : : }
3755 : :
3756 : 0 : const String& SwRedline::GetComment( sal_uInt16 nPos ) const
3757 : : {
3758 : 0 : return GetRedlineData(nPos).sComment;
3759 : : }
3760 : :
3761 : 0 : int SwRedline::operator==( const SwRedline& rCmp ) const
3762 : : {
3763 : 0 : return this == &rCmp;
3764 : : }
3765 : :
3766 : 2176 : int SwRedline::operator<( const SwRedline& rCmp ) const
3767 : : {
3768 : 2176 : sal_Bool nResult = sal_False;
3769 : :
3770 [ + - ]: 2176 : if (*Start() < *rCmp.Start())
3771 : 2176 : nResult = sal_True;
3772 [ # # ]: 0 : else if (*Start() == *rCmp.Start())
3773 [ # # ]: 0 : if (*End() < *rCmp.End())
3774 : 0 : nResult = sal_True;
3775 : :
3776 : 2176 : return nResult;
3777 : : }
3778 : :
3779 : 8035 : const SwRedlineData & SwRedline::GetRedlineData(sal_uInt16 nPos) const
3780 : : {
3781 : 8035 : SwRedlineData * pCur = pRedlineData;
3782 : :
3783 [ - + ][ # # ]: 8035 : while (nPos > 0 && NULL != pCur->pNext)
[ - + ]
3784 : : {
3785 : 0 : pCur = pCur->pNext;
3786 : :
3787 : 0 : nPos--;
3788 : : }
3789 : :
3790 : : OSL_ENSURE( 0 == nPos, "Pos is too big" );
3791 : :
3792 : 8035 : return *pCur;
3793 : : }
3794 : :
3795 : 0 : String SwRedline::GetDescr(sal_uInt16 nPos)
3796 : : {
3797 [ # # ]: 0 : String aResult;
3798 : :
3799 : : // get description of redline data (e.g.: "insert $1")
3800 [ # # ][ # # ]: 0 : aResult = GetRedlineData(nPos).GetDescr();
[ # # ][ # # ]
3801 : :
3802 : 0 : SwPaM * pPaM = NULL;
3803 : 0 : bool bDeletePaM = false;
3804 : :
3805 : : // if this redline is visible the content is in this PaM
3806 [ # # ]: 0 : if (NULL == pCntntSect)
3807 : : {
3808 : 0 : pPaM = this;
3809 : : }
3810 : : else // otherwise it is saved in pCntntSect
3811 : : {
3812 [ # # ]: 0 : SwNodeIndex aTmpIdx( *pCntntSect->GetNode().EndOfSectionNode() );
3813 [ # # ][ # # ]: 0 : pPaM = new SwPaM(*pCntntSect, aTmpIdx );
3814 [ # # ]: 0 : bDeletePaM = true;
3815 : : }
3816 : :
3817 : : // replace $1 in description by description of the redlines text
3818 [ # # ]: 0 : String aTmpStr;
3819 [ # # ][ # # ]: 0 : aTmpStr += String(SW_RES(STR_START_QUOTE));
[ # # ]
3820 : : aTmpStr += ShortenString(pPaM->GetTxt(), nUndoStringLength,
3821 [ # # ][ # # ]: 0 : String(SW_RES(STR_LDOTS)));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3822 [ # # ][ # # ]: 0 : aTmpStr += String(SW_RES(STR_END_QUOTE));
[ # # ]
3823 : :
3824 [ # # ]: 0 : SwRewriter aRewriter;
3825 [ # # ]: 0 : aRewriter.AddRule(UndoArg1, aTmpStr);
3826 : :
3827 [ # # ][ # # ]: 0 : aResult = aRewriter.Apply(aResult);
[ # # ]
3828 : :
3829 [ # # ]: 0 : if (bDeletePaM)
3830 [ # # ][ # # ]: 0 : delete pPaM;
3831 : :
3832 [ # # ][ # # ]: 0 : return aResult;
3833 : : }
3834 : :
3835 : :
3836 : 19239 : bool SwDoc::IsInRedlines(const SwNode & rNode) const
3837 : : {
3838 [ + - ]: 19239 : SwPosition aPos(rNode);
3839 [ + - ]: 19239 : SwNode & rEndOfRedlines = GetNodes().GetEndOfRedlines();
3840 : 19239 : SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()),
3841 [ + - ][ + - ]: 38478 : SwPosition(rEndOfRedlines));
[ + - ]
[ + - + - ]
3842 : :
3843 [ + - ][ + - ]: 19239 : return aPam.ContainsPosition(aPos) ? true : false;
[ + - ]
3844 : : }
3845 : :
3846 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|