summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-07-30 21:09:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-02 08:33:52 +0200
commit1abb82c0bc8c46acac8b2644e645725ff92dd538 (patch)
treea0a842161b8ab93f93ac1617f4f493e9142d92c8 /sc/source/ui
parentf7b5eefc36f6a7627e867651bafe38bdeb2f9c00 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/undobase.hxx5
-rw-r--r--sc/source/ui/inc/undocell.hxx10
-rw-r--r--sc/source/ui/inc/undomanager.hxx4
-rw-r--r--sc/source/ui/undo/undobase.cxx18
4 files changed, 25 insertions, 12 deletions
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 7ec3db645ffe..03168dfab980 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 31f1e4152a0d..cc7b8069cfe5 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -672,7 +672,7 @@ bool ScUndoManager::IsViewUndoActionIndependent(const SfxViewShell* pView, sal_u
for (size_t i = 0; i < GetRedoActionCount(); ++i)
{
- auto pRedoAction = getScUndoEnterData(GetRedoAction(i));
+ auto pRedoAction = getScSimpleUndo(GetRedoAction(i));
if (!pRedoAction)
{
return false;
@@ -691,23 +691,23 @@ bool ScUndoManager::IsViewUndoActionIndependent(const SfxViewShell* pView, sal_u
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: */