[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 5 commits - include/svx sd/inc sd/qa sd/sdi sd/source svl/source svx/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Aug 4 09:13:52 UTC 2016


 include/svx/svdundo.hxx                      |    8 +++--
 sd/inc/sdundo.hxx                            |    6 ++--
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   38 ++++++++++++++++++++++++++-
 sd/sdi/_drvwsh.sdi                           |    5 +++
 sd/source/core/drawdoc.cxx                   |    8 +++++
 sd/source/core/undo/undoobjects.cxx          |   18 ++++++++++++
 sd/source/ui/view/drviews2.cxx               |    1 
 svl/source/undo/undo.cxx                     |   13 +++++++++
 svx/source/svdraw/svdundo.cxx                |   11 +++++++
 9 files changed, 102 insertions(+), 6 deletions(-)

New commits:
commit ed91412a2f12f59d98575ccd1baa8bbf06d71896
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Aug 3 18:35:57 2016 +0200

    svl: handle nullptr pWriter in SfxUndoManager::dumpAsXml()
    
    This is useful when it's called from gdb for Calc.
    
    Change-Id: I22b3e5bbfc5627bff27899a288f7c25179f750ec
    Reviewed-on: https://gerrit.libreoffice.org/27836
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 9460d24883067160c53b53a018a88298131908da)

diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 154e8e9..def0089 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -1285,6 +1285,14 @@ void SfxUndoManager::RemoveOldestUndoActions( size_t const i_count )
 
 void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
+    bool bOwns = false;
+    if (!pWriter)
+    {
+        pWriter = xmlNewTextWriterFilename("undo.xml", 0);
+        xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
+        bOwns = true;
+    }
+
     xmlTextWriterStartElement(pWriter, BAD_CAST("sfxUndoManager"));
     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nUndoActionCount"), BAD_CAST(OString::number(GetUndoActionCount()).getStr()));
 
@@ -1292,6 +1300,11 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
         GetUndoAction(i)->dumpAsXml(pWriter);
 
     xmlTextWriterEndElement(pWriter);
+    if (bOwns)
+    {
+        xmlTextWriterEndDocument(pWriter);
+        xmlFreeTextWriter(pWriter);
+    }
 }
 
 struct SfxListUndoAction::Impl
commit 45e01b368e39069151f235b7d4954da1b76c9ffd
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>
    (cherry picked from commit f6283cf6b4342a0492f1127c2d7a8597255a75c3)

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 4e28834..ba1cb84 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);
@@ -427,6 +429,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)
commit be029cf8dc82702730d901cf881238763a3ec99b
Author: Rishabh Kumar <kris.kr296 at gmail.com>
Date:   Fri Jul 31 02:28:28 2015 +0530

    tdf#89466: Slide Background tab
    
    Reviewed-on: https://gerrit.libreoffice.org/17007
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    (cherry picked from commit 93b4bf647a5899f54ef51f8b4bfed0faa66b466e,
    just the SID_ATTR_PAGE_SIZE part)
    
    Change-Id: Ic3ba6b47a1e5fcaeec76c4e4ff0ba6128653af86

diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index a571051..dcf6a48 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -2700,6 +2700,11 @@ interface DrawView
         ExecMethod = FuTemporary ;
         StateMethod = GetMenuState ;
     ]
+    SID_ATTR_PAGE_SIZE
+    [
+        ExecMethod = FuTemporary ;
+        StateMethod = GetMenuState ;
+    ]
     SID_DISPLAY_MASTER_BACKGROUND
     [
         ExecMethod = FuTemporary ;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 026021c..6ff92f8 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1208,6 +1208,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_SELECT_BACKGROUND:
         case SID_SAVE_BACKGROUND:
+        case SID_ATTR_PAGE_SIZE:
         case SID_PAGESETUP:  // BASIC ??
         {
             SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
commit 4e3e7b9f9bb91c48c39d60a7f19fb085725fbe86
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 19 13:57:54 2016 +0200

    sd doc model dump: include undo manager info
    
    So that it's easy to see where the implementation for a given undo
    action is.
    
    Reviewed-on: https://gerrit.libreoffice.org/24243
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 7a06ef161cc27a3d1bcc8b970928f776500c267e)
    
    Change-Id: I93b8603f75d0b5a68922e02540b9db6824f4d0db

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 12529cd..4e28834 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -793,7 +793,7 @@ void SdTiledRenderingTest::testResizeTableColumn()
 
     // Remember the original cell widths.
     xmlDocPtr pXmlDoc = parseXmlDump();
-    OString aPrefix = "/sdrModel/sdPage/sdrObjList/sdrTableObj/sdrTableObjImpl/tableLayouter/columns/";
+    OString aPrefix = "/sdDrawDocument/sdrModel/sdPage/sdrObjList/sdrTableObj/sdrTableObjImpl/tableLayouter/columns/";
     sal_Int32 nExpectedColumn1 = getXPath(pXmlDoc, aPrefix + "layout[1]", "size").toInt32();
     sal_Int32 nExpectedColumn2 = getXPath(pXmlDoc, aPrefix + "layout[2]", "size").toInt32();
     xmlFreeDoc(pXmlDoc);
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index dcde763..3e1aff8 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -98,6 +98,7 @@
 #include "../ui/inc/ViewShell.hxx"
 #include "../ui/inc/optsitem.hxx"
 #include "../ui/inc/FrameView.hxx"
+#include <undo/undomanager.hxx>
 
 #include <tools/tenccvt.hxx>
 #include <vcl/settings.hxx>
@@ -1101,7 +1102,14 @@ void SdDrawDocument::dumpAsXml(xmlTextWriterPtr pWriter) const
         xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
         bOwns = true;
     }
