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 <tools/shl.hxx> // SHL_CALC
30 : : #include <tools/rtti.hxx>
31 : : #include <svl/zforlist.hxx>
32 : : #include <svl/itemset.hxx>
33 : : #include <svl/isethint.hxx>
34 : : #include <svl/itempool.hxx>
35 : : #include <sfx2/app.hxx>
36 : : #include <unotools/useroptions.hxx>
37 : : #include <sfx2/sfxsids.hrc>
38 : :
39 : : #include "cell.hxx"
40 : : #include "document.hxx"
41 : : #include "dociter.hxx"
42 : : #include "global.hxx"
43 : : #include "rechead.hxx"
44 : : #include "scerrors.hxx"
45 : : #include "scmod.hxx" // SC_MOD
46 : : #include "inputopt.hxx" // GetExpandRefs
47 : : #include "patattr.hxx"
48 : : #include "hints.hxx"
49 : : #include "markdata.hxx"
50 : :
51 : : #include "globstr.hrc"
52 : :
53 : : #define SC_CHGTRACK_CXX
54 : : #include "chgtrack.hxx"
55 : :
56 : 51 : IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
57 : :
58 : 51 : IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionLinkEntry )
59 : :
60 : : // loaded MSB > eigenes => inkompatibel
61 : : #define SC_CHGTRACK_FILEFORMAT_FIRST 0x0001
62 : : #define SC_CHGTRACK_FILEFORMAT 0x0001
63 : :
64 : : // --- ScChangeAction ------------------------------------------------------
65 : :
66 : 0 : ScChangeAction::ScChangeAction( ScChangeActionType eTypeP, const ScRange& rRange )
67 : : :
68 : : aBigRange( rRange ),
69 : : aDateTime( DateTime::SYSTEM ),
70 : : pNext( NULL ),
71 : : pPrev( NULL ),
72 : : pLinkAny( NULL ),
73 : : pLinkDeletedIn( NULL ),
74 : : pLinkDeleted( NULL ),
75 : : pLinkDependent( NULL ),
76 : : nAction( 0 ),
77 : : nRejectAction( 0 ),
78 : : eType( eTypeP ),
79 : 0 : eState( SC_CAS_VIRGIN )
80 : : {
81 [ # # ]: 0 : aDateTime.ConvertToUTC();
82 : 0 : }
83 : :
84 : 0 : ScChangeAction::ScChangeAction(
85 : : ScChangeActionType eTypeP, const ScBigRange& rRange,
86 : : const sal_uLong nTempAction, const sal_uLong nTempRejectAction,
87 : : const ScChangeActionState eTempState, const DateTime& aTempDateTime,
88 : : const rtl::OUString& aTempUser, const rtl::OUString& aTempComment) :
89 : : aBigRange( rRange ),
90 : : aDateTime( aTempDateTime ),
91 : : aUser( aTempUser ),
92 : : aComment( aTempComment ),
93 : : pNext( NULL ),
94 : : pPrev( NULL ),
95 : : pLinkAny( NULL ),
96 : : pLinkDeletedIn( NULL ),
97 : : pLinkDeleted( NULL ),
98 : : pLinkDependent( NULL ),
99 : : nAction( nTempAction ),
100 : : nRejectAction( nTempRejectAction ),
101 : : eType( eTypeP ),
102 : 0 : eState( eTempState )
103 : : {
104 : 0 : }
105 : :
106 : 0 : ScChangeAction::ScChangeAction( ScChangeActionType eTypeP, const ScBigRange& rRange,
107 : : const sal_uLong nTempAction)
108 : : :
109 : : aBigRange( rRange ),
110 : : aDateTime( DateTime::SYSTEM ),
111 : : pNext( NULL ),
112 : : pPrev( NULL ),
113 : : pLinkAny( NULL ),
114 : : pLinkDeletedIn( NULL ),
115 : : pLinkDeleted( NULL ),
116 : : pLinkDependent( NULL ),
117 : : nAction( nTempAction ),
118 : : nRejectAction( 0 ),
119 : : eType( eTypeP ),
120 : 0 : eState( SC_CAS_VIRGIN )
121 : : {
122 [ # # ]: 0 : aDateTime.ConvertToUTC();
123 : 0 : }
124 : :
125 : :
126 : 0 : ScChangeAction::~ScChangeAction()
127 : : {
128 [ # # ]: 0 : RemoveAllLinks();
129 [ # # ]: 0 : }
130 : :
131 : 0 : bool ScChangeAction::IsInsertType() const
132 : : {
133 [ # # ][ # # ]: 0 : return eType == SC_CAT_INSERT_COLS || eType == SC_CAT_INSERT_ROWS || eType == SC_CAT_INSERT_TABS;
[ # # ]
134 : : }
135 : :
136 : 0 : bool ScChangeAction::IsDeleteType() const
137 : : {
138 [ # # ][ # # ]: 0 : return eType == SC_CAT_DELETE_COLS || eType == SC_CAT_DELETE_ROWS || eType == SC_CAT_DELETE_TABS;
[ # # ]
139 : : }
140 : :
141 : 0 : bool ScChangeAction::IsVirgin() const
142 : : {
143 : 0 : return eState == SC_CAS_VIRGIN;
144 : : }
145 : :
146 : 0 : bool ScChangeAction::IsAccepted() const
147 : : {
148 : 0 : return eState == SC_CAS_ACCEPTED;
149 : : }
150 : :
151 : 0 : bool ScChangeAction::IsRejected() const
152 : : {
153 : 0 : return eState == SC_CAS_REJECTED;
154 : : }
155 : :
156 : 0 : bool ScChangeAction::IsRejecting() const
157 : : {
158 : 0 : return nRejectAction != 0;
159 : : }
160 : :
161 : 0 : bool ScChangeAction::IsVisible() const
162 : : {
163 : : //! sequence order of execution is significant
164 [ # # ][ # # ]: 0 : if ( IsRejected() || GetType() == SC_CAT_DELETE_TABS || IsDeletedIn() )
[ # # ][ # # ]
165 : 0 : return false;
166 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
167 : 0 : return ((ScChangeActionContent*)this)->IsTopContent();
168 : 0 : return true;
169 : : }
170 : :
171 : :
172 : 0 : bool ScChangeAction::IsTouchable() const
173 : : {
174 : : //! sequence order of execution is significant
175 [ # # ][ # # ]: 0 : if ( IsRejected() || GetType() == SC_CAT_REJECT || IsDeletedIn() )
[ # # ][ # # ]
176 : 0 : return false;
177 : : // content may reject and be touchable if on top
178 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
179 : 0 : return ((ScChangeActionContent*)this)->IsTopContent();
180 [ # # ]: 0 : if ( IsRejecting() )
181 : 0 : return false;
182 : 0 : return true;
183 : : }
184 : :
185 : :
186 : 0 : bool ScChangeAction::IsClickable() const
187 : : {
188 : : //! sequence order of execution is significant
189 [ # # ]: 0 : if ( !IsVirgin() )
190 : 0 : return false;
191 [ # # ]: 0 : if ( IsDeletedIn() )
192 : 0 : return false;
193 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
194 : : {
195 : : ScChangeActionContentCellType eCCT =
196 : : ScChangeActionContent::GetContentCellType(
197 : 0 : ((ScChangeActionContent*)this)->GetNewCell() );
198 [ # # ]: 0 : if ( eCCT == SC_CACCT_MATREF )
199 : 0 : return false;
200 [ # # ]: 0 : if ( eCCT == SC_CACCT_MATORG )
201 : : { // no Accept-Select if one of the references is in a deleted col/row
202 : : const ScChangeActionLinkEntry* pL =
203 : 0 : ((ScChangeActionContent*)this)->GetFirstDependentEntry();
204 [ # # ]: 0 : while ( pL )
205 : : {
206 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
207 [ # # ][ # # ]: 0 : if ( p && p->IsDeletedIn() )
[ # # ]
208 : 0 : return false;
209 : 0 : pL = pL->GetNext();
210 : : }
211 : : }
212 : 0 : return true; // for Select() a content doesn't have to be touchable
213 : : }
214 : 0 : return IsTouchable(); // Accept()/Reject() only on touchables
215 : : }
216 : :
217 : :
218 : 0 : bool ScChangeAction::IsRejectable() const
219 : : {
220 : : //! sequence order of execution is significant
221 [ # # ]: 0 : if ( !IsClickable() )
222 : 0 : return false;
223 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
224 : : {
225 [ # # ]: 0 : if ( ((ScChangeActionContent*)this)->IsOldMatrixReference() )
226 : 0 : return false;
227 : : ScChangeActionContent* pNextContent =
228 : 0 : ((ScChangeActionContent*)this)->GetNextContent();
229 [ # # ]: 0 : if ( pNextContent == NULL )
230 : 0 : return true; // *this is TopContent
231 : 0 : return pNextContent->IsRejected(); // *this is next rejectable
232 : : }
233 : 0 : return IsTouchable();
234 : : }
235 : :
236 : :
237 : 0 : bool ScChangeAction::IsInternalRejectable() const
238 : : {
239 : : //! sequence order of execution is significant
240 [ # # ]: 0 : if ( !IsVirgin() )
241 : 0 : return false;
242 [ # # ]: 0 : if ( IsDeletedIn() )
243 : 0 : return false;
244 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
245 : : {
246 : : ScChangeActionContent* pNextContent =
247 : 0 : ((ScChangeActionContent*)this)->GetNextContent();
248 [ # # ]: 0 : if ( pNextContent == NULL )
249 : 0 : return true; // *this is TopContent
250 : 0 : return pNextContent->IsRejected(); // *this is next rejectable
251 : : }
252 : 0 : return IsTouchable();
253 : : }
254 : :
255 : :
256 : 0 : bool ScChangeAction::IsDialogRoot() const
257 : : {
258 : 0 : return IsInternalRejectable(); // only rejectables in root
259 : : }
260 : :
261 : :
262 : 0 : bool ScChangeAction::IsDialogParent() const
263 : : {
264 : : //! sequence order of execution is significant
265 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
266 : : {
267 [ # # ]: 0 : if ( !IsDialogRoot() )
268 : 0 : return false;
269 [ # # ][ # # ]: 0 : if ( ((ScChangeActionContent*)this)->IsMatrixOrigin() && HasDependent() )
[ # # ]
270 : 0 : return true;
271 : : ScChangeActionContent* pPrevContent =
272 : 0 : ((ScChangeActionContent*)this)->GetPrevContent();
273 [ # # ][ # # ]: 0 : return pPrevContent && pPrevContent->IsVirgin();
274 : : }
275 [ # # ]: 0 : if ( HasDependent() )
276 [ # # ]: 0 : return IsDeleteType() ? true : !IsDeletedIn();
277 [ # # ]: 0 : if ( HasDeleted() )
278 : : {
279 [ # # ]: 0 : if ( IsDeleteType() )
280 : : {
281 [ # # ]: 0 : if ( IsDialogRoot() )
282 : 0 : return true;
283 : 0 : ScChangeActionLinkEntry* pL = pLinkDeleted;
284 [ # # ]: 0 : while ( pL )
285 : : {
286 : 0 : ScChangeAction* p = pL->GetAction();
287 [ # # ][ # # ]: 0 : if ( p && p->GetType() != eType )
[ # # ]
288 : 0 : return true;
289 : 0 : pL = pL->GetNext();
290 : : }
291 : : }
292 : : else
293 : 0 : return true;
294 : : }
295 : 0 : return false;
296 : : }
297 : :
298 : :
299 : 0 : bool ScChangeAction::IsMasterDelete() const
300 : : {
301 [ # # ]: 0 : if ( !IsDeleteType() )
302 : 0 : return false;
303 : 0 : ScChangeActionDel* pDel = (ScChangeActionDel*) this;
304 [ # # ][ # # ]: 0 : return pDel->IsMultiDelete() && (pDel->IsTopDelete() || pDel->IsRejectable());
[ # # ]
305 : : }
306 : :
307 : :
308 : 0 : void ScChangeAction::RemoveAllLinks()
309 : : {
310 : 0 : RemoveAllAnyLinks();
311 : 0 : RemoveAllDeletedIn();
312 : 0 : RemoveAllDeleted();
313 : 0 : RemoveAllDependent();
314 : 0 : }
315 : :
316 : :
317 : 0 : void ScChangeAction::RemoveAllAnyLinks()
318 : : {
319 [ # # ]: 0 : while ( pLinkAny )
320 [ # # ]: 0 : delete pLinkAny; // rueckt sich selbst hoch
321 : 0 : }
322 : :
323 : :
324 : 0 : bool ScChangeAction::RemoveDeletedIn( const ScChangeAction* p )
325 : : {
326 : 0 : bool bRemoved = false;
327 : 0 : ScChangeActionLinkEntry* pL = GetDeletedIn();
328 [ # # ]: 0 : while ( pL )
329 : : {
330 : 0 : ScChangeActionLinkEntry* pNextLink = pL->GetNext();
331 [ # # ]: 0 : if ( pL->GetAction() == p )
332 : : {
333 [ # # ]: 0 : delete pL;
334 : 0 : bRemoved = true;
335 : : }
336 : 0 : pL = pNextLink;
337 : : }
338 : 0 : return bRemoved;
339 : : }
340 : :
341 : 0 : bool ScChangeAction::IsDeletedIn() const
342 : : {
343 : 0 : return GetDeletedIn() != NULL;
344 : : }
345 : :
346 : 0 : bool ScChangeAction::IsDeletedIn( const ScChangeAction* p ) const
347 : : {
348 : 0 : ScChangeActionLinkEntry* pL = GetDeletedIn();
349 [ # # ]: 0 : while ( pL )
350 : : {
351 [ # # ]: 0 : if ( pL->GetAction() == p )
352 : 0 : return true;
353 : 0 : pL = pL->GetNext();
354 : : }
355 : 0 : return false;
356 : : }
357 : :
358 : 0 : void ScChangeAction::RemoveAllDeletedIn()
359 : : {
360 : : //! nicht vom evtl. TopContent sondern wirklich dieser
361 [ # # ]: 0 : while ( pLinkDeletedIn )
362 [ # # ]: 0 : delete pLinkDeletedIn; // rueckt sich selbst hoch
363 : 0 : }
364 : :
365 : 0 : bool ScChangeAction::IsDeletedInDelType( ScChangeActionType eDelType ) const
366 : : {
367 : : ScChangeAction* p;
368 : 0 : ScChangeActionLinkEntry* pL = GetDeletedIn();
369 [ # # ]: 0 : if ( pL )
370 : : {
371 : : // InsertType fuer MergePrepare/MergeOwn
372 : : ScChangeActionType eInsType;
373 [ # # # # ]: 0 : switch ( eDelType )
374 : : {
375 : : case SC_CAT_DELETE_COLS :
376 : 0 : eInsType = SC_CAT_INSERT_COLS;
377 : 0 : break;
378 : : case SC_CAT_DELETE_ROWS :
379 : 0 : eInsType = SC_CAT_INSERT_ROWS;
380 : 0 : break;
381 : : case SC_CAT_DELETE_TABS :
382 : 0 : eInsType = SC_CAT_INSERT_TABS;
383 : 0 : break;
384 : : default:
385 : 0 : eInsType = SC_CAT_NONE;
386 : : }
387 [ # # ]: 0 : while ( pL )
388 : : {
389 [ # # # # : 0 : if ( (p = pL->GetAction()) != NULL &&
# # ][ # # ]
390 : 0 : (p->GetType() == eDelType || p->GetType() == eInsType) )
391 : 0 : return true;
392 : 0 : pL = pL->GetNext();
393 : : }
394 : : }
395 : 0 : return false;
396 : : }
397 : :
398 : 0 : bool ScChangeAction::HasDependent() const
399 : : {
400 : 0 : return pLinkDependent != NULL;
401 : : }
402 : :
403 : 0 : bool ScChangeAction::HasDeleted() const
404 : : {
405 : 0 : return pLinkDeleted != NULL;
406 : : }
407 : :
408 : 0 : void ScChangeAction::SetDeletedIn( ScChangeAction* p )
409 : : {
410 : 0 : ScChangeActionLinkEntry* pLink1 = AddDeletedIn( p );
411 : : ScChangeActionLinkEntry* pLink2;
412 [ # # ]: 0 : if ( GetType() == SC_CAT_CONTENT )
413 : 0 : pLink2 = p->AddDeleted( ((ScChangeActionContent*)this)->GetTopContent() );
414 : : else
415 : 0 : pLink2 = p->AddDeleted( this );
416 : 0 : pLink1->SetLink( pLink2 );
417 : 0 : }
418 : :
419 : :
420 : 0 : void ScChangeAction::RemoveAllDeleted()
421 : : {
422 [ # # ]: 0 : while ( pLinkDeleted )
423 [ # # ]: 0 : delete pLinkDeleted; // rueckt sich selbst hoch
424 : 0 : }
425 : :
426 : :
427 : 0 : void ScChangeAction::RemoveAllDependent()
428 : : {
429 [ # # ]: 0 : while ( pLinkDependent )
430 [ # # ]: 0 : delete pLinkDependent; // rueckt sich selbst hoch
431 : 0 : }
432 : :
433 : :
434 : 0 : DateTime ScChangeAction::GetDateTime() const
435 : : {
436 : 0 : DateTime aDT( aDateTime );
437 : 0 : aDT.ConvertToLocalTime();
438 : 0 : return aDT;
439 : : }
440 : :
441 : :
442 : 0 : void ScChangeAction::UpdateReference( const ScChangeTrack* /* pTrack */,
443 : : UpdateRefMode eMode, const ScBigRange& rRange,
444 : : sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz )
445 : : {
446 : 0 : ScRefUpdate::Update( eMode, rRange, nDx, nDy, nDz, GetBigRange() );
447 : 0 : }
448 : :
449 : :
450 : 0 : void ScChangeAction::GetDescription(
451 : : rtl::OUString& rStr, ScDocument* /* pDoc */, bool /* bSplitRange */, bool bWarning ) const
452 : : {
453 [ # # ][ # # ]: 0 : if (!IsRejecting() || !bWarning)
[ # # ]
454 : : return;
455 : :
456 : : // Add comment if rejection may have resulted in references
457 : : // not properly restored in formulas. See specification at
458 : : // http://specs.openoffice.org/calc/ease-of-use/redlining_comment.sxw
459 : :
460 [ # # ]: 0 : rtl::OUStringBuffer aBuf(rStr); // Take the original string.
461 [ # # ]: 0 : if (GetType() == SC_CAT_MOVE)
462 : : {
463 : : aBuf.append(
464 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_MOVE_REJECTION_WARNING));
[ # # ]
465 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
466 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
467 : : return;
468 : : }
469 : :
470 [ # # ]: 0 : if (IsInsertType())
471 : : {
472 : : aBuf.append(
473 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_DELETE_REJECTION_WARNING));
[ # # ]
474 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
475 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
476 : : return;
477 : : }
478 : :
479 [ # # ]: 0 : const ScChangeTrack* pCT = GetChangeTrack();
480 [ # # ]: 0 : if (!pCT)
481 : : return;
482 : :
483 [ # # ]: 0 : ScChangeAction* pReject = pCT->GetActionOrGenerated(GetRejectAction());
484 : :
485 [ # # ]: 0 : if (!pReject)
486 : : return;
487 : :
488 [ # # ]: 0 : if (pReject->GetType() == SC_CAT_MOVE)
489 : : {
490 : : aBuf.append(
491 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_MOVE_REJECTION_WARNING));
[ # # ]
492 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
493 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
494 : : return;
495 : : }
496 : :
497 [ # # ]: 0 : if (pReject->IsDeleteType())
498 : : {
499 : : aBuf.append(
500 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_DELETE_REJECTION_WARNING));
[ # # ]
501 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
502 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
503 : : return;
504 : : }
505 : :
506 [ # # ]: 0 : if (pReject->HasDependent())
507 : : {
508 [ # # ]: 0 : ScChangeActionMap aMap;
509 [ # # ]: 0 : pCT->GetDependents( pReject, aMap, false, true );
510 : 0 : ScChangeActionMap::iterator itChangeAction;
511 [ # # ]: 0 : for( itChangeAction = aMap.begin(); itChangeAction != aMap.end(); ++itChangeAction )
512 : : {
513 [ # # ]: 0 : if( itChangeAction->second->GetType() == SC_CAT_MOVE)
514 : : {
515 : : aBuf.append(
516 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_MOVE_REJECTION_WARNING));
[ # # ]
517 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
518 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
519 : : return;
520 : : }
521 : :
522 [ # # ]: 0 : if (pReject->IsDeleteType())
523 : : {
524 : : aBuf.append(
525 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_CHANGED_DELETE_REJECTION_WARNING));
[ # # ]
526 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
527 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
528 : : return;
529 : : }
530 [ # # ]: 0 : }
531 [ # # ]: 0 : }
532 : : }
533 : :
534 : :
535 : 0 : rtl::OUString ScChangeAction::GetRefString(
536 : : const ScBigRange& rRange, ScDocument* pDoc, bool bFlag3D ) const
537 : : {
538 : 0 : rtl::OUStringBuffer aBuf;
539 [ # # ][ # # ]: 0 : sal_uInt16 nFlags = ( rRange.IsValid( pDoc ) ? SCA_VALID : 0 );
540 [ # # ]: 0 : if ( !nFlags )
541 [ # # ][ # # ]: 0 : aBuf.append(ScGlobal::GetRscString(STR_NOREF_STR));
[ # # ]
542 : : else
543 : : {
544 : 0 : ScRange aTmpRange( rRange.MakeRange() );
545 [ # # # ]: 0 : switch ( GetType() )
546 : : {
547 : : case SC_CAT_INSERT_COLS :
548 : : case SC_CAT_DELETE_COLS :
549 [ # # ]: 0 : if ( bFlag3D )
550 : : {
551 : 0 : rtl::OUString aTmp;
552 [ # # ]: 0 : pDoc->GetName( aTmpRange.aStart.Tab(), aTmp );
553 [ # # ]: 0 : aBuf.append(aTmp);
554 [ # # ]: 0 : aBuf.append(sal_Unicode('.'));
555 : : }
556 [ # # ][ # # ]: 0 : aBuf.append(ScColToAlpha(aTmpRange.aStart.Col()));
[ # # ][ # # ]
557 [ # # ]: 0 : aBuf.append(sal_Unicode(':'));
558 [ # # ][ # # ]: 0 : aBuf.append(ScColToAlpha(aTmpRange.aEnd.Col()));
[ # # ][ # # ]
559 : 0 : break;
560 : : case SC_CAT_INSERT_ROWS :
561 : : case SC_CAT_DELETE_ROWS :
562 [ # # ]: 0 : if ( bFlag3D )
563 : : {
564 : 0 : rtl::OUString aTmp;
565 [ # # ]: 0 : pDoc->GetName( aTmpRange.aStart.Tab(), aTmp );
566 [ # # ]: 0 : aBuf.append(aTmp);
567 [ # # ]: 0 : aBuf.append(sal_Unicode('.'));
568 : : }
569 [ # # ]: 0 : aBuf.append(static_cast<sal_Int32>(aTmpRange.aStart.Row()+1));
570 [ # # ]: 0 : aBuf.append(sal_Unicode(':'));
571 [ # # ]: 0 : aBuf.append(static_cast<sal_Int32>(aTmpRange.aEnd.Row()+1));
572 : 0 : break;
573 : : default:
574 : : {
575 [ # # ][ # # ]: 0 : if ( bFlag3D || GetType() == SC_CAT_INSERT_TABS )
[ # # ]
576 : 0 : nFlags |= SCA_TAB_3D;
577 : :
578 : 0 : rtl::OUString aTmp;
579 [ # # ][ # # ]: 0 : aTmpRange.Format(aTmp, nFlags, pDoc, pDoc->GetAddressConvention());
580 [ # # ]: 0 : aBuf.append(aTmp);
581 : : }
582 : : }
583 [ # # ][ # # ]: 0 : if ( (bFlag3D && IsDeleteType()) || IsDeletedIn() )
[ # # ][ # # ]
[ # # ]
584 : : {
585 [ # # ]: 0 : aBuf.insert(0, sal_Unicode('('));
586 [ # # ]: 0 : aBuf.append(sal_Unicode(')'));
587 : : }
588 : : }
589 [ # # ]: 0 : return aBuf.makeStringAndClear();
590 : : }
591 : :
592 : 0 : const rtl::OUString& ScChangeAction::GetUser() const
593 : : {
594 : 0 : return aUser;
595 : : }
596 : :
597 : 0 : void ScChangeAction::SetUser( const rtl::OUString& r )
598 : : {
599 : 0 : aUser = r;
600 : 0 : }
601 : :
602 : 0 : const rtl::OUString& ScChangeAction::GetComment() const
603 : : {
604 : 0 : return aComment;
605 : : }
606 : :
607 : 0 : void ScChangeAction::SetComment( const rtl::OUString& rStr )
608 : : {
609 : 0 : aComment = rStr;
610 : 0 : }
611 : :
612 : 0 : void ScChangeAction::GetRefString(
613 : : rtl::OUString& rStr, ScDocument* pDoc, bool bFlag3D ) const
614 : : {
615 : 0 : rStr = GetRefString( GetBigRange(), pDoc, bFlag3D );
616 : 0 : }
617 : :
618 : :
619 : 0 : void ScChangeAction::Accept()
620 : : {
621 [ # # ]: 0 : if ( IsVirgin() )
622 : : {
623 : 0 : SetState( SC_CAS_ACCEPTED );
624 : 0 : DeleteCellEntries();
625 : : }
626 : 0 : }
627 : :
628 : :
629 : 0 : void ScChangeAction::SetRejected()
630 : : {
631 [ # # ]: 0 : if ( IsVirgin() )
632 : : {
633 : 0 : SetState( SC_CAS_REJECTED );
634 : 0 : RemoveAllLinks();
635 : 0 : DeleteCellEntries();
636 : : }
637 : 0 : }
638 : :
639 : :
640 : 0 : void ScChangeAction::RejectRestoreContents( ScChangeTrack* pTrack,
641 : : SCsCOL nDx, SCsROW nDy )
642 : : {
643 : : // Liste der Contents aufbauen
644 : 0 : ScChangeActionCellListEntry* pListContents = NULL;
645 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkDeleted; pL; pL = pL->GetNext() )
646 : : {
647 : 0 : ScChangeAction* p = pL->GetAction();
648 [ # # ][ # # ]: 0 : if ( p && p->GetType() == SC_CAT_CONTENT )
[ # # ]
649 : : {
650 : : ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
651 : 0 : (ScChangeActionContent*) p, pListContents );
652 : 0 : pListContents = pE;
653 : : }
654 : : }
655 : 0 : SetState( SC_CAS_REJECTED ); // vor UpdateReference fuer Move
656 : 0 : pTrack->UpdateReference( this, true ); // LinkDeleted freigeben
657 : : OSL_ENSURE( !pLinkDeleted, "ScChangeAction::RejectRestoreContents: pLinkDeleted != NULL" );
658 : : // Liste der Contents abarbeiten und loeschen
659 : 0 : ScDocument* pDoc = pTrack->GetDocument();
660 : 0 : ScChangeActionCellListEntry* pE = pListContents;
661 [ # # ]: 0 : while ( pE )
662 : : {
663 [ # # # # ]: 0 : if ( !pE->pContent->IsDeletedIn() &&
[ # # ]
664 : 0 : pE->pContent->GetBigRange().aStart.IsValid( pDoc ) )
665 : 0 : pE->pContent->PutNewValueToDoc( pDoc, nDx, nDy );
666 : : ScChangeActionCellListEntry* pNextEntry;
667 : 0 : pNextEntry = pE->pNext;
668 : 0 : delete pE;
669 : 0 : pE = pNextEntry;
670 : : }
671 : 0 : DeleteCellEntries(); // weg mit den generierten
672 : 0 : }
673 : :
674 : :
675 : 0 : void ScChangeAction::SetDeletedInThis( sal_uLong nActionNumber,
676 : : const ScChangeTrack* pTrack )
677 : : {
678 [ # # ]: 0 : if ( nActionNumber )
679 : : {
680 : 0 : ScChangeAction* pAct = pTrack->GetActionOrGenerated( nActionNumber );
681 : : OSL_ENSURE( pAct, "ScChangeAction::SetDeletedInThis: missing Action" );
682 [ # # ]: 0 : if ( pAct )
683 : 0 : pAct->SetDeletedIn( this );
684 : : }
685 : 0 : }
686 : :
687 : :
688 : 0 : void ScChangeAction::AddDependent( sal_uLong nActionNumber,
689 : : const ScChangeTrack* pTrack )
690 : : {
691 [ # # ]: 0 : if ( nActionNumber )
692 : : {
693 : 0 : ScChangeAction* pAct = pTrack->GetActionOrGenerated( nActionNumber );
694 : : OSL_ENSURE( pAct, "ScChangeAction::AddDependent: missing Action" );
695 [ # # ]: 0 : if ( pAct )
696 : : {
697 : 0 : ScChangeActionLinkEntry* pLink = AddDependent( pAct );
698 : 0 : pAct->AddLink( this, pLink );
699 : : }
700 : : }
701 : 0 : }
702 : :
703 : : // --- ScChangeActionIns ---------------------------------------------------
704 : :
705 : 0 : ScChangeActionIns::ScChangeActionIns( const ScRange& rRange )
706 : 0 : : ScChangeAction( SC_CAT_NONE, rRange )
707 : : {
708 [ # # ][ # # ]: 0 : if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
[ # # ]
709 : : {
710 : 0 : aBigRange.aStart.SetCol( nInt32Min );
711 : 0 : aBigRange.aEnd.SetCol( nInt32Max );
712 [ # # ][ # # ]: 0 : if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
[ # # ]
713 : : {
714 : 0 : SetType( SC_CAT_INSERT_TABS );
715 : 0 : aBigRange.aStart.SetRow( nInt32Min );
716 : 0 : aBigRange.aEnd.SetRow( nInt32Max );
717 : : }
718 : : else
719 : 0 : SetType( SC_CAT_INSERT_ROWS );
720 : : }
721 [ # # ][ # # ]: 0 : else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
[ # # ]
722 : : {
723 : 0 : SetType( SC_CAT_INSERT_COLS );
724 : 0 : aBigRange.aStart.SetRow( nInt32Min );
725 : 0 : aBigRange.aEnd.SetRow( nInt32Max );
726 : : }
727 : : else
728 : : {
729 : : OSL_FAIL( "ScChangeActionIns: Block not supported!" );
730 : : }
731 : 0 : }
732 : :
733 : :
734 : 0 : ScChangeActionIns::ScChangeActionIns(
735 : : const sal_uLong nActionNumber, const ScChangeActionState eStateP,
736 : : const sal_uLong nRejectingNumber, const ScBigRange& aBigRangeP,
737 : : const rtl::OUString& aUserP, const DateTime& aDateTimeP,
738 : : const rtl::OUString& sComment, const ScChangeActionType eTypeP) :
739 : 0 : ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment)
740 : : {
741 : 0 : }
742 : :
743 : 0 : ScChangeActionIns::~ScChangeActionIns()
744 : : {
745 [ # # ]: 0 : }
746 : :
747 : 0 : void ScChangeActionIns::GetDescription(
748 : : rtl::OUString& rStr, ScDocument* pDoc, bool bSplitRange, bool bWarning ) const
749 : : {
750 [ # # ]: 0 : ScChangeAction::GetDescription( rStr, pDoc, bSplitRange, bWarning );
751 : :
752 : : sal_uInt16 nWhatId;
753 [ # # # ]: 0 : switch ( GetType() )
754 : : {
755 : : case SC_CAT_INSERT_COLS :
756 : 0 : nWhatId = STR_COLUMN;
757 : 0 : break;
758 : : case SC_CAT_INSERT_ROWS :
759 : 0 : nWhatId = STR_ROW;
760 : 0 : break;
761 : : default:
762 : 0 : nWhatId = STR_AREA;
763 : : }
764 : :
765 [ # # ][ # # ]: 0 : rtl::OUString aRsc = ScGlobal::GetRscString(STR_CHANGED_INSERT);
766 : 0 : sal_Int32 nPos = aRsc.indexOfAsciiL("#1", 2);
767 [ # # ]: 0 : if (nPos >= 0)
768 : : {
769 : : // Construct a range string to replace '#1' first.
770 [ # # ][ # # ]: 0 : rtl::OUStringBuffer aBuf(ScGlobal::GetRscString(nWhatId));
[ # # ]
771 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
772 [ # # ][ # # ]: 0 : aBuf.append(GetRefString(GetBigRange(), pDoc));
773 [ # # ]: 0 : rtl::OUString aRangeStr = aBuf.makeStringAndClear();
774 : :
775 : 0 : aRsc.replaceAt(nPos, 2, aRangeStr); // replace '#1' with the range string.
776 : :
777 [ # # ][ # # ]: 0 : aBuf.append(rStr).append(aRsc);
778 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
779 : 0 : }
780 : 0 : }
781 : :
782 : 0 : bool ScChangeActionIns::Reject( ScDocument* pDoc )
783 : : {
784 [ # # ][ # # ]: 0 : if ( !aBigRange.IsValid( pDoc ) )
785 : 0 : return false;
786 : :
787 : 0 : ScRange aRange( aBigRange.MakeRange() );
788 [ # # ]: 0 : if ( !pDoc->IsBlockEditable( aRange.aStart.Tab(), aRange.aStart.Col(),
789 [ # # ]: 0 : aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row() ) )
790 : 0 : return false;
791 : :
792 [ # # # # ]: 0 : switch ( GetType() )
793 : : {
794 : : case SC_CAT_INSERT_COLS :
795 [ # # ]: 0 : pDoc->DeleteCol( aRange );
796 : 0 : break;
797 : : case SC_CAT_INSERT_ROWS :
798 [ # # ]: 0 : pDoc->DeleteRow( aRange );
799 : 0 : break;
800 : : case SC_CAT_INSERT_TABS :
801 [ # # ]: 0 : pDoc->DeleteTab( aRange.aStart.Tab() );
802 : 0 : break;
803 : : default:
804 : : {
805 : : // added to avoid warnings
806 : : }
807 : : }
808 : 0 : SetState( SC_CAS_REJECTED );
809 [ # # ]: 0 : RemoveAllLinks();
810 : 0 : return true;
811 : : }
812 : :
813 : :
814 : : // --- ScChangeActionDel ---------------------------------------------------
815 : :
816 : 0 : ScChangeActionDel::ScChangeActionDel( const ScRange& rRange,
817 : : SCsCOL nDxP, SCsROW nDyP, ScChangeTrack* pTrackP )
818 : : :
819 : : ScChangeAction( SC_CAT_NONE, rRange ),
820 : : pTrack( pTrackP ),
821 : : pFirstCell( NULL ),
822 : : pCutOff( NULL ),
823 : : nCutOff( 0 ),
824 : : pLinkMove( NULL ),
825 : : nDx( nDxP ),
826 : 0 : nDy( nDyP )
827 : : {
828 [ # # ][ # # ]: 0 : if ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL )
[ # # ]
829 : : {
830 : 0 : aBigRange.aStart.SetCol( nInt32Min );
831 : 0 : aBigRange.aEnd.SetCol( nInt32Max );
832 [ # # ][ # # ]: 0 : if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
[ # # ]
833 : : {
834 : 0 : SetType( SC_CAT_DELETE_TABS );
835 : 0 : aBigRange.aStart.SetRow( nInt32Min );
836 : 0 : aBigRange.aEnd.SetRow( nInt32Max );
837 : : }
838 : : else
839 : 0 : SetType( SC_CAT_DELETE_ROWS );
840 : : }
841 [ # # ][ # # ]: 0 : else if ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW )
[ # # ]
842 : : {
843 : 0 : SetType( SC_CAT_DELETE_COLS );
844 : 0 : aBigRange.aStart.SetRow( nInt32Min );
845 : 0 : aBigRange.aEnd.SetRow( nInt32Max );
846 : : }
847 : : else
848 : : {
849 : : OSL_FAIL( "ScChangeActionDel: Block not supported!" );
850 : : }
851 : 0 : }
852 : :
853 : :
854 : 0 : ScChangeActionDel::ScChangeActionDel(
855 : : const sal_uLong nActionNumber, const ScChangeActionState eStateP,
856 : : const sal_uLong nRejectingNumber, const ScBigRange& aBigRangeP,
857 : : const rtl::OUString& aUserP, const DateTime& aDateTimeP, const rtl::OUString &sComment,
858 : : const ScChangeActionType eTypeP, const SCsCOLROW nD, ScChangeTrack* pTrackP) : // wich of nDx and nDy is set is depend on the type
859 : : ScChangeAction(eTypeP, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment),
860 : : pTrack( pTrackP ),
861 : : pFirstCell( NULL ),
862 : : pCutOff( NULL ),
863 : : nCutOff( 0 ),
864 : : pLinkMove( NULL ),
865 : : nDx( 0 ),
866 : 0 : nDy( 0 )
867 : : {
868 [ # # ]: 0 : if (eType == SC_CAT_DELETE_COLS)
869 : 0 : nDx = static_cast<SCsCOL>(nD);
870 [ # # ]: 0 : else if (eType == SC_CAT_DELETE_ROWS)
871 : 0 : nDy = static_cast<SCsROW>(nD);
872 : 0 : }
873 : :
874 : 0 : ScChangeActionDel::~ScChangeActionDel()
875 : : {
876 [ # # ]: 0 : DeleteCellEntries();
877 [ # # ]: 0 : while ( pLinkMove )
878 [ # # ][ # # ]: 0 : delete pLinkMove;
879 [ # # ]: 0 : }
880 : :
881 : 0 : void ScChangeActionDel::AddContent( ScChangeActionContent* pContent )
882 : : {
883 : : ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
884 : 0 : pContent, pFirstCell );
885 : 0 : pFirstCell = pE;
886 : 0 : }
887 : :
888 : :
889 : 0 : void ScChangeActionDel::DeleteCellEntries()
890 : : {
891 : 0 : pTrack->DeleteCellEntries( pFirstCell, this );
892 : 0 : }
893 : :
894 : :
895 : 0 : bool ScChangeActionDel::IsBaseDelete() const
896 : : {
897 [ # # ][ # # ]: 0 : return !GetDx() && !GetDy();
898 : : }
899 : :
900 : :
901 : 0 : bool ScChangeActionDel::IsTopDelete() const
902 : : {
903 : 0 : const ScChangeAction* p = GetNext();
904 [ # # ][ # # ]: 0 : if ( !p || p->GetType() != GetType() )
[ # # ]
905 : 0 : return true;
906 : 0 : return ((ScChangeActionDel*)p)->IsBaseDelete();
907 : : }
908 : :
909 : :
910 : 0 : bool ScChangeActionDel::IsMultiDelete() const
911 : : {
912 [ # # ][ # # ]: 0 : if ( GetDx() || GetDy() )
[ # # ]
913 : 0 : return true;
914 : 0 : const ScChangeAction* p = GetNext();
915 [ # # ][ # # ]: 0 : if ( !p || p->GetType() != GetType() )
[ # # ]
916 : 0 : return false;
917 : 0 : const ScChangeActionDel* pDel = (const ScChangeActionDel*) p;
918 [ # # ]: 0 : if ( (pDel->GetDx() > GetDx() || pDel->GetDy() > GetDy()) &&
[ # # # # ]
[ # # ]
919 : 0 : pDel->GetBigRange() == aBigRange )
920 : 0 : return true;
921 : 0 : return false;
922 : : }
923 : :
924 : :
925 : 0 : bool ScChangeActionDel::IsTabDeleteCol() const
926 : : {
927 [ # # ]: 0 : if ( GetType() != SC_CAT_DELETE_COLS )
928 : 0 : return false;
929 : 0 : const ScChangeAction* p = this;
930 [ # # ]: 0 : while ( p && p->GetType() == SC_CAT_DELETE_COLS &&
[ # # # # ]
[ # # ]
931 : 0 : !((const ScChangeActionDel*)p)->IsTopDelete() )
932 : 0 : p = p->GetNext();
933 [ # # ][ # # ]: 0 : return p && p->GetType() == SC_CAT_DELETE_TABS;
934 : : }
935 : :
936 : 0 : SCsCOL ScChangeActionDel::GetDx() const { return nDx; }
937 : 0 : SCsROW ScChangeActionDel::GetDy() const { return nDy; }
938 : :
939 : 0 : ScChangeActionDelMoveEntry* ScChangeActionDel::AddCutOffMove(
940 : : ScChangeActionMove* pMove, short nFrom, short nTo )
941 : : {
942 [ # # ]: 0 : return new ScChangeActionDelMoveEntry(&pLinkMove, pMove, nFrom, nTo);
943 : : }
944 : :
945 : 0 : void ScChangeActionDel::UpdateReference( const ScChangeTrack* /* pTrack */,
946 : : UpdateRefMode eMode, const ScBigRange& rRange,
947 : : sal_Int32 nDxP, sal_Int32 nDyP, sal_Int32 nDz )
948 : : {
949 : 0 : ScRefUpdate::Update( eMode, rRange, nDxP, nDyP, nDz, GetBigRange() );
950 [ # # ]: 0 : if ( !IsDeletedIn() )
951 : 0 : return ;
952 : : // evtl. in "druntergerutschten" anpassen
953 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkDeleted; pL; pL = pL->GetNext() )
954 : : {
955 : 0 : ScChangeAction* p = pL->GetAction();
956 [ # # # # ]: 0 : if ( p && p->GetType() == SC_CAT_CONTENT &&
[ # # ][ # # ]
957 : 0 : !GetBigRange().In( p->GetBigRange() ) )
958 : : {
959 [ # # # # ]: 0 : switch ( GetType() )
960 : : {
961 : : case SC_CAT_DELETE_COLS :
962 : 0 : p->GetBigRange().aStart.SetCol( GetBigRange().aStart.Col() );
963 : 0 : p->GetBigRange().aEnd.SetCol( GetBigRange().aStart.Col() );
964 : 0 : break;
965 : : case SC_CAT_DELETE_ROWS :
966 : 0 : p->GetBigRange().aStart.SetRow( GetBigRange().aStart.Row() );
967 : 0 : p->GetBigRange().aEnd.SetRow( GetBigRange().aStart.Row() );
968 : 0 : break;
969 : : case SC_CAT_DELETE_TABS :
970 : 0 : p->GetBigRange().aStart.SetTab( GetBigRange().aStart.Tab() );
971 : 0 : p->GetBigRange().aEnd.SetTab( GetBigRange().aStart.Tab() );
972 : 0 : break;
973 : : default:
974 : : {
975 : : // added to avoid warnings
976 : : }
977 : : }
978 : : }
979 : : }
980 : : }
981 : :
982 : :
983 : 0 : ScBigRange ScChangeActionDel::GetOverAllRange() const
984 : : {
985 : 0 : ScBigRange aTmpRange( GetBigRange() );
986 : 0 : aTmpRange.aEnd.SetCol( aTmpRange.aEnd.Col() + GetDx() );
987 : 0 : aTmpRange.aEnd.SetRow( aTmpRange.aEnd.Row() + GetDy() );
988 : 0 : return aTmpRange;
989 : : }
990 : :
991 : :
992 : 0 : void ScChangeActionDel::GetDescription(
993 : : rtl::OUString& rStr, ScDocument* pDoc, bool bSplitRange, bool bWarning ) const
994 : : {
995 [ # # ]: 0 : ScChangeAction::GetDescription( rStr, pDoc, bSplitRange, bWarning );
996 : :
997 : : sal_uInt16 nWhatId;
998 [ # # # ]: 0 : switch ( GetType() )
999 : : {
1000 : : case SC_CAT_DELETE_COLS :
1001 : 0 : nWhatId = STR_COLUMN;
1002 : 0 : break;
1003 : : case SC_CAT_DELETE_ROWS :
1004 : 0 : nWhatId = STR_ROW;
1005 : 0 : break;
1006 : : default:
1007 : 0 : nWhatId = STR_AREA;
1008 : : }
1009 : :
1010 : 0 : ScBigRange aTmpRange( GetBigRange() );
1011 [ # # ]: 0 : if ( !IsRejected() )
1012 : : {
1013 [ # # ]: 0 : if ( bSplitRange )
1014 : : {
1015 : 0 : aTmpRange.aStart.SetCol( aTmpRange.aStart.Col() + GetDx() );
1016 : 0 : aTmpRange.aStart.SetRow( aTmpRange.aStart.Row() + GetDy() );
1017 : : }
1018 : 0 : aTmpRange.aEnd.SetCol( aTmpRange.aEnd.Col() + GetDx() );
1019 : 0 : aTmpRange.aEnd.SetRow( aTmpRange.aEnd.Row() + GetDy() );
1020 : : }
1021 : :
1022 [ # # ][ # # ]: 0 : rtl::OUString aRsc = ScGlobal::GetRscString(STR_CHANGED_DELETE);
1023 : 0 : sal_Int32 nPos = aRsc.indexOfAsciiL("#1", 2);
1024 [ # # ]: 0 : if (nPos >= 0)
1025 : : {
1026 : : // Build a string to replace with.
1027 : 0 : rtl::OUStringBuffer aBuf;
1028 [ # # ][ # # ]: 0 : aBuf.append(ScGlobal::GetRscString(nWhatId));
[ # # ]
1029 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
1030 [ # # ][ # # ]: 0 : aBuf.append(GetRefString(aTmpRange, pDoc));
1031 [ # # ]: 0 : rtl::OUString aRangeStr = aBuf.makeStringAndClear();
1032 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aRangeStr); // replace '#1' with the string.
1033 : :
1034 [ # # ][ # # ]: 0 : aBuf.append(rStr).append(aRsc);
1035 [ # # ]: 0 : rStr = aBuf.makeStringAndClear(); // append to the original.
1036 : 0 : }
1037 : 0 : }
1038 : :
1039 : :
1040 : 0 : bool ScChangeActionDel::Reject( ScDocument* pDoc )
1041 : : {
1042 [ # # ][ # # ]: 0 : if ( !aBigRange.IsValid( pDoc ) && GetType() != SC_CAT_DELETE_TABS )
[ # # ]
1043 : 0 : return false;
1044 : :
1045 : 0 : bool bOk = true;
1046 : :
1047 [ # # ]: 0 : if ( IsTopDelete() )
1048 : : { // den kompletten Bereich in einem Rutsch restaurieren
1049 : 0 : ScBigRange aTmpRange( GetOverAllRange() );
1050 [ # # ][ # # ]: 0 : if ( !aTmpRange.IsValid( pDoc ) )
1051 : : {
1052 [ # # ]: 0 : if ( GetType() == SC_CAT_DELETE_TABS )
1053 : : { // wird Tab angehaengt?
1054 [ # # ]: 0 : if ( aTmpRange.aStart.Tab() > pDoc->GetMaxTableNumber() )
1055 : 0 : bOk = false;
1056 : : }
1057 : : else
1058 : 0 : bOk = false;
1059 : : }
1060 [ # # ]: 0 : if ( bOk )
1061 : : {
1062 : 0 : ScRange aRange( aTmpRange.MakeRange() );
1063 : : // InDelete... fuer Formel UpdateReference in Document
1064 : 0 : pTrack->SetInDeleteRange( aRange );
1065 : 0 : pTrack->SetInDeleteTop( true );
1066 : 0 : pTrack->SetInDeleteUndo( true );
1067 : 0 : pTrack->SetInDelete( true );
1068 [ # # # # ]: 0 : switch ( GetType() )
1069 : : {
1070 : : case SC_CAT_DELETE_COLS :
1071 [ # # ][ # # ]: 0 : if ( !(aRange.aStart.Col() == 0 && aRange.aEnd.Col() == MAXCOL) )
[ # # ]
1072 : : { // nur wenn nicht TabDelete
1073 [ # # ][ # # ]: 0 : if ( ( bOk = pDoc->CanInsertCol( aRange ) ) != false )
1074 [ # # ]: 0 : bOk = pDoc->InsertCol( aRange );
1075 : : }
1076 : 0 : break;
1077 : : case SC_CAT_DELETE_ROWS :
1078 [ # # ][ # # ]: 0 : if ( ( bOk = pDoc->CanInsertRow( aRange ) ) != false )
1079 [ # # ]: 0 : bOk = pDoc->InsertRow( aRange );
1080 : 0 : break;
1081 : : case SC_CAT_DELETE_TABS :
1082 : : {
1083 : : //2do: Tabellennamen merken?
1084 : 0 : rtl::OUString aName;
1085 [ # # ]: 0 : pDoc->CreateValidTabName( aName );
1086 [ # # ][ # # ]: 0 : if ( ( bOk = pDoc->ValidNewTabName( aName ) ) != false )
1087 [ # # ]: 0 : bOk = pDoc->InsertTab( aRange.aStart.Tab(), aName );
1088 : : }
1089 : 0 : break;
1090 : : default:
1091 : : {
1092 : : // added to avoid warnings
1093 : : }
1094 : : }
1095 : 0 : pTrack->SetInDelete( false );
1096 : 0 : pTrack->SetInDeleteUndo( false );
1097 : : }
1098 [ # # ]: 0 : if ( !bOk )
1099 : : {
1100 : 0 : pTrack->SetInDeleteTop( false );
1101 : 0 : return false;
1102 : : }
1103 : : // InDeleteTop fuer UpdateReference-Undo behalten
1104 : : }
1105 : :
1106 : : // setzt rejected und ruft UpdateReference-Undo und DeleteCellEntries
1107 : 0 : RejectRestoreContents( pTrack, GetDx(), GetDy() );
1108 : :
1109 : 0 : pTrack->SetInDeleteTop( false );
1110 : 0 : RemoveAllLinks();
1111 : 0 : return true;
1112 : : }
1113 : :
1114 : :
1115 : 0 : void ScChangeActionDel::UndoCutOffMoves()
1116 : : { // abgeschnittene Moves wiederherstellen, Entries/Links deleten
1117 [ # # ]: 0 : while ( pLinkMove )
1118 : : {
1119 : 0 : ScChangeActionMove* pMove = pLinkMove->GetMove();
1120 : 0 : short nFrom = pLinkMove->GetCutOffFrom();
1121 : 0 : short nTo = pLinkMove->GetCutOffTo();
1122 [ # # # # ]: 0 : switch ( GetType() )
1123 : : {
1124 : : case SC_CAT_DELETE_COLS :
1125 [ # # ]: 0 : if ( nFrom > 0 )
1126 : 0 : pMove->GetFromRange().aStart.IncCol( -nFrom );
1127 [ # # ]: 0 : else if ( nFrom < 0 )
1128 : 0 : pMove->GetFromRange().aEnd.IncCol( -nFrom );
1129 [ # # ]: 0 : if ( nTo > 0 )
1130 : 0 : pMove->GetBigRange().aStart.IncCol( -nTo );
1131 [ # # ]: 0 : else if ( nTo < 0 )
1132 : 0 : pMove->GetBigRange().aEnd.IncCol( -nTo );
1133 : 0 : break;
1134 : : case SC_CAT_DELETE_ROWS :
1135 [ # # ]: 0 : if ( nFrom > 0 )
1136 : 0 : pMove->GetFromRange().aStart.IncRow( -nFrom );
1137 [ # # ]: 0 : else if ( nFrom < 0 )
1138 : 0 : pMove->GetFromRange().aEnd.IncRow( -nFrom );
1139 [ # # ]: 0 : if ( nTo > 0 )
1140 : 0 : pMove->GetBigRange().aStart.IncRow( -nTo );
1141 [ # # ]: 0 : else if ( nTo < 0 )
1142 : 0 : pMove->GetBigRange().aEnd.IncRow( -nTo );
1143 : 0 : break;
1144 : : case SC_CAT_DELETE_TABS :
1145 [ # # ]: 0 : if ( nFrom > 0 )
1146 : 0 : pMove->GetFromRange().aStart.IncTab( -nFrom );
1147 [ # # ]: 0 : else if ( nFrom < 0 )
1148 : 0 : pMove->GetFromRange().aEnd.IncTab( -nFrom );
1149 [ # # ]: 0 : if ( nTo > 0 )
1150 : 0 : pMove->GetBigRange().aStart.IncTab( -nTo );
1151 [ # # ]: 0 : else if ( nTo < 0 )
1152 : 0 : pMove->GetBigRange().aEnd.IncTab( -nTo );
1153 : 0 : break;
1154 : : default:
1155 : : {
1156 : : // added to avoid warnings
1157 : : }
1158 : : }
1159 [ # # ]: 0 : delete pLinkMove; // rueckt sich selbst hoch
1160 : : }
1161 : 0 : }
1162 : :
1163 : 0 : void ScChangeActionDel::UndoCutOffInsert()
1164 : : { // abgeschnittenes Insert wiederherstellen
1165 [ # # ]: 0 : if ( pCutOff )
1166 : : {
1167 [ # # # # ]: 0 : switch ( pCutOff->GetType() )
1168 : : {
1169 : : case SC_CAT_INSERT_COLS :
1170 [ # # ]: 0 : if ( nCutOff < 0 )
1171 : 0 : pCutOff->GetBigRange().aEnd.IncCol( -nCutOff );
1172 : : else
1173 : 0 : pCutOff->GetBigRange().aStart.IncCol( -nCutOff );
1174 : 0 : break;
1175 : : case SC_CAT_INSERT_ROWS :
1176 [ # # ]: 0 : if ( nCutOff < 0 )
1177 : 0 : pCutOff->GetBigRange().aEnd.IncRow( -nCutOff );
1178 : : else
1179 : 0 : pCutOff->GetBigRange().aStart.IncRow( -nCutOff );
1180 : 0 : break;
1181 : : case SC_CAT_INSERT_TABS :
1182 [ # # ]: 0 : if ( nCutOff < 0 )
1183 : 0 : pCutOff->GetBigRange().aEnd.IncTab( -nCutOff );
1184 : : else
1185 : 0 : pCutOff->GetBigRange().aStart.IncTab( -nCutOff );
1186 : 0 : break;
1187 : : default:
1188 : : {
1189 : : // added to avoid warnings
1190 : : }
1191 : : }
1192 : 0 : SetCutOffInsert( NULL, 0 );
1193 : : }
1194 : 0 : }
1195 : :
1196 : :
1197 : : // --- ScChangeActionMove --------------------------------------------------
1198 : :
1199 : 0 : ScChangeActionMove::ScChangeActionMove(
1200 : : const sal_uLong nActionNumber, const ScChangeActionState eStateP,
1201 : : const sal_uLong nRejectingNumber, const ScBigRange& aToBigRange,
1202 : : const rtl::OUString& aUserP, const DateTime& aDateTimeP,
1203 : : const rtl::OUString &sComment, const ScBigRange& aFromBigRange,
1204 : : ScChangeTrack* pTrackP) : // wich of nDx and nDy is set is depend on the type
1205 : : ScChangeAction(SC_CAT_MOVE, aToBigRange, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment),
1206 : : aFromRange(aFromBigRange),
1207 : : pTrack( pTrackP ),
1208 : : pFirstCell( NULL ),
1209 : : nStartLastCut(0),
1210 : 0 : nEndLastCut(0)
1211 : : {
1212 : 0 : }
1213 : :
1214 : 0 : ScChangeActionMove::~ScChangeActionMove()
1215 : : {
1216 [ # # ]: 0 : DeleteCellEntries();
1217 [ # # ]: 0 : }
1218 : :
1219 : :
1220 : 0 : void ScChangeActionMove::AddContent( ScChangeActionContent* pContent )
1221 : : {
1222 : : ScChangeActionCellListEntry* pE = new ScChangeActionCellListEntry(
1223 : 0 : pContent, pFirstCell );
1224 : 0 : pFirstCell = pE;
1225 : 0 : }
1226 : :
1227 : :
1228 : 0 : void ScChangeActionMove::DeleteCellEntries()
1229 : : {
1230 : 0 : pTrack->DeleteCellEntries( pFirstCell, this );
1231 : 0 : }
1232 : :
1233 : :
1234 : 0 : void ScChangeActionMove::UpdateReference( const ScChangeTrack* /* pTrack */,
1235 : : UpdateRefMode eMode, const ScBigRange& rRange,
1236 : : sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz )
1237 : : {
1238 : 0 : ScRefUpdate::Update( eMode, rRange, nDx, nDy, nDz, aFromRange );
1239 : 0 : ScRefUpdate::Update( eMode, rRange, nDx, nDy, nDz, GetBigRange() );
1240 : 0 : }
1241 : :
1242 : :
1243 : 0 : void ScChangeActionMove::GetDelta( sal_Int32& nDx, sal_Int32& nDy, sal_Int32& nDz ) const
1244 : : {
1245 : 0 : const ScBigAddress& rToPos = GetBigRange().aStart;
1246 : 0 : const ScBigAddress& rFromPos = GetFromRange().aStart;
1247 : 0 : nDx = rToPos.Col() - rFromPos.Col();
1248 : 0 : nDy = rToPos.Row() - rFromPos.Row();
1249 : 0 : nDz = rToPos.Tab() - rFromPos.Tab();
1250 : 0 : }
1251 : :
1252 : :
1253 : 0 : void ScChangeActionMove::GetDescription(
1254 : : rtl::OUString& rStr, ScDocument* pDoc, bool bSplitRange, bool bWarning ) const
1255 : : {
1256 [ # # ]: 0 : ScChangeAction::GetDescription( rStr, pDoc, bSplitRange, bWarning );
1257 : :
1258 : 0 : bool bFlag3D = GetFromRange().aStart.Tab() != GetBigRange().aStart.Tab();
1259 : :
1260 [ # # ][ # # ]: 0 : rtl::OUString aRsc = ScGlobal::GetRscString(STR_CHANGED_MOVE);
1261 : :
1262 [ # # ]: 0 : rtl::OUString aTmpStr = ScChangeAction::GetRefString(GetFromRange(), pDoc, bFlag3D);
1263 : 0 : sal_Int32 nPos = aRsc.indexOfAsciiL("#1", 2);
1264 [ # # ]: 0 : if (nPos >= 0)
1265 : : {
1266 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
1267 : 0 : nPos += aTmpStr.getLength();
1268 : : }
1269 : :
1270 [ # # ]: 0 : aTmpStr = ScChangeAction::GetRefString(GetBigRange(), pDoc, bFlag3D);
1271 : 0 : nPos = aRsc.indexOfAsciiL("#2", 2, nPos);
1272 [ # # ]: 0 : if (nPos >= 0)
1273 : : {
1274 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
1275 : 0 : nPos += aTmpStr.getLength();
1276 : : }
1277 : :
1278 [ # # ]: 0 : rtl::OUStringBuffer aBuf(rStr); // append to the original string.
1279 [ # # ]: 0 : aBuf.append(aRsc);
1280 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
1281 : 0 : }
1282 : :
1283 : :
1284 : 0 : void ScChangeActionMove::GetRefString(
1285 : : rtl::OUString& rStr, ScDocument* pDoc, bool bFlag3D ) const
1286 : : {
1287 [ # # ]: 0 : if ( !bFlag3D )
1288 : 0 : bFlag3D = ( GetFromRange().aStart.Tab() != GetBigRange().aStart.Tab() );
1289 : :
1290 : 0 : rtl::OUStringBuffer aBuf;
1291 [ # # ][ # # ]: 0 : aBuf.append(ScChangeAction::GetRefString(GetFromRange(), pDoc, bFlag3D));
1292 [ # # ]: 0 : aBuf.append(sal_Unicode(','));
1293 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
1294 [ # # ][ # # ]: 0 : aBuf.append(ScChangeAction::GetRefString(GetBigRange(), pDoc, bFlag3D));
1295 [ # # ]: 0 : rStr = aBuf.makeStringAndClear(); // overwrite existing string value.
1296 : 0 : }
1297 : :
1298 : :
1299 : 0 : bool ScChangeActionMove::Reject( ScDocument* pDoc )
1300 : : {
1301 [ # # ][ # # ]: 0 : if ( !(aBigRange.IsValid( pDoc ) && aFromRange.IsValid( pDoc )) )
[ # # ][ # # ]
[ # # ]
1302 : 0 : return false;
1303 : :
1304 : 0 : ScRange aToRange( aBigRange.MakeRange() );
1305 : 0 : ScRange aFrmRange( aFromRange.MakeRange() );
1306 : :
1307 : 0 : bool bOk = pDoc->IsBlockEditable( aToRange.aStart.Tab(),
1308 : 0 : aToRange.aStart.Col(), aToRange.aStart.Row(),
1309 [ # # ]: 0 : aToRange.aEnd.Col(), aToRange.aEnd.Row() );
1310 [ # # ]: 0 : if ( bOk )
1311 : 0 : bOk = pDoc->IsBlockEditable( aFrmRange.aStart.Tab(),
1312 : 0 : aFrmRange.aStart.Col(), aFrmRange.aStart.Row(),
1313 [ # # ]: 0 : aFrmRange.aEnd.Col(), aFrmRange.aEnd.Row() );
1314 [ # # ]: 0 : if ( !bOk )
1315 : 0 : return false;
1316 : :
1317 [ # # ]: 0 : pTrack->LookUpContents( aToRange, pDoc, 0, 0, 0 ); // zu movende Contents
1318 : :
1319 [ # # ]: 0 : pDoc->DeleteAreaTab( aToRange, IDF_ALL );
1320 [ # # ]: 0 : pDoc->DeleteAreaTab( aFrmRange, IDF_ALL );
1321 : : // Formeln im Dokument anpassen
1322 : : pDoc->UpdateReference( URM_MOVE,
1323 : 0 : aFrmRange.aStart.Col(), aFrmRange.aStart.Row(), aFrmRange.aStart.Tab(),
1324 : 0 : aFrmRange.aEnd.Col(), aFrmRange.aEnd.Row(), aFrmRange.aEnd.Tab(),
1325 : 0 : (SCsCOL) aFrmRange.aStart.Col() - aToRange.aStart.Col(),
1326 : 0 : (SCsROW) aFrmRange.aStart.Row() - aToRange.aStart.Row(),
1327 [ # # ]: 0 : (SCsTAB) aFrmRange.aStart.Tab() - aToRange.aStart.Tab(), NULL );
1328 : :
1329 : : // LinkDependent freigeben, nachfolgendes UpdateReference-Undo setzt
1330 : : // ToRange->FromRange Dependents
1331 [ # # ]: 0 : RemoveAllDependent();
1332 : :
1333 : : // setzt rejected und ruft UpdateReference-Undo und DeleteCellEntries
1334 [ # # ]: 0 : RejectRestoreContents( pTrack, 0, 0 );
1335 : :
1336 [ # # ]: 0 : while ( pLinkDependent )
1337 : : {
1338 : 0 : ScChangeAction* p = pLinkDependent->GetAction();
1339 [ # # ][ # # ]: 0 : if ( p && p->GetType() == SC_CAT_CONTENT )
[ # # ]
1340 : : {
1341 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) p;
1342 [ # # ][ # # ]: 0 : if ( !pContent->IsDeletedIn() &&
[ # # ][ # # ]
1343 [ # # ]: 0 : pContent->GetBigRange().aStart.IsValid( pDoc ) )
1344 [ # # ]: 0 : pContent->PutNewValueToDoc( pDoc, 0, 0 );
1345 : : // in LookUpContents generierte loeschen
1346 [ # # ][ # # ]: 0 : if ( pTrack->IsGenerated( pContent->GetActionNumber() ) &&
[ # # ]
1347 [ # # ]: 0 : !pContent->IsDeletedIn() )
1348 : : {
1349 : 0 : pLinkDependent->UnLink(); //! sonst wird der mitgeloescht
1350 [ # # ]: 0 : pTrack->DeleteGeneratedDelContent( pContent );
1351 : : }
1352 : : }
1353 [ # # ][ # # ]: 0 : delete pLinkDependent;
1354 : : }
1355 : :
1356 [ # # ]: 0 : RemoveAllLinks();
1357 : 0 : return true;
1358 : : }
1359 : :
1360 : :
1361 : : // --- ScChangeActionContent -----------------------------------------------
1362 : :
1363 : 51 : IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeActionContent )
1364 : :
1365 : 0 : ScChangeActionContent::ScChangeActionContent( const sal_uLong nActionNumber,
1366 : : const ScChangeActionState eStateP, const sal_uLong nRejectingNumber,
1367 : : const ScBigRange& aBigRangeP, const rtl::OUString& aUserP,
1368 : : const DateTime& aDateTimeP, const rtl::OUString& sComment,
1369 : : ScBaseCell* pTempOldCell, ScDocument* pDoc, const rtl::OUString& sOldValue )
1370 : : :
1371 : : ScChangeAction(SC_CAT_CONTENT, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment),
1372 : : aOldValue(sOldValue),
1373 : : pOldCell(pTempOldCell),
1374 : : pNewCell(NULL),
1375 : : pNextContent(NULL),
1376 : : pPrevContent(NULL),
1377 : : pNextInSlot(NULL),
1378 : 0 : ppPrevInSlot(NULL)
1379 : :
1380 : : {
1381 [ # # ]: 0 : if (pOldCell)
1382 [ # # ]: 0 : ScChangeActionContent::SetCell( aOldValue, pOldCell, 0, pDoc );
1383 [ # # ]: 0 : if (!sOldValue.isEmpty()) // #i40704# don't overwrite SetCell result with empty string
1384 : 0 : aOldValue = sOldValue; // set again, because SetCell removes it
1385 : 0 : }
1386 : :
1387 : 0 : ScChangeActionContent::ScChangeActionContent( const sal_uLong nActionNumber,
1388 : : ScBaseCell* pTempNewCell, const ScBigRange& aBigRangeP,
1389 : : ScDocument* pDoc, const rtl::OUString& sNewValue )
1390 : : :
1391 : : ScChangeAction(SC_CAT_CONTENT, aBigRangeP, nActionNumber),
1392 : : aNewValue(sNewValue),
1393 : : pOldCell(NULL),
1394 : : pNewCell(pTempNewCell),
1395 : : pNextContent(NULL),
1396 : : pPrevContent(NULL),
1397 : : pNextInSlot(NULL),
1398 : 0 : ppPrevInSlot(NULL)
1399 : : {
1400 [ # # ]: 0 : if (pNewCell)
1401 [ # # ]: 0 : ScChangeActionContent::SetCell( aNewValue, pNewCell, 0, pDoc );
1402 [ # # ]: 0 : if (!sNewValue.isEmpty()) // #i40704# don't overwrite SetCell result with empty string
1403 : 0 : aNewValue = sNewValue; // set again, because SetCell removes it
1404 : 0 : }
1405 : :
1406 : 0 : ScChangeActionContent::~ScChangeActionContent()
1407 : : {
1408 : 0 : ClearTrack();
1409 [ # # ]: 0 : }
1410 : :
1411 : :
1412 : 0 : void ScChangeActionContent::ClearTrack()
1413 : : {
1414 : 0 : RemoveFromSlot();
1415 [ # # ]: 0 : if ( pPrevContent )
1416 : 0 : pPrevContent->pNextContent = pNextContent;
1417 [ # # ]: 0 : if ( pNextContent )
1418 : 0 : pNextContent->pPrevContent = pPrevContent;
1419 : 0 : }
1420 : :
1421 : :
1422 : 0 : ScChangeActionContent* ScChangeActionContent::GetTopContent() const
1423 : : {
1424 [ # # ]: 0 : if ( pNextContent )
1425 : : {
1426 : 0 : ScChangeActionContent* pContent = pNextContent;
1427 [ # # ][ # # ]: 0 : while ( pContent->pNextContent && pContent != pContent->pNextContent )
[ # # ]
1428 : 0 : pContent = pContent->pNextContent;
1429 : 0 : return pContent;
1430 : : }
1431 : 0 : return (ScChangeActionContent*) this;
1432 : : }
1433 : :
1434 : :
1435 : 0 : ScChangeActionLinkEntry* ScChangeActionContent::GetDeletedIn() const
1436 : : {
1437 [ # # ]: 0 : if ( pNextContent )
1438 : 0 : return GetTopContent()->pLinkDeletedIn;
1439 : 0 : return pLinkDeletedIn;
1440 : : }
1441 : :
1442 : :
1443 : 0 : ScChangeActionLinkEntry** ScChangeActionContent::GetDeletedInAddress()
1444 : : {
1445 [ # # ]: 0 : if ( pNextContent )
1446 : 0 : return GetTopContent()->GetDeletedInAddress();
1447 : 0 : return &pLinkDeletedIn;
1448 : : }
1449 : :
1450 : :
1451 : 0 : void ScChangeActionContent::SetOldValue( const ScBaseCell* pCell,
1452 : : const ScDocument* pFromDoc, ScDocument* pToDoc, sal_uLong nFormat )
1453 : : {
1454 : : ScChangeActionContent::SetValue( aOldValue, pOldCell,
1455 : 0 : nFormat, pCell, pFromDoc, pToDoc );
1456 : 0 : }
1457 : :
1458 : :
1459 : 0 : void ScChangeActionContent::SetOldValue( const ScBaseCell* pCell,
1460 : : const ScDocument* pFromDoc, ScDocument* pToDoc )
1461 : : {
1462 : : ScChangeActionContent::SetValue( aOldValue, pOldCell,
1463 [ # # ]: 0 : aBigRange.aStart.MakeAddress(), pCell, pFromDoc, pToDoc );
1464 : 0 : }
1465 : :
1466 : :
1467 : 0 : void ScChangeActionContent::SetNewValue( const ScBaseCell* pCell,
1468 : : ScDocument* pDoc )
1469 : : {
1470 : : ScChangeActionContent::SetValue( aNewValue, pNewCell,
1471 [ # # ]: 0 : aBigRange.aStart.MakeAddress(), pCell, pDoc, pDoc );
1472 : 0 : }
1473 : :
1474 : :
1475 : 0 : void ScChangeActionContent::SetOldNewCells( ScBaseCell* pOldCellP,
1476 : : sal_uLong nOldFormat, ScBaseCell* pNewCellP,
1477 : : sal_uLong nNewFormat, ScDocument* pDoc )
1478 : : {
1479 : 0 : pOldCell = pOldCellP;
1480 : 0 : pNewCell = pNewCellP;
1481 : 0 : ScChangeActionContent::SetCell( aOldValue, pOldCell, nOldFormat, pDoc );
1482 : 0 : ScChangeActionContent::SetCell( aNewValue, pNewCell, nNewFormat, pDoc );
1483 : 0 : }
1484 : :
1485 : 0 : void ScChangeActionContent::SetNewCell(
1486 : : ScBaseCell* pCell, ScDocument* pDoc, const rtl::OUString& rFormatted )
1487 : : {
1488 : : OSL_ENSURE( !pNewCell, "ScChangeActionContent::SetNewCell: overwriting existing cell" );
1489 : 0 : pNewCell = pCell;
1490 : 0 : ScChangeActionContent::SetCell( aNewValue, pNewCell, 0, pDoc );
1491 : :
1492 : : // #i40704# allow to set formatted text here - don't call SetNewValue with string from XML filter
1493 [ # # ]: 0 : if (!rFormatted.isEmpty())
1494 : 0 : aNewValue = rFormatted;
1495 : 0 : }
1496 : :
1497 : 0 : void ScChangeActionContent::SetValueString(
1498 : : rtl::OUString& rValue, ScBaseCell*& pCell, const rtl::OUString& rStr, ScDocument* pDoc )
1499 : : {
1500 [ # # ]: 0 : if ( pCell )
1501 : : {
1502 : 0 : pCell->Delete();
1503 : 0 : pCell = NULL;
1504 : : }
1505 [ # # ][ # # ]: 0 : if ( rStr.getLength() > 1 && rStr.getStr()[0] == '=' )
[ # # ]
1506 : : {
1507 : 0 : rValue = rtl::OUString();
1508 : : pCell = new ScFormulaCell(
1509 : : pDoc, aBigRange.aStart.MakeAddress(), rStr,
1510 [ # # ][ # # ]: 0 : formula::FormulaGrammar::GRAM_DEFAULT, formula::FormulaGrammar::CONV_OOO );
[ # # ]
1511 [ # # ]: 0 : ((ScFormulaCell*)pCell)->SetInChangeTrack( true );
1512 : : }
1513 : : else
1514 : 0 : rValue = rStr;
1515 : 0 : }
1516 : :
1517 : :
1518 : 0 : void ScChangeActionContent::SetOldValue( const rtl::OUString& rOld, ScDocument* pDoc )
1519 : : {
1520 : 0 : SetValueString( aOldValue, pOldCell, rOld, pDoc );
1521 : 0 : }
1522 : :
1523 : :
1524 : 0 : void ScChangeActionContent::GetOldString( rtl::OUString& rStr ) const
1525 : : {
1526 : 0 : GetValueString( rStr, aOldValue, pOldCell );
1527 : 0 : }
1528 : :
1529 : :
1530 : 0 : void ScChangeActionContent::GetNewString( rtl::OUString& rStr ) const
1531 : : {
1532 : 0 : GetValueString( rStr, aNewValue, pNewCell );
1533 : 0 : }
1534 : :
1535 : :
1536 : 0 : void ScChangeActionContent::GetDescription(
1537 : : rtl::OUString& rStr, ScDocument* pDoc, bool bSplitRange, bool bWarning ) const
1538 : : {
1539 [ # # ]: 0 : ScChangeAction::GetDescription( rStr, pDoc, bSplitRange, bWarning );
1540 : :
1541 [ # # ][ # # ]: 0 : rtl::OUString aRsc = ScGlobal::GetRscString(STR_CHANGED_CELL);
1542 : :
1543 : 0 : rtl::OUString aTmpStr;
1544 [ # # ]: 0 : GetRefString(aTmpStr, pDoc);
1545 : :
1546 : 0 : sal_Int32 nPos = 0;
1547 : 0 : nPos = aRsc.indexOfAsciiL("#1", 2, nPos);
1548 [ # # ]: 0 : if (nPos >= 0)
1549 : : {
1550 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
1551 : 0 : nPos += aTmpStr.getLength();
1552 : : }
1553 : :
1554 [ # # ]: 0 : GetOldString( aTmpStr );
1555 [ # # ]: 0 : if (aTmpStr.isEmpty())
1556 [ # # ][ # # ]: 0 : aTmpStr = ScGlobal::GetRscString( STR_CHANGED_BLANK );
1557 : :
1558 : 0 : nPos = aRsc.indexOfAsciiL("#2", 2, nPos);
1559 [ # # ]: 0 : if (nPos >= 0)
1560 : : {
1561 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
1562 : 0 : nPos += aTmpStr.getLength();
1563 : : }
1564 : :
1565 [ # # ]: 0 : GetNewString( aTmpStr );
1566 [ # # ]: 0 : if (aTmpStr.isEmpty())
1567 [ # # ][ # # ]: 0 : aTmpStr = ScGlobal::GetRscString( STR_CHANGED_BLANK );
1568 : :
1569 : 0 : nPos = aRsc.indexOfAsciiL("#3", 2, nPos);
1570 [ # # ]: 0 : if (nPos >= 0)
1571 : : {
1572 : 0 : aRsc = aRsc.replaceAt(nPos, 2, aTmpStr);
1573 : 0 : nPos += aTmpStr.getLength();
1574 : : }
1575 : :
1576 [ # # ]: 0 : rtl::OUStringBuffer aBuf(rStr); // append to the original string.
1577 [ # # ]: 0 : aBuf.append(aRsc);
1578 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
1579 : 0 : }
1580 : :
1581 : :
1582 : 0 : void ScChangeActionContent::GetRefString(
1583 : : rtl::OUString& rStr, ScDocument* pDoc, bool bFlag3D ) const
1584 : : {
1585 [ # # ]: 0 : sal_uInt16 nFlags = ( GetBigRange().IsValid( pDoc ) ? SCA_VALID : 0 );
1586 [ # # ]: 0 : if ( nFlags )
1587 : : {
1588 : 0 : const ScBaseCell* pCell = GetNewCell();
1589 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pCell ) == SC_CACCT_MATORG )
1590 : : {
1591 : 0 : ScBigRange aLocalBigRange( GetBigRange() );
1592 : : SCCOL nC;
1593 : : SCROW nR;
1594 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetMatColsRows( nC, nR );
1595 : 0 : aLocalBigRange.aEnd.IncCol( nC-1 );
1596 : 0 : aLocalBigRange.aEnd.IncRow( nR-1 );
1597 [ # # ]: 0 : rStr = ScChangeAction::GetRefString( aLocalBigRange, pDoc, bFlag3D );
1598 : :
1599 : 0 : return ;
1600 : : }
1601 : :
1602 : 0 : ScAddress aTmpAddress( GetBigRange().aStart.MakeAddress() );
1603 [ # # ]: 0 : if ( bFlag3D )
1604 : 0 : nFlags |= SCA_TAB_3D;
1605 [ # # ][ # # ]: 0 : aTmpAddress.Format( rStr, nFlags, pDoc, pDoc->GetAddressConvention() );
1606 [ # # ][ # # ]: 0 : if ( IsDeletedIn() )
1607 : : {
1608 : : // Insert the parentheses.
1609 : 0 : rtl::OUStringBuffer aBuf;
1610 [ # # ]: 0 : aBuf.append(sal_Unicode('('));
1611 [ # # ]: 0 : aBuf.append(rStr);
1612 [ # # ]: 0 : aBuf.append(sal_Unicode(')'));
1613 [ # # ]: 0 : rStr = aBuf.makeStringAndClear();
1614 : : }
1615 : : }
1616 : : else
1617 : 0 : rStr = ScGlobal::GetRscString( STR_NOREF_STR );
1618 : : }
1619 : :
1620 : :
1621 : 0 : bool ScChangeActionContent::Reject( ScDocument* pDoc )
1622 : : {
1623 [ # # ]: 0 : if ( !aBigRange.IsValid( pDoc ) )
1624 : 0 : return false;
1625 : :
1626 : 0 : PutOldValueToDoc( pDoc, 0, 0 );
1627 : :
1628 : 0 : SetState( SC_CAS_REJECTED );
1629 : 0 : RemoveAllLinks();
1630 : :
1631 : 0 : return true;
1632 : : }
1633 : :
1634 : :
1635 : 0 : bool ScChangeActionContent::Select( ScDocument* pDoc, ScChangeTrack* pTrack,
1636 : : bool bOldest, ::std::stack<ScChangeActionContent*>* pRejectActions )
1637 : : {
1638 [ # # ]: 0 : if ( !aBigRange.IsValid( pDoc ) )
1639 : 0 : return false;
1640 : :
1641 : 0 : ScChangeActionContent* pContent = this;
1642 : : // accept previous contents
1643 [ # # ]: 0 : while ( ( pContent = pContent->pPrevContent ) != NULL )
1644 : : {
1645 [ # # ]: 0 : if ( pContent->IsVirgin() )
1646 : 0 : pContent->SetState( SC_CAS_ACCEPTED );
1647 : : }
1648 : 0 : ScChangeActionContent* pEnd = pContent = this;
1649 : : // reject subsequent contents
1650 [ # # ]: 0 : while ( ( pContent = pContent->pNextContent ) != NULL )
1651 : : {
1652 : : // MatrixOrigin may have dependents, no dependency recursion needed
1653 : 0 : const ScChangeActionLinkEntry* pL = pContent->GetFirstDependentEntry();
1654 [ # # ]: 0 : while ( pL )
1655 : : {
1656 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
1657 [ # # ]: 0 : if ( p )
1658 : 0 : p->SetRejected();
1659 : 0 : pL = pL->GetNext();
1660 : : }
1661 : 0 : pContent->SetRejected();
1662 : 0 : pEnd = pContent;
1663 : : }
1664 : :
1665 [ # # ][ # # ]: 0 : if ( bOldest || pEnd != this )
1666 : : { // wenn nicht aeltester: ist es ueberhaupt ein anderer als der letzte?
1667 : 0 : ScRange aRange( aBigRange.aStart.MakeAddress() );
1668 : 0 : const ScAddress& rPos = aRange.aStart;
1669 : :
1670 [ # # ][ # # ]: 0 : ScChangeActionContent* pNew = new ScChangeActionContent( aRange );
1671 [ # # ][ # # ]: 0 : pNew->SetOldValue( pDoc->GetCell( rPos ), pDoc, pDoc );
1672 : :
1673 [ # # ]: 0 : if ( bOldest )
1674 [ # # ]: 0 : PutOldValueToDoc( pDoc, 0, 0 );
1675 : : else
1676 [ # # ]: 0 : PutNewValueToDoc( pDoc, 0, 0 );
1677 : :
1678 [ # # ]: 0 : pNew->SetRejectAction( bOldest ? GetActionNumber() : pEnd->GetActionNumber() );
1679 : 0 : pNew->SetState( SC_CAS_ACCEPTED );
1680 [ # # ]: 0 : if ( pRejectActions )
1681 [ # # ]: 0 : pRejectActions->push( pNew );
1682 : : else
1683 : : {
1684 [ # # ][ # # ]: 0 : pNew->SetNewValue( pDoc->GetCell( rPos ), pDoc );
1685 [ # # ]: 0 : pTrack->Append( pNew );
1686 : : }
1687 : : }
1688 : :
1689 [ # # ]: 0 : if ( bOldest )
1690 : 0 : SetRejected();
1691 : : else
1692 : 0 : SetState( SC_CAS_ACCEPTED );
1693 : :
1694 : 0 : return true;
1695 : : }
1696 : :
1697 : :
1698 : 0 : void ScChangeActionContent::GetStringOfCell( rtl::OUString& rStr,
1699 : : const ScBaseCell* pCell, const ScDocument* pDoc, const ScAddress& rPos )
1700 : : {
1701 [ # # ]: 0 : if ( pCell )
1702 : : {
1703 [ # # ]: 0 : if ( ScChangeActionContent::NeedsNumberFormat( pCell ) )
1704 : 0 : GetStringOfCell( rStr, pCell, pDoc, pDoc->GetNumberFormat( rPos ) );
1705 : : else
1706 : 0 : GetStringOfCell( rStr, pCell, pDoc, 0 );
1707 : : }
1708 : : else
1709 : 0 : rStr = rtl::OUString();
1710 : 0 : }
1711 : :
1712 : :
1713 : 0 : void ScChangeActionContent::GetStringOfCell( rtl::OUString& rStr,
1714 : : const ScBaseCell* pCell, const ScDocument* pDoc, sal_uLong nFormat )
1715 : : {
1716 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pCell ) )
1717 : : {
1718 [ # # # # : 0 : switch ( pCell->GetCellType() )
# ]
1719 : : {
1720 : : case CELLTYPE_VALUE :
1721 : : {
1722 : 0 : double nValue = ((ScValueCell*)pCell)->GetValue();
1723 : : pDoc->GetFormatTable()->GetInputLineString( nValue, nFormat,
1724 [ # # ][ # # ]: 0 : rStr );
1725 : : }
1726 : 0 : break;
1727 : : case CELLTYPE_STRING :
1728 : 0 : rStr = ((ScStringCell*)pCell)->GetString();
1729 : 0 : break;
1730 : : case CELLTYPE_EDIT :
1731 : 0 : rStr = ((ScEditCell*)pCell)->GetString();
1732 : 0 : break;
1733 : : case CELLTYPE_FORMULA :
1734 [ # # ]: 0 : ((ScFormulaCell*)pCell)->GetFormula( rStr );
1735 : 0 : break;
1736 : : default:
1737 : 0 : rStr = rtl::OUString();
1738 : : }
1739 : : }
1740 : : else
1741 : 0 : rStr = rtl::OUString();
1742 : 0 : }
1743 : :
1744 : :
1745 : 0 : ScChangeActionContentCellType ScChangeActionContent::GetContentCellType( const ScBaseCell* pCell )
1746 : : {
1747 [ # # ]: 0 : if ( pCell )
1748 : : {
1749 [ # # # ]: 0 : switch ( pCell->GetCellType() )
1750 : : {
1751 : : case CELLTYPE_VALUE :
1752 : : case CELLTYPE_STRING :
1753 : : case CELLTYPE_EDIT :
1754 : 0 : return SC_CACCT_NORMAL;
1755 : : //break;
1756 : : case CELLTYPE_FORMULA :
1757 [ # # ]: 0 : switch ( ((const ScFormulaCell*)pCell)->GetMatrixFlag() )
[ # # # # ]
1758 : : {
1759 : : case MM_NONE :
1760 : 0 : return SC_CACCT_NORMAL;
1761 : : //break;
1762 : : case MM_FORMULA :
1763 : : case MM_FAKE :
1764 : 0 : return SC_CACCT_MATORG;
1765 : : //break;
1766 : : case MM_REFERENCE :
1767 : 0 : return SC_CACCT_MATREF;
1768 : : //break;
1769 : : }
1770 : 0 : return SC_CACCT_NORMAL;
1771 : : //break;
1772 : : default:
1773 : 0 : return SC_CACCT_NONE;
1774 : : }
1775 : : }
1776 : 0 : return SC_CACCT_NONE;
1777 : : }
1778 : :
1779 : :
1780 : 0 : bool ScChangeActionContent::NeedsNumberFormat( const ScBaseCell* pCell )
1781 : : {
1782 [ # # ][ # # ]: 0 : return pCell && pCell->GetCellType() == CELLTYPE_VALUE;
1783 : : }
1784 : :
1785 : :
1786 : 0 : void ScChangeActionContent::SetValue(
1787 : : rtl::OUString& rStr, ScBaseCell*& pCell, const ScAddress& rPos, const ScBaseCell* pOrgCell,
1788 : : const ScDocument* pFromDoc, ScDocument* pToDoc )
1789 : : {
1790 [ # # ]: 0 : sal_uLong nFormat = NeedsNumberFormat( pOrgCell ) ? pFromDoc->GetNumberFormat( rPos ) : 0;
1791 : 0 : SetValue( rStr, pCell, nFormat, pOrgCell, pFromDoc, pToDoc );
1792 : 0 : }
1793 : :
1794 : 0 : void ScChangeActionContent::SetValue(
1795 : : rtl::OUString& rStr, ScBaseCell*& pCell, sal_uLong nFormat, const ScBaseCell* pOrgCell,
1796 : : const ScDocument* pFromDoc, ScDocument* pToDoc )
1797 : : {
1798 : 0 : rStr = rtl::OUString();
1799 [ # # ]: 0 : if ( pCell )
1800 : 0 : pCell->Delete();
1801 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pOrgCell ) )
1802 : : {
1803 : 0 : pCell = pOrgCell->Clone( *pToDoc );
1804 [ # # # ]: 0 : switch ( pOrgCell->GetCellType() )
1805 : : {
1806 : : case CELLTYPE_VALUE :
1807 : : { // z.B. Datum auch als solches merken
1808 : 0 : double nValue = ((ScValueCell*)pOrgCell)->GetValue();
1809 : : pFromDoc->GetFormatTable()->GetInputLineString( nValue,
1810 [ # # ][ # # ]: 0 : nFormat, rStr );
1811 : : }
1812 : 0 : break;
1813 : : case CELLTYPE_FORMULA :
1814 [ # # ]: 0 : ((ScFormulaCell*)pCell)->SetInChangeTrack( true );
1815 : 0 : break;
1816 : : default:
1817 : : {
1818 : : // added to avoid warnings
1819 : : }
1820 : : }
1821 : : }
1822 : : else
1823 : 0 : pCell = NULL;
1824 : 0 : }
1825 : :
1826 : :
1827 : 0 : void ScChangeActionContent::SetCell(
1828 : : rtl::OUString& rStr, ScBaseCell* pCell, sal_uLong nFormat, const ScDocument* pDoc )
1829 : : {
1830 : 0 : rStr = rtl::OUString();
1831 [ # # ]: 0 : if ( pCell )
1832 : : {
1833 [ # # # ]: 0 : switch ( pCell->GetCellType() )
1834 : : {
1835 : : case CELLTYPE_VALUE :
1836 : : { // e.g. remember date as date string
1837 : 0 : double nValue = ((ScValueCell*)pCell)->GetValue();
1838 : : pDoc->GetFormatTable()->GetInputLineString( nValue,
1839 [ # # ][ # # ]: 0 : nFormat, rStr );
1840 : : }
1841 : 0 : break;
1842 : : case CELLTYPE_FORMULA :
1843 [ # # ]: 0 : ((ScFormulaCell*)pCell)->SetInChangeTrack( true );
1844 : 0 : break;
1845 : : default:
1846 : : {
1847 : : // added to avoid warnings
1848 : : }
1849 : : }
1850 : : }
1851 : 0 : }
1852 : :
1853 : :
1854 : 0 : void ScChangeActionContent::GetValueString(
1855 : : rtl::OUString& rStr, const rtl::OUString& rValue, const ScBaseCell* pCell ) const
1856 : : {
1857 [ # # ]: 0 : if (rValue.isEmpty())
1858 : : {
1859 [ # # ]: 0 : if ( pCell )
1860 : : {
1861 [ # # # # : 0 : switch ( pCell->GetCellType() )
# ]
1862 : : {
1863 : : case CELLTYPE_STRING :
1864 : 0 : rStr = ((ScStringCell*)pCell)->GetString();
1865 : 0 : break;
1866 : : case CELLTYPE_EDIT :
1867 : 0 : rStr = ((ScEditCell*)pCell)->GetString();
1868 : 0 : break;
1869 : : case CELLTYPE_VALUE : // ist immer in rValue
1870 : 0 : rStr = rValue;
1871 : 0 : break;
1872 : : case CELLTYPE_FORMULA :
1873 [ # # ]: 0 : GetFormulaString( rStr, (ScFormulaCell*) pCell );
1874 : 0 : break;
1875 : : default:
1876 : : {
1877 : : // added to avoid warnings
1878 : : }
1879 : : }
1880 : : }
1881 : : else
1882 : 0 : rStr = rtl::OUString();
1883 : : }
1884 : : else
1885 : 0 : rStr = rValue;
1886 : 0 : }
1887 : :
1888 : :
1889 : 0 : void ScChangeActionContent::GetFormulaString(
1890 : : rtl::OUString& rStr, const ScFormulaCell* pCell ) const
1891 : : {
1892 : 0 : ScAddress aPos( aBigRange.aStart.MakeAddress() );
1893 [ # # ][ # # ]: 0 : if ( aPos == pCell->aPos || IsDeletedIn() )
[ # # ][ # # ]
1894 [ # # ]: 0 : pCell->GetFormula( rStr );
1895 : : else
1896 : : {
1897 : : OSL_FAIL( "ScChangeActionContent::GetFormulaString: aPos != pCell->aPos" );
1898 [ # # ][ # # ]: 0 : ScFormulaCell* pNew = new ScFormulaCell( *pCell, *pCell->GetDocument(), aPos );
1899 [ # # ]: 0 : pNew->GetFormula( rStr );
1900 [ # # ][ # # ]: 0 : delete pNew;
1901 : : }
1902 : 0 : }
1903 : :
1904 : :
1905 : 0 : void ScChangeActionContent::PutOldValueToDoc( ScDocument* pDoc,
1906 : : SCsCOL nDx, SCsROW nDy ) const
1907 : : {
1908 : 0 : PutValueToDoc( pOldCell, aOldValue, pDoc, nDx, nDy );
1909 : 0 : }
1910 : :
1911 : :
1912 : 0 : void ScChangeActionContent::PutNewValueToDoc( ScDocument* pDoc,
1913 : : SCsCOL nDx, SCsROW nDy ) const
1914 : : {
1915 : 0 : PutValueToDoc( pNewCell, aNewValue, pDoc, nDx, nDy );
1916 : 0 : }
1917 : :
1918 : :
1919 : 0 : void ScChangeActionContent::PutValueToDoc(
1920 : : ScBaseCell* pCell, const rtl::OUString& rValue, ScDocument* pDoc,
1921 : : SCsCOL nDx, SCsROW nDy ) const
1922 : : {
1923 : 0 : ScAddress aPos( aBigRange.aStart.MakeAddress() );
1924 [ # # ]: 0 : if ( nDx )
1925 [ # # ]: 0 : aPos.IncCol( nDx );
1926 [ # # ]: 0 : if ( nDy )
1927 [ # # ]: 0 : aPos.IncRow( nDy );
1928 [ # # ]: 0 : if (rValue.isEmpty())
1929 : : {
1930 [ # # ]: 0 : if ( pCell )
1931 : : {
1932 [ # # ]: 0 : switch ( pCell->GetCellType() )
1933 : : {
1934 : : case CELLTYPE_VALUE : // ist immer in rValue
1935 [ # # ]: 0 : pDoc->SetString( aPos.Col(), aPos.Row(), aPos.Tab(), rValue );
1936 : 0 : break;
1937 : : default:
1938 [ # # # ]: 0 : switch ( ScChangeActionContent::GetContentCellType( pCell ) )
1939 : : {
1940 : : case SC_CACCT_MATORG :
1941 : : {
1942 : : SCCOL nC;
1943 : : SCROW nR;
1944 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetMatColsRows( nC, nR );
1945 : : OSL_ENSURE( nC>0 && nR>0, "ScChangeActionContent::PutValueToDoc: MatColsRows?" );
1946 : 0 : ScRange aRange( aPos );
1947 [ # # ]: 0 : if ( nC > 1 )
1948 [ # # ]: 0 : aRange.aEnd.IncCol( nC-1 );
1949 [ # # ]: 0 : if ( nR > 1 )
1950 [ # # ]: 0 : aRange.aEnd.IncRow( nR-1 );
1951 [ # # ]: 0 : ScMarkData aDestMark;
1952 [ # # ]: 0 : aDestMark.SelectOneTable( aPos.Tab() );
1953 [ # # ]: 0 : aDestMark.SetMarkArea( aRange );
1954 : 0 : pDoc->InsertMatrixFormula( aPos.Col(), aPos.Row(),
1955 : 0 : aRange.aEnd.Col(), aRange.aEnd.Row(),
1956 [ # # ]: 0 : aDestMark, EMPTY_OUSTRING,
1957 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetCode() );
[ # # ]
1958 : : }
1959 : 0 : break;
1960 : : case SC_CACCT_MATREF :
1961 : : // nothing
1962 : 0 : break;
1963 : : default:
1964 [ # # ][ # # ]: 0 : pDoc->PutCell( aPos, pCell->Clone( *pDoc ) );
1965 : : }
1966 : : }
1967 : : }
1968 : : else
1969 [ # # ]: 0 : pDoc->PutCell( aPos, NULL );
1970 : : }
1971 : : else
1972 [ # # ]: 0 : pDoc->SetString( aPos.Col(), aPos.Row(), aPos.Tab(), rValue );
1973 : 0 : }
1974 : :
1975 : :
1976 : 0 : void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos )
1977 : : {
1978 : 0 : ScSingleRefData& rRef1 = rTok.GetSingleRef();
1979 [ # # ][ # # ]: 0 : if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
[ # # ]
1980 : : {
1981 : 0 : rRef1.nCol = SCCOL_MAX;
1982 : 0 : rRef1.nRelCol = SCCOL_MAX;
1983 : 0 : rRef1.SetColDeleted( true );
1984 : : }
1985 [ # # ][ # # ]: 0 : if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
[ # # ]
1986 : : {
1987 : 0 : rRef1.nRow = SCROW_MAX;
1988 : 0 : rRef1.nRelRow = SCROW_MAX;
1989 : 0 : rRef1.SetRowDeleted( true );
1990 : : }
1991 [ # # ][ # # ]: 0 : if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
[ # # ]
1992 : : {
1993 : 0 : rRef1.nTab = SCTAB_MAX;
1994 : 0 : rRef1.nRelTab = SCTAB_MAX;
1995 : 0 : rRef1.SetTabDeleted( true );
1996 : : }
1997 [ # # ]: 0 : if ( rTok.GetType() == formula::svDoubleRef )
1998 : : {
1999 : 0 : ScSingleRefData& rRef2 = rTok.GetDoubleRef().Ref2;
2000 [ # # ][ # # ]: 0 : if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
[ # # ]
2001 : : {
2002 : 0 : rRef2.nCol = SCCOL_MAX;
2003 : 0 : rRef2.nRelCol = SCCOL_MAX;
2004 : 0 : rRef2.SetColDeleted( true );
2005 : : }
2006 [ # # ][ # # ]: 0 : if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
[ # # ]
2007 : : {
2008 : 0 : rRef2.nRow = SCROW_MAX;
2009 : 0 : rRef2.nRelRow = SCROW_MAX;
2010 : 0 : rRef2.SetRowDeleted( true );
2011 : : }
2012 [ # # ][ # # ]: 0 : if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
[ # # ]
2013 : : {
2014 : 0 : rRef2.nTab = SCTAB_MAX;
2015 : 0 : rRef2.nRelTab = SCTAB_MAX;
2016 : 0 : rRef2.SetTabDeleted( true );
2017 : : }
2018 : : }
2019 : 0 : }
2020 : :
2021 : :
2022 : 0 : void ScChangeActionContent::UpdateReference( const ScChangeTrack* pTrack,
2023 : : UpdateRefMode eMode, const ScBigRange& rRange,
2024 : : sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz )
2025 : : {
2026 : 0 : SCSIZE nOldSlot = ScChangeTrack::ComputeContentSlot( aBigRange.aStart.Row() );
2027 : 0 : ScRefUpdate::Update( eMode, rRange, nDx, nDy, nDz, aBigRange );
2028 : 0 : SCSIZE nNewSlot = ScChangeTrack::ComputeContentSlot( aBigRange.aStart.Row() );
2029 [ # # ]: 0 : if ( nNewSlot != nOldSlot )
2030 : : {
2031 : 0 : RemoveFromSlot();
2032 : 0 : InsertInSlot( &(pTrack->GetContentSlots()[nNewSlot]) );
2033 : : }
2034 : :
2035 [ # # ][ # # ]: 0 : if ( pTrack->IsInDelete() && !pTrack->IsInDeleteTop() )
[ # # ]
2036 : 0 : return ; // Formeln nur kompletten Bereich updaten
2037 : :
2038 [ # # ][ # # ]: 0 : bool bOldFormula = ( pOldCell && pOldCell->GetCellType() == CELLTYPE_FORMULA );
2039 [ # # ][ # # ]: 0 : bool bNewFormula = ( pNewCell && pNewCell->GetCellType() == CELLTYPE_FORMULA );
2040 [ # # ][ # # ]: 0 : if ( bOldFormula || bNewFormula )
2041 : : { // via ScFormulaCell UpdateReference anpassen (dort)
2042 [ # # ]: 0 : if ( pTrack->IsInDelete() )
2043 : : {
2044 : 0 : const ScRange& rDelRange = pTrack->GetInDeleteRange();
2045 [ # # ]: 0 : if ( nDx > 0 )
2046 : 0 : nDx = rDelRange.aEnd.Col() - rDelRange.aStart.Col() + 1;
2047 [ # # ]: 0 : else if ( nDx < 0 )
2048 : 0 : nDx = -(rDelRange.aEnd.Col() - rDelRange.aStart.Col() + 1);
2049 [ # # ]: 0 : if ( nDy > 0 )
2050 : 0 : nDy = rDelRange.aEnd.Row() - rDelRange.aStart.Row() + 1;
2051 [ # # ]: 0 : else if ( nDy < 0 )
2052 : 0 : nDy = -(rDelRange.aEnd.Row() - rDelRange.aStart.Row() + 1);
2053 [ # # ]: 0 : if ( nDz > 0 )
2054 : 0 : nDz = rDelRange.aEnd.Tab() - rDelRange.aStart.Tab() + 1;
2055 [ # # ]: 0 : else if ( nDz < 0 )
2056 : 0 : nDz = -(rDelRange.aEnd.Tab() - rDelRange.aStart.Tab() + 1);
2057 : : }
2058 : 0 : ScBigRange aTmpRange( rRange );
2059 [ # # # ]: 0 : switch ( eMode )
2060 : : {
2061 : : case URM_INSDEL :
2062 [ # # ][ # # ]: 0 : if ( nDx < 0 || nDy < 0 || nDz < 0 )
[ # # ]
2063 : : { // Delete startet dort hinter geloeschtem Bereich,
2064 : : // Position wird dort angepasst.
2065 [ # # ]: 0 : if ( nDx )
2066 : 0 : aTmpRange.aStart.IncCol( -nDx );
2067 [ # # ]: 0 : if ( nDy )
2068 : 0 : aTmpRange.aStart.IncRow( -nDy );
2069 [ # # ]: 0 : if ( nDz )
2070 : 0 : aTmpRange.aStart.IncTab( -nDz );
2071 : : }
2072 : 0 : break;
2073 : : case URM_MOVE :
2074 : : // Move ist hier Quelle, dort Ziel,
2075 : : // Position muss vorher angepasst sein.
2076 [ # # ]: 0 : if ( bOldFormula )
2077 [ # # ]: 0 : ((ScFormulaCell*)pOldCell)->aPos = aBigRange.aStart.MakeAddress();
2078 [ # # ]: 0 : if ( bNewFormula )
2079 [ # # ]: 0 : ((ScFormulaCell*)pNewCell)->aPos = aBigRange.aStart.MakeAddress();
2080 [ # # ]: 0 : if ( nDx )
2081 : : {
2082 : 0 : aTmpRange.aStart.IncCol( nDx );
2083 : 0 : aTmpRange.aEnd.IncCol( nDx );
2084 : : }
2085 [ # # ]: 0 : if ( nDy )
2086 : : {
2087 : 0 : aTmpRange.aStart.IncRow( nDy );
2088 : 0 : aTmpRange.aEnd.IncRow( nDy );
2089 : : }
2090 [ # # ]: 0 : if ( nDz )
2091 : : {
2092 : 0 : aTmpRange.aStart.IncTab( nDz );
2093 : 0 : aTmpRange.aEnd.IncTab( nDz );
2094 : : }
2095 : 0 : break;
2096 : : default:
2097 : : {
2098 : : // added to avoid warnings
2099 : : }
2100 : : }
2101 : 0 : ScRange aRange( aTmpRange.MakeRange() );
2102 [ # # ]: 0 : if ( bOldFormula )
2103 : 0 : ((ScFormulaCell*)pOldCell)->UpdateReference( eMode, aRange,
2104 [ # # ][ # # ]: 0 : (SCsCOL) nDx, (SCsROW) nDy, (SCsTAB) nDz, NULL );
2105 [ # # ]: 0 : if ( bNewFormula )
2106 : 0 : ((ScFormulaCell*)pNewCell)->UpdateReference( eMode, aRange,
2107 [ # # ][ # # ]: 0 : (SCsCOL) nDx, (SCsROW) nDy, (SCsTAB) nDz, NULL );
2108 [ # # ][ # # ]: 0 : if ( !aBigRange.aStart.IsValid( pTrack->GetDocument() ) )
2109 : : { //! HACK!
2110 : : //! UpdateReference kann nicht mit Positionen ausserhalb des
2111 : : //! Dokuments umgehen, deswegen alles auf #REF! setzen
2112 : : //2do: make it possible! das bedeutet grossen Umbau von ScAddress etc.!
2113 : 0 : const ScBigAddress& rPos = aBigRange.aStart;
2114 [ # # ]: 0 : if ( bOldFormula )
2115 : : {
2116 : : ScToken* t;
2117 [ # # ]: 0 : ScTokenArray* pArr = ((ScFormulaCell*)pOldCell)->GetCode();
2118 : 0 : pArr->Reset();
2119 [ # # ][ # # ]: 0 : while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL )
2120 [ # # ]: 0 : lcl_InvalidateReference( *t, rPos );
2121 : 0 : pArr->Reset();
2122 [ # # ][ # # ]: 0 : while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
2123 [ # # ]: 0 : lcl_InvalidateReference( *t, rPos );
2124 : : }
2125 [ # # ]: 0 : if ( bNewFormula )
2126 : : {
2127 : : ScToken* t;
2128 [ # # ]: 0 : ScTokenArray* pArr = ((ScFormulaCell*)pNewCell)->GetCode();
2129 : 0 : pArr->Reset();
2130 [ # # ][ # # ]: 0 : while ( ( t = static_cast<ScToken*>(pArr->GetNextReference()) ) != NULL )
2131 [ # # ]: 0 : lcl_InvalidateReference( *t, rPos );
2132 : 0 : pArr->Reset();
2133 [ # # ][ # # ]: 0 : while ( ( t = static_cast<ScToken*>(pArr->GetNextReferenceRPN()) ) != NULL )
2134 [ # # ]: 0 : lcl_InvalidateReference( *t, rPos );
2135 : : }
2136 : : }
2137 : : }
2138 : : }
2139 : :
2140 : 0 : bool ScChangeActionContent::IsMatrixOrigin() const
2141 : : {
2142 : 0 : return GetContentCellType(GetNewCell()) == SC_CACCT_MATORG;
2143 : : }
2144 : :
2145 : 0 : bool ScChangeActionContent::IsOldMatrixReference() const
2146 : : {
2147 : 0 : return GetContentCellType(GetOldCell()) == SC_CACCT_MATREF;
2148 : : }
2149 : :
2150 : : // --- ScChangeActionReject ------------------------------------------------
2151 : :
2152 : 0 : ScChangeActionReject::ScChangeActionReject(
2153 : : const sal_uLong nActionNumber, const ScChangeActionState eStateP,
2154 : : const sal_uLong nRejectingNumber,
2155 : : const ScBigRange& aBigRangeP, const rtl::OUString& aUserP,
2156 : : const DateTime& aDateTimeP, const rtl::OUString& sComment) :
2157 : 0 : ScChangeAction(SC_CAT_CONTENT, aBigRangeP, nActionNumber, nRejectingNumber, eStateP, aDateTimeP, aUserP, sComment)
2158 : : {
2159 : 0 : }
2160 : :
2161 : 0 : bool ScChangeActionReject::Reject(ScDocument* /*pDoc*/)
2162 : : {
2163 : 0 : return false;
2164 : : }
2165 : :
2166 : :
2167 : : // --- ScChangeTrack -------------------------------------------------------
2168 : :
2169 : 51 : IMPL_FIXEDMEMPOOL_NEWDEL( ScChangeTrackMsgInfo )
2170 : :
2171 : 51 : const SCROW ScChangeTrack::nContentRowsPerSlot = InitContentRowsPerSlot();
2172 : 51 : const SCSIZE ScChangeTrack::nContentSlots =
2173 : 51 : (MAXROWCOUNT) / InitContentRowsPerSlot() + 2;
2174 : :
2175 : 102 : SCROW ScChangeTrack::InitContentRowsPerSlot()
2176 : : {
2177 : 102 : const SCSIZE nMaxSlots = 0xffe0 / sizeof( ScChangeActionContent* ) - 2;
2178 : 102 : SCROW nRowsPerSlot = (MAXROWCOUNT) / nMaxSlots;
2179 [ + - ]: 102 : if ( nRowsPerSlot * nMaxSlots < sal::static_int_cast<SCSIZE>(MAXROWCOUNT) )
2180 : 102 : ++nRowsPerSlot;
2181 : 102 : return nRowsPerSlot;
2182 : : }
2183 : :
2184 : :
2185 : 0 : ScChangeTrack::ScChangeTrack( ScDocument* pDocP ) :
2186 : : aFixDateTime( DateTime::SYSTEM ),
2187 [ # # ][ # # ]: 0 : pDoc( pDocP )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2188 : : {
2189 [ # # ]: 0 : Init();
2190 [ # # ][ # # ]: 0 : SC_MOD()->GetUserOptions().AddListener(this);
[ # # ]
2191 : :
2192 [ # # ]: 0 : ppContentSlots = new ScChangeActionContent* [ nContentSlots ];
2193 : 0 : memset( ppContentSlots, 0, nContentSlots * sizeof( ScChangeActionContent* ) );
2194 : 0 : }
2195 : :
2196 : 0 : ScChangeTrack::ScChangeTrack( ScDocument* pDocP, const std::set<rtl::OUString>& aTempUserCollection) :
2197 : : maUserCollection(aTempUserCollection),
2198 : : aFixDateTime( DateTime::SYSTEM ),
2199 [ # # ][ # # ]: 0 : pDoc( pDocP )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2200 : : {
2201 [ # # ]: 0 : Init();
2202 [ # # ][ # # ]: 0 : SC_MOD()->GetUserOptions().AddListener(this);
[ # # ]
2203 [ # # ]: 0 : ppContentSlots = new ScChangeActionContent* [ nContentSlots ];
2204 : 0 : memset( ppContentSlots, 0, nContentSlots * sizeof( ScChangeActionContent* ) );
2205 : 0 : }
2206 : :
2207 [ # # ]: 0 : ScChangeTrack::~ScChangeTrack()
2208 : : {
2209 [ # # ][ # # ]: 0 : SC_MOD()->GetUserOptions().RemoveListener(this);
[ # # ]
2210 [ # # ]: 0 : DtorClear();
2211 [ # # ]: 0 : delete [] ppContentSlots;
2212 [ # # ]: 0 : }
2213 : :
2214 : :
2215 : 0 : void ScChangeTrack::Init()
2216 : : {
2217 : 0 : pFirst = NULL;
2218 : 0 : pLast = NULL;
2219 : 0 : pFirstGeneratedDelContent = NULL;
2220 : 0 : pLastCutMove = NULL;
2221 : 0 : pLinkInsertCol = NULL;
2222 : 0 : pLinkInsertRow = NULL;
2223 : 0 : pLinkInsertTab = NULL;
2224 : 0 : pLinkMove = NULL;
2225 : 0 : pBlockModifyMsg = NULL;
2226 : 0 : nActionMax = 0;
2227 : 0 : nGeneratedMin = SC_CHGTRACK_GENERATED_START;
2228 : 0 : nMarkLastSaved = 0;
2229 : 0 : nStartLastCut = 0;
2230 : 0 : nEndLastCut = 0;
2231 : 0 : nLastMerge = 0;
2232 : 0 : eMergeState = SC_CTMS_NONE;
2233 : 0 : nLoadedFileFormatVersion = SC_CHGTRACK_FILEFORMAT;
2234 : 0 : bLoadSave = false;
2235 : 0 : bInDelete = false;
2236 : 0 : bInDeleteTop = false;
2237 : 0 : bInDeleteUndo = false;
2238 : 0 : bInPasteCut = false;
2239 : 0 : bUseFixDateTime = false;
2240 : 0 : bTime100thSeconds = true;
2241 : :
2242 [ # # ][ # # ]: 0 : const SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions();
2243 : 0 : rtl::OUStringBuffer aBuf;
2244 [ # # ][ # # ]: 0 : aBuf.append(rUserOpt.GetFirstName());
2245 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
2246 [ # # ][ # # ]: 0 : aBuf.append(rUserOpt.GetLastName());
2247 [ # # ]: 0 : maUser = aBuf.makeStringAndClear();
2248 [ # # ]: 0 : maUserCollection.insert(maUser);
2249 : 0 : }
2250 : :
2251 : :
2252 : 0 : void ScChangeTrack::DtorClear()
2253 : : {
2254 : : ScChangeAction* p;
2255 : : ScChangeAction* pNext;
2256 : 0 : ScChangeActionMap::iterator itChangeAction;
2257 [ # # ]: 0 : for ( p = GetFirst(); p; p = pNext )
2258 : : {
2259 : 0 : pNext = p->GetNext();
2260 [ # # ][ # # ]: 0 : delete p;
2261 : : }
2262 [ # # ]: 0 : for ( p = pFirstGeneratedDelContent; p; p = pNext )
2263 : : {
2264 : 0 : pNext = p->GetNext();
2265 [ # # ][ # # ]: 0 : delete p;
2266 : : }
2267 [ # # ]: 0 : for( itChangeAction = aPasteCutMap.begin(); itChangeAction != aPasteCutMap.end(); ++itChangeAction )
2268 : : {
2269 [ # # ][ # # ]: 0 : delete itChangeAction->second;
2270 : : }
2271 [ # # ][ # # ]: 0 : delete pLastCutMove;
2272 [ # # ]: 0 : ClearMsgQueue();
2273 : 0 : }
2274 : :
2275 : :
2276 : 0 : void ScChangeTrack::ClearMsgQueue()
2277 : : {
2278 [ # # ]: 0 : if ( pBlockModifyMsg )
2279 : : {
2280 [ # # ]: 0 : delete pBlockModifyMsg;
2281 : 0 : pBlockModifyMsg = NULL;
2282 : : }
2283 [ # # ]: 0 : while ( !aMsgStackTmp.empty() )
2284 : : {
2285 [ # # ][ # # ]: 0 : delete aMsgStackTmp.top();
2286 [ # # ]: 0 : aMsgStackTmp.pop();
2287 : : }
2288 [ # # ]: 0 : while ( !aMsgStackFinal.empty() )
2289 : : {
2290 [ # # ][ # # ]: 0 : delete aMsgStackFinal.top();
2291 [ # # ]: 0 : aMsgStackFinal.pop();
2292 : : }
2293 : :
2294 : 0 : ScChangeTrackMsgQueue::iterator itQueue;
2295 [ # # ][ # # ]: 0 : for ( itQueue = aMsgQueue.begin(); itQueue != aMsgQueue.end(); ++itQueue)
[ # # ]
2296 [ # # ]: 0 : delete *itQueue;
2297 : :
2298 : 0 : aMsgQueue.clear();
2299 : 0 : }
2300 : :
2301 : :
2302 : 0 : void ScChangeTrack::Clear()
2303 : : {
2304 : 0 : DtorClear();
2305 : 0 : aMap.clear();
2306 : 0 : aGeneratedMap.clear();
2307 : 0 : aPasteCutMap.clear();
2308 : 0 : maUserCollection.clear();
2309 : 0 : maUser = rtl::OUString();
2310 : 0 : Init();
2311 : 0 : }
2312 : :
2313 : 0 : const std::set<rtl::OUString>& ScChangeTrack::GetUserCollection() const
2314 : : {
2315 : 0 : return maUserCollection;
2316 : : }
2317 : :
2318 : 0 : void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
2319 : : {
2320 [ # # ]: 0 : if ( !pDoc->IsInDtorClear() )
2321 : : {
2322 [ # # ][ # # ]: 0 : const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions();
2323 : 0 : size_t nOldCount = maUserCollection.size();
2324 : :
2325 : 0 : rtl::OUStringBuffer aBuf;
2326 [ # # ][ # # ]: 0 : aBuf.append(rUserOptions.GetFirstName());
2327 [ # # ]: 0 : aBuf.append(sal_Unicode(' '));
2328 [ # # ][ # # ]: 0 : aBuf.append(rUserOptions.GetLastName());
2329 [ # # ][ # # ]: 0 : SetUser(aBuf.makeStringAndClear());
2330 : :
2331 [ # # ]: 0 : if ( maUserCollection.size() != nOldCount )
2332 : : {
2333 : : // New user in collection -> have to repaint because
2334 : : // colors may be different now (#106697#).
2335 : : // (Has to be done in the Notify handler, to be sure
2336 : : // the user collection has already been updated)
2337 : :
2338 : 0 : SfxObjectShell* pDocSh = pDoc->GetDocumentShell();
2339 [ # # ]: 0 : if (pDocSh)
2340 [ # # ][ # # ]: 0 : pDocSh->Broadcast( ScPaintHint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB), PAINT_GRID ) );
[ # # ]
2341 : 0 : }
2342 : : }
2343 : 0 : }
2344 : :
2345 : :
2346 : 0 : void ScChangeTrack::SetUser( const rtl::OUString& rUser )
2347 : : {
2348 [ # # ]: 0 : if ( IsLoadSave() )
2349 : 0 : return ; // nicht die Collection zerschiessen
2350 : :
2351 : 0 : maUser = rUser;
2352 : 0 : maUserCollection.insert(maUser);
2353 : : }
2354 : :
2355 : 0 : const rtl::OUString& ScChangeTrack::GetUser() const
2356 : : {
2357 : 0 : return maUser;
2358 : : }
2359 : :
2360 : 0 : void ScChangeTrack::StartBlockModify( ScChangeTrackMsgType eMsgType,
2361 : : sal_uLong nStartAction )
2362 : : {
2363 [ # # ]: 0 : if ( aModifiedLink.IsSet() )
2364 : : {
2365 [ # # ]: 0 : if ( pBlockModifyMsg )
2366 : 0 : aMsgStackTmp.push( pBlockModifyMsg ); // Block im Block
2367 : 0 : pBlockModifyMsg = new ScChangeTrackMsgInfo;
2368 : 0 : pBlockModifyMsg->eMsgType = eMsgType;
2369 : 0 : pBlockModifyMsg->nStartAction = nStartAction;
2370 : : }
2371 : 0 : }
2372 : :
2373 : :
2374 : 0 : void ScChangeTrack::EndBlockModify( sal_uLong nEndAction )
2375 : : {
2376 [ # # ]: 0 : if ( aModifiedLink.IsSet() )
2377 : : {
2378 [ # # ]: 0 : if ( pBlockModifyMsg )
2379 : : {
2380 [ # # ]: 0 : if ( pBlockModifyMsg->nStartAction <= nEndAction )
2381 : : {
2382 : 0 : pBlockModifyMsg->nEndAction = nEndAction;
2383 : : // Blocks in Blocks aufgeloest
2384 : 0 : aMsgStackFinal.push( pBlockModifyMsg );
2385 : : }
2386 : : else
2387 : 0 : delete pBlockModifyMsg;
2388 [ # # ]: 0 : if (aMsgStackTmp.empty())
2389 : 0 : pBlockModifyMsg = NULL;
2390 : : else
2391 : : {
2392 : 0 : pBlockModifyMsg = aMsgStackTmp.top(); // evtl. Block im Block
2393 : 0 : aMsgStackTmp.pop();
2394 : : }
2395 : : }
2396 [ # # ]: 0 : if ( !pBlockModifyMsg )
2397 : : {
2398 : 0 : bool bNew = false;
2399 [ # # ]: 0 : while ( !aMsgStackFinal.empty() )
2400 : : {
2401 : 0 : aMsgQueue.push_back( aMsgStackFinal.top() );
2402 : 0 : aMsgStackFinal.pop();
2403 : 0 : bNew = true;
2404 : : }
2405 [ # # ]: 0 : if ( bNew )
2406 : 0 : aModifiedLink.Call( this );
2407 : : }
2408 : : }
2409 : 0 : }
2410 : :
2411 : :
2412 : 0 : void ScChangeTrack::NotifyModified( ScChangeTrackMsgType eMsgType,
2413 : : sal_uLong nStartAction, sal_uLong nEndAction )
2414 : : {
2415 [ # # ]: 0 : if ( aModifiedLink.IsSet() )
2416 : : {
2417 [ # # ]: 0 : if ( !pBlockModifyMsg || pBlockModifyMsg->eMsgType != eMsgType ||
[ # # # # ]
[ # # ][ # # ]
[ # # ]
2418 : 0 : (IsGenerated( nStartAction ) &&
2419 : : (eMsgType == SC_CTM_APPEND || eMsgType == SC_CTM_REMOVE)) )
2420 : : { // Append innerhalb von Append z.B. nicht
2421 : 0 : StartBlockModify( eMsgType, nStartAction );
2422 : 0 : EndBlockModify( nEndAction );
2423 : : }
2424 : : }
2425 : 0 : }
2426 : :
2427 : :
2428 : 0 : void ScChangeTrack::MasterLinks( ScChangeAction* pAppend )
2429 : : {
2430 : 0 : ScChangeActionType eType = pAppend->GetType();
2431 : :
2432 [ # # ]: 0 : if ( eType == SC_CAT_CONTENT )
2433 : : {
2434 [ # # ]: 0 : if ( !IsGenerated( pAppend->GetActionNumber() ) )
2435 : : {
2436 : : SCSIZE nSlot = ComputeContentSlot(
2437 : 0 : pAppend->GetBigRange().aStart.Row() );
2438 : : ((ScChangeActionContent*)pAppend)->InsertInSlot(
2439 : 0 : &ppContentSlots[nSlot] );
2440 : : }
2441 : 0 : return ;
2442 : : }
2443 : :
2444 [ # # ]: 0 : if ( pAppend->IsRejecting() )
2445 : 0 : return ; // Rejects haben keine Abhaengigkeiten
2446 : :
2447 [ # # # # : 0 : switch ( eType )
# ]
2448 : : {
2449 : : case SC_CAT_INSERT_COLS :
2450 : : {
2451 : : ScChangeActionLinkEntry* pLink = new ScChangeActionLinkEntry(
2452 : 0 : &pLinkInsertCol, pAppend );
2453 : 0 : pAppend->AddLink( NULL, pLink );
2454 : : }
2455 : 0 : break;
2456 : : case SC_CAT_INSERT_ROWS :
2457 : : {
2458 : : ScChangeActionLinkEntry* pLink = new ScChangeActionLinkEntry(
2459 : 0 : &pLinkInsertRow, pAppend );
2460 : 0 : pAppend->AddLink( NULL, pLink );
2461 : : }
2462 : 0 : break;
2463 : : case SC_CAT_INSERT_TABS :
2464 : : {
2465 : : ScChangeActionLinkEntry* pLink = new ScChangeActionLinkEntry(
2466 : 0 : &pLinkInsertTab, pAppend );
2467 : 0 : pAppend->AddLink( NULL, pLink );
2468 : : }
2469 : 0 : break;
2470 : : case SC_CAT_MOVE :
2471 : : {
2472 : : ScChangeActionLinkEntry* pLink = new ScChangeActionLinkEntry(
2473 : 0 : &pLinkMove, pAppend );
2474 : 0 : pAppend->AddLink( NULL, pLink );
2475 : : }
2476 : 0 : break;
2477 : : default:
2478 : : {
2479 : : // added to avoid warnings
2480 : : }
2481 : : }
2482 : : }
2483 : :
2484 : :
2485 : 0 : void ScChangeTrack::AppendLoaded( ScChangeAction* pAppend )
2486 : : {
2487 [ # # ]: 0 : aMap.insert( ::std::make_pair( pAppend->GetActionNumber(), pAppend ) );
2488 [ # # ]: 0 : if ( !pLast )
2489 : 0 : pFirst = pLast = pAppend;
2490 : : else
2491 : : {
2492 : 0 : pLast->pNext = pAppend;
2493 : 0 : pAppend->pPrev = pLast;
2494 : 0 : pLast = pAppend;
2495 : : }
2496 : 0 : MasterLinks( pAppend );
2497 : 0 : }
2498 : :
2499 : :
2500 : 0 : void ScChangeTrack::Append( ScChangeAction* pAppend, sal_uLong nAction )
2501 : : {
2502 [ # # ]: 0 : if ( nActionMax < nAction )
2503 : 0 : nActionMax = nAction;
2504 : 0 : pAppend->SetUser( maUser );
2505 [ # # ]: 0 : if ( bUseFixDateTime )
2506 : 0 : pAppend->SetDateTimeUTC( aFixDateTime );
2507 : 0 : pAppend->SetActionNumber( nAction );
2508 [ # # ]: 0 : aMap.insert( ::std::make_pair( nAction, pAppend ) );
2509 : : // UpdateReference Inserts vor Dependencies.
2510 : : // Delete rejectendes Insert hatte UpdateReference mit Delete-Undo.
2511 : : // UpdateReference auch wenn pLast==NULL, weil pAppend ein Delete sein
2512 : : // kann, dass DelContents generiert haben kann
2513 [ # # ][ # # ]: 0 : if ( pAppend->IsInsertType() && !pAppend->IsRejecting() )
[ # # ]
2514 : 0 : UpdateReference( pAppend, false );
2515 [ # # ]: 0 : if ( !pLast )
2516 : 0 : pFirst = pLast = pAppend;
2517 : : else
2518 : : {
2519 : 0 : pLast->pNext = pAppend;
2520 : 0 : pAppend->pPrev = pLast;
2521 : 0 : pLast = pAppend;
2522 : 0 : Dependencies( pAppend );
2523 : : }
2524 : : // UpdateReference Inserts nicht nach Dependencies.
2525 : : // Move rejectendes Move hatte UpdateReference mit Move-Undo, Inhalt in
2526 : : // ToRange nicht deleten.
2527 [ # # # # ]: 0 : if ( !pAppend->IsInsertType() &&
[ # # ]
2528 [ # # ]: 0 : !(pAppend->GetType() == SC_CAT_MOVE && pAppend->IsRejecting()) )
2529 : 0 : UpdateReference( pAppend, false );
2530 : 0 : MasterLinks( pAppend );
2531 : :
2532 [ # # ]: 0 : if ( aModifiedLink.IsSet() )
2533 : : {
2534 : 0 : NotifyModified( SC_CTM_APPEND, nAction, nAction );
2535 [ # # ]: 0 : if ( pAppend->GetType() == SC_CAT_CONTENT )
2536 : : {
2537 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) pAppend;
2538 [ # # ]: 0 : if ( ( pContent = pContent->GetPrevContent() ) != NULL )
2539 : : {
2540 : 0 : sal_uLong nMod = pContent->GetActionNumber();
2541 : 0 : NotifyModified( SC_CTM_CHANGE, nMod, nMod );
2542 : : }
2543 : : }
2544 : : else
2545 : : NotifyModified( SC_CTM_CHANGE, pFirst->GetActionNumber(),
2546 : 0 : pLast->GetActionNumber() );
2547 : : }
2548 : 0 : }
2549 : :
2550 : :
2551 : 0 : void ScChangeTrack::Append( ScChangeAction* pAppend )
2552 : : {
2553 : 0 : Append( pAppend, ++nActionMax );
2554 : 0 : }
2555 : :
2556 : :
2557 : 0 : void ScChangeTrack::AppendDeleteRange( const ScRange& rRange,
2558 : : ScDocument* pRefDoc, sal_uLong& nStartAction, sal_uLong& nEndAction, SCsTAB nDz )
2559 : : {
2560 : 0 : nStartAction = GetActionMax() + 1;
2561 : 0 : AppendDeleteRange( rRange, pRefDoc, nDz, 0 );
2562 : 0 : nEndAction = GetActionMax();
2563 : 0 : }
2564 : :
2565 : :
2566 : 0 : void ScChangeTrack::AppendDeleteRange( const ScRange& rRange,
2567 : : ScDocument* pRefDoc, SCsTAB nDz, sal_uLong nRejectingInsert )
2568 : : {
2569 : 0 : SetInDeleteRange( rRange );
2570 [ # # ]: 0 : StartBlockModify( SC_CTM_APPEND, GetActionMax() + 1 );
2571 : : SCCOL nCol1;
2572 : : SCROW nRow1;
2573 : : SCTAB nTab1;
2574 : : SCCOL nCol2;
2575 : : SCROW nRow2;
2576 : : SCTAB nTab2;
2577 : 0 : rRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
2578 [ # # ]: 0 : for ( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
2579 : : {
2580 [ # # ][ # # ]: 0 : if ( !pRefDoc || nTab < pRefDoc->GetTableCount() )
[ # # ][ # # ]
2581 : : {
2582 [ # # ][ # # ]: 0 : if ( nCol1 == 0 && nCol2 == MAXCOL )
2583 : : { // ganze Zeilen und/oder Tabellen
2584 [ # # ][ # # ]: 0 : if ( nRow1 == 0 && nRow2 == MAXROW )
2585 : : { // ganze Tabellen
2586 : : //2do: geht nicht auch komplette Tabelle als ganzes?
2587 : 0 : ScRange aRange( 0, 0, nTab, 0, MAXROW, nTab );
2588 [ # # ]: 0 : for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
2589 : : { // spaltenweise ist weniger als zeilenweise
2590 : 0 : aRange.aStart.SetCol( nCol );
2591 : 0 : aRange.aEnd.SetCol( nCol );
2592 [ # # ]: 0 : if ( nCol == nCol2 )
2593 : 0 : SetInDeleteTop( true );
2594 : : AppendOneDeleteRange( aRange, pRefDoc, nCol-nCol1, 0,
2595 [ # # ]: 0 : nTab-nTab1 + nDz, nRejectingInsert );
2596 : : }
2597 : : //! immer noch InDeleteTop
2598 : : AppendOneDeleteRange( rRange, pRefDoc, 0, 0,
2599 [ # # ]: 0 : nTab-nTab1 + nDz, nRejectingInsert );
2600 : : }
2601 : : else
2602 : : { // ganze Zeilen
2603 : 0 : ScRange aRange( 0, 0, nTab, MAXCOL, 0, nTab );
2604 [ # # ]: 0 : for ( SCROW nRow = nRow1; nRow <= nRow2; nRow++ )
2605 : : {
2606 : 0 : aRange.aStart.SetRow( nRow );
2607 : 0 : aRange.aEnd.SetRow( nRow );
2608 [ # # ]: 0 : if ( nRow == nRow2 )
2609 : 0 : SetInDeleteTop( true );
2610 : : AppendOneDeleteRange( aRange, pRefDoc, 0, nRow-nRow1,
2611 [ # # ]: 0 : 0, nRejectingInsert );
2612 : : }
2613 : 0 : }
2614 : : }
2615 [ # # ][ # # ]: 0 : else if ( nRow1 == 0 && nRow2 == MAXROW )
2616 : : { // ganze Spalten
2617 : 0 : ScRange aRange( 0, 0, nTab, 0, MAXROW, nTab );
2618 [ # # ]: 0 : for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
2619 : : {
2620 : 0 : aRange.aStart.SetCol( nCol );
2621 : 0 : aRange.aEnd.SetCol( nCol );
2622 [ # # ]: 0 : if ( nCol == nCol2 )
2623 : 0 : SetInDeleteTop( true );
2624 : : AppendOneDeleteRange( aRange, pRefDoc, nCol-nCol1, 0,
2625 [ # # ]: 0 : 0, nRejectingInsert );
2626 : : }
2627 : : }
2628 : : else
2629 : : {
2630 : : OSL_FAIL( "ScChangeTrack::AppendDeleteRange: Block not supported!" );
2631 : : }
2632 : 0 : SetInDeleteTop( false );
2633 : : }
2634 : : }
2635 [ # # ]: 0 : EndBlockModify( GetActionMax() );
2636 : 0 : }
2637 : :
2638 : :
2639 : 0 : void ScChangeTrack::AppendOneDeleteRange( const ScRange& rOrgRange,
2640 : : ScDocument* pRefDoc, SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
2641 : : sal_uLong nRejectingInsert )
2642 : : {
2643 : 0 : ScRange aTrackRange( rOrgRange );
2644 [ # # ]: 0 : if ( nDx )
2645 : : {
2646 [ # # ]: 0 : aTrackRange.aStart.IncCol( -nDx );
2647 [ # # ]: 0 : aTrackRange.aEnd.IncCol( -nDx );
2648 : : }
2649 [ # # ]: 0 : if ( nDy )
2650 : : {
2651 [ # # ]: 0 : aTrackRange.aStart.IncRow( -nDy );
2652 [ # # ]: 0 : aTrackRange.aEnd.IncRow( -nDy );
2653 : : }
2654 [ # # ]: 0 : if ( nDz )
2655 : : {
2656 [ # # ]: 0 : aTrackRange.aStart.IncTab( -nDz );
2657 [ # # ]: 0 : aTrackRange.aEnd.IncTab( -nDz );
2658 : : }
2659 : : ScChangeActionDel* pAct = new ScChangeActionDel( aTrackRange, nDx, nDy,
2660 [ # # ][ # # ]: 0 : this );
2661 : : // TabDelete keine Contents, sind in einzelnen Spalten
2662 [ # # ]: 0 : if ( !(rOrgRange.aStart.Col() == 0 && rOrgRange.aStart.Row() == 0 &&
2663 [ # # ][ # # ]: 0 : rOrgRange.aEnd.Col() == MAXCOL && rOrgRange.aEnd.Row() == MAXROW) )
[ # # # # ]
2664 [ # # ]: 0 : LookUpContents( rOrgRange, pRefDoc, -nDx, -nDy, -nDz );
2665 [ # # ]: 0 : if ( nRejectingInsert )
2666 : : {
2667 : 0 : pAct->SetRejectAction( nRejectingInsert );
2668 : 0 : pAct->SetState( SC_CAS_ACCEPTED );
2669 : : }
2670 [ # # ]: 0 : Append( pAct );
2671 : 0 : }
2672 : :
2673 : :
2674 : 0 : void ScChangeTrack::LookUpContents( const ScRange& rOrgRange,
2675 : : ScDocument* pRefDoc, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
2676 : : {
2677 [ # # ]: 0 : if ( pRefDoc )
2678 : : {
2679 : 0 : ScAddress aPos;
2680 : 0 : ScBigAddress aBigPos;
2681 [ # # ]: 0 : ScCellIterator aIter( pRefDoc, rOrgRange );
2682 [ # # ]: 0 : ScBaseCell* pCell = aIter.GetFirst();
2683 [ # # ]: 0 : while ( pCell )
2684 : : {
2685 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pCell ) )
2686 : : {
2687 : 0 : aBigPos.Set( aIter.GetCol() + nDx, aIter.GetRow() + nDy,
2688 : 0 : aIter.GetTab() + nDz );
2689 [ # # ]: 0 : ScChangeActionContent* pContent = SearchContentAt( aBigPos, NULL );
2690 [ # # ]: 0 : if ( !pContent )
2691 : : { // nicht getrackte Contents
2692 : 0 : aPos.Set( aIter.GetCol() + nDx, aIter.GetRow() + nDy,
2693 : 0 : aIter.GetTab() + nDz );
2694 [ # # ]: 0 : GenerateDelContent( aPos, pCell, pRefDoc );
2695 : : //! der Content wird hier _nicht_ per AddContent hinzugefuegt,
2696 : : //! sondern in UpdateReference, um z.B. auch kreuzende Deletes
2697 : : //! korrekt zu erfassen
2698 : : }
2699 : : }
2700 [ # # ]: 0 : pCell = aIter.GetNext();
2701 : : }
2702 : : }
2703 : 0 : }
2704 : :
2705 : :
2706 : 0 : void ScChangeTrack::AppendMove( const ScRange& rFromRange,
2707 : : const ScRange& rToRange, ScDocument* pRefDoc )
2708 : : {
2709 [ # # ]: 0 : ScChangeActionMove* pAct = new ScChangeActionMove( rFromRange, rToRange, this );
2710 : 0 : LookUpContents( rToRange, pRefDoc, 0, 0, 0 ); // ueberschriebene Contents
2711 : 0 : Append( pAct );
2712 : 0 : }
2713 : :
2714 : :
2715 : 0 : bool ScChangeTrack::IsMatrixFormulaRangeDifferent(
2716 : : const ScBaseCell* pOldCell, const ScBaseCell* pNewCell )
2717 : : {
2718 : : SCCOL nC1, nC2;
2719 : : SCROW nR1, nR2;
2720 : 0 : nC1 = nC2 = 0;
2721 : 0 : nR1 = nR2 = 0;
2722 [ # # ]: 0 : if ( pOldCell && (pOldCell->GetCellType() == CELLTYPE_FORMULA) &&
[ # # # # ]
[ # # ]
2723 [ # # ]: 0 : ((const ScFormulaCell*)pOldCell)->GetMatrixFlag() == MM_FORMULA )
2724 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pOldCell)->GetMatColsRows( nC1, nR1 );
2725 [ # # ]: 0 : if ( pNewCell && (pNewCell->GetCellType() == CELLTYPE_FORMULA) &&
[ # # # # ]
[ # # ]
2726 [ # # ]: 0 : ((const ScFormulaCell*)pNewCell)->GetMatrixFlag() == MM_FORMULA )
2727 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pNewCell)->GetMatColsRows( nC1, nR1 );
2728 [ # # ][ # # ]: 0 : return nC1 != nC2 || nR1 != nR2;
2729 : : }
2730 : :
2731 : 0 : void ScChangeTrack::AppendContent( const ScAddress& rPos,
2732 : : const ScBaseCell* pOldCell, sal_uLong nOldFormat, ScDocument* pRefDoc )
2733 : : {
2734 [ # # ]: 0 : if ( !pRefDoc )
2735 : 0 : pRefDoc = pDoc;
2736 : 0 : rtl::OUString aOldValue;
2737 [ # # ]: 0 : ScChangeActionContent::GetStringOfCell( aOldValue, pOldCell, pRefDoc, nOldFormat );
2738 : 0 : rtl::OUString aNewValue;
2739 [ # # ]: 0 : ScBaseCell* pNewCell = pDoc->GetCell( rPos );
2740 [ # # ]: 0 : ScChangeActionContent::GetStringOfCell( aNewValue, pNewCell, pDoc, rPos );
2741 [ # # ][ # # ]: 0 : if (!aOldValue.equals(aNewValue) || IsMatrixFormulaRangeDifferent(pOldCell, pNewCell))
[ # # ][ # # ]
2742 : : { // nur wirkliche Aenderung tracken
2743 : 0 : ScRange aRange( rPos );
2744 [ # # ][ # # ]: 0 : ScChangeActionContent* pAct = new ScChangeActionContent( aRange );
2745 [ # # ]: 0 : pAct->SetOldValue( pOldCell, pRefDoc, pDoc, nOldFormat );
2746 [ # # ]: 0 : pAct->SetNewValue( pNewCell, pDoc );
2747 [ # # ]: 0 : Append( pAct );
2748 : 0 : }
2749 : 0 : }
2750 : :
2751 : :
2752 : 0 : void ScChangeTrack::AppendContent( const ScAddress& rPos,
2753 : : ScDocument* pRefDoc )
2754 : : {
2755 : 0 : rtl::OUString aOldValue;
2756 [ # # ]: 0 : ScBaseCell* pOldCell = pRefDoc->GetCell( rPos );
2757 [ # # ]: 0 : ScChangeActionContent::GetStringOfCell( aOldValue, pOldCell, pRefDoc, rPos );
2758 : 0 : rtl::OUString aNewValue;
2759 [ # # ]: 0 : ScBaseCell* pNewCell = pDoc->GetCell( rPos );
2760 [ # # ]: 0 : ScChangeActionContent::GetStringOfCell( aNewValue, pNewCell, pDoc, rPos );
2761 [ # # ][ # # ]: 0 : if (!aOldValue.equals(aNewValue) || IsMatrixFormulaRangeDifferent(pOldCell, pNewCell))
[ # # ][ # # ]
2762 : : { // nur wirkliche Aenderung tracken
2763 : 0 : ScRange aRange( rPos );
2764 [ # # ][ # # ]: 0 : ScChangeActionContent* pAct = new ScChangeActionContent( aRange );
2765 [ # # ]: 0 : pAct->SetOldValue( pOldCell, pRefDoc, pDoc );
2766 [ # # ]: 0 : pAct->SetNewValue( pNewCell, pDoc );
2767 [ # # ]: 0 : Append( pAct );
2768 : 0 : }
2769 : 0 : }
2770 : :
2771 : :
2772 : 0 : void ScChangeTrack::AppendContent( const ScAddress& rPos,
2773 : : const ScBaseCell* pOldCell )
2774 : : {
2775 [ # # ]: 0 : if ( ScChangeActionContent::NeedsNumberFormat( pOldCell ) )
2776 : 0 : AppendContent( rPos, pOldCell, pDoc->GetNumberFormat( rPos ), pDoc );
2777 : : else
2778 : 0 : AppendContent( rPos, pOldCell, 0, pDoc );
2779 : 0 : }
2780 : :
2781 : :
2782 : 0 : void ScChangeTrack::SetLastCutMoveRange( const ScRange& rRange,
2783 : : ScDocument* pRefDoc )
2784 : : {
2785 [ # # ]: 0 : if ( pLastCutMove )
2786 : : {
2787 : : // ToRange nicht mit Deletes linken und nicht in der Groesse aendern,
2788 : : // eigentlich unnoetig, da ein Delete vorher in
2789 : : // ScViewFunc::PasteFromClip ein ResetLastCut ausloest
2790 : 0 : ScBigRange& r = pLastCutMove->GetBigRange();
2791 : 0 : r.aEnd.SetCol( -1 );
2792 : 0 : r.aEnd.SetRow( -1 );
2793 : 0 : r.aEnd.SetTab( -1 );
2794 : 0 : r.aStart.SetCol( -1 - (rRange.aEnd.Col() - rRange.aStart.Col()) );
2795 : 0 : r.aStart.SetRow( -1 - (rRange.aEnd.Row() - rRange.aStart.Row()) );
2796 : 0 : r.aStart.SetTab( -1 - (rRange.aEnd.Tab() - rRange.aStart.Tab()) );
2797 : : // zu ueberschreibende Contents im FromRange
2798 : 0 : LookUpContents( rRange, pRefDoc, 0, 0, 0 );
2799 : : }
2800 : 0 : }
2801 : :
2802 : :
2803 : 0 : void ScChangeTrack::AppendContentRange( const ScRange& rRange,
2804 : : ScDocument* pRefDoc, sal_uLong& nStartAction, sal_uLong& nEndAction,
2805 : : ScChangeActionClipMode eClipMode )
2806 : : {
2807 [ # # ]: 0 : if ( eClipMode == SC_CACM_CUT )
2808 : : {
2809 [ # # ]: 0 : ResetLastCut();
2810 [ # # ][ # # ]: 0 : pLastCutMove = new ScChangeActionMove( rRange, rRange, this );
2811 [ # # ]: 0 : SetLastCutMoveRange( rRange, pRefDoc );
2812 : : }
2813 : : SCCOL nCol1;
2814 : : SCROW nRow1;
2815 : : SCTAB nTab1;
2816 : : SCCOL nCol2;
2817 : : SCROW nRow2;
2818 : : SCTAB nTab2;
2819 : 0 : rRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
2820 : : bool bDoContents;
2821 [ # # ][ # # ]: 0 : if ( eClipMode == SC_CACM_PASTE && HasLastCut() )
[ # # ]
2822 : : {
2823 : 0 : bDoContents = false;
2824 : 0 : SetInPasteCut( true );
2825 : : // Paste und Cut abstimmen, Paste kann groesserer Range sein
2826 : 0 : ScRange aRange( rRange );
2827 : 0 : ScBigRange& r = pLastCutMove->GetBigRange();
2828 : : SCCOL nTmpCol;
2829 [ # # ]: 0 : if ( (nTmpCol = (SCCOL) (r.aEnd.Col() - r.aStart.Col())) != (nCol2 - nCol1) )
2830 : : {
2831 : 0 : aRange.aEnd.SetCol( aRange.aStart.Col() + nTmpCol );
2832 : 0 : nCol1 += nTmpCol + 1;
2833 : 0 : bDoContents = true;
2834 : : }
2835 : : SCROW nTmpRow;
2836 [ # # ]: 0 : if ( (nTmpRow = (SCROW) (r.aEnd.Row() - r.aStart.Row())) != (nRow2 - nRow1) )
2837 : : {
2838 : 0 : aRange.aEnd.SetRow( aRange.aStart.Row() + nTmpRow );
2839 : 0 : nRow1 += nTmpRow + 1;
2840 : 0 : bDoContents = true;
2841 : : }
2842 : : SCTAB nTmpTab;
2843 [ # # ]: 0 : if ( (nTmpTab = (SCTAB) (r.aEnd.Tab() - r.aStart.Tab())) != (nTab2 - nTab1) )
2844 : : {
2845 : 0 : aRange.aEnd.SetTab( aRange.aStart.Tab() + nTmpTab );
2846 : 0 : nTab1 += nTmpTab + 1;
2847 : 0 : bDoContents = true;
2848 : : }
2849 : 0 : r = aRange;
2850 [ # # ]: 0 : Undo( nStartLastCut, nEndLastCut ); // hier werden sich die Cuts gemerkt
2851 : : //! StartAction erst nach Undo
2852 : 0 : nStartAction = GetActionMax() + 1;
2853 [ # # ]: 0 : StartBlockModify( SC_CTM_APPEND, nStartAction );
2854 : : // zu ueberschreibende Contents im ToRange
2855 [ # # ]: 0 : LookUpContents( aRange, pRefDoc, 0, 0, 0 );
2856 : 0 : pLastCutMove->SetStartLastCut( nStartLastCut );
2857 : 0 : pLastCutMove->SetEndLastCut( nEndLastCut );
2858 [ # # ]: 0 : Append( pLastCutMove );
2859 : 0 : pLastCutMove = NULL;
2860 [ # # ]: 0 : ResetLastCut();
2861 : 0 : SetInPasteCut( false );
2862 : : }
2863 : : else
2864 : : {
2865 : 0 : bDoContents = true;
2866 : 0 : nStartAction = GetActionMax() + 1;
2867 [ # # ]: 0 : StartBlockModify( SC_CTM_APPEND, nStartAction );
2868 : : }
2869 [ # # ]: 0 : if ( bDoContents )
2870 : : {
2871 : 0 : ScAddress aPos;
2872 [ # # ]: 0 : for ( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
2873 : : {
2874 : 0 : aPos.SetTab( nTab );
2875 [ # # ]: 0 : for ( SCCOL nCol = nCol1; nCol <= nCol2; nCol++ )
2876 : : {
2877 : 0 : aPos.SetCol( nCol );
2878 [ # # ]: 0 : for ( SCROW nRow = nRow1; nRow <= nRow2; nRow++ )
2879 : : {
2880 : 0 : aPos.SetRow( nRow );
2881 [ # # ]: 0 : AppendContent( aPos, pRefDoc );
2882 : : }
2883 : : }
2884 : : }
2885 : : }
2886 : 0 : nEndAction = GetActionMax();
2887 [ # # ]: 0 : EndBlockModify( nEndAction );
2888 [ # # ]: 0 : if ( eClipMode == SC_CACM_CUT )
2889 : : {
2890 : 0 : nStartLastCut = nStartAction;
2891 : 0 : nEndLastCut = nEndAction;
2892 : : }
2893 : 0 : }
2894 : :
2895 : :
2896 : 0 : void ScChangeTrack::AppendContentsIfInRefDoc( ScDocument* pRefDoc,
2897 : : sal_uLong& nStartAction, sal_uLong& nEndAction )
2898 : : {
2899 [ # # ]: 0 : ScDocumentIterator aIter( pRefDoc, 0, MAXTAB );
2900 [ # # ][ # # ]: 0 : if ( aIter.GetFirst() )
2901 : : {
2902 : 0 : nStartAction = GetActionMax() + 1;
2903 [ # # ]: 0 : StartBlockModify( SC_CTM_APPEND, nStartAction );
2904 [ # # ]: 0 : SvNumberFormatter* pFormatter = pRefDoc->GetFormatTable();
2905 [ # # ][ # # ]: 0 : do
2906 : : {
2907 : : SCCOL nCol;
2908 : : SCROW nRow;
2909 : : SCTAB nTab;
2910 [ # # ]: 0 : aIter.GetPos( nCol, nRow, nTab );
2911 : 0 : ScAddress aPos( nCol, nRow, nTab );
2912 [ # # ]: 0 : AppendContent( aPos, aIter.GetCell(),
2913 [ # # ][ # # ]: 0 : aIter.GetPattern()->GetNumberFormat( pFormatter ), pRefDoc );
[ # # ]
2914 : : } while ( aIter.GetNext() );
2915 : 0 : nEndAction = GetActionMax();
2916 [ # # ]: 0 : EndBlockModify( nEndAction );
2917 : : }
2918 : : else
2919 [ # # ]: 0 : nStartAction = nEndAction = 0;
2920 : 0 : }
2921 : :
2922 : :
2923 : 0 : ScChangeActionContent* ScChangeTrack::AppendContentOnTheFly(
2924 : : const ScAddress& rPos, ScBaseCell* pOldCell, ScBaseCell* pNewCell,
2925 : : sal_uLong nOldFormat, sal_uLong nNewFormat )
2926 : : {
2927 : 0 : ScRange aRange( rPos );
2928 [ # # ][ # # ]: 0 : ScChangeActionContent* pAct = new ScChangeActionContent( aRange );
2929 [ # # ]: 0 : pAct->SetOldNewCells( pOldCell, nOldFormat, pNewCell, nNewFormat, pDoc );
2930 [ # # ]: 0 : Append( pAct );
2931 : 0 : return pAct;
2932 : : }
2933 : :
2934 : :
2935 : 0 : void ScChangeTrack::AppendInsert( const ScRange& rRange )
2936 : : {
2937 [ # # ]: 0 : ScChangeActionIns* pAct = new ScChangeActionIns( rRange );
2938 : 0 : Append( pAct );
2939 : 0 : }
2940 : :
2941 : :
2942 : 0 : void ScChangeTrack::DeleteCellEntries( ScChangeActionCellListEntry*& pCellList,
2943 : : ScChangeAction* pDeletor )
2944 : : {
2945 : 0 : ScChangeActionCellListEntry* pE = pCellList;
2946 [ # # ]: 0 : while ( pE )
2947 : : {
2948 : 0 : ScChangeActionCellListEntry* pNext = pE->pNext;
2949 : 0 : pE->pContent->RemoveDeletedIn( pDeletor );
2950 [ # # ]: 0 : if ( IsGenerated( pE->pContent->GetActionNumber() ) &&
[ # # # # ]
2951 : 0 : !pE->pContent->IsDeletedIn() )
2952 : 0 : DeleteGeneratedDelContent( pE->pContent );
2953 : 0 : delete pE;
2954 : 0 : pE = pNext;
2955 : : }
2956 : 0 : pCellList = NULL;
2957 : 0 : }
2958 : :
2959 : :
2960 : 0 : ScChangeActionContent* ScChangeTrack::GenerateDelContent(
2961 : : const ScAddress& rPos, const ScBaseCell* pCell,
2962 : : const ScDocument* pFromDoc )
2963 : : {
2964 : : ScChangeActionContent* pContent = new ScChangeActionContent(
2965 [ # # ][ # # ]: 0 : ScRange( rPos ) );
2966 : 0 : pContent->SetActionNumber( --nGeneratedMin );
2967 : : // nur NewValue
2968 : : ScChangeActionContent::SetValue( pContent->aNewValue, pContent->pNewCell,
2969 [ # # ]: 0 : rPos, pCell, pFromDoc, pDoc );
2970 : : // pNextContent und pPrevContent werden nicht gesetzt
2971 [ # # ]: 0 : if ( pFirstGeneratedDelContent )
2972 : : { // vorne reinhaengen
2973 : 0 : pFirstGeneratedDelContent->pPrev = pContent;
2974 : 0 : pContent->pNext = pFirstGeneratedDelContent;
2975 : : }
2976 : 0 : pFirstGeneratedDelContent = pContent;
2977 [ # # ]: 0 : aGeneratedMap.insert( std::make_pair( nGeneratedMin, pContent ) );
2978 [ # # ]: 0 : NotifyModified( SC_CTM_APPEND, nGeneratedMin, nGeneratedMin );
2979 : 0 : return pContent;
2980 : : }
2981 : :
2982 : :
2983 : 0 : void ScChangeTrack::DeleteGeneratedDelContent( ScChangeActionContent* pContent )
2984 : : {
2985 : 0 : sal_uLong nAct = pContent->GetActionNumber();
2986 [ # # ]: 0 : aGeneratedMap.erase( nAct );
2987 [ # # ]: 0 : if ( pFirstGeneratedDelContent == pContent )
2988 : 0 : pFirstGeneratedDelContent = (ScChangeActionContent*) pContent->pNext;
2989 [ # # ]: 0 : if ( pContent->pNext )
2990 : 0 : pContent->pNext->pPrev = pContent->pPrev;
2991 [ # # ]: 0 : if ( pContent->pPrev )
2992 : 0 : pContent->pPrev->pNext = pContent->pNext;
2993 [ # # ][ # # ]: 0 : delete pContent;
2994 [ # # ]: 0 : NotifyModified( SC_CTM_REMOVE, nAct, nAct );
2995 [ # # ]: 0 : if ( nAct == nGeneratedMin )
2996 : 0 : ++nGeneratedMin; //! erst nach NotifyModified wg. IsGenerated
2997 : 0 : }
2998 : :
2999 : :
3000 : 0 : ScChangeActionContent* ScChangeTrack::SearchContentAt(
3001 : : const ScBigAddress& rPos, ScChangeAction* pButNotThis ) const
3002 : : {
3003 : 0 : SCSIZE nSlot = ComputeContentSlot( rPos.Row() );
3004 [ # # ]: 0 : for ( ScChangeActionContent* p = ppContentSlots[nSlot]; p;
3005 : : p = p->GetNextInSlot() )
3006 : : {
3007 [ # # ]: 0 : if ( p != pButNotThis && !p->IsDeletedIn() &&
[ # # # # ]
[ # # ]
3008 : 0 : p->GetBigRange().aStart == rPos )
3009 : : {
3010 : 0 : ScChangeActionContent* pContent = p->GetTopContent();
3011 [ # # ]: 0 : if ( !pContent->IsDeletedIn() )
3012 : 0 : return pContent;
3013 : : }
3014 : : }
3015 : 0 : return NULL;
3016 : : }
3017 : :
3018 : :
3019 : 0 : void ScChangeTrack::AddDependentWithNotify( ScChangeAction* pParent,
3020 : : ScChangeAction* pDependent )
3021 : : {
3022 : 0 : ScChangeActionLinkEntry* pLink = pParent->AddDependent( pDependent );
3023 : 0 : pDependent->AddLink( pParent, pLink );
3024 [ # # ]: 0 : if ( aModifiedLink.IsSet() )
3025 : : {
3026 : 0 : sal_uLong nMod = pParent->GetActionNumber();
3027 : 0 : NotifyModified( SC_CTM_PARENT, nMod, nMod );
3028 : : }
3029 : 0 : }
3030 : :
3031 : :
3032 : 0 : void ScChangeTrack::Dependencies( ScChangeAction* pAct )
3033 : : {
3034 : : // Finde die letzte Abhaengigkeit fuer jeweils Col/Row/Tab.
3035 : : // Content an gleicher Position verketten.
3036 : : // Move Abhaengigkeiten.
3037 : 0 : ScChangeActionType eActType = pAct->GetType();
3038 [ # # # # ]: 0 : if ( eActType == SC_CAT_REJECT ||
[ # # ][ # # ]
3039 : 0 : (eActType == SC_CAT_MOVE && pAct->IsRejecting()) )
3040 : 0 : return ; // diese Rejects sind nicht abhaengig
3041 : :
3042 [ # # ]: 0 : if ( eActType == SC_CAT_CONTENT )
3043 : : {
3044 [ # # ]: 0 : if ( !(((ScChangeActionContent*)pAct)->GetNextContent() ||
3045 [ # # ][ # # ]: 0 : ((ScChangeActionContent*)pAct)->GetPrevContent()) )
3046 : : { // Contents an gleicher Position verketten
3047 : : ScChangeActionContent* pContent = SearchContentAt(
3048 : 0 : pAct->GetBigRange().aStart, pAct );
3049 [ # # ]: 0 : if ( pContent )
3050 : : {
3051 : 0 : pContent->SetNextContent( (ScChangeActionContent*) pAct );
3052 : 0 : ((ScChangeActionContent*)pAct)->SetPrevContent( pContent );
3053 : : }
3054 : : }
3055 : 0 : const ScBaseCell* pCell = ((ScChangeActionContent*)pAct)->GetNewCell();
3056 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pCell ) == SC_CACCT_MATREF )
3057 : : {
3058 : 0 : ScAddress aOrg;
3059 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetMatrixOrigin( aOrg );
3060 [ # # ]: 0 : ScChangeActionContent* pContent = SearchContentAt( aOrg, pAct );
3061 [ # # ][ # # ]: 0 : if ( pContent && pContent->IsMatrixOrigin() )
[ # # ]
3062 : : {
3063 [ # # ]: 0 : AddDependentWithNotify( pContent, pAct );
3064 : : }
3065 : : else
3066 : : {
3067 : : OSL_FAIL( "ScChangeTrack::Dependencies: MatOrg not found" );
3068 : : }
3069 : : }
3070 : : }
3071 : :
3072 [ # # ][ # # ]: 0 : if ( !(pLinkInsertCol || pLinkInsertRow || pLinkInsertTab || pLinkMove) )
[ # # ][ # # ]
3073 : 0 : return ; // keine Dependencies
3074 [ # # ]: 0 : if ( pAct->IsRejecting() )
3075 : 0 : return ; // ausser Content keine Dependencies
3076 : :
3077 : : // Insert in einem entsprechenden Insert haengt davon ab, sonst muesste
3078 : : // der vorherige Insert gesplittet werden.
3079 : : // Sich kreuzende Inserts und Deletes sind nicht abhaengig.
3080 : : // Alles andere ist abhaengig.
3081 : :
3082 : : // Der zuletzt eingelinkte Insert steht am Anfang einer Kette,
3083 : : // also genau richtig
3084 : :
3085 : 0 : const ScBigRange& rRange = pAct->GetBigRange();
3086 : 0 : bool bActNoInsert = !pAct->IsInsertType();
3087 : 0 : bool bActColDel = ( eActType == SC_CAT_DELETE_COLS );
3088 : 0 : bool bActRowDel = ( eActType == SC_CAT_DELETE_ROWS );
3089 : 0 : bool bActTabDel = ( eActType == SC_CAT_DELETE_TABS );
3090 : :
3091 [ # # ][ # # ]: 0 : if ( pLinkInsertCol && (eActType == SC_CAT_INSERT_COLS ||
[ # # ][ # # ]
[ # # ]
3092 : 0 : (bActNoInsert && !bActRowDel && !bActTabDel)) )
3093 : : {
3094 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkInsertCol; pL; pL = pL->GetNext() )
3095 : : {
3096 : 0 : ScChangeActionIns* pTest = (ScChangeActionIns*) pL->GetAction();
3097 [ # # ]: 0 : if ( !pTest->IsRejected() &&
[ # # # # ]
3098 : 0 : pTest->GetBigRange().Intersects( rRange ) )
3099 : : {
3100 : 0 : AddDependentWithNotify( pTest, pAct );
3101 : 0 : break; // for
3102 : : }
3103 : : }
3104 : : }
3105 [ # # ][ # # ]: 0 : if ( pLinkInsertRow && (eActType == SC_CAT_INSERT_ROWS ||
[ # # ][ # # ]
[ # # ]
3106 : 0 : (bActNoInsert && !bActColDel && !bActTabDel)) )
3107 : : {
3108 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkInsertRow; pL; pL = pL->GetNext() )
3109 : : {
3110 : 0 : ScChangeActionIns* pTest = (ScChangeActionIns*) pL->GetAction();
3111 [ # # ]: 0 : if ( !pTest->IsRejected() &&
[ # # # # ]
3112 : 0 : pTest->GetBigRange().Intersects( rRange ) )
3113 : : {
3114 : 0 : AddDependentWithNotify( pTest, pAct );
3115 : 0 : break; // for
3116 : : }
3117 : : }
3118 : : }
3119 [ # # ][ # # ]: 0 : if ( pLinkInsertTab && (eActType == SC_CAT_INSERT_TABS ||
[ # # ][ # # ]
[ # # ]
3120 : 0 : (bActNoInsert && !bActColDel && !bActRowDel)) )
3121 : : {
3122 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkInsertTab; pL; pL = pL->GetNext() )
3123 : : {
3124 : 0 : ScChangeActionIns* pTest = (ScChangeActionIns*) pL->GetAction();
3125 [ # # ]: 0 : if ( !pTest->IsRejected() &&
[ # # # # ]
3126 : 0 : pTest->GetBigRange().Intersects( rRange ) )
3127 : : {
3128 : 0 : AddDependentWithNotify( pTest, pAct );
3129 : 0 : break; // for
3130 : : }
3131 : : }
3132 : : }
3133 : :
3134 [ # # ]: 0 : if ( pLinkMove )
3135 : : {
3136 [ # # ]: 0 : if ( eActType == SC_CAT_CONTENT )
3137 : : { // Content ist von FromRange abhaengig
3138 : 0 : const ScBigAddress& rPos = rRange.aStart;
3139 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkMove; pL; pL = pL->GetNext() )
3140 : : {
3141 : 0 : ScChangeActionMove* pTest = (ScChangeActionMove*) pL->GetAction();
3142 [ # # ]: 0 : if ( !pTest->IsRejected() &&
[ # # # # ]
3143 : 0 : pTest->GetFromRange().In( rPos ) )
3144 : : {
3145 : 0 : AddDependentWithNotify( pTest, pAct );
3146 : : }
3147 : : }
3148 : : }
3149 [ # # ]: 0 : else if ( eActType == SC_CAT_MOVE )
3150 : : { // Move FromRange ist von ToRange abhaengig
3151 : 0 : const ScBigRange& rFromRange = ((ScChangeActionMove*)pAct)->GetFromRange();
3152 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkMove; pL; pL = pL->GetNext() )
3153 : : {
3154 : 0 : ScChangeActionMove* pTest = (ScChangeActionMove*) pL->GetAction();
3155 [ # # ]: 0 : if ( !pTest->IsRejected() &&
[ # # # # ]
3156 : 0 : pTest->GetBigRange().Intersects( rFromRange ) )
3157 : : {
3158 : 0 : AddDependentWithNotify( pTest, pAct );
3159 : : }
3160 : : }
3161 : : }
3162 : : else
3163 : : { // Inserts und Deletes sind abhaengig, sobald sie FromRange oder
3164 : : // ToRange kreuzen
3165 [ # # ]: 0 : for ( ScChangeActionLinkEntry* pL = pLinkMove; pL; pL = pL->GetNext() )
3166 : : {
3167 : 0 : ScChangeActionMove* pTest = (ScChangeActionMove*) pL->GetAction();
3168 [ # # ][ # # : 0 : if ( !pTest->IsRejected() &&
# # # # ]
3169 : 0 : (pTest->GetFromRange().Intersects( rRange ) ||
3170 : 0 : pTest->GetBigRange().Intersects( rRange )) )
3171 : : {
3172 : 0 : AddDependentWithNotify( pTest, pAct );
3173 : : }
3174 : : }
3175 : : }
3176 : : }
3177 : : }
3178 : :
3179 : :
3180 : 0 : void ScChangeTrack::Remove( ScChangeAction* pRemove )
3181 : : {
3182 : : // aus Track ausklinken
3183 : 0 : sal_uLong nAct = pRemove->GetActionNumber();
3184 [ # # ]: 0 : aMap.erase( nAct );
3185 [ # # ]: 0 : if ( nAct == nActionMax )
3186 : 0 : --nActionMax;
3187 [ # # ]: 0 : if ( pRemove == pLast )
3188 : 0 : pLast = pRemove->pPrev;
3189 [ # # ]: 0 : if ( pRemove == pFirst )
3190 : 0 : pFirst = pRemove->pNext;
3191 [ # # ]: 0 : if ( nAct == nMarkLastSaved )
3192 : : nMarkLastSaved =
3193 [ # # ]: 0 : ( pRemove->pPrev ? pRemove->pPrev->GetActionNumber() : 0 );
3194 : :
3195 : : // aus der globalen Kette ausklinken
3196 [ # # ]: 0 : if ( pRemove->pNext )
3197 : 0 : pRemove->pNext->pPrev = pRemove->pPrev;
3198 [ # # ]: 0 : if ( pRemove->pPrev )
3199 : 0 : pRemove->pPrev->pNext = pRemove->pNext;
3200 : :
3201 : : // Dependencies nicht loeschen, passiert on delete automatisch durch
3202 : : // LinkEntry, ohne Listen abzuklappern
3203 : :
3204 [ # # ][ # # ]: 0 : if ( aModifiedLink.IsSet() )
3205 : : {
3206 [ # # ]: 0 : NotifyModified( SC_CTM_REMOVE, nAct, nAct );
3207 [ # # ]: 0 : if ( pRemove->GetType() == SC_CAT_CONTENT )
3208 : : {
3209 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) pRemove;
3210 [ # # ]: 0 : if ( ( pContent = pContent->GetPrevContent() ) != NULL )
3211 : : {
3212 : 0 : sal_uLong nMod = pContent->GetActionNumber();
3213 [ # # ]: 0 : NotifyModified( SC_CTM_CHANGE, nMod, nMod );
3214 : : }
3215 : : }
3216 [ # # ]: 0 : else if ( pLast )
3217 : : NotifyModified( SC_CTM_CHANGE, pFirst->GetActionNumber(),
3218 [ # # ]: 0 : pLast->GetActionNumber() );
3219 : : }
3220 : :
3221 [ # # ][ # # ]: 0 : if ( IsInPasteCut() && pRemove->GetType() == SC_CAT_CONTENT )
[ # # ]
3222 : : { //! Content wird wiederverwertet
3223 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) pRemove;
3224 [ # # ]: 0 : pContent->RemoveAllLinks();
3225 : 0 : pContent->ClearTrack();
3226 : 0 : pContent->pNext = pContent->pPrev = NULL;
3227 : 0 : pContent->pNextContent = pContent->pPrevContent = NULL;
3228 : : }
3229 : 0 : }
3230 : :
3231 : :
3232 : 0 : void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMerge )
3233 : : {
3234 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3235 [ # # ]: 0 : if ( bMerge )
3236 : : {
3237 : 0 : SetMergeState( SC_CTMS_UNDO );
3238 : : }
3239 : :
3240 [ # # ]: 0 : if ( nStartAction == 0 )
3241 : 0 : ++nStartAction;
3242 [ # # ]: 0 : if ( nEndAction > nActionMax )
3243 : 0 : nEndAction = nActionMax;
3244 [ # # ][ # # ]: 0 : if ( nEndAction && nStartAction <= nEndAction )
3245 : : {
3246 [ # # ]: 0 : if ( nStartAction == nStartLastCut && nEndAction == nEndLastCut &&
[ # # # # ]
[ # # ]
3247 : 0 : !IsInPasteCut() )
3248 : 0 : ResetLastCut();
3249 : 0 : StartBlockModify( SC_CTM_REMOVE, nStartAction );
3250 [ # # ]: 0 : for ( sal_uLong j = nEndAction; j >= nStartAction; --j )
3251 : : { // rueckwaerts um evtl. nActionMax zu recyclen und schnelleren
3252 : : // Zugriff via pLast, Deletes in richtiger Reihenfolge
3253 : : ScChangeAction* pAct = ( (j == nActionMax && pLast &&
3254 [ # # ][ # # ]: 0 : pLast->GetActionNumber() == j) ? pLast : GetAction( j ) );
[ # # ][ # # ]
3255 [ # # ]: 0 : if ( pAct )
3256 : : {
3257 [ # # ]: 0 : if ( pAct->IsDeleteType() )
3258 : : {
3259 [ # # ][ # # ]: 0 : if ( j == nEndAction || (pAct != pLast &&
[ # # ][ # # ]
3260 [ # # ]: 0 : ((ScChangeActionDel*)pAct)->IsTopDelete()) )
3261 : : {
3262 : 0 : SetInDeleteTop( true );
3263 : : SetInDeleteRange( ((ScChangeActionDel*)pAct)->
3264 : 0 : GetOverAllRange().MakeRange() );
3265 : : }
3266 : : }
3267 [ # # ]: 0 : UpdateReference( pAct, true );
3268 : 0 : SetInDeleteTop( false );
3269 [ # # ]: 0 : Remove( pAct );
3270 [ # # ]: 0 : if ( IsInPasteCut() )
3271 [ # # ]: 0 : aPasteCutMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
3272 : : else
3273 : : {
3274 [ # # ][ # # ]: 0 : if ( j == nStartAction && pAct->GetType() == SC_CAT_MOVE )
[ # # ]
3275 : : {
3276 : 0 : ScChangeActionMove* pMove = (ScChangeActionMove*) pAct;
3277 : 0 : sal_uLong nStart = pMove->GetStartLastCut();
3278 : 0 : sal_uLong nEnd = pMove->GetEndLastCut();
3279 [ # # ][ # # ]: 0 : if ( nStart && nStart <= nEnd )
3280 : : { // LastCut wiederherstellen
3281 : : //! Links vor Cut-Append aufloesen
3282 [ # # ]: 0 : pMove->RemoveAllLinks();
3283 [ # # ]: 0 : StartBlockModify( SC_CTM_APPEND, nStart );
3284 [ # # ]: 0 : for ( sal_uLong nCut = nStart; nCut <= nEnd; nCut++ )
3285 : : {
3286 [ # # ]: 0 : ScChangeActionMap::iterator itCut = aPasteCutMap.find( nCut );
3287 : :
3288 [ # # ]: 0 : if ( itCut != aPasteCutMap.end() )
3289 : : {
3290 : : OSL_ENSURE( aMap.find( nCut ) == aMap.end(), "ScChangeTrack::Undo: nCut dup" );
3291 [ # # ]: 0 : Append( itCut->second, nCut );
3292 [ # # ]: 0 : aPasteCutMap.erase( itCut );
3293 : : }
3294 : : else
3295 : : {
3296 : : OSL_FAIL( "ScChangeTrack::Undo: nCut not found" );
3297 : : }
3298 : : }
3299 [ # # ]: 0 : EndBlockModify( nEnd );
3300 [ # # ]: 0 : ResetLastCut();
3301 : 0 : nStartLastCut = nStart;
3302 : 0 : nEndLastCut = nEnd;
3303 : 0 : pLastCutMove = pMove;
3304 : : SetLastCutMoveRange(
3305 [ # # ]: 0 : pMove->GetFromRange().MakeRange(), pDoc );
3306 : : }
3307 : : else
3308 [ # # ][ # # ]: 0 : delete pMove;
3309 : : }
3310 : : else
3311 [ # # ][ # # ]: 0 : delete pAct;
3312 : : }
3313 : : }
3314 : : }
3315 : 0 : EndBlockModify( nEndAction );
3316 : : }
3317 : :
3318 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3319 [ # # ]: 0 : if ( bMerge )
3320 : : {
3321 : 0 : SetMergeState( SC_CTMS_OTHER );
3322 : : }
3323 : 0 : }
3324 : :
3325 : :
3326 : 0 : bool ScChangeTrack::MergeIgnore( const ScChangeAction& rAction, sal_uLong nFirstMerge )
3327 : : {
3328 [ # # ]: 0 : if ( rAction.IsRejected() )
3329 : 0 : return true; // da kommt noch eine passende Reject-Action
3330 : :
3331 [ # # ][ # # ]: 0 : if ( rAction.IsRejecting() && rAction.GetRejectAction() >= nFirstMerge )
[ # # ]
3332 : 0 : return true; // da ist sie
3333 : :
3334 : 0 : return false; // alles andere
3335 : : }
3336 : :
3337 : :
3338 : 0 : void ScChangeTrack::MergePrepare( ScChangeAction* pFirstMerge, bool bShared )
3339 : : {
3340 : 0 : SetMergeState( SC_CTMS_PREPARE );
3341 : 0 : sal_uLong nFirstMerge = pFirstMerge->GetActionNumber();
3342 : 0 : ScChangeAction* pAct = GetLast();
3343 [ # # ]: 0 : if ( pAct )
3344 : : {
3345 : 0 : SetLastMerge( pAct->GetActionNumber() );
3346 [ # # ]: 0 : while ( pAct )
3347 : : { // rueckwaerts, Deletes in richtiger Reihenfolge
3348 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3349 [ # # ][ # # ]: 0 : if ( bShared || !ScChangeTrack::MergeIgnore( *pAct, nFirstMerge ) )
[ # # ]
3350 : : {
3351 [ # # ]: 0 : if ( pAct->IsDeleteType() )
3352 : : {
3353 [ # # ]: 0 : if ( ((ScChangeActionDel*)pAct)->IsTopDelete() )
3354 : : {
3355 : 0 : SetInDeleteTop( true );
3356 : : SetInDeleteRange( ((ScChangeActionDel*)pAct)->
3357 : 0 : GetOverAllRange().MakeRange() );
3358 : : }
3359 : : }
3360 : 0 : UpdateReference( pAct, true );
3361 : 0 : SetInDeleteTop( false );
3362 : 0 : pAct->DeleteCellEntries(); // sonst GPF bei Track Clear()
3363 : : }
3364 [ # # ]: 0 : pAct = ( pAct == pFirstMerge ? NULL : pAct->GetPrev() );
3365 : : }
3366 : : }
3367 : 0 : SetMergeState( SC_CTMS_OTHER ); //! nachfolgende per default MergeOther
3368 : 0 : }
3369 : :
3370 : :
3371 : 0 : void ScChangeTrack::MergeOwn( ScChangeAction* pAct, sal_uLong nFirstMerge, bool bShared )
3372 : : {
3373 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3374 [ # # ][ # # ]: 0 : if ( bShared || !ScChangeTrack::MergeIgnore( *pAct, nFirstMerge ) )
[ # # ]
3375 : : {
3376 : 0 : SetMergeState( SC_CTMS_OWN );
3377 [ # # ]: 0 : if ( pAct->IsDeleteType() )
3378 : : {
3379 [ # # ]: 0 : if ( ((ScChangeActionDel*)pAct)->IsTopDelete() )
3380 : : {
3381 : 0 : SetInDeleteTop( true );
3382 : : SetInDeleteRange( ((ScChangeActionDel*)pAct)->
3383 : 0 : GetOverAllRange().MakeRange() );
3384 : : }
3385 : : }
3386 : 0 : UpdateReference( pAct, false );
3387 : 0 : SetInDeleteTop( false );
3388 : 0 : SetMergeState( SC_CTMS_OTHER ); //! nachfolgende per default MergeOther
3389 : : }
3390 : 0 : }
3391 : :
3392 : :
3393 : 0 : void ScChangeTrack::UpdateReference( ScChangeAction* pAct, bool bUndo )
3394 : : {
3395 : 0 : ScChangeActionType eActType = pAct->GetType();
3396 [ # # ][ # # ]: 0 : if ( eActType == SC_CAT_CONTENT || eActType == SC_CAT_REJECT )
3397 : 0 : return ;
3398 : :
3399 : : //! Formelzellen haengen nicht im Dokument
3400 : 0 : bool bOldAutoCalc = pDoc->GetAutoCalc();
3401 : 0 : pDoc->SetAutoCalc( false );
3402 : 0 : bool bOldNoListening = pDoc->GetNoListening();
3403 : 0 : pDoc->SetNoListening( true );
3404 : : //! Formelzellen ExpandRefs synchronisiert zu denen im Dokument
3405 : 0 : bool bOldExpandRefs = pDoc->IsExpandRefs();
3406 [ # # ][ # # ]: 0 : if ( (!bUndo && pAct->IsInsertType()) || (bUndo && pAct->IsDeleteType()) )
[ # # ][ # # ]
[ # # ]
3407 : 0 : pDoc->SetExpandRefs( SC_MOD()->GetInputOptions().GetExpandRefs() );
3408 : :
3409 [ # # ]: 0 : if ( pAct->IsDeleteType() )
3410 : : {
3411 : 0 : SetInDeleteUndo( bUndo );
3412 : 0 : SetInDelete( true );
3413 : : }
3414 [ # # ]: 0 : else if ( GetMergeState() == SC_CTMS_OWN )
3415 : : {
3416 : : // Referenzen von Formelzellen wiederherstellen,
3417 : : // vorheriges MergePrepare war bei einem Insert wie ein Delete
3418 [ # # ]: 0 : if ( pAct->IsInsertType() )
3419 : 0 : SetInDeleteUndo( true );
3420 : : }
3421 : :
3422 : : //! erst die generated, als waeren sie vorher getrackt worden
3423 [ # # ]: 0 : if ( pFirstGeneratedDelContent )
3424 : : UpdateReference( (ScChangeAction**)&pFirstGeneratedDelContent, pAct,
3425 : 0 : bUndo );
3426 : 0 : UpdateReference( &pFirst, pAct, bUndo );
3427 : :
3428 : 0 : SetInDelete( false );
3429 : 0 : SetInDeleteUndo( false );
3430 : :
3431 : 0 : pDoc->SetExpandRefs( bOldExpandRefs );
3432 : 0 : pDoc->SetNoListening( bOldNoListening );
3433 : 0 : pDoc->SetAutoCalc( bOldAutoCalc );
3434 : : }
3435 : :
3436 : :
3437 : 0 : void ScChangeTrack::UpdateReference( ScChangeAction** ppFirstAction,
3438 : : ScChangeAction* pAct, bool bUndo )
3439 : : {
3440 : 0 : ScChangeActionType eActType = pAct->GetType();
3441 : : bool bGeneratedDelContents =
3442 : 0 : ( ppFirstAction == (ScChangeAction**)&pFirstGeneratedDelContent );
3443 : 0 : const ScBigRange& rOrgRange = pAct->GetBigRange();
3444 : 0 : ScBigRange aRange( rOrgRange );
3445 : 0 : ScBigRange aDelRange( rOrgRange );
3446 : : sal_Int32 nDx, nDy, nDz;
3447 : 0 : nDx = nDy = nDz = 0;
3448 : 0 : UpdateRefMode eMode = URM_INSDEL;
3449 : 0 : bool bDel = false;
3450 [ # # # # : 0 : switch ( eActType )
# # # # ]
3451 : : {
3452 : : case SC_CAT_INSERT_COLS :
3453 : 0 : aRange.aEnd.SetCol( nInt32Max );
3454 : 0 : nDx = rOrgRange.aEnd.Col() - rOrgRange.aStart.Col() + 1;
3455 : 0 : break;
3456 : : case SC_CAT_INSERT_ROWS :
3457 : 0 : aRange.aEnd.SetRow( nInt32Max );
3458 : 0 : nDy = rOrgRange.aEnd.Row() - rOrgRange.aStart.Row() + 1;
3459 : 0 : break;
3460 : : case SC_CAT_INSERT_TABS :
3461 : 0 : aRange.aEnd.SetTab( nInt32Max );
3462 : 0 : nDz = rOrgRange.aEnd.Tab() - rOrgRange.aStart.Tab() + 1;
3463 : 0 : break;
3464 : : case SC_CAT_DELETE_COLS :
3465 : 0 : aRange.aEnd.SetCol( nInt32Max );
3466 : 0 : nDx = -(rOrgRange.aEnd.Col() - rOrgRange.aStart.Col() + 1);
3467 : 0 : aDelRange.aEnd.SetCol( aDelRange.aStart.Col() - nDx - 1 );
3468 : 0 : bDel = true;
3469 : 0 : break;
3470 : : case SC_CAT_DELETE_ROWS :
3471 : 0 : aRange.aEnd.SetRow( nInt32Max );
3472 : 0 : nDy = -(rOrgRange.aEnd.Row() - rOrgRange.aStart.Row() + 1);
3473 : 0 : aDelRange.aEnd.SetRow( aDelRange.aStart.Row() - nDy - 1 );
3474 : 0 : bDel = true;
3475 : 0 : break;
3476 : : case SC_CAT_DELETE_TABS :
3477 : 0 : aRange.aEnd.SetTab( nInt32Max );
3478 : 0 : nDz = -(rOrgRange.aEnd.Tab() - rOrgRange.aStart.Tab() + 1);
3479 : 0 : aDelRange.aEnd.SetTab( aDelRange.aStart.Tab() - nDz - 1 );
3480 : 0 : bDel = true;
3481 : 0 : break;
3482 : : case SC_CAT_MOVE :
3483 : 0 : eMode = URM_MOVE;
3484 [ # # ]: 0 : ((ScChangeActionMove*)pAct)->GetDelta( nDx, nDy, nDz );
3485 : 0 : break;
3486 : : default:
3487 : : OSL_FAIL( "ScChangeTrack::UpdateReference: unknown Type" );
3488 : : }
3489 [ # # ]: 0 : if ( bUndo )
3490 : : {
3491 : 0 : nDx = -nDx;
3492 : 0 : nDy = -nDy;
3493 : 0 : nDz = -nDz;
3494 : : }
3495 [ # # ]: 0 : if ( bDel )
3496 : : { //! fuer diesen Mechanismus gilt:
3497 : : //! es gibt nur ganze, einfache geloeschte Spalten/Zeilen
3498 : 0 : ScChangeActionDel* pActDel = (ScChangeActionDel*) pAct;
3499 [ # # ]: 0 : if ( !bUndo )
3500 : : { // Delete
3501 : 0 : ScChangeActionType eInsType = SC_CAT_NONE; // for Insert-Undo-"Deletes"
3502 [ # # # # ]: 0 : switch ( eActType )
3503 : : {
3504 : : case SC_CAT_DELETE_COLS :
3505 : 0 : eInsType = SC_CAT_INSERT_COLS;
3506 : 0 : break;
3507 : : case SC_CAT_DELETE_ROWS :
3508 : 0 : eInsType = SC_CAT_INSERT_ROWS;
3509 : 0 : break;
3510 : : case SC_CAT_DELETE_TABS :
3511 : 0 : eInsType = SC_CAT_INSERT_TABS;
3512 : 0 : break;
3513 : : default:
3514 : : {
3515 : : // added to avoid warnings
3516 : : }
3517 : : }
3518 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3519 : : {
3520 [ # # ]: 0 : if ( p == pAct )
3521 : 0 : continue; // for
3522 : 0 : bool bUpdate = true;
3523 [ # # # # ]: 0 : if ( GetMergeState() == SC_CTMS_OTHER &&
[ # # ]
3524 : 0 : p->GetActionNumber() <= GetLastMerge() )
3525 : : { // Delete in mergendem Dokument, Action im zu mergenden
3526 [ # # ]: 0 : if ( p->IsInsertType() )
3527 : : {
3528 : : // Bei Insert Referenzen nur anpassen, wenn das Delete
3529 : : // das Insert nicht schneidet.
3530 [ # # ][ # # ]: 0 : if ( !aDelRange.Intersects( p->GetBigRange() ) )
3531 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3532 : 0 : bUpdate = false;
3533 : : }
3534 [ # # ][ # # ]: 0 : else if ( p->GetType() == SC_CAT_CONTENT &&
[ # # ]
3535 [ # # ]: 0 : p->IsDeletedInDelType( eInsType ) )
3536 : : { // Content in Insert-Undo-"Delete"
3537 : : // Nicht anpassen, wenn dieses Delete in dem
3538 : : // Insert-"Delete" sein wuerde (ist nur verschoben).
3539 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange().aStart ) )
3540 : 0 : bUpdate = false;
3541 : : else
3542 : : {
3543 [ # # ]: 0 : const ScChangeActionLinkEntry* pLink = p->GetDeletedIn();
3544 [ # # ][ # # ]: 0 : while ( pLink && bUpdate )
[ # # ]
3545 : : {
3546 : 0 : const ScChangeAction* pDel = pLink->GetAction();
3547 [ # # # # ]: 0 : if ( pDel && pDel->GetType() == eInsType &&
[ # # ][ # # ]
3548 : 0 : pDel->GetBigRange().In( aDelRange ) )
3549 : 0 : bUpdate = false;
3550 : 0 : pLink = pLink->GetNext();
3551 : : }
3552 : : }
3553 : : }
3554 [ # # ]: 0 : if ( !bUpdate )
3555 : 0 : continue; // for
3556 : : }
3557 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange() ) )
3558 : : {
3559 : : // Innerhalb eines gerade geloeschten Bereiches nicht
3560 : : // anpassen, stattdessen dem Bereich zuordnen.
3561 : : // Mehrfache geloeschte Bereiche "stapeln".
3562 : : // Kreuzende Deletes setzen mehrfach geloescht.
3563 [ # # ][ # # ]: 0 : if ( !p->IsDeletedInDelType( eActType ) )
3564 : : {
3565 [ # # ]: 0 : p->SetDeletedIn( pActDel );
3566 : : // GeneratedDelContent in zu loeschende Liste aufnehmen
3567 [ # # ]: 0 : if ( bGeneratedDelContents )
3568 [ # # ]: 0 : pActDel->AddContent( (ScChangeActionContent*) p );
3569 : : }
3570 : 0 : bUpdate = false;
3571 : : }
3572 : : else
3573 : : {
3574 : : // Eingefuegte Bereiche abschneiden, wenn Start/End im
3575 : : // Delete liegt, aber das Insert nicht komplett innerhalb
3576 : : // des Delete liegt bzw. das Delete nicht komplett im
3577 : : // Insert. Das Delete merkt sich, welchem Insert es was
3578 : : // abgeschnitten hat, es kann auch nur ein einziges Insert
3579 : : // sein (weil Delete einspaltig/einzeilig ist).
3580 : : // Abgeschnittene Moves kann es viele geben.
3581 : : //! Ein Delete ist immer einspaltig/einzeilig, deswegen 1
3582 : : //! ohne die Ueberlappung auszurechnen.
3583 [ # # # # : 0 : switch ( p->GetType() )
# ]
3584 : : {
3585 : : case SC_CAT_INSERT_COLS :
3586 [ # # ]: 0 : if ( eActType == SC_CAT_DELETE_COLS )
3587 : : {
3588 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange().aStart ) )
3589 : : {
3590 : : pActDel->SetCutOffInsert(
3591 : 0 : (ScChangeActionIns*) p, 1 );
3592 : 0 : p->GetBigRange().aStart.IncCol( 1 );
3593 : : }
3594 [ # # ]: 0 : else if ( aDelRange.In( p->GetBigRange().aEnd ) )
3595 : : {
3596 : : pActDel->SetCutOffInsert(
3597 : 0 : (ScChangeActionIns*) p, -1 );
3598 : 0 : p->GetBigRange().aEnd.IncCol( -1 );
3599 : : }
3600 : : }
3601 : 0 : break;
3602 : : case SC_CAT_INSERT_ROWS :
3603 [ # # ]: 0 : if ( eActType == SC_CAT_DELETE_ROWS )
3604 : : {
3605 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange().aStart ) )
3606 : : {
3607 : : pActDel->SetCutOffInsert(
3608 : 0 : (ScChangeActionIns*) p, 1 );
3609 : 0 : p->GetBigRange().aStart.IncRow( 1 );
3610 : : }
3611 [ # # ]: 0 : else if ( aDelRange.In( p->GetBigRange().aEnd ) )
3612 : : {
3613 : : pActDel->SetCutOffInsert(
3614 : 0 : (ScChangeActionIns*) p, -1 );
3615 : 0 : p->GetBigRange().aEnd.IncRow( -1 );
3616 : : }
3617 : : }
3618 : 0 : break;
3619 : : case SC_CAT_INSERT_TABS :
3620 [ # # ]: 0 : if ( eActType == SC_CAT_DELETE_TABS )
3621 : : {
3622 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange().aStart ) )
3623 : : {
3624 : : pActDel->SetCutOffInsert(
3625 : 0 : (ScChangeActionIns*) p, 1 );
3626 : 0 : p->GetBigRange().aStart.IncTab( 1 );
3627 : : }
3628 [ # # ]: 0 : else if ( aDelRange.In( p->GetBigRange().aEnd ) )
3629 : : {
3630 : : pActDel->SetCutOffInsert(
3631 : 0 : (ScChangeActionIns*) p, -1 );
3632 : 0 : p->GetBigRange().aEnd.IncTab( -1 );
3633 : : }
3634 : : }
3635 : 0 : break;
3636 : : case SC_CAT_MOVE :
3637 : : {
3638 : 0 : ScChangeActionMove* pMove = (ScChangeActionMove*) p;
3639 : 0 : short nFrom = 0;
3640 : 0 : short nTo = 0;
3641 [ # # ]: 0 : if ( aDelRange.In( pMove->GetBigRange().aStart ) )
3642 : 0 : nTo = 1;
3643 [ # # ]: 0 : else if ( aDelRange.In( pMove->GetBigRange().aEnd ) )
3644 : 0 : nTo = -1;
3645 [ # # ]: 0 : if ( aDelRange.In( pMove->GetFromRange().aStart ) )
3646 : 0 : nFrom = 1;
3647 [ # # ]: 0 : else if ( aDelRange.In( pMove->GetFromRange().aEnd ) )
3648 : 0 : nFrom = -1;
3649 [ # # ]: 0 : if ( nFrom )
3650 : : {
3651 [ # # # # ]: 0 : switch ( eActType )
3652 : : {
3653 : : case SC_CAT_DELETE_COLS :
3654 [ # # ]: 0 : if ( nFrom > 0 )
3655 : 0 : pMove->GetFromRange().aStart.IncCol( nFrom );
3656 : : else
3657 : 0 : pMove->GetFromRange().aEnd.IncCol( nFrom );
3658 : 0 : break;
3659 : : case SC_CAT_DELETE_ROWS :
3660 [ # # ]: 0 : if ( nFrom > 0 )
3661 : 0 : pMove->GetFromRange().aStart.IncRow( nFrom );
3662 : : else
3663 : 0 : pMove->GetFromRange().aEnd.IncRow( nFrom );
3664 : 0 : break;
3665 : : case SC_CAT_DELETE_TABS :
3666 [ # # ]: 0 : if ( nFrom > 0 )
3667 : 0 : pMove->GetFromRange().aStart.IncTab( nFrom );
3668 : : else
3669 : 0 : pMove->GetFromRange().aEnd.IncTab( nFrom );
3670 : 0 : break;
3671 : : default:
3672 : : {
3673 : : // added to avoid warnings
3674 : : }
3675 : : }
3676 : : }
3677 [ # # ]: 0 : if ( nTo )
3678 : : {
3679 [ # # # # ]: 0 : switch ( eActType )
3680 : : {
3681 : : case SC_CAT_DELETE_COLS :
3682 [ # # ]: 0 : if ( nTo > 0 )
3683 : 0 : pMove->GetBigRange().aStart.IncCol( nTo );
3684 : : else
3685 : 0 : pMove->GetBigRange().aEnd.IncCol( nTo );
3686 : 0 : break;
3687 : : case SC_CAT_DELETE_ROWS :
3688 [ # # ]: 0 : if ( nTo > 0 )
3689 : 0 : pMove->GetBigRange().aStart.IncRow( nTo );
3690 : : else
3691 : 0 : pMove->GetBigRange().aEnd.IncRow( nTo );
3692 : 0 : break;
3693 : : case SC_CAT_DELETE_TABS :
3694 [ # # ]: 0 : if ( nTo > 0 )
3695 : 0 : pMove->GetBigRange().aStart.IncTab( nTo );
3696 : : else
3697 : 0 : pMove->GetBigRange().aEnd.IncTab( nTo );
3698 : 0 : break;
3699 : : default:
3700 : : {
3701 : : // added to avoid warnings
3702 : : }
3703 : : }
3704 : : }
3705 [ # # ][ # # ]: 0 : if ( nFrom || nTo )
3706 : : {
3707 : : ScChangeActionDelMoveEntry* pLink =
3708 [ # # ]: 0 : pActDel->AddCutOffMove( pMove, nFrom, nTo );
3709 [ # # ]: 0 : pMove->AddLink( pActDel, pLink );
3710 : : }
3711 : : }
3712 : 0 : break;
3713 : : default:
3714 : : {
3715 : : // added to avoid warnings
3716 : : }
3717 : : }
3718 : : }
3719 [ # # ]: 0 : if ( bUpdate )
3720 : : {
3721 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3722 [ # # ][ # # ]: 0 : if ( p->GetType() == eActType && !p->IsRejected() &&
[ # # # # ]
[ # # ]
3723 [ # # ]: 0 : !pActDel->IsDeletedIn() &&
3724 : 0 : p->GetBigRange().In( aDelRange ) )
3725 [ # # ]: 0 : pActDel->SetDeletedIn( p ); // "druntergerutscht"
3726 : : }
3727 : : }
3728 : : }
3729 : : else
3730 : : { // Undo Delete
3731 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3732 : : {
3733 [ # # ]: 0 : if ( p == pAct )
3734 : 0 : continue; // for
3735 : 0 : bool bUpdate = true;
3736 [ # # ]: 0 : if ( aDelRange.In( p->GetBigRange() ) )
3737 : : {
3738 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3739 [ # # ][ # # ]: 0 : if ( GetMergeState() == SC_CTMS_UNDO && !p->IsDeletedIn( pAct ) && pAct->IsDeleteType() &&
[ # # ][ # #
# # # # #
# # # #
# ][ # # ]
3740 : 0 : ( p->GetType() == SC_CAT_CONTENT ||
3741 : 0 : p->GetType() == SC_CAT_DELETE_ROWS || p->GetType() == SC_CAT_DELETE_COLS ||
3742 : 0 : p->GetType() == SC_CAT_INSERT_ROWS || p->GetType() == SC_CAT_INSERT_COLS ) )
3743 : : {
3744 [ # # ]: 0 : p->SetDeletedIn( pAct );
3745 : : }
3746 : :
3747 [ # # ][ # # ]: 0 : if ( p->IsDeletedInDelType( eActType ) )
3748 : : {
3749 [ # # ][ # # ]: 0 : if ( p->IsDeletedIn( pActDel ) )
3750 : : {
3751 [ # # # # ]: 0 : if ( p->GetType() != SC_CAT_CONTENT ||
[ # # ]
3752 : 0 : ((ScChangeActionContent*)p)->IsTopContent() )
3753 : : { // erst der TopContent wird wirklich entfernt
3754 [ # # ]: 0 : p->RemoveDeletedIn( pActDel );
3755 : : // GeneratedDelContent _nicht_ aus Liste loeschen,
3756 : : // wir brauchen ihn evtl. noch fuer Reject,
3757 : : // geloescht wird in DeleteCellEntries
3758 : : }
3759 : : }
3760 : 0 : bUpdate = false;
3761 : : }
3762 [ # # ][ # # ]: 0 : else if ( eActType != SC_CAT_DELETE_TABS &&
[ # # ]
3763 [ # # ]: 0 : p->IsDeletedInDelType( SC_CAT_DELETE_TABS ) )
3764 : : { // in geloeschten Tabellen nicht updaten,
3765 : : // ausser wenn Tabelle verschoben wird
3766 : 0 : bUpdate = false;
3767 : : }
3768 [ # # ][ # # ]: 0 : if ( p->GetType() == eActType && pActDel->IsDeletedIn( p ) )
[ # # ][ # # ]
3769 : : {
3770 [ # # ]: 0 : pActDel->RemoveDeletedIn( p ); // "druntergerutscht"
3771 : 0 : bUpdate = true;
3772 : : }
3773 : : }
3774 [ # # ]: 0 : if ( bUpdate )
3775 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3776 : : }
3777 [ # # ]: 0 : if ( !bGeneratedDelContents )
3778 : : { // die werden sonst noch fuer das echte Undo gebraucht
3779 : 0 : pActDel->UndoCutOffInsert();
3780 [ # # ]: 0 : pActDel->UndoCutOffMoves();
3781 : : }
3782 : : }
3783 : : }
3784 [ # # ]: 0 : else if ( eActType == SC_CAT_MOVE )
3785 : : {
3786 : 0 : ScChangeActionMove* pActMove = (ScChangeActionMove*) pAct;
3787 : 0 : bool bLastCutMove = ( pActMove == pLastCutMove );
3788 : 0 : const ScBigRange& rTo = pActMove->GetBigRange();
3789 : 0 : const ScBigRange& rFrom = pActMove->GetFromRange();
3790 [ # # ]: 0 : if ( !bUndo )
3791 : : { // Move
3792 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3793 : : {
3794 [ # # ]: 0 : if ( p == pAct )
3795 : 0 : continue; // for
3796 [ # # ]: 0 : if ( p->GetType() == SC_CAT_CONTENT )
3797 : : {
3798 : : // Inhalt in Ziel deleten (Inhalt in Quelle moven)
3799 [ # # ]: 0 : if ( rTo.In( p->GetBigRange() ) )
3800 : : {
3801 [ # # ][ # # ]: 0 : if ( !p->IsDeletedIn( pActMove ) )
3802 : : {
3803 [ # # ]: 0 : p->SetDeletedIn( pActMove );
3804 : : // GeneratedDelContent in zu loeschende Liste aufnehmen
3805 [ # # ]: 0 : if ( bGeneratedDelContents )
3806 [ # # ]: 0 : pActMove->AddContent( (ScChangeActionContent*) p );
3807 : : }
3808 : : }
3809 [ # # # # : 0 : else if ( bLastCutMove &&
# # ][ # # ]
3810 : 0 : p->GetActionNumber() > nEndLastCut &&
3811 : 0 : rFrom.In( p->GetBigRange() ) )
3812 : : { // Paste Cut: neuer Content nach Cut eingefuegt, bleibt.
3813 : : // Aufsplitten der ContentChain
3814 : : ScChangeActionContent *pHere, *pTmp;
3815 : 0 : pHere = (ScChangeActionContent*) p;
3816 [ # # # # ]: 0 : while ( (pTmp = pHere->GetPrevContent()) != NULL &&
[ # # ]
3817 : 0 : pTmp->GetActionNumber() > nEndLastCut )
3818 : 0 : pHere = pTmp;
3819 [ # # ]: 0 : if ( pTmp )
3820 : : { // wird TopContent des Move
3821 : 0 : pTmp->SetNextContent( NULL );
3822 : 0 : pHere->SetPrevContent( NULL );
3823 : : }
3824 [ # # ]: 0 : do
3825 : : { // Abhaengigkeit vom FromRange herstellen
3826 [ # # ]: 0 : AddDependentWithNotify( pActMove, pHere );
3827 : : } while ( ( pHere = pHere->GetNextContent() ) != NULL );
3828 : : }
3829 : : // #i87003# [Collaboration] Move range and insert content in FromRange is not merged correctly
3830 [ # # ][ # # ]: 0 : else if ( ( GetMergeState() != SC_CTMS_PREPARE && GetMergeState() != SC_CTMS_OWN ) || p->GetActionNumber() <= pAct->GetActionNumber() )
[ # # ][ # # ]
3831 [ # # ]: 0 : p->UpdateReference( this, eMode, rFrom, nDx, nDy, nDz );
3832 : : }
3833 : : }
3834 : : }
3835 : : else
3836 : : { // Undo Move
3837 : 0 : bool bActRejected = pActMove->IsRejected();
3838 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3839 : : {
3840 [ # # ]: 0 : if ( p == pAct )
3841 : 0 : continue; // for
3842 [ # # ]: 0 : if ( p->GetType() == SC_CAT_CONTENT )
3843 : : {
3844 : : // Inhalt in Ziel moven, wenn nicht deleted, sonst undelete
3845 [ # # ][ # # ]: 0 : if ( p->IsDeletedIn( pActMove ) )
3846 : : {
3847 [ # # ]: 0 : if ( ((ScChangeActionContent*)p)->IsTopContent() )
3848 : : { // erst der TopContent wird wirklich entfernt
3849 [ # # ]: 0 : p->RemoveDeletedIn( pActMove );
3850 : : // GeneratedDelContent _nicht_ aus Liste loeschen,
3851 : : // wir brauchen ihn evtl. noch fuer Reject,
3852 : : // geloescht wird in DeleteCellEntries
3853 : : }
3854 : : }
3855 : : // #i87003# [Collaboration] Move range and insert content in FromRange is not merged correctly
3856 [ # # ][ # # ]: 0 : else if ( ( GetMergeState() != SC_CTMS_PREPARE && GetMergeState() != SC_CTMS_OWN ) || p->GetActionNumber() <= pAct->GetActionNumber() )
[ # # ][ # # ]
3857 [ # # ]: 0 : p->UpdateReference( this, eMode, rTo, nDx, nDy, nDz );
3858 [ # # # # : 0 : if ( bActRejected &&
# # ][ # # ]
3859 : 0 : ((ScChangeActionContent*)p)->IsTopContent() &&
3860 : 0 : rFrom.In( p->GetBigRange() ) )
3861 : : { // Abhaengigkeit herstellen, um Content zu schreiben
3862 : : ScChangeActionLinkEntry* pLink =
3863 [ # # ]: 0 : pActMove->AddDependent( p );
3864 [ # # ]: 0 : p->AddLink( pActMove, pLink );
3865 : : }
3866 : : }
3867 : : }
3868 : : }
3869 : : }
3870 : : else
3871 : : { // Insert / Undo Insert
3872 [ # # # # : 0 : switch ( GetMergeState() )
# ]
3873 : : {
3874 : : case SC_CTMS_NONE :
3875 : : case SC_CTMS_OTHER :
3876 : : {
3877 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3878 : : {
3879 [ # # ]: 0 : if ( p == pAct )
3880 : 0 : continue; // for
3881 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3882 : : }
3883 : : }
3884 : 0 : break;
3885 : : case SC_CTMS_PREPARE :
3886 : : {
3887 : : // in Insert-Undo "Deleten"
3888 : 0 : const ScChangeActionLinkEntry* pLink = pAct->GetFirstDependentEntry();
3889 [ # # ]: 0 : while ( pLink )
3890 : : {
3891 : 0 : ScChangeAction* p = (ScChangeAction*) pLink->GetAction();
3892 [ # # ]: 0 : if ( p )
3893 [ # # ]: 0 : p->SetDeletedIn( pAct );
3894 : 0 : pLink = pLink->GetNext();
3895 : : }
3896 : :
3897 : : // #i87049# [Collaboration] Conflict between delete row and insert content is not merged correctly
3898 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3899 : : {
3900 [ # # ][ # # ]: 0 : if ( !p->IsDeletedIn( pAct ) && pAct->IsInsertType() &&
[ # # # #
# # # # #
# # # ]
[ # # ][ # # ]
3901 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3902 : 0 : ( p->GetType() == SC_CAT_CONTENT ||
3903 : 0 : p->GetType() == SC_CAT_DELETE_ROWS || p->GetType() == SC_CAT_DELETE_COLS ||
3904 : 0 : p->GetType() == SC_CAT_INSERT_ROWS || p->GetType() == SC_CAT_INSERT_COLS ) &&
3905 [ # # ]: 0 : pAct->GetBigRange().Intersects( p->GetBigRange() ) )
3906 : : {
3907 [ # # ]: 0 : p->SetDeletedIn( pAct );
3908 : : }
3909 : : }
3910 : :
3911 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3912 : : {
3913 [ # # ]: 0 : if ( p == pAct )
3914 : 0 : continue; // for
3915 [ # # ]: 0 : if ( !p->IsDeletedIn( pAct )
[ # # # # ]
[ # # ]
3916 : : // #i95212# [Collaboration] Bad handling of row insertion in shared spreadsheet
3917 : 0 : && p->GetActionNumber() <= pAct->GetActionNumber() )
3918 : : {
3919 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3920 : : }
3921 : : }
3922 : : }
3923 : 0 : break;
3924 : : case SC_CTMS_OWN :
3925 : : {
3926 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3927 : : {
3928 [ # # ]: 0 : if ( p == pAct )
3929 : 0 : continue; // for
3930 [ # # ]: 0 : if ( !p->IsDeletedIn( pAct )
[ # # # # ]
[ # # ]
3931 : : // #i95212# [Collaboration] Bad handling of row insertion in shared spreadsheet
3932 : 0 : && p->GetActionNumber() <= pAct->GetActionNumber() )
3933 : : {
3934 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3935 : : }
3936 : : }
3937 : : // in Insert-Undo "Delete" rueckgaengig
3938 : 0 : const ScChangeActionLinkEntry* pLink = pAct->GetFirstDependentEntry();
3939 [ # # ]: 0 : while ( pLink )
3940 : : {
3941 : 0 : ScChangeAction* p = (ScChangeAction*) pLink->GetAction();
3942 [ # # ]: 0 : if ( p )
3943 [ # # ]: 0 : p->RemoveDeletedIn( pAct );
3944 : 0 : pLink = pLink->GetNext();
3945 : : }
3946 : :
3947 : : // #i87049# [Collaboration] Conflict between delete row and insert content is not merged correctly
3948 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3949 : : {
3950 [ # # ][ # # ]: 0 : if ( p->IsDeletedIn( pAct ) && pAct->IsInsertType() &&
[ # # # #
# # # # #
# # # ]
[ # # ][ # # ]
3951 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3952 : 0 : ( p->GetType() == SC_CAT_CONTENT ||
3953 : 0 : p->GetType() == SC_CAT_DELETE_ROWS || p->GetType() == SC_CAT_DELETE_COLS ||
3954 : 0 : p->GetType() == SC_CAT_INSERT_ROWS || p->GetType() == SC_CAT_INSERT_COLS ) &&
3955 [ # # ]: 0 : pAct->GetBigRange().Intersects( p->GetBigRange() ) )
3956 : : {
3957 [ # # ]: 0 : p->RemoveDeletedIn( pAct );
3958 : : }
3959 : : }
3960 : : }
3961 : 0 : break;
3962 : : // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
3963 : : case SC_CTMS_UNDO :
3964 : : {
3965 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3966 : : {
3967 [ # # ][ # # ]: 0 : if ( !p->IsDeletedIn( pAct ) && pAct->IsInsertType() &&
[ # # # #
# # # # #
# # # ]
[ # # ][ # # ]
3968 : 0 : ( p->GetType() == SC_CAT_CONTENT ||
3969 : 0 : p->GetType() == SC_CAT_DELETE_ROWS || p->GetType() == SC_CAT_DELETE_COLS ||
3970 : 0 : p->GetType() == SC_CAT_INSERT_ROWS || p->GetType() == SC_CAT_INSERT_COLS ) &&
3971 [ # # ]: 0 : pAct->GetBigRange().Intersects( p->GetBigRange() ) )
3972 : : {
3973 [ # # ]: 0 : p->SetDeletedIn( pAct );
3974 : : }
3975 : : }
3976 : :
3977 [ # # ]: 0 : for ( ScChangeAction* p = *ppFirstAction; p; p = p->GetNext() )
3978 : : {
3979 [ # # ]: 0 : if ( p == pAct )
3980 : : {
3981 : 0 : continue;
3982 : : }
3983 [ # # ][ # # ]: 0 : if ( !p->IsDeletedIn( pAct ) && p->GetActionNumber() <= pAct->GetActionNumber() )
[ # # ][ # # ]
3984 : : {
3985 [ # # ]: 0 : p->UpdateReference( this, eMode, aRange, nDx, nDy, nDz );
3986 : : }
3987 : : }
3988 : : }
3989 : 0 : break;
3990 : : }
3991 : : }
3992 : 0 : }
3993 : :
3994 : :
3995 : 0 : void ScChangeTrack::GetDependents( ScChangeAction* pAct,
3996 : : ScChangeActionMap& rMap, bool bListMasterDelete, bool bAllFlat ) const
3997 : : {
3998 : : //! bAllFlat==TRUE: intern aus Accept oder Reject gerufen,
3999 : : //! => Generated werden nicht aufgenommen
4000 : :
4001 : 0 : bool bIsDelete = pAct->IsDeleteType();
4002 [ # # ][ # # ]: 0 : bool bIsMasterDelete = ( bListMasterDelete && pAct->IsMasterDelete() );
[ # # ]
4003 : :
4004 : 0 : const ScChangeAction* pCur = NULL;
4005 [ # # ][ # # ]: 0 : ::std::stack<ScChangeAction*> cStack;
4006 [ # # ]: 0 : cStack.push(pAct);
4007 : :
4008 [ # # ]: 0 : while ( !cStack.empty() )
4009 : : {
4010 [ # # ]: 0 : pCur = cStack.top();
4011 [ # # ]: 0 : cStack.pop();
4012 : :
4013 [ # # ]: 0 : if ( pCur->IsInsertType() )
4014 : : {
4015 : 0 : const ScChangeActionLinkEntry* pL = pCur->GetFirstDependentEntry();
4016 [ # # ]: 0 : while ( pL )
4017 : : {
4018 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4019 [ # # ]: 0 : if ( p != pAct )
4020 : : {
4021 [ # # ]: 0 : if ( bAllFlat )
4022 : : {
4023 : 0 : sal_uLong n = p->GetActionNumber();
4024 [ # # ][ # # ]: 0 : if ( !IsGenerated( n ) && rMap.insert( ::std::make_pair( n, p ) ).second )
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
4025 [ # # ]: 0 : if ( p->HasDependent() )
4026 [ # # ]: 0 : cStack.push( p );
4027 : : }
4028 : : else
4029 : : {
4030 [ # # ]: 0 : if ( p->GetType() == SC_CAT_CONTENT )
4031 : : {
4032 [ # # ]: 0 : if ( ((ScChangeActionContent*)p)->IsTopContent() )
4033 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4034 : : }
4035 : : else
4036 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4037 : : }
4038 : : }
4039 : 0 : pL = pL->GetNext();
4040 : : }
4041 : : }
4042 [ # # ]: 0 : else if ( pCur->IsDeleteType() )
4043 : : {
4044 [ # # ]: 0 : if ( bIsDelete )
4045 : : { // Inhalte geloeschter Bereiche interessieren nur bei Delete
4046 : 0 : ScChangeActionDel* pDel = (ScChangeActionDel*) pCur;
4047 [ # # ][ # # ]: 0 : if ( !bAllFlat && bIsMasterDelete && pCur == pAct )
[ # # ]
4048 : : {
4049 : : // zu diesem Delete gehoerende Deletes in gleiche Ebene,
4050 : : // wenn dieses Delete das momentan oberste einer Reihe ist,
4051 : 0 : ScChangeActionType eType = pDel->GetType();
4052 : 0 : ScChangeAction* p = pDel;
4053 [ # # ][ # # ]: 0 : while ( (p = p->GetPrev()) != NULL && p->GetType() == eType &&
[ # # ][ # # ]
4054 [ # # ]: 0 : !((ScChangeActionDel*)p)->IsTopDelete() )
4055 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4056 : : // delete this in the map too
4057 [ # # ]: 0 : rMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
4058 : : }
4059 : : else
4060 : : {
4061 : 0 : const ScChangeActionLinkEntry* pL = pCur->GetFirstDeletedEntry();
4062 [ # # ]: 0 : while ( pL )
4063 : : {
4064 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4065 [ # # ]: 0 : if ( p != pAct )
4066 : : {
4067 [ # # ]: 0 : if ( bAllFlat )
4068 : : {
4069 : : // nur ein TopContent einer Kette ist in LinkDeleted
4070 : 0 : sal_uLong n = p->GetActionNumber();
4071 [ # # ][ # # ]: 0 : if ( !IsGenerated( n ) && rMap.insert( ::std::make_pair( n, p ) ).second )
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
4072 [ # # # # ]: 0 : if ( p->HasDeleted() ||
[ # # ]
4073 : 0 : p->GetType() == SC_CAT_CONTENT )
4074 [ # # ]: 0 : cStack.push( p );
4075 : : }
4076 : : else
4077 : : {
4078 [ # # ]: 0 : if ( p->IsDeleteType() )
4079 : : { // weiteres TopDelete in gleiche Ebene,
4080 : : // es ist nicht rejectable
4081 [ # # ][ # # ]: 0 : if ( ((ScChangeActionDel*)p)->IsTopDelete() )
4082 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4083 : : }
4084 : : else
4085 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4086 : : }
4087 : : }
4088 : 0 : pL = pL->GetNext();
4089 : : }
4090 : : }
4091 : : }
4092 : : }
4093 [ # # ]: 0 : else if ( pCur->GetType() == SC_CAT_MOVE )
4094 : : {
4095 : : // geloeschte Contents im ToRange
4096 : 0 : const ScChangeActionLinkEntry* pL = pCur->GetFirstDeletedEntry();
4097 [ # # ]: 0 : while ( pL )
4098 : : {
4099 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4100 [ # # ][ # # ]: 0 : if ( p != pAct && rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) ).second )
[ # # ][ # # ]
[ # # ][ # #
# # # # #
# ][ # # ]
4101 : : {
4102 : : // nur ein TopContent einer Kette ist in LinkDeleted
4103 [ # # ]: 0 : if ( bAllFlat && (p->HasDeleted() ||
[ # # # # ]
[ # # ]
4104 : 0 : p->GetType() == SC_CAT_CONTENT) )
4105 [ # # ]: 0 : cStack.push( p );
4106 : : }
4107 : 0 : pL = pL->GetNext();
4108 : : }
4109 : : // neue Contents im FromRange oder neuer FromRange im ToRange
4110 : : // oder Inserts/Deletes in FromRange/ToRange
4111 : 0 : pL = pCur->GetFirstDependentEntry();
4112 [ # # ]: 0 : while ( pL )
4113 : : {
4114 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4115 [ # # ]: 0 : if ( p != pAct )
4116 : : {
4117 [ # # ]: 0 : if ( bAllFlat )
4118 : : {
4119 : 0 : sal_uLong n = p->GetActionNumber();
4120 [ # # ][ # # ]: 0 : if ( !IsGenerated( n ) && rMap.insert( ::std::make_pair( n, p ) ).second )
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
4121 [ # # ][ # # ]: 0 : if ( p->HasDependent() || p->HasDeleted() )
[ # # ]
4122 [ # # ]: 0 : cStack.push( p );
4123 : : }
4124 : : else
4125 : : {
4126 [ # # ]: 0 : if ( p->GetType() == SC_CAT_CONTENT )
4127 : : {
4128 [ # # ]: 0 : if ( ((ScChangeActionContent*)p)->IsTopContent() )
4129 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4130 : : }
4131 : : else
4132 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4133 : : }
4134 : : }
4135 : 0 : pL = pL->GetNext();
4136 : : }
4137 : : }
4138 [ # # ]: 0 : else if ( pCur->GetType() == SC_CAT_CONTENT )
4139 : : { // alle Aenderungen an gleicher Position
4140 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) pCur;
4141 : : // alle vorherigen
4142 [ # # ]: 0 : while ( ( pContent = pContent->GetPrevContent() ) != NULL )
4143 : : {
4144 [ # # ]: 0 : if ( !pContent->IsRejected() )
4145 [ # # ]: 0 : rMap.insert( ::std::make_pair( pContent->GetActionNumber(), pContent ) );
4146 : : }
4147 : 0 : pContent = (ScChangeActionContent*) pCur;
4148 : : // alle nachfolgenden
4149 [ # # ]: 0 : while ( ( pContent = pContent->GetNextContent() ) != NULL )
4150 : : {
4151 [ # # ]: 0 : if ( !pContent->IsRejected() )
4152 [ # # ]: 0 : rMap.insert( ::std::make_pair( pContent->GetActionNumber(), pContent ) );
4153 : : }
4154 : : // all MatrixReferences of a MatrixOrigin
4155 : 0 : const ScChangeActionLinkEntry* pL = pCur->GetFirstDependentEntry();
4156 [ # # ]: 0 : while ( pL )
4157 : : {
4158 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4159 [ # # ]: 0 : if ( p != pAct )
4160 : : {
4161 [ # # ]: 0 : if ( bAllFlat )
4162 : : {
4163 : 0 : sal_uLong n = p->GetActionNumber();
4164 [ # # ][ # # ]: 0 : if ( !IsGenerated( n ) && rMap.insert( ::std::make_pair( n, p ) ).second )
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
4165 [ # # ]: 0 : if ( p->HasDependent() )
4166 [ # # ]: 0 : cStack.push( p );
4167 : : }
4168 : : else
4169 [ # # ]: 0 : rMap.insert( ::std::make_pair( p->GetActionNumber(), p ) );
4170 : : }
4171 : 0 : pL = pL->GetNext();
4172 : : }
4173 : : }
4174 [ # # ]: 0 : else if ( pCur->GetType() == SC_CAT_REJECT )
4175 : : {
4176 [ # # ]: 0 : if ( bAllFlat )
4177 : : {
4178 : : ScChangeAction* p = GetAction(
4179 [ # # ]: 0 : ((ScChangeActionReject*)pCur)->GetRejectAction() );
4180 [ # # ][ # # ]: 0 : if (p != pAct && rMap.find( p->GetActionNumber() ) == rMap.end())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # # # ]
4181 [ # # ]: 0 : cStack.push( p );
4182 : : }
4183 : : }
4184 : 0 : }
4185 : 0 : }
4186 : :
4187 : :
4188 : 0 : bool ScChangeTrack::SelectContent( ScChangeAction* pAct, bool bOldest )
4189 : : {
4190 [ # # ]: 0 : if ( pAct->GetType() != SC_CAT_CONTENT )
4191 : 0 : return false;
4192 : :
4193 : 0 : ScChangeActionContent* pContent = (ScChangeActionContent*) pAct;
4194 [ # # ]: 0 : if ( bOldest )
4195 : : {
4196 : 0 : pContent = pContent->GetTopContent();
4197 : : ScChangeActionContent* pPrevContent;
4198 [ # # # # ]: 0 : while ( (pPrevContent = pContent->GetPrevContent()) != NULL &&
[ # # ]
4199 : 0 : pPrevContent->IsVirgin() )
4200 : 0 : pContent = pPrevContent;
4201 : : }
4202 : :
4203 [ # # ][ # # ]: 0 : if ( !pContent->IsClickable() )
4204 : 0 : return false;
4205 : :
4206 : 0 : ScBigRange aBigRange( pContent->GetBigRange() );
4207 : : const ScBaseCell* pCell = (bOldest ? pContent->GetOldCell() :
4208 [ # # ]: 0 : pContent->GetNewCell());
4209 [ # # ]: 0 : if ( ScChangeActionContent::GetContentCellType( pCell ) == SC_CACCT_MATORG )
4210 : : {
4211 : : SCCOL nC;
4212 : : SCROW nR;
4213 [ # # ][ # # ]: 0 : ((const ScFormulaCell*)pCell)->GetMatColsRows( nC, nR );
4214 : 0 : aBigRange.aEnd.IncCol( nC-1 );
4215 : 0 : aBigRange.aEnd.IncRow( nR-1 );
4216 : : }
4217 : :
4218 [ # # ][ # # ]: 0 : if ( !aBigRange.IsValid( pDoc ) )
4219 : 0 : return false;
4220 : :
4221 : 0 : ScRange aRange( aBigRange.MakeRange() );
4222 [ # # ]: 0 : if ( !pDoc->IsBlockEditable( aRange.aStart.Tab(), aRange.aStart.Col(),
4223 [ # # ]: 0 : aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row() ) )
4224 : 0 : return false;
4225 : :
4226 [ # # ]: 0 : if ( pContent->HasDependent() )
4227 : : {
4228 : 0 : bool bOk = true;
4229 [ # # ][ # # ]: 0 : ::std::stack<ScChangeActionContent*> aRejectActions;
4230 : 0 : const ScChangeActionLinkEntry* pL = pContent->GetFirstDependentEntry();
4231 [ # # ]: 0 : while ( pL )
4232 : : {
4233 : 0 : ScChangeAction* p = (ScChangeAction*) pL->GetAction();
4234 [ # # ]: 0 : if ( p != pContent )
4235 : : {
4236 [ # # ]: 0 : if ( p->GetType() == SC_CAT_CONTENT )
4237 : : {
4238 : : // we don't need no recursion here, do we?
4239 : : bOk &= ((ScChangeActionContent*)p)->Select( pDoc, this,
4240 [ # # ]: 0 : bOldest, &aRejectActions );
4241 : : }
4242 : : else
4243 : : {
4244 : : OSL_FAIL( "ScChangeTrack::SelectContent: content dependent no content" );
4245 : : }
4246 : : }
4247 : 0 : pL = pL->GetNext();
4248 : : }
4249 : :
4250 [ # # ]: 0 : bOk &= pContent->Select( pDoc, this, bOldest, NULL );
4251 : : // now the matrix is inserted and new content values are ready
4252 : :
4253 : : ScChangeActionContent* pNew;
4254 [ # # ]: 0 : while ( !aRejectActions.empty() )
4255 : : {
4256 [ # # ]: 0 : pNew = aRejectActions.top();
4257 [ # # ]: 0 : aRejectActions.pop();
4258 : 0 : ScAddress aPos( pNew->GetBigRange().aStart.MakeAddress() );
4259 [ # # ][ # # ]: 0 : pNew->SetNewValue( pDoc->GetCell( aPos ), pDoc );
4260 [ # # ]: 0 : Append( pNew );
4261 : : }
4262 : 0 : return bOk;
4263 : : }
4264 : : else
4265 [ # # ]: 0 : return pContent->Select( pDoc, this, bOldest, NULL );
4266 : : }
4267 : :
4268 : :
4269 : 0 : void ScChangeTrack::AcceptAll()
4270 : : {
4271 [ # # ]: 0 : for ( ScChangeAction* p = GetFirst(); p; p = p->GetNext() )
4272 : : {
4273 : 0 : p->Accept();
4274 : : }
4275 : 0 : }
4276 : :
4277 : :
4278 : 0 : bool ScChangeTrack::Accept( ScChangeAction* pAct )
4279 : : {
4280 [ # # ]: 0 : if ( !pAct->IsClickable() )
4281 : 0 : return false;
4282 : :
4283 [ # # ][ # # ]: 0 : if ( pAct->IsDeleteType() || pAct->GetType() == SC_CAT_CONTENT )
[ # # ]
4284 : : {
4285 [ # # ]: 0 : ScChangeActionMap aActionMap;
4286 : 0 : ScChangeActionMap::iterator itChangeAction;
4287 : :
4288 [ # # ]: 0 : GetDependents( pAct, aActionMap, false, true );
4289 : :
4290 [ # # ]: 0 : for( itChangeAction = aActionMap.begin(); itChangeAction != aActionMap.end(); ++itChangeAction )
4291 : : {
4292 [ # # ]: 0 : itChangeAction->second->Accept();
4293 : 0 : }
4294 : : }
4295 : 0 : pAct->Accept();
4296 : 0 : return true;
4297 : : }
4298 : :
4299 : :
4300 : 0 : bool ScChangeTrack::RejectAll()
4301 : : {
4302 : 0 : bool bOk = true;
4303 [ # # ][ # # ]: 0 : for ( ScChangeAction* p = GetLast(); p && bOk; p = p->GetPrev() )
[ # # ]
4304 : : { //! rueckwaerts, weil abhaengige hinten und RejectActions angehaengt
4305 [ # # ]: 0 : if ( p->IsInternalRejectable() )
4306 : 0 : bOk = Reject( p );
4307 : : }
4308 : 0 : return bOk;
4309 : : }
4310 : :
4311 : :
4312 : 0 : bool ScChangeTrack::Reject( ScChangeAction* pAct, bool bShared )
4313 : : {
4314 : : // #i100895# When collaboration changes are reversed, it must be possible
4315 : : // to reject a deleted row above another deleted row.
4316 [ # # ][ # # ]: 0 : if ( bShared && pAct->IsDeletedIn() )
[ # # ]
4317 : 0 : pAct->RemoveAllDeletedIn();
4318 : :
4319 [ # # ]: 0 : if ( !pAct->IsRejectable() )
4320 : 0 : return false;
4321 : :
4322 : 0 : ScChangeActionMap* pMap = NULL;
4323 [ # # ]: 0 : if ( pAct->HasDependent() )
4324 : : {
4325 [ # # ]: 0 : pMap = new ScChangeActionMap;
4326 : 0 : GetDependents( pAct, *pMap, false, true );
4327 : : }
4328 : 0 : bool bRejected = Reject( pAct, pMap, false );
4329 [ # # ]: 0 : if ( pMap )
4330 [ # # ]: 0 : delete pMap;
4331 : 0 : return bRejected;
4332 : : }
4333 : :
4334 : :
4335 : 0 : bool ScChangeTrack::Reject(
4336 : : ScChangeAction* pAct, ScChangeActionMap* pMap, bool bRecursion )
4337 : : {
4338 [ # # ]: 0 : if ( !pAct->IsInternalRejectable() )
4339 : 0 : return false;
4340 : :
4341 : 0 : bool bOk = true;
4342 : 0 : bool bRejected = false;
4343 [ # # ]: 0 : if ( pAct->IsInsertType() )
4344 : : {
4345 [ # # ][ # # ]: 0 : if ( pAct->HasDependent() && !bRecursion )
[ # # ]
4346 : : {
4347 : : OSL_ENSURE( pMap, "ScChangeTrack::Reject: Insert ohne map" );
4348 : 0 : ScChangeActionMap::reverse_iterator itChangeAction;
4349 [ # # ][ # # ]: 0 : for (itChangeAction = pMap->rbegin();
[ # # ][ # # ]
4350 [ # # ][ # # ]: 0 : itChangeAction != pMap->rend() && bOk; ++itChangeAction)
[ # # ]
4351 : : {
4352 : : // keine Contents restoren, die eh geloescht werden wuerden
4353 [ # # ][ # # ]: 0 : if ( itChangeAction->second->GetType() == SC_CAT_CONTENT )
4354 [ # # ][ # # ]: 0 : itChangeAction->second->SetRejected();
4355 [ # # ][ # # ]: 0 : else if ( itChangeAction->second->IsDeleteType() )
4356 [ # # ][ # # ]: 0 : itChangeAction->second->Accept(); // geloeschtes ins Nirvana
4357 : : else
4358 [ # # ][ # # ]: 0 : bOk = Reject( itChangeAction->second, NULL, true ); //! rekursiv
4359 : : }
4360 : : }
4361 [ # # ][ # # ]: 0 : if ( bOk && (bRejected = pAct->Reject( pDoc )) != false )
[ # # ]
4362 : : {
4363 : : // pRefDoc NULL := geloeschte Zellen nicht speichern
4364 : 0 : AppendDeleteRange( pAct->GetBigRange().MakeRange(), NULL, (short) 0,
4365 [ # # ]: 0 : pAct->GetActionNumber() );
4366 : : }
4367 : : }
4368 [ # # ]: 0 : else if ( pAct->IsDeleteType() )
4369 : : {
4370 : : OSL_ENSURE( !pMap, "ScChangeTrack::Reject: Delete mit map" );
4371 : 0 : ScBigRange aDelRange;
4372 : 0 : sal_uLong nRejectAction = pAct->GetActionNumber();
4373 : : bool bTabDel, bTabDelOk;
4374 [ # # ]: 0 : if ( pAct->GetType() == SC_CAT_DELETE_TABS )
4375 : : {
4376 : 0 : bTabDel = true;
4377 : 0 : aDelRange = pAct->GetBigRange();
4378 [ # # ]: 0 : bTabDelOk = pAct->Reject( pDoc );
4379 : 0 : bOk = bTabDelOk;
4380 [ # # ]: 0 : if ( bOk )
4381 : : {
4382 : 0 : pAct = pAct->GetPrev();
4383 [ # # ][ # # ]: 0 : bOk = ( pAct && pAct->GetType() == SC_CAT_DELETE_COLS );
4384 : : }
4385 : : }
4386 : : else
4387 : 0 : bTabDel = bTabDelOk = false;
4388 : 0 : ScChangeActionDel* pDel = (ScChangeActionDel*) pAct;
4389 [ # # ]: 0 : if ( bOk )
4390 : : {
4391 : 0 : aDelRange = pDel->GetOverAllRange();
4392 [ # # ]: 0 : bOk = aDelRange.IsValid( pDoc );
4393 : : }
4394 : 0 : bool bOneOk = false;
4395 [ # # ]: 0 : if ( bOk )
4396 : : {
4397 : 0 : ScChangeActionType eActType = pAct->GetType();
4398 [ # # # # ]: 0 : switch ( eActType )
4399 : : {
4400 : : case SC_CAT_DELETE_COLS :
4401 : 0 : aDelRange.aStart.SetCol( aDelRange.aEnd.Col() );
4402 : 0 : break;
4403 : : case SC_CAT_DELETE_ROWS :
4404 : 0 : aDelRange.aStart.SetRow( aDelRange.aEnd.Row() );
4405 : 0 : break;
4406 : : case SC_CAT_DELETE_TABS :
4407 : 0 : aDelRange.aStart.SetTab( aDelRange.aEnd.Tab() );
4408 : 0 : break;
4409 : : default:
4410 : : {
4411 : : // added to avoid warnings
4412 : : }
4413 : : }
4414 : 0 : ScChangeAction* p = pAct;
4415 : 0 : bool bLoop = true;
4416 [ # # ][ # # ]: 0 : do
[ # # # # ]
[ # # ][ # # ]
4417 : : {
4418 : 0 : pDel = (ScChangeActionDel*) p;
4419 [ # # ]: 0 : bOk = pDel->Reject( pDoc );
4420 [ # # ]: 0 : if ( bOk )
4421 : : {
4422 [ # # ]: 0 : if ( bOneOk )
4423 : : {
4424 [ # # # # ]: 0 : switch ( pDel->GetType() )
4425 : : {
4426 : : case SC_CAT_DELETE_COLS :
4427 : 0 : aDelRange.aStart.IncCol( -1 );
4428 : 0 : break;
4429 : : case SC_CAT_DELETE_ROWS :
4430 : 0 : aDelRange.aStart.IncRow( -1 );
4431 : 0 : break;
4432 : : case SC_CAT_DELETE_TABS :
4433 : 0 : aDelRange.aStart.IncTab( -1 );
4434 : 0 : break;
4435 : : default:
4436 : : {
4437 : : // added to avoid warnings
4438 : : }
4439 : : }
4440 : : }
4441 : : else
4442 : 0 : bOneOk = true;
4443 : : }
4444 [ # # ][ # # ]: 0 : if ( pDel->IsBaseDelete() )
4445 : 0 : bLoop = false;
4446 : : else
4447 : 0 : p = p->GetPrev();
4448 : 0 : } while ( bOk && bLoop && p && p->GetType() == eActType &&
4449 [ # # ]: 0 : !((ScChangeActionDel*)p)->IsTopDelete() );
4450 : : }
4451 : 0 : bRejected = bOk;
4452 [ # # ][ # # ]: 0 : if ( bOneOk || (bTabDel && bTabDelOk) )
[ # # ]
4453 : : {
4454 : : // Delete-Reject machte UpdateReference Undo
4455 : : ScChangeActionIns* pReject = new ScChangeActionIns(
4456 [ # # ][ # # ]: 0 : aDelRange.MakeRange() );
4457 : 0 : pReject->SetRejectAction( nRejectAction );
4458 : 0 : pReject->SetState( SC_CAS_ACCEPTED );
4459 [ # # ]: 0 : Append( pReject );
4460 : : }
4461 : : }
4462 [ # # ]: 0 : else if ( pAct->GetType() == SC_CAT_MOVE )
4463 : : {
4464 [ # # ][ # # ]: 0 : if ( pAct->HasDependent() && !bRecursion )
[ # # ]
4465 : : {
4466 : : OSL_ENSURE( pMap, "ScChangeTrack::Reject: Move ohne Map" );
4467 : 0 : ScChangeActionMap::reverse_iterator itChangeAction;
4468 : :
4469 [ # # ][ # # ]: 0 : for( itChangeAction = pMap->rbegin(); itChangeAction != pMap->rend() && bOk; ++itChangeAction )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
4470 : : {
4471 [ # # ][ # # ]: 0 : bOk = Reject( itChangeAction->second, NULL, true ); //! rekursiv
4472 : : }
4473 : : }
4474 [ # # ][ # # ]: 0 : if ( bOk && (bRejected = pAct->Reject( pDoc )) != false )
[ # # ]
4475 : : {
4476 : : ScChangeActionMove* pReject = new ScChangeActionMove(
4477 : 0 : pAct->GetBigRange().MakeRange(),
4478 [ # # ][ # # ]: 0 : ((ScChangeActionMove*)pAct)->GetFromRange().MakeRange(), this );
4479 : 0 : pReject->SetRejectAction( pAct->GetActionNumber() );
4480 : 0 : pReject->SetState( SC_CAS_ACCEPTED );
4481 : 0 : Append( pReject );
4482 : : }
4483 : : }
4484 [ # # ]: 0 : else if ( pAct->GetType() == SC_CAT_CONTENT )
4485 : : {
4486 : 0 : ScRange aRange;
4487 : : ScChangeActionContent* pReject;
4488 [ # # ]: 0 : if ( bRecursion )
4489 : 0 : pReject = NULL;
4490 : : else
4491 : : {
4492 : 0 : aRange = pAct->GetBigRange().aStart.MakeAddress();
4493 [ # # ][ # # ]: 0 : pReject = new ScChangeActionContent( aRange );
4494 [ # # ][ # # ]: 0 : pReject->SetOldValue( pDoc->GetCell( aRange.aStart ), pDoc, pDoc );
4495 : : }
4496 [ # # ][ # # ]: 0 : if ( (bRejected = pAct->Reject( pDoc )) != false && !bRecursion )
[ # # ][ # # ]
4497 : : {
4498 [ # # ][ # # ]: 0 : pReject->SetNewValue( pDoc->GetCell( aRange.aStart ), pDoc );
4499 : 0 : pReject->SetRejectAction( pAct->GetActionNumber() );
4500 : 0 : pReject->SetState( SC_CAS_ACCEPTED );
4501 [ # # ]: 0 : Append( pReject );
4502 : : }
4503 [ # # ]: 0 : else if ( pReject )
4504 [ # # ][ # # ]: 0 : delete pReject;
4505 : : }
4506 : : else
4507 : : {
4508 : : OSL_FAIL( "ScChangeTrack::Reject: say what?" );
4509 : : }
4510 : :
4511 : 0 : return bRejected;
4512 : : }
4513 : :
4514 : :
4515 : 0 : sal_uLong ScChangeTrack::AddLoadedGenerated(
4516 : : ScBaseCell* pNewCell, const ScBigRange& aBigRange, const rtl::OUString& sNewValue )
4517 : : {
4518 [ # # ][ # # ]: 0 : ScChangeActionContent* pAct = new ScChangeActionContent( --nGeneratedMin, pNewCell, aBigRange, pDoc, sNewValue );
4519 [ # # ]: 0 : if ( pAct )
4520 : : {
4521 [ # # ]: 0 : if ( pFirstGeneratedDelContent )
4522 : 0 : pFirstGeneratedDelContent->pPrev = pAct;
4523 : 0 : pAct->pNext = pFirstGeneratedDelContent;
4524 : 0 : pFirstGeneratedDelContent = pAct;
4525 [ # # ]: 0 : aGeneratedMap.insert( ::std::make_pair( pAct->GetActionNumber(), pAct ) );
4526 : 0 : return pAct->GetActionNumber();
4527 : : }
4528 : 0 : return 0;
4529 : : }
4530 : :
4531 : 0 : void ScChangeTrack::AppendCloned( ScChangeAction* pAppend )
4532 : : {
4533 [ # # ]: 0 : aMap.insert( ::std::make_pair( pAppend->GetActionNumber(), pAppend ) );
4534 [ # # ]: 0 : if ( !pLast )
4535 : 0 : pFirst = pLast = pAppend;
4536 : : else
4537 : : {
4538 : 0 : pLast->pNext = pAppend;
4539 : 0 : pAppend->pPrev = pLast;
4540 : 0 : pLast = pAppend;
4541 : : }
4542 : 0 : }
4543 : :
4544 : 0 : ScChangeTrack* ScChangeTrack::Clone( ScDocument* pDocument ) const
4545 : : {
4546 [ # # ]: 0 : if ( !pDocument )
4547 : : {
4548 : 0 : return NULL;
4549 : : }
4550 : :
4551 [ # # ][ # # ]: 0 : ScChangeTrack* pClonedTrack = new ScChangeTrack( pDocument );
4552 : 0 : pClonedTrack->SetTime100thSeconds( IsTime100thSeconds() );
4553 : :
4554 : : // clone generated actions
4555 [ # # ][ # # ]: 0 : ::std::stack< const ScChangeAction* > aGeneratedStack;
4556 : 0 : const ScChangeAction* pGenerated = GetFirstGenerated();
4557 [ # # ]: 0 : while ( pGenerated )
4558 : : {
4559 [ # # ]: 0 : aGeneratedStack.push( pGenerated );
4560 : 0 : pGenerated = pGenerated->GetNext();
4561 : : }
4562 [ # # ]: 0 : while ( !aGeneratedStack.empty() )
4563 : : {
4564 [ # # ]: 0 : pGenerated = aGeneratedStack.top();
4565 [ # # ]: 0 : aGeneratedStack.pop();
4566 [ # # ]: 0 : const ScChangeActionContent* pContent = dynamic_cast< const ScChangeActionContent* >( pGenerated );
4567 : : OSL_ENSURE( pContent, "ScChangeTrack::Clone: pContent is null!" );
4568 : 0 : const ScBaseCell* pNewCell = pContent->GetNewCell();
4569 [ # # ]: 0 : if ( pNewCell )
4570 : : {
4571 [ # # ]: 0 : ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument );
4572 : 0 : rtl::OUString aNewValue;
4573 [ # # ]: 0 : pContent->GetNewString( aNewValue );
4574 : 0 : pClonedTrack->nGeneratedMin = pGenerated->GetActionNumber() + 1;
4575 [ # # ]: 0 : pClonedTrack->AddLoadedGenerated( pClonedNewCell, pGenerated->GetBigRange(), aNewValue );
4576 : : }
4577 : : }
4578 : :
4579 : : // clone actions
4580 : 0 : const ScChangeAction* pAction = GetFirst();
4581 [ # # ]: 0 : while ( pAction )
4582 : : {
4583 : 0 : ScChangeAction* pClonedAction = NULL;
4584 : :
4585 [ # # # # : 0 : switch ( pAction->GetType() )
# # ]
4586 : : {
4587 : : case SC_CAT_INSERT_COLS:
4588 : : case SC_CAT_INSERT_ROWS:
4589 : : case SC_CAT_INSERT_TABS:
4590 : : {
4591 : : pClonedAction = new ScChangeActionIns(
4592 : : pAction->GetActionNumber(),
4593 : : pAction->GetState(),
4594 : : pAction->GetRejectAction(),
4595 : : pAction->GetBigRange(),
4596 : : pAction->GetUser(),
4597 : : pAction->GetDateTimeUTC(),
4598 : : pAction->GetComment(),
4599 [ # # ][ # # ]: 0 : pAction->GetType() );
[ # # ]
4600 : : }
4601 : 0 : break;
4602 : : case SC_CAT_DELETE_COLS:
4603 : : case SC_CAT_DELETE_ROWS:
4604 : : case SC_CAT_DELETE_TABS:
4605 : : {
4606 [ # # ]: 0 : const ScChangeActionDel* pDelete = dynamic_cast< const ScChangeActionDel* >( pAction );
4607 : : OSL_ENSURE( pDelete, "ScChangeTrack::Clone: pDelete is null!" );
4608 : :
4609 : 0 : SCsCOLROW nD = 0;
4610 : 0 : ScChangeActionType eType = pAction->GetType();
4611 [ # # ]: 0 : if ( eType == SC_CAT_DELETE_COLS )
4612 : : {
4613 : 0 : nD = static_cast< SCsCOLROW >( pDelete->GetDx() );
4614 : : }
4615 [ # # ]: 0 : else if ( eType == SC_CAT_DELETE_ROWS )
4616 : : {
4617 : 0 : nD = static_cast< SCsCOLROW >( pDelete->GetDy() );
4618 : : }
4619 : :
4620 : : pClonedAction = new ScChangeActionDel(
4621 : : pAction->GetActionNumber(),
4622 : : pAction->GetState(),
4623 : : pAction->GetRejectAction(),
4624 : : pAction->GetBigRange(),
4625 : : pAction->GetUser(),
4626 : : pAction->GetDateTimeUTC(),
4627 : : pAction->GetComment(),
4628 : : eType,
4629 : : nD,
4630 [ # # ][ # # ]: 0 : pClonedTrack );
[ # # ]
4631 : : }
4632 : 0 : break;
4633 : : case SC_CAT_MOVE:
4634 : : {
4635 [ # # ]: 0 : const ScChangeActionMove* pMove = dynamic_cast< const ScChangeActionMove* >( pAction );
4636 : : OSL_ENSURE( pMove, "ScChangeTrack::Clone: pMove is null!" );
4637 : :
4638 : : pClonedAction = new ScChangeActionMove(
4639 : : pAction->GetActionNumber(),
4640 : : pAction->GetState(),
4641 : : pAction->GetRejectAction(),
4642 : : pAction->GetBigRange(),
4643 : : pAction->GetUser(),
4644 : : pAction->GetDateTimeUTC(),
4645 : : pAction->GetComment(),
4646 : : pMove->GetFromRange(),
4647 [ # # ][ # # ]: 0 : pClonedTrack );
[ # # ]
4648 : : }
4649 : 0 : break;
4650 : : case SC_CAT_CONTENT:
4651 : : {
4652 [ # # ]: 0 : const ScChangeActionContent* pContent = dynamic_cast< const ScChangeActionContent* >( pAction );
4653 : : OSL_ENSURE( pContent, "ScChangeTrack::Clone: pContent is null!" );
4654 : 0 : const ScBaseCell* pOldCell = pContent->GetOldCell();
4655 [ # # ][ # # ]: 0 : ScBaseCell* pClonedOldCell = pOldCell ? pOldCell->Clone( *pDocument ) : 0;
4656 : 0 : rtl::OUString aOldValue;
4657 [ # # ]: 0 : pContent->GetOldString( aOldValue );
4658 : :
4659 : : ScChangeActionContent* pClonedContent = new ScChangeActionContent(
4660 : : pAction->GetActionNumber(),
4661 : : pAction->GetState(),
4662 : : pAction->GetRejectAction(),
4663 : : pAction->GetBigRange(),
4664 : : pAction->GetUser(),
4665 : : pAction->GetDateTimeUTC(),
4666 : : pAction->GetComment(),
4667 : : pClonedOldCell,
4668 : : pDocument,
4669 [ # # ][ # # ]: 0 : aOldValue );
[ # # ]
4670 : :
4671 : 0 : const ScBaseCell* pNewCell = pContent->GetNewCell();
4672 [ # # ]: 0 : if ( pNewCell )
4673 : : {
4674 [ # # ]: 0 : ScBaseCell* pClonedNewCell = pNewCell->Clone( *pDocument );
4675 [ # # ]: 0 : pClonedContent->SetNewValue( pClonedNewCell, pDocument );
4676 : : }
4677 : :
4678 : 0 : pClonedAction = pClonedContent;
4679 : : }
4680 : 0 : break;
4681 : : case SC_CAT_REJECT:
4682 : : {
4683 : : pClonedAction = new ScChangeActionReject(
4684 : : pAction->GetActionNumber(),
4685 : : pAction->GetState(),
4686 : : pAction->GetRejectAction(),
4687 : : pAction->GetBigRange(),
4688 : : pAction->GetUser(),
4689 : : pAction->GetDateTimeUTC(),
4690 [ # # ][ # # ]: 0 : pAction->GetComment() );
[ # # ]
4691 : : }
4692 : 0 : break;
4693 : : default:
4694 : : {
4695 : : }
4696 : 0 : break;
4697 : : }
4698 : :
4699 [ # # ]: 0 : if ( pClonedAction )
4700 : : {
4701 [ # # ]: 0 : pClonedTrack->AppendCloned( pClonedAction );
4702 : : }
4703 : :
4704 : 0 : pAction = pAction->GetNext();
4705 : : }
4706 : :
4707 [ # # ]: 0 : if ( pClonedTrack->GetLast() )
4708 : : {
4709 : 0 : pClonedTrack->SetActionMax( pClonedTrack->GetLast()->GetActionNumber() );
4710 : : }
4711 : :
4712 : : // set dependencies for Deleted/DeletedIn
4713 : 0 : pAction = GetFirst();
4714 [ # # ]: 0 : while ( pAction )
4715 : : {
4716 [ # # ]: 0 : if ( pAction->HasDeleted() )
4717 : : {
4718 [ # # ][ # # ]: 0 : ::std::stack< sal_uLong > aStack;
4719 : 0 : const ScChangeActionLinkEntry* pL = pAction->GetFirstDeletedEntry();
4720 [ # # ]: 0 : while ( pL )
4721 : : {
4722 : 0 : const ScChangeAction* pDeleted = pL->GetAction();
4723 [ # # ]: 0 : if ( pDeleted )
4724 : : {
4725 [ # # ]: 0 : aStack.push( pDeleted->GetActionNumber() );
4726 : : }
4727 : 0 : pL = pL->GetNext();
4728 : : }
4729 [ # # ]: 0 : ScChangeAction* pClonedAction = pClonedTrack->GetAction( pAction->GetActionNumber() );
4730 [ # # ]: 0 : if ( pClonedAction )
4731 : : {
4732 [ # # ][ # # ]: 0 : while ( !aStack.empty() )
4733 : : {
4734 [ # # ][ # # ]: 0 : ScChangeAction* pClonedDeleted = pClonedTrack->GetActionOrGenerated( aStack.top() );
4735 [ # # ]: 0 : aStack.pop();
4736 [ # # ]: 0 : if ( pClonedDeleted )
4737 : : {
4738 [ # # ]: 0 : pClonedDeleted->SetDeletedIn( pClonedAction );
4739 : : }
4740 : : }
4741 : 0 : }
4742 : : }
4743 : 0 : pAction = pAction->GetNext();
4744 : : }
4745 : :
4746 : : // set dependencies for Dependent/Any
4747 : 0 : pAction = GetLast();
4748 [ # # ]: 0 : while ( pAction )
4749 : : {
4750 [ # # ]: 0 : if ( pAction->HasDependent() )
4751 : : {
4752 [ # # ][ # # ]: 0 : ::std::stack< sal_uLong > aStack;
4753 : 0 : const ScChangeActionLinkEntry* pL = pAction->GetFirstDependentEntry();
4754 [ # # ]: 0 : while ( pL )
4755 : : {
4756 : 0 : const ScChangeAction* pDependent = pL->GetAction();
4757 [ # # ]: 0 : if ( pDependent )
4758 : : {
4759 [ # # ]: 0 : aStack.push( pDependent->GetActionNumber() );
4760 : : }
4761 : 0 : pL = pL->GetNext();
4762 : : }
4763 [ # # ]: 0 : ScChangeAction* pClonedAction = pClonedTrack->GetAction( pAction->GetActionNumber() );
4764 [ # # ]: 0 : if ( pClonedAction )
4765 : : {
4766 [ # # ][ # # ]: 0 : while ( !aStack.empty() )
4767 : : {
4768 [ # # ][ # # ]: 0 : ScChangeAction* pClonedDependent = pClonedTrack->GetActionOrGenerated( aStack.top() );
4769 [ # # ]: 0 : aStack.pop();
4770 [ # # ]: 0 : if ( pClonedDependent )
4771 : : {
4772 [ # # ]: 0 : ScChangeActionLinkEntry* pLink = pClonedAction->AddDependent( pClonedDependent );
4773 [ # # ]: 0 : pClonedDependent->AddLink( pClonedAction, pLink );
4774 : : }
4775 : : }
4776 : 0 : }
4777 : : }
4778 : 0 : pAction = pAction->GetPrev();
4779 : : }
4780 : :
4781 : : // masterlinks
4782 : 0 : ScChangeAction* pClonedAction = pClonedTrack->GetFirst();
4783 [ # # ]: 0 : while ( pClonedAction )
4784 : : {
4785 [ # # ]: 0 : pClonedTrack->MasterLinks( pClonedAction );
4786 : 0 : pClonedAction = pClonedAction->GetNext();
4787 : : }
4788 : :
4789 [ # # ][ # # ]: 0 : if ( IsProtected() )
4790 : : {
4791 [ # # ][ # # ]: 0 : pClonedTrack->SetProtection( GetProtection() );
[ # # ]
4792 : : }
4793 : :
4794 [ # # ]: 0 : if ( pClonedTrack->GetLast() )
4795 : : {
4796 : 0 : pClonedTrack->SetLastSavedActionNumber( pClonedTrack->GetLast()->GetActionNumber() );
4797 : : }
4798 : :
4799 [ # # ]: 0 : pDocument->SetChangeTrack( pClonedTrack );
4800 : :
4801 : 0 : return pClonedTrack;
4802 : : }
4803 : :
4804 : 0 : void ScChangeTrack::MergeActionState( ScChangeAction* pAct, const ScChangeAction* pOtherAct )
4805 : : {
4806 [ # # ]: 0 : if ( pAct->IsVirgin() )
4807 : : {
4808 [ # # ]: 0 : if ( pOtherAct->IsAccepted() )
4809 : : {
4810 : 0 : pAct->Accept();
4811 [ # # ]: 0 : if ( pOtherAct->IsRejecting() )
4812 : : {
4813 : 0 : pAct->SetRejectAction( pOtherAct->GetRejectAction() );
4814 : : }
4815 : : }
4816 [ # # ]: 0 : else if ( pOtherAct->IsRejected() )
4817 : : {
4818 : 0 : pAct->SetRejected();
4819 : : }
4820 : : }
4821 [ + - ][ + - ]: 153 : }
4822 : :
4823 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|