[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl sd/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 17 07:47:17 UTC 2019


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 ++-
 desktop/source/lib/init.cxx                 |   18 ++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h     |    3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |    8 ++++++++
 include/vcl/ITiledRenderable.hxx            |    6 ++++++
 sd/source/ui/inc/unomodel.hxx               |    2 ++
 sd/source/ui/unoidl/unomodel.cxx            |    7 +++++++
 7 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 0e82806ed6841c0a6919f97660ed4622c89d2338
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Sep 16 17:27:35 2018 -0400
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Jul 17 09:46:17 2019 +0200

    LOK: support for ordering/moving parts
    
    Currently reordering of slides is only supported
    for presentations, although it is provisioned for
    spreadsheets as well.
    
    Change-Id: I6c35066d6a5ef7586d34a8e8b89db69a20b86572
    Reviewed-on: https://gerrit.libreoffice.org/69612
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/73495
    Tested-by: Jenkins
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 75b9143e4417..a3db0fd57b1f 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2716,9 +2716,10 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, createViewWithOptions));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), offsetof(struct _LibreOfficeKitDocumentClass, selectPart));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), offsetof(struct _LibreOfficeKitDocumentClass, moveSelectedParts));
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c8ec63210664..f48f9846d063 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -711,6 +711,7 @@ static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis);
 static int doc_getPart(LibreOfficeKitDocument* pThis);
 static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
 static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect);
+static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate);
 static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
 static void doc_setPartMode(LibreOfficeKitDocument* pThis, int nPartMode);
 static void doc_paintTile(LibreOfficeKitDocument* pThis,
@@ -862,6 +863,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->getPart = doc_getPart;
         m_pDocumentClass->setPart = doc_setPart;
         m_pDocumentClass->selectPart = doc_selectPart;
+        m_pDocumentClass->moveSelectedParts = doc_moveSelectedParts;
         m_pDocumentClass->getPartName = doc_getPartName;
         m_pDocumentClass->setPartMode = doc_setPartMode;
         m_pDocumentClass->paintTile = doc_paintTile;
@@ -2358,6 +2360,22 @@ static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect
     pDoc->selectPart( nPart, nSelect );
 }
 
+static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate)
+{
+    SolarMutexGuard aGuard;
+    if (gImpl)
+        gImpl->maLastExceptionMsg.clear();
+
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return;
+    }
+
+    pDoc->moveSelectedParts(nPosition, bDuplicate);
+}
+
 static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis)
 {
     comphelper::ProfileZone aZone("doc_getPartPageRectangles");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 81a4787d24df..896b441ff715 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -381,6 +381,9 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::selectPart().
     void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect);
 
+    /// @see lok::Document::moveSelectedParts().
+    void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 6b3968b5ff6c..0290e6f8efb3 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -656,6 +656,14 @@ public:
         mpDoc->pClass->selectPart(mpDoc, nPart, nSelect);
     }
 
+    /// Moves the selected pages/slides to a new position.
+    /// nPosition is the new position where the selection
+    /// should go. bDuplicate when true will copy instead of move.
+    void moveSelectedParts(int nPosition, bool bDuplicate)
+    {
+        mpDoc->pClass->moveSelectedParts(mpDoc, nPosition, bDuplicate);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 90af3403ce28..905a3262b1a6 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -282,6 +282,12 @@ public:
      */
     virtual void selectPart(int /*nPart*/, int /*nSelect*/) {}
 
+    /**
+     * Move selected pages/slides to a new position.
+     * nPosition: the new position to move to.
+     * bDuplicate: to copy (true), or to move (false).
+     */
+    virtual void moveSelectedParts(int /*nPosition*/, bool /*bDuplicate*/) {}
 };
 } // namespace vcl
 
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 0ce303c09330..9a5da032893b 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -265,6 +265,8 @@ public:
     virtual OUString getPostIts() override;
     /// @see vcl::ITiledRenderable::selectPart().
     virtual void selectPart(int nPart, int nSelect) override;
+    /// @see vcl::ITiledRenderable::moveSelectedParts().
+    virtual void moveSelectedParts(int nPosition, bool bDuplicate) override;
     /// @see vcl::ITiledRenderable::getPartInfo().
     virtual OUString getPartInfo(int nPart) override;
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 5592535d1648..24b77f9e3730 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2282,6 +2282,13 @@ void SdXImpressDocument::selectPart(int nPart, int nSelect)
     pViewSh->SelectPage(nPart, nSelect);
 }
 
+void SdXImpressDocument::moveSelectedParts(int nPosition, bool bDuplicate)
+{
+    // Duplicating is currently unsupported.
+    if (!bDuplicate)
+        mpDoc->MovePages(nPosition);
+}
+
 OUString SdXImpressDocument::getPartInfo(int nPart)
 {
     DrawViewShell* pViewSh = GetViewShell();


More information about the Libreoffice-commits mailing list