summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx22
-rw-r--r--sc/source/ui/inc/undobase.hxx6
-rw-r--r--sc/source/ui/inc/undodraw.hxx3
-rw-r--r--sc/source/ui/undo/undobase.cxx20
-rw-r--r--sc/source/ui/undo/undodraw.cxx10
5 files changed, 58 insertions, 3 deletions
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 093fa181db52..d5258c2d0447 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -61,6 +61,7 @@ public:
void testDocumentSizeChanged();
void testViewLock();
void testColRowResize();
+ void testUndoShells();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -73,6 +74,7 @@ public:
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testColRowResize);
+ CPPUNIT_TEST(testUndoShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -582,6 +584,26 @@ void ScTiledRenderingTest::testColRowResize()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testUndoShells()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("small.ods");
+ // Clear the currently selected cell.
+ comphelper::dispatchCommand(".uno:ClearContents", {});
+
+ auto pDocShell = dynamic_cast<ScDocShell*>(pModelObj->GetEmbeddedObject());
+ CPPUNIT_ASSERT(pDocShell);
+ ScDocument& rDoc = pDocShell->GetDocument();
+ SfxUndoManager* pUndoManager = rDoc.GetUndoManager();
+ CPPUNIT_ASSERT(pUndoManager);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
+ sal_Int32 nView1 = SfxLokHelper::getView();
+ // This was -1: ScSimpleUndo did not remember what view shell created it.
+ CPPUNIT_ASSERT_EQUAL(nView1, pUndoManager->GetUndoAction()->GetViewShellId());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index 95fed6c2d475..522bf63bf043 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -46,10 +46,13 @@ public:
virtual ~ScSimpleUndo();
virtual bool Merge( SfxUndoAction *pNextAction ) override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
protected:
ScDocShell* pDocShell;
SfxUndoAction* pDetectiveUndo;
+ sal_Int32 mnViewShellId;
bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
@@ -164,6 +167,7 @@ private:
class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
{
SfxUndoAction* pWrappedUndo;
+ sal_Int32 mnViewShellId;
public:
ScUndoWrapper( SfxUndoAction* pUndo );
@@ -180,6 +184,8 @@ public:
virtual OUString GetComment() const override;
virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
virtual sal_uInt16 GetId() const override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
};
#endif
diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx
index 1572abd857d0..4b91271c68b7 100644
--- a/sc/source/ui/inc/undodraw.hxx
+++ b/sc/source/ui/inc/undodraw.hxx
@@ -28,6 +28,7 @@ class ScUndoDraw: public SfxUndoAction
{
SfxUndoAction* pDrawUndo;
ScDocShell* pDocShell;
+ sal_Int32 mnViewShellId;
void UpdateSubShell();
@@ -46,6 +47,8 @@ public:
virtual OUString GetComment() const override;
virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
virtual sal_uInt16 GetId() const override;
+ /// See SfxUndoAction::GetViewShellId().
+ sal_Int32 GetViewShellId() const override;
};
#endif
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index eefce30f3ff1..6d59c1d18970 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -38,8 +38,16 @@
ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) :
pDocShell( pDocSh ),
- pDetectiveUndo( nullptr )
+ pDetectiveUndo( nullptr ),
+ mnViewShellId(-1)
{
+ if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
+ mnViewShellId = pViewShell->GetViewShellId();
+}
+
+sal_Int32 ScSimpleUndo::GetViewShellId() const
+{
+ return mnViewShellId;
}
ScSimpleUndo::~ScSimpleUndo()
@@ -594,8 +602,11 @@ void ScDBFuncUndo::EndRedo()
}
ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) :
- pWrappedUndo( pUndo )
+ pWrappedUndo( pUndo ),
+ mnViewShellId( -1 )
{
+ if (pWrappedUndo)
+ mnViewShellId = pWrappedUndo->GetViewShellId();
}
ScUndoWrapper::~ScUndoWrapper()
@@ -615,6 +626,11 @@ OUString ScUndoWrapper::GetComment() const
return OUString();
}
+sal_Int32 ScUndoWrapper::GetViewShellId() const
+{
+ return mnViewShellId;
+}
+
OUString ScUndoWrapper::GetRepeatComment(SfxRepeatTarget& rTarget) const
{
if (pWrappedUndo)
diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx
index 89359ffbc6b1..110f9f3e4e94 100644
--- a/sc/source/ui/undo/undodraw.cxx
+++ b/sc/source/ui/undo/undodraw.cxx
@@ -26,8 +26,11 @@
ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
pDrawUndo( pUndo ),
- pDocShell( pDocSh )
+ pDocShell( pDocSh ),
+ mnViewShellId( -1 )
{
+ if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell())
+ mnViewShellId = pViewShell->GetViewShellId();
}
ScUndoDraw::~ScUndoDraw()
@@ -47,6 +50,11 @@ OUString ScUndoDraw::GetComment() const
return OUString();
}
+sal_Int32 ScUndoDraw::GetViewShellId() const
+{
+ return mnViewShellId;
+}
+
OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
{
if (pDrawUndo)