diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-04 09:13:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-04 08:41:33 +0000 |
commit | 7cbb0664b94bb9f4587098c1940de98e4f7aae16 (patch) | |
tree | b0f4aa00173ef868f2fadd8d164e251f2e1512d5 | |
parent | 2b3112b30a8dea8a009c11ddb209e12697f72e32 (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>
-rw-r--r-- | sc/qa/unit/tiledrendering/tiledrendering.cxx | 22 | ||||
-rw-r--r-- | sc/source/ui/inc/undobase.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/inc/undodraw.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/undo/undobase.cxx | 20 | ||||
-rw-r--r-- | sc/source/ui/undo/undodraw.cxx | 10 |
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) |