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