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