diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-09-11 08:11:47 -0400 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-08-02 16:14:47 -0400 |
commit | 86073d788fb1834a8e99aae0478d9ce7f63fec52 (patch) | |
tree | 9c662c3df7a7aad7adc3a1f6b7deb7863596eeb6 | |
parent | 106c4786be04e60a25740d5b2af05c367563c669 (diff) |
slide-sorter: multiple selection
Change-Id: I8624de25b0bb66020002890f33758e52059a24ab
Reviewed-on: https://gerrit.libreoffice.org/69610
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/73493
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 20 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 3 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 7 | ||||
-rw-r--r-- | include/vcl/ITiledRenderable.hxx | 7 | ||||
-rw-r--r-- | sd/source/ui/inc/DrawViewShell.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/inc/unomodel.hxx | 3 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/view/drviews1.cxx | 46 |
9 files changed, 99 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 16e9a516fa9d..5aff0c23d82f 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2456,9 +2456,10 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection)); 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)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 3f2a3e0cdf32..da31c2e7f294 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -591,6 +591,7 @@ static int doc_getParts(LibreOfficeKitDocument* pThis); 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 char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart); static void doc_setPartMode(LibreOfficeKitDocument* pThis, int nPartMode); static void doc_paintTile(LibreOfficeKitDocument* pThis, @@ -741,6 +742,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->getPartPageRectangles = doc_getPartPageRectangles; m_pDocumentClass->getPart = doc_getPart; m_pDocumentClass->setPart = doc_setPart; + m_pDocumentClass->selectPart = doc_selectPart; m_pDocumentClass->getPartName = doc_getPartName; m_pDocumentClass->setPartMode = doc_setPartMode; m_pDocumentClass->paintTile = doc_paintTile; @@ -2034,6 +2036,22 @@ static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart) return pMemory; } +static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect) +{ + SolarMutexGuard aGuard; + if (gImpl) + gImpl->maLastExceptionMsg.clear(); + + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + return; + } + + pDoc->selectPart( nPart, nSelect ); +} + static char* doc_getPartPageRectangles(LibreOfficeKitDocument* pThis) { SolarMutexGuard aGuard; @@ -2378,6 +2396,8 @@ static void doc_initializeForRendering(LibreOfficeKitDocument* pThis, if (pDoc) { doc_iniUnoCommands(); + // Create the SlideSorter which is used for multiselection and reordering. + doc_postUnoCommand(pThis, ".uno:LeftPaneImpress", nullptr, false); pDoc->initializeForTiledRendering( comphelper::containerToSequence(jsonToPropertyValuesVector(pArguments))); } diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 5ac307536f5f..307707cbf305 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -362,6 +362,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::createViewWithOptions(). int (*createViewWithOptions) (LibreOfficeKitDocument* pThis, const char* pOptions); + /// @see lok::Document::selectPart(). + void (*selectPart) (LibreOfficeKitDocument* pThis, int nPart, int nSelect); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 3030f3db24b3..a759737a35c6 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -649,6 +649,13 @@ public: return mpDoc->pClass->postWindowGestureEvent(mpDoc, nWindowId, pType, nX, nY, nOffset); } + /// Set a part's selection mode. + /// nSelect is 0 to deselect, 1 to select, and 2 to toggle. + void selectPart(int nPart, int nSelect) + { + mpDoc->pClass->selectPart(mpDoc, nPart, nSelect); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index d50f1ff192d4..e8331f9560c7 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -370,6 +370,13 @@ public: return OUString(); } + /** + * Select/Unselect a document "part", i.e. slide for a slideshow, and + * tab for a spreadsheet(?). + * nSelect: 0 to deselect, 1 to select, and 2 to toggle. + */ + virtual void selectPart(int /*nPart*/, int /*nSelect*/) {} + }; } // namespace vcl diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index 9ec9d86ff9e4..71f1ed4a397c 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -247,6 +247,8 @@ public: bool SwitchPage(sal_uInt16 nPage); bool IsSwitchPageAllowed() const; + bool SelectPage(sal_uInt16 nPage, sal_uInt16 nSelect); + void GotoBookmark(const OUString& rBookmark); //Realize multi-selection of objects, If object is marked, the //corresponding entry is set true, else the corresponding entry is set diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index eda3a1511038..f8a6f50be604 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -262,6 +262,9 @@ public: virtual Pointer getPointer() override; /// @see vcl::ITiledRenderable::getPostIts(). virtual OUString getPostIts() override; + /// @see vcl::ITiledRenderable::selectPart(). + virtual void selectPart(int nPart, int nSelect) override; + // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index c7b8b6b4950a..aeaf03c9f112 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2282,6 +2282,15 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, nTilePosX, nTilePosY, nTileWidth, nTileHeight); } +void SdXImpressDocument::selectPart(int nPart, int nSelect) +{ + DrawViewShell* pViewSh = GetViewShell(); + if (!pViewSh) + return; + + pViewSh->SelectPage(nPart, nSelect); +} + void SdXImpressDocument::setPart( int nPart ) { DrawViewShell* pViewSh = GetViewShell(); diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 365a3b57b21e..d690e16121bb 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -76,6 +76,10 @@ #include <LayerTabBar.hxx> #include <ViewShellManager.hxx> #include <ViewShellHint.hxx> +#include <SlideSorter.hxx> +#include <SlideSorterViewShell.hxx> +#include <controller/SlideSorterController.hxx> +#include <controller/SlsPageSelector.hxx> #include <sfx2/request.hxx> #include <comphelper/lok.hxx> @@ -762,6 +766,48 @@ bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) } /** + * Mark the desired page as selected (1), deselected (0), toggle (2). + * nPage refers to the page in question. + */ +bool DrawViewShell::SelectPage(sal_uInt16 nPage, sal_uInt16 nSelect) +{ + bool bOK = false; + + // Tell the slide sorter about the name change (necessary for + // accessibility.) + slidesorter::SlideSorterViewShell* pSlideSorterViewShell + = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase()); + if (pSlideSorterViewShell != nullptr) + { + slidesorter::controller::PageSelector& aPageSelector + = pSlideSorterViewShell->GetSlideSorter().GetController().GetPageSelector(); + if (nSelect == 0) + { + // Deselect. + aPageSelector.DeselectPage(nPage); + bOK = true; + } + else if (nSelect == 1) + { + // Select. + aPageSelector.SelectPage(nPage); + bOK = true; + } + else + { + // Toggle. + if (aPageSelector.IsPageSelected(nPage)) + aPageSelector.DeselectPage(nPage); + else + aPageSelector.SelectPage(nPage); + bOK = true; + } + } + + return bOK; +} + +/** * Switch to desired page. * nSelectPage refers to the current EditMode */ |