sc/source/ui/inc/undobase.hxx | 5 +++++ sc/source/ui/inc/undocell.hxx | 10 +++++++++- sc/source/ui/inc/undomanager.hxx | 4 ++-- sc/source/ui/undo/undobase.cxx | 18 +++++++++--------- 4 files changed, 25 insertions(+), 12 deletions(-)
New commits: commit fba10e9cb3d81a5eeca78dbd55cb49acdaf62b5a Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jul 30 21:09:47 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 2 09:24:57 2022 +0200 generalize the undo independence check Change-Id: I441edbdf11ada1a0a724577a4f76ae8ae14177e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137683 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 41a513e5bbd253fad0ea78e297f4c1dd3c0837aa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137607 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx index 4e07e6ae50fe..460702a5fbaa 100644 --- a/sc/source/ui/inc/undobase.hxx +++ b/sc/source/ui/inc/undobase.hxx @@ -25,6 +25,7 @@ #include <memory> #include <map> +#include <optional> class SdrUndoAction; class ScRefUndoData; @@ -43,6 +44,8 @@ public: /// See SfxUndoAction::GetViewShellId(). ViewShellId GetViewShellId() const override; + virtual std::optional<ScRange> getAffectedRange() const { return std::nullopt; } + protected: ScDocShell* pDocShell; std::unique_ptr<SfxUndoAction> @@ -81,6 +84,8 @@ public: ScBlockUndoMode eBlockMode ); virtual ~ScBlockUndo() override; + virtual std::optional<ScRange> getAffectedRange() const override { return aBlockRange; } + protected: ScRange aBlockRange; std::unique_ptr<SdrUndoAction> pDrawUndo; diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx index f47aa6ca18bb..206ed7d31713 100644 --- a/sc/source/ui/inc/undocell.hxx +++ b/sc/source/ui/inc/undocell.hxx @@ -94,7 +94,7 @@ public: virtual OUString GetComment() const override; - const ScAddress& GetPositionAddress() const { return maPos; } + virtual std::optional<ScRange> getAffectedRange() const override { return maPos; } private: ValuesType maOldValues; @@ -124,6 +124,8 @@ public: virtual OUString GetComment() const override; + virtual std::optional<ScRange> getAffectedRange() const override { return aPos; } + private: ScAddress aPos; ScCellValue maOldCell; @@ -146,6 +148,8 @@ public: virtual bool CanRepeat( SfxRepeatTarget& rTarget ) const override; virtual OUString GetComment() const override; + virtual std::optional<ScRange> getAffectedRange() const override { return maPos; } + private: void SetChangeTrack(); void SetValue( const ScCellValue& rVal ); @@ -265,6 +269,8 @@ public: virtual OUString GetComment() const override; + virtual std::optional<ScRange> getAffectedRange() const override { return maPos; } + private: void DoInsertNote( const ScNoteData& rNoteData ); void DoRemoveNote( const ScNoteData& rNoteData ); @@ -290,6 +296,8 @@ public: virtual OUString GetComment() const override; + virtual std::optional<ScRange> getAffectedRange() const override { return maPos; } + private: ScAddress maPos; bool mbShown; diff --git a/sc/source/ui/inc/undomanager.hxx b/sc/source/ui/inc/undomanager.hxx index da254a02d294..585e32e5fee7 100644 --- a/sc/source/ui/inc/undomanager.hxx +++ b/sc/source/ui/inc/undomanager.hxx @@ -11,7 +11,7 @@ #include <svx/sdrundomanager.hxx> class SfxViewShell; -class ScUndoEnterData; +class ScSimpleUndo; class SC_DLLPUBLIC ScUndoManager : public SdrUndoManager { @@ -30,7 +30,7 @@ public: private: static std::optional<ScRange> getAffectedRangeFromUndo(const SfxUndoAction*); - static const ScUndoEnterData* getScUndoEnterData(const SfxUndoAction*); + static const ScSimpleUndo* getScSimpleUndo(const SfxUndoAction*); }; class ScUndoRedoContext final : public SfxUndoContext diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx index 250c78619ef8..3a5fec1bf975 100644 --- a/sc/source/ui/undo/undobase.cxx +++ b/sc/source/ui/undo/undobase.cxx @@ -666,7 +666,7 @@ bool ScUndoManager::IsViewUndoActionIndependent(const SfxViewShell* pView) const for (size_t i = 0; i < GetRedoActionCount(); ++i) { - auto pRedoAction = getScUndoEnterData(GetRedoAction(i)); + auto pRedoAction = getScSimpleUndo(GetRedoAction(i)); if (!pRedoAction) { return false; @@ -684,23 +684,23 @@ bool ScUndoManager::IsViewUndoActionIndependent(const SfxViewShell* pView) const std::optional<ScRange> ScUndoManager::getAffectedRangeFromUndo(const SfxUndoAction* pAction) { - auto pTopScUndoEnterData = getScUndoEnterData(pAction); - if (!pTopScUndoEnterData) + auto pSimpleUndo = getScSimpleUndo(pAction); + if (!pSimpleUndo) return std::nullopt; - return pTopScUndoEnterData->GetPositionAddress(); + return pSimpleUndo->getAffectedRange(); } -const ScUndoEnterData* ScUndoManager::getScUndoEnterData(const SfxUndoAction* pAction) +const ScSimpleUndo* ScUndoManager::getScSimpleUndo(const SfxUndoAction* pAction) { - const ScUndoEnterData* pUndoEnterData = dynamic_cast<const ScUndoEnterData*>(pAction); - if (pUndoEnterData) - return pUndoEnterData; + const ScSimpleUndo* pSimpleUndo = dynamic_cast<const ScSimpleUndo*>(pAction); + if (pSimpleUndo) + return pSimpleUndo; auto pListAction = dynamic_cast<const SfxListUndoAction*>(pAction); if (!pListAction) return nullptr; if (pListAction->maUndoActions.size() > 1) return nullptr; - return dynamic_cast<ScUndoEnterData*>(pListAction->maUndoActions[0].pAction.get()); + return dynamic_cast<ScSimpleUndo*>(pListAction->maUndoActions[0].pAction.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */