LibreOffice Module sd (master) 1
SlideSorterViewShell.cxx
Go to the documentation of this file.
1#/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22
23#include <SlideSorter.hxx>
32#include <view/SlsLayouter.hxx>
36#include <ViewShellBase.hxx>
37#include <drawdoc.hxx>
38#include <sdpage.hxx>
39#include <app.hrc>
41#include <DrawDocShell.hxx>
42#include <DrawViewShell.hxx>
43#include <FrameView.hxx>
44#include <SdUnoSlideView.hxx>
45#include <ViewShellManager.hxx>
46#include <Window.hxx>
47#include <drawview.hxx>
48#include <sfx2/msg.hxx>
49#include <sfx2/objface.hxx>
50#include <sfx2/viewfrm.hxx>
51#include <sfx2/bindings.hxx>
52#include <sfx2/request.hxx>
55#include <svx/svxids.hrc>
56#include <vcl/EnumContext.hxx>
60
61using namespace ::sd::slidesorter;
62#define ShellClass_SlideSorterViewShell
63#include <sdslots.hxx>
64
65using namespace ::com::sun::star;
66using namespace ::com::sun::star::uno;
68
69using ::sd::framework::FrameworkHelper;
70using ::vcl::EnumContext;
71using namespace sfx2::sidebar;
72
73namespace sd::slidesorter {
74
75namespace {
76
77bool inChartOrMathContext(const sd::View* pView)
78{
79 if (!pView)
80 return false;
81
82 SfxViewShell* pViewShell = pView->GetSfxViewShell();
83 SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
84 if (pSidebar)
85 return pSidebar->hasChartOrMathContextCurrently();
86
87 return false;
88}
89
90} // anonymous namespace
91
92
93SFX_IMPL_INTERFACE(SlideSorterViewShell, SfxShell)
94
95void SlideSorterViewShell::InitInterface_Impl()
96{
97 GetStaticInterface()->RegisterChildWindow(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
98 GetStaticInterface()->RegisterChildWindow(DevelopmentToolChildWindow::GetChildWindowId());
99}
100
101
102std::shared_ptr<SlideSorterViewShell> SlideSorterViewShell::Create (
103 SfxViewFrame* pFrame,
104 ViewShellBase& rViewShellBase,
105 vcl::Window* pParentWindow,
106 FrameView* pFrameViewArgument)
107{
108 std::shared_ptr<SlideSorterViewShell> pViewShell;
109 try
110 {
111 pViewShell.reset(
112 new SlideSorterViewShell(pFrame,rViewShellBase,pParentWindow,pFrameViewArgument));
113 pViewShell->Initialize();
114 if (pViewShell->mpSlideSorter == nullptr)
115 pViewShell.reset();
116 }
117 catch(Exception&)
118 {
119 pViewShell.reset();
120 }
121 return pViewShell;
122}
123
125 SfxViewFrame* /*pFrame*/,
126 ViewShellBase& rViewShellBase,
127 vcl::Window* pParentWindow,
128 FrameView* pFrameViewArgument)
129 : ViewShell (pParentWindow, rViewShellBase),
130 mbIsArrangeGUIElementsPending(true)
131{
132 GetContentWindow()->set_id("slidesorter");
134
135 if (pFrameViewArgument != nullptr)
136 mpFrameView = pFrameViewArgument;
137 else
140
141 SetName ("SlideSorterViewShell");
142
143 pParentWindow->SetStyle(pParentWindow->GetStyle() | WB_DIALOGCONTROL);
144}
145
147{
149
150 try
151 {
152 ::sd::Window* pWindow = GetActiveWindow();
153 if (pWindow!=nullptr)
154 {
155 css::uno::Reference<css::lang::XComponent> xComponent (
156 pWindow->GetAccessible(false),
157 css::uno::UNO_QUERY);
158 if (xComponent.is())
159 xComponent->dispose();
160 }
161 }
162 catch( css::uno::Exception& )
163 {
164 TOOLS_WARN_EXCEPTION( "sd", "sd::SlideSorterViewShell::~SlideSorterViewShell()" );
165 }
167}
168
170{
172 *this,
176 mpView = &mpSlideSorter->GetView();
177
178 doShow();
179
180 SetPool( &GetDoc()->GetPool() );
182
183 // For accessibility we have to shortly hide the content window.
184 // This triggers the construction of a new accessibility object for
185 // the new view shell. (One is created earlier while the constructor
186 // of the base class is executed. At that time the correct
187 // accessibility object can not be constructed.)
188 sd::Window *pWindow (mpSlideSorter->GetContentWindow().get());
189 if (pWindow)
190 {
191 pWindow->Hide();
192 pWindow->Show();
193 }
194}
195
196void SlideSorterViewShell::Init (bool bIsMainViewShell)
197{
198 ViewShell::Init(bIsMainViewShell);
199
200 // since the updatePageList will show focus, the window.show() must be called ahead. This show is deferred from Init()
201 ::sd::Window* pActiveWindow = GetActiveWindow();
202 if (pActiveWindow)
203 pActiveWindow->Show();
204 mpSlideSorter->GetModel().UpdatePageList();
205
206 if (mpContentWindow)
207 mpContentWindow->SetViewShell(this);
208}
209
211{
212 SlideSorterViewShell* pViewShell = nullptr;
213
214 // Test the center and left pane for showing a slide sorter.
215 OUString aPaneURLs[] = {
216 FrameworkHelper::msCenterPaneURL,
218 FrameworkHelper::msLeftImpressPaneURL,
219 FrameworkHelper::msLeftDrawPaneURL,
220 OUString()};
221
222 try
223 {
224 std::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rBase));
225 if (pFrameworkHelper->IsValid())
226 for (int i=0; pViewShell==nullptr && !aPaneURLs[i].isEmpty(); ++i)
227 {
228 pViewShell = dynamic_cast<SlideSorterViewShell*>(
229 pFrameworkHelper->GetViewShell(aPaneURLs[i]).get());
230 }
231 }
232 catch (RuntimeException&)
233 {}
234
235 return pViewShell;
236}
237
238Reference<drawing::XDrawSubController> SlideSorterViewShell::CreateSubController()
239{
240 Reference<drawing::XDrawSubController> xSubController;
241
242 if (IsMainViewShell())
243 {
244 // Create uno controller for the main view shell.
245 xSubController.set( new SdUnoSlideView( *mpSlideSorter));
246 }
247
248 return xSubController;
249}
250
256css::uno::Reference<css::accessibility::XAccessible>
258{
259 // When the view is not set then the initialization is not yet complete
260 // and we can not yet provide an accessibility object.
261 if (mpView == nullptr || mpSlideSorter == nullptr)
262 return nullptr;
263
264 assert(mpSlideSorter);
265
267 new ::accessibility::AccessibleSlideSorterView(
269 pWindow);
270
271 pAccessibleView->Init();
272
273 return pAccessibleView;
274}
275
276void SlideSorterViewShell::SwitchViewFireFocus(const css::uno::Reference< css::accessibility::XAccessible >& xAcc )
277{
278 if (xAcc)
279 {
281 if (pBase)
282 {
283 pBase->SwitchViewActivated();
284 }
285 }
286}
287
289{
290 assert(mpSlideSorter);
291 return *mpSlideSorter;
292}
293
295{
296 assert(mpSlideSorter);
297 if ( ! mpSlideSorter)
298 return false;
299
300 mpSlideSorter->RelocateToWindow(pParentWindow);
302
303 return true;
304}
305
307{
308 SfxShell* pObjectBar = GetViewShellBase().GetViewShellManager()->GetTopShell();
309 if (pObjectBar != nullptr)
310 {
311 // When it exists then return the undo manager of the currently
312 // active object bar. The object bar is missing when the
313 // SlideSorterViewShell is not the main view shell.
314 return pObjectBar->GetUndoManager();
315 }
316 else
317 {
318 // Return the undo manager of this shell when there is no object or
319 // tool bar.
320 return const_cast<SlideSorterViewShell*>(this)->GetUndoManager();
321 }
322}
323
325{
326 // since SlideSorterViewShell::GetActualPage() currently also
327 // returns master pages, which is a wrong behaviour for GetActualPage(),
328 // we can just use that for now
329 return const_cast<SlideSorterViewShell*>(this)->GetActualPage();
330}
331
333{
334 SdPage* pCurrentPage = nullptr;
335
336 // 1. Try to get the current page from the view shell in the center pane
337 // (if we are that not ourself).
338 if ( ! IsMainViewShell())
339 {
340 std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
341 if (pMainViewShell != nullptr)
342 pCurrentPage = pMainViewShell->GetActualPage();
343 }
344
345 if (pCurrentPage == nullptr)
346 {
347 model::SharedPageDescriptor pDescriptor (
348 mpSlideSorter->GetController().GetCurrentSlideManager()->GetCurrentSlide());
349 if (pDescriptor)
350 pCurrentPage = pDescriptor->GetPage();
351 }
352
353 return pCurrentPage;
354}
355
357{
359 assert(mpSlideSorter);
360 mpSlideSorter->GetController().GetSlotManager()->GetMenuState(rSet);
361}
362
364{
366 assert(mpSlideSorter);
367 mpSlideSorter->GetController().GetSlotManager()->GetClipboardState(rSet);
368}
369
371{
372 assert(mpSlideSorter);
373 mpSlideSorter->GetController().ExecCtrl(rRequest);
374}
375
377{
378 assert(mpSlideSorter);
379 mpSlideSorter->GetController().GetCtrlState(rSet);
380}
381
383{
384 assert(mpSlideSorter);
385 mpSlideSorter->GetController().FuSupport(rRequest);
386}
387
392{
393 assert(mpSlideSorter);
394 switch (rRequest.GetSlot())
395 {
396 case SID_MODIFYPAGE:
397 {
398 SdPage* pCurrentPage = GetActualPage();
399 if (pCurrentPage != nullptr)
400 mpImpl->ProcessModifyPageSlot (
401 rRequest,
402 pCurrentPage,
404 Cancel();
405 rRequest.Done ();
406 }
407 break;
408
409 default:
410 mpSlideSorter->GetController().FuTemporary(rRequest);
411 break;
412 }
413}
414
416{
417 assert(mpSlideSorter);
418 mpSlideSorter->GetController().GetStatusBarState(rSet);
419}
420
422{
423 assert(mpSlideSorter);
424 mpSlideSorter->GetController().FuPermanent(rRequest);
425}
426
428{
429 assert(mpSlideSorter);
430 mpSlideSorter->GetController().GetAttrState(rSet);
431}
432
434{
435}
436
438 const ::tools::Rectangle& rBBox,
439 ::sd::Window* pWindow)
440{
441 SetActiveWindow (pWindow);
442 assert(mpSlideSorter);
443 if (mpSlideSorter)
444 mpSlideSorter->GetController().Paint(rBBox,pWindow);
445}
446
448{
449 if (IsActive())
450 {
451 assert(mpSlideSorter);
452 mpSlideSorter->ArrangeGUIElements(maViewPos, maViewSize);
454 }
455 else
457}
458
459void SlideSorterViewShell::Activate (bool bIsMDIActivate)
460{
461 if(inChartOrMathContext(GetView()))
462 {
463 // Avoid context changes for chart/math during activation / deactivation.
464 const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
465
466 ViewShell::Activate(bIsMDIActivate);
467
468 SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
469 return;
470 }
471
472 ViewShell::Activate(bIsMDIActivate);
475
476 // Determine and broadcast the context that belongs to the main view shell.
477 EnumContext::Context eContext = EnumContext::Context::Unknown;
478 std::shared_ptr<ViewShell> pMainViewShell (GetViewShellBase().GetMainViewShell());
479 ViewShell::ShellType eMainViewShellType (
480 pMainViewShell
481 ? pMainViewShell->GetShellType()
483 switch (eMainViewShellType)
484 {
489 eContext = EnumContext::Context::DrawPage;
490 if( nullptr != dynamic_cast< const DrawViewShell *>( pMainViewShell.get() ))
491 {
492 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pMainViewShell.get());
493 if (pDrawViewShell != nullptr)
494 eContext = EnumContext::GetContextEnum(pDrawViewShell->GetSidebarContextName());
495 }
496 break;
497
498 default:
499 break;
500 }
503 eContext);
504}
505
506void SlideSorterViewShell::Deactivate (bool /*bIsMDIActivate*/)
507{
508 // Save Settings - Specifically SlidesPerRow to retrieve it later
510}
511
513 const CommandEvent& rEvent,
514 ::sd::Window* pWindow)
515{
516 assert(mpSlideSorter);
517 if ( ! mpSlideSorter->GetController().Command (rEvent, pWindow))
518 ViewShell::Command (rEvent, pWindow);
519}
520
522{
523 assert(mpSlideSorter);
524 if (pFrameView != nullptr)
525 {
526 view::SlideSorterView& rView (mpSlideSorter->GetView());
527
528 sal_uInt16 nSlidesPerRow (pFrameView->GetSlidesPerRow());
529 if (nSlidesPerRow > 0
531 && IsMainViewShell())
532 {
533 rView.GetLayouter().SetColumnCount(nSlidesPerRow,nSlidesPerRow);
534 }
535 if (IsMainViewShell())
536 mpSlideSorter->GetController().GetCurrentSlideManager()->NotifyCurrentSlideChange(
538 mpSlideSorter->GetController().Rearrange(true);
539
540 // DrawMode for 'main' window
541 if (GetActiveWindow()->GetOutDev()->GetDrawMode() != pFrameView->GetDrawMode() )
542 GetActiveWindow()->GetOutDev()->SetDrawMode( pFrameView->GetDrawMode() );
543 }
544
545 // When this slide sorter is not displayed in the main window then we do
546 // not share the same frame view and have to find other ways to acquire
547 // certain values.
548 if ( ! IsMainViewShell())
549 {
550 std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
551 if (pMainViewShell != nullptr)
552 mpSlideSorter->GetController().GetCurrentSlideManager()->NotifyCurrentSlideChange(
553 pMainViewShell->getCurrentPage());
554 }
555}
556
558{
559 assert(mpSlideSorter);
560 if (mpFrameView == nullptr)
561 return;
562
563 view::SlideSorterView& rView (mpSlideSorter->GetView());
564 mpFrameView->SetSlidesPerRow(static_cast<sal_uInt16>(rView.GetLayouter().GetColumnCount()));
565
566 // DrawMode for 'main' window
567 if( mpFrameView->GetDrawMode() != GetActiveWindow()->GetOutDev()->GetDrawMode() )
568 mpFrameView->SetDrawMode( GetActiveWindow()->GetOutDev()->GetDrawMode() );
569
570 SdPage* pActualPage = GetActualPage();
571 if (pActualPage != nullptr)
572 {
573 if (IsMainViewShell())
574 mpFrameView->SetSelectedPage((pActualPage->GetPageNum()- 1) / 2);
575 // else
576 // The slide sorter is not expected to switch the current page
577 // other than by double clicks. That is handled separately.
578 }
579 else
580 {
581 // We have no current page to set but at least we can make sure
582 // that the index of the frame view has a legal value.
583 if (mpFrameView->GetSelectedPage() >= mpSlideSorter->GetModel().GetPageCount())
584 mpFrameView->SetSelectedPage(static_cast<sal_uInt16>(mpSlideSorter->GetModel().GetPageCount())-1);
585 }
586}
587
589{
590 // Ignored.
591 // The zoom scale is adapted internally to fit a number of columns in
592 // the window.
593}
594
595void SlideSorterViewShell::SetZoomRect (const ::tools::Rectangle& rZoomRect)
596{
597 assert(mpSlideSorter);
598 Size aPageSize (mpSlideSorter->GetView().GetLayouter().GetPageObjectSize());
599
600 ::tools::Rectangle aRect(rZoomRect);
601
602 if (aRect.GetWidth() < aPageSize.Width())
603 {
604 ::tools::Long nWidthDiff = (aPageSize.Width() - aRect.GetWidth()) / 2;
605
606 aRect.AdjustLeft( -nWidthDiff );
607 aRect.AdjustRight(nWidthDiff );
608
609 if (aRect.Left() < 0)
610 {
611 aRect.SetPos(Point(0, aRect.Top()));
612 }
613 }
614
615 if (aRect.GetHeight() < aPageSize.Height())
616 {
617 ::tools::Long nHeightDiff = (aPageSize.Height() - aRect.GetHeight()) / 2;
618
619 aRect.AdjustTop( -nHeightDiff );
620 aRect.AdjustBottom(nHeightDiff );
621
622 if (aRect.Top() < 0)
623 {
624 aRect.SetPos(Point(aRect.Left(), 0));
625 }
626 }
627
629
630 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
631 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
632}
633
635{
636 // Do not call the overwritten method of the base class: We do all the
637 // scroll bar setup by ourselves.
638 mpSlideSorter->GetController().GetScrollBarManager().UpdateScrollBars(true);
639}
640
642 const Point& rDragPt,
643 vcl::Window* pWindow )
644{
645 assert(mpSlideSorter);
646 mpSlideSorter->GetController().GetClipboard().StartDrag (
647 rDragPt,
648 pWindow);
649}
650
652 const AcceptDropEvent& rEvt,
653 DropTargetHelper& rTargetHelper,
654 ::sd::Window* pTargetWindow,
655 sal_uInt16 nPage,
656 SdrLayerID nLayer)
657{
658 assert(mpSlideSorter);
659 return mpSlideSorter->GetController().GetClipboard().AcceptDrop (
660 rEvt,
661 rTargetHelper,
662 pTargetWindow,
663 nPage,
664 nLayer);
665}
666
668 const ExecuteDropEvent& rEvt,
669 DropTargetHelper& rTargetHelper,
670 ::sd::Window* pTargetWindow,
671 sal_uInt16 nPage,
672 SdrLayerID nLayer)
673{
674 assert(mpSlideSorter);
675 return mpSlideSorter->GetController().GetClipboard().ExecuteDrop (
676 rEvt,
677 rTargetHelper,
678 pTargetWindow,
679 nPage,
680 nLayer);
681}
682
683std::shared_ptr<SlideSorterViewShell::PageSelection>
685{
686 assert(mpSlideSorter);
687 return mpSlideSorter->GetController().GetPageSelector().GetPageSelection();
688}
689
691 const std::shared_ptr<PageSelection>& rSelection)
692{
693 assert(mpSlideSorter);
694 mpSlideSorter->GetController().GetPageSelector().SetPageSelection(rSelection, true);
695}
696
698 const Link<LinkParamNone*,void>& rCallback)
699{
700 assert(mpSlideSorter);
701 mpSlideSorter->GetController().GetSelectionManager()->AddSelectionChangeListener(rCallback);
702}
703
705 const Link<LinkParamNone*,void>& rCallback)
706{
707 assert(mpSlideSorter);
708 mpSlideSorter->GetController().GetSelectionManager()->RemoveSelectionChangeListener(rCallback);
709}
710
712{
713 std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
714 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pMainViewShell.get());
715 SdrView* pView = pDrawViewShell ? pDrawViewShell->GetDrawView() : nullptr;
716 if (pView)
717 {
718 pView->SdrEndTextEdit();
719 pView->UnmarkAll();
720 }
721}
722
723std::pair<sal_uInt16, sal_uInt16> SlideSorterViewShell::SyncPageSelectionToDocument(const std::shared_ptr<SlideSorterViewShell::PageSelection> &rpSelection)
724{
725 sal_uInt16 firstSelectedPageNo = SAL_MAX_UINT16;
726 sal_uInt16 lastSelectedPageNo = 0;
727
729 for (auto& rpPage : *rpSelection)
730 {
731 // Check page number
732 sal_uInt16 pageNo = rpPage->GetPageNum();
733 if (pageNo > lastSelectedPageNo)
734 lastSelectedPageNo = pageNo;
735 if (pageNo < firstSelectedPageNo)
736 firstSelectedPageNo = pageNo;
737 GetDoc()->SetSelected(rpPage, true);
738 }
739
740 return std::make_pair(firstSelectedPageNo, lastSelectedPageNo);
741}
742
744{
746
747 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
748
749 // SdDrawDocument MovePages is based on SdPage IsSelected, so
750 // transfer the SlideSorter selection to SdPages
751 SyncPageSelectionToDocument(xSelection);
752
753 // Moves selected pages after page -1
754 GetDoc()->MovePages( sal_uInt16(-1) );
755
756 PostMoveSlidesActions(xSelection);
757}
758
760{
761 if ( ! IsMainViewShell())
762 {
763 std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
764 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pMainViewShell.get());
765 if (pDrawViewShell != nullptr && pDrawViewShell->GetPageKind() == PageKind::Handout)
766 {
767 rSet.DisableItem( SID_MOVE_PAGE_FIRST );
768 rSet.DisableItem( SID_MOVE_PAGE_UP );
769 return;
770 }
771 }
772
773 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
774
775 // SdDrawDocument MovePages is based on SdPage IsSelected, so
776 // transfer the SlideSorter selection to SdPages
777 sal_uInt16 firstSelectedPageNo = SyncPageSelectionToDocument(xSelection).first;
778 // Now compute human page number from internal page number
779 firstSelectedPageNo = (firstSelectedPageNo - 1) / 2;
780
781 if (firstSelectedPageNo == 0)
782 {
783 rSet.DisableItem( SID_MOVE_PAGE_FIRST );
784 rSet.DisableItem( SID_MOVE_PAGE_UP );
785 }
786}
787
789{
791
792 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
793
794 // SdDrawDocument MovePages is based on SdPage IsSelected, so
795 // transfer the SlideSorter selection to SdPages
796 sal_uInt16 firstSelectedPageNo = SyncPageSelectionToDocument(xSelection).first;
797
798 // In case no slide is selected
799 if (firstSelectedPageNo == SAL_MAX_UINT16)
800 return;
801
802 // Now compute human page number from internal page number
803 firstSelectedPageNo = (firstSelectedPageNo - 1) / 2;
804
805 if (firstSelectedPageNo == 0)
806 return;
807
808 // Move pages before firstSelectedPageNo - 1 (so after firstSelectedPageNo - 2),
809 // remembering that -1 means at first, which is good.
810 GetDoc()->MovePages( firstSelectedPageNo - 2 );
811
812 PostMoveSlidesActions(xSelection);
813}
814
816{
818}
819
821{
823
824 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
825
826 // SdDrawDocument MovePages is based on SdPage IsSelected, so
827 // transfer the SlideSorter selection to SdPages
828 sal_uInt16 lastSelectedPageNo = SyncPageSelectionToDocument(xSelection).second;
829
830 // Get page number of the last page
831 sal_uInt16 nNoOfPages = GetDoc()->GetSdPageCount(PageKind::Standard);
832
833 // Now compute human page number from internal page number
834 lastSelectedPageNo = (lastSelectedPageNo - 1) / 2;
835 if (lastSelectedPageNo == nNoOfPages - 1)
836 return;
837
838 // Move to position after lastSelectedPageNo
839 GetDoc()->MovePages( lastSelectedPageNo + 1 );
840
841 PostMoveSlidesActions(xSelection);
842}
843
845{
847}
848
850{
852
853 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
854
855 // SdDrawDocument MovePages is based on SdPage IsSelected, so
856 // transfer the SlideSorter selection to SdPages
857 SyncPageSelectionToDocument(xSelection);
858
859 // Get page number of the last page
860 sal_uInt16 nNoOfPages = GetDoc()->GetSdPageCount(PageKind::Standard);
861
862 // Move to position after last page No (=Number of pages - 1)
863 GetDoc()->MovePages( nNoOfPages - 1 );
864
865 PostMoveSlidesActions(xSelection);
866}
867
869{
870 std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
871 DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(pMainViewShell.get());
872 if (pDrawViewShell != nullptr && pDrawViewShell->GetPageKind() == PageKind::Handout)
873 {
874 rSet.DisableItem( SID_MOVE_PAGE_LAST );
875 rSet.DisableItem( SID_MOVE_PAGE_DOWN );
876 return;
877 }
878
879 std::shared_ptr<SlideSorterViewShell::PageSelection> xSelection(GetPageSelection());
880
881 // SdDrawDocument MovePages is based on SdPage IsSelected, so
882 // transfer the SlideSorter selection to SdPages
883 sal_uInt16 lastSelectedPageNo = SyncPageSelectionToDocument(xSelection).second;
884
885 // Get page number of the last page
886 sal_uInt16 nNoOfPages = GetDoc()->GetSdPageCount(PageKind::Standard);
887
888 // Now compute human page number from internal page number
889 lastSelectedPageNo = (lastSelectedPageNo - 1) / 2;
890 if (lastSelectedPageNo == nNoOfPages - 1)
891 {
892 rSet.DisableItem( SID_MOVE_PAGE_LAST );
893 rSet.DisableItem( SID_MOVE_PAGE_DOWN );
894 }
895}
896
897void SlideSorterViewShell::PostMoveSlidesActions(const std::shared_ptr<SlideSorterViewShell::PageSelection> &rpSelection)
898{
899 sal_uInt16 nNoOfPages = GetDoc()->GetSdPageCount(PageKind::Standard);
900 for (sal_uInt16 nPage = 0; nPage < nNoOfPages; nPage++)
901 {
902 SdPage* pPage = GetDoc()->GetSdPage(nPage, PageKind::Standard);
903 GetDoc()->SetSelected(pPage, false);
904 }
905
906 mpSlideSorter->GetController().GetPageSelector().DeselectAllPages();
907 for (const auto& rpPage : *rpSelection)
908 {
909 mpSlideSorter->GetController().GetPageSelector().SelectPage(rpPage);
910 }
911
912 // Refresh toolbar icons
913 SfxBindings& rBindings = GetViewFrame()->GetBindings();
914 rBindings.Invalidate(SID_MOVE_PAGE_FIRST);
915 rBindings.Invalidate(SID_MOVE_PAGE_UP);
916 rBindings.Invalidate(SID_MOVE_PAGE_DOWN);
917 rBindings.Invalidate(SID_MOVE_PAGE_LAST);
918
919}
920
921} // end of namespace ::sd::slidesorter
922
923/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void NotifyContextChange(const css::uno::Reference< css::frame::XController > &rxController, const vcl::EnumContext::Context eContext)
void SetDrawMode(DrawModeFlags nDrawMode)
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
Definition: drawdoc2.cxx:207
SAL_DLLPRIVATE bool MovePages(sal_uInt16 nTargetPage)
Definition: drawdoc2.cxx:726
SAL_DLLPRIVATE void UnselectAllPages()
Definition: drawdoc2.cxx:713
SAL_DLLPRIVATE void SetSelected(SdPage *pPage, bool bSelect)
Definition: drawdoc2.cxx:461
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
Definition: drawdoc2.cxx:212
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
sal_uInt16 GetPageNum() const
void UnmarkAll()
void Invalidate(sal_uInt16 nId)
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void Done(bool bRemove=false)
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
SfxItemPool & GetPool() const
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
virtual SfxUndoManager * GetUndoManager()
bool IsActive() const
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
SfxBindings & GetBindings()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
This class makes the SlideSorterViewShell accessible.
Base class of the stacked shells that provide graphical views to Draw and Impress documents and editi...
OUString const & GetSidebarContextName() const
Definition: drviewsa.cxx:773
DrawView * GetDrawView() const
PageKind GetPageKind() const
View for MDIFrame.
Definition: FrameView.hxx:36
sal_uInt16 GetSelectedPage() const
Definition: FrameView.hxx:96
void SetDrawMode(DrawModeFlags nNewDrawMode)
Definition: FrameView.hxx:159
void Connect()
Definition: frmview.cxx:256
sal_uInt16 GetSlidesPerRow() const
Definition: FrameView.hxx:157
void SetSlidesPerRow(sal_uInt16 nSlides)
Definition: FrameView.hxx:156
void Disconnect()
Definition: frmview.cxx:261
void SetSelectedPage(sal_uInt16 nPage)
Definition: frmview.cxx:907
DrawModeFlags GetDrawMode() const
Definition: FrameView.hxx:160
This class implements the SlideSorter specific part of the controller.
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
std::shared_ptr< ViewShellManager > const & GetViewShellManager() const
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC DrawDocShell * GetDocSh() const
Definition: viewshel.cxx:1407
VclPtr< ScrollAdaptor > mpVerticalScrollBar
Vertical scroll bar for whole document is always visible.
Definition: ViewShell.hxx:439
bool IsMainViewShell() const
Return <TRUE> when the called view shell is the main sub shell of its ViewShellBase object,...
Definition: viewshel.cxx:1493
FrameView * mpFrameView
Definition: ViewShell.hxx:453
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
std::unique_ptr< Implementation, o3tl::default_delete< Implementation > > mpImpl
Definition: ViewShell.hxx:485
void GetMenuState(SfxItemSet &rSet)
set state (enabled/disabled) of Menu SfxSlots
Definition: viewshe3.cxx:61
virtual void Command(const CommandEvent &rCEvt, ::sd::Window *pWin)
Definition: viewshel.cxx:621
void DisposeFunctions()
must be called in the beginning of each subclass d'tor.
Definition: viewshel.cxx:1475
ShellType meShellType
The type of the shell. Returned by GetShellType().
Definition: ViewShell.hxx:483
void SetActiveWindow(::sd::Window *pWindow)
Set the active window.
Definition: viewshe2.cxx:549
FrameView * GetFrameView()
Definition: ViewShell.hxx:221
virtual void Init(bool bIsMainViewShell)
The Init method has to be called from the outside directly after a new object of this class has been ...
Definition: viewshel.cxx:261
::sd::Window * GetActiveWindow() const
The active window is usually the mpContentWindow.
Definition: ViewShell.hxx:155
::sd::View * GetView() const
Definition: ViewShell.hxx:144
virtual void SetZoomRect(const ::tools::Rectangle &rZoomRect)
Set zoom rectangle for active window.
Definition: viewshe2.cxx:358
::sd::View * mpView
Definition: ViewShell.hxx:452
void Cancel()
this method deactivates the current function.
Definition: viewshel.cxx:1442
virtual void Activate(bool IsMDIActivate) override
set focus to working window
Definition: viewshel.cxx:289
VclPtr< sd::Window > mpContentWindow
Window inside the rulers and scroll bars that shows a view of the document.
Definition: ViewShell.hxx:434
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
void doShow()
This must be called after the ctor, but before anything else.
Definition: viewshel.cxx:238
VclPtr< ScrollAdaptor > mpHorizontalScrollBar
Horizontal scroll bar for the current slide is displayed when needed.
Definition: ViewShell.hxx:437
sd::Window * GetContentWindow() const
Definition: viewshel.cxx:1587
SfxViewShell * GetSfxViewShell() const override
Definition: sdview.cxx:639
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
virtual bool RelocateToParentWindow(vcl::Window *pParentWindow) override
Try to relocate all toplevel window elements to the given parent window.
virtual void SetZoomRect(const ::tools::Rectangle &rZoomRect) override
Set zoom rectangle for active window.
std::pair< sal_uInt16, sal_uInt16 > SyncPageSelectionToDocument(const std::shared_ptr< SlideSorterViewShell::PageSelection > &rpSelection)
Select the same pages in the document as are selected in the SlideSorterViewShell.
virtual void Command(const CommandEvent &rEvent, ::sd::Window *pWindow) override
void AddSelectionChangeListener(const Link< LinkParamNone *, void > &rListener)
Add a listener that is called when the selection of the slide sorter changes.
virtual void SwitchViewFireFocus(const css::uno::Reference< css::accessibility::XAccessible > &xAcc) override
virtual void Paint(const ::tools::Rectangle &rRect, ::sd::Window *pWin) override
This is a callback method used by the active window to delegate its Paint() call to.
SD_DLLPUBLIC SlideSorter & GetSlideSorter() const
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer) override
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleDocumentView(::sd::Window *pWindow) override
Create an accessible object representing the specified window.
virtual void UpdateScrollBars() override
This method overwrites the one from our base class: We do our own scroll bar and the base class call ...
static void ExecStatusBar(SfxRequest &rRequest)
void FuTemporary(SfxRequest &rRequest)
We have to handle those slot calls here that need to have access to private or protected members and ...
void PostMoveSlidesActions(const std::shared_ptr< SlideSorterViewShell::PageSelection > &rpSelection)
virtual void SetZoom(::tools::Long nZoom) override
Set the zoom factor.
virtual void ArrangeGUIElements() override
Place and size the controls and windows.
virtual SdPage * getCurrentPage() const override
inherited from sd::ViewShell
void StartDrag(const Point &rDragPt, vcl::Window *pWindow)
SlideSorterViewShell(SfxViewFrame *pFrame, ViewShellBase &rViewShellBase, vcl::Window *pParentWindow, FrameView *pFrameView)
virtual void Init(bool bIsMainViewShell) override
Late initialization that has to be called after a new instance has completed its construction.
static std::shared_ptr< SlideSorterViewShell > Create(SfxViewFrame *pFrame, ViewShellBase &rViewShellBase, vcl::Window *pParentWindow, FrameView *pFrameView)
virtual void ReadFrameViewData(FrameView *pView) override
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt, DropTargetHelper &rTargetHelper, ::sd::Window *pTargetWindow, sal_uInt16 nPage, SdrLayerID nLayer) override
virtual css::uno::Reference< css::drawing::XDrawSubController > CreateSubController() override
Return a sub controller that implements the view shell specific part of the DrawController.
void ExecMovePageUp(SfxRequest &rReq)
Move slides up and down.
virtual void Activate(bool IsMDIActivate) override
set focus to working window
std::shared_ptr< SlideSorter > mpSlideSorter
virtual void Deactivate(bool IsMDIActivate) override
void SetPageSelection(const std::shared_ptr< PageSelection > &rSelection)
void RemoveSelectionChangeListener(const Link< LinkParamNone *, void > &rListener)
Remove a listener that was called when the selection of the slide sorter changes.
std::shared_ptr< PageSelection > GetPageSelection() const
Return the set of selected pages.
virtual SfxUndoManager * ImpGetUndoManager() const override
Override this method to handle a missing tool bar correctly.
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
static std::shared_ptr< SlideSorter > CreateSlideSorter(ViewShell &rViewShell, sd::Window *pContentWindow, ScrollAdaptor *pHorizontalScrollBar, ScrollAdaptor *pVerticalScrollBar)
Create a new slide sorter that is strongly coupled to the given view shell.
Definition: SlideSorter.cxx:48
void SetColumnCount(sal_Int32 nMinimalColumnCount, sal_Int32 nMaximalColumnCount)
Set the interval of valid column counts.
sal_Int32 GetColumnCount() const
Return the number of columns.
Layouter::Orientation GetOrientation() const
bool hasChartOrMathContextCurrently() const
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
void SetPos(const Point &rPoint)
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr tools::Long GetHeight() const
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
void SetStyle(WinBits nStyle)
void set_id(const OUString &rID)
WinBits GetStyle() const
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
::OutputDevice const * GetOutDev() const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
#define TOOLS_WARN_EXCEPTION(area, stream)
@ Exception
int i
std::shared_ptr< PageDescriptor > SharedPageDescriptor
long Long
static SfxItemSet & rSet
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define SAL_MAX_UINT16
signed char sal_Int8
WinBits const WB_DIALOGCONTROL