[Libreoffice-commits] core.git: sd/source
Pranam Lashkari (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 25 06:11:43 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 31a76d64ff91d4dd8606890a8996a6c4400e1c0c
Author: Pranam Lashkari <lpranam at collabora.com>
AuthorDate: Tue May 26 21:15:15 2020 +0530
Commit: Pranam Lashkari <lpranam at collabora.com>
CommitDate: Thu Jun 25 08:11:10 2020 +0200
LOK: duplicating multiple slides
Change-Id: Ic2e870bf2ec3b236e2babf6c090bf3ec1978776e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94817
Tested-by: Jenkins
Reviewed-by: Pranam Lashkari <lpranam at collabora.com>
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index e5e6b94b645a..5213c25f4c91 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -450,6 +450,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 c839b79e3fb9..79962d9dbc28 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -180,6 +180,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>
@@ -744,7 +752,6 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
case SID_INSERTPAGE:
case SID_INSERTPAGE_QUICK:
- case SID_DUPLICATE_PAGE:
{
SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
Cancel();
@@ -756,6 +763,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.
@@ -3757,6 +3774,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