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