+    xmlTextWriterStartElement(pWriter, BAD_CAST("sdDrawDocument"));
+    xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+
     FmFormModel::dumpAsXml(pWriter);
+    if (GetUndoManager())
+        GetUndoManager()->dumpAsXml(pWriter);
+
+    xmlTextWriterEndElement(pWriter);
     if (bOwns)
     {
         xmlTextWriterEndDocument(pWriter);
commit 64eba246de2277602eb10f26789093ba3c066b5b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Aug 3 11:39:07 2016 +0200

    svx: track view shell id in SdrUndoAction
    
    This is used in Impress e.g. when resizing a picture.
    
    Change-Id: I2e0a9228ed0ff9ecfd72696ef84e56f88e4c0f70
    Reviewed-on: https://gerrit.libreoffice.org/27822
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 4acac00df5a85ff006ecead06c4018e88caaf401)

diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx
index 63f532c..4ffc74b 100644
--- a/include/svx/svdundo.hxx
+++ b/include/svx/svdundo.hxx
@@ -55,11 +55,10 @@ class SVX_DLLPUBLIC SdrUndoAction : public SfxUndoAction
 {
 protected:
     SdrModel&                   rMod;
+    sal_Int32 m_nViewShellId;
 
 protected:
-    SdrUndoAction(SdrModel& rNewMod)
-    :   rMod(rNewMod)
-    {}
+    SdrUndoAction(SdrModel& rNewMod);
 
 public:
     virtual ~SdrUndoAction();
@@ -72,6 +71,9 @@ public:
 
     virtual bool CanSdrRepeat(SdrView& rView) const;
     virtual void SdrRepeat(SdrView& rView);
+
+    /// See SfxUndoAction::GetViewShellId().
+    sal_Int32 GetViewShellId() const override;
 };
 
 /**
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 8823924..12529cd 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -34,6 +34,7 @@
 #include <sdpage.hxx>
 #include <unomodel.hxx>
 #include <drawdoc.hxx>
+#include <undo/undomanager.hxx>
 
 using namespace css;
 
@@ -408,6 +409,18 @@ void SdTiledRenderingTest::testSetGraphicSelection()
     // Resize.
     pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY()));
     pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY() + 1000));
+
+    // Assert that view shell ID tracking works.
+    sal_Int32 nView1 = SfxLokHelper::getView();
+    SdDrawDocument* pDocument = pXImpressDocument->GetDoc();
+    sd::UndoManager* pUndoManager = pDocument->GetUndoManager();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
+    auto pListAction = dynamic_cast<SfxListUndoAction*>(pUndoManager->GetUndoAction());
+    CPPUNIT_ASSERT(pListAction);
+    for (size_t i = 0; i < pListAction->aUndoActions.size(); ++i)
+        // The second item was -1 here, view shell ID wasn't known.
+        CPPUNIT_ASSERT_EQUAL(nView1, pListAction->aUndoActions.GetUndoAction(i)->GetViewShellId());
+
     Rectangle aShapeAfter = pObject->GetSnapRect();
     // Check that a resize happened, but aspect ratio is not kept.
     CPPUNIT_ASSERT_EQUAL(aShapeBefore.getWidth(), aShapeAfter.getWidth());
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 835d34b..28064e7 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -45,6 +45,7 @@
 #include <sdr/contact/viewcontactofgraphic.hxx>
 #include <svx/svdotable.hxx> // #i124389#
 #include <vcl/svapp.hxx>
+#include <sfx2/viewsh.hxx>
 
 
 // iterates over all views and unmarks this SdrObject if it is marked
@@ -57,6 +58,12 @@ static void ImplUnmarkObject( SdrObject* pObj )
     }
 }
 
+SdrUndoAction::SdrUndoAction(SdrModel& rNewMod)
+    : rMod(rNewMod), m_nViewShellId(-1)
+{
+    if (SfxViewShell* pViewShell = SfxViewShell::Current())
+        m_nViewShellId = pViewShell->GetViewShellId();
+}
 
 SdrUndoAction::~SdrUndoAction() {}
 
@@ -95,6 +102,10 @@ OUString SdrUndoAction::GetSdrRepeatComment(SdrView& /*rView*/) const
     return OUString();
 }
 
+sal_Int32 SdrUndoAction::GetViewShellId() const
+{
+    return m_nViewShellId;
+}
 
 SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod)
 :   SdrUndoAction(rNewMod),


More information about the Libreoffice-commits mailing list