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
);
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
);
92 bool SdrUndoAction::CanSdrRepeat(SdrView
& /*rView*/) const
97 void SdrUndoAction::SdrRepeat(SdrView
& /*rView*/)
101 XubString
SdrUndoAction::GetSdrRepeatComment(SdrView
& /*rView*/) const
106 ////////////////////////////////////////////////////////////////////////////////////////////////////
108 SdrUndoGroup::SdrUndoGroup(SdrModel
& rNewMod
)
109 : SdrUndoAction(rNewMod
),
111 eFunction(SDRREPFUNC_OBJ_NONE
) /*#72642#*/
114 SdrUndoGroup::SdrUndoGroup(SdrModel
& rNewMod
,const String
& rStr
)
115 : SdrUndoAction(rNewMod
),
118 eFunction(SDRREPFUNC_OBJ_NONE
)
121 SdrUndoGroup::~SdrUndoGroup()
126 void SdrUndoGroup::Clear()
128 for (ULONG nu
=0; nu
<GetActionCount(); nu
++) {
129 SdrUndoAction
* pAct
=GetAction(nu
);
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;) {
149 SdrUndoAction
* pAct
=GetAction(nu
);
154 void SdrUndoGroup::Redo()
156 for (ULONG nu
=0; nu
<GetActionCount(); nu
++) {
157 SdrUndoAction
* pAct
=GetAction(nu
);
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
);
173 bool SdrUndoGroup::CanSdrRepeat(SdrView
& rView
) const
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();
197 void SdrUndoGroup::SdrRepeat(SdrView
& rView
)
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;
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
));
231 ////////////////////////////////////////////////////////////////////////////////////////////////////
232 ////////////////////////////////////////////////////////////////////////////////////////////////////
234 // @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@ @@@@
235 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
236 // @@ @@ @@ @@ @@ @@ @@ @@ @@
237 // @@ @@ @@@@@ @@ @@@@ @@ @@ @@@@
238 // @@ @@ @@ @@ @@ @@ @@ @@ @@
239 // @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
240 // @@@@ @@@@@ @@@@ @@@@@ @@@@ @@ @@@@
242 ////////////////////////////////////////////////////////////////////////////////////////////////////
243 ////////////////////////////////////////////////////////////////////////////////////////////////////
245 SdrUndoObj::SdrUndoObj(SdrObject
& rNewObj
):
246 SdrUndoAction(*rNewObj
.GetModel()),
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
)
265 rStr
.Insert(ImpGetResStr(STR_ObjNameSingulPlural
), nPos
);
271 _rForObject
.TakeObjNameSingul(aStr
);
272 rStr
.Insert(aStr
, nPos
);
277 void SdrUndoObj::ImpTakeDescriptionStr(USHORT nStrCacheID
, XubString
& rStr
, FASTBOOL bRepeat
) const
280 GetDescriptionStringForObject( *pObj
, nStrCacheID
, rStr
, bRepeat
);
283 // #94278# common call method for evtl. page change when UNDO/REDO
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
),
305 pUndoStyleSheet(NULL
),
306 pRedoStyleSheet(NULL
),
307 pRepeatStyleSheet(NULL
),
308 bHaveToTakeRedoSet(TRUE
),
316 bStyleSheet
= bStyleSheet1
;
318 SdrObjList
* pOL
= rNewObj
.GetSubList();
319 BOOL
bIsGroup(pOL
!=NULL
&& pOL
->GetObjCount());
320 BOOL
bIs3DScene(bIsGroup
&& pObj
->ISA(E3dScene
));
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
)
342 pUndoSet
= new SfxItemSet(pObj
->GetMergedItemSet());
345 pUndoStyleSheet
= pObj
->GetStyleSheet();
349 pTextUndo
= pObj
->GetOutlinerParaObject();
351 pTextUndo
= new OutlinerParaObject(*pTextUndo
);
356 SdrUndoAttrObj::~SdrUndoAttrObj()
374 void SdrUndoAttrObj::SetRepeatAttr(const SfxItemSet
& rSet
)
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
;
401 pRedoSet
= new SfxItemSet(pObj
->GetMergedItemSet());
404 pRedoStyleSheet
=pObj
->GetStyleSheet();
409 pTextRedo
= pObj
->GetOutlinerParaObject();
412 pTextRedo
= new OutlinerParaObject(*pTextRedo
);
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();
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
442 SfxWhichIter
aIter(*pUndoSet
);
443 sal_uInt16
nWhich(aIter
.FirstWhich());
447 if(SFX_ITEM_SET
!= pUndoSet
->GetItemState(nWhich
, sal_False
))
449 pObj
->ClearMergedItem(nWhich
);
452 nWhich
= aIter
.NextWhich();
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
);
473 pObj
->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo
));
483 void SdrUndoAttrObj::Redo()
485 E3DModifySceneSnapRectUpdater
aUpdater(pObj
);
486 BOOL
bIs3DScene(pObj
&& pObj
->ISA(E3dScene
));
488 if(!pUndoGroup
|| bIs3DScene
)
492 pUndoStyleSheet
= pObj
->GetStyleSheet();
493 pObj
->SetStyleSheet(pRedoStyleSheet
, TRUE
);
496 sdr::properties::ItemChangeBroadcaster
aItemChange(*pObj
);
499 const Rectangle aSnapRect
= pObj
->GetSnapRect();
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
511 SfxWhichIter
aIter(*pRedoSet
);
512 sal_uInt16
nWhich(aIter
.FirstWhich());
516 if(SFX_ITEM_SET
!= pRedoSet
->GetItemState(nWhich
, sal_False
))
518 pObj
->ClearMergedItem(nWhich
);
521 nWhich
= aIter
.NextWhich();
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
);
543 pObj
->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo
));
552 // #94278# Trigger PageChangeCall
553 ImpShowPageOfThisObject();
556 XubString
SdrUndoAttrObj::GetComment() const
562 ImpTakeDescriptionStr(STR_EditSetStylesheet
, aStr
);
566 ImpTakeDescriptionStr(STR_EditSetAttributes
, aStr
);
572 void SdrUndoAttrObj::SdrRepeat(SdrView
& rView
)
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
591 ImpTakeDescriptionStr(STR_EditSetStylesheet
, aStr
, TRUE
);
595 ImpTakeDescriptionStr(STR_EditSetAttributes
, aStr
, TRUE
);
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
622 ImpTakeDescriptionStr(STR_EditMove
,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
639 ImpTakeDescriptionStr(STR_EditMove
,aStr
,TRUE
);
643 ////////////////////////////////////////////////////////////////////////////////////////////////////
645 SdrUndoGeoObj::SdrUndoGeoObj(SdrObject
& rNewObj
):
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
)));
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();
683 // only repaint, no objectchange
684 pObj
->ActionChanged();
688 if (pRedoGeo
!=NULL
) delete pRedoGeo
;
689 pRedoGeo
=pObj
->GetGeoData();
690 pObj
->SetGeoData(*pUndoGeo
);
694 void SdrUndoGeoObj::Redo()
701 // only repaint, no objectchange
702 pObj
->ActionChanged();
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
718 ImpTakeDescriptionStr(STR_DragMethObjOwn
,aStr
);
722 ////////////////////////////////////////////////////////////////////////////////////////////////////
724 SdrUndoObjList::SdrUndoObjList(SdrObject
& rNewObj
, bool bOrdNumDirect
)
725 : SdrUndoObj(rNewObj
),
730 pObjList
=pObj
->GetObjList();
732 nOrdNum
=pObj
->GetOrdNumDirect();
734 nOrdNum
=pObj
->GetOrdNum();
738 SdrUndoObjList::~SdrUndoObjList()
740 if (pObj
!=NULL
&& IsOwner())
742 // Attribute muessen wieder in den regulaeren Pool
746 SdrObject::Free( pObj
);
750 void SdrUndoObjList::SetOwner(bool 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())
766 // For UNDOs in Calc/Writer it is necessary to adapt the anchor
767 // pos of the target object.
768 Point
aOwnerAnchorPos(0, 0);
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
);
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
);
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 );
833 pObjList
->GetOwnerObj() &&
834 pObjList
->GetOwnerObj()->ISA(SdrObjGroup
) )
836 aAnchorPos
= pObj
->GetAnchorPos();
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
);
851 // #94278# Trigger PageChangeCall
852 ImpShowPageOfThisObject();
855 ////////////////////////////////////////////////////////////////////////////////////////////////////
857 void SdrUndoDelObj::Undo()
859 SdrUndoRemoveObj::Undo();
860 DBG_ASSERT(IsOwner(),"UndoDeleteObj: pObj gehoert nicht der UndoAction");
864 void SdrUndoDelObj::Redo()
866 SdrUndoRemoveObj::Redo();
867 DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj gehoert bereits der UndoAction");
871 XubString
SdrUndoDelObj::GetComment() const
874 ImpTakeDescriptionStr(STR_EditDelete
,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
891 ImpTakeDescriptionStr(STR_EditDelete
,aStr
,TRUE
);
895 ////////////////////////////////////////////////////////////////////////////////////////////////////
897 void SdrUndoNewObj::Undo()
899 SdrUndoInsertObj::Undo();
900 DBG_ASSERT(!IsOwner(),"RedoNewObj: pObj gehoert bereits der UndoAction");
904 void SdrUndoNewObj::Redo()
906 SdrUndoInsertObj::Redo();
907 DBG_ASSERT(IsOwner(),"RedoNewObj: pObj gehoert nicht der UndoAction");
911 String
SdrUndoNewObj::GetComment( const SdrObject
& _rForObject
)
914 GetDescriptionStringForObject( _rForObject
, STR_UndoInsertObj
, sComment
);
918 XubString
SdrUndoNewObj::GetComment() const
921 ImpTakeDescriptionStr(STR_UndoInsertObj
,aStr
);
925 SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject
& rOldObj1
, SdrObject
& rNewObj1
, bool bOrdNumDirect
)
926 : SdrUndoObj(rOldObj1
),
933 pObjList
=pObj
->GetObjList();
935 nOrdNum
=pObj
->GetOrdNumDirect();
937 nOrdNum
=pObj
->GetOrdNum();
941 SdrUndoReplaceObj::~SdrUndoReplaceObj()
943 if (pObj
!=NULL
&& IsOldOwner())
945 // Attribute muessen wieder in den regulaeren Pool
949 SdrObject::Free( pObj
);
951 if (pNewObj
!=NULL
&& IsNewOwner())
953 // Attribute muessen wieder in den regulaeren Pool
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!");
973 ImplUnmarkObject( pNewObj
);
974 pObjList
->ReplaceObject(pObj
,nOrdNum
);
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!");
991 ImplUnmarkObject( pObj
);
992 pObjList
->ReplaceObject(pNewObj
,nOrdNum
);
997 DBG_ERROR("SdrUndoReplaceObj::Redo(): IsMine-Flags stehen verkehrt. Doppelter Redo-Aufruf?");
1000 // #94278# Trigger PageChangeCall
1001 ImpShowPageOfThisObject();
1004 void SdrUndoReplaceObj::SetNewOwner(bool bNew
)
1009 void SdrUndoReplaceObj::SetOldOwner(bool bNew
)
1014 ////////////////////////////////////////////////////////////////////////////////////////////////////
1016 XubString
SdrUndoCopyObj::GetComment() const
1019 ImpTakeDescriptionStr(STR_UndoCopyObj
,aStr
);
1023 ////////////////////////////////////////////////////////////////////////////////////////////////////
1026 SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject
& rObj
, SdrLayerID aOldLayer
, SdrLayerID aNewLayer
)
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();
1061 DBG_ERROR("UndoObjOrdNum: pObj hat keine ObjList");
1064 pOL
->SetObjectOrdNum(nNewOrdNum
,nOldOrdNum
);
1067 void SdrUndoObjOrdNum::Redo()
1069 SdrObjList
* pOL
=pObj
->GetObjList();
1071 DBG_ERROR("RedoObjOrdNum: pObj hat keine ObjList");
1074 pOL
->SetObjectOrdNum(nOldOrdNum
,nNewOrdNum
);
1076 // #94278# Trigger PageChangeCall
1077 ImpShowPageOfThisObject();
1080 XubString
SdrUndoObjOrdNum::GetComment() const
1083 ImpTakeDescriptionStr(STR_UndoObjOrdNum
,aStr
);
1087 ////////////////////////////////////////////////////////////////////////////////////////////////////
1089 SdrUndoObjSetText::SdrUndoObjSetText(SdrObject
& rNewObj
, sal_Int32 nText
)
1090 : SdrUndoObj(rNewObj
)
1093 , bNewTextAvailable(FALSE
)
1094 , bEmptyPresObj(FALSE
)
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()
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
)
1132 // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung
1133 OutlinerParaObject
* pText1
= pOldText
;
1135 pText1
= new OutlinerParaObject(*pText1
);
1137 SdrText
* pText
= static_cast< SdrTextObj
*>( pObj
)->getText(mnText
);
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
;
1151 pText1
= new OutlinerParaObject(*pText1
);
1153 SdrText
* pText
= static_cast< SdrTextObj
*>( pObj
)->getText(mnText
);
1155 static_cast< SdrTextObj
* >( pObj
)->NbcSetOutlinerParaObjectForText( pText1
, pText
);
1157 pObj
->ActionChanged();
1159 // #94278# Trigger PageChangeCall
1160 ImpShowPageOfThisObject();
1163 XubString
SdrUndoObjSetText::GetComment() const
1166 ImpTakeDescriptionStr(STR_UndoObjSetText
,aStr
);
1170 XubString
SdrUndoObjSetText::GetSdrRepeatComment(SdrView
& /*rView*/) const
1173 ImpTakeDescriptionStr(STR_UndoObjSetText
,aStr
);
1177 void SdrUndoObjSetText::SdrRepeat(SdrView
& rView
)
1179 if (bNewTextAvailable
&& rView
.AreObjectsMarked())
1181 const SdrMarkList
& rML
=rView
.GetMarkedObjectList();
1183 const bool bUndo
= rView
.IsUndoEnabled();
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
);
1199 rView
.AddUndo(new SdrUndoObjSetText(*pTextObj
,0));
1201 OutlinerParaObject
* pText1
=pNewText
;
1203 pText1
= new OutlinerParaObject(*pText1
);
1204 pTextObj
->SetOutlinerParaObject(pText1
);
1213 bool SdrUndoObjSetText::CanSdrRepeat(SdrView
& rView
) const
1216 if (bNewTextAvailable
&& rView
.AreObjectsMarked()) {
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
),
1234 void SdrUndoObjStrAttr::Undo()
1236 ImpShowPageOfThisObject();
1238 switch ( meObjStrAttr
)
1242 pObj
->SetName( msOldStr
);
1247 pObj
->SetTitle( msOldStr
);
1250 case OBJ_DESCRIPTION
:
1252 pObj
->SetDescription( msOldStr
);
1258 void SdrUndoObjStrAttr::Redo()
1260 switch ( meObjStrAttr
)
1264 pObj
->SetName( msNewStr
);
1269 pObj
->SetTitle( msNewStr
);
1272 case OBJ_DESCRIPTION
:
1274 pObj
->SetDescription( msNewStr
);
1279 ImpShowPageOfThisObject();
1282 String
SdrUndoObjStrAttr::GetComment() const
1285 switch ( meObjStrAttr
)
1289 ImpTakeDescriptionStr( STR_UndoObjName
, aStr
);
1290 aStr
+= sal_Unicode(' ');
1291 aStr
+= sal_Unicode('\'');
1293 aStr
+= sal_Unicode('\'');
1298 ImpTakeDescriptionStr( STR_UndoObjTitle
, aStr
);
1301 case OBJ_DESCRIPTION
:
1303 ImpTakeDescriptionStr( STR_UndoObjDescription
, 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
),
1334 SdrUndoLayer::~SdrUndoLayer()
1341 ////////////////////////////////////////////////////////////////////////////////////////////////////
1343 void SdrUndoNewLayer::Undo()
1345 DBG_ASSERT(!bItsMine
,"SdrUndoNewLayer::Undo(): Layer gehoert bereits der UndoAction");
1348 SdrLayer
* pCmpLayer
=
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");
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");
1372 pLayerAdmin
->InsertLayer(pLayer
,nNum
);
1375 void SdrUndoDelLayer::Redo()
1377 DBG_ASSERT(!bItsMine
,"SdrUndoDelLayer::Undo(): Layer gehoert bereits der UndoAction");
1380 SdrLayer
* pCmpLayer
=
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()
1396 SdrLayer
* pCmpLayer
=
1398 pLayerAdmin
->RemoveLayer(nNeuPos
);
1399 DBG_ASSERT(pCmpLayer
==pLayer
,"SdrUndoMoveLayer::Undo(): Removter Layer ist != pLayer");
1400 pLayerAdmin
->InsertLayer(pLayer
,nNum
);
1403 void SdrUndoMoveLayer::Redo()
1406 SdrLayer
* pCmpLayer
=
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()),
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
);
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
);
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
);
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
),
1487 nPageNum
=rNewPg
.GetPageNum();
1490 SdrUndoPageList::~SdrUndoPageList()
1498 ////////////////////////////////////////////////////////////////////////////////////////////////////
1500 SdrUndoDelPage::SdrUndoDelPage(SdrPage
& rNewPg
):
1501 SdrUndoPageList(rNewPg
),
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
)
1523 pUndoGroup
= new SdrUndoGroup(rMod
);
1526 pUndoGroup
->AddAction(rMod
.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage
));
1533 SdrUndoDelPage::~SdrUndoDelPage()
1535 if (pUndoGroup
!=NULL
) {
1540 void SdrUndoDelPage::Undo()
1542 ImpInsertPage(nPageNum
);
1543 if (pUndoGroup
!=NULL
) { // MasterPage-Beziehungen wiederherstellen
1546 DBG_ASSERT(bItsMine
,"UndoDeletePage: mrPage gehoert nicht der UndoAction");
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");
1558 XubString
SdrUndoDelPage::GetComment() const
1561 ImpTakeDescriptionStr(STR_UndoDelPage
,aStr
,0,FALSE
);
1565 XubString
SdrUndoDelPage::GetSdrRepeatComment(SdrView
& /*rView*/) const
1568 ImpTakeDescriptionStr(STR_UndoDelPage
,aStr
,0,FALSE
);
1572 void SdrUndoDelPage::SdrRepeat(SdrView
& /*rView*/)
1576 bool SdrUndoDelPage::CanSdrRepeat(SdrView
& /*rView*/) const
1581 ////////////////////////////////////////////////////////////////////////////////////////////////////
1583 void SdrUndoNewPage::Undo()
1585 ImpRemovePage(nPageNum
);
1586 DBG_ASSERT(!bItsMine
,"UndoNewPage: mrPage gehoert bereits der UndoAction");
1590 void SdrUndoNewPage::Redo()
1592 ImpInsertPage(nPageNum
);
1593 DBG_ASSERT(bItsMine
,"RedoNewPage: mrPage gehoert nicht der UndoAction");
1597 XubString
SdrUndoNewPage::GetComment() const
1600 ImpTakeDescriptionStr(STR_UndoNewPage
,aStr
,0,FALSE
);
1604 ////////////////////////////////////////////////////////////////////////////////////////////////////
1606 XubString
SdrUndoCopyPage::GetComment() const
1609 ImpTakeDescriptionStr(STR_UndoCopPage
,aStr
,0,FALSE
);
1613 XubString
SdrUndoCopyPage::GetSdrRepeatComment(SdrView
& /*rView*/) const
1616 ImpTakeDescriptionStr(STR_UndoCopPage
,aStr
,0,FALSE
);
1620 void SdrUndoCopyPage::SdrRepeat(SdrView
& /*rView*/)
1625 bool SdrUndoCopyPage::CanSdrRepeat(SdrView
& /*rView*/) const
1630 ////////////////////////////////////////////////////////////////////////////////////////////////////
1632 void SdrUndoSetPageNum::Undo()
1634 ImpMovePage(nNewPageNum
,nOldPageNum
);
1637 void SdrUndoSetPageNum::Redo()
1639 ImpMovePage(nOldPageNum
,nNewPageNum
);
1642 XubString
SdrUndoSetPageNum::GetComment() const
1645 ImpTakeDescriptionStr(STR_UndoMovPage
,aStr
,0,FALSE
);
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
1701 ImpTakeDescriptionStr(STR_UndoDelPageMasterDscr
,aStr
,0,FALSE
);
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
1746 ImpTakeDescriptionStr(STR_UndoChgPageMasterDscr
,aStr
,0,FALSE
);
1750 ///////////////////////////////////////////////////////////////////////
1751 SdrUndoFactory::~SdrUndoFactory(){}
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
,
1823 return new SdrUndoObjStrAttr( rObject
, eObjStrAttrType
, sOldStr
, sNewStr
);
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
);
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
);
1864 SdrUndoAction
* SdrUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage
& rChangedPage
)
1866 return new SdrUndoPageRemoveMasterPage( rChangedPage
);
1869 SdrUndoAction
* SdrUndoFactory::CreateUndoPageChangeMasterPage(SdrPage
& rChangedPage
)
1871 return new SdrUndoPageChangeMasterPage(rChangedPage
);