xref: /aoo41x/main/sc/inc/chgtrack.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_CHGTRACK_HXX
29 #define SC_CHGTRACK_HXX
30 
31 
32 #include <tools/string.hxx>
33 #include <tools/datetime.hxx>
34 #include <tools/table.hxx>
35 #include <tools/stack.hxx>
36 #include <tools/queue.hxx>
37 #include <tools/mempool.hxx>
38 #include <tools/link.hxx>
39 #include <unotools/options.hxx>
40 #include "global.hxx"
41 #include "bigrange.hxx"
42 #include "collect.hxx"
43 #include "scdllapi.h"
44 
45 #ifdef SC_CHGTRACK_CXX
46 // core/inc
47 #include "refupdat.hxx"
48 #endif
49 
50 #define DEBUG_CHANGETRACK 0
51 
52 
53 class ScBaseCell;
54 class ScDocument;
55 
56 
57 enum ScChangeActionType
58 {
59 	SC_CAT_NONE,
60 	SC_CAT_INSERT_COLS,
61 	SC_CAT_INSERT_ROWS,
62 	SC_CAT_INSERT_TABS,
63 	SC_CAT_DELETE_COLS,
64 	SC_CAT_DELETE_ROWS,
65 	SC_CAT_DELETE_TABS,
66 	SC_CAT_MOVE,
67 	SC_CAT_CONTENT,
68 	SC_CAT_REJECT
69 };
70 
71 
72 enum ScChangeActionState
73 {
74 	SC_CAS_VIRGIN,
75 	SC_CAS_ACCEPTED,
76 	SC_CAS_REJECTED
77 };
78 
79 
80 enum ScChangeActionClipMode
81 {
82 	SC_CACM_NONE,
83 	SC_CACM_CUT,
84 	SC_CACM_COPY,
85 	SC_CACM_PASTE
86 };
87 
88 class SvStream;
89 
90 // --- ScChangeActionLinkEntry ---------------------------------------------
91 
92 // Fuegt sich selbst am Beginn einer Kette ein, bzw. vor einem anderen
93 // LinkEntry, on delete selbstaendiges ausklinken auch des gelinkten.
94 // ppPrev == &previous->pNext oder Adresse des Pointers auf Beginn der Kette,
95 // *ppPrev == this
96 
97 class ScChangeAction;
98 
99 class ScChangeActionLinkEntry
100 {
101 								// not implemented, prevent usage
102 								ScChangeActionLinkEntry(
103 									const ScChangeActionLinkEntry& );
104 	ScChangeActionLinkEntry&	operator=( const ScChangeActionLinkEntry& );
105 
106 protected:
107 
108 	ScChangeActionLinkEntry*	pNext;
109 	ScChangeActionLinkEntry**	ppPrev;
110 	ScChangeAction*				pAction;
111 	ScChangeActionLinkEntry*	pLink;
112 
113 public:
114 
115 	DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionLinkEntry )
116 
117 								ScChangeActionLinkEntry(
118 										ScChangeActionLinkEntry** ppPrevP,
119 										ScChangeAction* pActionP )
120 									:	pNext( *ppPrevP ),
121 										ppPrev( ppPrevP ),
122 										pAction( pActionP ),
123 										pLink( NULL )
124 									{
125 										if ( pNext )
126 											pNext->ppPrev = &pNext;
127 										*ppPrevP = this;
128 									}
129 
130 	virtual						~ScChangeActionLinkEntry()
131 									{
132 										ScChangeActionLinkEntry* p = pLink;
133 										UnLink();
134 										Remove();
135 										if ( p )
136 											delete p;
137 									}
138 
139 			void				SetLink( ScChangeActionLinkEntry* pLinkP )
140 									{
141 										UnLink();
142 										if ( pLinkP )
143 										{
144 											pLink = pLinkP;
145 											pLinkP->pLink = this;
146 										}
147 									}
148 
149 			void				UnLink()
150 									{
151 										if ( pLink )
152 										{
153 											pLink->pLink = NULL;
154 											pLink = NULL;
155 										}
156 									}
157 
158 			void				Remove()
159 									{
160 										if ( ppPrev )
161 										{
162                                             if ( ( *ppPrev = pNext ) != NULL )
163 												pNext->ppPrev = ppPrev;
164 											ppPrev = NULL;	// not inserted
165 										}
166 									}
167 
168 			void				Insert( ScChangeActionLinkEntry** ppPrevP )
169 									{
170 										if ( !ppPrev )
171 										{
172 											ppPrev = ppPrevP;
173 											if ( (pNext = *ppPrevP) )
174 												pNext->ppPrev = &pNext;
175 											*ppPrevP = this;
176 										}
177 									}
178 
179 	const ScChangeActionLinkEntry*	GetLink() const		{ return pLink; }
180 	ScChangeActionLinkEntry*		GetLink()			{ return pLink; }
181 	const ScChangeActionLinkEntry*	GetNext() const		{ return pNext; }
182 	ScChangeActionLinkEntry*		GetNext()			{ return pNext; }
183 	const ScChangeAction*			GetAction() const	{ return pAction; }
184 	ScChangeAction*					GetAction()			{ return pAction; }
185 #if DEBUG_CHANGETRACK
186     String                          ToString() const;
187 #endif // DEBUG_CHANGETRACK
188 };
189 
190 // --- ScChangeActionCellListEntry -----------------------------------------
191 // this is only for the XML Export in the hxx
192 class ScChangeActionContent;
193 
194 class ScChangeActionCellListEntry
195 {
196 	friend class ScChangeAction;
197 	friend class ScChangeActionDel;
198 	friend class ScChangeActionMove;
199 	friend class ScChangeTrack;
200 
201 			ScChangeActionCellListEntry*	pNext;
202 			ScChangeActionContent*			pContent;
203 
204 								ScChangeActionCellListEntry(
205 									ScChangeActionContent* pContentP,
206 									ScChangeActionCellListEntry* pNextP )
207 									:	pNext( pNextP ),
208 										pContent( pContentP )
209 									{}
210 
211 public:
212 	const ScChangeActionCellListEntry* GetNext() const { return pNext; } // this is only for the XML Export public
213 	const ScChangeActionContent* GetContent() const { return pContent; } // this is only for the XML Export public
214 
215 	DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry )
216 };
217 
218 // --- ScChangeAction -------------------------------------------------------
219 
220 class ScChangeTrack;
221 class ScChangeActionIns;
222 class ScChangeActionDel;
223 class ScChangeActionContent;
224 
225 class ScChangeAction
226 {
227 	friend class ScChangeTrack;
228 	friend class ScChangeActionIns;
229 	friend class ScChangeActionDel;
230 	friend class ScChangeActionMove;
231 	friend class ScChangeActionContent;
232 
233 								// not implemented, prevent usage
234 								ScChangeAction( const ScChangeAction& );
235 			ScChangeAction&		operator=( const ScChangeAction& );
236 
237 protected:
238 
239 			ScBigRange	  		aBigRange;		 	// Ins/Del/MoveTo/ContentPos
240 			DateTime			aDateTime;			//! UTC
241 			String				aUser;				// wer war's
242 			String				aComment;			// Benutzerkommentar
243 			ScChangeAction*		pNext;				// naechster in Kette
244 			ScChangeAction*		pPrev;				// vorheriger in Kette
245 			ScChangeActionLinkEntry*	pLinkAny;	// irgendwelche Links
246 			ScChangeActionLinkEntry*	pLinkDeletedIn;	// Zuordnung zu
247 													// geloeschten oder
248 													// druebergemoveten oder
249 													// rejecteten Insert
250 													// Bereichen
251 			ScChangeActionLinkEntry*	pLinkDeleted;	// Links zu geloeschten
252 			ScChangeActionLinkEntry*	pLinkDependent;	// Links zu abhaengigen
253 			sal_uLong				nAction;
254 			sal_uLong				nRejectAction;
255 			ScChangeActionType	eType;
256 			ScChangeActionState	eState;
257 
258 
259 								ScChangeAction( ScChangeActionType,
260 												const ScRange& );
261 
262 								// only to be used in the XML import
263 								ScChangeAction( ScChangeActionType,
264 												const ScBigRange&,
265 												const sal_uLong nAction,
266 												const sal_uLong nRejectAction,
267 												const ScChangeActionState eState,
268 												const DateTime& aDateTime,
269 												const String& aUser,
270 												const String& aComment );
271 								// only to be used in the XML import
272 								ScChangeAction( ScChangeActionType,
273 												const ScBigRange&,
274 												const sal_uLong nAction);
275 
276 	virtual						~ScChangeAction();
277 
278 			String				GetRefString( const ScBigRange&,
279 									ScDocument*, sal_Bool bFlag3D = sal_False ) const;
280 
281 			void				SetActionNumber( sal_uLong n ) { nAction = n; }
282 			void				SetRejectAction( sal_uLong n ) { nRejectAction = n; }
283 			void				SetUser( const String& r ) { aUser = r; }
284 			void				SetType( ScChangeActionType e ) { eType = e; }
285 			void				SetState( ScChangeActionState e ) { eState = e; }
286 			void				SetRejected();
287 
288 			ScBigRange& 		GetBigRange() { return aBigRange; }
289 
290 			ScChangeActionLinkEntry*	AddLink( ScChangeAction* p,
291 											ScChangeActionLinkEntry* pL )
292 									{
293 										ScChangeActionLinkEntry* pLnk =
294 											new ScChangeActionLinkEntry(
295 											&pLinkAny, p );
296 										pLnk->SetLink( pL );
297 										return pLnk;
298 									}
299 			void				RemoveAllAnyLinks();
300 
301 	virtual	ScChangeActionLinkEntry*	GetDeletedIn() const
302 											{ return pLinkDeletedIn; }
303 	virtual	ScChangeActionLinkEntry**	GetDeletedInAddress()
304 											{ return &pLinkDeletedIn; }
305 			ScChangeActionLinkEntry*	AddDeletedIn( ScChangeAction* p )
306 									{
307 										return new ScChangeActionLinkEntry(
308 											GetDeletedInAddress(), p );
309 									}
310 			sal_Bool				RemoveDeletedIn( const ScChangeAction* );
311 			void				SetDeletedIn( ScChangeAction* );
312 
313 			ScChangeActionLinkEntry*	AddDeleted( ScChangeAction* p )
314 									{
315 										return new ScChangeActionLinkEntry(
316 											&pLinkDeleted, p );
317 									}
318 			void				RemoveAllDeleted();
319 
320 			ScChangeActionLinkEntry*	AddDependent( ScChangeAction* p )
321 									{
322 										return new ScChangeActionLinkEntry(
323 											&pLinkDependent, p );
324 									}
325 			void				RemoveAllDependent();
326 
327 			void				RemoveAllLinks();
328 
329 	virtual	void				AddContent( ScChangeActionContent* ) = 0;
330 	virtual	void				DeleteCellEntries() = 0;
331 
332 	virtual	void 				UpdateReference( const ScChangeTrack*,
333 									UpdateRefMode, const ScBigRange&,
334 									sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz );
335 
336 			void				Accept();
337 	virtual	sal_Bool				Reject( ScDocument* ) = 0;
338 			void				RejectRestoreContents( ScChangeTrack*,
339 									SCsCOL nDx, SCsROW nDy );
340 
341 								// used in Reject() instead of IsRejectable()
342 			sal_Bool				IsInternalRejectable() const;
343 
344                                 // Derived classes that hold a pointer to the
345                                 // ChangeTrack must return that. Otherwise NULL.
346     virtual const ScChangeTrack*    GetChangeTrack() const = 0;
347 
348 public:
349 
350 			sal_Bool				IsInsertType() const
351 									{
352 										return eType == SC_CAT_INSERT_COLS ||
353 											eType == SC_CAT_INSERT_ROWS ||
354 											eType == SC_CAT_INSERT_TABS;
355 									}
356 			sal_Bool				IsDeleteType() const
357 									{
358 										return eType == SC_CAT_DELETE_COLS ||
359 											eType == SC_CAT_DELETE_ROWS ||
360 											eType == SC_CAT_DELETE_TABS;
361 									}
362 			sal_Bool				IsVirgin() const
363 									{ return eState == SC_CAS_VIRGIN; }
364 			sal_Bool				IsAccepted() const
365 									{ return eState == SC_CAS_ACCEPTED; }
366 			sal_Bool				IsRejected() const
367 									{ return eState == SC_CAS_REJECTED; }
368 
369 								// Action rejects another Action
370 			sal_Bool				IsRejecting() const
371 									{ return nRejectAction != 0; }
372 
373 								// ob Action im Dokument sichtbar ist
374 			sal_Bool				IsVisible() const;
375 
376 								// ob Action anfassbar ist
377 			sal_Bool				IsTouchable() const;
378 
379 								// ob Action ein Eintrag in Dialog-Root ist
380 			sal_Bool				IsDialogRoot() const;
381 
382 								// ob ein Eintrag im Dialog aufklappbar sein soll
383 			sal_Bool				IsDialogParent() const;
384 
385 								// ob Action ein Delete ist, unter dem
386 								// aufgeklappt mehrere einzelne Deletes sind
387 			sal_Bool				IsMasterDelete() const;
388 
389 								// ob Action akzeptiert/selektiert/abgelehnt
390 								// werden kann
391 			sal_Bool				IsClickable() const;
392 
393 								// ob Action abgelehnt werden kann
394 			sal_Bool				IsRejectable() const;
395 
396 			const ScBigRange& 	GetBigRange() const { return aBigRange; }
397 			SC_DLLPUBLIC DateTime			GetDateTime() const;		// local time
398 			const DateTime&		GetDateTimeUTC() const		// UTC time
399 									{ return aDateTime; }
400 			const String&		GetUser() const { return aUser; }
401 			const String&		GetComment() const { return aComment; }
402 			ScChangeActionType	GetType() const { return eType; }
403 			ScChangeActionState	GetState() const { return eState; }
404 			sal_uLong				GetActionNumber() const { return nAction; }
405 			sal_uLong				GetRejectAction() const { return nRejectAction; }
406 
407 			ScChangeAction*		GetNext() const { return pNext; }
408 			ScChangeAction*		GetPrev() const { return pPrev; }
409 
410 			sal_Bool				IsDeletedIn() const
411 									{ return GetDeletedIn() != NULL; }
412 			sal_Bool				IsDeleted() const
413 									{ return IsDeleteType() || IsDeletedIn(); }
414 			sal_Bool				IsDeletedIn( const ScChangeAction* ) const;
415 			sal_Bool				IsDeletedInDelType( ScChangeActionType ) const;
416             void                RemoveAllDeletedIn();
417 
418 			const ScChangeActionLinkEntry* GetFirstDeletedEntry() const
419 									{ return pLinkDeleted; }
420 			const ScChangeActionLinkEntry* GetFirstDependentEntry() const
421 									{ return pLinkDependent; }
422 			sal_Bool				HasDependent() const
423 									{ return pLinkDependent != NULL; }
424 			sal_Bool				HasDeleted() const
425 									{ return pLinkDeleted != NULL; }
426 
427 								// Description wird an String angehaengt.
428 								// Mit bSplitRange wird bei Delete nur
429 								// eine Spalte/Zeile beruecksichtigt (fuer
430 								// Auflistung der einzelnen Eintraege).
431 	virtual	void				GetDescription( String&, ScDocument*,
432 									sal_Bool bSplitRange = sal_False, bool bWarning = true ) const;
433 
434 	virtual void				GetRefString( String&, ScDocument*,
435 									sal_Bool bFlag3D = sal_False ) const;
436 
437 								// fuer DocumentMerge altes Datum einer anderen
438 								// Action setzen, mit GetDateTimeUTC geholt
439 			void				SetDateTimeUTC( const DateTime& rDT )
440 									{ aDateTime = rDT; }
441 
442 								// Benutzerkommentar setzen
443 			void				SetComment( const String& rStr )
444 									{ aComment = rStr; }
445 
446 								// only to be used in the XML import
447 			void				SetDeletedInThis( sal_uLong nActionNumber,
448 										const ScChangeTrack* pTrack );
449 								// only to be used in the XML import
450 			void				AddDependent( sal_uLong nActionNumber,
451 										const ScChangeTrack* pTrack );
452 #if DEBUG_CHANGETRACK
453             String              ToString( ScDocument* pDoc ) const;
454 #endif // DEBUG_CHANGETRACK
455 };
456 
457 
458 // --- ScChangeActionIns ----------------------------------------------------
459 
460 class ScChangeActionIns : public ScChangeAction
461 {
462 	friend class ScChangeTrack;
463 
464 								ScChangeActionIns( const ScRange& rRange );
465 	virtual						~ScChangeActionIns();
466 
467 	virtual	void				AddContent( ScChangeActionContent* ) {}
468 	virtual	void				DeleteCellEntries() {}
469 
470 	virtual	sal_Bool				Reject( ScDocument* );
471 
472     virtual const ScChangeTrack*    GetChangeTrack() const { return 0; }
473 
474 public:
475 								ScChangeActionIns(const sal_uLong nActionNumber,
476 										const ScChangeActionState eState,
477 										const sal_uLong nRejectingNumber,
478 										const ScBigRange& aBigRange,
479 										const String& aUser,
480 										const DateTime& aDateTime,
481 										const String &sComment,
482 										const ScChangeActionType eType); // only to use in the XML import
483 
484 	virtual	void				GetDescription( String&, ScDocument*,
485 									sal_Bool bSplitRange = sal_False, bool bWarning = true ) const;
486 };
487 
488 
489 // --- ScChangeActionDel ----------------------------------------------------
490 
491 class ScChangeActionMove;
492 
493 class ScChangeActionDelMoveEntry : public ScChangeActionLinkEntry
494 {
495 	friend class ScChangeActionDel;
496 	friend class ScChangeTrack;
497 
498 			short		   		nCutOffFrom;
499 			short		   		nCutOffTo;
500 
501 
502 								ScChangeActionDelMoveEntry(
503                                     ScChangeActionDelMoveEntry** ppPrevP,
504 									ScChangeActionMove* pMove,
505 									short nFrom, short nTo )
506 									:	ScChangeActionLinkEntry(
507 											(ScChangeActionLinkEntry**)
508                                                 ppPrevP,
509 											(ScChangeAction*) pMove ),
510 										nCutOffFrom( nFrom ),
511 										nCutOffTo( nTo )
512 									{}
513 
514 			ScChangeActionDelMoveEntry*	GetNext()
515 									{
516 										return (ScChangeActionDelMoveEntry*)
517 										ScChangeActionLinkEntry::GetNext();
518 									}
519 			ScChangeActionMove*	GetMove()
520 									{
521 										return (ScChangeActionMove*)
522 										ScChangeActionLinkEntry::GetAction();
523 									}
524 
525 public:
526 			const ScChangeActionDelMoveEntry*	GetNext() const
527 									{
528 										return (const ScChangeActionDelMoveEntry*)
529 										ScChangeActionLinkEntry::GetNext();
530 									}
531 			const ScChangeActionMove*	GetMove() const
532 									{
533 										return (const ScChangeActionMove*)
534 										ScChangeActionLinkEntry::GetAction();
535 									}
536 			short				GetCutOffFrom() const { return nCutOffFrom; }
537 			short				GetCutOffTo() const { return nCutOffTo; }
538 };
539 
540 
541 class ScChangeActionDel : public ScChangeAction
542 {
543 	friend class ScChangeTrack;
544 	friend void ScChangeAction::Accept();
545 
546 			ScChangeTrack*		pTrack;
547 			ScChangeActionCellListEntry* pFirstCell;
548 			ScChangeActionIns*	pCutOff;		// abgeschnittener Insert
549 			short				nCutOff;		// +: Start  -: End
550 			ScChangeActionDelMoveEntry* pLinkMove;
551 			SCsCOL				nDx;
552 			SCsROW				nDy;
553 
554 								ScChangeActionDel( const ScRange& rRange,
555 									SCsCOL nDx, SCsROW nDy, ScChangeTrack* );
556 	virtual						~ScChangeActionDel();
557 
558 			ScChangeActionIns*	GetCutOffInsert() { return pCutOff; }
559 
560 	virtual	void				AddContent( ScChangeActionContent* );
561 	virtual	void				DeleteCellEntries();
562 
563 			void				UndoCutOffMoves();
564 			void				UndoCutOffInsert();
565 
566 	virtual	void 				UpdateReference( const ScChangeTrack*,
567 									UpdateRefMode, const ScBigRange&,
568 									sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz );
569 
570 	virtual	sal_Bool				Reject( ScDocument* );
571 
572     virtual const ScChangeTrack*    GetChangeTrack() const { return pTrack; }
573 
574 public:
575 								ScChangeActionDel(const sal_uLong nActionNumber,
576 												const ScChangeActionState eState,
577 												const sal_uLong nRejectingNumber,
578 												const ScBigRange& aBigRange,
579 												const String& aUser,
580 												const DateTime& aDateTime,
581 												const String &sComment,
582 												const ScChangeActionType eType,
583 												const SCsCOLROW nD,
584 												ScChangeTrack* pTrack); // only to use in the XML import
585 																		// wich of nDx and nDy is set is depend on the type
586 
587 								// ob dieses das unterste einer Reihe (oder
588 								// auch einzeln) ist
589 			sal_Bool				IsBaseDelete() const;
590 
591 								// ob dieses das oberste einer Reihe (oder
592 								// auch einzeln) ist
593 			sal_Bool				IsTopDelete() const;
594 
595 								// ob dieses ein Teil einer Reihe ist
596 			sal_Bool				IsMultiDelete() const;
597 
598 								// ob es eine Col ist, die zu einem TabDelete gehoert
599 			sal_Bool				IsTabDeleteCol() const;
600 
601 			SCsCOL				GetDx() const { return nDx; }
602 			SCsROW				GetDy() const { return nDy; }
603 			ScBigRange			GetOverAllRange() const;	// BigRange + (nDx, nDy)
604 
605 			const ScChangeActionCellListEntry* GetFirstCellEntry() const
606 									{ return pFirstCell; }
607 			const ScChangeActionDelMoveEntry* GetFirstMoveEntry() const
608 									{ return pLinkMove; }
609 			const ScChangeActionIns*	GetCutOffInsert() const { return pCutOff; }
610 			short				GetCutOffCount() const { return nCutOff; }
611 
612 	virtual	void				GetDescription( String&, ScDocument*,
613 									sal_Bool bSplitRange = sal_False, bool bWarning = true ) const;
614 			void				SetCutOffInsert( ScChangeActionIns* p, short n )
615 									{ pCutOff = p; nCutOff = n; }	// only to use in the XML import
616 																	// this should be protected, but for the XML import it is public
617 			// only to use in the XML import
618 			// this should be protected, but for the XML import it is public
619 			ScChangeActionDelMoveEntry*	AddCutOffMove( ScChangeActionMove* pMove,
620 										short nFrom, short nTo )
621 									{
622 										return new ScChangeActionDelMoveEntry(
623 										&pLinkMove, pMove, nFrom, nTo );
624 									}
625 };
626 
627 
628 // --- ScChangeActionMove ---------------------------------------------------
629 
630 class ScChangeActionMove : public ScChangeAction
631 {
632 	friend class ScChangeTrack;
633 	friend class ScChangeActionDel;
634 
635 			ScBigRange			aFromRange;
636 			ScChangeTrack*		pTrack;
637 			ScChangeActionCellListEntry* pFirstCell;
638 			sal_uLong				nStartLastCut;	// fuer PasteCut Undo
639 			sal_uLong				nEndLastCut;
640 
641 								ScChangeActionMove( const ScRange& rFromRange,
642 									const ScRange& rToRange,
643 									ScChangeTrack* pTrackP )
644 									: ScChangeAction( SC_CAT_MOVE, rToRange ),
645 										aFromRange( rFromRange ),
646 										pTrack( pTrackP ),
647 										pFirstCell( NULL ),
648 										nStartLastCut(0),
649 										nEndLastCut(0)
650 									{}
651 	virtual						~ScChangeActionMove();
652 
653 	virtual	void				AddContent( ScChangeActionContent* );
654 	virtual	void				DeleteCellEntries();
655 
656 			ScBigRange&			GetFromRange() { return aFromRange; }
657 
658 			void				SetStartLastCut( sal_uLong nVal ) { nStartLastCut = nVal; }
659 			sal_uLong				GetStartLastCut() const { return nStartLastCut; }
660 			void				SetEndLastCut( sal_uLong nVal )	{ nEndLastCut = nVal; }
661 			sal_uLong				GetEndLastCut() const { return nEndLastCut; }
662 
663 	virtual	void 				UpdateReference( const ScChangeTrack*,
664 									UpdateRefMode, const ScBigRange&,
665 									sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz );
666 
667 	virtual	sal_Bool				Reject( ScDocument* );
668 
669     virtual const ScChangeTrack*    GetChangeTrack() const { return pTrack; }
670 
671 protected:
672     using ScChangeAction::GetRefString;
673 
674 public:
675 								ScChangeActionMove(const sal_uLong nActionNumber,
676 												const ScChangeActionState eState,
677 												const sal_uLong nRejectingNumber,
678 												const ScBigRange& aToBigRange,
679 												const String& aUser,
680 												const DateTime& aDateTime,
681 												const String &sComment,
682 												const ScBigRange& aFromBigRange,
683 												ScChangeTrack* pTrack); // only to use in the XML import
684 			const ScChangeActionCellListEntry* GetFirstCellEntry() const
685 									{ return pFirstCell; } // only to use in the XML export
686 
687 			const ScBigRange&	GetFromRange() const { return aFromRange; }
688 	SC_DLLPUBLIC		void				GetDelta( sal_Int32& nDx, sal_Int32& nDy, sal_Int32& nDz ) const;
689 
690 	virtual	void				GetDescription( String&, ScDocument*,
691 									sal_Bool bSplitRange = sal_False, bool bWarning = true ) const;
692 
693 	virtual void				GetRefString( String&, ScDocument*,
694 									sal_Bool bFlag3D = sal_False ) const;
695 };
696 
697 
698 // --- ScChangeActionContent ------------------------------------------------
699 
700 enum ScChangeActionContentCellType
701 {
702 	SC_CACCT_NONE = 0,
703 	SC_CACCT_NORMAL,
704 	SC_CACCT_MATORG,
705 	SC_CACCT_MATREF
706 };
707 
708 class Stack;
709 
710 class ScChangeActionContent : public ScChangeAction
711 {
712 	friend class ScChangeTrack;
713 
714 			String				aOldValue;
715 			String				aNewValue;
716 			ScBaseCell*			pOldCell;
717 			ScBaseCell*			pNewCell;
718 		ScChangeActionContent*	pNextContent;	// an gleicher Position
719 		ScChangeActionContent*	pPrevContent;
720 		ScChangeActionContent*	pNextInSlot;	// in gleichem Slot
721 		ScChangeActionContent**	ppPrevInSlot;
722 
723 			void				InsertInSlot( ScChangeActionContent** pp )
724 									{
725 										if ( !ppPrevInSlot )
726 										{
727 											ppPrevInSlot = pp;
728                                             if ( ( pNextInSlot = *pp ) != NULL )
729 												pNextInSlot->ppPrevInSlot = &pNextInSlot;
730 											*pp = this;
731 										}
732 									}
733 			void				RemoveFromSlot()
734 									{
735 										if ( ppPrevInSlot )
736 										{
737                                             if ( ( *ppPrevInSlot = pNextInSlot ) != NULL )
738 												pNextInSlot->ppPrevInSlot = ppPrevInSlot;
739 											ppPrevInSlot = NULL;	// not inserted
740 										}
741 									}
742 		ScChangeActionContent*	GetNextInSlot() { return pNextInSlot; }
743 
744 			void				ClearTrack();
745 
746 	static	void				GetStringOfCell( String& rStr,
747 									const ScBaseCell* pCell,
748 									const ScDocument* pDoc,
749 									const ScAddress& rPos );
750 
751 	static	void				GetStringOfCell( String& rStr,
752 									const ScBaseCell* pCell,
753 									const ScDocument* pDoc,
754 									sal_uLong nFormat );
755 
756 	static	void				SetValue( String& rStr, ScBaseCell*& pCell,
757 									const ScAddress& rPos,
758 									const ScBaseCell* pOrgCell,
759 									const ScDocument* pFromDoc,
760 									ScDocument* pToDoc );
761 
762 	static	void				SetValue( String& rStr, ScBaseCell*& pCell,
763 									sal_uLong nFormat,
764 									const ScBaseCell* pOrgCell,
765 									const ScDocument* pFromDoc,
766 									ScDocument* pToDoc );
767 
768 	static	void				SetCell( String& rStr, ScBaseCell* pCell,
769 									sal_uLong nFormat, const ScDocument* pDoc );
770 
771 	static	sal_Bool				NeedsNumberFormat( const ScBaseCell* );
772 
773 			void				SetValueString( String& rValue,
774 									ScBaseCell*& pCell,	const String& rStr,
775 									ScDocument* pDoc );
776 
777 			void				GetValueString( String& rStr,
778 									const String& rValue,
779 									const ScBaseCell* pCell ) const;
780 
781 			void				GetFormulaString( String& rStr,
782 									const ScFormulaCell* pCell ) const;
783 
784 	virtual	void				AddContent( ScChangeActionContent* ) {}
785 	virtual	void				DeleteCellEntries() {}
786 
787 	virtual	void 				UpdateReference( const ScChangeTrack*,
788 									UpdateRefMode, const ScBigRange&,
789 									sal_Int32 nDx, sal_Int32 nDy, sal_Int32 nDz );
790 
791 	virtual	sal_Bool				Reject( ScDocument* );
792 
793     virtual const ScChangeTrack*    GetChangeTrack() const { return 0; }
794 
795 								// pRejectActions!=NULL: reject actions get
796 								// stacked, no SetNewValue, no Append
797 			sal_Bool				Select( ScDocument*, ScChangeTrack*,
798 									sal_Bool bOldest, Stack* pRejectActions );
799 
800 			void				PutValueToDoc( ScBaseCell*, const String&,
801 									ScDocument*, SCsCOL nDx, SCsROW nDy ) const;
802 
803 protected:
804     using ScChangeAction::GetRefString;
805 
806 public:
807 
808 	DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionContent )
809 
810 								ScChangeActionContent( const ScRange& rRange )
811 									: ScChangeAction( SC_CAT_CONTENT, rRange ),
812 										pOldCell( NULL ),
813 										pNewCell( NULL ),
814 										pNextContent( NULL ),
815 										pPrevContent( NULL ),
816 										pNextInSlot( NULL ),
817 										ppPrevInSlot( NULL )
818 									{}
819 								ScChangeActionContent(const sal_uLong nActionNumber,
820 												const ScChangeActionState eState,
821 												const sal_uLong nRejectingNumber,
822 												const ScBigRange& aBigRange,
823 												const String& aUser,
824 												const DateTime& aDateTime,
825 												const String &sComment,
826 												ScBaseCell* pOldCell,
827 												ScDocument* pDoc,
828 												const String& sOldValue); // to use for XML Import
829 								ScChangeActionContent(const sal_uLong nActionNumber,
830 												ScBaseCell* pNewCell,
831 												const ScBigRange& aBigRange,
832 												ScDocument* pDoc,
833                                                 const String& sNewValue); // to use for XML Import of Generated Actions
834 	virtual						~ScChangeActionContent();
835 
836 		ScChangeActionContent*	GetNextContent() const { return pNextContent; }
837 		ScChangeActionContent*	GetPrevContent() const { return pPrevContent; }
838 		ScChangeActionContent*	GetTopContent() const;
839 			sal_Bool				IsTopContent() const
840 									{ return pNextContent == NULL; }
841 
842 	virtual	ScChangeActionLinkEntry*  	GetDeletedIn() const;
843 	virtual	ScChangeActionLinkEntry**	GetDeletedInAddress();
844 
845 			void				PutOldValueToDoc( ScDocument*,
846 									SCsCOL nDx, SCsROW nDy ) const;
847 			void				PutNewValueToDoc( ScDocument*,
848 									SCsCOL nDx, SCsROW nDy ) const;
849 
850 			void				SetOldValue( const ScBaseCell*,
851 									const ScDocument* pFromDoc,
852 									ScDocument* pToDoc,
853 									sal_uLong nFormat );
854 			void				SetOldValue( const ScBaseCell*,
855 									const ScDocument* pFromDoc,
856 									ScDocument* pToDoc );
857 			void				SetNewValue( const ScBaseCell*,	ScDocument* );
858 
859 								// Used in import filter AppendContentOnTheFly,
860 								// takes ownership of cells.
861 			void				SetOldNewCells( ScBaseCell* pOldCell,
862 									sal_uLong nOldFormat, ScBaseCell* pNewCell,
863 									sal_uLong nNewFormat, ScDocument* pDoc );
864 
865 								// Use this only in the XML import,
866 								// takes ownership of cell.
867 			void				SetNewCell( ScBaseCell* pCell, ScDocument* pDoc, const String& rFormatted );
868 
869 								// These functions should be protected but for
870 								// the XML import they are public.
871 			void				SetNextContent( ScChangeActionContent* p )
872 									{ pNextContent = p; }
873 			void				SetPrevContent( ScChangeActionContent* p )
874 									{ pPrevContent = p; }
875 
876 								// moeglichst nicht verwenden,
877 								// setzt nur String bzw. generiert Formelzelle
878 			void				SetOldValue( const String& rOld, ScDocument* );
879 			void				SetNewValue( const String& rNew, ScDocument* );
880 
881 			void				GetOldString( String& ) const;
882 			void				GetNewString( String& ) const;
883 			const ScBaseCell*	GetOldCell() const { return pOldCell; }
884 			const ScBaseCell*	GetNewCell() const { return pNewCell; }
885 	virtual	void				GetDescription( String&, ScDocument*,
886 									sal_Bool bSplitRange = sal_False, bool bWarning = true ) const;
887 	virtual void				GetRefString( String&, ScDocument*,
888 									sal_Bool bFlag3D = sal_False ) const;
889 
890 	static	ScChangeActionContentCellType	GetContentCellType( const ScBaseCell* );
891 
892 								// NewCell
893 			sal_Bool				IsMatrixOrigin() const
894 									{
895 										return GetContentCellType( GetNewCell() )
896 											== SC_CACCT_MATORG;
897 									}
898 			sal_Bool				IsMatrixReference() const
899 									{
900 										return GetContentCellType( GetNewCell() )
901 											== SC_CACCT_MATREF;
902 									}
903 								// OldCell
904 			sal_Bool				IsOldMatrixOrigin() const
905 									{
906 										return GetContentCellType( GetOldCell() )
907 											== SC_CACCT_MATORG;
908 									}
909 			sal_Bool				IsOldMatrixReference() const
910 									{
911 										return GetContentCellType( GetOldCell() )
912 											== SC_CACCT_MATREF;
913 									}
914 
915 };
916 
917 
918 // --- ScChangeActionReject -------------------------------------------------
919 
920 class Stack;
921 
922 class ScChangeActionReject : public ScChangeAction
923 {
924 	friend class ScChangeTrack;
925 	friend class ScChangeActionContent;
926 
927 								ScChangeActionReject( sal_uLong nReject )
928 									: ScChangeAction( SC_CAT_REJECT, ScRange() )
929 									{
930 										SetRejectAction( nReject );
931 										SetState( SC_CAS_ACCEPTED );
932 									}
933 
934 	virtual	void				AddContent( ScChangeActionContent* ) {}
935 	virtual	void				DeleteCellEntries() {}
936 
937 	virtual	sal_Bool				Reject( ScDocument* ) { return sal_False; }
938 
939     virtual const ScChangeTrack*    GetChangeTrack() const { return 0; }
940 
941 public:
942 								ScChangeActionReject(const sal_uLong nActionNumber,
943 												const ScChangeActionState eState,
944 												const sal_uLong nRejectingNumber,
945 												const ScBigRange& aBigRange,
946 												const String& aUser,
947 												const DateTime& aDateTime,
948 												const String &sComment); // only to use in the XML import
949 };
950 
951 
952 // --- ScChangeTrack --------------------------------------------------------
953 
954 enum ScChangeTrackMsgType
955 {
956 	SC_CTM_NONE,
957 	SC_CTM_APPEND,		// Actions angehaengt
958 	SC_CTM_REMOVE,		// Actions weggenommen
959 	SC_CTM_CHANGE,		// Actions geaendert
960 	SC_CTM_PARENT		// war kein Parent und ist jetzt einer
961 };
962 
963 struct ScChangeTrackMsgInfo
964 {
965 	DECL_FIXEDMEMPOOL_NEWDEL( ScChangeTrackMsgInfo )
966 
967 	ScChangeTrackMsgType	eMsgType;
968 	sal_uLong					nStartAction;
969 	sal_uLong					nEndAction;
970 };
971 
972 // MsgQueue fuer Benachrichtigung via ModifiedLink
973 DECLARE_QUEUE( ScChangeTrackMsgQueue, ScChangeTrackMsgInfo* )
974 DECLARE_STACK( ScChangeTrackMsgStack, ScChangeTrackMsgInfo* )
975 
976 enum ScChangeTrackMergeState
977 {
978 	SC_CTMS_NONE,
979 	SC_CTMS_PREPARE,
980 	SC_CTMS_OWN,
981     SC_CTMS_UNDO,
982 	SC_CTMS_OTHER
983 };
984 
985 // zusaetzlich zu pFirst/pNext/pLast/pPrev eine Table, um schnell sowohl
986 // per ActionNumber als auch ueber Liste zugreifen zu koennen
987 DECLARE_TABLE( ScChangeActionTable, ScChangeAction* )
988 
989 // Intern generierte Actions beginnen bei diesem Wert (fast alle Bits gesetzt)
990 // und werden runtergezaehlt, um sich in einer Table wertemaessig nicht mit den
991 // "normalen" Actions in die Quere zu kommen.
992 #define SC_CHGTRACK_GENERATED_START	((sal_uInt32) 0xfffffff0)
993 
994 class ScChangeTrack : public utl::ConfigurationListener
995 {
996 	friend void ScChangeAction::RejectRestoreContents( ScChangeTrack*, SCsCOL, SCsROW );
997 	friend sal_Bool ScChangeActionDel::Reject( ScDocument* pDoc );
998 	friend void ScChangeActionDel::DeleteCellEntries();
999 	friend void ScChangeActionMove::DeleteCellEntries();
1000 	friend sal_Bool ScChangeActionMove::Reject( ScDocument* pDoc );
1001 
1002     static	const SCROW         nContentRowsPerSlot;
1003     static	const SCSIZE        nContentSlots;
1004 
1005 	com::sun::star::uno::Sequence< sal_Int8 >	aProtectPass;
1006 			ScChangeActionTable	aTable;
1007 			ScChangeActionTable	aGeneratedTable;
1008 			ScChangeActionTable	aPasteCutTable;
1009 		ScChangeTrackMsgQueue	aMsgQueue;
1010 		ScChangeTrackMsgStack	aMsgStackTmp;
1011 		ScChangeTrackMsgStack	aMsgStackFinal;
1012 			ScStrCollection		aUserCollection;
1013 			String				aUser;
1014 			Link				aModifiedLink;
1015 			ScRange				aInDeleteRange;
1016 			DateTime			aFixDateTime;
1017 			ScChangeAction*		pFirst;
1018 			ScChangeAction*		pLast;
1019 		ScChangeActionContent*	pFirstGeneratedDelContent;
1020 		ScChangeActionContent**	ppContentSlots;
1021 		ScChangeActionMove*		pLastCutMove;
1022 	ScChangeActionLinkEntry*	pLinkInsertCol;
1023 	ScChangeActionLinkEntry*	pLinkInsertRow;
1024 	ScChangeActionLinkEntry*	pLinkInsertTab;
1025 	ScChangeActionLinkEntry*	pLinkMove;
1026 		ScChangeTrackMsgInfo*	pBlockModifyMsg;
1027 			ScDocument*			pDoc;
1028 			sal_uLong				nActionMax;
1029 			sal_uLong				nGeneratedMin;
1030 			sal_uLong				nMarkLastSaved;
1031 			sal_uLong				nStartLastCut;
1032 			sal_uLong				nEndLastCut;
1033 			sal_uLong				nLastMerge;
1034 		ScChangeTrackMergeState	eMergeState;
1035 			sal_uInt16				nLoadedFileFormatVersion;
1036 			sal_Bool				bLoadSave;
1037 			sal_Bool				bInDelete;
1038 			sal_Bool				bInDeleteUndo;
1039 			sal_Bool				bInDeleteTop;
1040 			sal_Bool				bInPasteCut;
1041 			sal_Bool				bUseFixDateTime;
1042             sal_Bool                bTime100thSeconds;
1043 
1044 								// not implemented, prevent usage
1045 								ScChangeTrack( const ScChangeTrack& );
1046 			ScChangeTrack&		operator=( const ScChangeTrack& );
1047 
1048 #ifdef SC_CHGTRACK_CXX
1049 	static	SCROW				InitContentRowsPerSlot();
1050 
1051 								// sal_True if one is MM_FORMULA and the other is
1052 								// not, or if both are and range differs
1053 	static	sal_Bool				IsMatrixFormulaRangeDifferent(
1054 									const ScBaseCell* pOldCell,
1055 									const ScBaseCell* pNewCell );
1056 
1057 			void				Init();
1058 			void				DtorClear();
1059 			void				SetLoadSave( sal_Bool bVal ) { bLoadSave = bVal; }
1060 			void				SetInDeleteRange( const ScRange& rRange )
1061 									{ aInDeleteRange = rRange; }
1062 			void				SetInDelete( sal_Bool bVal )
1063 									{ bInDelete = bVal; }
1064 			void				SetInDeleteTop( sal_Bool bVal )
1065 									{ bInDeleteTop = bVal; }
1066 			void				SetInDeleteUndo( sal_Bool bVal )
1067 									{ bInDeleteUndo = bVal; }
1068 			void				SetInPasteCut( sal_Bool bVal )
1069 									{ bInPasteCut = bVal; }
1070 			void				SetMergeState( ScChangeTrackMergeState eState )
1071 									{ eMergeState = eState; }
1072 		ScChangeTrackMergeState	GetMergeState() const { return eMergeState; }
1073 			void				SetLastMerge( sal_uLong nVal ) { nLastMerge = nVal; }
1074 			sal_uLong				GetLastMerge() const { return nLastMerge; }
1075 
1076 			void				SetLastCutMoveRange( const ScRange&, ScDocument* );
1077 
1078 								// ModifyMsg blockweise und nicht einzeln erzeugen
1079 			void				StartBlockModify( ScChangeTrackMsgType,
1080 									sal_uLong nStartAction );
1081 			void				EndBlockModify( sal_uLong nEndAction );
1082 
1083 			void				AddDependentWithNotify( ScChangeAction* pParent,
1084 									ScChangeAction* pDependent );
1085 
1086 			void				Dependencies( ScChangeAction* );
1087 			void				UpdateReference( ScChangeAction*, sal_Bool bUndo );
1088 			void				UpdateReference( ScChangeAction** ppFirstAction,
1089 									ScChangeAction* pAct, sal_Bool bUndo );
1090 			void				Append( ScChangeAction* pAppend, sal_uLong nAction );
1091 	SC_DLLPUBLIC		void				AppendDeleteRange( const ScRange&,
1092 									ScDocument* pRefDoc, SCsTAB nDz,
1093 									sal_uLong nRejectingInsert );
1094 			void				AppendOneDeleteRange( const ScRange& rOrgRange,
1095 									ScDocument* pRefDoc,
1096 									SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
1097 									sal_uLong nRejectingInsert );
1098 			void				LookUpContents( const ScRange& rOrgRange,
1099 									ScDocument* pRefDoc,
1100 									SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
1101 			void				Remove( ScChangeAction* );
1102 			void				MasterLinks( ScChangeAction* );
1103 
1104 								// Content on top an Position
1105 		ScChangeActionContent*	SearchContentAt( const ScBigAddress&,
1106 									ScChangeAction* pButNotThis ) const;
1107 			void				DeleteGeneratedDelContent(
1108 									ScChangeActionContent* );
1109 		ScChangeActionContent*	GenerateDelContent( const ScAddress&,
1110 									const ScBaseCell*,
1111 									const ScDocument* pFromDoc );
1112 			void				DeleteCellEntries(
1113 									ScChangeActionCellListEntry*&,
1114 									ScChangeAction* pDeletor );
1115 
1116 								// Action und alle abhaengigen rejecten,
1117 								// Table stammt aus vorherigem GetDependents,
1118 								// ist nur bei Insert und Move (MasterType)
1119 								// noetig, kann ansonsten NULL sein.
1120 								// bRecursion == Aufruf aus Reject mit Table
1121 			sal_Bool				Reject( ScChangeAction*,
1122 									ScChangeActionTable*, sal_Bool bRecursion );
1123 
1124 #endif	// SC_CHGTRACK_CXX
1125 
1126 			void				ClearMsgQueue();
1127     virtual void                ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
1128 
1129 public:
1130 
1131 	static	SCSIZE				ComputeContentSlot( sal_Int32 nRow )
1132 									{
1133 										if ( nRow < 0 || nRow > MAXROW )
1134 											return nContentSlots - 1;
1135                                         return static_cast< SCSIZE >( nRow / nContentRowsPerSlot );
1136 									}
1137 
1138             SC_DLLPUBLIC        ScChangeTrack( ScDocument* );
1139 								ScChangeTrack( ScDocument*,
1140 											const ScStrCollection& ); // only to use in the XML import
1141             SC_DLLPUBLIC virtual ~ScChangeTrack();
1142 			void				Clear();
1143 
1144 			ScChangeActionContent*	GetFirstGenerated() const { return pFirstGeneratedDelContent; }
1145 			ScChangeAction*		GetFirst() const { return pFirst; }
1146 			ScChangeAction*		GetLast() const	{ return pLast; }
1147 			sal_uLong				GetActionMax() const { return nActionMax; }
1148 			sal_Bool				IsGenerated( sal_uLong nAction ) const
1149 									{ return nAction >= nGeneratedMin; }
1150 			ScChangeAction*		GetAction( sal_uLong nAction ) const
1151 									{ return aTable.Get( nAction ); }
1152 			ScChangeAction*		GetGenerated( sal_uLong nGenerated ) const
1153 									{ return aGeneratedTable.Get( nGenerated ); }
1154 			ScChangeAction*		GetActionOrGenerated( sal_uLong nAction ) const
1155 									{
1156 										return IsGenerated( nAction ) ?
1157 											GetGenerated( nAction ) :
1158 											GetAction( nAction );
1159 									}
1160 			sal_uLong				GetLastSavedActionNumber() const
1161 									{ return nMarkLastSaved; }
1162             void                SetLastSavedActionNumber(sal_uLong nNew)
1163                                     { nMarkLastSaved = nNew; }
1164 			ScChangeAction*		GetLastSaved() const
1165 									{ return aTable.Get( nMarkLastSaved ); }
1166 		ScChangeActionContent**	GetContentSlots() const { return ppContentSlots; }
1167 
1168 			sal_Bool				IsLoadSave() const { return bLoadSave; }
1169 			const ScRange&		GetInDeleteRange() const
1170 									{ return aInDeleteRange; }
1171 			sal_Bool				IsInDelete() const { return bInDelete; }
1172 			sal_Bool				IsInDeleteTop() const { return bInDeleteTop; }
1173 			sal_Bool				IsInDeleteUndo() const { return bInDeleteUndo; }
1174 			sal_Bool				IsInPasteCut() const { return bInPasteCut; }
1175 	SC_DLLPUBLIC		void				SetUser( const String& );
1176 			const String&		GetUser() const { return aUser; }
1177 			const ScStrCollection&	GetUserCollection() const
1178 									{ return aUserCollection; }
1179 			ScDocument*			GetDocument() const { return pDoc; }
1180 								// for import filter
1181 			const DateTime&		GetFixDateTime() const { return aFixDateTime; }
1182 
1183 								// set this if the date/time set with
1184 								// SetFixDateTime...() shall be applied to
1185 								// appended actions
1186 			void				SetUseFixDateTime( sal_Bool bVal )
1187 									{ bUseFixDateTime = bVal; }
1188 								// for MergeDocument, apply original date/time as UTC
1189 			void				SetFixDateTimeUTC( const DateTime& rDT )
1190 									{ aFixDateTime = rDT; }
1191 								// for import filter, apply original date/time as local time
1192 			void				SetFixDateTimeLocal( const DateTime& rDT )
1193 									{ aFixDateTime = rDT; aFixDateTime.ConvertToUTC(); }
1194 
1195 			void				Append( ScChangeAction* );
1196 
1197 								// pRefDoc may be NULL => no lookup of contents
1198 								// => no generation of deleted contents
1199 	SC_DLLPUBLIC		void				AppendDeleteRange( const ScRange&,
1200 									ScDocument* pRefDoc,
1201 									sal_uLong& nStartAction, sal_uLong& nEndAction,
1202 									SCsTAB nDz = 0 );
1203 									// nDz: Multi-TabDel, LookUpContent ist
1204 									// um -nDz verschoben zu suchen
1205 
1206 								// nachdem neuer Wert im Dokument gesetzt wurde,
1207 								// alter Wert aus RefDoc/UndoDoc
1208 			void				AppendContent( const ScAddress& rPos,
1209 									ScDocument* pRefDoc );
1210 								// nachdem neue Werte im Dokument gesetzt wurden,
1211 								// alte Werte aus RefDoc/UndoDoc
1212 			void				AppendContentRange( const ScRange& rRange,
1213 									ScDocument* pRefDoc,
1214 									sal_uLong& nStartAction, sal_uLong& nEndAction,
1215 									ScChangeActionClipMode eMode = SC_CACM_NONE );
1216 								// nachdem neuer Wert im Dokument gesetzt wurde,
1217 								// alter Wert aus pOldCell, nOldFormat,
1218 								// RefDoc==NULL => Doc
1219 			void				AppendContent( const ScAddress& rPos,
1220 									const ScBaseCell* pOldCell,
1221 									sal_uLong nOldFormat, ScDocument* pRefDoc = NULL );
1222 								// nachdem neuer Wert im Dokument gesetzt wurde,
1223 								// alter Wert aus pOldCell, Format aus Doc
1224 			void				AppendContent( const ScAddress& rPos,
1225 									const ScBaseCell* pOldCell );
1226 								// nachdem neue Werte im Dokument gesetzt wurden,
1227 								// alte Werte aus RefDoc/UndoDoc.
1228 								// Alle Contents, wo im RefDoc eine Zelle steht.
1229 			void				AppendContentsIfInRefDoc( ScDocument* pRefDoc,
1230 									sal_uLong& nStartAction, sal_uLong& nEndAction );
1231 
1232 								// Meant for import filter, creates and inserts
1233 								// an unconditional content action of the two
1234 								// cells without querying the document, not
1235 								// even for number formats (though the number
1236 								// formatter of the document may be used).
1237 								// The action is returned and may be used to
1238 								// set user name, description, date/time et al.
1239 								// Takes ownership of the cells!
1240 	SC_DLLPUBLIC	ScChangeActionContent*	AppendContentOnTheFly( const ScAddress& rPos,
1241 									ScBaseCell* pOldCell,
1242 									ScBaseCell* pNewCell,
1243 									sal_uLong nOldFormat = 0,
1244 									sal_uLong nNewFormat = 0 );
1245 
1246 								// die folgenden beiden nur benutzen wenn's
1247 								// nicht anders geht (setzen nur String fuer
1248 								// NewValue bzw. Formelerzeugung)
1249 
1250 								// bevor neuer Wert im Dokument gesetzt wird
1251 			void				AppendContent( const ScAddress& rPos,
1252 									const String& rNewValue,
1253 									ScBaseCell* pOldCell );
1254 
1255 	SC_DLLPUBLIC		void				AppendInsert( const ScRange& );
1256 
1257 								// pRefDoc may be NULL => no lookup of contents
1258 								// => no generation of deleted contents
1259 	SC_DLLPUBLIC		void				AppendMove( const ScRange& rFromRange,
1260 									const ScRange& rToRange,
1261 									ScDocument* pRefDoc );
1262 
1263 								// Cut to Clipboard
1264 			void				ResetLastCut()
1265 									{
1266 										nStartLastCut = nEndLastCut = 0;
1267 										if ( pLastCutMove )
1268 										{
1269 											delete pLastCutMove;
1270 											pLastCutMove = NULL;
1271 										}
1272 									}
1273 			sal_Bool				HasLastCut() const
1274 									{
1275 										return nEndLastCut > 0 &&
1276 											nStartLastCut <= nEndLastCut &&
1277 											pLastCutMove;
1278 									}
1279 
1280 	SC_DLLPUBLIC		void				Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMerge = false );
1281 
1282 								// fuer MergeDocument, Referenzen anpassen,
1283 								//! darf nur in einem temporaer geoeffneten
1284 								//! Dokument verwendet werden, der Track
1285 								//! ist danach verhunzt
1286 			void				MergePrepare( ScChangeAction* pFirstMerge, bool bShared = false );
1287 			void				MergeOwn( ScChangeAction* pAct, sal_uLong nFirstMerge, bool bShared = false );
1288 	static	sal_Bool				MergeIgnore( const ScChangeAction&, sal_uLong nFirstMerge );
1289 
1290 								// Abhaengige in Table einfuegen.
1291 								// Bei Insert sind es echte Abhaengige,
1292 								// bei Move abhaengige Contents im FromRange
1293 								// und geloeschte im ToRange bzw. Inserts in
1294 								// FromRange oder ToRange,
1295 								// bei Delete eine Liste der geloeschten,
1296 								// bei Content andere Contents an gleicher
1297 								// Position oder MatrixReferences zu MatrixOrigin.
1298 								// Mit bListMasterDelete werden unter einem
1299 								// MasterDelete alle zu diesem Delete gehoerenden
1300 								// Deletes einer Reihe gelistet.
1301 								// Mit bAllFlat werden auch alle Abhaengigen
1302 								// der Abhaengigen flach eingefuegt.
1303 	SC_DLLPUBLIC		void				GetDependents( ScChangeAction*,
1304 									ScChangeActionTable&,
1305 									sal_Bool bListMasterDelete = sal_False,
1306 									sal_Bool bAllFlat = sal_False ) const;
1307 
1308 								// Reject visible Action (und abhaengige)
1309             sal_Bool                Reject( ScChangeAction*, bool bShared = false );
1310 
1311 								// Accept visible Action (und abhaengige)
1312 	SC_DLLPUBLIC		sal_Bool				Accept( ScChangeAction* );
1313 
1314 			void				AcceptAll();	// alle Virgins
1315 			sal_Bool				RejectAll();	// alle Virgins
1316 
1317 								// Selektiert einen Content von mehreren an
1318 								// gleicher Position und akzeptiert diesen und
1319 								// die aelteren, rejected die neueren.
1320 								// Mit bOldest==sal_True wird der erste OldValue
1321 								// einer Virgin-Content-Kette restauriert.
1322 			sal_Bool				SelectContent( ScChangeAction*,
1323 									sal_Bool bOldest = sal_False );
1324 
1325 								// wenn ModifiedLink gesetzt, landen
1326 								// Aenderungen in ScChangeTrackMsgQueue
1327 			void				SetModifiedLink( const Link& r )
1328 									{ aModifiedLink = r; ClearMsgQueue(); }
1329 			const Link&			GetModifiedLink() const { return aModifiedLink; }
1330 			ScChangeTrackMsgQueue& GetMsgQueue() { return aMsgQueue; }
1331 
1332 			void				NotifyModified( ScChangeTrackMsgType eMsgType,
1333 									sal_uLong nStartAction, sal_uLong nEndAction );
1334 
1335 			sal_uInt16				GetLoadedFileFormatVersion() const
1336 									{ return nLoadedFileFormatVersion; }
1337 
1338 			sal_uLong				AddLoadedGenerated(ScBaseCell* pOldCell,
1339 												const ScBigRange& aBigRange, const String& sNewValue ); // only to use in the XML import
1340 			void				AppendLoaded( ScChangeAction* pAppend ); // this is only for the XML import public, it should be protected
1341 			void				SetActionMax(sal_uLong nTempActionMax)
1342 									{ nActionMax = nTempActionMax; } // only to use in the XML import
1343 
1344             void                SetProtection( const com::sun::star::uno::Sequence< sal_Int8 >& rPass )
1345                                     { aProtectPass = rPass; }
1346     com::sun::star::uno::Sequence< sal_Int8 >   GetProtection() const
1347                                     { return aProtectPass; }
1348             sal_Bool                IsProtected() const
1349                                     { return aProtectPass.getLength() != 0; }
1350 
1351                                 // If time stamps of actions of this
1352                                 // ChangeTrack and a second one are to be
1353                                 // compared including 100th seconds.
1354             void                SetTime100thSeconds( sal_Bool bVal )
1355                                     { bTime100thSeconds = bVal; }
1356             sal_Bool                IsTime100thSeconds() const
1357                                     { return bTime100thSeconds; }
1358 
1359             void                AppendCloned( ScChangeAction* pAppend );
1360     SC_DLLPUBLIC ScChangeTrack* Clone( ScDocument* pDocument ) const;
1361             void                MergeActionState( ScChangeAction* pAct, const ScChangeAction* pOtherAct );
1362 #if DEBUG_CHANGETRACK
1363             String              ToString() const;
1364 #endif // DEBUG_CHANGETRACK
1365 };
1366 
1367 
1368 #endif
1369 
1370 
1371