[Libreoffice-commits] core.git: sd/inc sd/qa sd/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Aug 3 16:30:33 UTC 2016


 sd/inc/sdundo.hxx                            |    6 ++++--
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   23 +++++++++++++++++++++++
 sd/source/core/undo/undoobjects.cxx          |   18 ++++++++++++++++++
 3 files changed, 45 insertions(+), 2 deletions(-)

New commits:
commit f6283cf6b4342a0492f1127c2d7a8597255a75c3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Aug 3 17:01:02 2016 +0200

    sd: track view shell id in SdUndoAction
    
    This helps in case of e.g. setting the page size of an Impress slide
    from the sidebar.
    
    Change-Id: I6247d6efcc59f2c6311dcd33d0f989a39fd7b3f9
    Reviewed-on: https://gerrit.libreoffice.org/27827
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sd/inc/sdundo.hxx b/sd/inc/sdundo.hxx
index 84b81a3..661f354 100644
--- a/sd/inc/sdundo.hxx
+++ b/sd/inc/sdundo.hxx
@@ -28,17 +28,19 @@ class SdDrawDocument;
 class SD_DLLPUBLIC SdUndoAction : public SfxUndoAction
 {
 public:
-                            SdUndoAction(SdDrawDocument* pSdDrawDocument)
-                                : mpDoc(pSdDrawDocument)  {}
+                            SdUndoAction(SdDrawDocument* pSdDrawDocument);
     virtual                 ~SdUndoAction() {}
 
     void                    SetComment(const OUString& rStr) { maComment = rStr; }
     virtual OUString        GetComment() const override { return maComment; }
     virtual SdUndoAction*   Clone() const { return nullptr; }
+    /// See SfxUndoAction::GetViewShellId().
+    sal_Int32 GetViewShellId() const override;
 
 protected:
     SdDrawDocument* mpDoc;
     OUString maComment;
+    sal_Int32 mnViewShellId;
 };
 
 #endif // INCLUDED_SD_INC_SDUNDO_HXX
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index c8dc993..d3bcd88f 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -53,6 +53,7 @@ public:
     void testSetTextSelection();
     void testGetTextSelection();
     void testSetGraphicSelection();
+    void testUndoShells();
     void testResetSelection();
     void testSearch();
     void testSearchAll();
@@ -76,6 +77,7 @@ public:
     CPPUNIT_TEST(testSetTextSelection);
     CPPUNIT_TEST(testGetTextSelection);
     CPPUNIT_TEST(testSetGraphicSelection);
+    CPPUNIT_TEST(testUndoShells);
     CPPUNIT_TEST(testResetSelection);
     CPPUNIT_TEST(testSearch);
     CPPUNIT_TEST(testSearchAll);
@@ -431,6 +433,27 @@ void SdTiledRenderingTest::testSetGraphicSelection()
     CPPUNIT_ASSERT(aShapeBefore.getHeight() < aShapeAfter.getHeight());
 }
 
+void SdTiledRenderingTest::testUndoShells()
+{
+    // Load a document and set the page size.
+    SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+    uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+    {
+        {"AttributePageSize.Width", uno::makeAny(static_cast<sal_Int32>(10000))},
+        {"AttributePageSize.Height", uno::makeAny(static_cast<sal_Int32>(10000))},
+    }));
+    comphelper::dispatchCommand(".uno:AttributePageSize", aPropertyValues);
+    Scheduler::ProcessEventsToIdle();
+
+    // Assert that view shell ID tracking works for SdUndoAction subclasses.
+    SdDrawDocument* pDocument = pXImpressDocument->GetDoc();
+    sd::UndoManager* pUndoManager = pDocument->GetUndoManager();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
+    sal_Int32 nView1 = SfxLokHelper::getView();
+    // This was -1, SdUndoGroup did not track what view shell created it.
+    CPPUNIT_ASSERT_EQUAL(nView1, pUndoManager->GetUndoAction()->GetViewShellId());
+}
+
 void SdTiledRenderingTest::testResetSelection()
 {
     SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx
index c8017f3..84eced5 100644
--- a/sd/source/core/undo/undoobjects.cxx
+++ b/sd/source/core/undo/undoobjects.cxx
@@ -22,9 +22,27 @@
 #include "CustomAnimationEffect.hxx"
 #include "drawdoc.hxx"
 #include "undoanim.hxx"
+#include "../../ui/inc/ViewShell.hxx"
+#include "../../ui/inc/ViewShellBase.hxx"
+#include "../../ui/inc/DrawDocShell.hxx"
 
 using namespace sd;
 
+SdUndoAction::SdUndoAction(SdDrawDocument* pSdDrawDocument)
+    : mpDoc(pSdDrawDocument),
+      mnViewShellId(-1)
+{
+    sd::DrawDocShell* pDocShell = pSdDrawDocument ? pSdDrawDocument->GetDocSh() : nullptr;
+    sd::ViewShell* pViewShell = pDocShell ? pDocShell->GetViewShell() : nullptr;
+    if (pViewShell)
+        mnViewShellId = pViewShell->GetViewShellBase().GetViewShellId();
+}
+
+sal_Int32 SdUndoAction::GetViewShellId() const
+{
+    return mnViewShellId;
+}
+
 UndoRemovePresObjectImpl::UndoRemovePresObjectImpl( SdrObject& rObject )
 : mpUndoUsercall(nullptr)
 , mpUndoAnimation(nullptr)


More information about the Libreoffice-commits mailing list