[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sd/source

Pranam Lashkari (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 10 10:32:04 UTC 2020


 sd/source/ui/inc/DrawViewShell.hxx |    2 +
 sd/source/ui/view/drviews2.cxx     |   69 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 70 insertions(+), 1 deletion(-)

New commits:
commit 55392f9c7283903e487a4989a119ab2bf60abf20
Author:     Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue May 26 21:15:13 2020 +0530
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Jun 10 12:31:33 2020 +0200

    LOK: duplicating multiple slides
    
    Change-Id: Ic2e870bf2ec3b236e2babf6c090bf3ec1978776e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94814
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index df118b58ef1f..64fc215017d3 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -451,6 +451,8 @@ private:
         SdPage* pPage,
         const sal_Int32 nInsertPosition = -1) override;
 
+    void DuplicateSelectedSlides (SfxRequest& rRequest);
+
     css::uno::Reference< css::scanner::XScannerManager2 > mxScannerManager;
     css::uno::Reference< css::lang::XEventListener >      mxScannerListener;
     rtl::Reference<TransferableClipboardListener>         mxClipEvtLstnr;
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 3945bf1bf550..374ec6508342 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -186,6 +186,14 @@
 #include <sfx2/sidebar/Sidebar.hxx>
 #include <sfx2/classificationhelper.hxx>
 #include <sdmod.hxx>
+#include <model/SlsPageEnumerationProvider.hxx>
+#include <SlideSorter.hxx>
+#include <SlideSorterViewShell.hxx>
+#include <controller/SlideSorterController.hxx>
+#include <model/SlideSorterModel.hxx>
+#include <controller/SlsSelectionManager.hxx>
+#include <controller/SlsInsertionIndicatorHandler.hxx>
+#include <controller/SlsPageSelector.hxx>
 
 #include <ViewShellBase.hxx>
 #include <memory>
@@ -754,7 +762,6 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
 
         case SID_INSERTPAGE:
         case SID_INSERTPAGE_QUICK:
-        case SID_DUPLICATE_PAGE:
         {
             SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
             Cancel();
@@ -766,6 +773,16 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         }
         break;
 
+        case SID_DUPLICATE_PAGE:
+        {
+            DuplicateSelectedSlides(rReq);
+            Cancel();
+            if(HasCurrentFunction(SID_BEZIER_EDIT) )
+                GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
+            rReq.Done();
+        }
+        break;
+
         case SID_INSERT_MASTER_PAGE:
         {
             // Use the API to create a new page.
@@ -3604,6 +3621,56 @@ SdPage* DrawViewShell::CreateOrDuplicatePage (
     return pNewPage;
 }
 
+void DrawViewShell::DuplicateSelectedSlides (SfxRequest& rRequest)
+{
+    // Create a list of the pages that are to be duplicated.  The process of
+    // duplication alters the selection.
+    sal_Int32 nInsertPosition (0);
+    ::std::vector<SdPage*> aPagesToDuplicate;
+    sd::slidesorter::SlideSorter &mrSlideSorter = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase())->GetSlideSorter();
+    sd::slidesorter::model::PageEnumeration aSelectedPages (
+        sd::slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel()));
+    while (aSelectedPages.HasMoreElements())
+    {
+        sd::slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
+        if (pDescriptor && pDescriptor->GetPage())
+        {
+            aPagesToDuplicate.push_back(pDescriptor->GetPage());
+            nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2;
+        }
+    }
+
+    // Duplicate the pages in aPagesToDuplicate and collect the newly
+    // created pages in aPagesToSelect.
+    const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled());
+    if (bUndo)
+        mrSlideSorter.GetView().BegUndo(SdResId(STR_INSERTPAGE));
+
+    ::std::vector<SdPage*> aPagesToSelect;
+    for(::std::vector<SdPage*>::const_iterator
+            iPage(aPagesToDuplicate.begin()),
+            iEnd(aPagesToDuplicate.end());
+        iPage!=iEnd;
+        ++iPage, nInsertPosition+=2)
+    {
+        aPagesToSelect.push_back(
+            mrSlideSorter.GetViewShell()->CreateOrDuplicatePage(
+                rRequest, PageKind::Standard, *iPage, nInsertPosition));
+    }
+    aPagesToDuplicate.clear();
+
+    if (bUndo)
+        mrSlideSorter.GetView().EndUndo();
+
+    // Set the selection to the pages in aPagesToSelect.
+    sd::slidesorter::controller::PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
+    rSelector.DeselectAllPages();
+    for (auto const& it: aPagesToSelect)
+    {
+        rSelector.SelectPage(it);
+    }
+}
+
 void DrawViewShell::ExecutePropPanelAttr (SfxRequest const & rReq)
 {
     if(SlideShow::IsRunning( GetViewShellBase() ))


More information about the Libreoffice-commits mailing list