From 5116ec373c0a7c65f8bf8ace182d0cb4151288c0 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 16 Sep 2018 17:27:35 -0400 Subject: 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 Tested-by: Ashod Nakashian Reviewed-on: https://gerrit.libreoffice.org/73495 Tested-by: Jenkins Reviewed-by: Jan Holesovsky --- 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 | 5 ++++- sd/source/ui/unoidl/unomodel.cxx | 25 +++++++++++++++++++++++++ 7 files changed, 66 insertions(+), 2 deletions(-) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 5aff0c23d82f..2ec64b6cc37f 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2457,9 +2457,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 da31c2e7f294..0cc4e3bace4c 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -592,6 +592,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, @@ -743,6 +744,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference 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; @@ -2052,6 +2054,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) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 307707cbf305..952f023cd26c 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -365,6 +365,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 a759737a35c6..863f1ac48ba0 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 e8331f9560c7..4e9a80a5378b 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -377,6 +377,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 f8a6f50be604..f271d7b37b69 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -264,7 +264,10 @@ 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; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index aeaf03c9f112..fbefc1c7e0bf 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2291,6 +2291,31 @@ 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(); + if (!pViewSh) + return OUString(); + + OUString aPartInfo; + const bool bIsVisible = pViewSh->IsVisible(nPart); + const bool bIsSelected = pViewSh->IsSelected(nPart); + + aPartInfo += "{ \"visible\": \""; + aPartInfo += OUString::number(static_cast(bIsVisible)); + aPartInfo += "\", \"selected\": \""; + aPartInfo += OUString::number(static_cast(bIsSelected)); + aPartInfo += "\" }"; + return aPartInfo; +} + void SdXImpressDocument::setPart( int nPart ) { DrawViewShell* pViewSh = GetViewShell(); -- cgit n value='distro/mimo/mimo-7-3'>distro/mimo/mimo-7-3 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff