1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chgtrack.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CHGTRACK_HXX
32 #define SC_CHGTRACK_HXX
35 #ifndef _DATETIME_HXX //autogen
36 #include <tools/datetime.hxx>
38 #ifndef _TOOLS_TABLE_HXX //autogen
39 #include <tools/table.hxx>
41 #ifndef _STACK_HXX //autogen
42 #include <tools/stack.hxx>
44 #ifndef _QUEUE_HXX //autogen
45 #include <tools/queue.hxx>
47 #ifndef _SVMEMPOOL_HXX //autogen
48 #include <tools/mempool.hxx>
50 #ifndef _SFXLSTNER_HXX //autogen
51 #include <bf_svtools/lstner.hxx>
54 #ifndef SC_BIGRANGE_HXX
55 #include "bigrange.hxx"
57 #ifndef SC_COLLECT_HXX
58 #include "collect.hxx"
61 #ifdef SC_CHGTRACK_CXX
64 /*N*/#include <tools/debug.hxx>
75 enum ScChangeActionType
90 enum ScChangeActionState
98 enum ScChangeActionClipMode
106 class ScMultipleReadHeader
;
107 class ScMultipleWriteHeader
;
109 // --- ScChangeActionLinkEntry ---------------------------------------------
111 // Fuegt sich selbst am Beginn einer Kette ein, bzw. vor einem anderen
112 // LinkEntry, on delete selbstaendiges ausklinken auch des gelinkten.
113 // ppPrev == &previous->pNext oder Adresse des Pointers auf Beginn der Kette,
116 class ScChangeAction
;
118 class ScChangeActionLinkEntry
120 // not implemented, prevent usage
121 ScChangeActionLinkEntry(
122 const ScChangeActionLinkEntry
& );
123 /*N*/ ScChangeActionLinkEntry
& operator=( const ScChangeActionLinkEntry
& );
127 ScChangeActionLinkEntry
* pNext
;
128 ScChangeActionLinkEntry
** ppPrev
;
129 ScChangeAction
* pAction
;
130 ScChangeActionLinkEntry
* pLink
;
134 DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionLinkEntry
)
136 ScChangeActionLinkEntry(
137 ScChangeActionLinkEntry
** ppPrevP
,
138 ScChangeAction
* pActionP
)
145 pNext
->ppPrev
= &pNext
;
149 virtual ~ScChangeActionLinkEntry()
151 ScChangeActionLinkEntry
* p
= pLink
;
158 void SetLink( ScChangeActionLinkEntry
* pLinkP
)
164 pLinkP
->pLink
= this;
181 if ( *ppPrev
= pNext
)
182 pNext
->ppPrev
= ppPrev
;
183 ppPrev
= NULL
; // not inserted
187 void Insert( ScChangeActionLinkEntry
** ppPrevP
)
192 if ( pNext
= *ppPrevP
)
193 pNext
->ppPrev
= &pNext
;
198 const ScChangeActionLinkEntry
* GetLink() const { return pLink
; }
199 ScChangeActionLinkEntry
* GetLink() { return pLink
; }
200 const ScChangeActionLinkEntry
* GetNext() const { return pNext
; }
201 ScChangeActionLinkEntry
* GetNext() { return pNext
; }
202 const ScChangeAction
* GetAction() const { return pAction
; }
203 ScChangeAction
* GetAction() { return pAction
; }
206 // --- ScChangeActionCellListEntry -----------------------------------------
207 // this is only for the XML Export in the hxx
208 class ScChangeActionContent
;
210 class ScChangeActionCellListEntry
212 friend class ScChangeAction
;
213 friend class ScChangeActionDel
;
214 friend class ScChangeActionMove
;
215 friend class ScChangeTrack
;
217 ScChangeActionCellListEntry
* pNext
;
218 ScChangeActionContent
* pContent
;
220 ScChangeActionCellListEntry(
221 ScChangeActionContent
* pContentP
,
222 ScChangeActionCellListEntry
* pNextP
)
223 : pContent( pContentP
),
228 const ScChangeActionCellListEntry
* GetNext() const { return pNext
; } // this is only for the XML Export public
229 const ScChangeActionContent
* GetContent() const { return pContent
; } // this is only for the XML Export public
231 DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionCellListEntry
)
234 // --- ScChangeAction -------------------------------------------------------
237 class ScChangeActionIns
;
238 class ScChangeActionDel
;
239 class ScChangeActionContent
;
243 friend class ScChangeTrack
;
244 friend class ScChangeActionIns
;
245 friend class ScChangeActionDel
;
246 friend class ScChangeActionMove
;
247 friend class ScChangeActionContent
;
249 /*N*/ // not implemented, prevent usage
250 /*N*/ ScChangeAction( const ScChangeAction
& );
251 ScChangeAction
& operator=( const ScChangeAction
& );
255 ScBigRange aBigRange
; // Ins/Del/MoveTo/ContentPos
256 DateTime aDateTime
; //! UTC
257 String aUser
; // wer war's
258 String aComment
; // Benutzerkommentar
259 ScChangeAction
* pNext
; // naechster in Kette
260 ScChangeAction
* pPrev
; // vorheriger in Kette
261 ScChangeActionLinkEntry
* pLinkAny
; // irgendwelche Links
262 ScChangeActionLinkEntry
* pLinkDeletedIn
; // Zuordnung zu
264 // druebergemoveten oder
267 ScChangeActionLinkEntry
* pLinkDeleted
; // Links zu geloeschten
268 ScChangeActionLinkEntry
* pLinkDependent
; // Links zu abhaengigen
271 ScChangeActionType eType
;
272 ScChangeActionState eState
;
275 ScChangeAction( ScChangeActionType
,
278 // only to be used in the XML import
279 ScChangeAction( ScChangeActionType
,
282 const ULONG nRejectAction
,
283 const ScChangeActionState eState
,
284 const DateTime
& aDateTime
,
286 const String
& aComment
);
287 /*N*/ // only to be used in the XML import
288 ScChangeAction( ScChangeActionType
,
290 const ULONG nAction
);
292 ScChangeAction( SvStream
&,
293 ScMultipleReadHeader
&, ScChangeTrack
* );
294 virtual ~ScChangeAction();
296 /*N*/ static void StoreCell( ScBaseCell
*, SvStream
&,
297 /*N*/ ScMultipleWriteHeader
& );
298 /*N*/ static ScBaseCell
* LoadCell( SvStream
&, ScMultipleReadHeader
&,
299 /*N*/ ScDocument
*, USHORT nVer
);
301 /*N*/ static BOOL
StoreLinkChain( ScChangeActionLinkEntry
*,
303 /*N*/ static BOOL
LoadLinkChain( ScChangeAction
*,
304 /*N*/ ScChangeActionLinkEntry
**,
305 /*N*/ SvStream
&, ScChangeTrack
*,
306 /*N*/ BOOL bLinkDeleted
);
308 /*N*/ static BOOL
StoreCellList( ScChangeActionCellListEntry
*,
310 /*N*/ static BOOL
LoadCellList( ScChangeAction
* pOfAction
,
311 /*N*/ ScChangeActionCellListEntry
*&, SvStream
&,
312 /*N*/ ScChangeTrack
* );
314 /*N*/ String
GetRefString( const ScBigRange
&,
315 /*N*/ ScDocument
*, BOOL bFlag3D
= FALSE
) const;
317 /*N*/ void SetActionNumber( ULONG n
) { nAction
= n
; }
318 /*N*/ void SetRejectAction( ULONG n
) { nRejectAction
= n
; }
319 /*N*/ void SetUser( const String
& r
) { aUser
= r
; }
320 /*N*/ void SetType( ScChangeActionType e
) { eType
= e
; }
321 /*N*/ void SetState( ScChangeActionState e
) { eState
= e
; }
322 /*N*/ void SetRejected();
324 ScBigRange
& GetBigRange() { return aBigRange
; }
326 /*N*/ ScChangeActionLinkEntry
* AddLink( ScChangeAction
* p
,
327 /*N*/ ScChangeActionLinkEntry
* pL
)
329 /*N*/ ScChangeActionLinkEntry
* pLnk
=
330 /*N*/ new ScChangeActionLinkEntry(
331 /*N*/ &pLinkAny
, p
);
332 /*N*/ pLnk
->SetLink( pL
);
335 /*N*/ void RemoveAllAnyLinks();
337 virtual ScChangeActionLinkEntry
* GetDeletedIn() const
338 { return pLinkDeletedIn
; }
339 /*N*/ virtual ScChangeActionLinkEntry
** GetDeletedInAddress()
340 /*N*/ { return &pLinkDeletedIn
; }
341 /*N*/ ScChangeActionLinkEntry
* AddDeletedIn( ScChangeAction
* p
)
343 /*N*/ return new ScChangeActionLinkEntry(
344 /*N*/ GetDeletedInAddress(), p
);
346 /*N*/ BOOL
RemoveDeletedIn( const ScChangeAction
* );
347 /*N*/ void RemoveAllDeletedIn();
348 /*N*/ void SetDeletedIn( ScChangeAction
* );
350 /*N*/ ScChangeActionLinkEntry
* AddDeleted( ScChangeAction
* p
)
352 /*N*/ return new ScChangeActionLinkEntry(
353 /*N*/ &pLinkDeleted
, p
);
355 /*N*/ void RemoveAllDeleted();
357 ScChangeActionLinkEntry
* AddDependent( ScChangeAction
* p
)
359 return new ScChangeActionLinkEntry(
360 &pLinkDependent
, p
);
362 /*N*/ void RemoveAllDependent();
364 void RemoveAllLinks();
366 /*N*/ virtual void AddContent( ScChangeActionContent
* ) = 0;
367 /*N*/ virtual void DeleteCellEntries() = 0;
369 /*N*/ virtual void UpdateReference( const ScChangeTrack
*,
370 /*N*/ UpdateRefMode
, const ScBigRange
&,
371 /*N*/ INT32 nDx
, INT32 nDy
, INT32 nDz
);
374 /*N*/ virtual BOOL
Reject( ScDocument
* ) = 0;
375 /*N*/ void RejectRestoreContents( ScChangeTrack
*,
376 /*N*/ short nDx
, short nDy
);
378 /*N*/ // used in Reject() instead of IsRejectable()
379 /*N*/ BOOL
IsInternalRejectable() const;
381 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
382 /*N*/ virtual BOOL
StoreLinks( SvStream
& ) const;
383 /*N*/ virtual BOOL
LoadLinks( SvStream
&, ScChangeTrack
* );
387 BOOL
IsInsertType() const
389 return eType
== SC_CAT_INSERT_COLS
||
390 eType
== SC_CAT_INSERT_ROWS
||
391 eType
== SC_CAT_INSERT_TABS
;
393 BOOL
IsDeleteType() const
395 return eType
== SC_CAT_DELETE_COLS
||
396 eType
== SC_CAT_DELETE_ROWS
||
397 eType
== SC_CAT_DELETE_TABS
;
399 /*N*/ BOOL
IsVirgin() const
400 /*N*/ { return eState
== SC_CAS_VIRGIN
; }
401 BOOL
IsAccepted() const
402 { return eState
== SC_CAS_ACCEPTED
; }
403 BOOL
IsRejected() const
404 { return eState
== SC_CAS_REJECTED
; }
406 /*N*/ // Action rejects another Action
407 BOOL
IsRejecting() const
408 { return nRejectAction
!= 0; }
410 /*N*/ // ob Action anfassbar ist
411 /*N*/ BOOL
IsTouchable() const;
414 const ScBigRange
& GetBigRange() const { return aBigRange
; }
415 const DateTime
& GetDateTimeUTC() const // UTC time
416 { return aDateTime
; }
417 const String
& GetUser() const { return aUser
; }
418 const String
& GetComment() const { return aComment
; }
419 ScChangeActionType
GetType() const { return eType
; }
420 /*N*/ ScChangeActionState
GetState() const { return eState
; }
421 ULONG
GetActionNumber() const { return nAction
; }
422 ULONG
GetRejectAction() const { return nRejectAction
; }
424 ScChangeAction
* GetNext() const { return pNext
; }
425 /*N*/ ScChangeAction
* GetPrev() const { return pPrev
; }
427 BOOL
IsDeletedIn() const
428 { return GetDeletedIn() != NULL
; }
429 /*N*/ BOOL
IsDeleted() const
430 /*N*/ { return IsDeleteType() || IsDeletedIn(); }
431 /*N*/ BOOL
IsDeletedIn( const ScChangeAction
* ) const;
432 /*N*/ BOOL
IsDeletedInDelType( ScChangeActionType
) const;
434 const ScChangeActionLinkEntry
* GetFirstDeletedEntry() const
435 { return pLinkDeleted
; }
436 const ScChangeActionLinkEntry
* GetFirstDependentEntry() const
437 { return pLinkDependent
; }
438 BOOL
HasDependent() const
439 { return pLinkDependent
!= NULL
; }
440 BOOL
HasDeleted() const
441 { return pLinkDeleted
!= NULL
; }
443 /*N*/ // Description wird an String angehaengt.
444 /*N*/ // Mit bSplitRange wird bei Delete nur
445 /*N*/ // eine Spalte/Zeile beruecksichtigt (fuer
446 /*N*/ // Auflistung der einzelnen Eintraege).
447 /*N*/ virtual void GetDescription( String
&, ScDocument
*,
448 /*N*/ BOOL bSplitRange
= FALSE
) const {}
450 /*N*/ virtual void GetRefString( String
&, ScDocument
*,
451 /*N*/ BOOL bFlag3D
= FALSE
) const;
453 /*N*/ // fuer DocumentMerge altes Datum einer anderen
454 /*N*/ // Action setzen, mit GetDateTimeUTC geholt
455 /*N*/ void SetDateTimeUTC( const DateTime
& rDT
)
456 /*N*/ { aDateTime
= rDT
; }
458 /*N*/ // Benutzerkommentar setzen
459 /*N*/ void SetComment( const String
& rStr
)
460 /*N*/ { aComment
= rStr
; }
462 /*N*/ // only to be used in the XML import
463 void SetDeletedInThis( ULONG nActionNumber
,
464 const ScChangeTrack
* pTrack
);
465 /*N*/ // only to be used in the XML import
466 void AddDependent( ULONG nActionNumber
,
467 const ScChangeTrack
* pTrack
);
471 // --- ScChangeActionIns ----------------------------------------------------
473 class ScChangeActionIns
: public ScChangeAction
475 friend class ScChangeTrack
;
477 ScChangeActionIns( const ScRange
& rRange
);
478 ScChangeActionIns( SvStream
&,
479 ScMultipleReadHeader
&, ScChangeTrack
* );
480 virtual ~ScChangeActionIns();
482 /*N*/ virtual void AddContent( ScChangeActionContent
* ) {}
483 /*N*/ virtual void DeleteCellEntries() {}
485 /*N*/ virtual BOOL
Reject( ScDocument
* );
487 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
490 ScChangeActionIns(const ULONG nActionNumber
,
491 const ScChangeActionState eState
,
492 const ULONG nRejectingNumber
,
493 const ScBigRange
& aBigRange
,
495 const DateTime
& aDateTime
,
496 const String
&sComment
,
497 const ScChangeActionType eType
); // only to use in the XML import
499 /*N*/ virtual void GetDescription( String
&, ScDocument
*,
500 /*N*/ BOOL bSplitRange
= FALSE
) const;
504 // --- ScChangeActionDel ----------------------------------------------------
506 class ScChangeActionMove
;
508 class ScChangeActionDelMoveEntry
: public ScChangeActionLinkEntry
510 friend class ScChangeActionDel
;
511 friend class ScChangeTrack
;
517 ScChangeActionDelMoveEntry(
518 ScChangeActionDelMoveEntry
** ppPrev
,
519 ScChangeActionMove
* pMove
,
520 short nFrom
, short nTo
)
521 : ScChangeActionLinkEntry(
522 (ScChangeActionLinkEntry
**)
524 (ScChangeAction
*) pMove
),
525 nCutOffFrom( nFrom
),
529 /*N*/ ScChangeActionDelMoveEntry
* GetNext()
531 /*N*/ return (ScChangeActionDelMoveEntry
*)
532 /*N*/ ScChangeActionLinkEntry::GetNext();
534 /*N*/ ScChangeActionMove
* GetMove()
536 /*N*/ return (ScChangeActionMove
*)
537 /*N*/ ScChangeActionLinkEntry::GetAction();
541 const ScChangeActionDelMoveEntry
* GetNext() const
543 return (const ScChangeActionDelMoveEntry
*)
544 ScChangeActionLinkEntry::GetNext();
546 /*N*/ const ScChangeActionMove
* GetMove() const
548 /*N*/ return (const ScChangeActionMove
*)
549 /*N*/ ScChangeActionLinkEntry::GetAction();
551 short GetCutOffFrom() const { return nCutOffFrom
; }
552 short GetCutOffTo() const { return nCutOffTo
; }
556 class ScChangeActionDel
: public ScChangeAction
558 friend class ScChangeTrack
;
559 /*N*/ friend class ScChangeAction
;
561 ScChangeTrack
* pTrack
;
562 ScChangeActionCellListEntry
* pFirstCell
;
563 ScChangeActionIns
* pCutOff
; // abgeschnittener Insert
564 short nCutOff
; // +: Start -: End
565 ScChangeActionDelMoveEntry
* pLinkMove
;
569 ScChangeActionDel( const ScRange
& rRange
,
570 short nDx
, short nDy
, ScChangeTrack
* );
571 ScChangeActionDel( SvStream
&,
572 ScMultipleReadHeader
&, ScDocument
*,
573 USHORT nVer
, ScChangeTrack
* );
574 /*N*/ virtual ~ScChangeActionDel();
576 ScChangeActionIns
* GetCutOffInsert() { return pCutOff
; }
578 /*N*/ virtual void AddContent( ScChangeActionContent
* );
579 /*N*/ virtual void DeleteCellEntries();
581 /*N*/ void UndoCutOffMoves();
582 /*N*/ void UndoCutOffInsert();
584 /*N*/ virtual void UpdateReference( const ScChangeTrack
*,
585 /*N*/ UpdateRefMode
, const ScBigRange
&,
586 /*N*/ INT32 nDx
, INT32 nDy
, INT32 nDz
);
588 /*N*/ virtual BOOL
Reject( ScDocument
* );
590 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
591 /*N*/ virtual BOOL
StoreLinks( SvStream
& ) const;
592 /*N*/ virtual BOOL
LoadLinks( SvStream
&, ScChangeTrack
* );
595 ScChangeActionDel(const ULONG nActionNumber
,
596 const ScChangeActionState eState
,
597 const ULONG nRejectingNumber
,
598 const ScBigRange
& aBigRange
,
600 const DateTime
& aDateTime
,
601 const String
&sComment
,
602 const ScChangeActionType eType
,
604 ScChangeTrack
* pTrack
); // only to use in the XML import
605 // wich of nDx and nDy is set is depend on the type
607 // ob dieses das unterste einer Reihe (oder
609 /*N*/ BOOL
IsBaseDelete() const;
611 // ob dieses das oberste einer Reihe (oder
613 /*N*/ BOOL
IsTopDelete() const;
615 // ob dieses ein Teil einer Reihe ist
616 /*N*/ BOOL
IsMultiDelete() const;
619 short GetDx() const { return nDx
; }
620 short GetDy() const { return nDy
; }
621 /*N*/ ScBigRange
GetOverAllRange() const; // BigRange + (nDx, nDy)
623 /*N*/ const ScChangeActionCellListEntry
* GetFirstCellEntry() const
624 /*N*/ { return pFirstCell
; }
625 const ScChangeActionDelMoveEntry
* GetFirstMoveEntry() const
626 { return pLinkMove
; }
627 const ScChangeActionIns
* GetCutOffInsert() const { return pCutOff
; }
628 short GetCutOffCount() const { return nCutOff
; }
630 /*N*/ virtual void GetDescription( String
&, ScDocument
*,
631 /*N*/ BOOL bSplitRange
= FALSE
) const;
632 void SetCutOffInsert( ScChangeActionIns
* p
, short n
)
633 { pCutOff
= p
; nCutOff
= n
; } // only to use in the XML import
634 /*N*/ // this should be protected, but for the XML import it is public
635 /*N*/ // only to use in the XML import
636 /*N*/ // this should be protected, but for the XML import it is public
637 ScChangeActionDelMoveEntry
* AddCutOffMove( ScChangeActionMove
* pMove
,
638 short nFrom
, short nTo
)
640 return new ScChangeActionDelMoveEntry(
641 &pLinkMove
, pMove
, nFrom
, nTo
);
646 // --- ScChangeActionMove ---------------------------------------------------
648 class ScChangeActionMove
: public ScChangeAction
650 friend class ScChangeTrack
;
651 /*N*/ friend class ScChangeActionDel
;
653 ScBigRange aFromRange
;
654 ScChangeTrack
* pTrack
;
655 ScChangeActionCellListEntry
* pFirstCell
;
656 ULONG nStartLastCut
; // fuer PasteCut Undo
659 ScChangeActionMove( const ScRange
& rFromRange
,
660 const ScRange
& rToRange
,
661 ScChangeTrack
* pTrackP
)
662 : ScChangeAction( SC_CAT_MOVE
, rToRange
),
663 aFromRange( rFromRange
),
669 ScChangeActionMove( SvStream
&,
670 ScMultipleReadHeader
&, ScChangeTrack
* );
671 /*N*/ virtual ~ScChangeActionMove();
673 /*N*/ virtual void AddContent( ScChangeActionContent
* );
674 /*N*/ virtual void DeleteCellEntries();
676 ScBigRange
& GetFromRange() { return aFromRange
; }
678 /*N*/ void SetStartLastCut( ULONG nVal
) { nStartLastCut
= nVal
; }
679 /*N*/ ULONG
GetStartLastCut() const { return nStartLastCut
; }
680 /*N*/ void SetEndLastCut( ULONG nVal
) { nEndLastCut
= nVal
; }
681 /*N*/ ULONG
GetEndLastCut() const { return nEndLastCut
; }
683 /*N*/ virtual void UpdateReference( const ScChangeTrack
*,
684 /*N*/ UpdateRefMode
, const ScBigRange
&,
685 /*N*/ INT32 nDx
, INT32 nDy
, INT32 nDz
);
687 /*N*/ virtual BOOL
Reject( ScDocument
* );
689 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
690 /*N*/ virtual BOOL
StoreLinks( SvStream
& ) const;
691 /*N*/ virtual BOOL
LoadLinks( SvStream
&, ScChangeTrack
* );
694 ScChangeActionMove(const ULONG nActionNumber
,
695 const ScChangeActionState eState
,
696 const ULONG nRejectingNumber
,
697 const ScBigRange
& aToBigRange
,
699 const DateTime
& aDateTime
,
700 const String
&sComment
,
701 const ScBigRange
& aFromBigRange
,
702 ScChangeTrack
* pTrack
); // only to use in the XML import
703 /*N*/ const ScChangeActionCellListEntry
* GetFirstCellEntry() const
704 /*N*/ { return pFirstCell
; } // only to use in the XML export
706 const ScBigRange
& GetFromRange() const { return aFromRange
; }
707 /*N*/ void GetDelta( INT32
& nDx
, INT32
& nDy
, INT32
& nDz
) const;
709 /*N*/ virtual void GetDescription( String
&, ScDocument
*,
710 /*N*/ BOOL bSplitRange
= FALSE
) const;
712 /*N*/ virtual void GetRefString( String
&, ScDocument
*,
713 /*N*/ BOOL bFlag3D
= FALSE
) const;
717 // --- ScChangeActionContent ------------------------------------------------
719 enum ScChangeActionContentCellType
727 class ScChangeActionContent
: public ScChangeAction
729 friend class ScChangeTrack
;
733 ScBaseCell
* pOldCell
;
734 ScBaseCell
* pNewCell
;
735 ScChangeActionContent
* pNextContent
; // an gleicher Position
736 ScChangeActionContent
* pPrevContent
;
737 ScChangeActionContent
* pNextInSlot
; // in gleichem Slot
738 ScChangeActionContent
** ppPrevInSlot
;
740 ScChangeActionContent( SvStream
&,
741 ScMultipleReadHeader
&, ScDocument
*,
742 USHORT nVer
, ScChangeTrack
* );
744 /*N*/ void InsertInSlot( ScChangeActionContent
** pp
)
746 /*N*/ if ( !ppPrevInSlot
)
748 /*N*/ ppPrevInSlot
= pp
;
749 /*N*/ if ( pNextInSlot
= *pp
)
750 /*N*/ pNextInSlot
->ppPrevInSlot
= &pNextInSlot
;
754 /*N*/ void RemoveFromSlot()
756 /*N*/ if ( ppPrevInSlot
)
758 /*N*/ if ( *ppPrevInSlot
= pNextInSlot
)
759 /*N*/ pNextInSlot
->ppPrevInSlot
= ppPrevInSlot
;
760 /*N*/ ppPrevInSlot
= NULL
; // not inserted
763 /*N*/ ScChangeActionContent
* GetNextInSlot() { return pNextInSlot
; }
765 /*N*/ void ClearTrack();
767 /*N*/ static void SetValue( String
& rStr
, ScBaseCell
*& pCell
,
768 /*N*/ const ScAddress
& rPos
,
769 /*N*/ const ScBaseCell
* pOrgCell
,
770 /*N*/ const ScDocument
* pFromDoc
,
771 /*N*/ ScDocument
* pToDoc
);
773 /*N*/ static void SetValue( String
& rStr
, ScBaseCell
*& pCell
,
775 /*N*/ const ScBaseCell
* pOrgCell
,
776 /*N*/ const ScDocument
* pFromDoc
,
777 /*N*/ ScDocument
* pToDoc
);
779 /*N*/ static void SetCell( String
& rStr
, ScBaseCell
* pCell
,
780 /*N*/ ULONG nFormat
, const ScDocument
* pDoc
);
782 /*N*/ static BOOL
NeedsNumberFormat( const ScBaseCell
* );
784 /*N*/ void GetValueString( String
& rStr
,
785 /*N*/ const String
& rValue
,
786 /*N*/ const ScBaseCell
* pCell
) const;
788 /*N*/ void GetFormulaString( String
& rStr
,
789 /*N*/ const ScFormulaCell
* pCell
) const;
791 /*N*/ virtual void AddContent( ScChangeActionContent
* ) {}
792 /*N*/ virtual void DeleteCellEntries() {}
794 /*N*/ virtual void UpdateReference( const ScChangeTrack
*,
795 /*N*/ UpdateRefMode
, const ScBigRange
&,
796 /*N*/ INT32 nDx
, INT32 nDy
, INT32 nDz
);
798 /*N*/ virtual BOOL
Reject( ScDocument
* );
800 /*N*/ void PutValueToDoc( ScBaseCell
*, const String
&,
801 /*N*/ ScDocument
*, short nDx
, short nDy
) const;
803 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
804 /*N*/ virtual BOOL
StoreLinks( SvStream
& ) const;
805 /*N*/ virtual BOOL
LoadLinks( SvStream
&, ScChangeTrack
* );
809 DECL_FIXEDMEMPOOL_NEWDEL( ScChangeActionContent
)
811 ScChangeActionContent( const ScRange
& rRange
)
812 : ScChangeAction( SC_CAT_CONTENT
, rRange
),
815 pNextContent( NULL
),
816 pPrevContent( NULL
),
820 ScChangeActionContent(const ULONG nActionNumber
,
821 const ScChangeActionState eState
,
822 const ULONG nRejectingNumber
,
823 const ScBigRange
& aBigRange
,
825 const DateTime
& aDateTime
,
826 const String
&sComment
,
827 ScBaseCell
* pOldCell
,
829 const String
& sResult
); // to use for XML Import
830 ScChangeActionContent(const ULONG nActionNumber
,
831 ScBaseCell
* pNewCell
,
832 const ScBigRange
& aBigRange
,
833 ScDocument
* pDoc
); // to use for XML Import of Generated Actions
834 /*N*/ virtual ~ScChangeActionContent();
836 /*N*/ ScChangeActionContent
* GetNextContent() const { return pNextContent
; }
837 ScChangeActionContent
* GetPrevContent() const { return pPrevContent
; }
838 /*N*/ ScChangeActionContent
* GetTopContent() const;
839 BOOL
IsTopContent() const
840 { return pNextContent
== NULL
; }
842 /*N*/ virtual ScChangeActionLinkEntry
* GetDeletedIn() const;
843 /*N*/ virtual ScChangeActionLinkEntry
** GetDeletedInAddress();
845 /*N*/ void PutOldValueToDoc( ScDocument
*,
846 /*N*/ short nDx
, short nDy
) const;
847 /*N*/ void PutNewValueToDoc( ScDocument
*,
848 /*N*/ short nDx
, short nDy
) const;
850 /*N*/ void SetOldValue( const ScBaseCell
*,
851 /*N*/ const ScDocument
* pFromDoc
,
852 /*N*/ ScDocument
* pToDoc
);
853 /*N*/ void SetNewValue( const ScBaseCell
*, ScDocument
* );
855 /*N*/ // Use this only in the XML import,
856 /*N*/ // takes ownership of cell.
857 void SetNewCell( ScBaseCell
* pNewCell
, ScDocument
* pDoc
);
859 /*N*/ // These functions should be protected but for
860 /*N*/ // the XML import they are public.
861 void SetNextContent( ScChangeActionContent
* p
)
862 { pNextContent
= p
; }
863 void SetPrevContent( ScChangeActionContent
* p
)
864 { pPrevContent
= p
; }
866 /*N*/ void GetOldString( String
& ) const;
867 /*N*/ void GetNewString( String
& ) const;
868 const ScBaseCell
* GetOldCell() const { return pOldCell
; }
869 const ScBaseCell
* GetNewCell() const { return pNewCell
; }
870 /*N*/ virtual void GetDescription( String
&, ScDocument
*,
871 /*N*/ BOOL bSplitRange
= FALSE
) const;
872 /*N*/ virtual void GetRefString( String
&, ScDocument
*,
873 /*N*/ BOOL bFlag3D
= FALSE
) const;
875 /*N*/ static ScChangeActionContentCellType
GetContentCellType( const ScBaseCell
* );
878 /*N*/ BOOL
IsMatrixOrigin() const
880 /*N*/ return GetContentCellType( GetNewCell() )
881 /*N*/ == SC_CACCT_MATORG
;
883 /*N*/ BOOL
IsMatrixReference() const
885 /*N*/ return GetContentCellType( GetNewCell() )
886 /*N*/ == SC_CACCT_MATREF
;
889 /*N*/ BOOL
IsOldMatrixOrigin() const
891 /*N*/ return GetContentCellType( GetOldCell() )
892 /*N*/ == SC_CACCT_MATORG
;
894 /*N*/ BOOL
IsOldMatrixReference() const
896 /*N*/ return GetContentCellType( GetOldCell() )
897 /*N*/ == SC_CACCT_MATREF
;
903 // --- ScChangeActionReject -------------------------------------------------
905 class ScChangeActionReject
: public ScChangeAction
907 friend class ScChangeTrack
;
908 /*N*/ friend class ScChangeActionContent
;
910 ScChangeActionReject( ULONG nReject
)
911 : ScChangeAction( SC_CAT_REJECT
, ScRange() )
913 /*N*/ SetRejectAction( nReject
);
914 /*N*/ SetState( SC_CAS_ACCEPTED
);
916 ScChangeActionReject( SvStream
&,
917 ScMultipleReadHeader
&, ScChangeTrack
* );
919 /*N*/ virtual void AddContent( ScChangeActionContent
* ) {}
920 /*N*/ virtual void DeleteCellEntries() {}
922 /*N*/ virtual BOOL
Reject( ScDocument
* p
) { return FALSE
; }
924 /*N*/ virtual BOOL
Store( SvStream
&, ScMultipleWriteHeader
& ) const;
927 ScChangeActionReject(const ULONG nActionNumber
,
928 const ScChangeActionState eState
,
929 const ULONG nRejectingNumber
,
930 const ScBigRange
& aBigRange
,
932 const DateTime
& aDateTime
,
933 const String
&sComment
); // only to use in the XML import
937 // --- ScChangeTrack --------------------------------------------------------
939 enum ScChangeTrackMsgType
942 SC_CTM_APPEND
, // Actions angehaengt
943 SC_CTM_REMOVE
, // Actions weggenommen
944 SC_CTM_CHANGE
, // Actions geaendert
945 SC_CTM_PARENT
// war kein Parent und ist jetzt einer
948 struct ScChangeTrackMsgInfo
950 DECL_FIXEDMEMPOOL_NEWDEL( ScChangeTrackMsgInfo
)
952 ScChangeTrackMsgType eMsgType
;
957 // MsgQueue fuer Benachrichtigung via ModifiedLink
958 /*N*/ DECLARE_QUEUE( ScChangeTrackMsgQueue
, ScChangeTrackMsgInfo
* )
959 /*N*/ DECLARE_STACK( ScChangeTrackMsgStack
, ScChangeTrackMsgInfo
* )
961 enum ScChangeTrackMergeState
969 // zusaetzlich zu pFirst/pNext/pLast/pPrev eine Table, um schnell sowohl
970 // per ActionNumber als auch ueber Liste zugreifen zu koennen
971 /*N*/DECLARE_TABLE( ScChangeActionTable
, ScChangeAction
* )
973 // Intern generierte Actions beginnen bei diesem Wert (fast alle Bits gesetzt)
974 // und werden runtergezaehlt, um sich in einer Table wertemaessig nicht mit den
975 // "normalen" Actions in die Quere zu kommen.
976 #define SC_CHGTRACK_GENERATED_START ((UINT32) 0xfffffff0)
978 // SfxListener an der Applikation, um Aenderungen des Usernamens mitzubekommen
980 class ScChangeTrack
: public SfxListener
982 /*N*/ friend void ScChangeAction::RejectRestoreContents( ScChangeTrack
*, short, short );
983 /*N*/ friend BOOL
ScChangeActionDel::Reject( ScDocument
* pDoc
);
984 /*N*/ friend void ScChangeActionDel::DeleteCellEntries();
985 /*N*/ friend void ScChangeActionMove::DeleteCellEntries();
986 /*N*/ friend BOOL
ScChangeActionMove::Reject( ScDocument
* pDoc
);
988 static const USHORT nContentRowsPerSlot
;
989 static const USHORT nContentSlots
;
991 ::com::sun::star::uno::Sequence
< sal_Int8
> aProtectPass
;
992 ScChangeActionTable aTable
;
993 ScChangeActionTable aGeneratedTable
;
994 ScChangeActionTable aPasteCutTable
;
995 /*N*/ ScChangeTrackMsgQueue aMsgQueue
;
996 /*N*/ ScChangeTrackMsgStack aMsgStackTmp
;
997 /*N*/ ScChangeTrackMsgStack aMsgStackFinal
;
998 StrCollection aUserCollection
;
1001 ScRange aInDeleteRange
;
1002 DateTime aFixDateTime
;
1003 ScChangeAction
* pFirst
;
1004 ScChangeAction
* pLast
;
1005 ScChangeActionContent
* pFirstGeneratedDelContent
;
1006 ScChangeActionContent
** ppContentSlots
;
1007 ScChangeActionMove
* pLastCutMove
;
1008 ScChangeActionLinkEntry
* pLinkInsertCol
;
1009 ScChangeActionLinkEntry
* pLinkInsertRow
;
1010 ScChangeActionLinkEntry
* pLinkInsertTab
;
1011 ScChangeActionLinkEntry
* pLinkMove
;
1012 ScChangeTrackMsgInfo
* pBlockModifyMsg
;
1015 ULONG nGeneratedMin
;
1016 ULONG nMarkLastSaved
;
1017 ULONG nStartLastCut
;
1020 ScChangeTrackMergeState eMergeState
;
1021 USHORT nLoadedFileFormatVersion
;
1027 BOOL bUseFixDateTime
;
1028 BOOL bTime100thSeconds
;
1030 // not implemented, prevent usage
1031 /*N*/ ScChangeTrack( const ScChangeTrack
& );
1032 ScChangeTrack
& operator=( const ScChangeTrack
& );
1034 #ifdef SC_CHGTRACK_CXX
1035 static USHORT
InitContentRowsPerSlot();
1037 /*N*/ virtual void Notify( SfxBroadcaster
&, const SfxHint
& );
1039 /*N*/ void DtorClear();
1040 /*N*/ void SetLoadSave( BOOL bVal
) { bLoadSave
= bVal
; }
1041 /*N*/ void SetInDeleteRange( const ScRange
& rRange
)
1042 /*N*/ { aInDeleteRange
= rRange
; }
1043 /*N*/ void SetInDelete( BOOL bVal
)
1044 /*N*/ { bInDelete
= bVal
; }
1045 /*N*/ void SetInDeleteTop( BOOL bVal
)
1046 /*N*/ { bInDeleteTop
= bVal
; }
1047 /*N*/ void SetInDeleteUndo( BOOL bVal
)
1048 /*N*/ { bInDeleteUndo
= bVal
; }
1049 /*N*/ void SetInPasteCut( BOOL bVal
)
1050 /*N*/ { bInPasteCut
= bVal
; }
1051 /*N*/ void SetMergeState( ScChangeTrackMergeState eState
)
1052 /*N*/ { eMergeState
= eState
; }
1053 /*N*/ ScChangeTrackMergeState
GetMergeState() const { return eMergeState
; }
1054 /*N*/ void SetLastMerge( ULONG nVal
) { nLastMerge
= nVal
; }
1055 /*N*/ ULONG
GetLastMerge() const { return nLastMerge
; }
1057 /*N*/ // ModifyMsg blockweise und nicht einzeln erzeugen
1058 /*N*/ void StartBlockModify( ScChangeTrackMsgType
,
1059 /*N*/ ULONG nStartAction
);
1060 /*N*/ void EndBlockModify( ULONG nEndAction
);
1062 /*N*/ void AddDependentWithNotify( ScChangeAction
* pParent
,
1063 /*N*/ ScChangeAction
* pDependent
);
1065 /*N*/ void Dependencies( ScChangeAction
* );
1066 /*N*/ void UpdateReference( ScChangeAction
*, BOOL bUndo
);
1067 /*N*/ void UpdateReference( ScChangeAction
** ppFirstAction
,
1068 /*N*/ ScChangeAction
* pAct
, BOOL bUndo
);
1069 /*N*/ void Append( ScChangeAction
* pAppend
, ULONG nAction
);
1070 /*N*/ void AppendDeleteRange( const ScRange
&,
1071 /*N*/ ScDocument
* pRefDoc
, short nDz
,
1072 /*N*/ ULONG nRejectingInsert
);
1073 /*N*/ void AppendOneDeleteRange( const ScRange
& rOrgRange
,
1074 /*N*/ ScDocument
* pRefDoc
,
1075 /*N*/ short nDx
, short nDy
, short nDz
,
1076 /*N*/ ULONG nRejectingInsert
);
1077 /*N*/ void LookUpContents( const ScRange
& rOrgRange
,
1078 /*N*/ ScDocument
* pRefDoc
,
1079 /*N*/ short nDx
, short nDy
, short nDz
);
1080 /*N*/ void Remove( ScChangeAction
* );
1081 /*N*/ void MasterLinks( ScChangeAction
* );
1082 /*N*/ // Content on top an Position
1083 /*N*/ ScChangeActionContent
* SearchContentAt( const ScBigAddress
&,
1084 /*N*/ ScChangeAction
* pButNotThis
) const;
1086 /*N*/ // das gleiche fuer generierte Del-Eintraege,
1087 /*N*/ // wobei der Content nicht in der angegebenen
1088 /*N*/ // Richtung geloescht sein darf
1089 /*N*/ void DeleteGeneratedDelContent(
1090 /*N*/ ScChangeActionContent
* );
1091 /*N*/ ScChangeActionContent
* GenerateDelContent( const ScAddress
&,
1092 /*N*/ const ScBaseCell
*,
1093 /*N*/ const ScDocument
* pFromDoc
);
1094 /*N*/ void DeleteCellEntries(
1095 /*N*/ ScChangeActionCellListEntry
*&,
1096 /*N*/ ScChangeAction
* pDeletor
);
1098 /*N*/ // Action und alle abhaengigen rejecten,
1099 /*N*/ // Table stammt aus vorherigem GetDependents,
1100 /*N*/ // ist nur bei Insert und Move (MasterType)
1101 /*N*/ // noetig, kann ansonsten NULL sein.
1102 /*N*/ // bRecursion == Aufruf aus Reject mit Table
1103 /*N*/ BOOL
Reject( ScChangeAction
*,
1104 /*N*/ ScChangeActionTable
*, BOOL bRecursion
);
1106 #endif // SC_CHGTRACK_CXX
1108 /*N*/ void ClearMsgQueue();
1112 /*N*/ static USHORT
ComputeContentSlot( INT32 nRow
)
1114 /*N*/ if ( nRow
< 0 || nRow
> MAXROW
)
1115 /*N*/ return nContentSlots
- 1;
1116 /*N*/ return nRow
/ nContentRowsPerSlot
;
1119 /*N*/ ScChangeTrack( ScDocument
* );
1120 ScChangeTrack( ScDocument
*,
1121 /*N*/ const StrCollection
& ); // only to use in the XML import
1122 /*N*/ virtual ~ScChangeTrack();
1125 ScChangeActionContent
* GetFirstGenerated() const { return pFirstGeneratedDelContent
; }
1126 ScChangeAction
* GetFirst() const { return pFirst
; }
1127 ScChangeAction
* GetLast() const { return pLast
; }
1128 ULONG
GetActionMax() const { return nActionMax
; }
1129 BOOL
IsGenerated( ULONG nAction
) const
1130 /*N*/ { return nAction
>= nGeneratedMin
;}
1131 ScChangeAction
* GetAction( ULONG nAction
) const
1132 { return aTable
.Get( nAction
); }
1133 /*N*/ ScChangeAction
* GetGenerated( ULONG nGenerated
) const
1134 /*N*/ { return aGeneratedTable
.Get( nGenerated
); }
1135 /*N*/ ScChangeAction
* GetActionOrGenerated( ULONG nAction
) const
1137 /*N*/ return IsGenerated( nAction
) ?
1138 /*N*/ GetGenerated( nAction
) :
1139 /*N*/ GetAction( nAction
);
1141 /*N*/ ULONG
GetLastSavedActionNumber() const
1142 /*N*/ { return nMarkLastSaved
; }
1143 void SetLastSavedActionNumber(ULONG nNew
)
1144 { nMarkLastSaved
= nNew
; }
1145 /*N*/ ScChangeAction
* GetLastSaved() const
1146 /*N*/ { return aTable
.Get( nMarkLastSaved
); }
1147 /*N*/ ScChangeActionContent
** GetContentSlots() const { return ppContentSlots
; }
1149 /*N*/ BOOL
IsLoadSave() const { return bLoadSave
; }
1150 /*N*/ const ScRange
& GetInDeleteRange() const
1151 /*N*/ { return aInDeleteRange
; }
1152 /*N*/ BOOL
IsInDelete() const { return bInDelete
; }
1153 /*N*/ BOOL
IsInDeleteTop() const { return bInDeleteTop
; }
1154 BOOL
IsInDeleteUndo() const { return bInDeleteUndo
; }
1155 /*N*/ BOOL
IsInPasteCut() const { return bInPasteCut
; }
1156 /*N*/ void SetUser( const String
& );
1157 /*N*/ const String
& GetUser() const { return aUser
; }
1158 const StrCollection
& GetUserCollection() const
1159 { return aUserCollection
; }
1160 /*N*/ ScDocument
* GetDocument() const { return pDoc
; }
1161 /*N*/ // for import filter
1162 /*N*/ const DateTime
& GetFixDateTime() const { return aFixDateTime
; }
1164 /*N*/ // set this if the date/time set with
1165 /*N*/ // SetFixDateTime...() shall be applied to
1166 /*N*/ // appended actions
1167 /*N*/ void SetUseFixDateTime( BOOL bVal
)
1168 /*N*/ { bUseFixDateTime
= bVal
; }
1169 /*N*/ // for MergeDocument, apply original date/time as UTC
1170 /*N*/ void SetFixDateTimeUTC( const DateTime
& rDT
)
1171 /*N*/ { aFixDateTime
= rDT
; }
1172 /*N*/ // for import filter, apply original date/time as local time
1173 /*N*/ void SetFixDateTimeLocal( const DateTime
& rDT
)
1174 /*N*/ { aFixDateTime
= rDT
; aFixDateTime
.ConvertToUTC(); }
1176 /*N*/ void Append( ScChangeAction
* );
1178 /*N*/ // Cut to Clipboard
1179 /*N*/ void ResetLastCut()
1181 /*N*/ nStartLastCut
= nEndLastCut
= 0;
1182 /*N*/ if ( pLastCutMove
)
1184 /*N*/ delete pLastCutMove
;
1185 /*N*/ pLastCutMove
= NULL
;
1188 /*N*/ BOOL
HasLastCut() const
1190 /*N*/ return nEndLastCut
> 0 &&
1191 /*N*/ nStartLastCut
<= nEndLastCut
&&
1196 /*N*/ // wenn ModifiedLink gesetzt, landen
1197 /*N*/ // Aenderungen in ScChangeTrackMsgQueue
1198 /*N*/ void SetModifiedLink( const Link
& r
)
1199 /*N*/ { aModifiedLink
= r
; ClearMsgQueue(); }
1200 /*N*/ const Link
& GetModifiedLink() const { return aModifiedLink
; }
1201 /*N*/ ScChangeTrackMsgQueue
& GetMsgQueue() { return aMsgQueue
; }
1203 /*N*/ void NotifyModified( ScChangeTrackMsgType eMsgType
,
1204 /*N*/ ULONG nStartAction
, ULONG nEndAction
);
1206 /*N*/ BOOL
Load( SvStream
& rStrm
, USHORT nVer
);
1207 /*N*/ BOOL
Store( SvStream
& rStrm
);
1208 /*N*/ USHORT
GetLoadedFileFormatVersion() const
1209 /*N*/ { return nLoadedFileFormatVersion
; }
1211 ULONG
AddLoadedGenerated(ScBaseCell
* pOldCell
,
1212 const ScBigRange
& aBigRange
); // only to use in the XML import
1213 void AppendLoaded( ScChangeAction
* pAppend
); // this is only for the XML import public, it should be protected
1214 void SetActionMax(ULONG nTempActionMax
)
1215 { nActionMax
= nTempActionMax
; } // only to use in the XML import
1217 void SetProtection( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rPass
)
1218 { aProtectPass
= rPass
; }
1219 ::com::sun::star::uno::Sequence
< sal_Int8
> GetProtection() const
1220 { return aProtectPass
; }
1221 BOOL
IsProtected() const
1222 { return aProtectPass
.getLength() != 0; }
1224 /*N*/ // If time stamps of actions of this
1225 /*N*/ // ChangeTrack and a second one are to be
1226 /*N*/ // compared including 100th seconds.
1227 void SetTime100thSeconds( BOOL bVal
)
1228 { bTime100thSeconds
= bVal
; }
1229 /*N*/ BOOL
IsTime100thSeconds() const
1230 /*N*/ { return bTime100thSeconds
; }
1234 } //namespace binfilter