1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <svx/svdundo.hxx> 32 #include "svx/svditext.hxx" 33 #include <svx/svdotext.hxx> 34 #include <svx/svdobj.hxx> 35 #include <svx/svdpage.hxx> 36 #include <svx/svdlayer.hxx> 37 #include <svx/svdmodel.hxx> 38 #include <svx/svdview.hxx> 39 #include "svx/svdstr.hrc" // Namen aus der Resource 40 #include "svx/svdglob.hxx" // StringCache 41 #include <svx/scene3d.hxx> 42 #include <editeng/outlobj.hxx> 43 #include <svx/svdogrp.hxx> 44 #include <svx/sdr/properties/itemsettools.hxx> 45 #include <svx/sdr/properties/properties.hxx> 46 #include <svx/svdocapt.hxx> 47 #include <svl/whiter.hxx> 48 #include <svx/e3dsceneupdater.hxx> 49 50 #include "svx/svdviter.hxx" 51 52 //////////////////////////////////////////////////////////////////////////////////////////////////// 53 54 // iterates over all views and unmarks this SdrObject if it is marked 55 static void ImplUnmarkObject( SdrObject* pObj ) 56 { 57 SdrViewIter aIter( pObj ); 58 for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() ) 59 { 60 pView->MarkObj( pObj, pView->GetSdrPageView(), sal_True ); 61 } 62 } 63 64 //////////////////////////////////////////////////////////////////////////////////////////////////// 65 66 TYPEINIT1(SdrUndoAction,SfxUndoAction); 67 68 sal_Bool SdrUndoAction::CanRepeat(SfxRepeatTarget& rView) const 69 { 70 SdrView* pV=PTR_CAST(SdrView,&rView); 71 if (pV!=NULL) return CanSdrRepeat(*pV); 72 return sal_False; 73 } 74 75 void SdrUndoAction::Repeat(SfxRepeatTarget& rView) 76 { 77 SdrView* pV=PTR_CAST(SdrView,&rView); 78 if (pV!=NULL) SdrRepeat(*pV); 79 DBG_ASSERT(pV!=NULL,"Repeat: Uebergebenes SfxRepeatTarget ist keine SdrView"); 80 } 81 82 XubString SdrUndoAction::GetRepeatComment(SfxRepeatTarget& rView) const 83 { 84 SdrView* pV=PTR_CAST(SdrView,&rView); 85 if (pV!=NULL) return GetSdrRepeatComment(*pV); 86 return String(); 87 } 88 89 bool SdrUndoAction::CanSdrRepeat(SdrView& /*rView*/) const 90 { 91 return sal_False; 92 } 93 94 void SdrUndoAction::SdrRepeat(SdrView& /*rView*/) 95 { 96 } 97 98 XubString SdrUndoAction::GetSdrRepeatComment(SdrView& /*rView*/) const 99 { 100 return String(); 101 } 102 103 //////////////////////////////////////////////////////////////////////////////////////////////////// 104 105 SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod) 106 : SdrUndoAction(rNewMod), 107 aBuf(1024,32,32), 108 eFunction(SDRREPFUNC_OBJ_NONE) /*#72642#*/ 109 {} 110 111 SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod,const String& rStr) 112 : SdrUndoAction(rNewMod), 113 aBuf(1024,32,32), 114 aComment(rStr), 115 eFunction(SDRREPFUNC_OBJ_NONE) 116 {} 117 118 SdrUndoGroup::~SdrUndoGroup() 119 { 120 Clear(); 121 } 122 123 void SdrUndoGroup::Clear() 124 { 125 for (sal_uIntPtr nu=0; nu<GetActionCount(); nu++) { 126 SdrUndoAction* pAct=GetAction(nu); 127 delete pAct; 128 } 129 aBuf.Clear(); 130 } 131 132 void SdrUndoGroup::AddAction(SdrUndoAction* pAct) 133 { 134 aBuf.Insert(pAct,CONTAINER_APPEND); 135 } 136 137 void SdrUndoGroup::push_front( SdrUndoAction* pAct ) 138 { 139 aBuf.Insert(pAct, (sal_uIntPtr)0 ); 140 } 141 142 void SdrUndoGroup::Undo() 143 { 144 for (sal_uIntPtr nu=GetActionCount(); nu>0;) { 145 nu--; 146 SdrUndoAction* pAct=GetAction(nu); 147 pAct->Undo(); 148 } 149 } 150 151 void SdrUndoGroup::Redo() 152 { 153 for (sal_uIntPtr nu=0; nu<GetActionCount(); nu++) { 154 SdrUndoAction* pAct=GetAction(nu); 155 pAct->Redo(); 156 } 157 } 158 159 XubString SdrUndoGroup::GetComment() const 160 { 161 XubString aRet(aComment); 162 sal_Char aSearchText[] = "%1"; 163 String aSearchString(aSearchText, sizeof(aSearchText-1)); 164 165 aRet.SearchAndReplace(aSearchString, aObjDescription); 166 167 return aRet; 168 } 169 170 bool SdrUndoGroup::CanSdrRepeat(SdrView& rView) const 171 { 172 switch (eFunction) { 173 case SDRREPFUNC_OBJ_NONE : return sal_False; 174 case SDRREPFUNC_OBJ_DELETE : return rView.AreObjectsMarked(); 175 case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: return rView.IsCombinePossible(sal_False); 176 case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : return rView.IsCombinePossible(sal_True); 177 case SDRREPFUNC_OBJ_DISMANTLE_POLYS : return rView.IsDismantlePossible(sal_False); 178 case SDRREPFUNC_OBJ_DISMANTLE_LINES : return rView.IsDismantlePossible(sal_True); 179 case SDRREPFUNC_OBJ_CONVERTTOPOLY : return rView.IsConvertToPolyObjPossible(sal_False); 180 case SDRREPFUNC_OBJ_CONVERTTOPATH : return rView.IsConvertToPathObjPossible(sal_False); 181 case SDRREPFUNC_OBJ_GROUP : return rView.IsGroupPossible(); 182 case SDRREPFUNC_OBJ_UNGROUP : return rView.IsUnGroupPossible(); 183 case SDRREPFUNC_OBJ_PUTTOTOP : return rView.IsToTopPossible(); 184 case SDRREPFUNC_OBJ_PUTTOBTM : return rView.IsToBtmPossible(); 185 case SDRREPFUNC_OBJ_MOVTOTOP : return rView.IsToTopPossible(); 186 case SDRREPFUNC_OBJ_MOVTOBTM : return rView.IsToBtmPossible(); 187 case SDRREPFUNC_OBJ_REVORDER : return rView.IsReverseOrderPossible(); 188 case SDRREPFUNC_OBJ_IMPORTMTF : return rView.IsImportMtfPossible(); 189 default: break; 190 } // switch 191 return sal_False; 192 } 193 194 void SdrUndoGroup::SdrRepeat(SdrView& rView) 195 { 196 switch (eFunction) { 197 case SDRREPFUNC_OBJ_NONE : break; 198 case SDRREPFUNC_OBJ_DELETE : rView.DeleteMarked(); break; 199 case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: rView.CombineMarkedObjects(sal_False); break; 200 case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : rView.CombineMarkedObjects(sal_True); break; 201 case SDRREPFUNC_OBJ_DISMANTLE_POLYS : rView.DismantleMarkedObjects(sal_False); break; 202 case SDRREPFUNC_OBJ_DISMANTLE_LINES : rView.DismantleMarkedObjects(sal_True); break; 203 case SDRREPFUNC_OBJ_CONVERTTOPOLY : rView.ConvertMarkedToPolyObj(sal_False); break; 204 case SDRREPFUNC_OBJ_CONVERTTOPATH : rView.ConvertMarkedToPathObj(sal_False); break; 205 case SDRREPFUNC_OBJ_GROUP : rView.GroupMarked(); break; 206 case SDRREPFUNC_OBJ_UNGROUP : rView.UnGroupMarked(); break; 207 case SDRREPFUNC_OBJ_PUTTOTOP : rView.PutMarkedToTop(); break; 208 case SDRREPFUNC_OBJ_PUTTOBTM : rView.PutMarkedToBtm(); break; 209 case SDRREPFUNC_OBJ_MOVTOTOP : rView.MovMarkedToTop(); break; 210 case SDRREPFUNC_OBJ_MOVTOBTM : rView.MovMarkedToBtm(); break; 211 case SDRREPFUNC_OBJ_REVORDER : rView.ReverseOrderOfMarked(); break; 212 case SDRREPFUNC_OBJ_IMPORTMTF : rView.DoImportMarkedMtf(); break; 213 default: break; 214 } // switch 215 } 216 217 XubString SdrUndoGroup::GetSdrRepeatComment(SdrView& /*rView*/) const 218 { 219 XubString aRet(aComment); 220 sal_Char aSearchText[] = "%1"; 221 String aSearchString(aSearchText, sizeof(aSearchText-1)); 222 223 aRet.SearchAndReplace(aSearchString, ImpGetResStr(STR_ObjNameSingulPlural)); 224 225 return aRet; 226 } 227 228 //////////////////////////////////////////////////////////////////////////////////////////////////// 229 //////////////////////////////////////////////////////////////////////////////////////////////////// 230 // 231 // @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@ @@@@ 232 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 233 // @@ @@ @@ @@ @@ @@ @@ @@ @@ 234 // @@ @@ @@@@@ @@ @@@@ @@ @@ @@@@ 235 // @@ @@ @@ @@ @@ @@ @@ @@ @@ 236 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 237 // @@@@ @@@@@ @@@@ @@@@@ @@@@ @@ @@@@ 238 // 239 //////////////////////////////////////////////////////////////////////////////////////////////////// 240 //////////////////////////////////////////////////////////////////////////////////////////////////// 241 242 SdrUndoObj::SdrUndoObj(SdrObject& rNewObj): 243 SdrUndoAction(*rNewObj.GetModel()), 244 pObj(&rNewObj) 245 { 246 } 247 248 void SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject, sal_uInt16 nStrCacheID, String& rStr, FASTBOOL bRepeat ) 249 { 250 rStr = ImpGetResStr(nStrCacheID); 251 sal_Char aSearchText[] = "%1"; 252 String aSearchString(aSearchText, sizeof(aSearchText-1)); 253 254 xub_StrLen nPos = rStr.Search(aSearchString); 255 256 if(nPos != STRING_NOTFOUND) 257 { 258 rStr.Erase(nPos, 2); 259 260 if(bRepeat) 261 { 262 rStr.Insert(ImpGetResStr(STR_ObjNameSingulPlural), nPos); 263 } 264 else 265 { 266 XubString aStr; 267 268 _rForObject.TakeObjNameSingul(aStr); 269 rStr.Insert(aStr, nPos); 270 } 271 } 272 } 273 274 void SdrUndoObj::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, XubString& rStr, FASTBOOL bRepeat) const 275 { 276 if ( pObj ) 277 GetDescriptionStringForObject( *pObj, nStrCacheID, rStr, bRepeat ); 278 } 279 280 // #94278# common call method for evtl. page change when UNDO/REDO 281 // is triggered 282 void SdrUndoObj::ImpShowPageOfThisObject() 283 { 284 if(pObj && pObj->IsInserted() && pObj->GetPage() && pObj->GetModel()) 285 { 286 SdrHint aHint(HINT_SWITCHTOPAGE); 287 288 aHint.SetObject(pObj); 289 aHint.SetPage(pObj->GetPage()); 290 291 pObj->GetModel()->Broadcast(aHint); 292 } 293 } 294 295 //////////////////////////////////////////////////////////////////////////////////////////////////// 296 297 SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, FASTBOOL bStyleSheet1, FASTBOOL bSaveText) 298 : SdrUndoObj(rNewObj), 299 pUndoSet(NULL), 300 pRedoSet(NULL), 301 pRepeatSet(NULL), 302 pUndoStyleSheet(NULL), 303 pRedoStyleSheet(NULL), 304 pRepeatStyleSheet(NULL), 305 bHaveToTakeRedoSet(sal_True), 306 pTextUndo(NULL), 307 308 // #i8508# 309 pTextRedo(NULL), 310 311 pUndoGroup(NULL) 312 { 313 bStyleSheet = bStyleSheet1; 314 315 SdrObjList* pOL = rNewObj.GetSubList(); 316 sal_Bool bIsGroup(pOL!=NULL && pOL->GetObjCount()); 317 sal_Bool bIs3DScene(bIsGroup && pObj->ISA(E3dScene)); 318 319 if(bIsGroup) 320 { 321 // Aha, Gruppenobjekt 322 pUndoGroup = new SdrUndoGroup(*pObj->GetModel()); 323 sal_uInt32 nObjAnz(pOL->GetObjCount()); 324 325 for(sal_uInt32 nObjNum(0); nObjNum < nObjAnz; nObjNum++) 326 { 327 pUndoGroup->AddAction( 328 new SdrUndoAttrObj(*pOL->GetObj(nObjNum), bStyleSheet1)); 329 } 330 } 331 332 if(!bIsGroup || bIs3DScene) 333 { 334 if(pUndoSet) 335 { 336 delete pUndoSet; 337 } 338 339 pUndoSet = new SfxItemSet(pObj->GetMergedItemSet()); 340 341 if(bStyleSheet) 342 pUndoStyleSheet = pObj->GetStyleSheet(); 343 344 if(bSaveText) 345 { 346 pTextUndo = pObj->GetOutlinerParaObject(); 347 if(pTextUndo) 348 pTextUndo = new OutlinerParaObject(*pTextUndo); 349 } 350 } 351 } 352 353 SdrUndoAttrObj::~SdrUndoAttrObj() 354 { 355 if(pUndoSet) 356 delete pUndoSet; 357 if(pRedoSet) 358 delete pRedoSet; 359 if(pRepeatSet) 360 delete pRepeatSet; 361 if(pUndoGroup) 362 delete pUndoGroup; 363 if(pTextUndo) 364 delete pTextUndo; 365 366 // #i8508# 367 if(pTextRedo) 368 delete pTextRedo; 369 } 370 371 void SdrUndoAttrObj::SetRepeatAttr(const SfxItemSet& rSet) 372 { 373 if(pRepeatSet) 374 delete pRepeatSet; 375 376 pRepeatSet = new SfxItemSet(rSet); 377 } 378 379 void SdrUndoAttrObj::Undo() 380 { 381 E3DModifySceneSnapRectUpdater aUpdater(pObj); 382 sal_Bool bIs3DScene(pObj && pObj->ISA(E3dScene)); 383 384 // #94278# Trigger PageChangeCall 385 ImpShowPageOfThisObject(); 386 387 if(!pUndoGroup || bIs3DScene) 388 { 389 if(bHaveToTakeRedoSet) 390 { 391 bHaveToTakeRedoSet = sal_False; 392 393 if(pRedoSet) 394 { 395 delete pRedoSet; 396 } 397 398 pRedoSet = new SfxItemSet(pObj->GetMergedItemSet()); 399 400 if(bStyleSheet) 401 pRedoStyleSheet=pObj->GetStyleSheet(); 402 403 if(pTextUndo) 404 { 405 // #i8508# 406 pTextRedo = pObj->GetOutlinerParaObject(); 407 408 if(pTextRedo) 409 pTextRedo = new OutlinerParaObject(*pTextRedo); 410 } 411 } 412 413 if(bStyleSheet) 414 { 415 pRedoStyleSheet = pObj->GetStyleSheet(); 416 pObj->SetStyleSheet(pUndoStyleSheet, sal_True); 417 } 418 419 sdr::properties::ItemChangeBroadcaster aItemChange(*pObj); 420 421 // #105122# Since ClearItem sets back everything to normal 422 // it also sets fit-to-size text to non-fit-to-size text and 423 // switches on autogrowheight (the default). That may lead to 424 // loosing the geometry size info for the object when it is 425 // re-layouted from AdjustTextFrameWidthAndHeight(). This makes 426 // rescuing the size of the object necessary. 427 const Rectangle aSnapRect = pObj->GetSnapRect(); 428 429 if(pUndoSet) 430 { 431 // #109587# 432 if(pObj->ISA(SdrCaptionObj)) 433 { 434 // do a more smooth item deletion here, else the text 435 // rect will be reformatted, especially when information regarding 436 // vertical text is changed. When clearing only set items it's 437 // slower, but safer regarding such information (it's not changed 438 // usually) 439 SfxWhichIter aIter(*pUndoSet); 440 sal_uInt16 nWhich(aIter.FirstWhich()); 441 442 while(nWhich) 443 { 444 if(SFX_ITEM_SET != pUndoSet->GetItemState(nWhich, sal_False)) 445 { 446 pObj->ClearMergedItem(nWhich); 447 } 448 449 nWhich = aIter.NextWhich(); 450 } 451 } 452 else 453 { 454 pObj->ClearMergedItem(); 455 } 456 457 pObj->SetMergedItemSet(*pUndoSet); 458 } 459 460 // #105122# Restore prev size here when it was changed. 461 if(aSnapRect != pObj->GetSnapRect()) 462 { 463 pObj->NbcSetSnapRect(aSnapRect); 464 } 465 466 pObj->GetProperties().BroadcastItemChange(aItemChange); 467 468 if(pTextUndo) 469 { 470 pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo)); 471 } 472 } 473 474 if(pUndoGroup) 475 { 476 pUndoGroup->Undo(); 477 } 478 } 479 480 void SdrUndoAttrObj::Redo() 481 { 482 E3DModifySceneSnapRectUpdater aUpdater(pObj); 483 sal_Bool bIs3DScene(pObj && pObj->ISA(E3dScene)); 484 485 if(!pUndoGroup || bIs3DScene) 486 { 487 if(bStyleSheet) 488 { 489 pUndoStyleSheet = pObj->GetStyleSheet(); 490 pObj->SetStyleSheet(pRedoStyleSheet, sal_True); 491 } 492 493 sdr::properties::ItemChangeBroadcaster aItemChange(*pObj); 494 495 // #105122# 496 const Rectangle aSnapRect = pObj->GetSnapRect(); 497 498 if(pRedoSet) 499 { 500 // #109587# 501 if(pObj->ISA(SdrCaptionObj)) 502 { 503 // do a more smooth item deletion here, else the text 504 // rect will be reformatted, especially when information regarding 505 // vertical text is changed. When clearing only set items it's 506 // slower, but safer regarding such information (it's not changed 507 // usually) 508 SfxWhichIter aIter(*pRedoSet); 509 sal_uInt16 nWhich(aIter.FirstWhich()); 510 511 while(nWhich) 512 { 513 if(SFX_ITEM_SET != pRedoSet->GetItemState(nWhich, sal_False)) 514 { 515 pObj->ClearMergedItem(nWhich); 516 } 517 518 nWhich = aIter.NextWhich(); 519 } 520 } 521 else 522 { 523 pObj->ClearMergedItem(); 524 } 525 526 pObj->SetMergedItemSet(*pRedoSet); 527 } 528 529 // #105122# Restore prev size here when it was changed. 530 if(aSnapRect != pObj->GetSnapRect()) 531 { 532 pObj->NbcSetSnapRect(aSnapRect); 533 } 534 535 pObj->GetProperties().BroadcastItemChange(aItemChange); 536 537 // #i8508# 538 if(pTextRedo) 539 { 540 pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo)); 541 } 542 } 543 544 if(pUndoGroup) 545 { 546 pUndoGroup->Redo(); 547 } 548 549 // #94278# Trigger PageChangeCall 550 ImpShowPageOfThisObject(); 551 } 552 553 XubString SdrUndoAttrObj::GetComment() const 554 { 555 XubString aStr; 556 557 if(bStyleSheet) 558 { 559 ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr); 560 } 561 else 562 { 563 ImpTakeDescriptionStr(STR_EditSetAttributes, aStr); 564 } 565 566 return aStr; 567 } 568 569 void SdrUndoAttrObj::SdrRepeat(SdrView& rView) 570 { 571 if(pRepeatSet) 572 { 573 rView.SetAttrToMarked(*pRepeatSet, sal_False); 574 } 575 } 576 577 bool SdrUndoAttrObj::CanSdrRepeat(SdrView& rView) const 578 { 579 return (pRepeatSet!=0L && rView.AreObjectsMarked()); 580 } 581 582 XubString SdrUndoAttrObj::GetSdrRepeatComment(SdrView& /*rView*/) const 583 { 584 XubString aStr; 585 586 if(bStyleSheet) 587 { 588 ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr, sal_True); 589 } 590 else 591 { 592 ImpTakeDescriptionStr(STR_EditSetAttributes, aStr, sal_True); 593 } 594 595 return aStr; 596 } 597 598 //////////////////////////////////////////////////////////////////////////////////////////////////// 599 600 void SdrUndoMoveObj::Undo() 601 { 602 // #94278# Trigger PageChangeCall 603 ImpShowPageOfThisObject(); 604 605 pObj->Move(Size(-aDistance.Width(),-aDistance.Height())); 606 } 607 608 void SdrUndoMoveObj::Redo() 609 { 610 pObj->Move(Size(aDistance.Width(),aDistance.Height())); 611 612 // #94278# Trigger PageChangeCall 613 ImpShowPageOfThisObject(); 614 } 615 616 XubString SdrUndoMoveObj::GetComment() const 617 { 618 XubString aStr; 619 ImpTakeDescriptionStr(STR_EditMove,aStr); 620 return aStr; 621 } 622 623 void SdrUndoMoveObj::SdrRepeat(SdrView& rView) 624 { 625 rView.MoveMarkedObj(aDistance); 626 } 627 628 bool SdrUndoMoveObj::CanSdrRepeat(SdrView& rView) const 629 { 630 return rView.AreObjectsMarked(); 631 } 632 633 XubString SdrUndoMoveObj::GetSdrRepeatComment(SdrView& /*rView*/) const 634 { 635 XubString aStr; 636 ImpTakeDescriptionStr(STR_EditMove,aStr,sal_True); 637 return aStr; 638 } 639 640 //////////////////////////////////////////////////////////////////////////////////////////////////// 641 642 SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj): 643 SdrUndoObj(rNewObj), 644 pUndoGeo(NULL), 645 pRedoGeo(NULL), 646 pUndoGroup(NULL) 647 { 648 SdrObjList* pOL=rNewObj.GetSubList(); 649 if (pOL!=NULL && pOL->GetObjCount() && !rNewObj.ISA(E3dScene)) 650 { 651 // Aha, Gruppenobjekt 652 // AW: Aber keine 3D-Szene, dann nur fuer die Szene selbst den Undo anlegen 653 pUndoGroup=new SdrUndoGroup(*pObj->GetModel()); 654 sal_uIntPtr nObjAnz=pOL->GetObjCount(); 655 for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) { 656 pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum))); 657 } 658 } else { 659 pUndoGeo=pObj->GetGeoData(); 660 } 661 } 662 663 SdrUndoGeoObj::~SdrUndoGeoObj() 664 { 665 if (pUndoGeo!=NULL) delete pUndoGeo; 666 if (pRedoGeo!=NULL) delete pRedoGeo; 667 if (pUndoGroup!=NULL) delete pUndoGroup; 668 } 669 670 void SdrUndoGeoObj::Undo() 671 { 672 // #94278# Trigger PageChangeCall 673 ImpShowPageOfThisObject(); 674 675 if(pUndoGroup) 676 { 677 pUndoGroup->Undo(); 678 679 // #97172# 680 // only repaint, no objectchange 681 pObj->ActionChanged(); 682 } 683 else 684 { 685 if (pRedoGeo!=NULL) delete pRedoGeo; 686 pRedoGeo=pObj->GetGeoData(); 687 pObj->SetGeoData(*pUndoGeo); 688 } 689 } 690 691 void SdrUndoGeoObj::Redo() 692 { 693 if(pUndoGroup) 694 { 695 pUndoGroup->Redo(); 696 697 // #97172# 698 // only repaint, no objectchange 699 pObj->ActionChanged(); 700 } 701 else 702 { 703 if (pUndoGeo!=NULL) delete pUndoGeo; 704 pUndoGeo=pObj->GetGeoData(); 705 pObj->SetGeoData(*pRedoGeo); 706 } 707 708 // #94278# Trigger PageChangeCall 709 ImpShowPageOfThisObject(); 710 } 711 712 XubString SdrUndoGeoObj::GetComment() const 713 { 714 XubString aStr; 715 ImpTakeDescriptionStr(STR_DragMethObjOwn,aStr); 716 return aStr; 717 } 718 719 //////////////////////////////////////////////////////////////////////////////////////////////////// 720 721 SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect) 722 : SdrUndoObj(rNewObj), 723 bOwner(sal_False), 724 pView(NULL), 725 pPageView(NULL) 726 { 727 pObjList=pObj->GetObjList(); 728 if (bOrdNumDirect) { 729 nOrdNum=pObj->GetOrdNumDirect(); 730 } else { 731 nOrdNum=pObj->GetOrdNum(); 732 } 733 } 734 735 SdrUndoObjList::~SdrUndoObjList() 736 { 737 if (pObj!=NULL && IsOwner()) 738 { 739 // Attribute muessen wieder in den regulaeren Pool 740 SetOwner(sal_False); 741 742 // nun loeschen 743 SdrObject::Free( pObj ); 744 } 745 } 746 747 void SdrUndoObjList::SetOwner(bool bNew) 748 { 749 bOwner = bNew; 750 } 751 752 //////////////////////////////////////////////////////////////////////////////////////////////////// 753 754 void SdrUndoRemoveObj::Undo() 755 { 756 // #94278# Trigger PageChangeCall 757 ImpShowPageOfThisObject(); 758 759 DBG_ASSERT(!pObj->IsInserted(),"UndoRemoveObj: pObj ist bereits Inserted"); 760 if (!pObj->IsInserted()) 761 { 762 // #i11426# 763 // For UNDOs in Calc/Writer it is necessary to adapt the anchor 764 // pos of the target object. 765 Point aOwnerAnchorPos(0, 0); 766 767 if(pObjList 768 && pObjList->GetOwnerObj() 769 && pObjList->GetOwnerObj()->ISA(SdrObjGroup)) 770 { 771 aOwnerAnchorPos = pObjList->GetOwnerObj()->GetAnchorPos(); 772 } 773 774 E3DModifySceneSnapRectUpdater aUpdater(pObjList->GetOwnerObj()); 775 SdrInsertReason aReason(SDRREASON_UNDO); 776 pObjList->InsertObject(pObj,nOrdNum,&aReason); 777 778 // #i11426# 779 if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y()) 780 { 781 pObj->NbcSetAnchorPos(aOwnerAnchorPos); 782 } 783 } 784 } 785 786 void SdrUndoRemoveObj::Redo() 787 { 788 DBG_ASSERT(pObj->IsInserted(),"RedoRemoveObj: pObj ist nicht Inserted"); 789 if (pObj->IsInserted()) 790 { 791 ImplUnmarkObject( pObj ); 792 E3DModifySceneSnapRectUpdater aUpdater(pObj); 793 pObjList->RemoveObject(nOrdNum); 794 } 795 796 // #94278# Trigger PageChangeCall 797 ImpShowPageOfThisObject(); 798 } 799 800 //////////////////////////////////////////////////////////////////////////////////////////////////// 801 802 void SdrUndoInsertObj::Undo() 803 { 804 // #94278# Trigger PageChangeCall 805 ImpShowPageOfThisObject(); 806 807 DBG_ASSERT(pObj->IsInserted(),"UndoInsertObj: pObj ist nicht Inserted"); 808 if (pObj->IsInserted()) 809 { 810 ImplUnmarkObject( pObj ); 811 812 #ifdef DBG_UTIL 813 SdrObject* pChkObj= 814 #endif 815 pObjList->RemoveObject(nOrdNum); 816 DBG_ASSERT(pChkObj==pObj,"UndoInsertObj: RemoveObjNum!=pObj"); 817 } 818 } 819 820 void SdrUndoInsertObj::Redo() 821 { 822 DBG_ASSERT(!pObj->IsInserted(),"RedoInsertObj: pObj ist bereits Inserted"); 823 if (!pObj->IsInserted()) 824 { 825 // --> OD 2005-05-10 #i45952# - restore anchor position of an object, 826 // which becomes a member of a group, because its cleared in method 827 // <InsertObject(..)>. Needed for correct ReDo in Writer. 828 Point aAnchorPos( 0, 0 ); 829 if ( pObjList && 830 pObjList->GetOwnerObj() && 831 pObjList->GetOwnerObj()->ISA(SdrObjGroup) ) 832 { 833 aAnchorPos = pObj->GetAnchorPos(); 834 } 835 // <-- 836 837 SdrInsertReason aReason(SDRREASON_UNDO); 838 pObjList->InsertObject(pObj,nOrdNum,&aReason); 839 840 // --> OD 2005-05-10 #i45952# 841 if ( aAnchorPos.X() || aAnchorPos.Y() ) 842 { 843 pObj->NbcSetAnchorPos( aAnchorPos ); 844 } 845 // <-- 846 } 847 848 // #94278# Trigger PageChangeCall 849 ImpShowPageOfThisObject(); 850 } 851 852 //////////////////////////////////////////////////////////////////////////////////////////////////// 853 854 void SdrUndoDelObj::Undo() 855 { 856 SdrUndoRemoveObj::Undo(); 857 DBG_ASSERT(IsOwner(),"UndoDeleteObj: pObj gehoert nicht der UndoAction"); 858 SetOwner(sal_False); 859 } 860 861 void SdrUndoDelObj::Redo() 862 { 863 SdrUndoRemoveObj::Redo(); 864 DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj gehoert bereits der UndoAction"); 865 SetOwner(sal_True); 866 } 867 868 XubString SdrUndoDelObj::GetComment() const 869 { 870 XubString aStr; 871 ImpTakeDescriptionStr(STR_EditDelete,aStr); 872 return aStr; 873 } 874 875 void SdrUndoDelObj::SdrRepeat(SdrView& rView) 876 { 877 rView.DeleteMarked(); 878 } 879 880 bool SdrUndoDelObj::CanSdrRepeat(SdrView& rView) const 881 { 882 return rView.AreObjectsMarked(); 883 } 884 885 XubString SdrUndoDelObj::GetSdrRepeatComment(SdrView& /*rView*/) const 886 { 887 XubString aStr; 888 ImpTakeDescriptionStr(STR_EditDelete,aStr,sal_True); 889 return aStr; 890 } 891 892 //////////////////////////////////////////////////////////////////////////////////////////////////// 893 894 void SdrUndoNewObj::Undo() 895 { 896 SdrUndoInsertObj::Undo(); 897 DBG_ASSERT(!IsOwner(),"RedoNewObj: pObj gehoert bereits der UndoAction"); 898 SetOwner(sal_True); 899 } 900 901 void SdrUndoNewObj::Redo() 902 { 903 SdrUndoInsertObj::Redo(); 904 DBG_ASSERT(IsOwner(),"RedoNewObj: pObj gehoert nicht der UndoAction"); 905 SetOwner(sal_False); 906 } 907 908 String SdrUndoNewObj::GetComment( const SdrObject& _rForObject ) 909 { 910 String sComment; 911 GetDescriptionStringForObject( _rForObject, STR_UndoInsertObj, sComment ); 912 return sComment; 913 } 914 915 XubString SdrUndoNewObj::GetComment() const 916 { 917 XubString aStr; 918 ImpTakeDescriptionStr(STR_UndoInsertObj,aStr); 919 return aStr; 920 } 921 922 SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject& rOldObj1, SdrObject& rNewObj1, bool bOrdNumDirect) 923 : SdrUndoObj(rOldObj1), 924 bOldOwner(sal_False), 925 bNewOwner(sal_False), 926 pNewObj(&rNewObj1) 927 { 928 SetOldOwner(sal_True); 929 930 pObjList=pObj->GetObjList(); 931 if (bOrdNumDirect) { 932 nOrdNum=pObj->GetOrdNumDirect(); 933 } else { 934 nOrdNum=pObj->GetOrdNum(); 935 } 936 } 937 938 SdrUndoReplaceObj::~SdrUndoReplaceObj() 939 { 940 if (pObj!=NULL && IsOldOwner()) 941 { 942 // Attribute muessen wieder in den regulaeren Pool 943 SetOldOwner(sal_False); 944 945 // nun loeschen 946 SdrObject::Free( pObj ); 947 } 948 if (pNewObj!=NULL && IsNewOwner()) 949 { 950 // Attribute muessen wieder in den regulaeren Pool 951 SetNewOwner(sal_False); 952 953 // nun loeschen 954 SdrObject::Free( pNewObj ); 955 } 956 } 957 958 void SdrUndoReplaceObj::Undo() 959 { 960 // #94278# Trigger PageChangeCall 961 ImpShowPageOfThisObject(); 962 963 if (IsOldOwner() && !IsNewOwner()) 964 { 965 DBG_ASSERT(!pObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Altes Objekt ist bereits inserted!"); 966 DBG_ASSERT(pNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Neues Objekt ist nicht inserted!"); 967 SetOldOwner(sal_False); 968 SetNewOwner(sal_True); 969 970 ImplUnmarkObject( pNewObj ); 971 pObjList->ReplaceObject(pObj,nOrdNum); 972 } 973 else 974 { 975 DBG_ERROR("SdrUndoReplaceObj::Undo(): IsMine-Flags stehen verkehrt. Doppelter Undo-Aufruf?"); 976 } 977 } 978 979 void SdrUndoReplaceObj::Redo() 980 { 981 if (!IsOldOwner() && IsNewOwner()) 982 { 983 DBG_ASSERT(!pNewObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Neues Objekt ist bereits inserted!"); 984 DBG_ASSERT(pObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Altes Objekt ist nicht inserted!"); 985 SetOldOwner(sal_True); 986 SetNewOwner(sal_False); 987 988 ImplUnmarkObject( pObj ); 989 pObjList->ReplaceObject(pNewObj,nOrdNum); 990 991 } 992 else 993 { 994 DBG_ERROR("SdrUndoReplaceObj::Redo(): IsMine-Flags stehen verkehrt. Doppelter Redo-Aufruf?"); 995 } 996 997 // #94278# Trigger PageChangeCall 998 ImpShowPageOfThisObject(); 999 } 1000 1001 void SdrUndoReplaceObj::SetNewOwner(bool bNew) 1002 { 1003 bNewOwner = bNew; 1004 } 1005 1006 void SdrUndoReplaceObj::SetOldOwner(bool bNew) 1007 { 1008 bOldOwner = bNew; 1009 } 1010 1011 //////////////////////////////////////////////////////////////////////////////////////////////////// 1012 1013 XubString SdrUndoCopyObj::GetComment() const 1014 { 1015 XubString aStr; 1016 ImpTakeDescriptionStr(STR_UndoCopyObj,aStr); 1017 return aStr; 1018 } 1019 1020 //////////////////////////////////////////////////////////////////////////////////////////////////// 1021 // #i11702# 1022 1023 SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject& rObj, SdrLayerID aOldLayer, SdrLayerID aNewLayer) 1024 : SdrUndoObj(rObj), 1025 maOldLayer(aOldLayer), 1026 maNewLayer(aNewLayer) 1027 { 1028 } 1029 1030 void SdrUndoObjectLayerChange::Undo() 1031 { 1032 ImpShowPageOfThisObject(); 1033 pObj->SetLayer(maOldLayer); 1034 } 1035 1036 void SdrUndoObjectLayerChange::Redo() 1037 { 1038 pObj->SetLayer(maNewLayer); 1039 ImpShowPageOfThisObject(); 1040 } 1041 1042 //////////////////////////////////////////////////////////////////////////////////////////////////// 1043 1044 SdrUndoObjOrdNum::SdrUndoObjOrdNum(SdrObject& rNewObj, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1): 1045 SdrUndoObj(rNewObj), 1046 nOldOrdNum(nOldOrdNum1), 1047 nNewOrdNum(nNewOrdNum1) 1048 { 1049 } 1050 1051 void SdrUndoObjOrdNum::Undo() 1052 { 1053 // #94278# Trigger PageChangeCall 1054 ImpShowPageOfThisObject(); 1055 1056 SdrObjList* pOL=pObj->GetObjList(); 1057 if (pOL==NULL) { 1058 DBG_ERROR("UndoObjOrdNum: pObj hat keine ObjList"); 1059 return; 1060 } 1061 pOL->SetObjectOrdNum(nNewOrdNum,nOldOrdNum); 1062 } 1063 1064 void SdrUndoObjOrdNum::Redo() 1065 { 1066 SdrObjList* pOL=pObj->GetObjList(); 1067 if (pOL==NULL) { 1068 DBG_ERROR("RedoObjOrdNum: pObj hat keine ObjList"); 1069 return; 1070 } 1071 pOL->SetObjectOrdNum(nOldOrdNum,nNewOrdNum); 1072 1073 // #94278# Trigger PageChangeCall 1074 ImpShowPageOfThisObject(); 1075 } 1076 1077 XubString SdrUndoObjOrdNum::GetComment() const 1078 { 1079 XubString aStr; 1080 ImpTakeDescriptionStr(STR_UndoObjOrdNum,aStr); 1081 return aStr; 1082 } 1083 1084 //////////////////////////////////////////////////////////////////////////////////////////////////// 1085 1086 SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText) 1087 : SdrUndoObj(rNewObj) 1088 , pOldText(NULL) 1089 , pNewText(NULL) 1090 , bNewTextAvailable(sal_False) 1091 , bEmptyPresObj(sal_False) 1092 , mnText(nText) 1093 { 1094 SdrText* pText = static_cast< SdrTextObj*>( &rNewObj )->getText(mnText); 1095 if( pText && pText->GetOutlinerParaObject() ) 1096 pOldText = new OutlinerParaObject(*pText->GetOutlinerParaObject()); 1097 1098 bEmptyPresObj = rNewObj.IsEmptyPresObj(); 1099 } 1100 1101 SdrUndoObjSetText::~SdrUndoObjSetText() 1102 { 1103 if ( pOldText ) 1104 delete pOldText; 1105 if ( pNewText ) 1106 delete pNewText; 1107 } 1108 1109 void SdrUndoObjSetText::AfterSetText() 1110 { 1111 if (!bNewTextAvailable) 1112 { 1113 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); 1114 if( pText && pText->GetOutlinerParaObject() ) 1115 pNewText = new OutlinerParaObject(*pText->GetOutlinerParaObject()); 1116 bNewTextAvailable=sal_True; 1117 } 1118 } 1119 1120 void SdrUndoObjSetText::Undo() 1121 { 1122 // #94278# Trigger PageChangeCall 1123 ImpShowPageOfThisObject(); 1124 1125 // alten Text sichern fuer Redo 1126 if (!bNewTextAvailable) 1127 AfterSetText(); 1128 1129 // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung 1130 OutlinerParaObject* pText1 = pOldText; 1131 if(pText1) 1132 pText1 = new OutlinerParaObject(*pText1); 1133 1134 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); 1135 if( pText ) 1136 pText->SetOutlinerParaObject(pText1); 1137 1138 pObj->SetEmptyPresObj( bEmptyPresObj ); 1139 pObj->ActionChanged(); 1140 } 1141 1142 void SdrUndoObjSetText::Redo() 1143 { 1144 // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung 1145 OutlinerParaObject* pText1 = pNewText; 1146 1147 if(pText1) 1148 pText1 = new OutlinerParaObject(*pText1); 1149 1150 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); 1151 if( pText ) 1152 static_cast< SdrTextObj* >( pObj )->NbcSetOutlinerParaObjectForText( pText1, pText ); 1153 1154 pObj->ActionChanged(); 1155 1156 // #94278# Trigger PageChangeCall 1157 ImpShowPageOfThisObject(); 1158 } 1159 1160 XubString SdrUndoObjSetText::GetComment() const 1161 { 1162 XubString aStr; 1163 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr); 1164 return aStr; 1165 } 1166 1167 XubString SdrUndoObjSetText::GetSdrRepeatComment(SdrView& /*rView*/) const 1168 { 1169 XubString aStr; 1170 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr); 1171 return aStr; 1172 } 1173 1174 void SdrUndoObjSetText::SdrRepeat(SdrView& rView) 1175 { 1176 if (bNewTextAvailable && rView.AreObjectsMarked()) 1177 { 1178 const SdrMarkList& rML=rView.GetMarkedObjectList(); 1179 1180 const bool bUndo = rView.IsUndoEnabled(); 1181 if( bUndo ) 1182 { 1183 XubString aStr; 1184 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr); 1185 rView.BegUndo(aStr); 1186 } 1187 1188 sal_uIntPtr nAnz=rML.GetMarkCount(); 1189 for (sal_uIntPtr nm=0; nm<nAnz; nm++) 1190 { 1191 SdrObject* pObj2=rML.GetMark(nm)->GetMarkedSdrObj(); 1192 SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pObj2); 1193 if (pTextObj!=NULL) 1194 { 1195 if( bUndo ) 1196 rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0)); 1197 1198 OutlinerParaObject* pText1=pNewText; 1199 if (pText1!=NULL) 1200 pText1 = new OutlinerParaObject(*pText1); 1201 pTextObj->SetOutlinerParaObject(pText1); 1202 } 1203 } 1204 1205 if( bUndo ) 1206 rView.EndUndo(); 1207 } 1208 } 1209 1210 bool SdrUndoObjSetText::CanSdrRepeat(SdrView& rView) const 1211 { 1212 bool bOk=sal_False; 1213 if (bNewTextAvailable && rView.AreObjectsMarked()) { 1214 bOk=sal_True; 1215 } 1216 return bOk; 1217 } 1218 1219 // --> OD 2009-07-09 #i73249# 1220 SdrUndoObjStrAttr::SdrUndoObjStrAttr( SdrObject& rNewObj, 1221 const ObjStrAttrType eObjStrAttr, 1222 const String& sOldStr, 1223 const String& sNewStr) 1224 : SdrUndoObj( rNewObj ), 1225 meObjStrAttr( eObjStrAttr ), 1226 msOldStr( sOldStr ), 1227 msNewStr( sNewStr ) 1228 { 1229 } 1230 1231 void SdrUndoObjStrAttr::Undo() 1232 { 1233 ImpShowPageOfThisObject(); 1234 1235 switch ( meObjStrAttr ) 1236 { 1237 case OBJ_NAME: 1238 { 1239 pObj->SetName( msOldStr ); 1240 } 1241 break; 1242 case OBJ_TITLE: 1243 { 1244 pObj->SetTitle( msOldStr ); 1245 } 1246 break; 1247 case OBJ_DESCRIPTION: 1248 { 1249 pObj->SetDescription( msOldStr ); 1250 } 1251 break; 1252 } 1253 } 1254 1255 void SdrUndoObjStrAttr::Redo() 1256 { 1257 switch ( meObjStrAttr ) 1258 { 1259 case OBJ_NAME: 1260 { 1261 pObj->SetName( msNewStr ); 1262 } 1263 break; 1264 case OBJ_TITLE: 1265 { 1266 pObj->SetTitle( msNewStr ); 1267 } 1268 break; 1269 case OBJ_DESCRIPTION: 1270 { 1271 pObj->SetDescription( msNewStr ); 1272 } 1273 break; 1274 } 1275 1276 ImpShowPageOfThisObject(); 1277 } 1278 1279 String SdrUndoObjStrAttr::GetComment() const 1280 { 1281 String aStr; 1282 switch ( meObjStrAttr ) 1283 { 1284 case OBJ_NAME: 1285 { 1286 ImpTakeDescriptionStr( STR_UndoObjName, aStr ); 1287 aStr += sal_Unicode(' '); 1288 aStr += sal_Unicode('\''); 1289 aStr += msNewStr; 1290 aStr += sal_Unicode('\''); 1291 } 1292 break; 1293 case OBJ_TITLE: 1294 { 1295 ImpTakeDescriptionStr( STR_UndoObjTitle, aStr ); 1296 } 1297 break; 1298 case OBJ_DESCRIPTION: 1299 { 1300 ImpTakeDescriptionStr( STR_UndoObjDescription, aStr ); 1301 } 1302 break; 1303 } 1304 1305 return aStr; 1306 } 1307 1308 //////////////////////////////////////////////////////////////////////////////////////////////////// 1309 //////////////////////////////////////////////////////////////////////////////////////////////////// 1310 // 1311 // @@ @@@@ @@ @@ @@@@@ @@@@@ 1312 // @@ @@ @@ @@ @@ @@ @@ @@ 1313 // @@ @@ @@ @@ @@ @@ @@ @@ 1314 // @@ @@@@@@ @@@@ @@@@ @@@@@ 1315 // @@ @@ @@ @@ @@ @@ @@ 1316 // @@ @@ @@ @@ @@ @@ @@ 1317 // @@@@@ @@ @@ @@ @@@@@ @@ @@ 1318 // 1319 //////////////////////////////////////////////////////////////////////////////////////////////////// 1320 //////////////////////////////////////////////////////////////////////////////////////////////////// 1321 1322 SdrUndoLayer::SdrUndoLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel): 1323 SdrUndoAction(rNewModel), 1324 pLayer(rNewLayerAdmin.GetLayer(nLayerNum)), 1325 pLayerAdmin(&rNewLayerAdmin), 1326 nNum(nLayerNum), 1327 bItsMine(sal_False) 1328 { 1329 } 1330 1331 SdrUndoLayer::~SdrUndoLayer() 1332 { 1333 if (bItsMine) { 1334 delete pLayer; 1335 } 1336 } 1337 1338 //////////////////////////////////////////////////////////////////////////////////////////////////// 1339 1340 void SdrUndoNewLayer::Undo() 1341 { 1342 DBG_ASSERT(!bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert bereits der UndoAction"); 1343 bItsMine=sal_True; 1344 #ifdef DBG_UTIL 1345 SdrLayer* pCmpLayer= 1346 #endif 1347 pLayerAdmin->RemoveLayer(nNum); 1348 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoNewLayer::Undo(): Removter Layer ist != pLayer"); 1349 } 1350 1351 void SdrUndoNewLayer::Redo() 1352 { 1353 DBG_ASSERT(bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert nicht der UndoAction"); 1354 bItsMine=sal_False; 1355 pLayerAdmin->InsertLayer(pLayer,nNum); 1356 } 1357 1358 XubString SdrUndoNewLayer::GetComment() const 1359 { 1360 return ImpGetResStr(STR_UndoNewLayer); 1361 } 1362 1363 //////////////////////////////////////////////////////////////////////////////////////////////////// 1364 1365 void SdrUndoDelLayer::Undo() 1366 { 1367 DBG_ASSERT(bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert nicht der UndoAction"); 1368 bItsMine=sal_False; 1369 pLayerAdmin->InsertLayer(pLayer,nNum); 1370 } 1371 1372 void SdrUndoDelLayer::Redo() 1373 { 1374 DBG_ASSERT(!bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert bereits der UndoAction"); 1375 bItsMine=sal_True; 1376 #ifdef DBG_UTIL 1377 SdrLayer* pCmpLayer= 1378 #endif 1379 pLayerAdmin->RemoveLayer(nNum); 1380 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoDelLayer::Redo(): Removter Layer ist != pLayer"); 1381 } 1382 1383 XubString SdrUndoDelLayer::GetComment() const 1384 { 1385 return ImpGetResStr(STR_UndoDelLayer); 1386 } 1387 1388 //////////////////////////////////////////////////////////////////////////////////////////////////// 1389 1390 void SdrUndoMoveLayer::Undo() 1391 { 1392 #ifdef DBG_UTIL 1393 SdrLayer* pCmpLayer= 1394 #endif 1395 pLayerAdmin->RemoveLayer(nNeuPos); 1396 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Undo(): Removter Layer ist != pLayer"); 1397 pLayerAdmin->InsertLayer(pLayer,nNum); 1398 } 1399 1400 void SdrUndoMoveLayer::Redo() 1401 { 1402 #ifdef DBG_UTIL 1403 SdrLayer* pCmpLayer= 1404 #endif 1405 pLayerAdmin->RemoveLayer(nNum); 1406 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Redo(): Removter Layer ist != pLayer"); 1407 pLayerAdmin->InsertLayer(pLayer,nNeuPos); 1408 } 1409 1410 XubString SdrUndoMoveLayer::GetComment() const 1411 { 1412 return ImpGetResStr(STR_UndoMovLayer); 1413 } 1414 1415 //////////////////////////////////////////////////////////////////////////////////////////////////// 1416 //////////////////////////////////////////////////////////////////////////////////////////////////// 1417 // 1418 // @@@@@ @@@@ @@@@ @@@@@ @@@@ 1419 // @@ @@ @@ @@ @@ @@ @@ @@ @@ 1420 // @@ @@ @@ @@ @@ @@ @@ 1421 // @@@@@ @@@@@@ @@ @@@ @@@@ @@@@ 1422 // @@ @@ @@ @@ @@ @@ @@ 1423 // @@ @@ @@ @@ @@ @@ @@ @@ 1424 // @@ @@ @@ @@@@@ @@@@@ @@@@ 1425 // 1426 //////////////////////////////////////////////////////////////////////////////////////////////////// 1427 //////////////////////////////////////////////////////////////////////////////////////////////////// 1428 1429 SdrUndoPage::SdrUndoPage(SdrPage& rNewPg) 1430 : SdrUndoAction(*rNewPg.GetModel()), 1431 mrPage(rNewPg) 1432 { 1433 } 1434 1435 void SdrUndoPage::ImpInsertPage(sal_uInt16 nNum) 1436 { 1437 DBG_ASSERT(!mrPage.IsInserted(),"SdrUndoPage::ImpInsertPage(): mrPage ist bereits Inserted"); 1438 if (!mrPage.IsInserted()) { 1439 if (mrPage.IsMasterPage()) { 1440 rMod.InsertMasterPage(&mrPage,nNum); 1441 } else { 1442 rMod.InsertPage(&mrPage,nNum); 1443 } 1444 } 1445 } 1446 1447 void SdrUndoPage::ImpRemovePage(sal_uInt16 nNum) 1448 { 1449 DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpRemovePage(): mrPage ist nicht Inserted"); 1450 if (mrPage.IsInserted()) { 1451 SdrPage* pChkPg=NULL; 1452 if (mrPage.IsMasterPage()) { 1453 pChkPg=rMod.RemoveMasterPage(nNum); 1454 } else { 1455 pChkPg=rMod.RemovePage(nNum); 1456 } 1457 DBG_ASSERT(pChkPg==&mrPage,"SdrUndoPage::ImpRemovePage(): RemovePage!=&mrPage"); 1458 } 1459 } 1460 1461 void SdrUndoPage::ImpMovePage(sal_uInt16 nOldNum, sal_uInt16 nNewNum) 1462 { 1463 DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpMovePage(): mrPage ist nicht Inserted"); 1464 if (mrPage.IsInserted()) { 1465 if (mrPage.IsMasterPage()) { 1466 rMod.MoveMasterPage(nOldNum,nNewNum); 1467 } else { 1468 rMod.MovePage(nOldNum,nNewNum); 1469 } 1470 } 1471 } 1472 1473 void SdrUndoPage::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, XubString& rStr, sal_uInt16 /*n*/, FASTBOOL /*bRepeat*/) const 1474 { 1475 rStr=ImpGetResStr(nStrCacheID); 1476 } 1477 1478 //////////////////////////////////////////////////////////////////////////////////////////////////// 1479 1480 SdrUndoPageList::SdrUndoPageList(SdrPage& rNewPg): 1481 SdrUndoPage(rNewPg), 1482 bItsMine(sal_False) 1483 { 1484 nPageNum=rNewPg.GetPageNum(); 1485 } 1486 1487 SdrUndoPageList::~SdrUndoPageList() 1488 { 1489 if(bItsMine) 1490 { 1491 delete (&mrPage); 1492 } 1493 } 1494 1495 //////////////////////////////////////////////////////////////////////////////////////////////////// 1496 1497 SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg): 1498 SdrUndoPageList(rNewPg), 1499 pUndoGroup(NULL) 1500 { 1501 bItsMine = sal_True; 1502 1503 // Und nun ggf. die MasterPage-Beziehungen merken 1504 if(mrPage.IsMasterPage()) 1505 { 1506 sal_uInt16 nPageAnz(rMod.GetPageCount()); 1507 1508 for(sal_uInt16 nPageNum2(0); nPageNum2 < nPageAnz; nPageNum2++) 1509 { 1510 SdrPage* pDrawPage = rMod.GetPage(nPageNum2); 1511 1512 if(pDrawPage->TRG_HasMasterPage()) 1513 { 1514 SdrPage& rMasterPage = pDrawPage->TRG_GetMasterPage(); 1515 1516 if(&mrPage == &rMasterPage) 1517 { 1518 if(!pUndoGroup) 1519 { 1520 pUndoGroup = new SdrUndoGroup(rMod); 1521 } 1522 1523 pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage)); 1524 } 1525 } 1526 } 1527 } 1528 } 1529 1530 SdrUndoDelPage::~SdrUndoDelPage() 1531 { 1532 if (pUndoGroup!=NULL) { 1533 delete pUndoGroup; 1534 } 1535 } 1536 1537 void SdrUndoDelPage::Undo() 1538 { 1539 ImpInsertPage(nPageNum); 1540 if (pUndoGroup!=NULL) { // MasterPage-Beziehungen wiederherstellen 1541 pUndoGroup->Undo(); 1542 } 1543 DBG_ASSERT(bItsMine,"UndoDeletePage: mrPage gehoert nicht der UndoAction"); 1544 bItsMine=sal_False; 1545 } 1546 1547 void SdrUndoDelPage::Redo() 1548 { 1549 ImpRemovePage(nPageNum); 1550 // Die MasterPage-Beziehungen werden ggf. von selbst geloesst 1551 DBG_ASSERT(!bItsMine,"RedoDeletePage: mrPage gehoert bereits der UndoAction"); 1552 bItsMine=sal_True; 1553 } 1554 1555 XubString SdrUndoDelPage::GetComment() const 1556 { 1557 XubString aStr; 1558 ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,sal_False); 1559 return aStr; 1560 } 1561 1562 XubString SdrUndoDelPage::GetSdrRepeatComment(SdrView& /*rView*/) const 1563 { 1564 XubString aStr; 1565 ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,sal_False); 1566 return aStr; 1567 } 1568 1569 void SdrUndoDelPage::SdrRepeat(SdrView& /*rView*/) 1570 { 1571 } 1572 1573 bool SdrUndoDelPage::CanSdrRepeat(SdrView& /*rView*/) const 1574 { 1575 return sal_False; 1576 } 1577 1578 //////////////////////////////////////////////////////////////////////////////////////////////////// 1579 1580 void SdrUndoNewPage::Undo() 1581 { 1582 ImpRemovePage(nPageNum); 1583 DBG_ASSERT(!bItsMine,"UndoNewPage: mrPage gehoert bereits der UndoAction"); 1584 bItsMine=sal_True; 1585 } 1586 1587 void SdrUndoNewPage::Redo() 1588 { 1589 ImpInsertPage(nPageNum); 1590 DBG_ASSERT(bItsMine,"RedoNewPage: mrPage gehoert nicht der UndoAction"); 1591 bItsMine=sal_False; 1592 } 1593 1594 XubString SdrUndoNewPage::GetComment() const 1595 { 1596 XubString aStr; 1597 ImpTakeDescriptionStr(STR_UndoNewPage,aStr,0,sal_False); 1598 return aStr; 1599 } 1600 1601 //////////////////////////////////////////////////////////////////////////////////////////////////// 1602 1603 XubString SdrUndoCopyPage::GetComment() const 1604 { 1605 XubString aStr; 1606 ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,sal_False); 1607 return aStr; 1608 } 1609 1610 XubString SdrUndoCopyPage::GetSdrRepeatComment(SdrView& /*rView*/) const 1611 { 1612 XubString aStr; 1613 ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,sal_False); 1614 return aStr; 1615 } 1616 1617 void SdrUndoCopyPage::SdrRepeat(SdrView& /*rView*/) 1618 { 1619 1620 } 1621 1622 bool SdrUndoCopyPage::CanSdrRepeat(SdrView& /*rView*/) const 1623 { 1624 return sal_False; 1625 } 1626 1627 //////////////////////////////////////////////////////////////////////////////////////////////////// 1628 1629 void SdrUndoSetPageNum::Undo() 1630 { 1631 ImpMovePage(nNewPageNum,nOldPageNum); 1632 } 1633 1634 void SdrUndoSetPageNum::Redo() 1635 { 1636 ImpMovePage(nOldPageNum,nNewPageNum); 1637 } 1638 1639 XubString SdrUndoSetPageNum::GetComment() const 1640 { 1641 XubString aStr; 1642 ImpTakeDescriptionStr(STR_UndoMovPage,aStr,0,sal_False); 1643 return aStr; 1644 } 1645 1646 //////////////////////////////////////////////////////////////////////////////////////////////////// 1647 // 1648 // @@ @@ @@@@ @@@@ @@@@@@ @@@@@ @@@@@ @@@@@ @@@@ @@@@ @@@@@ @@@@ 1649 // @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 1650 // @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 1651 // @@@@@@@ @@@@@@ @@@@ @@ @@@@ @@@@@ @@@@@ @@@@@@ @@ @@@ @@@@ @@@@ 1652 // @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 1653 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ 1654 // @@ @@ @@ @@ @@@@ @@ @@@@@ @@ @@ @@ @@ @@ @@@@@ @@@@@ @@@@ 1655 // 1656 //////////////////////////////////////////////////////////////////////////////////////////////////// 1657 1658 SdrUndoPageMasterPage::SdrUndoPageMasterPage(SdrPage& rChangedPage) 1659 : SdrUndoPage(rChangedPage), 1660 mbOldHadMasterPage(mrPage.TRG_HasMasterPage()) 1661 { 1662 // get current state from page 1663 if(mbOldHadMasterPage) 1664 { 1665 maOldSet = mrPage.TRG_GetMasterPageVisibleLayers(); 1666 maOldMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum(); 1667 } 1668 } 1669 1670 SdrUndoPageMasterPage::~SdrUndoPageMasterPage() 1671 { 1672 } 1673 1674 //////////////////////////////////////////////////////////////////////////////////////////////////// 1675 1676 SdrUndoPageRemoveMasterPage::SdrUndoPageRemoveMasterPage(SdrPage& rChangedPage) 1677 : SdrUndoPageMasterPage(rChangedPage) 1678 { 1679 } 1680 1681 void SdrUndoPageRemoveMasterPage::Undo() 1682 { 1683 if(mbOldHadMasterPage) 1684 { 1685 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber)); 1686 mrPage.TRG_SetMasterPageVisibleLayers(maOldSet); 1687 } 1688 } 1689 1690 void SdrUndoPageRemoveMasterPage::Redo() 1691 { 1692 mrPage.TRG_ClearMasterPage(); 1693 } 1694 1695 XubString SdrUndoPageRemoveMasterPage::GetComment() const 1696 { 1697 XubString aStr; 1698 ImpTakeDescriptionStr(STR_UndoDelPageMasterDscr,aStr,0,sal_False); 1699 return aStr; 1700 } 1701 1702 //////////////////////////////////////////////////////////////////////////////////////////////////// 1703 1704 SdrUndoPageChangeMasterPage::SdrUndoPageChangeMasterPage(SdrPage& rChangedPage) 1705 : SdrUndoPageMasterPage(rChangedPage), 1706 mbNewHadMasterPage(sal_False) 1707 { 1708 } 1709 1710 void SdrUndoPageChangeMasterPage::Undo() 1711 { 1712 // remember values from new page 1713 if(mrPage.TRG_HasMasterPage()) 1714 { 1715 mbNewHadMasterPage = sal_True; 1716 maNewSet = mrPage.TRG_GetMasterPageVisibleLayers(); 1717 maNewMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum(); 1718 } 1719 1720 // restore old values 1721 if(mbOldHadMasterPage) 1722 { 1723 mrPage.TRG_ClearMasterPage(); 1724 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber)); 1725 mrPage.TRG_SetMasterPageVisibleLayers(maOldSet); 1726 } 1727 } 1728 1729 void SdrUndoPageChangeMasterPage::Redo() 1730 { 1731 // restore new values 1732 if(mbNewHadMasterPage) 1733 { 1734 mrPage.TRG_ClearMasterPage(); 1735 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maNewMasterPageNumber)); 1736 mrPage.TRG_SetMasterPageVisibleLayers(maNewSet); 1737 } 1738 } 1739 1740 XubString SdrUndoPageChangeMasterPage::GetComment() const 1741 { 1742 XubString aStr; 1743 ImpTakeDescriptionStr(STR_UndoChgPageMasterDscr,aStr,0,sal_False); 1744 return aStr; 1745 } 1746 1747 /////////////////////////////////////////////////////////////////////// 1748 SdrUndoFactory::~SdrUndoFactory(){} 1749 // shapes 1750 SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject ) 1751 { 1752 return new SdrUndoMoveObj( rObject ); 1753 } 1754 1755 SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist ) 1756 { 1757 return new SdrUndoMoveObj( rObject, rDist ); 1758 } 1759 1760 SdrUndoAction* SdrUndoFactory::CreateUndoGeoObject( SdrObject& rObject ) 1761 { 1762 return new SdrUndoGeoObj( rObject ); 1763 } 1764 1765 SdrUndoAction* SdrUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText ) 1766 { 1767 return new SdrUndoAttrObj( rObject, bStyleSheet1 ? sal_True : sal_False, bSaveText ? sal_True : sal_False ); 1768 } 1769 1770 SdrUndoAction* SdrUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect ) 1771 { 1772 return new SdrUndoRemoveObj( rObject, bOrdNumDirect ? sal_True : sal_False ); 1773 } 1774 1775 SdrUndoAction* SdrUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect ) 1776 { 1777 return new SdrUndoInsertObj( rObject, bOrdNumDirect ? sal_True : sal_False ); 1778 } 1779 1780 SdrUndoAction* SdrUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect ) 1781 { 1782 return new SdrUndoDelObj( rObject, bOrdNumDirect ? sal_True : sal_False ); 1783 } 1784 1785 SdrUndoAction* SdrUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect ) 1786 { 1787 return new SdrUndoNewObj( rObject, bOrdNumDirect ? sal_True : sal_False ); 1788 } 1789 1790 SdrUndoAction* SdrUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect ) 1791 { 1792 return new SdrUndoCopyObj( rObject, bOrdNumDirect ? sal_True : sal_False ); 1793 } 1794 1795 SdrUndoAction* SdrUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1) 1796 { 1797 return new SdrUndoObjOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 ); 1798 } 1799 1800 SdrUndoAction* SdrUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect ) 1801 { 1802 return new SdrUndoReplaceObj( rOldObject, rNewObject, bOrdNumDirect ? sal_True : sal_False ); 1803 } 1804 1805 SdrUndoAction* SdrUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer ) 1806 { 1807 return new SdrUndoObjectLayerChange( rObject, aOldLayer, aNewLayer ); 1808 } 1809 1810 SdrUndoAction* SdrUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText ) 1811 { 1812 return new SdrUndoObjSetText( rNewObj, nText ); 1813 } 1814 1815 SdrUndoAction* SdrUndoFactory::CreateUndoObjectStrAttr( SdrObject& rObject, 1816 SdrUndoObjStrAttr::ObjStrAttrType eObjStrAttrType, 1817 String sOldStr, 1818 String sNewStr ) 1819 { 1820 return new SdrUndoObjStrAttr( rObject, eObjStrAttrType, sOldStr, sNewStr ); 1821 } 1822 1823 1824 // layer 1825 SdrUndoAction* SdrUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) 1826 { 1827 return new SdrUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel ); 1828 } 1829 1830 SdrUndoAction* SdrUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel) 1831 { 1832 return new SdrUndoDelLayer( nLayerNum, rNewLayerAdmin, rNewModel ); 1833 } 1834 1835 SdrUndoAction* SdrUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1) 1836 { 1837 return new SdrUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 ); 1838 } 1839 1840 // page 1841 SdrUndoAction* SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage) 1842 { 1843 return new SdrUndoDelPage( rPage ); 1844 } 1845 1846 SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage) 1847 { 1848 return new SdrUndoNewPage( rPage ); 1849 } 1850 1851 SdrUndoAction* SdrUndoFactory::CreateUndoCopyPage(SdrPage& rPage) 1852 { 1853 return new SdrUndoCopyPage( rPage ); 1854 } 1855 1856 SdrUndoAction* SdrUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1) 1857 { 1858 return new SdrUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 ); 1859 } 1860 // master page 1861 SdrUndoAction* SdrUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage) 1862 { 1863 return new SdrUndoPageRemoveMasterPage( rChangedPage ); 1864 } 1865 1866 SdrUndoAction* SdrUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage) 1867 { 1868 return new SdrUndoPageChangeMasterPage(rChangedPage); 1869 } 1870 1871 // eof 1872