sc/qa/unit/tiledrendering/tiledrendering.cxx | 22 ++++++++++++++++++++++ sc/source/ui/inc/undobase.hxx | 6 ++++++ sc/source/ui/inc/undodraw.hxx | 3 +++ sc/source/ui/undo/undobase.cxx | 20 ++++++++++++++++++-- sc/source/ui/undo/undodraw.cxx | 10 +++++++++- 5 files changed, 58 insertions(+), 3 deletions(-)
New commits: commit 7cbb0664b94bb9f4587098c1940de98e4f7aae16 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Aug 4 09:13:33 2016 +0200 sc: implement SfxUndoAction::GetViewShellId() interface ... ... in SfxUndoAction subclasses Change-Id: I1504e2cfb0f58ff97e2de7a641d72e4867238164 Reviewed-on: https://gerrit.libreoffice.org/27861 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 093fa18..d5258c2 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 95fed6c..522bf63 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 1572abd..4b91271 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 eefce30..6d59c1d 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 89359ff..110f9f3e 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits