diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2020-05-26 21:15:15 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2020-06-25 08:11:10 +0200 |
commit | 31a76d64ff91d4dd8606890a8996a6c4400e1c0c (patch) | |
tree | 34a9ce5fe5388af7f1ff828c08b4d9511891b579 /sd/source/ui/view/drviews2.cxx | |
parent | 4acb7b9249206aadaf4617a2abf3ac6d57d62079 (diff) |
LOK: duplicating multiple slides
Change-Id: Ic2e870bf2ec3b236e2babf6c090bf3ec1978776e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94817
Tested-by: Jenkins
Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Diffstat (limited to 'sd/source/ui/view/drviews2.cxx')
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 69 |
1 files changed, 68 insertions, 1 deletions
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() )) |