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