Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdundo.cxx
blob896e4d4aee272027dddf53631f7e29f44160a544
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdundo.cxx,v $
10 * $Revision: 1.31.226.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svdundo.hxx>
35 #include "svditext.hxx"
36 #include <svx/svdotext.hxx>
37 #include <svx/svdobj.hxx>
38 #include <svx/svdpage.hxx>
39 #include <svx/svdlayer.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdview.hxx>
42 #include "svdstr.hrc" // Namen aus der Resource
43 #include "svdglob.hxx" // StringCache
44 #include <svx/scene3d.hxx>
45 #include <svx/outlobj.hxx>
46 #include <svx/svdogrp.hxx>
47 #include <svx/sdr/properties/itemsettools.hxx>
48 #include <svx/sdr/properties/properties.hxx>
49 #include <svx/svdocapt.hxx>
50 #include <svtools/whiter.hxx>
51 #include <svx/e3dsceneupdater.hxx>
53 #include "svdviter.hxx"
55 ////////////////////////////////////////////////////////////////////////////////////////////////////
57 // iterates over all views and unmarks this SdrObject if it is marked
58 static void ImplUnmarkObject( SdrObject* pObj )
60 SdrViewIter aIter( pObj );
61 for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
63 pView->MarkObj( pObj, pView->GetSdrPageView(), TRUE );
67 ////////////////////////////////////////////////////////////////////////////////////////////////////
69 TYPEINIT1(SdrUndoAction,SfxUndoAction);
71 BOOL SdrUndoAction::CanRepeat(SfxRepeatTarget& rView) const
73 SdrView* pV=PTR_CAST(SdrView,&rView);
74 if (pV!=NULL) return CanSdrRepeat(*pV);
75 return FALSE;
78 void SdrUndoAction::Repeat(SfxRepeatTarget& rView)
80 SdrView* pV=PTR_CAST(SdrView,&rView);
81 if (pV!=NULL) SdrRepeat(*pV);
82 DBG_ASSERT(pV!=NULL,"Repeat: Uebergebenes SfxRepeatTarget ist keine SdrView");
85 XubString SdrUndoAction::GetRepeatComment(SfxRepeatTarget& rView) const
87 SdrView* pV=PTR_CAST(SdrView,&rView);
88 if (pV!=NULL) return GetSdrRepeatComment(*pV);
89 return String();
92 bool SdrUndoAction::CanSdrRepeat(SdrView& /*rView*/) const
94 return FALSE;
97 void SdrUndoAction::SdrRepeat(SdrView& /*rView*/)
101 XubString SdrUndoAction::GetSdrRepeatComment(SdrView& /*rView*/) const
103 return String();
106 ////////////////////////////////////////////////////////////////////////////////////////////////////
108 SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod)
109 : SdrUndoAction(rNewMod),
110 aBuf(1024,32,32),
111 eFunction(SDRREPFUNC_OBJ_NONE) /*#72642#*/
114 SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod,const String& rStr)
115 : SdrUndoAction(rNewMod),
116 aBuf(1024,32,32),
117 aComment(rStr),
118 eFunction(SDRREPFUNC_OBJ_NONE)
121 SdrUndoGroup::~SdrUndoGroup()
123 Clear();
126 void SdrUndoGroup::Clear()
128 for (ULONG nu=0; nu<GetActionCount(); nu++) {
129 SdrUndoAction* pAct=GetAction(nu);
130 delete pAct;
132 aBuf.Clear();
135 void SdrUndoGroup::AddAction(SdrUndoAction* pAct)
137 aBuf.Insert(pAct,CONTAINER_APPEND);
140 void SdrUndoGroup::push_front( SdrUndoAction* pAct )
142 aBuf.Insert(pAct, (ULONG)0 );
145 void SdrUndoGroup::Undo()
147 for (ULONG nu=GetActionCount(); nu>0;) {
148 nu--;
149 SdrUndoAction* pAct=GetAction(nu);
150 pAct->Undo();
154 void SdrUndoGroup::Redo()
156 for (ULONG nu=0; nu<GetActionCount(); nu++) {
157 SdrUndoAction* pAct=GetAction(nu);
158 pAct->Redo();
162 XubString SdrUndoGroup::GetComment() const
164 XubString aRet(aComment);
165 sal_Char aSearchText[] = "%1";
166 String aSearchString(aSearchText, sizeof(aSearchText-1));
168 aRet.SearchAndReplace(aSearchString, aObjDescription);
170 return aRet;
173 bool SdrUndoGroup::CanSdrRepeat(SdrView& rView) const
175 switch (eFunction) {
176 case SDRREPFUNC_OBJ_NONE : return FALSE;
177 case SDRREPFUNC_OBJ_DELETE : return rView.AreObjectsMarked();
178 case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: return rView.IsCombinePossible(FALSE);
179 case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : return rView.IsCombinePossible(TRUE);
180 case SDRREPFUNC_OBJ_DISMANTLE_POLYS : return rView.IsDismantlePossible(FALSE);
181 case SDRREPFUNC_OBJ_DISMANTLE_LINES : return rView.IsDismantlePossible(TRUE);
182 case SDRREPFUNC_OBJ_CONVERTTOPOLY : return rView.IsConvertToPolyObjPossible(FALSE);
183 case SDRREPFUNC_OBJ_CONVERTTOPATH : return rView.IsConvertToPathObjPossible(FALSE);
184 case SDRREPFUNC_OBJ_GROUP : return rView.IsGroupPossible();
185 case SDRREPFUNC_OBJ_UNGROUP : return rView.IsUnGroupPossible();
186 case SDRREPFUNC_OBJ_PUTTOTOP : return rView.IsToTopPossible();
187 case SDRREPFUNC_OBJ_PUTTOBTM : return rView.IsToBtmPossible();
188 case SDRREPFUNC_OBJ_MOVTOTOP : return rView.IsToTopPossible();
189 case SDRREPFUNC_OBJ_MOVTOBTM : return rView.IsToBtmPossible();
190 case SDRREPFUNC_OBJ_REVORDER : return rView.IsReverseOrderPossible();
191 case SDRREPFUNC_OBJ_IMPORTMTF : return rView.IsImportMtfPossible();
192 default: break;
193 } // switch
194 return FALSE;
197 void SdrUndoGroup::SdrRepeat(SdrView& rView)
199 switch (eFunction) {
200 case SDRREPFUNC_OBJ_NONE : break;
201 case SDRREPFUNC_OBJ_DELETE : rView.DeleteMarked(); break;
202 case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: rView.CombineMarkedObjects(sal_False); break;
203 case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : rView.CombineMarkedObjects(sal_True); break;
204 case SDRREPFUNC_OBJ_DISMANTLE_POLYS : rView.DismantleMarkedObjects(FALSE); break;
205 case SDRREPFUNC_OBJ_DISMANTLE_LINES : rView.DismantleMarkedObjects(TRUE); break;
206 case SDRREPFUNC_OBJ_CONVERTTOPOLY : rView.ConvertMarkedToPolyObj(FALSE); break;
207 case SDRREPFUNC_OBJ_CONVERTTOPATH : rView.ConvertMarkedToPathObj(FALSE); break;
208 case SDRREPFUNC_OBJ_GROUP : rView.GroupMarked(); break;
209 case SDRREPFUNC_OBJ_UNGROUP : rView.UnGroupMarked(); break;
210 case SDRREPFUNC_OBJ_PUTTOTOP : rView.PutMarkedToTop(); break;
211 case SDRREPFUNC_OBJ_PUTTOBTM : rView.PutMarkedToBtm(); break;
212 case SDRREPFUNC_OBJ_MOVTOTOP : rView.MovMarkedToTop(); break;
213 case SDRREPFUNC_OBJ_MOVTOBTM : rView.MovMarkedToBtm(); break;
214 case SDRREPFUNC_OBJ_REVORDER : rView.ReverseOrderOfMarked(); break;
215 case SDRREPFUNC_OBJ_IMPORTMTF : rView.DoImportMarkedMtf(); break;
216 default: break;
217 } // switch
220 XubString SdrUndoGroup::GetSdrRepeatComment(SdrView& /*rView*/) const
222 XubString aRet(aComment);
223 sal_Char aSearchText[] = "%1";
224 String aSearchString(aSearchText, sizeof(aSearchText-1));
226 aRet.SearchAndReplace(aSearchString, ImpGetResStr(STR_ObjNameSingulPlural));
228 return aRet;
231 ////////////////////////////////////////////////////////////////////////////////////////////////////
232 ////////////////////////////////////////////////////////////////////////////////////////////////////
234 // @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@ @@@@
235 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
236 // @@ @@ @@ @@ @@ @@ @@ @@ @@
237 // @@ @@ @@@@@ @@ @@@@ @@ @@ @@@@
238 // @@ @@ @@ @@ @@ @@ @@ @@ @@
239 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
240 // @@@@ @@@@@ @@@@ @@@@@ @@@@ @@ @@@@
242 ////////////////////////////////////////////////////////////////////////////////////////////////////
243 ////////////////////////////////////////////////////////////////////////////////////////////////////
245 SdrUndoObj::SdrUndoObj(SdrObject& rNewObj):
246 SdrUndoAction(*rNewObj.GetModel()),
247 pObj(&rNewObj)
251 void SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject, USHORT nStrCacheID, String& rStr, FASTBOOL bRepeat )
253 rStr = ImpGetResStr(nStrCacheID);
254 sal_Char aSearchText[] = "%1";
255 String aSearchString(aSearchText, sizeof(aSearchText-1));
257 xub_StrLen nPos = rStr.Search(aSearchString);
259 if(nPos != STRING_NOTFOUND)
261 rStr.Erase(nPos, 2);
263 if(bRepeat)
265 rStr.Insert(ImpGetResStr(STR_ObjNameSingulPlural), nPos);
267 else
269 XubString aStr;
271 _rForObject.TakeObjNameSingul(aStr);
272 rStr.Insert(aStr, nPos);
277 void SdrUndoObj::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, FASTBOOL bRepeat) const
279 if ( pObj )
280 GetDescriptionStringForObject( *pObj, nStrCacheID, rStr, bRepeat );
283 // #94278# common call method for evtl. page change when UNDO/REDO
284 // is triggered
285 void SdrUndoObj::ImpShowPageOfThisObject()
287 if(pObj && pObj->IsInserted() && pObj->GetPage() && pObj->GetModel())
289 SdrHint aHint(HINT_SWITCHTOPAGE);
291 aHint.SetObject(pObj);
292 aHint.SetPage(pObj->GetPage());
294 pObj->GetModel()->Broadcast(aHint);
298 ////////////////////////////////////////////////////////////////////////////////////////////////////
300 SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, FASTBOOL bStyleSheet1, FASTBOOL bSaveText)
301 : SdrUndoObj(rNewObj),
302 pUndoSet(NULL),
303 pRedoSet(NULL),
304 pRepeatSet(NULL),
305 pUndoStyleSheet(NULL),
306 pRedoStyleSheet(NULL),
307 pRepeatStyleSheet(NULL),
308 bHaveToTakeRedoSet(TRUE),
309 pTextUndo(NULL),
311 // #i8508#
312 pTextRedo(NULL),
314 pUndoGroup(NULL)
316 bStyleSheet = bStyleSheet1;
318 SdrObjList* pOL = rNewObj.GetSubList();
319 BOOL bIsGroup(pOL!=NULL && pOL->GetObjCount());
320 BOOL bIs3DScene(bIsGroup && pObj->ISA(E3dScene));
322 if(bIsGroup)
324 // Aha, Gruppenobjekt
325 pUndoGroup = new SdrUndoGroup(*pObj->GetModel());
326 sal_uInt32 nObjAnz(pOL->GetObjCount());
328 for(sal_uInt32 nObjNum(0); nObjNum < nObjAnz; nObjNum++)
330 pUndoGroup->AddAction(
331 new SdrUndoAttrObj(*pOL->GetObj(nObjNum), bStyleSheet1));
335 if(!bIsGroup || bIs3DScene)
337 if(pUndoSet)
339 delete pUndoSet;
342 pUndoSet = new SfxItemSet(pObj->GetMergedItemSet());
344 if(bStyleSheet)
345 pUndoStyleSheet = pObj->GetStyleSheet();
347 if(bSaveText)
349 pTextUndo = pObj->GetOutlinerParaObject();
350 if(pTextUndo)
351 pTextUndo = new OutlinerParaObject(*pTextUndo);
356 SdrUndoAttrObj::~SdrUndoAttrObj()
358 if(pUndoSet)
359 delete pUndoSet;
360 if(pRedoSet)
361 delete pRedoSet;
362 if(pRepeatSet)
363 delete pRepeatSet;
364 if(pUndoGroup)
365 delete pUndoGroup;
366 if(pTextUndo)
367 delete pTextUndo;
369 // #i8508#
370 if(pTextRedo)
371 delete pTextRedo;
374 void SdrUndoAttrObj::SetRepeatAttr(const SfxItemSet& rSet)
376 if(pRepeatSet)
377 delete pRepeatSet;
379 pRepeatSet = new SfxItemSet(rSet);
382 void SdrUndoAttrObj::Undo()
384 E3DModifySceneSnapRectUpdater aUpdater(pObj);
385 BOOL bIs3DScene(pObj && pObj->ISA(E3dScene));
387 // #94278# Trigger PageChangeCall
388 ImpShowPageOfThisObject();
390 if(!pUndoGroup || bIs3DScene)
392 if(bHaveToTakeRedoSet)
394 bHaveToTakeRedoSet = FALSE;
396 if(pRedoSet)
398 delete pRedoSet;
401 pRedoSet = new SfxItemSet(pObj->GetMergedItemSet());
403 if(bStyleSheet)
404 pRedoStyleSheet=pObj->GetStyleSheet();
406 if(pTextUndo)
408 // #i8508#
409 pTextRedo = pObj->GetOutlinerParaObject();
411 if(pTextRedo)
412 pTextRedo = new OutlinerParaObject(*pTextRedo);
416 if(bStyleSheet)
418 pRedoStyleSheet = pObj->GetStyleSheet();
419 pObj->SetStyleSheet(pUndoStyleSheet, TRUE);
422 sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
424 // #105122# Since ClearItem sets back everything to normal
425 // it also sets fit-to-size text to non-fit-to-size text and
426 // switches on autogrowheight (the default). That may lead to
427 // loosing the geometry size info for the object when it is
428 // re-layouted from AdjustTextFrameWidthAndHeight(). This makes
429 // rescuing the size of the object necessary.
430 const Rectangle aSnapRect = pObj->GetSnapRect();
432 if(pUndoSet)
434 // #109587#
435 if(pObj->ISA(SdrCaptionObj))
437 // do a more smooth item deletion here, else the text
438 // rect will be reformatted, especially when information regarding
439 // vertical text is changed. When clearing only set items it's
440 // slower, but safer regarding such information (it's not changed
441 // usually)
442 SfxWhichIter aIter(*pUndoSet);
443 sal_uInt16 nWhich(aIter.FirstWhich());
445 while(nWhich)
447 if(SFX_ITEM_SET != pUndoSet->GetItemState(nWhich, sal_False))
449 pObj->ClearMergedItem(nWhich);
452 nWhich = aIter.NextWhich();
455 else
457 pObj->ClearMergedItem();
460 pObj->SetMergedItemSet(*pUndoSet);
463 // #105122# Restore prev size here when it was changed.
464 if(aSnapRect != pObj->GetSnapRect())
466 pObj->NbcSetSnapRect(aSnapRect);
469 pObj->GetProperties().BroadcastItemChange(aItemChange);
471 if(pTextUndo)
473 pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo));
477 if(pUndoGroup)
479 pUndoGroup->Undo();
483 void SdrUndoAttrObj::Redo()
485 E3DModifySceneSnapRectUpdater aUpdater(pObj);
486 BOOL bIs3DScene(pObj && pObj->ISA(E3dScene));
488 if(!pUndoGroup || bIs3DScene)
490 if(bStyleSheet)
492 pUndoStyleSheet = pObj->GetStyleSheet();
493 pObj->SetStyleSheet(pRedoStyleSheet, TRUE);
496 sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
498 // #105122#
499 const Rectangle aSnapRect = pObj->GetSnapRect();
501 if(pRedoSet)
503 // #109587#
504 if(pObj->ISA(SdrCaptionObj))
506 // do a more smooth item deletion here, else the text
507 // rect will be reformatted, especially when information regarding
508 // vertical text is changed. When clearing only set items it's
509 // slower, but safer regarding such information (it's not changed
510 // usually)
511 SfxWhichIter aIter(*pRedoSet);
512 sal_uInt16 nWhich(aIter.FirstWhich());
514 while(nWhich)
516 if(SFX_ITEM_SET != pRedoSet->GetItemState(nWhich, sal_False))
518 pObj->ClearMergedItem(nWhich);
521 nWhich = aIter.NextWhich();
524 else
526 pObj->ClearMergedItem();
529 pObj->SetMergedItemSet(*pRedoSet);
532 // #105122# Restore prev size here when it was changed.
533 if(aSnapRect != pObj->GetSnapRect())
535 pObj->NbcSetSnapRect(aSnapRect);
538 pObj->GetProperties().BroadcastItemChange(aItemChange);
540 // #i8508#
541 if(pTextRedo)
543 pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo));
547 if(pUndoGroup)
549 pUndoGroup->Redo();
552 // #94278# Trigger PageChangeCall
553 ImpShowPageOfThisObject();
556 XubString SdrUndoAttrObj::GetComment() const
558 XubString aStr;
560 if(bStyleSheet)
562 ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr);
564 else
566 ImpTakeDescriptionStr(STR_EditSetAttributes, aStr);
569 return aStr;
572 void SdrUndoAttrObj::SdrRepeat(SdrView& rView)
574 if(pRepeatSet)
576 rView.SetAttrToMarked(*pRepeatSet, FALSE);
580 bool SdrUndoAttrObj::CanSdrRepeat(SdrView& rView) const
582 return (pRepeatSet!=0L && rView.AreObjectsMarked());
585 XubString SdrUndoAttrObj::GetSdrRepeatComment(SdrView& /*rView*/) const
587 XubString aStr;
589 if(bStyleSheet)
591 ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr, TRUE);
593 else
595 ImpTakeDescriptionStr(STR_EditSetAttributes, aStr, TRUE);
598 return aStr;
601 ////////////////////////////////////////////////////////////////////////////////////////////////////
603 void SdrUndoMoveObj::Undo()
605 // #94278# Trigger PageChangeCall
606 ImpShowPageOfThisObject();
608 pObj->Move(Size(-aDistance.Width(),-aDistance.Height()));
611 void SdrUndoMoveObj::Redo()
613 pObj->Move(Size(aDistance.Width(),aDistance.Height()));
615 // #94278# Trigger PageChangeCall
616 ImpShowPageOfThisObject();
619 XubString SdrUndoMoveObj::GetComment() const
621 XubString aStr;
622 ImpTakeDescriptionStr(STR_EditMove,aStr);
623 return aStr;
626 void SdrUndoMoveObj::SdrRepeat(SdrView& rView)
628 rView.MoveMarkedObj(aDistance);
631 bool SdrUndoMoveObj::CanSdrRepeat(SdrView& rView) const
633 return rView.AreObjectsMarked();
636 XubString SdrUndoMoveObj::GetSdrRepeatComment(SdrView& /*rView*/) const
638 XubString aStr;
639 ImpTakeDescriptionStr(STR_EditMove,aStr,TRUE);
640 return aStr;
643 ////////////////////////////////////////////////////////////////////////////////////////////////////
645 SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj):
646 SdrUndoObj(rNewObj),
647 pUndoGeo(NULL),
648 pRedoGeo(NULL),
649 pUndoGroup(NULL)
651 SdrObjList* pOL=rNewObj.GetSubList();
652 if (pOL!=NULL && pOL->GetObjCount() && !rNewObj.ISA(E3dScene))
654 // Aha, Gruppenobjekt
655 // AW: Aber keine 3D-Szene, dann nur fuer die Szene selbst den Undo anlegen
656 pUndoGroup=new SdrUndoGroup(*pObj->GetModel());
657 ULONG nObjAnz=pOL->GetObjCount();
658 for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
659 pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
661 } else {
662 pUndoGeo=pObj->GetGeoData();
666 SdrUndoGeoObj::~SdrUndoGeoObj()
668 if (pUndoGeo!=NULL) delete pUndoGeo;
669 if (pRedoGeo!=NULL) delete pRedoGeo;
670 if (pUndoGroup!=NULL) delete pUndoGroup;
673 void SdrUndoGeoObj::Undo()
675 // #94278# Trigger PageChangeCall
676 ImpShowPageOfThisObject();
678 if(pUndoGroup)
680 pUndoGroup->Undo();
682 // #97172#
683 // only repaint, no objectchange
684 pObj->ActionChanged();
686 else
688 if (pRedoGeo!=NULL) delete pRedoGeo;
689 pRedoGeo=pObj->GetGeoData();
690 pObj->SetGeoData(*pUndoGeo);
694 void SdrUndoGeoObj::Redo()
696 if(pUndoGroup)
698 pUndoGroup->Redo();
700 // #97172#
701 // only repaint, no objectchange
702 pObj->ActionChanged();
704 else
706 if (pUndoGeo!=NULL) delete pUndoGeo;
707 pUndoGeo=pObj->GetGeoData();
708 pObj->SetGeoData(*pRedoGeo);
711 // #94278# Trigger PageChangeCall
712 ImpShowPageOfThisObject();
715 XubString SdrUndoGeoObj::GetComment() const
717 XubString aStr;
718 ImpTakeDescriptionStr(STR_DragMethObjOwn,aStr);
719 return aStr;
722 ////////////////////////////////////////////////////////////////////////////////////////////////////
724 SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect)
725 : SdrUndoObj(rNewObj),
726 bOwner(FALSE),
727 pView(NULL),
728 pPageView(NULL)
730 pObjList=pObj->GetObjList();
731 if (bOrdNumDirect) {
732 nOrdNum=pObj->GetOrdNumDirect();
733 } else {
734 nOrdNum=pObj->GetOrdNum();
738 SdrUndoObjList::~SdrUndoObjList()
740 if (pObj!=NULL && IsOwner())
742 // Attribute muessen wieder in den regulaeren Pool
743 SetOwner(FALSE);
745 // nun loeschen
746 SdrObject::Free( pObj );
750 void SdrUndoObjList::SetOwner(bool bNew)
752 bOwner = bNew;
755 ////////////////////////////////////////////////////////////////////////////////////////////////////
757 void SdrUndoRemoveObj::Undo()
759 // #94278# Trigger PageChangeCall
760 ImpShowPageOfThisObject();
762 DBG_ASSERT(!pObj->IsInserted(),"UndoRemoveObj: pObj ist bereits Inserted");
763 if (!pObj->IsInserted())
765 // #i11426#
766 // For UNDOs in Calc/Writer it is necessary to adapt the anchor
767 // pos of the target object.
768 Point aOwnerAnchorPos(0, 0);
770 if(pObjList
771 && pObjList->GetOwnerObj()
772 && pObjList->GetOwnerObj()->ISA(SdrObjGroup))
774 aOwnerAnchorPos = pObjList->GetOwnerObj()->GetAnchorPos();
777 E3DModifySceneSnapRectUpdater aUpdater(pObjList->GetOwnerObj());
778 SdrInsertReason aReason(SDRREASON_UNDO);
779 pObjList->InsertObject(pObj,nOrdNum,&aReason);
781 // #i11426#
782 if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y())
784 pObj->NbcSetAnchorPos(aOwnerAnchorPos);
789 void SdrUndoRemoveObj::Redo()
791 DBG_ASSERT(pObj->IsInserted(),"RedoRemoveObj: pObj ist nicht Inserted");
792 if (pObj->IsInserted())
794 ImplUnmarkObject( pObj );
795 E3DModifySceneSnapRectUpdater aUpdater(pObj);
796 pObjList->RemoveObject(nOrdNum);
799 // #94278# Trigger PageChangeCall
800 ImpShowPageOfThisObject();
803 ////////////////////////////////////////////////////////////////////////////////////////////////////
805 void SdrUndoInsertObj::Undo()
807 // #94278# Trigger PageChangeCall
808 ImpShowPageOfThisObject();
810 DBG_ASSERT(pObj->IsInserted(),"UndoInsertObj: pObj ist nicht Inserted");
811 if (pObj->IsInserted())
813 ImplUnmarkObject( pObj );
815 #ifdef DBG_UTIL
816 SdrObject* pChkObj=
817 #endif
818 pObjList->RemoveObject(nOrdNum);
819 DBG_ASSERT(pChkObj==pObj,"UndoInsertObj: RemoveObjNum!=pObj");
823 void SdrUndoInsertObj::Redo()
825 DBG_ASSERT(!pObj->IsInserted(),"RedoInsertObj: pObj ist bereits Inserted");
826 if (!pObj->IsInserted())
828 // --> OD 2005-05-10 #i45952# - restore anchor position of an object,
829 // which becomes a member of a group, because its cleared in method
830 // <InsertObject(..)>. Needed for correct ReDo in Writer.
831 Point aAnchorPos( 0, 0 );
832 if ( pObjList &&
833 pObjList->GetOwnerObj() &&
834 pObjList->GetOwnerObj()->ISA(SdrObjGroup) )
836 aAnchorPos = pObj->GetAnchorPos();
838 // <--
840 SdrInsertReason aReason(SDRREASON_UNDO);
841 pObjList->InsertObject(pObj,nOrdNum,&aReason);
843 // --> OD 2005-05-10 #i45952#
844 if ( aAnchorPos.X() || aAnchorPos.Y() )
846 pObj->NbcSetAnchorPos( aAnchorPos );
848 // <--
851 // #94278# Trigger PageChangeCall
852 ImpShowPageOfThisObject();
855 ////////////////////////////////////////////////////////////////////////////////////////////////////
857 void SdrUndoDelObj::Undo()
859 SdrUndoRemoveObj::Undo();
860 DBG_ASSERT(IsOwner(),"UndoDeleteObj: pObj gehoert nicht der UndoAction");
861 SetOwner(FALSE);
864 void SdrUndoDelObj::Redo()
866 SdrUndoRemoveObj::Redo();
867 DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj gehoert bereits der UndoAction");
868 SetOwner(TRUE);
871 XubString SdrUndoDelObj::GetComment() const
873 XubString aStr;
874 ImpTakeDescriptionStr(STR_EditDelete,aStr);
875 return aStr;
878 void SdrUndoDelObj::SdrRepeat(SdrView& rView)
880 rView.DeleteMarked();
883 bool SdrUndoDelObj::CanSdrRepeat(SdrView& rView) const
885 return rView.AreObjectsMarked();
888 XubString SdrUndoDelObj::GetSdrRepeatComment(SdrView& /*rView*/) const
890 XubString aStr;
891 ImpTakeDescriptionStr(STR_EditDelete,aStr,TRUE);
892 return aStr;
895 ////////////////////////////////////////////////////////////////////////////////////////////////////
897 void SdrUndoNewObj::Undo()
899 SdrUndoInsertObj::Undo();
900 DBG_ASSERT(!IsOwner(),"RedoNewObj: pObj gehoert bereits der UndoAction");
901 SetOwner(TRUE);
904 void SdrUndoNewObj::Redo()
906 SdrUndoInsertObj::Redo();
907 DBG_ASSERT(IsOwner(),"RedoNewObj: pObj gehoert nicht der UndoAction");
908 SetOwner(FALSE);
911 String SdrUndoNewObj::GetComment( const SdrObject& _rForObject )
913 String sComment;
914 GetDescriptionStringForObject( _rForObject, STR_UndoInsertObj, sComment );
915 return sComment;
918 XubString SdrUndoNewObj::GetComment() const
920 XubString aStr;
921 ImpTakeDescriptionStr(STR_UndoInsertObj,aStr);
922 return aStr;
925 SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject& rOldObj1, SdrObject& rNewObj1, bool bOrdNumDirect)
926 : SdrUndoObj(rOldObj1),
927 bOldOwner(FALSE),
928 bNewOwner(FALSE),
929 pNewObj(&rNewObj1)
931 SetOldOwner(TRUE);
933 pObjList=pObj->GetObjList();
934 if (bOrdNumDirect) {
935 nOrdNum=pObj->GetOrdNumDirect();
936 } else {
937 nOrdNum=pObj->GetOrdNum();
941 SdrUndoReplaceObj::~SdrUndoReplaceObj()
943 if (pObj!=NULL && IsOldOwner())
945 // Attribute muessen wieder in den regulaeren Pool
946 SetOldOwner(FALSE);
948 // nun loeschen
949 SdrObject::Free( pObj );
951 if (pNewObj!=NULL && IsNewOwner())
953 // Attribute muessen wieder in den regulaeren Pool
954 SetNewOwner(FALSE);
956 // nun loeschen
957 SdrObject::Free( pNewObj );
961 void SdrUndoReplaceObj::Undo()
963 // #94278# Trigger PageChangeCall
964 ImpShowPageOfThisObject();
966 if (IsOldOwner() && !IsNewOwner())
968 DBG_ASSERT(!pObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Altes Objekt ist bereits inserted!");
969 DBG_ASSERT(pNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Neues Objekt ist nicht inserted!");
970 SetOldOwner(FALSE);
971 SetNewOwner(TRUE);
973 ImplUnmarkObject( pNewObj );
974 pObjList->ReplaceObject(pObj,nOrdNum);
976 else
978 DBG_ERROR("SdrUndoReplaceObj::Undo(): IsMine-Flags stehen verkehrt. Doppelter Undo-Aufruf?");
982 void SdrUndoReplaceObj::Redo()
984 if (!IsOldOwner() && IsNewOwner())
986 DBG_ASSERT(!pNewObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Neues Objekt ist bereits inserted!");
987 DBG_ASSERT(pObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Altes Objekt ist nicht inserted!");
988 SetOldOwner(TRUE);
989 SetNewOwner(FALSE);
991 ImplUnmarkObject( pObj );
992 pObjList->ReplaceObject(pNewObj,nOrdNum);
995 else
997 DBG_ERROR("SdrUndoReplaceObj::Redo(): IsMine-Flags stehen verkehrt. Doppelter Redo-Aufruf?");
1000 // #94278# Trigger PageChangeCall
1001 ImpShowPageOfThisObject();
1004 void SdrUndoReplaceObj::SetNewOwner(bool bNew)
1006 bNewOwner = bNew;
1009 void SdrUndoReplaceObj::SetOldOwner(bool bNew)
1011 bOldOwner = bNew;
1014 ////////////////////////////////////////////////////////////////////////////////////////////////////
1016 XubString SdrUndoCopyObj::GetComment() const
1018 XubString aStr;
1019 ImpTakeDescriptionStr(STR_UndoCopyObj,aStr);
1020 return aStr;
1023 ////////////////////////////////////////////////////////////////////////////////////////////////////
1024 // #i11702#
1026 SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject& rObj, SdrLayerID aOldLayer, SdrLayerID aNewLayer)
1027 : SdrUndoObj(rObj),
1028 maOldLayer(aOldLayer),
1029 maNewLayer(aNewLayer)
1033 void SdrUndoObjectLayerChange::Undo()
1035 ImpShowPageOfThisObject();
1036 pObj->SetLayer(maOldLayer);
1039 void SdrUndoObjectLayerChange::Redo()
1041 pObj->SetLayer(maNewLayer);
1042 ImpShowPageOfThisObject();
1045 ////////////////////////////////////////////////////////////////////////////////////////////////////
1047 SdrUndoObjOrdNum::SdrUndoObjOrdNum(SdrObject& rNewObj, UINT32 nOldOrdNum1, UINT32 nNewOrdNum1):
1048 SdrUndoObj(rNewObj),
1049 nOldOrdNum(nOldOrdNum1),
1050 nNewOrdNum(nNewOrdNum1)
1054 void SdrUndoObjOrdNum::Undo()
1056 // #94278# Trigger PageChangeCall
1057 ImpShowPageOfThisObject();
1059 SdrObjList* pOL=pObj->GetObjList();
1060 if (pOL==NULL) {
1061 DBG_ERROR("UndoObjOrdNum: pObj hat keine ObjList");
1062 return;
1064 pOL->SetObjectOrdNum(nNewOrdNum,nOldOrdNum);
1067 void SdrUndoObjOrdNum::Redo()
1069 SdrObjList* pOL=pObj->GetObjList();
1070 if (pOL==NULL) {
1071 DBG_ERROR("RedoObjOrdNum: pObj hat keine ObjList");
1072 return;
1074 pOL->SetObjectOrdNum(nOldOrdNum,nNewOrdNum);
1076 // #94278# Trigger PageChangeCall
1077 ImpShowPageOfThisObject();
1080 XubString SdrUndoObjOrdNum::GetComment() const
1082 XubString aStr;
1083 ImpTakeDescriptionStr(STR_UndoObjOrdNum,aStr);
1084 return aStr;
1087 ////////////////////////////////////////////////////////////////////////////////////////////////////
1089 SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText)
1090 : SdrUndoObj(rNewObj)
1091 , pOldText(NULL)
1092 , pNewText(NULL)
1093 , bNewTextAvailable(FALSE)
1094 , bEmptyPresObj(FALSE)
1095 , mnText(nText)
1097 SdrText* pText = static_cast< SdrTextObj*>( &rNewObj )->getText(mnText);
1098 if( pText && pText->GetOutlinerParaObject() )
1099 pOldText = new OutlinerParaObject(*pText->GetOutlinerParaObject());
1101 bEmptyPresObj = rNewObj.IsEmptyPresObj();
1104 SdrUndoObjSetText::~SdrUndoObjSetText()
1106 if ( pOldText )
1107 delete pOldText;
1108 if ( pNewText )
1109 delete pNewText;
1112 void SdrUndoObjSetText::AfterSetText()
1114 if (!bNewTextAvailable)
1116 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
1117 if( pText && pText->GetOutlinerParaObject() )
1118 pNewText = new OutlinerParaObject(*pText->GetOutlinerParaObject());
1119 bNewTextAvailable=TRUE;
1123 void SdrUndoObjSetText::Undo()
1125 // #94278# Trigger PageChangeCall
1126 ImpShowPageOfThisObject();
1128 // alten Text sichern fuer Redo
1129 if (!bNewTextAvailable)
1130 AfterSetText();
1132 // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung
1133 OutlinerParaObject* pText1 = pOldText;
1134 if(pText1)
1135 pText1 = new OutlinerParaObject(*pText1);
1137 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
1138 if( pText )
1139 pText->SetOutlinerParaObject(pText1);
1141 pObj->SetEmptyPresObj( bEmptyPresObj );
1142 pObj->ActionChanged();
1145 void SdrUndoObjSetText::Redo()
1147 // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung
1148 OutlinerParaObject* pText1 = pNewText;
1150 if(pText1)
1151 pText1 = new OutlinerParaObject(*pText1);
1153 SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
1154 if( pText )
1155 static_cast< SdrTextObj* >( pObj )->NbcSetOutlinerParaObjectForText( pText1, pText );
1157 pObj->ActionChanged();
1159 // #94278# Trigger PageChangeCall
1160 ImpShowPageOfThisObject();
1163 XubString SdrUndoObjSetText::GetComment() const
1165 XubString aStr;
1166 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
1167 return aStr;
1170 XubString SdrUndoObjSetText::GetSdrRepeatComment(SdrView& /*rView*/) const
1172 XubString aStr;
1173 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
1174 return aStr;
1177 void SdrUndoObjSetText::SdrRepeat(SdrView& rView)
1179 if (bNewTextAvailable && rView.AreObjectsMarked())
1181 const SdrMarkList& rML=rView.GetMarkedObjectList();
1183 const bool bUndo = rView.IsUndoEnabled();
1184 if( bUndo )
1186 XubString aStr;
1187 ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
1188 rView.BegUndo(aStr);
1191 ULONG nAnz=rML.GetMarkCount();
1192 for (ULONG nm=0; nm<nAnz; nm++)
1194 SdrObject* pObj2=rML.GetMark(nm)->GetMarkedSdrObj();
1195 SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pObj2);
1196 if (pTextObj!=NULL)
1198 if( bUndo )
1199 rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0));
1201 OutlinerParaObject* pText1=pNewText;
1202 if (pText1!=NULL)
1203 pText1 = new OutlinerParaObject(*pText1);
1204 pTextObj->SetOutlinerParaObject(pText1);
1208 if( bUndo )
1209 rView.EndUndo();
1213 bool SdrUndoObjSetText::CanSdrRepeat(SdrView& rView) const
1215 FASTBOOL bOk=FALSE;
1216 if (bNewTextAvailable && rView.AreObjectsMarked()) {
1217 bOk=TRUE;
1219 return bOk;
1222 // --> OD 2009-07-09 #i73249#
1223 SdrUndoObjStrAttr::SdrUndoObjStrAttr( SdrObject& rNewObj,
1224 const ObjStrAttrType eObjStrAttr,
1225 const String& sOldStr,
1226 const String& sNewStr)
1227 : SdrUndoObj( rNewObj ),
1228 meObjStrAttr( eObjStrAttr ),
1229 msOldStr( sOldStr ),
1230 msNewStr( sNewStr )
1234 void SdrUndoObjStrAttr::Undo()
1236 ImpShowPageOfThisObject();
1238 switch ( meObjStrAttr )
1240 case OBJ_NAME:
1242 pObj->SetName( msOldStr );
1244 break;
1245 case OBJ_TITLE:
1247 pObj->SetTitle( msOldStr );
1249 break;
1250 case OBJ_DESCRIPTION:
1252 pObj->SetDescription( msOldStr );
1254 break;
1258 void SdrUndoObjStrAttr::Redo()
1260 switch ( meObjStrAttr )
1262 case OBJ_NAME:
1264 pObj->SetName( msNewStr );
1266 break;
1267 case OBJ_TITLE:
1269 pObj->SetTitle( msNewStr );
1271 break;
1272 case OBJ_DESCRIPTION:
1274 pObj->SetDescription( msNewStr );
1276 break;
1279 ImpShowPageOfThisObject();
1282 String SdrUndoObjStrAttr::GetComment() const
1284 String aStr;
1285 switch ( meObjStrAttr )
1287 case OBJ_NAME:
1289 ImpTakeDescriptionStr( STR_UndoObjName, aStr );
1290 aStr += sal_Unicode(' ');
1291 aStr += sal_Unicode('\'');
1292 aStr += msNewStr;
1293 aStr += sal_Unicode('\'');
1295 break;
1296 case OBJ_TITLE:
1298 ImpTakeDescriptionStr( STR_UndoObjTitle, aStr );
1300 break;
1301 case OBJ_DESCRIPTION:
1303 ImpTakeDescriptionStr( STR_UndoObjDescription, aStr );
1305 break;
1308 return aStr;
1311 ////////////////////////////////////////////////////////////////////////////////////////////////////
1312 ////////////////////////////////////////////////////////////////////////////////////////////////////
1314 // @@ @@@@ @@ @@ @@@@@ @@@@@
1315 // @@ @@ @@ @@ @@ @@ @@ @@
1316 // @@ @@ @@ @@ @@ @@ @@ @@
1317 // @@ @@@@@@ @@@@ @@@@ @@@@@
1318 // @@ @@ @@ @@ @@ @@ @@
1319 // @@ @@ @@ @@ @@ @@ @@
1320 // @@@@@ @@ @@ @@ @@@@@ @@ @@
1322 ////////////////////////////////////////////////////////////////////////////////////////////////////
1323 ////////////////////////////////////////////////////////////////////////////////////////////////////
1325 SdrUndoLayer::SdrUndoLayer(USHORT nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel):
1326 SdrUndoAction(rNewModel),
1327 pLayer(rNewLayerAdmin.GetLayer(nLayerNum)),
1328 pLayerAdmin(&rNewLayerAdmin),
1329 nNum(nLayerNum),
1330 bItsMine(FALSE)
1334 SdrUndoLayer::~SdrUndoLayer()
1336 if (bItsMine) {
1337 delete pLayer;
1341 ////////////////////////////////////////////////////////////////////////////////////////////////////
1343 void SdrUndoNewLayer::Undo()
1345 DBG_ASSERT(!bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert bereits der UndoAction");
1346 bItsMine=TRUE;
1347 #ifdef DBG_UTIL
1348 SdrLayer* pCmpLayer=
1349 #endif
1350 pLayerAdmin->RemoveLayer(nNum);
1351 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoNewLayer::Undo(): Removter Layer ist != pLayer");
1354 void SdrUndoNewLayer::Redo()
1356 DBG_ASSERT(bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert nicht der UndoAction");
1357 bItsMine=FALSE;
1358 pLayerAdmin->InsertLayer(pLayer,nNum);
1361 XubString SdrUndoNewLayer::GetComment() const
1363 return ImpGetResStr(STR_UndoNewLayer);
1366 ////////////////////////////////////////////////////////////////////////////////////////////////////
1368 void SdrUndoDelLayer::Undo()
1370 DBG_ASSERT(bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert nicht der UndoAction");
1371 bItsMine=FALSE;
1372 pLayerAdmin->InsertLayer(pLayer,nNum);
1375 void SdrUndoDelLayer::Redo()
1377 DBG_ASSERT(!bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert bereits der UndoAction");
1378 bItsMine=TRUE;
1379 #ifdef DBG_UTIL
1380 SdrLayer* pCmpLayer=
1381 #endif
1382 pLayerAdmin->RemoveLayer(nNum);
1383 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoDelLayer::Redo(): Removter Layer ist != pLayer");
1386 XubString SdrUndoDelLayer::GetComment() const
1388 return ImpGetResStr(STR_UndoDelLayer);
1391 ////////////////////////////////////////////////////////////////////////////////////////////////////
1393 void SdrUndoMoveLayer::Undo()
1395 #ifdef DBG_UTIL
1396 SdrLayer* pCmpLayer=
1397 #endif
1398 pLayerAdmin->RemoveLayer(nNeuPos);
1399 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Undo(): Removter Layer ist != pLayer");
1400 pLayerAdmin->InsertLayer(pLayer,nNum);
1403 void SdrUndoMoveLayer::Redo()
1405 #ifdef DBG_UTIL
1406 SdrLayer* pCmpLayer=
1407 #endif
1408 pLayerAdmin->RemoveLayer(nNum);
1409 DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Redo(): Removter Layer ist != pLayer");
1410 pLayerAdmin->InsertLayer(pLayer,nNeuPos);
1413 XubString SdrUndoMoveLayer::GetComment() const
1415 return ImpGetResStr(STR_UndoMovLayer);
1418 ////////////////////////////////////////////////////////////////////////////////////////////////////
1419 ////////////////////////////////////////////////////////////////////////////////////////////////////
1421 // @@@@@ @@@@ @@@@ @@@@@ @@@@
1422 // @@ @@ @@ @@ @@ @@ @@ @@ @@
1423 // @@ @@ @@ @@ @@ @@ @@
1424 // @@@@@ @@@@@@ @@ @@@ @@@@ @@@@
1425 // @@ @@ @@ @@ @@ @@ @@
1426 // @@ @@ @@ @@ @@ @@ @@ @@
1427 // @@ @@ @@ @@@@@ @@@@@ @@@@
1429 ////////////////////////////////////////////////////////////////////////////////////////////////////
1430 ////////////////////////////////////////////////////////////////////////////////////////////////////
1432 SdrUndoPage::SdrUndoPage(SdrPage& rNewPg)
1433 : SdrUndoAction(*rNewPg.GetModel()),
1434 mrPage(rNewPg)
1438 void SdrUndoPage::ImpInsertPage(USHORT nNum)
1440 DBG_ASSERT(!mrPage.IsInserted(),"SdrUndoPage::ImpInsertPage(): mrPage ist bereits Inserted");
1441 if (!mrPage.IsInserted()) {
1442 if (mrPage.IsMasterPage()) {
1443 rMod.InsertMasterPage(&mrPage,nNum);
1444 } else {
1445 rMod.InsertPage(&mrPage,nNum);
1450 void SdrUndoPage::ImpRemovePage(USHORT nNum)
1452 DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpRemovePage(): mrPage ist nicht Inserted");
1453 if (mrPage.IsInserted()) {
1454 SdrPage* pChkPg=NULL;
1455 if (mrPage.IsMasterPage()) {
1456 pChkPg=rMod.RemoveMasterPage(nNum);
1457 } else {
1458 pChkPg=rMod.RemovePage(nNum);
1460 DBG_ASSERT(pChkPg==&mrPage,"SdrUndoPage::ImpRemovePage(): RemovePage!=&mrPage");
1464 void SdrUndoPage::ImpMovePage(USHORT nOldNum, USHORT nNewNum)
1466 DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpMovePage(): mrPage ist nicht Inserted");
1467 if (mrPage.IsInserted()) {
1468 if (mrPage.IsMasterPage()) {
1469 rMod.MoveMasterPage(nOldNum,nNewNum);
1470 } else {
1471 rMod.MovePage(nOldNum,nNewNum);
1476 void SdrUndoPage::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT /*n*/, FASTBOOL /*bRepeat*/) const
1478 rStr=ImpGetResStr(nStrCacheID);
1481 ////////////////////////////////////////////////////////////////////////////////////////////////////
1483 SdrUndoPageList::SdrUndoPageList(SdrPage& rNewPg):
1484 SdrUndoPage(rNewPg),
1485 bItsMine(FALSE)
1487 nPageNum=rNewPg.GetPageNum();
1490 SdrUndoPageList::~SdrUndoPageList()
1492 if(bItsMine)
1494 delete (&mrPage);
1498 ////////////////////////////////////////////////////////////////////////////////////////////////////
1500 SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg):
1501 SdrUndoPageList(rNewPg),
1502 pUndoGroup(NULL)
1504 bItsMine = TRUE;
1506 // Und nun ggf. die MasterPage-Beziehungen merken
1507 if(mrPage.IsMasterPage())
1509 sal_uInt16 nPageAnz(rMod.GetPageCount());
1511 for(sal_uInt16 nPageNum2(0); nPageNum2 < nPageAnz; nPageNum2++)
1513 SdrPage* pDrawPage = rMod.GetPage(nPageNum2);
1515 if(pDrawPage->TRG_HasMasterPage())
1517 SdrPage& rMasterPage = pDrawPage->TRG_GetMasterPage();
1519 if(&mrPage == &rMasterPage)
1521 if(!pUndoGroup)
1523 pUndoGroup = new SdrUndoGroup(rMod);
1526 pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage));
1533 SdrUndoDelPage::~SdrUndoDelPage()
1535 if (pUndoGroup!=NULL) {
1536 delete pUndoGroup;
1540 void SdrUndoDelPage::Undo()
1542 ImpInsertPage(nPageNum);
1543 if (pUndoGroup!=NULL) { // MasterPage-Beziehungen wiederherstellen
1544 pUndoGroup->Undo();
1546 DBG_ASSERT(bItsMine,"UndoDeletePage: mrPage gehoert nicht der UndoAction");
1547 bItsMine=FALSE;
1550 void SdrUndoDelPage::Redo()
1552 ImpRemovePage(nPageNum);
1553 // Die MasterPage-Beziehungen werden ggf. von selbst geloesst
1554 DBG_ASSERT(!bItsMine,"RedoDeletePage: mrPage gehoert bereits der UndoAction");
1555 bItsMine=TRUE;
1558 XubString SdrUndoDelPage::GetComment() const
1560 XubString aStr;
1561 ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,FALSE);
1562 return aStr;
1565 XubString SdrUndoDelPage::GetSdrRepeatComment(SdrView& /*rView*/) const
1567 XubString aStr;
1568 ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,FALSE);
1569 return aStr;
1572 void SdrUndoDelPage::SdrRepeat(SdrView& /*rView*/)
1576 bool SdrUndoDelPage::CanSdrRepeat(SdrView& /*rView*/) const
1578 return FALSE;
1581 ////////////////////////////////////////////////////////////////////////////////////////////////////
1583 void SdrUndoNewPage::Undo()
1585 ImpRemovePage(nPageNum);
1586 DBG_ASSERT(!bItsMine,"UndoNewPage: mrPage gehoert bereits der UndoAction");
1587 bItsMine=TRUE;
1590 void SdrUndoNewPage::Redo()
1592 ImpInsertPage(nPageNum);
1593 DBG_ASSERT(bItsMine,"RedoNewPage: mrPage gehoert nicht der UndoAction");
1594 bItsMine=FALSE;
1597 XubString SdrUndoNewPage::GetComment() const
1599 XubString aStr;
1600 ImpTakeDescriptionStr(STR_UndoNewPage,aStr,0,FALSE);
1601 return aStr;
1604 ////////////////////////////////////////////////////////////////////////////////////////////////////
1606 XubString SdrUndoCopyPage::GetComment() const
1608 XubString aStr;
1609 ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,FALSE);
1610 return aStr;
1613 XubString SdrUndoCopyPage::GetSdrRepeatComment(SdrView& /*rView*/) const
1615 XubString aStr;
1616 ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,FALSE);
1617 return aStr;
1620 void SdrUndoCopyPage::SdrRepeat(SdrView& /*rView*/)
1625 bool SdrUndoCopyPage::CanSdrRepeat(SdrView& /*rView*/) const
1627 return FALSE;
1630 ////////////////////////////////////////////////////////////////////////////////////////////////////
1632 void SdrUndoSetPageNum::Undo()
1634 ImpMovePage(nNewPageNum,nOldPageNum);
1637 void SdrUndoSetPageNum::Redo()
1639 ImpMovePage(nOldPageNum,nNewPageNum);
1642 XubString SdrUndoSetPageNum::GetComment() const
1644 XubString aStr;
1645 ImpTakeDescriptionStr(STR_UndoMovPage,aStr,0,FALSE);
1646 return aStr;
1649 ////////////////////////////////////////////////////////////////////////////////////////////////////
1651 // @@ @@ @@@@ @@@@ @@@@@@ @@@@@ @@@@@ @@@@@ @@@@ @@@@ @@@@@ @@@@
1652 // @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
1653 // @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
1654 // @@@@@@@ @@@@@@ @@@@ @@ @@@@ @@@@@ @@@@@ @@@@@@ @@ @@@ @@@@ @@@@
1655 // @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
1656 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
1657 // @@ @@ @@ @@ @@@@ @@ @@@@@ @@ @@ @@ @@ @@ @@@@@ @@@@@ @@@@
1659 ////////////////////////////////////////////////////////////////////////////////////////////////////
1661 SdrUndoPageMasterPage::SdrUndoPageMasterPage(SdrPage& rChangedPage)
1662 : SdrUndoPage(rChangedPage),
1663 mbOldHadMasterPage(mrPage.TRG_HasMasterPage())
1665 // get current state from page
1666 if(mbOldHadMasterPage)
1668 maOldSet = mrPage.TRG_GetMasterPageVisibleLayers();
1669 maOldMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum();
1673 SdrUndoPageMasterPage::~SdrUndoPageMasterPage()
1677 ////////////////////////////////////////////////////////////////////////////////////////////////////
1679 SdrUndoPageRemoveMasterPage::SdrUndoPageRemoveMasterPage(SdrPage& rChangedPage)
1680 : SdrUndoPageMasterPage(rChangedPage)
1684 void SdrUndoPageRemoveMasterPage::Undo()
1686 if(mbOldHadMasterPage)
1688 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
1689 mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
1693 void SdrUndoPageRemoveMasterPage::Redo()
1695 mrPage.TRG_ClearMasterPage();
1698 XubString SdrUndoPageRemoveMasterPage::GetComment() const
1700 XubString aStr;
1701 ImpTakeDescriptionStr(STR_UndoDelPageMasterDscr,aStr,0,FALSE);
1702 return aStr;
1705 ////////////////////////////////////////////////////////////////////////////////////////////////////
1707 SdrUndoPageChangeMasterPage::SdrUndoPageChangeMasterPage(SdrPage& rChangedPage)
1708 : SdrUndoPageMasterPage(rChangedPage),
1709 mbNewHadMasterPage(sal_False)
1713 void SdrUndoPageChangeMasterPage::Undo()
1715 // remember values from new page
1716 if(mrPage.TRG_HasMasterPage())
1718 mbNewHadMasterPage = sal_True;
1719 maNewSet = mrPage.TRG_GetMasterPageVisibleLayers();
1720 maNewMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum();
1723 // restore old values
1724 if(mbOldHadMasterPage)
1726 mrPage.TRG_ClearMasterPage();
1727 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
1728 mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
1732 void SdrUndoPageChangeMasterPage::Redo()
1734 // restore new values
1735 if(mbNewHadMasterPage)
1737 mrPage.TRG_ClearMasterPage();
1738 mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maNewMasterPageNumber));
1739 mrPage.TRG_SetMasterPageVisibleLayers(maNewSet);
1743 XubString SdrUndoPageChangeMasterPage::GetComment() const
1745 XubString aStr;
1746 ImpTakeDescriptionStr(STR_UndoChgPageMasterDscr,aStr,0,FALSE);
1747 return aStr;
1750 ///////////////////////////////////////////////////////////////////////
1751 SdrUndoFactory::~SdrUndoFactory(){}
1752 // shapes
1753 SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject )
1755 return new SdrUndoMoveObj( rObject );
1758 SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
1760 return new SdrUndoMoveObj( rObject, rDist );
1763 SdrUndoAction* SdrUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
1765 return new SdrUndoGeoObj( rObject );
1768 SdrUndoAction* SdrUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
1770 return new SdrUndoAttrObj( rObject, bStyleSheet1 ? TRUE : FALSE, bSaveText ? TRUE : FALSE );
1773 SdrUndoAction* SdrUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
1775 return new SdrUndoRemoveObj( rObject, bOrdNumDirect ? TRUE : FALSE );
1778 SdrUndoAction* SdrUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect )
1780 return new SdrUndoInsertObj( rObject, bOrdNumDirect ? TRUE : FALSE );
1783 SdrUndoAction* SdrUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect )
1785 return new SdrUndoDelObj( rObject, bOrdNumDirect ? TRUE : FALSE );
1788 SdrUndoAction* SdrUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect )
1790 return new SdrUndoNewObj( rObject, bOrdNumDirect ? TRUE : FALSE );
1793 SdrUndoAction* SdrUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
1795 return new SdrUndoCopyObj( rObject, bOrdNumDirect ? TRUE : FALSE );
1798 SdrUndoAction* SdrUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
1800 return new SdrUndoObjOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
1803 SdrUndoAction* SdrUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
1805 return new SdrUndoReplaceObj( rOldObject, rNewObject, bOrdNumDirect ? TRUE : FALSE );
1808 SdrUndoAction* SdrUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
1810 return new SdrUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
1813 SdrUndoAction* SdrUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
1815 return new SdrUndoObjSetText( rNewObj, nText );
1818 SdrUndoAction* SdrUndoFactory::CreateUndoObjectStrAttr( SdrObject& rObject,
1819 SdrUndoObjStrAttr::ObjStrAttrType eObjStrAttrType,
1820 String sOldStr,
1821 String sNewStr )
1823 return new SdrUndoObjStrAttr( rObject, eObjStrAttrType, sOldStr, sNewStr );
1827 // layer
1828 SdrUndoAction* SdrUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
1830 return new SdrUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
1833 SdrUndoAction* SdrUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
1835 return new SdrUndoDelLayer( nLayerNum, rNewLayerAdmin, rNewModel );
1838 SdrUndoAction* SdrUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1)
1840 return new SdrUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 );
1843 // page
1844 SdrUndoAction* SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
1846 return new SdrUndoDelPage( rPage );
1849 SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage)
1851 return new SdrUndoNewPage( rPage );
1854 SdrUndoAction* SdrUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
1856 return new SdrUndoCopyPage( rPage );
1859 SdrUndoAction* SdrUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
1861 return new SdrUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
1863 // master page
1864 SdrUndoAction* SdrUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
1866 return new SdrUndoPageRemoveMasterPage( rChangedPage );
1869 SdrUndoAction* SdrUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
1871 return new SdrUndoPageChangeMasterPage(rChangedPage);
1874 // eof