summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-08-04 09:13:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-08-05 14:31:26 +0200
commit392635220aad1c361897fedeff1c4e7ca5c8476d (patch)
tree0d86d181b5218b21e4f386f3e9f4c70c8a6d6e39
parented91412a2f12f59d98575ccd1baa8bbf06d71896 (diff)
sc: implement SfxUndoAction::GetViewShellId() interface ...
... in SfxUndoAction subclasses Change-Id: I1504e2cfb0f58ff97e2de7a641d72e4867238164 Reviewed-on: https://gerrit.libreoffice.org/27861 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 7cbb0664b94bb9f4587098c1940de98e4f7aae16)
-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 f049f4ed1cf4..8b088baaf771 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -60,6 +60,7 @@ public:
void testDocumentSizeChanged();
void testViewLock();
void testColRowResize();
+ void testUndoShells();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -71,6 +72,7 @@ public:
CPPUNIT_TEST(testDocumentSizeChanged);
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testColRowResize);
+ CPPUNIT_TEST(testUndoShells);
CPPUNIT_TEST_SUITE_END();
private:
@@ -560,6 +562,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 f501f5b305b5..a9a3ba241bdc 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -45,10 +45,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 );
@@ -182,6 +186,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 103b01514609..bbebad8bfc4b 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();
@@ -48,6 +49,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 64ce53a7bcca..1859b5876035 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()
@@ -562,8 +570,11 @@ void ScDBFuncUndo::EndRedo()
}
ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) :
- pWrappedUndo( pUndo )
+ pWrappedUndo( pUndo ),
+ mnViewShellId( -1 )
{
+ if (pWrappedUndo)
+ mnViewShellId = pWrappedUndo->GetViewShellId();
}
ScUndoWrapper::~ScUndoWrapper()
@@ -583,6 +594,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 5645afb09406..5b9c0d540f7d 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)