From e226c19e9136dda366c1485a9d53a0c5d433387c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 17 May 2016 16:25:17 +0100 Subject: give this tremendously useful snippet a descriptive name and de-duplicate it This is the magic smoke which sets the right selection on an undo of move slides when the slidesorter has the focus. If the main shell has the focus then the undo doesn't reselect the original slides like it does when this artifact is in the mix. Change-Id: I5ebe0195225136bfaf81e28ad4ba8e9ec431cc22 --- .../ui/slidesorter/controller/SlsSlotManager.cxx | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'sd') diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx index 56e7e4b7e2c4..05fd566fe9c3 100644 --- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx +++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx @@ -334,6 +334,23 @@ void SlotManager::FuPermanent (SfxRequest& rRequest) // Invalidate( SID_OBJECT_SELECT ); } +class KeepSlideSorterInSyncWithPageChanges +{ + view::SlideSorterView::DrawLock m_aDrawLock; + SlideSorterController::ModelChangeLock m_aModelLock; + PageSelector::UpdateLock m_aUpdateLock; + SelectionObserver::Context m_aContext; + +public: + KeepSlideSorterInSyncWithPageChanges(SlideSorter& rSlideSorter) + : m_aDrawLock(rSlideSorter) + , m_aModelLock(rSlideSorter.GetController()) + , m_aUpdateLock(rSlideSorter) + , m_aContext(rSlideSorter) + { + } +}; + void SlotManager::FuSupport (SfxRequest& rRequest) { switch (rRequest.GetSlot()) @@ -406,10 +423,7 @@ void SlotManager::FuSupport (SfxRequest& rRequest) = dynamic_cast(mrSlideSorter.GetViewShell()); if (pViewShell != nullptr) { - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController()); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - SelectionObserver::Context aContext (mrSlideSorter); + KeepSlideSorterInSyncWithPageChanges aWatcher(mrSlideSorter); pViewShell->ImpSidUndo (false, rRequest); } break; @@ -421,10 +435,7 @@ void SlotManager::FuSupport (SfxRequest& rRequest) = dynamic_cast(mrSlideSorter.GetViewShell()); if (pViewShell != nullptr) { - view::SlideSorterView::DrawLock aDrawLock (mrSlideSorter); - SlideSorterController::ModelChangeLock aModelLock (mrSlideSorter.GetController()); - PageSelector::UpdateLock aUpdateLock (mrSlideSorter); - SelectionObserver::Context aContext (mrSlideSorter); + KeepSlideSorterInSyncWithPageChanges aWatcher(mrSlideSorter); pViewShell->ImpSidRedo (false, rRequest); } break; -- cgit