summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-11-30 20:27:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-12-03 22:40:17 +0100
commit0742445bf5cfb691f2ec0b5b1f0f752911b058bb (patch)
treeb43d4c2c444a05402a3b665c5b5e6bd303f5d01a /include
parent0d4568f4b082b0f3cce97b4f18c2dc1ff60aeb85 (diff)
tdf#145928 svx: fix undo of sorting shapes
The problem is that in sw there are these obnoxious virtual SdrObjects that are created and destroyed by the layout. 0 SdrObject::~SdrObject() 3 SwVirtFlyDrawObj::~SwVirtFlyDrawObj() 5 SwFlyFrame::FinitDrawObj() 12 SwFrame::DestroyFrame(SwFrame*) 13 SwFrameFormat::DelFrames() 14 SwUndoFlyBase::DelFly(SwDoc*) 15 SwUndoDelLayFormat::SwUndoDelLayFormat(SwFrameFormat*) 16 SwHistoryTextFlyCnt::SwHistoryTextFlyCnt(SwFrameFormat*) This misdesign means that SdrUndoObj::pObj may point to a deleted object. Commit 9bc6160e0acbc78be998129ea55ed7e4529959fa may create SdrUnoObj when saving the document, so that is now an additional way to introduce the problem. Try to work around it by not using a SdrUndoObj subclass in this case, but create a new SdrUndoAction subclass that uses SdrPage::sort() and stores no pointers. There is still the problem that changes in the layout or view settings like "Hide tracked changes" could cause different virtual SdrObjects to exist between when the Undo was recorded and when it is activated, in which case nothing is done. But that really requires a larger refactoring such as having a SdrPage for the model that never contains virtual SdrObjects, and another SdrPage for the view that does contain virtual SdrObjects to fix. Change-Id: I4cf5d4eb8bb24a51730c55ff34a043b8a88fdb52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126153 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 25a368c30acb54e0819d2b2b890a3fd1530d8a76) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126137 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/svx/svdundo.hxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index 04665b9daa28..27ed763f859e 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -377,6 +377,24 @@ public:
virtual OUString GetComment() const override;
};
+class SdrUndoSort final : public SdrUndoAction
+{
+private:
+ ::std::vector<sal_Int32> m_OldSortOrder;
+ ::std::vector<sal_Int32> m_NewSortOrder;
+ sal_uInt16 const m_nPage;
+
+ void Do(::std::vector<sal_Int32> & rSortOrder);
+
+public:
+ SdrUndoSort(SdrPage & rPage,
+ ::std::vector<sal_Int32> const& rSortOrder);
+
+ virtual void Undo() override;
+ virtual void Redo() override;
+
+ virtual OUString GetComment() const override;
+};
// #i11702#
@@ -732,6 +750,7 @@ public:
virtual std::unique_ptr<SdrUndoAction> CreateUndoNewPage(SdrPage& rPage);
virtual std::unique_ptr<SdrUndoAction> CreateUndoCopyPage(SdrPage& rPage);
virtual std::unique_ptr<SdrUndoAction> CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1);
+ virtual std::unique_ptr<SdrUndoAction> CreateUndoSort(SdrPage& rPage, ::std::vector<sal_Int32> const& rSortOrder);
// Master page
virtual std::unique_ptr<SdrUndoAction> CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage);