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_UNDOTAB_HXX 25 #define SC_UNDOTAB_HXX 26 27 #include "undobase.hxx" 28 #include "markdata.hxx" 29 #include "formula/grammar.hxx" 30 #include <tools/color.hxx> 31 #include "tabbgcolor.hxx" 32 33 #ifndef _SVSTDARR_SHORTS 34 35 #define _SVSTDARR_SHORTS 36 #include <svl/svstdarr.hxx> 37 38 #endif 39 40 #ifndef _SVSTDARR_STRINGS 41 42 #define _SVSTDARR_STRINGS 43 #include <svl/svstdarr.hxx> 44 45 #endif 46 47 #include <com/sun/star/uno/Sequence.hxx> 48 49 #include <memory> 50 51 class ScDocShell; 52 class ScDocument; 53 class SdrUndoAction; 54 class ScPrintRangeSaver; 55 class SdrObject; 56 class ScDocProtection; 57 class ScTableProtection; 58 59 //---------------------------------------------------------------------------- 60 61 class ScUndoInsertTab : public ScSimpleUndo 62 { 63 public: 64 TYPEINFO(); 65 ScUndoInsertTab( 66 ScDocShell* pNewDocShell, 67 SCTAB nTabNum, 68 sal_Bool bApp, 69 const String& rNewName); 70 virtual ~ScUndoInsertTab(); 71 72 virtual void Undo(); 73 virtual void Redo(); 74 virtual void Repeat(SfxRepeatTarget& rTarget); 75 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 76 77 virtual String GetComment() const; 78 79 private: 80 String sNewName; 81 SdrUndoAction* pDrawUndo; 82 sal_uLong nEndChangeAction; 83 SCTAB nTab; 84 sal_Bool bAppend; 85 86 void SetChangeTrack(); 87 }; 88 89 class ScUndoInsertTables : public ScSimpleUndo 90 { 91 public: 92 TYPEINFO(); 93 ScUndoInsertTables( 94 ScDocShell* pNewDocShell, 95 SCTAB nTabNum, 96 sal_Bool bApp, 97 SvStrings *pNewNameList); 98 virtual ~ScUndoInsertTables(); 99 100 virtual void Undo(); 101 virtual void Redo(); 102 virtual void Repeat(SfxRepeatTarget& rTarget); 103 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 104 105 virtual String GetComment() const; 106 107 private: 108 109 SdrUndoAction* pDrawUndo; 110 SvStrings* pNameList; 111 sal_uLong nStartChangeAction; 112 sal_uLong nEndChangeAction; 113 SCTAB nTab; 114 sal_Bool bAppend; 115 116 void SetChangeTrack(); 117 }; 118 119 120 class ScUndoDeleteTab: public ScMoveUndo // Draw vom Move fuer geloeschte Tabelle 121 { 122 public: 123 TYPEINFO(); 124 ScUndoDeleteTab( 125 ScDocShell* pNewDocShell, 126 const SvShorts &theTabs, //SCTAB nNewTab, 127 ScDocument* pUndoDocument, 128 ScRefUndoData* pRefData ); 129 virtual ~ScUndoDeleteTab(); 130 131 virtual void Undo(); 132 virtual void Redo(); 133 virtual void Repeat(SfxRepeatTarget& rTarget); 134 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 135 136 virtual String GetComment() const; 137 138 private: 139 SvShorts theTabs; 140 sal_uLong nStartChangeAction; 141 sal_uLong nEndChangeAction; 142 143 void SetChangeTrack(); 144 }; 145 146 147 class ScUndoRenameTab: public ScSimpleUndo 148 { 149 public: 150 TYPEINFO(); 151 ScUndoRenameTab( 152 ScDocShell* pNewDocShell, 153 SCTAB nT, 154 const String& rOldName, 155 const String& rNewName); 156 virtual ~ScUndoRenameTab(); 157 158 virtual void Undo(); 159 virtual void Redo(); 160 virtual void Repeat(SfxRepeatTarget& rTarget); 161 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 162 163 virtual String GetComment() const; 164 165 private: 166 SCTAB nTab; 167 String sOldName; 168 String sNewName; 169 170 void DoChange( SCTAB nTab, const String& rName ) const; 171 }; 172 173 174 class ScUndoMoveTab: public ScSimpleUndo 175 { 176 public: 177 TYPEINFO(); 178 ScUndoMoveTab( ScDocShell* pNewDocShell, 179 const SvShorts &aOldTab, 180 const SvShorts &aNewTab); 181 virtual ~ScUndoMoveTab(); 182 183 virtual void Undo(); 184 virtual void Redo(); 185 virtual void Repeat(SfxRepeatTarget& rTarget); 186 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 187 188 virtual String GetComment() const; 189 190 private: 191 SvShorts theOldTabs; 192 SvShorts theNewTabs; 193 194 void DoChange( sal_Bool bUndo ) const; 195 }; 196 197 198 class ScUndoCopyTab: public ScSimpleUndo 199 { 200 public: 201 TYPEINFO(); 202 ScUndoCopyTab(ScDocShell* pNewDocShell, 203 const SvShorts &aOldTab, 204 const SvShorts &aNewTab); 205 206 virtual ~ScUndoCopyTab(); 207 208 virtual void Undo(); 209 virtual void Redo(); 210 virtual void Repeat(SfxRepeatTarget& rTarget); 211 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 212 213 virtual String GetComment() const; 214 215 private: 216 SdrUndoAction* pDrawUndo; 217 SvShorts theOldTabs; 218 SvShorts theNewTabs; 219 220 void DoChange() const; 221 }; 222 223 class ScUndoTabColor: public ScSimpleUndo 224 { 225 public: 226 TYPEINFO(); 227 ScUndoTabColor( 228 ScDocShell* pNewDocShell, 229 SCTAB nT, 230 const Color& aOTabBgColor, 231 const Color& aNTabBgColor); 232 ScUndoTabColor( 233 ScDocShell* pNewDocShell, 234 const ScUndoTabColorInfo::List& rUndoTabColorList); 235 virtual ~ScUndoTabColor(); 236 237 virtual void Undo(); 238 virtual void Redo(); 239 virtual void Repeat(SfxRepeatTarget& rTarget); 240 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 241 242 virtual String GetComment() const; 243 244 private: 245 ScUndoTabColorInfo::List aTabColorList; 246 bool bIsMultipleUndo; 247 248 void DoChange(bool bUndoType) const; 249 }; 250 251 class ScUndoMakeScenario: public ScSimpleUndo 252 { 253 public: 254 TYPEINFO(); 255 ScUndoMakeScenario( 256 ScDocShell* pNewDocShell, 257 SCTAB nSrc, SCTAB nDest, 258 const String& rN, const String& rC, 259 const Color& rCol, sal_uInt16 nF, 260 const ScMarkData& rMark ); 261 virtual ~ScUndoMakeScenario(); 262 263 virtual void Undo(); 264 virtual void Redo(); 265 virtual void Repeat(SfxRepeatTarget& rTarget); 266 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 267 268 virtual String GetComment() const; 269 270 private: 271 SCTAB nSrcTab; 272 SCTAB nDestTab; 273 String aName; 274 String aComment; 275 Color aColor; 276 sal_uInt16 nFlags; 277 ScMarkData aMarkData; 278 SdrUndoAction* pDrawUndo; 279 }; 280 281 282 class ScUndoImportTab : public ScSimpleUndo 283 { 284 public: 285 TYPEINFO(); 286 ScUndoImportTab( 287 ScDocShell* pShell, 288 SCTAB nNewTab, SCTAB nNewCount, 289 sal_Bool bNewLink ); 290 virtual ~ScUndoImportTab(); 291 292 virtual void Undo(); 293 virtual void Redo(); 294 virtual void Repeat(SfxRepeatTarget& rTarget); 295 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 296 297 virtual String GetComment() const; 298 299 private: 300 SCTAB nTab; 301 SCTAB nCount; 302 sal_Bool bLink; 303 ScDocument* pRedoDoc; 304 SdrUndoAction* pDrawUndo; 305 306 void DoChange() const; 307 }; 308 309 310 class ScUndoRemoveLink : public ScSimpleUndo 311 { 312 public: 313 TYPEINFO(); 314 ScUndoRemoveLink( // vor dem Loeschen aufrufen! 315 ScDocShell* pShell, 316 const String& rDoc ); 317 virtual ~ScUndoRemoveLink(); 318 319 virtual void Undo(); 320 virtual void Redo(); 321 virtual void Repeat(SfxRepeatTarget& rTarget); 322 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 323 324 virtual String GetComment() const; 325 326 private: 327 String aDocName; 328 String aFltName; 329 String aOptions; 330 sal_uLong nRefreshDelay; 331 sal_uInt16 nCount; 332 SCTAB* pTabs; 333 sal_uInt8* pModes; 334 String* pTabNames; 335 336 void DoChange( sal_Bool bLink ) const; 337 }; 338 339 340 class ScUndoShowHideTab : public ScSimpleUndo 341 { 342 public: 343 TYPEINFO(); 344 ScUndoShowHideTab( 345 ScDocShell* pShell, 346 SCTAB nNewTab, sal_Bool bNewShow ); 347 virtual ~ScUndoShowHideTab(); 348 349 virtual void Undo(); 350 virtual void Redo(); 351 virtual void Repeat(SfxRepeatTarget& rTarget); 352 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 353 354 virtual String GetComment() const; 355 356 private: 357 SCTAB nTab; 358 sal_Bool bShow; 359 360 void DoChange( sal_Bool bShow ) const; 361 }; 362 363 // ============================================================================ 364 365 /** This class implements undo & redo of document protect & unprotect 366 operations. */ 367 class ScUndoDocProtect : public ScSimpleUndo 368 { 369 public: 370 ScUndoDocProtect(ScDocShell* pShell, ::std::auto_ptr<ScDocProtection> pProtectSettings); 371 virtual ~ScUndoDocProtect(); 372 373 virtual void Undo(); 374 virtual void Redo(); 375 virtual void Repeat(SfxRepeatTarget& rTarget); 376 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 377 378 virtual String GetComment() const; 379 380 private: 381 ::std::auto_ptr<ScDocProtection> mpProtectSettings; 382 383 void DoProtect(bool bProtect); 384 }; 385 386 // ============================================================================ 387 388 /** This class implements undo & redo of both protect and unprotect of 389 sheet. */ 390 class ScUndoTabProtect : public ScSimpleUndo 391 { 392 public: 393 ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab, 394 ::std::auto_ptr<ScTableProtection> pProtectSettings); 395 virtual ~ScUndoTabProtect(); 396 397 virtual void Undo(); 398 virtual void Redo(); 399 virtual void Repeat(SfxRepeatTarget& rTarget); 400 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 401 402 virtual String GetComment() const; 403 404 private: 405 SCTAB mnTab; 406 ::std::auto_ptr<ScTableProtection> mpProtectSettings; 407 408 void DoProtect(bool bProtect); 409 }; 410 411 412 class ScUndoPrintRange : public ScSimpleUndo 413 { 414 public: 415 TYPEINFO(); 416 ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab, 417 ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew ); 418 virtual ~ScUndoPrintRange(); 419 420 virtual void Undo(); 421 virtual void Redo(); 422 virtual void Repeat(SfxRepeatTarget& rTarget); 423 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 424 425 virtual String GetComment() const; 426 427 private: 428 SCTAB nTab; 429 ScPrintRangeSaver* pOldRanges; 430 ScPrintRangeSaver* pNewRanges; 431 432 void DoChange( sal_Bool bUndo ); 433 }; 434 435 436 class ScUndoScenarioFlags: public ScSimpleUndo 437 { 438 public: 439 TYPEINFO(); 440 ScUndoScenarioFlags( 441 ScDocShell* pNewDocShell, SCTAB nT, 442 const String& rON, const String& rNN, 443 const String& rOC, const String& rNC, 444 const Color& rOCol, const Color& rNCol, 445 sal_uInt16 nOF, sal_uInt16 nNF ); 446 447 virtual ~ScUndoScenarioFlags(); 448 449 virtual void Undo(); 450 virtual void Redo(); 451 virtual void Repeat(SfxRepeatTarget& rTarget); 452 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 453 454 virtual String GetComment() const; 455 456 private: 457 SCTAB nTab; 458 String aOldName; 459 String aNewName; 460 String aOldComment; 461 String aNewComment; 462 Color aOldColor; 463 Color aNewColor; 464 sal_uInt16 nOldFlags; 465 sal_uInt16 nNewFlags; 466 }; 467 468 469 class ScUndoRenameObject: public ScSimpleUndo 470 { 471 public: 472 TYPEINFO(); 473 ScUndoRenameObject( 474 ScDocShell* pNewDocShell, const String& rPN, 475 const String& rON, const String& rNN ); 476 477 virtual ~ScUndoRenameObject(); 478 479 virtual void Undo(); 480 virtual void Redo(); 481 virtual void Repeat(SfxRepeatTarget& rTarget); 482 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 483 484 virtual String GetComment() const; 485 486 private: 487 String aPersistName; // to find object (works only for OLE objects) 488 String aOldName; 489 String aNewName; 490 491 SdrObject* GetObject(); 492 }; 493 494 495 class ScUndoLayoutRTL : public ScSimpleUndo 496 { 497 public: 498 TYPEINFO(); 499 ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, sal_Bool bNewRTL ); 500 virtual ~ScUndoLayoutRTL(); 501 502 virtual void Undo(); 503 virtual void Redo(); 504 virtual void Repeat(SfxRepeatTarget& rTarget); 505 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 506 507 virtual String GetComment() const; 508 509 private: 510 SCTAB nTab; 511 sal_Bool bRTL; 512 513 void DoChange( sal_Bool bNew ); 514 }; 515 516 517 //UNUSED2009-05 class ScUndoSetGrammar : public ScSimpleUndo 518 //UNUSED2009-05 { 519 //UNUSED2009-05 public: 520 //UNUSED2009-05 TYPEINFO(); 521 //UNUSED2009-05 ScUndoSetGrammar( ScDocShell* pShell, 522 //UNUSED2009-05 formula::FormulaGrammar::Grammar eGrammar ); 523 //UNUSED2009-05 virtual ~ScUndoSetGrammar(); 524 //UNUSED2009-05 525 //UNUSED2009-05 virtual void Undo(); 526 //UNUSED2009-05 virtual void Redo(); 527 //UNUSED2009-05 virtual void Repeat(SfxRepeatTarget& rTarget); 528 //UNUSED2009-05 virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const; 529 //UNUSED2009-05 530 //UNUSED2009-05 virtual String GetComment() const; 531 //UNUSED2009-05 532 //UNUSED2009-05 private: 533 //UNUSED2009-05 formula::FormulaGrammar::Grammar meNewGrammar, meOldGrammar; 534 //UNUSED2009-05 535 //UNUSED2009-05 void DoChange( formula::FormulaGrammar::Grammar eGrammar ); 536 //UNUSED2009-05 }; 537 538 #endif 539 540