1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/drawing/FillStyle.hpp>
22 #include <svx/svdundo.hxx>
23 #include <svx/svdotext.hxx>
24 #include <svx/svdobj.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/svdlayer.hxx>
27 #include <svx/svdmodel.hxx>
28 #include <svx/svdview.hxx>
29 #include <svx/xbtmpit.hxx>
30 #include <svx/xfillit0.hxx>
31 #include <svx/strings.hrc>
32 #include <svx/dialmgr.hxx>
33 #include <svx/scene3d.hxx>
34 #include <editeng/outlobj.hxx>
35 #include <svx/svdogrp.hxx>
36 #include <sdr/properties/itemsettools.hxx>
37 #include <svx/sdr/properties/properties.hxx>
38 #include <svx/svdocapt.hxx>
39 #include <svl/whiter.hxx>
40 #include <svx/e3dsceneupdater.hxx>
41 #include <svx/svdviter.hxx>
42 #include <svx/svdotable.hxx> // #i124389#
44 #include <vcl/svapp.hxx>
45 #include <sfx2/viewsh.hxx>
46 #include <svx/svdoashp.hxx>
47 #include <sal/log.hxx>
48 #include <osl/diagnose.h>
49 #include <svx/diagram/datamodel.hxx>
50 #include <svx/diagram/IDiagramHelper.hxx>
53 // iterates over all views and unmarks this SdrObject if it is marked
54 static void ImplUnmarkObject( SdrObject
* pObj
)
56 SdrViewIter
aIter( pObj
);
57 for ( SdrView
* pView
= aIter
.FirstView(); pView
; pView
= aIter
.NextView() )
59 pView
->MarkObj( pObj
, pView
->GetSdrPageView(), true );
63 SdrUndoAction::SdrUndoAction(SdrModel
& rNewMod
)
64 : rMod(rNewMod
), m_nViewShellId(-1)
66 if (SfxViewShell
* pViewShell
= SfxViewShell::Current())
67 m_nViewShellId
= pViewShell
->GetViewShellId();
70 SdrUndoAction::~SdrUndoAction() {}
72 bool SdrUndoAction::CanRepeat(SfxRepeatTarget
& rView
) const
74 SdrView
* pV
=dynamic_cast<SdrView
*>( &rView
);
75 if (pV
!=nullptr) return CanSdrRepeat(*pV
);
79 void SdrUndoAction::Repeat(SfxRepeatTarget
& rView
)
81 SdrView
* pV
=dynamic_cast<SdrView
*>( &rView
);
82 if (pV
!=nullptr) SdrRepeat(*pV
);
83 DBG_ASSERT(pV
!=nullptr,"Repeat: SfxRepeatTarget that was handed over is not a SdrView");
86 OUString
SdrUndoAction::GetRepeatComment(SfxRepeatTarget
& rView
) const
88 SdrView
* pV
=dynamic_cast<SdrView
*>( &rView
);
89 if (pV
!=nullptr) return GetSdrRepeatComment();
93 bool SdrUndoAction::CanSdrRepeat(SdrView
& /*rView*/) const
98 void SdrUndoAction::SdrRepeat(SdrView
& /*rView*/)
102 OUString
SdrUndoAction::GetSdrRepeatComment() const
107 ViewShellId
SdrUndoAction::GetViewShellId() const
109 return m_nViewShellId
;
112 SdrUndoGroup::SdrUndoGroup(SdrModel
& rNewMod
)
113 : SdrUndoAction(rNewMod
),
114 eFunction(SdrRepeatFunc::NONE
)
117 SdrUndoGroup::~SdrUndoGroup()
121 void SdrUndoGroup::AddAction(std::unique_ptr
<SdrUndoAction
> pAct
)
123 maActions
.push_back(std::move(pAct
));
126 void SdrUndoGroup::Undo()
128 for (auto it
= maActions
.rbegin(); it
!= maActions
.rend(); ++it
)
132 void SdrUndoGroup::Redo()
134 for (std::unique_ptr
<SdrUndoAction
> & pAction
: maActions
)
138 OUString
SdrUndoGroup::GetComment() const
140 return aComment
.replaceAll("%1", aObjDescription
);
143 bool SdrUndoGroup::CanSdrRepeat(SdrView
& rView
) const
147 case SdrRepeatFunc::NONE
: return false;
148 case SdrRepeatFunc::Delete
: return rView
.AreObjectsMarked();
149 case SdrRepeatFunc::CombinePolyPoly
: return rView
.IsCombinePossible();
150 case SdrRepeatFunc::CombineOnePoly
: return rView
.IsCombinePossible(true);
151 case SdrRepeatFunc::DismantlePolys
: return rView
.IsDismantlePossible();
152 case SdrRepeatFunc::DismantleLines
: return rView
.IsDismantlePossible(true);
153 case SdrRepeatFunc::ConvertToPoly
: return rView
.IsConvertToPolyObjPossible();
154 case SdrRepeatFunc::ConvertToPath
: return rView
.IsConvertToPathObjPossible();
155 case SdrRepeatFunc::Group
: return rView
.IsGroupPossible();
156 case SdrRepeatFunc::Ungroup
: return rView
.IsUnGroupPossible();
157 case SdrRepeatFunc::PutToTop
: return rView
.IsToTopPossible();
158 case SdrRepeatFunc::PutToBottom
: return rView
.IsToBtmPossible();
159 case SdrRepeatFunc::MoveToTop
: return rView
.IsToTopPossible();
160 case SdrRepeatFunc::MoveToBottom
: return rView
.IsToBtmPossible();
161 case SdrRepeatFunc::ReverseOrder
: return rView
.IsReverseOrderPossible();
162 case SdrRepeatFunc::ImportMtf
: return rView
.IsImportMtfPossible();
168 void SdrUndoGroup::SdrRepeat(SdrView
& rView
)
172 case SdrRepeatFunc::NONE
: break;
173 case SdrRepeatFunc::Delete
: rView
.DeleteMarked(); break;
174 case SdrRepeatFunc::CombinePolyPoly
: rView
.CombineMarkedObjects(false); break;
175 case SdrRepeatFunc::CombineOnePoly
: rView
.CombineMarkedObjects(); break;
176 case SdrRepeatFunc::DismantlePolys
: rView
.DismantleMarkedObjects(); break;
177 case SdrRepeatFunc::DismantleLines
: rView
.DismantleMarkedObjects(true); break;
178 case SdrRepeatFunc::ConvertToPoly
: rView
.ConvertMarkedToPolyObj(); break;
179 case SdrRepeatFunc::ConvertToPath
: rView
.ConvertMarkedToPathObj(false); break;
180 case SdrRepeatFunc::Group
: rView
.GroupMarked(); break;
181 case SdrRepeatFunc::Ungroup
: rView
.UnGroupMarked(); break;
182 case SdrRepeatFunc::PutToTop
: rView
.PutMarkedToTop(); break;
183 case SdrRepeatFunc::PutToBottom
: rView
.PutMarkedToBtm(); break;
184 case SdrRepeatFunc::MoveToTop
: rView
.MovMarkedToTop(); break;
185 case SdrRepeatFunc::MoveToBottom
: rView
.MovMarkedToBtm(); break;
186 case SdrRepeatFunc::ReverseOrder
: rView
.ReverseOrderOfMarked(); break;
187 case SdrRepeatFunc::ImportMtf
: rView
.DoImportMarkedMtf(); break;
192 OUString
SdrUndoGroup::GetSdrRepeatComment() const
194 return aComment
.replaceAll("%1", SvxResId(STR_ObjNameSingulPlural
));
197 SdrUndoObj::SdrUndoObj(SdrObject
& rNewObj
)
198 : SdrUndoAction(rNewObj
.getSdrModelFromSdrObject())
203 SdrUndoObj::~SdrUndoObj() {}
205 OUString
SdrUndoObj::GetDescriptionStringForObject( const SdrObject
& _rForObject
, TranslateId pStrCacheID
, bool bRepeat
)
207 const OUString rStr
{SvxResId(pStrCacheID
)};
209 const sal_Int32 nPos
= rStr
.indexOf("%1");
214 return rStr
.replaceAt(nPos
, 2, SvxResId(STR_ObjNameSingulPlural
));
216 return rStr
.replaceAt(nPos
, 2, _rForObject
.TakeObjNameSingul());
219 OUString
SdrUndoObj::ImpGetDescriptionStr(TranslateId pStrCacheID
, bool bRepeat
) const
222 return GetDescriptionStringForObject( *mxObj
, pStrCacheID
, bRepeat
);
226 // common call method for possible change of the page when UNDO/REDO is triggered
227 void SdrUndoObj::ImpShowPageOfThisObject()
229 if(mxObj
&& mxObj
->IsInserted() && mxObj
->getSdrPageFromSdrObject())
231 SdrHint
aHint(SdrHintKind::SwitchToPage
, *mxObj
, mxObj
->getSdrPageFromSdrObject());
232 mxObj
->getSdrModelFromSdrObject().Broadcast(aHint
);
236 void SdrUndoAttrObj::ensureStyleSheetInStyleSheetPool(SfxStyleSheetBasePool
& rStyleSheetPool
, SfxStyleSheet
& rSheet
)
238 SfxStyleSheetBase
* pThere
= rStyleSheetPool
.Find(rSheet
.GetName(), rSheet
.GetFamily());
242 // re-insert remembered style which was removed in the meantime. To do this
243 // without assertion, do it without parent and set parent after insertion
244 const OUString
aParent(rSheet
.GetParent());
246 rSheet
.SetParent(OUString());
247 rStyleSheetPool
.Insert(&rSheet
);
248 rSheet
.SetParent(aParent
);
252 SdrUndoAttrObj::SdrUndoAttrObj(SdrObject
& rNewObj
, bool bStyleSheet1
, bool bSaveText
)
253 : SdrUndoObj(rNewObj
)
254 , bHaveToTakeRedoSet(true)
256 bStyleSheet
= bStyleSheet1
;
258 SdrObjList
* pOL
= rNewObj
.GetSubList();
259 bool bIsGroup(pOL
!=nullptr && pOL
->GetObjCount());
260 bool bIs3DScene(bIsGroup
&& DynCastE3dScene(mxObj
.get()));
264 // it's a group object!
265 pUndoGroup
.reset(new SdrUndoGroup(mxObj
->getSdrModelFromSdrObject()));
266 const size_t nObjCount(pOL
->GetObjCount());
268 for(size_t nObjNum
= 0; nObjNum
< nObjCount
; ++nObjNum
)
270 pUndoGroup
->AddAction(
271 std::make_unique
<SdrUndoAttrObj
>(*pOL
->GetObj(nObjNum
), bStyleSheet1
));
275 if(bIsGroup
&& !bIs3DScene
)
278 moUndoSet
.emplace( mxObj
->GetMergedItemSet() );
281 mxUndoStyleSheet
= mxObj
->GetStyleSheet();
285 auto p
= mxObj
->GetOutlinerParaObject();
291 SdrUndoAttrObj::~SdrUndoAttrObj()
300 void SdrUndoAttrObj::Undo()
302 E3DModifySceneSnapRectUpdater
aUpdater(mxObj
.get());
303 bool bIs3DScene(DynCastE3dScene(mxObj
.get()));
305 // Trigger PageChangeCall
306 ImpShowPageOfThisObject();
308 if(!pUndoGroup
|| bIs3DScene
)
310 if(bHaveToTakeRedoSet
)
312 bHaveToTakeRedoSet
= false;
314 moRedoSet
.emplace( mxObj
->GetMergedItemSet() );
317 mxRedoStyleSheet
= mxObj
->GetStyleSheet();
322 auto p
= mxObj
->GetOutlinerParaObject();
330 mxRedoStyleSheet
= mxObj
->GetStyleSheet();
331 SfxStyleSheet
* pSheet
= dynamic_cast< SfxStyleSheet
* >(mxUndoStyleSheet
.get());
333 if(pSheet
&& mxObj
->getSdrModelFromSdrObject().GetStyleSheetPool())
335 ensureStyleSheetInStyleSheetPool(*mxObj
->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet
);
336 mxObj
->SetStyleSheet(pSheet
, true);
340 OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)");
344 sdr::properties::ItemChangeBroadcaster
aItemChange(*mxObj
);
346 // Since ClearItem sets back everything to normal
347 // it also sets fit-to-size text to non-fit-to-size text and
348 // switches on autogrowheight (the default). That may lead to
349 // losing the geometry size info for the object when it is
350 // laid out again from AdjustTextFrameWidthAndHeight(). This makes
351 // rescuing the size of the object necessary.
352 const tools::Rectangle aSnapRect
= mxObj
->GetSnapRect();
353 // SdrObjCustomShape::NbcSetSnapRect needs logic instead of snap rect
354 const tools::Rectangle aLogicRect
= mxObj
->GetLogicRect();
358 if(dynamic_cast<const SdrCaptionObj
*>( mxObj
.get() ) != nullptr)
360 // do a more smooth item deletion here, else the text
361 // rect will be reformatted, especially when information regarding
362 // vertical text is changed. When clearing only set items it's
363 // slower, but safer regarding such information (it's not changed
365 SfxWhichIter
aIter(*moUndoSet
);
366 sal_uInt16
nWhich(aIter
.FirstWhich());
370 if(SfxItemState::SET
!= aIter
.GetItemState(false))
372 mxObj
->ClearMergedItem(nWhich
);
375 nWhich
= aIter
.NextWhich();
380 mxObj
->ClearMergedItem();
383 mxObj
->SetMergedItemSet(*moUndoSet
);
386 // Restore previous size here when it was changed.
387 if(aSnapRect
!= mxObj
->GetSnapRect())
389 if(dynamic_cast<const SdrObjCustomShape
*>(mxObj
.get()))
390 mxObj
->NbcSetSnapRect(aLogicRect
);
392 mxObj
->NbcSetSnapRect(aSnapRect
);
395 mxObj
->GetProperties().BroadcastItemChange(aItemChange
);
399 mxObj
->SetOutlinerParaObject(*pTextUndo
);
409 void SdrUndoAttrObj::Redo()
411 E3DModifySceneSnapRectUpdater
aUpdater(mxObj
.get());
412 bool bIs3DScene(DynCastE3dScene(mxObj
.get()));
414 if(!pUndoGroup
|| bIs3DScene
)
418 mxUndoStyleSheet
= mxObj
->GetStyleSheet();
419 SfxStyleSheet
* pSheet
= dynamic_cast< SfxStyleSheet
* >(mxRedoStyleSheet
.get());
421 if(pSheet
&& mxObj
->getSdrModelFromSdrObject().GetStyleSheetPool())
423 ensureStyleSheetInStyleSheetPool(*mxObj
->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet
);
424 mxObj
->SetStyleSheet(pSheet
, true);
428 OSL_ENSURE(false, "OOps, something went wrong in SdrUndoAttrObj (!)");
432 sdr::properties::ItemChangeBroadcaster
aItemChange(*mxObj
);
434 const tools::Rectangle aSnapRect
= mxObj
->GetSnapRect();
435 const tools::Rectangle aLogicRect
= mxObj
->GetLogicRect();
439 if(dynamic_cast<const SdrCaptionObj
*>( mxObj
.get() ) != nullptr)
441 // do a more smooth item deletion here, else the text
442 // rect will be reformatted, especially when information regarding
443 // vertical text is changed. When clearing only set items it's
444 // slower, but safer regarding such information (it's not changed
446 SfxWhichIter
aIter(*moRedoSet
);
447 sal_uInt16
nWhich(aIter
.FirstWhich());
451 if(SfxItemState::SET
!= aIter
.GetItemState(false))
453 mxObj
->ClearMergedItem(nWhich
);
456 nWhich
= aIter
.NextWhich();
461 mxObj
->ClearMergedItem();
464 mxObj
->SetMergedItemSet(*moRedoSet
);
467 // Restore previous size here when it was changed.
468 if(aSnapRect
!= mxObj
->GetSnapRect())
470 if(dynamic_cast<const SdrObjCustomShape
*>(mxObj
.get()))
471 mxObj
->NbcSetSnapRect(aLogicRect
);
473 mxObj
->NbcSetSnapRect(aSnapRect
);
476 mxObj
->GetProperties().BroadcastItemChange(aItemChange
);
481 mxObj
->SetOutlinerParaObject(*pTextRedo
);
490 // Trigger PageChangeCall
491 ImpShowPageOfThisObject();
494 OUString
SdrUndoAttrObj::GetComment() const
498 return ImpGetDescriptionStr(STR_EditSetStylesheet
);
502 return ImpGetDescriptionStr(STR_EditSetAttributes
);
506 OUString
SdrUndoAttrObj::GetSdrRepeatComment() const
510 return ImpGetDescriptionStr(STR_EditSetStylesheet
, true);
514 return ImpGetDescriptionStr(STR_EditSetAttributes
, true);
519 SdrUndoMoveObj::~SdrUndoMoveObj() {}
521 void SdrUndoMoveObj::Undo()
523 // Trigger PageChangeCall
524 ImpShowPageOfThisObject();
526 mxObj
->Move(Size(-aDistance
.Width(),-aDistance
.Height()));
529 void SdrUndoMoveObj::Redo()
531 mxObj
->Move(Size(aDistance
.Width(),aDistance
.Height()));
533 // Trigger PageChangeCall
534 ImpShowPageOfThisObject();
537 OUString
SdrUndoMoveObj::GetComment() const
539 return ImpGetDescriptionStr(STR_EditMove
);
542 void SdrUndoMoveObj::SdrRepeat(SdrView
& rView
)
544 rView
.MoveMarkedObj(aDistance
);
547 bool SdrUndoMoveObj::CanSdrRepeat(SdrView
& rView
) const
549 return rView
.AreObjectsMarked();
552 OUString
SdrUndoMoveObj::GetSdrRepeatComment() const
554 return ImpGetDescriptionStr(STR_EditMove
,true);
558 SdrUndoGeoObj::SdrUndoGeoObj(SdrObject
& rNewObj
)
559 : SdrUndoObj(rNewObj
)
560 , mbSkipChangeLayout(false)
562 SdrObjList
* pOL
=rNewObj
.GetSubList();
563 if (pOL
!=nullptr && pOL
->GetObjCount() && !DynCastE3dScene(&rNewObj
))
565 // this is a group object!
566 // If this were 3D scene, we'd only add an Undo for the scene itself
567 // (which we do elsewhere).
568 pUndoGroup
.reset(new SdrUndoGroup(mxObj
->getSdrModelFromSdrObject()));
569 const size_t nObjCount
= pOL
->GetObjCount();
570 for (size_t nObjNum
= 0; nObjNum
<nObjCount
; ++nObjNum
) {
571 pUndoGroup
->AddAction(std::make_unique
<SdrUndoGeoObj
>(*pOL
->GetObj(nObjNum
)));
576 pUndoGeo
= mxObj
->GetGeoData();
580 SdrUndoGeoObj::~SdrUndoGeoObj()
587 void SdrUndoGeoObj::Undo()
589 // Trigger PageChangeCall
590 ImpShowPageOfThisObject();
596 // only repaint, no objectchange
597 mxObj
->ActionChanged();
601 pRedoGeo
= mxObj
->GetGeoData();
603 auto pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(mxObj
.get());
604 if (pTableObj
&& mbSkipChangeLayout
)
605 pTableObj
->SetSkipChangeLayout(true);
606 mxObj
->SetGeoData(*pUndoGeo
);
607 if (pTableObj
&& mbSkipChangeLayout
)
608 pTableObj
->SetSkipChangeLayout(false);
612 void SdrUndoGeoObj::Redo()
618 // only repaint, no objectchange
619 mxObj
->ActionChanged();
623 pUndoGeo
= mxObj
->GetGeoData();
624 mxObj
->SetGeoData(*pRedoGeo
);
627 // Trigger PageChangeCall
628 ImpShowPageOfThisObject();
631 OUString
SdrUndoGeoObj::GetComment() const
633 return ImpGetDescriptionStr(STR_DragMethObjOwn
);
636 SdrUndoDiagramModelData::SdrUndoDiagramModelData(SdrObject
& rNewObj
, svx::diagram::DiagramDataStatePtr
& rStartState
)
637 : SdrUndoObj(rNewObj
)
638 , m_aStartState(rStartState
)
641 if(rNewObj
.isDiagram())
642 m_aEndState
= rNewObj
.getDiagramHelper()->extractDiagramDataState();
645 SdrUndoDiagramModelData::~SdrUndoDiagramModelData()
649 void SdrUndoDiagramModelData::implUndoRedo(bool bUndo
)
654 if(!mxObj
->isDiagram())
657 mxObj
->getDiagramHelper()->applyDiagramDataState(
658 bUndo
? m_aStartState
: m_aEndState
);
659 mxObj
->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup
*>(mxObj
.get()));
662 void SdrUndoDiagramModelData::Undo()
667 void SdrUndoDiagramModelData::Redo()
672 OUString
SdrUndoDiagramModelData::GetComment() const
674 return ImpGetDescriptionStr(STR_DiagramModelDataChange
);
677 SdrUndoObjList::SdrUndoObjList(SdrObject
& rNewObj
, bool bOrdNumDirect
)
678 : SdrUndoObj(rNewObj
)
680 pObjList
=mxObj
->getParentSdrObjListFromSdrObject();
683 nOrdNum
=mxObj
->GetOrdNumDirect();
687 nOrdNum
=mxObj
->GetOrdNum();
691 SdrUndoObjList::~SdrUndoObjList()
695 void SdrUndoRemoveObj::Undo()
697 // Trigger PageChangeCall
698 ImpShowPageOfThisObject();
700 DBG_ASSERT(!mxObj
->IsInserted(),"UndoRemoveObj: mxObj has already been inserted.");
701 if (mxObj
->IsInserted())
705 // For UNDOs in Calc/Writer it is necessary to adapt the anchor
706 // position of the target object.
707 Point
aOwnerAnchorPos(0, 0);
709 if (dynamic_cast< const SdrObjGroup
* >(pObjList
->getSdrObjectFromSdrObjList()) != nullptr)
711 aOwnerAnchorPos
= pObjList
->getSdrObjectFromSdrObjList()->GetAnchorPos();
714 E3DModifySceneSnapRectUpdater
aUpdater(pObjList
->getSdrObjectFromSdrObjList());
715 pObjList
->InsertObject(mxObj
.get(), nOrdNum
);
718 if(aOwnerAnchorPos
.X() || aOwnerAnchorPos
.Y())
720 mxObj
->NbcSetAnchorPos(aOwnerAnchorPos
);
724 void SdrUndoRemoveObj::Redo()
726 DBG_ASSERT(mxObj
->IsInserted(),"RedoRemoveObj: mxObj is not inserted.");
727 if (mxObj
->IsInserted())
729 ImplUnmarkObject( mxObj
.get() );
730 E3DModifySceneSnapRectUpdater
aUpdater(mxObj
.get());
731 pObjList
->RemoveObject(mxObj
->GetOrdNum());
734 // Trigger PageChangeCall
735 ImpShowPageOfThisObject();
738 SdrUndoRemoveObj::~SdrUndoRemoveObj()
743 void SdrUndoInsertObj::Undo()
745 // Trigger PageChangeCall
746 ImpShowPageOfThisObject();
748 DBG_ASSERT(mxObj
->IsInserted(),"UndoInsertObj: mxObj is not inserted.");
749 if (mxObj
->IsInserted())
751 ImplUnmarkObject( mxObj
.get() );
753 rtl::Reference
<SdrObject
> pChkObj
= pObjList
->RemoveObject(mxObj
->GetOrdNum());
754 DBG_ASSERT(pChkObj
.get()==mxObj
.get(),"UndoInsertObj: RemoveObjNum!=mxObj");
758 void SdrUndoInsertObj::Redo()
760 DBG_ASSERT(!mxObj
->IsInserted(),"RedoInsertObj: mxObj is already inserted");
761 if (!mxObj
->IsInserted())
763 // Restore anchor position of an object,
764 // which becomes a member of a group, because its cleared in method
765 // <InsertObject(..)>. Needed for correct Redo in Writer. (#i45952#)
766 Point
aAnchorPos( 0, 0 );
768 if (dynamic_cast<const SdrObjGroup
*>(pObjList
->getSdrObjectFromSdrObjList()) != nullptr)
770 aAnchorPos
= mxObj
->GetAnchorPos();
773 pObjList
->InsertObject(mxObj
.get(), nOrdNum
);
775 // Arcs lose position when grouped (#i45952#)
776 if ( aAnchorPos
.X() || aAnchorPos
.Y() )
778 mxObj
->NbcSetAnchorPos( aAnchorPos
);
782 // Trigger PageChangeCall
783 ImpShowPageOfThisObject();
786 SdrUndoDelObj::SdrUndoDelObj(SdrObject
& rNewObj
, bool bOrdNumDirect
)
787 : SdrUndoRemoveObj(rNewObj
,bOrdNumDirect
)
791 void SdrUndoDelObj::Undo()
793 SdrUndoRemoveObj::Undo();
796 void SdrUndoDelObj::Redo()
798 SdrUndoRemoveObj::Redo();
801 OUString
SdrUndoDelObj::GetComment() const
803 return ImpGetDescriptionStr(STR_EditDelete
);
806 void SdrUndoDelObj::SdrRepeat(SdrView
& rView
)
808 rView
.DeleteMarked();
811 bool SdrUndoDelObj::CanSdrRepeat(SdrView
& rView
) const
813 return rView
.AreObjectsMarked();
816 OUString
SdrUndoDelObj::GetSdrRepeatComment() const
818 return ImpGetDescriptionStr(STR_EditDelete
,true);
822 void SdrUndoNewObj::Undo()
824 SdrUndoInsertObj::Undo();
827 void SdrUndoNewObj::Redo()
829 SdrUndoInsertObj::Redo();
832 OUString
SdrUndoNewObj::GetComment( const SdrObject
& _rForObject
)
834 return GetDescriptionStringForObject( _rForObject
, STR_UndoInsertObj
);
837 OUString
SdrUndoNewObj::GetComment() const
839 return ImpGetDescriptionStr(STR_UndoInsertObj
);
842 SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject
& rOldObj1
, SdrObject
& rNewObj1
)
843 : SdrUndoObj(rOldObj1
)
844 , mxNewObj(&rNewObj1
)
846 pObjList
=mxObj
->getParentSdrObjListFromSdrObject();
849 SdrUndoReplaceObj::~SdrUndoReplaceObj()
853 void SdrUndoReplaceObj::Undo()
855 // Trigger PageChangeCall
856 ImpShowPageOfThisObject();
858 DBG_ASSERT(!mxObj
->IsInserted(),"SdrUndoReplaceObj::Undo(): Old object is already inserted!");
859 DBG_ASSERT(mxNewObj
->IsInserted(),"SdrUndoReplaceObj::Undo(): New object is not inserted!");
861 ImplUnmarkObject( mxNewObj
.get() );
862 pObjList
->ReplaceObject(mxObj
.get(), mxNewObj
->GetOrdNum());
865 void SdrUndoReplaceObj::Redo()
867 ImplUnmarkObject( mxObj
.get() );
868 pObjList
->ReplaceObject(mxNewObj
.get(), mxObj
->GetOrdNum());
870 // Trigger PageChangeCall
871 ImpShowPageOfThisObject();
875 OUString
SdrUndoCopyObj::GetComment() const
877 return ImpGetDescriptionStr(STR_UndoCopyObj
);
883 SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject
& rObj
, SdrLayerID aOldLayer
, SdrLayerID aNewLayer
)
885 , maOldLayer(aOldLayer
)
886 , maNewLayer(aNewLayer
)
890 void SdrUndoObjectLayerChange::Undo()
892 ImpShowPageOfThisObject();
893 mxObj
->SetLayer(maOldLayer
);
896 void SdrUndoObjectLayerChange::Redo()
898 mxObj
->SetLayer(maNewLayer
);
899 ImpShowPageOfThisObject();
903 SdrUndoObjOrdNum::SdrUndoObjOrdNum(SdrObject
& rNewObj
, sal_uInt32 nOldOrdNum1
, sal_uInt32 nNewOrdNum1
)
904 : SdrUndoObj(rNewObj
)
905 , nOldOrdNum(nOldOrdNum1
)
906 , nNewOrdNum(nNewOrdNum1
)
910 void SdrUndoObjOrdNum::Undo()
912 // Trigger PageChangeCall
913 ImpShowPageOfThisObject();
915 SdrObjList
* pOL
=mxObj
->getParentSdrObjListFromSdrObject();
918 OSL_FAIL("UndoObjOrdNum: mxObj does not have an ObjList.");
921 pOL
->SetObjectOrdNum(nNewOrdNum
,nOldOrdNum
);
924 void SdrUndoObjOrdNum::Redo()
926 SdrObjList
* pOL
=mxObj
->getParentSdrObjListFromSdrObject();
929 OSL_FAIL("RedoObjOrdNum: mxObj does not have an ObjList.");
932 pOL
->SetObjectOrdNum(nOldOrdNum
,nNewOrdNum
);
934 // Trigger PageChangeCall
935 ImpShowPageOfThisObject();
938 OUString
SdrUndoObjOrdNum::GetComment() const
940 return ImpGetDescriptionStr(STR_UndoObjOrdNum
);
943 SdrUndoSort::SdrUndoSort(const SdrPage
& rPage
,
944 ::std::vector
<sal_Int32
> const& rSortOrder
)
945 : SdrUndoAction(rPage
.getSdrModelFromSdrPage())
946 , m_OldSortOrder(rSortOrder
.size())
947 , m_NewSortOrder(rSortOrder
)
948 , m_nPage(rPage
.GetPageNum())
951 for (size_t i
= 0; i
< rSortOrder
.size(); ++i
)
953 m_OldSortOrder
[rSortOrder
[i
]] = i
;
957 void SdrUndoSort::Do(::std::vector
<sal_Int32
> & rSortOrder
)
959 SdrPage
& rPage(*rMod
.GetPage(m_nPage
));
960 if (rPage
.GetObjCount() != rSortOrder
.size())
962 // can probably happen with sw's cursed SdrVirtObj mess - no good solution for that
963 SAL_WARN("svx", "SdrUndoSort size mismatch");
967 // hopefully this can't throw
968 rPage
.sort(rSortOrder
);
971 void SdrUndoSort::Undo()
976 void SdrUndoSort::Redo()
981 OUString
SdrUndoSort::GetComment() const
983 return SvxResId(STR_SortShapes
);
986 SdrUndoObjSetText::SdrUndoObjSetText(SdrObject
& rNewObj
, sal_Int32 nText
)
987 : SdrUndoObj(rNewObj
)
988 , bNewTextAvailable(false)
989 , bEmptyPresObj(false)
992 SdrText
* pText
= static_cast< SdrTextObj
*>( &rNewObj
)->getText(mnText
);
993 if( pText
&& pText
->GetOutlinerParaObject() )
994 pOldText
= *pText
->GetOutlinerParaObject();
996 bEmptyPresObj
= rNewObj
.IsEmptyPresObj();
999 SdrUndoObjSetText::~SdrUndoObjSetText()
1005 bool SdrUndoObjSetText::IsDifferent() const
1007 if (!pOldText
|| !pNewText
)
1008 return pOldText
|| pNewText
;
1009 return *pOldText
!= *pNewText
;
1012 void SdrUndoObjSetText::AfterSetText()
1014 if (!bNewTextAvailable
)
1016 SdrText
* pText
= static_cast< SdrTextObj
*>( mxObj
.get() )->getText(mnText
);
1017 if( pText
&& pText
->GetOutlinerParaObject() )
1018 pNewText
= *pText
->GetOutlinerParaObject();
1019 bNewTextAvailable
=true;
1023 void SdrUndoObjSetText::Undo()
1025 // only works with SdrTextObj
1026 SdrTextObj
* pTarget
= DynCastSdrTextObj(mxObj
.get());
1030 OSL_ENSURE(false, "SdrUndoObjSetText::Undo with SdrObject not based on SdrTextObj (!)");
1034 // Trigger PageChangeCall
1035 ImpShowPageOfThisObject();
1037 // save old text for Redo
1038 if(!bNewTextAvailable
)
1043 SdrText
* pText
= pTarget
->getText(mnText
);
1046 // copy text for Undo, because the original now belongs to SetOutlinerParaObject()
1047 pTarget
->NbcSetOutlinerParaObjectForText(pOldText
, pText
);
1050 pTarget
->SetEmptyPresObj(bEmptyPresObj
);
1051 pTarget
->ActionChanged();
1053 // #i124389# if it's a table, also need to relayout TextFrame
1054 if(dynamic_cast< sdr::table::SdrTableObj
* >(pTarget
) != nullptr)
1056 pTarget
->NbcAdjustTextFrameWidthAndHeight();
1059 // #i122410# SetOutlinerParaObject at SdrText does not trigger a
1060 // BroadcastObjectChange, but it is needed to make evtl. SlideSorters
1061 // update their preview.
1062 pTarget
->BroadcastObjectChange();
1065 void SdrUndoObjSetText::Redo()
1067 // only works with SdrTextObj
1068 SdrTextObj
* pTarget
= DynCastSdrTextObj(mxObj
.get());
1072 OSL_ENSURE(false, "SdrUndoObjSetText::Redo with SdrObject not based on SdrTextObj (!)");
1076 SdrText
* pText
= pTarget
->getText(mnText
);
1079 // copy text for Undo, because the original now belongs to SetOutlinerParaObject()
1080 pTarget
->NbcSetOutlinerParaObjectForText( pNewText
, pText
);
1083 pTarget
->ActionChanged();
1085 // #i124389# if it's a table, also need to relayout TextFrame
1086 if(dynamic_cast< sdr::table::SdrTableObj
* >(pTarget
) != nullptr)
1088 pTarget
->NbcAdjustTextFrameWidthAndHeight();
1091 // #i122410# NbcSetOutlinerParaObjectForText at SdrTextObj does not trigger a
1092 // BroadcastObjectChange, but it is needed to make evtl. SlideSorters
1093 // update their preview.
1094 pTarget
->BroadcastObjectChange();
1096 // Trigger PageChangeCall
1097 ImpShowPageOfThisObject();
1100 OUString
SdrUndoObjSetText::GetComment() const
1102 return ImpGetDescriptionStr(STR_UndoObjSetText
);
1105 OUString
SdrUndoObjSetText::GetSdrRepeatComment() const
1107 return ImpGetDescriptionStr(STR_UndoObjSetText
);
1110 void SdrUndoObjSetText::SdrRepeat(SdrView
& rView
)
1112 if (!(bNewTextAvailable
&& rView
.AreObjectsMarked()))
1115 const SdrMarkList
& rML
=rView
.GetMarkedObjectList();
1117 const bool bUndo
= rView
.IsUndoEnabled();
1120 OUString aStr
= ImpGetDescriptionStr(STR_UndoObjSetText
);
1121 rView
.BegUndo(aStr
);
1124 const size_t nCount
=rML
.GetMarkCount();
1125 for (size_t nm
=0; nm
<nCount
; ++nm
)
1127 SdrObject
* pObj2
=rML
.GetMark(nm
)->GetMarkedSdrObj();
1128 SdrTextObj
* pTextObj
=DynCastSdrTextObj( pObj2
);
1129 if (pTextObj
!=nullptr)
1132 rView
.AddUndo(std::make_unique
<SdrUndoObjSetText
>(*pTextObj
,0));
1134 pTextObj
->SetOutlinerParaObject(pNewText
);
1142 bool SdrUndoObjSetText::CanSdrRepeat(SdrView
& rView
) const
1145 if (bNewTextAvailable
&& rView
.AreObjectsMarked()) {
1151 // Undo/Redo for setting object's name (#i73249#)
1152 SdrUndoObjStrAttr::SdrUndoObjStrAttr( SdrObject
& rNewObj
,
1153 const ObjStrAttrType eObjStrAttr
,
1156 : SdrUndoObj( rNewObj
)
1157 , meObjStrAttr( eObjStrAttr
)
1158 , msOldStr(std::move( sOldStr
))
1159 , msNewStr(std::move( sNewStr
))
1163 void SdrUndoObjStrAttr::Undo()
1165 ImpShowPageOfThisObject();
1167 switch ( meObjStrAttr
)
1169 case ObjStrAttrType::Name
:
1170 mxObj
->SetName( msOldStr
);
1172 case ObjStrAttrType::Title
:
1173 mxObj
->SetTitle( msOldStr
);
1175 case ObjStrAttrType::Description
:
1176 mxObj
->SetDescription( msOldStr
);
1181 void SdrUndoObjStrAttr::Redo()
1183 switch ( meObjStrAttr
)
1185 case ObjStrAttrType::Name
:
1186 mxObj
->SetName( msNewStr
);
1188 case ObjStrAttrType::Title
:
1189 mxObj
->SetTitle( msNewStr
);
1191 case ObjStrAttrType::Description
:
1192 mxObj
->SetDescription( msNewStr
);
1196 ImpShowPageOfThisObject();
1199 OUString
SdrUndoObjStrAttr::GetComment() const
1202 switch ( meObjStrAttr
)
1204 case ObjStrAttrType::Name
:
1205 aStr
= ImpGetDescriptionStr( STR_UndoObjName
) +
1206 " '" + msNewStr
+ "'";
1208 case ObjStrAttrType::Title
:
1209 aStr
= ImpGetDescriptionStr( STR_UndoObjTitle
);
1211 case ObjStrAttrType::Description
:
1212 aStr
= ImpGetDescriptionStr( STR_UndoObjDescription
);
1219 SdrUndoObjDecorative::SdrUndoObjDecorative(SdrObject
& rObj
, bool const WasDecorative
)
1221 , m_WasDecorative(WasDecorative
)
1225 void SdrUndoObjDecorative::Undo()
1227 ImpShowPageOfThisObject();
1229 mxObj
->SetDecorative(m_WasDecorative
);
1232 void SdrUndoObjDecorative::Redo()
1234 mxObj
->SetDecorative(!m_WasDecorative
);
1236 ImpShowPageOfThisObject();
1239 OUString
SdrUndoObjDecorative::GetComment() const
1241 return ImpGetDescriptionStr(STR_UndoObjDecorative
);
1245 SdrUndoLayer::SdrUndoLayer(sal_uInt16 nLayerNum
, SdrLayerAdmin
& rNewLayerAdmin
, SdrModel
& rNewModel
)
1246 : SdrUndoAction(rNewModel
)
1247 , pLayer(rNewLayerAdmin
.GetLayer(nLayerNum
))
1248 , pLayerAdmin(&rNewLayerAdmin
)
1254 SdrUndoLayer::~SdrUndoLayer()
1262 void SdrUndoNewLayer::Undo()
1264 DBG_ASSERT(!bItsMine
,"SdrUndoNewLayer::Undo(): Layer already belongs to UndoAction.");
1266 // coverity[leaked_storage] - owned by this SdrUndoNewLayer as pLayer
1267 SdrLayer
* pCmpLayer
= pLayerAdmin
->RemoveLayer(nNum
).release();
1268 assert(pCmpLayer
== pLayer
&& "SdrUndoNewLayer::Undo(): Removed layer is != pLayer."); (void)pCmpLayer
;
1271 void SdrUndoNewLayer::Redo()
1273 DBG_ASSERT(bItsMine
,"SdrUndoNewLayer::Undo(): Layer does not belong to UndoAction.");
1275 pLayerAdmin
->InsertLayer(std::unique_ptr
<SdrLayer
>(pLayer
),nNum
);
1278 OUString
SdrUndoNewLayer::GetComment() const
1280 return SvxResId(STR_UndoNewLayer
);
1284 void SdrUndoDelLayer::Undo()
1286 DBG_ASSERT(bItsMine
,"SdrUndoDelLayer::Undo(): Layer does not belong to UndoAction.");
1288 pLayerAdmin
->InsertLayer(std::unique_ptr
<SdrLayer
>(pLayer
),nNum
);
1291 void SdrUndoDelLayer::Redo()
1293 DBG_ASSERT(!bItsMine
,"SdrUndoDelLayer::Undo(): Layer already belongs to UndoAction.");
1295 // coverity[leaked_storage] - owned by this SdrUndoNewLayer as pLayer
1296 SdrLayer
* pCmpLayer
= pLayerAdmin
->RemoveLayer(nNum
).release();
1297 assert(pCmpLayer
== pLayer
&& "SdrUndoDelLayer::Redo(): Removed layer is != pLayer."); (void)pCmpLayer
;
1300 OUString
SdrUndoDelLayer::GetComment() const
1302 return SvxResId(STR_UndoDelLayer
);
1306 SdrUndoPage::SdrUndoPage(SdrPage
& rNewPg
)
1307 : SdrUndoAction(rNewPg
.getSdrModelFromSdrPage())
1312 SdrUndoPage::~SdrUndoPage() {}
1314 void SdrUndoPage::ImpInsertPage(sal_uInt16 nNum
)
1316 DBG_ASSERT(!mxPage
->IsInserted(),"SdrUndoPage::ImpInsertPage(): mxPage is already inserted.");
1317 if (!mxPage
->IsInserted())
1319 if (mxPage
->IsMasterPage())
1321 rMod
.InsertMasterPage(mxPage
.get(), nNum
);
1325 rMod
.InsertPage(mxPage
.get(), nNum
);
1330 void SdrUndoPage::ImpRemovePage(sal_uInt16 nNum
)
1332 DBG_ASSERT(mxPage
->IsInserted(),"SdrUndoPage::ImpRemovePage(): mxPage is not inserted.");
1333 if (!mxPage
->IsInserted())
1336 rtl::Reference
<SdrPage
> pChkPg
;
1337 if (mxPage
->IsMasterPage())
1339 pChkPg
= rMod
.RemoveMasterPage(nNum
);
1343 pChkPg
= rMod
.RemovePage(nNum
);
1345 DBG_ASSERT(pChkPg
==mxPage
,"SdrUndoPage::ImpRemovePage(): RemovePage!=mxPage");
1348 void SdrUndoPage::ImpMovePage(sal_uInt16 nOldNum
, sal_uInt16 nNewNum
)
1350 DBG_ASSERT(mxPage
->IsInserted(),"SdrUndoPage::ImpMovePage(): mxPage is not inserted.");
1351 if (mxPage
->IsInserted())
1353 if (mxPage
->IsMasterPage())
1355 rMod
.MoveMasterPage(nOldNum
,nNewNum
);
1359 rMod
.MovePage(nOldNum
,nNewNum
);
1364 OUString
SdrUndoPage::ImpGetDescriptionStr(TranslateId pStrCacheID
)
1366 return SvxResId(pStrCacheID
);
1370 SdrUndoPageList::SdrUndoPageList(SdrPage
& rNewPg
)
1371 : SdrUndoPage(rNewPg
)
1373 nPageNum
=rNewPg
.GetPageNum();
1376 SdrUndoPageList::~SdrUndoPageList()
1381 SdrUndoDelPage::SdrUndoDelPage(SdrPage
& rNewPg
)
1382 : SdrUndoPageList(rNewPg
)
1383 , mbHasFillBitmap(false)
1385 // keep fill bitmap separately to remove it from pool if not used elsewhere
1386 if (mxPage
->IsMasterPage())
1388 SfxStyleSheet
* const pStyleSheet
= mxPage
->getSdrPageProperties().GetStyleSheet();
1390 queryFillBitmap(pStyleSheet
->GetItemSet());
1394 queryFillBitmap(mxPage
->getSdrPageProperties().GetItemSet());
1396 if (bool(mpFillBitmapItem
))
1399 // now remember the master page relationships
1400 if(!mxPage
->IsMasterPage())
1403 sal_uInt16
nPageCnt(rMod
.GetPageCount());
1405 for(sal_uInt16
nPageNum2(0); nPageNum2
< nPageCnt
; nPageNum2
++)
1407 SdrPage
* pDrawPage
= rMod
.GetPage(nPageNum2
);
1409 if(pDrawPage
->TRG_HasMasterPage())
1411 SdrPage
& rMasterPage
= pDrawPage
->TRG_GetMasterPage();
1413 if(mxPage
.get() == &rMasterPage
)
1417 pUndoGroup
.reset( new SdrUndoGroup(rMod
) );
1420 pUndoGroup
->AddAction(rMod
.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage
));
1426 SdrUndoDelPage::~SdrUndoDelPage()
1430 void SdrUndoDelPage::Undo()
1432 if (bool(mpFillBitmapItem
))
1433 restoreFillBitmap();
1434 ImpInsertPage(nPageNum
);
1435 if (pUndoGroup
!=nullptr)
1437 // recover master page relationships
1442 void SdrUndoDelPage::Redo()
1444 ImpRemovePage(nPageNum
);
1445 if (bool(mpFillBitmapItem
))
1449 OUString
SdrUndoDelPage::GetComment() const
1451 return ImpGetDescriptionStr(STR_UndoDelPage
);
1454 OUString
SdrUndoDelPage::GetSdrRepeatComment() const
1456 return ImpGetDescriptionStr(STR_UndoDelPage
);
1459 void SdrUndoDelPage::SdrRepeat(SdrView
& /*rView*/)
1463 bool SdrUndoDelPage::CanSdrRepeat(SdrView
& /*rView*/) const
1468 void SdrUndoDelPage::queryFillBitmap(const SfxItemSet
& rItemSet
)
1470 if (const XFillBitmapItem
*pItem
= rItemSet
.GetItemIfSet(XATTR_FILLBITMAP
, false))
1471 mpFillBitmapItem
.reset(pItem
->Clone());
1472 if (const XFillStyleItem
*pItem
= rItemSet
.GetItemIfSet(XATTR_FILLSTYLE
, false))
1473 mbHasFillBitmap
= pItem
->GetValue() == css::drawing::FillStyle_BITMAP
;
1476 void SdrUndoDelPage::clearFillBitmap()
1478 if (mxPage
->IsMasterPage())
1480 SfxStyleSheet
* const pStyleSheet
= mxPage
->getSdrPageProperties().GetStyleSheet();
1481 assert(bool(pStyleSheet
)); // who took away my stylesheet?
1482 if (pStyleSheet
->GetListenerCount() == 1)
1484 SfxItemSet
& rItemSet
= pStyleSheet
->GetItemSet();
1485 rItemSet
.ClearItem(XATTR_FILLBITMAP
);
1486 if (mbHasFillBitmap
)
1487 rItemSet
.ClearItem(XATTR_FILLSTYLE
);
1492 SdrPageProperties
&rPageProps
= mxPage
->getSdrPageProperties();
1493 rPageProps
.ClearItem(XATTR_FILLBITMAP
);
1494 if (mbHasFillBitmap
)
1495 rPageProps
.ClearItem(XATTR_FILLSTYLE
);
1499 void SdrUndoDelPage::restoreFillBitmap()
1501 if (mxPage
->IsMasterPage())
1503 SfxStyleSheet
* const pStyleSheet
= mxPage
->getSdrPageProperties().GetStyleSheet();
1504 assert(bool(pStyleSheet
)); // who took away my stylesheet?
1505 if (pStyleSheet
->GetListenerCount() == 1)
1507 SfxItemSet
& rItemSet
= pStyleSheet
->GetItemSet();
1508 rItemSet
.Put(*mpFillBitmapItem
);
1509 if (mbHasFillBitmap
)
1510 rItemSet
.Put(XFillStyleItem(css::drawing::FillStyle_BITMAP
));
1515 SdrPageProperties
&rPageProps
= mxPage
->getSdrPageProperties();
1516 rPageProps
.PutItem(*mpFillBitmapItem
);
1517 if (mbHasFillBitmap
)
1518 rPageProps
.PutItem(XFillStyleItem(css::drawing::FillStyle_BITMAP
));
1523 void SdrUndoNewPage::Undo()
1525 ImpRemovePage(nPageNum
);
1528 void SdrUndoNewPage::Redo()
1530 ImpInsertPage(nPageNum
);
1533 OUString
SdrUndoNewPage::GetComment() const
1535 return ImpGetDescriptionStr(STR_UndoNewPage
);
1539 OUString
SdrUndoCopyPage::GetComment() const
1541 return ImpGetDescriptionStr(STR_UndoCopPage
);
1544 OUString
SdrUndoCopyPage::GetSdrRepeatComment() const
1546 return ImpGetDescriptionStr(STR_UndoCopPage
);
1549 void SdrUndoCopyPage::SdrRepeat(SdrView
& /*rView*/)
1554 bool SdrUndoCopyPage::CanSdrRepeat(SdrView
& /*rView*/) const
1560 void SdrUndoSetPageNum::Undo()
1562 ImpMovePage(nNewPageNum
,nOldPageNum
);
1565 void SdrUndoSetPageNum::Redo()
1567 ImpMovePage(nOldPageNum
,nNewPageNum
);
1570 OUString
SdrUndoSetPageNum::GetComment() const
1572 return ImpGetDescriptionStr(STR_UndoMovPage
);
1575 SdrUndoPageMasterPage::SdrUndoPageMasterPage(SdrPage
& rChangedPage
)
1576 : SdrUndoPage(rChangedPage
)
1577 , mbOldHadMasterPage(mxPage
->TRG_HasMasterPage())
1578 , maOldMasterPageNumber(0)
1580 // get current state from page
1581 if(mbOldHadMasterPage
)
1583 maOldSet
= mxPage
->TRG_GetMasterPageVisibleLayers();
1584 maOldMasterPageNumber
= mxPage
->TRG_GetMasterPage().GetPageNum();
1588 SdrUndoPageMasterPage::~SdrUndoPageMasterPage()
1592 SdrUndoPageRemoveMasterPage::SdrUndoPageRemoveMasterPage(SdrPage
& rChangedPage
)
1593 : SdrUndoPageMasterPage(rChangedPage
)
1597 void SdrUndoPageRemoveMasterPage::Undo()
1599 if(mbOldHadMasterPage
)
1601 mxPage
->TRG_SetMasterPage(*mxPage
->getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber
));
1602 mxPage
->TRG_SetMasterPageVisibleLayers(maOldSet
);
1606 void SdrUndoPageRemoveMasterPage::Redo()
1608 mxPage
->TRG_ClearMasterPage();
1611 OUString
SdrUndoPageRemoveMasterPage::GetComment() const
1613 return ImpGetDescriptionStr(STR_UndoDelPageMasterDscr
);
1616 SdrUndoPageChangeMasterPage::SdrUndoPageChangeMasterPage(SdrPage
& rChangedPage
)
1617 : SdrUndoPageMasterPage(rChangedPage
)
1618 , mbNewHadMasterPage(false)
1619 , maNewMasterPageNumber(0)
1623 void SdrUndoPageChangeMasterPage::Undo()
1625 // remember values from new page
1626 if(mxPage
->TRG_HasMasterPage())
1628 mbNewHadMasterPage
= true;
1629 maNewSet
= mxPage
->TRG_GetMasterPageVisibleLayers();
1630 maNewMasterPageNumber
= mxPage
->TRG_GetMasterPage().GetPageNum();
1633 // restore old values
1634 if(mbOldHadMasterPage
)
1636 mxPage
->TRG_ClearMasterPage();
1637 mxPage
->TRG_SetMasterPage(*mxPage
->getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber
));
1638 mxPage
->TRG_SetMasterPageVisibleLayers(maOldSet
);
1642 void SdrUndoPageChangeMasterPage::Redo()
1644 // restore new values
1645 if(mbNewHadMasterPage
)
1647 mxPage
->TRG_ClearMasterPage();
1648 mxPage
->TRG_SetMasterPage(*mxPage
->getSdrModelFromSdrPage().GetMasterPage(maNewMasterPageNumber
));
1649 mxPage
->TRG_SetMasterPageVisibleLayers(maNewSet
);
1653 OUString
SdrUndoPageChangeMasterPage::GetComment() const
1655 return ImpGetDescriptionStr(STR_UndoChgPageMasterDscr
);
1659 SdrUndoFactory::~SdrUndoFactory(){}
1663 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoMoveObject( SdrObject
& rObject
, const Size
& rDist
)
1665 return std::make_unique
<SdrUndoMoveObj
>( rObject
, rDist
);
1668 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoGeoObject( SdrObject
& rObject
)
1670 return std::make_unique
<SdrUndoGeoObj
>( rObject
);
1673 // Diagram ModelData changes
1674 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoDiagramModelData( SdrObject
& rObject
, std::shared_ptr
< svx::diagram::DiagramDataState
>& rStartState
)
1676 return std::make_unique
<SdrUndoDiagramModelData
>( rObject
, rStartState
);
1679 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoAttrObject( SdrObject
& rObject
, bool bStyleSheet1
, bool bSaveText
)
1681 return std::make_unique
<SdrUndoAttrObj
>( rObject
, bStyleSheet1
, bSaveText
);
1684 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoRemoveObject(SdrObject
& rObject
)
1686 return std::make_unique
<SdrUndoRemoveObj
>(rObject
);
1689 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoInsertObject( SdrObject
& rObject
, bool bOrdNumDirect
)
1691 return std::make_unique
<SdrUndoInsertObj
>( rObject
, bOrdNumDirect
);
1694 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoDeleteObject( SdrObject
& rObject
, bool bOrdNumDirect
)
1696 return std::make_unique
<SdrUndoDelObj
>( rObject
, bOrdNumDirect
);
1699 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoNewObject( SdrObject
& rObject
, bool bOrdNumDirect
)
1701 return std::make_unique
<SdrUndoNewObj
>( rObject
, bOrdNumDirect
);
1704 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoCopyObject( SdrObject
& rObject
, bool bOrdNumDirect
)
1706 return std::make_unique
<SdrUndoCopyObj
>( rObject
, bOrdNumDirect
);
1709 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoObjectOrdNum( SdrObject
& rObject
, sal_uInt32 nOldOrdNum1
, sal_uInt32 nNewOrdNum1
)
1711 return std::make_unique
<SdrUndoObjOrdNum
>( rObject
, nOldOrdNum1
, nNewOrdNum1
);
1714 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoSort(SdrPage
& rPage
, ::std::vector
<sal_Int32
> const& rSortOrder
)
1716 return std::make_unique
<SdrUndoSort
>(rPage
, rSortOrder
);
1719 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoReplaceObject( SdrObject
& rOldObject
, SdrObject
& rNewObject
)
1721 return std::make_unique
<SdrUndoReplaceObj
>( rOldObject
, rNewObject
);
1724 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoObjectLayerChange( SdrObject
& rObject
, SdrLayerID aOldLayer
, SdrLayerID aNewLayer
)
1726 return std::make_unique
<SdrUndoObjectLayerChange
>( rObject
, aOldLayer
, aNewLayer
);
1729 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoObjectSetText( SdrObject
& rNewObj
, sal_Int32 nText
)
1731 return std::make_unique
<SdrUndoObjSetText
>( rNewObj
, nText
);
1734 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoObjectStrAttr( SdrObject
& rObject
,
1735 SdrUndoObjStrAttr::ObjStrAttrType eObjStrAttrType
,
1736 const OUString
& sOldStr
,
1737 const OUString
& sNewStr
)
1739 return std::make_unique
<SdrUndoObjStrAttr
>( rObject
, eObjStrAttrType
, sOldStr
, sNewStr
);
1742 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoObjectDecorative(
1743 SdrObject
& rObject
, bool const WasDecorative
)
1745 return std::make_unique
<SdrUndoObjDecorative
>(rObject
, WasDecorative
);
1750 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum
, SdrLayerAdmin
& rNewLayerAdmin
, SdrModel
& rNewModel
)
1752 return std::make_unique
<SdrUndoNewLayer
>( nLayerNum
, rNewLayerAdmin
, rNewModel
);
1755 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum
, SdrLayerAdmin
& rNewLayerAdmin
, SdrModel
& rNewModel
)
1757 return std::make_unique
<SdrUndoDelLayer
>( nLayerNum
, rNewLayerAdmin
, rNewModel
);
1761 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoDeletePage(SdrPage
& rPage
)
1763 return std::make_unique
<SdrUndoDelPage
>(rPage
);
1766 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoNewPage(SdrPage
& rPage
)
1768 return std::make_unique
<SdrUndoNewPage
>( rPage
);
1771 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoCopyPage(SdrPage
& rPage
)
1773 return std::make_unique
<SdrUndoCopyPage
>( rPage
);
1776 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoSetPageNum(SdrPage
& rNewPg
, sal_uInt16 nOldPageNum1
, sal_uInt16 nNewPageNum1
)
1778 return std::make_unique
<SdrUndoSetPageNum
>( rNewPg
, nOldPageNum1
, nNewPageNum1
);
1781 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage
& rChangedPage
)
1783 return std::make_unique
<SdrUndoPageRemoveMasterPage
>( rChangedPage
);
1786 std::unique_ptr
<SdrUndoAction
> SdrUndoFactory::CreateUndoPageChangeMasterPage(SdrPage
& rChangedPage
)
1788 return std::make_unique
<SdrUndoPageChangeMasterPage
>(rChangedPage
);
1792 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */