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