[Libreoffice-commits] core.git: sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 15 07:45:39 UTC 2019


 sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx                    |   30 -
 sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx                 |   32 -
 sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx               |   84 ++--
 sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx                   |   24 -
 sd/source/ui/slidesorter/controller/SlideSorterController.cxx        |  162 ++++-----
 sd/source/ui/slidesorter/controller/SlsClipboard.cxx                 |  108 +++---
 sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx       |   94 ++---
 sd/source/ui/slidesorter/controller/SlsFocusManager.cxx              |  110 +++---
 sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx |   35 --
 sd/source/ui/slidesorter/controller/SlsListener.cxx                  |  136 ++++----
 sd/source/ui/slidesorter/controller/SlsPageSelector.cxx              |   88 ++---
 sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx         |  106 +++---
 sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx          |   54 +--
 sd/source/ui/slidesorter/controller/SlsSlotManager.cxx               |  170 +++++-----
 sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx        |   22 -
 sd/source/ui/slidesorter/shell/SlideSorter.cxx                       |   36 +-
 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx              |   46 +-
 sd/source/ui/slidesorter/view/SlideSorterView.cxx                    |  144 ++++----
 sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx                  |   38 +-
 sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx       |  108 +++---
 sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx               |   56 +--
 sd/source/ui/slidesorter/view/SlsToolTip.cxx                         |  124 +++----
 22 files changed, 902 insertions(+), 905 deletions(-)

New commits:
commit 8f6a170e4bbb5d0a0bf06d26560189e4ca7ecfb0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Feb 14 09:11:13 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Feb 15 08:45:07 2019 +0100

    loplugin:flatten in sd/source/ui/slidesorter
    
    Change-Id: I001e0957dafee168bb997a0673be64b2e92cb658
    Reviewed-on: https://gerrit.libreoffice.org/67830
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
index 01659b9211aa..ee311d1c13e4 100644
--- a/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsBitmapCache.cxx
@@ -490,27 +490,27 @@ inline sal_Int32 BitmapCache::CacheEntry::GetMemorySize() const
 
 void BitmapCache::CacheEntry::Compress (const std::shared_ptr<BitmapCompressor>& rpCompressor)
 {
-    if ( ! maPreview.IsEmpty())
+    if (  maPreview.IsEmpty())
+        return;
+
+    if (mpReplacement == nullptr)
     {
-        if (mpReplacement == nullptr)
-        {
-            mpReplacement = rpCompressor->Compress(maPreview);
+        mpReplacement = rpCompressor->Compress(maPreview);
 
 #ifdef DEBUG_SD_SLSBITMAPCACHE
-            sal_uInt32 nOldSize (maPreview.GetSizeBytes());
-            sal_uInt32 nNewSize (mpReplacement.get()!=NULL ? mpReplacement->GetMemorySize() : 0);
-            if (nOldSize == 0)
-                nOldSize = 1;
-            sal_Int32 nRatio (100L * nNewSize / nOldSize);
-            SAL_INFO("sd.sls", OSL_THIS_FUNC << ": compressing bitmap for " << %x << " from " << nOldSize << " to " << nNewSize << " bytes (" << nRatio << "%)");
+        sal_uInt32 nOldSize (maPreview.GetSizeBytes());
+        sal_uInt32 nNewSize (mpReplacement.get()!=NULL ? mpReplacement->GetMemorySize() : 0);
+        if (nOldSize == 0)
+            nOldSize = 1;
+        sal_Int32 nRatio (100L * nNewSize / nOldSize);
+        SAL_INFO("sd.sls", OSL_THIS_FUNC << ": compressing bitmap for " << %x << " from " << nOldSize << " to " << nNewSize << " bytes (" << nRatio << "%)");
 #endif
 
-            mpCompressor = rpCompressor;
-        }
-
-        maPreview.SetEmpty();
-        maMarkedPreview.SetEmpty();
+        mpCompressor = rpCompressor;
     }
+
+    maPreview.SetEmpty();
+    maMarkedPreview.SetEmpty();
 }
 
 inline void BitmapCache::CacheEntry::Decompress()
diff --git a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx
index e1b04310893f..fc45c039f56d 100644
--- a/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsCacheCompactor.cxx
@@ -166,24 +166,24 @@ CacheCompactionByCompression::CacheCompactionByCompression (
 
 void CacheCompactionByCompression::Run()
 {
-    if (mrCache.GetSize() > mnMaximalCacheSize)
+    if (mrCache.GetSize() <= mnMaximalCacheSize)
+        return;
+
+    SAL_INFO("sd.sls", OSL_THIS_FUNC << ": bitmap cache uses to much space: " << mrCache.GetSize() << " > " << mnMaximalCacheSize);
+
+    ::std::unique_ptr< ::sd::slidesorter::cache::BitmapCache::CacheIndex> pIndex (
+        mrCache.GetCacheIndex());
+    for (const auto& rpIndex : *pIndex)
     {
-        SAL_INFO("sd.sls", OSL_THIS_FUNC << ": bitmap cache uses to much space: " << mrCache.GetSize() << " > " << mnMaximalCacheSize);
-
-        ::std::unique_ptr< ::sd::slidesorter::cache::BitmapCache::CacheIndex> pIndex (
-            mrCache.GetCacheIndex());
-        for (const auto& rpIndex : *pIndex)
-        {
-            if (rpIndex == nullptr)
-                continue;
-
-            mrCache.Compress(rpIndex, mpCompressor);
-            if (mrCache.GetSize() < mnMaximalCacheSize)
-                break;
-        }
-        mrCache.ReCalculateTotalCacheSize();
-        SAL_INFO("sd.sls", OSL_THIS_FUNC << ":    there are now " << mrCache.GetSize() << " bytes occupied");
+        if (rpIndex == nullptr)
+            continue;
+
+        mrCache.Compress(rpIndex, mpCompressor);
+        if (mrCache.GetSize() < mnMaximalCacheSize)
+            break;
     }
+    mrCache.ReCalculateTotalCacheSize();
+    SAL_INFO("sd.sls", OSL_THIS_FUNC << ":    there are now " << mrCache.GetSize() << " bytes occupied");
 }
 
 } // end of anonymous namespace
diff --git a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
index c5a83ec1ebf9..344f72f56cc2 100644
--- a/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsGenericPageCache.cxx
@@ -81,27 +81,27 @@ void GenericPageCache::ChangePreviewSize (
     const Size& rPreviewSize,
     const bool bDoSuperSampling)
 {
-    if (rPreviewSize!=maPreviewSize || bDoSuperSampling!=mbDoSuperSampling)
-    {
-        // A large size may indicate an error of the caller.  After all we
-        // are creating previews.
-        DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
-            "GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
-            "This may indicate an error.");
+    if (rPreviewSize==maPreviewSize && bDoSuperSampling==mbDoSuperSampling)
+        return;
+
+    // A large size may indicate an error of the caller.  After all we
+    // are creating previews.
+    DBG_ASSERT (maPreviewSize.Width()<1000 && maPreviewSize.Height()<1000,
+        "GenericPageCache<>::GetPreviewBitmap(): bitmap requested with large width. "
+        "This may indicate an error.");
 
-        if (mpBitmapCache != nullptr)
+    if (mpBitmapCache != nullptr)
+    {
+        mpBitmapCache = PageCacheManager::Instance()->ChangeSize(
+            mpBitmapCache, maPreviewSize, rPreviewSize);
+        if (mpQueueProcessor != nullptr)
         {
-            mpBitmapCache = PageCacheManager::Instance()->ChangeSize(
-                mpBitmapCache, maPreviewSize, rPreviewSize);
-            if (mpQueueProcessor != nullptr)
-            {
-                mpQueueProcessor->SetPreviewSize(rPreviewSize, bDoSuperSampling);
-                mpQueueProcessor->SetBitmapCache(mpBitmapCache);
-            }
+            mpQueueProcessor->SetPreviewSize(rPreviewSize, bDoSuperSampling);
+            mpQueueProcessor->SetBitmapCache(mpBitmapCache);
         }
-        maPreviewSize = rPreviewSize;
-        mbDoSuperSampling = bDoSuperSampling;
     }
+    maPreviewSize = rPreviewSize;
+    mbDoSuperSampling = bDoSuperSampling;
 }
 
 BitmapEx GenericPageCache::GetPreviewBitmap (
@@ -186,20 +186,20 @@ void GenericPageCache::RequestPreviewBitmap (
               bIsUpToDate = false;
     }
 
-    if ( ! bIsUpToDate)
+    if (  bIsUpToDate)
+        return;
+
+    // No, the bitmap is not up-to-date.  Request a new one.
+    RequestPriorityClass ePriorityClass (NOT_VISIBLE);
+    if (mpCacheContext->IsVisible(aKey))
     {
-        // No, the bitmap is not up-to-date.  Request a new one.
-        RequestPriorityClass ePriorityClass (NOT_VISIBLE);
-        if (mpCacheContext->IsVisible(aKey))
-        {
-            if (mpBitmapCache->HasBitmap(pPage))
-                ePriorityClass = VISIBLE_OUTDATED_PREVIEW;
-            else
-                ePriorityClass = VISIBLE_NO_PREVIEW;
-        }
-        maRequestQueue.AddRequest(aKey, ePriorityClass);
-        mpQueueProcessor->Start(ePriorityClass);
+        if (mpBitmapCache->HasBitmap(pPage))
+            ePriorityClass = VISIBLE_OUTDATED_PREVIEW;
+        else
+            ePriorityClass = VISIBLE_NO_PREVIEW;
     }
+    maRequestQueue.AddRequest(aKey, ePriorityClass);
+    mpQueueProcessor->Start(ePriorityClass);
 }
 
 bool GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey)
@@ -219,20 +219,20 @@ bool GenericPageCache::InvalidatePreviewBitmap (const CacheKey aKey)
 
 void GenericPageCache::InvalidateCache ()
 {
-    if (mpBitmapCache)
-    {
-        // When the cache is being invalidated then it makes no sense to
-        // continue creating preview bitmaps.  However, this may be
-        // re-started below.
-        mpQueueProcessor->Stop();
-        maRequestQueue.Clear();
+    if (!mpBitmapCache)
+        return;
 
-        // Mark the previews in the cache as not being up-to-date anymore.
-        // Depending on the given bUpdateCache flag we start to create new
-        // preview bitmaps.
-        mpBitmapCache->InvalidateCache();
-        RequestFactory()(maRequestQueue, mpCacheContext);
-    }
+    // When the cache is being invalidated then it makes no sense to
+    // continue creating preview bitmaps.  However, this may be
+    // re-started below.
+    mpQueueProcessor->Stop();
+    maRequestQueue.Clear();
+
+    // Mark the previews in the cache as not being up-to-date anymore.
+    // Depending on the given bUpdateCache flag we start to create new
+    // preview bitmaps.
+    mpBitmapCache->InvalidateCache();
+    RequestFactory()(maRequestQueue, mpCacheContext);
 }
 
 void GenericPageCache::SetPreciousFlag (
diff --git a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
index 3f851b76e508..4d07bd5977b3 100644
--- a/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
+++ b/sd/source/ui/slidesorter/cache/SlsRequestQueue.cxx
@@ -229,19 +229,19 @@ void RequestQueue::PopFront()
 {
     ::osl::MutexGuard aGuard (maMutex);
 
-    if ( ! mpRequestQueue->empty())
-    {
-        Container::const_iterator aIter(mpRequestQueue->begin());
-        SdrPage *pPage = const_cast<SdrPage*>(aIter->maKey);
-        pPage->RemovePageUser(*this);
-        mpRequestQueue->erase(aIter);
+    if (  mpRequestQueue->empty())
+        return;
 
-        // Reset the priority counter if possible.
-        if (mpRequestQueue->empty())
-        {
-            mnMinimumPriority = 0;
-            mnMaximumPriority = 1;
-        }
+    Container::const_iterator aIter(mpRequestQueue->begin());
+    SdrPage *pPage = const_cast<SdrPage*>(aIter->maKey);
+    pPage->RemovePageUser(*this);
+    mpRequestQueue->erase(aIter);
+
+    // Reset the priority counter if possible.
+    if (mpRequestQueue->empty())
+    {
+        mnMinimumPriority = 0;
+        mnMaximumPriority = 1;
     }
 }
 
diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
index 121e0067b891..3e730ac129e5 100644
--- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
+++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx
@@ -118,20 +118,20 @@ SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter)
 {
     sd::Window *pWindow (mrSlideSorter.GetContentWindow().get());
     OSL_ASSERT(pWindow);
-    if (pWindow)
-    {
-        // The whole background is painted by the view and controls.
-        vcl::Window* pParentWindow = pWindow->GetParent();
-        OSL_ASSERT(pParentWindow!=nullptr);
-        pParentWindow->SetBackground (Wallpaper());
-
-        // Connect the view with the window that has been created by our base
-        // class.
-        pWindow->SetBackground(Wallpaper());
-        pWindow->SetCenterAllowed(false);
-        pWindow->SetMapMode(MapMode(MapUnit::MapPixel));
-        pWindow->SetViewSize(mrView.GetModelArea().GetSize());
-    }
+    if (!pWindow)
+        return;
+
+    // The whole background is painted by the view and controls.
+    vcl::Window* pParentWindow = pWindow->GetParent();
+    OSL_ASSERT(pParentWindow!=nullptr);
+    pParentWindow->SetBackground (Wallpaper());
+
+    // Connect the view with the window that has been created by our base
+    // class.
+    pWindow->SetBackground(Wallpaper());
+    pWindow->SetCenterAllowed(false);
+    pWindow->SetMapMode(MapMode(MapUnit::MapPixel));
+    pWindow->SetViewSize(mrView.GetModelArea().GetSize());
 }
 
 void SlideSorterController::Init()
@@ -264,21 +264,21 @@ void SlideSorterController::Paint (
     const ::tools::Rectangle& rBBox,
     vcl::Window* pWindow)
 {
-    if (mnPaintEntranceCount == 0)
-    {
-        ++mnPaintEntranceCount;
+    if (mnPaintEntranceCount != 0)
+        return;
 
-        try
-        {
-            mrView.CompleteRedraw(pWindow, vcl::Region(rBBox));
-        }
-        catch (const Exception&)
-        {
-            // Ignore all exceptions.
-        }
+    ++mnPaintEntranceCount;
 
-        --mnPaintEntranceCount;
+    try
+    {
+        mrView.CompleteRedraw(pWindow, vcl::Region(rBBox));
     }
+    catch (const Exception&)
+    {
+        // Ignore all exceptions.
+    }
+
+    --mnPaintEntranceCount;
 }
 
 void SlideSorterController::FuTemporary (SfxRequest& rRequest)
@@ -677,41 +677,41 @@ void  SlideSorterController::Rearrange (bool bForce)
         mbIsForcedRearrangePending = false;
 
     sd::Window *pWindow (mrSlideSorter.GetContentWindow().get());
-    if (pWindow)
-    {
-        if (bForce)
-            mrView.UpdateOrientation();
-
-        // Place the scroll bars.
-        ::tools::Rectangle aNewContentArea = GetScrollBarManager().PlaceScrollBars(
-            maTotalWindowArea,
-            mrView.GetOrientation() != view::Layouter::VERTICAL,
-            mrView.GetOrientation() != view::Layouter::HORIZONTAL);
-
-        bool bSizeHasChanged (false);
-        // Only when bForce is not true we have to test for a size change in
-        // order to determine whether the window and the view have to be resized.
-        if ( ! bForce)
-        {
-            ::tools::Rectangle aCurrentContentArea (pWindow->GetPosPixel(), pWindow->GetOutputSizePixel());
-            bSizeHasChanged = (aNewContentArea != aCurrentContentArea);
-        }
-        if (bForce || bSizeHasChanged)
-        {
-            // The browser window gets the remaining space.
-            pWindow->SetPosSizePixel (aNewContentArea.TopLeft(), aNewContentArea.GetSize());
-            mrView.Resize();
-        }
+    if (!pWindow)
+        return;
 
-        // Adapt the scroll bars to the new zoom factor of the browser
-        // window and the arrangement of the page objects.
-        GetScrollBarManager().UpdateScrollBars(!bForce);
+    if (bForce)
+        mrView.UpdateOrientation();
 
-        // Keep the current slide in the visible area.
-        GetVisibleAreaManager().RequestCurrentSlideVisible();
+    // Place the scroll bars.
+    ::tools::Rectangle aNewContentArea = GetScrollBarManager().PlaceScrollBars(
+        maTotalWindowArea,
+        mrView.GetOrientation() != view::Layouter::VERTICAL,
+        mrView.GetOrientation() != view::Layouter::HORIZONTAL);
 
-        mrView.RequestRepaint();
+    bool bSizeHasChanged (false);
+    // Only when bForce is not true we have to test for a size change in
+    // order to determine whether the window and the view have to be resized.
+    if ( ! bForce)
+    {
+        ::tools::Rectangle aCurrentContentArea (pWindow->GetPosPixel(), pWindow->GetOutputSizePixel());
+        bSizeHasChanged = (aNewContentArea != aCurrentContentArea);
+    }
+    if (bForce || bSizeHasChanged)
+    {
+        // The browser window gets the remaining space.
+        pWindow->SetPosSizePixel (aNewContentArea.TopLeft(), aNewContentArea.GetSize());
+        mrView.Resize();
     }
+
+    // Adapt the scroll bars to the new zoom factor of the browser
+    // window and the arrangement of the page objects.
+    GetScrollBarManager().UpdateScrollBars(!bForce);
+
+    // Keep the current slide in the visible area.
+    GetVisibleAreaManager().RequestCurrentSlideVisible();
+
+    mrView.RequestRepaint();
 }
 
 rtl::Reference<FuPoor> SlideSorterController::CreateSelectionFunction (SfxRequest& rRequest)
@@ -731,32 +731,32 @@ void SlideSorterController::PrepareEditModeChange()
     //  Before we throw away the page descriptors we prepare for selecting
     //  descriptors in the other mode and for restoring the current
     //  selection when switching back to the current mode.
-    if (mrModel.GetEditMode() == EditMode::Page)
-    {
-        maSelectionBeforeSwitch.clear();
-
-        // Search for the first selected page and determine the master page
-        // used by its page object.  It will be selected after the switch.
-        // In the same loop the current selection is stored.
-        PageEnumeration aSelectedPages (
-            PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel));
-        while (aSelectedPages.HasMoreElements())
-        {
-            SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
-            SdPage* pPage = pDescriptor->GetPage();
-            // Remember the master page of the first selected descriptor.
-            if (pPage!=nullptr && mpEditModeChangeMasterPage==nullptr)
-                mpEditModeChangeMasterPage = &static_cast<SdPage&>(
-                    pPage->TRG_GetMasterPage());
-
-            maSelectionBeforeSwitch.push_back(pPage);
-        }
+    if (mrModel.GetEditMode() != EditMode::Page)
+        return;
 
-        // Remember the current page.
-        if (mrSlideSorter.GetViewShell() != nullptr)
-            mnCurrentPageBeforeSwitch = (mrSlideSorter.GetViewShell()->GetViewShellBase()
-            .GetMainViewShell()->GetActualPage()->GetPageNum()-1)/2;
+    maSelectionBeforeSwitch.clear();
+
+    // Search for the first selected page and determine the master page
+    // used by its page object.  It will be selected after the switch.
+    // In the same loop the current selection is stored.
+    PageEnumeration aSelectedPages (
+        PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel));
+    while (aSelectedPages.HasMoreElements())
+    {
+        SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
+        SdPage* pPage = pDescriptor->GetPage();
+        // Remember the master page of the first selected descriptor.
+        if (pPage!=nullptr && mpEditModeChangeMasterPage==nullptr)
+            mpEditModeChangeMasterPage = &static_cast<SdPage&>(
+                pPage->TRG_GetMasterPage());
+
+        maSelectionBeforeSwitch.push_back(pPage);
     }
+
+    // Remember the current page.
+    if (mrSlideSorter.GetViewShell() != nullptr)
+        mnCurrentPageBeforeSwitch = (mrSlideSorter.GetViewShell()->GetViewShellBase()
+        .GetMainViewShell()->GetActualPage()->GetPageNum()-1)/2;
 }
 
 void SlideSorterController::ChangeEditMode (EditMode eEditMode)
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 18d2608841f0..00a13cf106b8 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -236,19 +236,19 @@ void Clipboard::DoPaste ()
 {
     SdTransferable* pClipTransferable = SD_MOD()->pTransferClip;
 
-    if (pClipTransferable!=nullptr && pClipTransferable->IsPageTransferable())
-    {
-        sal_Int32 nInsertPosition = GetInsertionPosition();
+    if (pClipTransferable==nullptr || !pClipTransferable->IsPageTransferable())
+        return;
 
-        if (nInsertPosition >= 0)
-        {
-            // Paste the pages from the clipboard.
-            sal_Int32 nInsertPageCount = PasteTransferable(nInsertPosition);
-            // Select the pasted pages and make the first of them the
-            // current page.
-            mrSlideSorter.GetContentWindow()->GrabFocus();
-            SelectPageRange(nInsertPosition, nInsertPageCount);
-        }
+    sal_Int32 nInsertPosition = GetInsertionPosition();
+
+    if (nInsertPosition >= 0)
+    {
+        // Paste the pages from the clipboard.
+        sal_Int32 nInsertPageCount = PasteTransferable(nInsertPosition);
+        // Select the pasted pages and make the first of them the
+        // current page.
+        mrSlideSorter.GetContentWindow()->GrabFocus();
+        SelectPageRange(nInsertPosition, nInsertPageCount);
     }
 }
 
@@ -429,57 +429,57 @@ void Clipboard::CreateSlideTransferable (
             break;
     }
 
-    if (!aBookmarkList.empty())
-    {
-        mrSlideSorter.GetView().BrkAction();
-        SdTransferable* pTransferable = TransferableData::CreateTransferable (
-            pDocument,
-            dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()),
-            aRepresentatives);
-
-        if (bDrag)
-            SD_MOD()->pTransferDrag = pTransferable;
-        else
-            SD_MOD()->pTransferClip = pTransferable;
+    if (aBookmarkList.empty())
+        return;
 
-        pDocument->CreatingDataObj (pTransferable);
-        pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
-        std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
-        pTransferable->GetWorkDocument()->GetDocSh()
-            ->FillTransferableObjectDescriptor (*pObjDesc);
+    mrSlideSorter.GetView().BrkAction();
+    SdTransferable* pTransferable = TransferableData::CreateTransferable (
+        pDocument,
+        dynamic_cast<SlideSorterViewShell*>(mrSlideSorter.GetViewShell()),
+        aRepresentatives);
 
-        if (pDataDocSh != nullptr)
-            pObjDesc->maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+    if (bDrag)
+        SD_MOD()->pTransferDrag = pTransferable;
+    else
+        SD_MOD()->pTransferClip = pTransferable;
 
-        vcl::Window* pActionWindow = pWindow;
-        if (pActionWindow == nullptr)
-        {
-            ViewShell* pViewShell = mrSlideSorter.GetViewShell();
-            if (pViewShell != nullptr)
-                pActionWindow = pViewShell->GetActiveWindow();
-        }
+    pDocument->CreatingDataObj (pTransferable);
+    pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
+    std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
+    pTransferable->GetWorkDocument()->GetDocSh()
+        ->FillTransferableObjectDescriptor (*pObjDesc);
 
-        assert(pActionWindow);
+    if (pDataDocSh != nullptr)
+        pObjDesc->maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass();
 
-        pTransferable->SetStartPos (pActionWindow->PixelToLogic(
-            pActionWindow->GetPointerPosPixel()));
-        pTransferable->SetObjectDescriptor (std::move(pObjDesc));
+    vcl::Window* pActionWindow = pWindow;
+    if (pActionWindow == nullptr)
+    {
+        ViewShell* pViewShell = mrSlideSorter.GetViewShell();
+        if (pViewShell != nullptr)
+            pActionWindow = pViewShell->GetActiveWindow();
+    }
 
-        {
-            TemporarySlideTrackingDeactivator aDeactivator (mrController);
-            pTransferable->SetPageBookmarks (aBookmarkList, !bDrag);
-        }
+    assert(pActionWindow);
 
-        if (bDrag)
-        {
-            pTransferable->SetView (&mrSlideSorter.GetView());
-            pTransferable->StartDrag (pActionWindow, DND_ACTION_COPY | DND_ACTION_MOVE);
-        }
-        else
-            pTransferable->CopyToClipboard (pActionWindow);
+    pTransferable->SetStartPos (pActionWindow->PixelToLogic(
+        pActionWindow->GetPointerPosPixel()));
+    pTransferable->SetObjectDescriptor (std::move(pObjDesc));
 
-        pDocument->CreatingDataObj(nullptr);
+    {
+        TemporarySlideTrackingDeactivator aDeactivator (mrController);
+        pTransferable->SetPageBookmarks (aBookmarkList, !bDrag);
     }
+
+    if (bDrag)
+    {
+        pTransferable->SetView (&mrSlideSorter.GetView());
+        pTransferable->StartDrag (pActionWindow, DND_ACTION_COPY | DND_ACTION_MOVE);
+    }
+    else
+        pTransferable->CopyToClipboard (pActionWindow);
+
+    pDocument->CreatingDataObj(nullptr);
 }
 
 std::shared_ptr<SdTransferable::UserData> Clipboard::CreateTransferableUserData (SdTransferable* pTransferable)
diff --git a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
index 0afd2d78809b..fd926c732638 100644
--- a/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsCurrentSlideManager.cxx
@@ -67,21 +67,21 @@ void CurrentSlideManager::NotifyCurrentSlideChange (const SdPage* pPage)
 
 void CurrentSlideManager::NotifyCurrentSlideChange (const sal_Int32 nSlideIndex)
 {
-    if (mnCurrentSlideIndex != nSlideIndex)
-    {
-        PageSelector::BroadcastLock aBroadcastLock (mrSlideSorter.GetController().GetPageSelector());
+    if (mnCurrentSlideIndex == nSlideIndex)
+        return;
 
-        mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
+    PageSelector::BroadcastLock aBroadcastLock (mrSlideSorter.GetController().GetPageSelector());
 
-        ReleaseCurrentSlide();
-        AcquireCurrentSlide(nSlideIndex);
+    mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
 
-        // Update the selection.
-        if (mpCurrentSlide)
-        {
-            mrSlideSorter.GetController().GetPageSelector().SelectPage(mpCurrentSlide);
-            mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(mpCurrentSlide);
-        }
+    ReleaseCurrentSlide();
+    AcquireCurrentSlide(nSlideIndex);
+
+    // Update the selection.
+    if (mpCurrentSlide)
+    {
+        mrSlideSorter.GetController().GetPageSelector().SelectPage(mpCurrentSlide);
+        mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(mpCurrentSlide);
     }
 }
 
@@ -120,44 +120,44 @@ void CurrentSlideManager::SwitchCurrentSlide (
     const SharedPageDescriptor& rpDescriptor,
     const bool bUpdateSelection)
 {
-    if (rpDescriptor.get() != nullptr && mpCurrentSlide!=rpDescriptor)
-    {
-        ReleaseCurrentSlide();
-        AcquireCurrentSlide((rpDescriptor->GetPage()->GetPageNum()-1)/2);
+    if (!(rpDescriptor.get() != nullptr && mpCurrentSlide!=rpDescriptor))
+        return;
 
-        ViewShell* pViewShell = mrSlideSorter.GetViewShell();
-        if (pViewShell != nullptr && pViewShell->IsMainViewShell())
-        {
-            // The slide sorter is the main view.
-            FrameView* pFrameView = pViewShell->GetFrameView();
-            if (pFrameView != nullptr)
-                pFrameView->SetSelectedPage(sal::static_int_cast<sal_uInt16>(mnCurrentSlideIndex));
-            mrSlideSorter.GetController().GetPageSelector().SetCoreSelection();
-        }
+    ReleaseCurrentSlide();
+    AcquireCurrentSlide((rpDescriptor->GetPage()->GetPageNum()-1)/2);
 
-        // We do not tell the XController/ViewShellBase about the new
-        // slide right away.  This is done asynchronously after a short
-        // delay to allow for more slide switches in the slide sorter.
-        // This goes under the assumption that slide switching inside
-        // the slide sorter is fast (no expensive redraw of the new page
-        // (unless the preview of the new slide is not yet preset)) and
-        // that slide switching in the edit view is slow (all shapes of
-        // the new slide have to be repainted.)
-        maSwitchPageDelayTimer.Start();
-
-        // We have to store the (index of the) new current slide at
-        // the tab control because there are other asynchronous
-        // notifications of the slide switching that otherwise
-        // overwrite the correct value.
-        SetCurrentSlideAtTabControl(mpCurrentSlide);
-
-        if (bUpdateSelection)
-        {
-            mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
-            mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor);
-        }
-        mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(rpDescriptor);
+    ViewShell* pViewShell = mrSlideSorter.GetViewShell();
+    if (pViewShell != nullptr && pViewShell->IsMainViewShell())
+    {
+        // The slide sorter is the main view.
+        FrameView* pFrameView = pViewShell->GetFrameView();
+        if (pFrameView != nullptr)
+            pFrameView->SetSelectedPage(sal::static_int_cast<sal_uInt16>(mnCurrentSlideIndex));
+        mrSlideSorter.GetController().GetPageSelector().SetCoreSelection();
+    }
+
+    // We do not tell the XController/ViewShellBase about the new
+    // slide right away.  This is done asynchronously after a short
+    // delay to allow for more slide switches in the slide sorter.
+    // This goes under the assumption that slide switching inside
+    // the slide sorter is fast (no expensive redraw of the new page
+    // (unless the preview of the new slide is not yet preset)) and
+    // that slide switching in the edit view is slow (all shapes of
+    // the new slide have to be repainted.)
+    maSwitchPageDelayTimer.Start();
+
+    // We have to store the (index of the) new current slide at
+    // the tab control because there are other asynchronous
+    // notifications of the slide switching that otherwise
+    // overwrite the correct value.
+    SetCurrentSlideAtTabControl(mpCurrentSlide);
+
+    if (bUpdateSelection)
+    {
+        mrSlideSorter.GetController().GetPageSelector().DeselectAllPages();
+        mrSlideSorter.GetController().GetPageSelector().SelectPage(rpDescriptor);
     }
+    mrSlideSorter.GetController().GetFocusManager().SetFocusedPage(rpDescriptor);
 }
 
 void CurrentSlideManager::SetCurrentSlideAtViewShellBase (const SharedPageDescriptor& rpDescriptor)
diff --git a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
index 232457574de2..ba8273d7628a 100644
--- a/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsFocusManager.cxx
@@ -50,62 +50,62 @@ FocusManager::~FocusManager()
 
 void FocusManager::MoveFocus (FocusMoveDirection eDirection)
 {
-    if (mnPageIndex >= 0 && mbPageIsFocused)
-    {
-        HideFocusIndicator (GetFocusedPageDescriptor());
+    if (!(mnPageIndex >= 0 && mbPageIsFocused))
+        return;
 
-        const sal_Int32 nColumnCount (mrSlideSorter.GetView().GetLayouter().GetColumnCount());
-        const sal_Int32 nPageCount (mrSlideSorter.GetModel().GetPageCount());
-        switch (eDirection)
-        {
-            case FocusMoveDirection::Left:
-                if (mnPageIndex > 0)
-                    mnPageIndex -= 1;
-                break;
+    HideFocusIndicator (GetFocusedPageDescriptor());
 
-            case FocusMoveDirection::Right:
-                if (mnPageIndex < nPageCount-1)
-                    mnPageIndex += 1;
-                break;
+    const sal_Int32 nColumnCount (mrSlideSorter.GetView().GetLayouter().GetColumnCount());
+    const sal_Int32 nPageCount (mrSlideSorter.GetModel().GetPageCount());
+    switch (eDirection)
+    {
+        case FocusMoveDirection::Left:
+            if (mnPageIndex > 0)
+                mnPageIndex -= 1;
+            break;
 
-            case FocusMoveDirection::Up:
-            {
-                const sal_Int32 nCandidate (mnPageIndex - nColumnCount);
-                if (nCandidate >= 0)
-                {
-                    // Move the focus the previous row.
-                    mnPageIndex = nCandidate;
-                }
-            }
+        case FocusMoveDirection::Right:
+            if (mnPageIndex < nPageCount-1)
+                mnPageIndex += 1;
             break;
 
-            case FocusMoveDirection::Down:
+        case FocusMoveDirection::Up:
+        {
+            const sal_Int32 nCandidate (mnPageIndex - nColumnCount);
+            if (nCandidate >= 0)
             {
-                const sal_Int32 nCandidate (mnPageIndex + nColumnCount);
-                if (nCandidate < nPageCount)
-                {
-                    // Move the focus to the next row.
-                    mnPageIndex = nCandidate;
-                }
+                // Move the focus the previous row.
+                mnPageIndex = nCandidate;
             }
-            break;
         }
+        break;
 
-        if (mnPageIndex < 0)
+        case FocusMoveDirection::Down:
         {
-            OSL_ASSERT(mnPageIndex>=0);
-            mnPageIndex = 0;
-        }
-        else if (mnPageIndex >= nPageCount)
-        {
-            OSL_ASSERT(mnPageIndex<nPageCount);
-            mnPageIndex = nPageCount - 1;
+            const sal_Int32 nCandidate (mnPageIndex + nColumnCount);
+            if (nCandidate < nPageCount)
+            {
+                // Move the focus to the next row.
+                mnPageIndex = nCandidate;
+            }
         }
+        break;
+    }
 
-        if (mbPageIsFocused)
-        {
-            ShowFocusIndicator(GetFocusedPageDescriptor(), true);
-        }
+    if (mnPageIndex < 0)
+    {
+        OSL_ASSERT(mnPageIndex>=0);
+        mnPageIndex = 0;
+    }
+    else if (mnPageIndex >= nPageCount)
+    {
+        OSL_ASSERT(mnPageIndex<nPageCount);
+        mnPageIndex = nPageCount - 1;
+    }
+
+    if (mbPageIsFocused)
+    {
+        ShowFocusIndicator(GetFocusedPageDescriptor(), true);
     }
 }
 
@@ -183,20 +183,20 @@ void FocusManager::ShowFocusIndicator (
     const model::SharedPageDescriptor& rpDescriptor,
     const bool bScrollToFocus)
 {
-    if (rpDescriptor.get() != nullptr)
-    {
-        mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, true);
+    if (rpDescriptor.get() == nullptr)
+        return;
 
-        if (bScrollToFocus)
-        {
-            // Scroll the focused page object into the visible area and repaint
-            // it, so that the focus indicator becomes visible.
-            mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true);
-        }
-        mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
+    mrSlideSorter.GetView().SetState(rpDescriptor, model::PageDescriptor::ST_Focused, true);
 
-        NotifyFocusChangeListeners();
+    if (bScrollToFocus)
+    {
+        // Scroll the focused page object into the visible area and repaint
+        // it, so that the focus indicator becomes visible.
+        mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true);
     }
+    mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
+
+    NotifyFocusChangeListeners();
 }
 
 void FocusManager::AddFocusChangeListener (const Link<LinkParamNone*,void>& rListener)
diff --git a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx
index 6a691e4219f9..ec79f5e85e90 100644
--- a/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsInsertionIndicatorHandler.cxx
@@ -149,26 +149,23 @@ void InsertionIndicatorHandler::SetPosition (
         maIconSize,
         mrSlideSorter.GetModel()));
 
-    if (maInsertPosition != aInsertPosition
-        || meMode != eMode
-        //        || ! mpInsertionIndicatorOverlay->IsVisible()
-        )
+    if (maInsertPosition == aInsertPosition && meMode == eMode)
+        return;
+
+    maInsertPosition = aInsertPosition;
+    meMode = eMode;
+    mbIsInsertionTrivial = IsInsertionTrivial(maInsertPosition.GetIndex(), eMode);
+    if (maInsertPosition.GetIndex()>=0 && ! mbIsInsertionTrivial)
     {
-        maInsertPosition = aInsertPosition;
-        meMode = eMode;
-        mbIsInsertionTrivial = IsInsertionTrivial(maInsertPosition.GetIndex(), eMode);
-        if (maInsertPosition.GetIndex()>=0 && ! mbIsInsertionTrivial)
-        {
-            mpInsertionIndicatorOverlay->SetLocation(maInsertPosition.GetLocation());
-
-            GetInsertAnimator()->SetInsertPosition(maInsertPosition);
-            mpInsertionIndicatorOverlay->Show();
-        }
-        else
-        {
-            GetInsertAnimator()->Reset(Animator::AM_Animated);
-            mpInsertionIndicatorOverlay->Hide();
-        }
+        mpInsertionIndicatorOverlay->SetLocation(maInsertPosition.GetLocation());
+
+        GetInsertAnimator()->SetInsertPosition(maInsertPosition);
+        mpInsertionIndicatorOverlay->Show();
+    }
+    else
+    {
+        GetInsertAnimator()->Reset(Animator::AM_Animated);
+        mpInsertionIndicatorOverlay->Hide();
     }
 }
 
diff --git a/sd/source/ui/slidesorter/controller/SlsListener.cxx b/sd/source/ui/slidesorter/controller/SlsListener.cxx
index d65299ae7b84..0971c8ffe60e 100644
--- a/sd/source/ui/slidesorter/controller/SlsListener.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsListener.cxx
@@ -192,75 +192,75 @@ void Listener::ConnectToController()
 
     // Register at the controller of the main view shell (if we are that not
     // ourself).
-    if (pShell==nullptr || ! pShell->IsMainViewShell())
-    {
-        Reference<frame::XController> xController (mrSlideSorter.GetXController());
+    if (pShell!=nullptr && pShell->IsMainViewShell())
+        return;
 
-        // Listen to changes of certain properties.
-        Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
-        if (xSet.is())
+    Reference<frame::XController> xController (mrSlideSorter.GetXController());
+
+    // Listen to changes of certain properties.
+    Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
+    if (xSet.is())
+    {
+        try
         {
-            try
-            {
-                xSet->addPropertyChangeListener("CurrentPage", this);
-            }
-            catch (beans::UnknownPropertyException&)
-            {
-                DBG_UNHANDLED_EXCEPTION("sd");
-            }
-            try
-            {
-                xSet->addPropertyChangeListener("IsMasterPageMode", this);
-            }
-            catch (beans::UnknownPropertyException&)
-            {
-                DBG_UNHANDLED_EXCEPTION("sd");
-            }
+            xSet->addPropertyChangeListener("CurrentPage", this);
         }
-
-        // Listen for disposing events.
-        Reference<XComponent> xComponent (xController, UNO_QUERY);
-        if (xComponent.is())
+        catch (beans::UnknownPropertyException&)
         {
-            xComponent->addEventListener (
-                Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY));
-
-            mxControllerWeak = xController;
-            mbListeningToController = true;
+            DBG_UNHANDLED_EXCEPTION("sd");
+        }
+        try
+        {
+            xSet->addPropertyChangeListener("IsMasterPageMode", this);
+        }
+        catch (beans::UnknownPropertyException&)
+        {
+            DBG_UNHANDLED_EXCEPTION("sd");
         }
     }
+
+    // Listen for disposing events.
+    Reference<XComponent> xComponent (xController, UNO_QUERY);
+    if (xComponent.is())
+    {
+        xComponent->addEventListener (
+            Reference<lang::XEventListener>(static_cast<XWeak*>(this), UNO_QUERY));
+
+        mxControllerWeak = xController;
+        mbListeningToController = true;
+    }
 }
 
 void Listener::DisconnectFromController()
 {
-    if (mbListeningToController)
-    {
-        Reference<frame::XController> xController = mxControllerWeak;
-        Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
-        try
-        {
-            // Remove the property listener.
-            if (xSet.is())
-            {
-                xSet->removePropertyChangeListener( "CurrentPage", this );
-                xSet->removePropertyChangeListener( "IsMasterPageMode", this);
-            }
+    if (!mbListeningToController)
+        return;
 
-            // Remove the dispose listener.
-            Reference<XComponent> xComponent (xController, UNO_QUERY);
-            if (xComponent.is())
-                xComponent->removeEventListener (
-                    Reference<lang::XEventListener>(
-                        static_cast<XWeak*>(this), UNO_QUERY));
-        }
-        catch (beans::UnknownPropertyException&)
+    Reference<frame::XController> xController = mxControllerWeak;
+    Reference<beans::XPropertySet> xSet (xController, UNO_QUERY);
+    try
+    {
+        // Remove the property listener.
+        if (xSet.is())
         {
-            DBG_UNHANDLED_EXCEPTION("sd");
+            xSet->removePropertyChangeListener( "CurrentPage", this );
+            xSet->removePropertyChangeListener( "IsMasterPageMode", this);
         }
 
-        mbListeningToController = false;
-        mxControllerWeak = Reference<frame::XController>();
+        // Remove the dispose listener.
+        Reference<XComponent> xComponent (xController, UNO_QUERY);
+        if (xComponent.is())
+            xComponent->removeEventListener (
+                Reference<lang::XEventListener>(
+                    static_cast<XWeak*>(this), UNO_QUERY));
+    }
+    catch (beans::UnknownPropertyException&)
+    {
+        DBG_UNHANDLED_EXCEPTION("sd");
     }
+
+    mbListeningToController = false;
+    mxControllerWeak = Reference<frame::XController>();
 }
 
 void Listener::Notify (
@@ -585,22 +585,22 @@ void Listener::HandleShapeModification (const SdrPage* pPage)
 
     // When the page is a master page then invalidate the previews of all
     // pages that are linked to this master page.
-    if (pPage->IsMasterPage())
+    if (!pPage->IsMasterPage())
+        return;
+
+    for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PageKind::Standard);
+         nIndex<nCount;
+         ++nIndex)
     {
-        for (sal_uInt16 nIndex=0,nCount=pDocument->GetSdPageCount(PageKind::Standard);
-             nIndex<nCount;
-             ++nIndex)
+        const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PageKind::Standard);
+        if (pCandidate!=nullptr && pCandidate->TRG_HasMasterPage())
         {
-            const SdPage* pCandidate = pDocument->GetSdPage(nIndex, PageKind::Standard);
-            if (pCandidate!=nullptr && pCandidate->TRG_HasMasterPage())
-            {
-                if (&pCandidate->TRG_GetMasterPage() == pPage)
-                    pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate);
-            }
-            else
-            {
-                OSL_ASSERT(pCandidate!=nullptr && pCandidate->TRG_HasMasterPage());
-            }
+            if (&pCandidate->TRG_GetMasterPage() == pPage)
+                pCacheManager->InvalidatePreviewBitmap(pDocument->getUnoModel(), pCandidate);
+        }
+        else
+        {
+            OSL_ASSERT(pCandidate!=nullptr && pCandidate->TRG_HasMasterPage());
         }
     }
 }
diff --git a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
index a7c935698bb7..4564b8f99ca1 100644
--- a/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsPageSelector.cxx
@@ -145,25 +145,25 @@ void PageSelector::SelectPage (const SdPage* pPage)
 
 void PageSelector::SelectPage (const SharedPageDescriptor& rpDescriptor)
 {
-    if (rpDescriptor.get()!=nullptr
-        && mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, true))
-    {
-        ++mnSelectedPageCount;
-        mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true);
-        mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
+    if (rpDescriptor.get()==nullptr
+        || !mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, true))
+        return;
 
-        mpMostRecentlySelectedPage = rpDescriptor;
-        if (mpSelectionAnchor == nullptr)
-            mpSelectionAnchor = rpDescriptor;
+    ++mnSelectedPageCount;
+    mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor,true);
+    mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
 
-        if (mnBroadcastDisableLevel > 0)
-            mbSelectionChangeBroadcastPending = true;
-        else
-            mrController.GetSelectionManager()->SelectionHasChanged();
-        UpdateCurrentPage();
+    mpMostRecentlySelectedPage = rpDescriptor;
+    if (mpSelectionAnchor == nullptr)
+        mpSelectionAnchor = rpDescriptor;
 
-        CheckConsistency();
-    }
+    if (mnBroadcastDisableLevel > 0)
+        mbSelectionChangeBroadcastPending = true;
+    else
+        mrController.GetSelectionManager()->SelectionHasChanged();
+    UpdateCurrentPage();
+
+    CheckConsistency();
 }
 
 void PageSelector::DeselectPage (int nPageIndex)
@@ -177,23 +177,23 @@ void PageSelector::DeselectPage (
     const SharedPageDescriptor& rpDescriptor,
     const bool bUpdateCurrentPage)
 {
-    if (rpDescriptor.get()!=nullptr
-        && mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, false))
-    {
-        --mnSelectedPageCount;
-        mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor);
-        mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
-        if (mpMostRecentlySelectedPage == rpDescriptor)
-            mpMostRecentlySelectedPage.reset();
-        if (mnBroadcastDisableLevel > 0)
-            mbSelectionChangeBroadcastPending = true;
-        else
-            mrController.GetSelectionManager()->SelectionHasChanged();
-        if (bUpdateCurrentPage)
-            UpdateCurrentPage();
+    if (rpDescriptor.get()==nullptr
+        || mrSlideSorter.GetView().SetState(rpDescriptor, PageDescriptor::ST_Selected, false))
+        return;
 
-        CheckConsistency();
-    }
+    --mnSelectedPageCount;
+    mrSlideSorter.GetController().GetVisibleAreaManager().RequestVisible(rpDescriptor);
+    mrSlideSorter.GetView().RequestRepaint(rpDescriptor);
+    if (mpMostRecentlySelectedPage == rpDescriptor)
+        mpMostRecentlySelectedPage.reset();
+    if (mnBroadcastDisableLevel > 0)
+        mbSelectionChangeBroadcastPending = true;
+    else
+        mrController.GetSelectionManager()->SelectionHasChanged();
+    if (bUpdateCurrentPage)
+        UpdateCurrentPage();
+
+    CheckConsistency();
 }
 
 void PageSelector::CheckConsistency() const
@@ -312,20 +312,20 @@ void PageSelector::UpdateCurrentPage (const bool bUpdateOnlyWhenPending)
         }
     }
 
-    if (pCurrentPageDescriptor)
-    {
-        // Switching the current slide normally sets also the
-        // selection to just the new current slide.  To prevent that,
-        // we store (and at the end of this scope restore) the current
-        // selection.
-        std::shared_ptr<PageSelection> pSelection (GetPageSelection());
+    if (!pCurrentPageDescriptor)
+        return;
 
-        mrController.GetCurrentSlideManager()->SwitchCurrentSlide(pCurrentPageDescriptor);
+    // Switching the current slide normally sets also the
+    // selection to just the new current slide.  To prevent that,
+    // we store (and at the end of this scope restore) the current
+    // selection.
+    std::shared_ptr<PageSelection> pSelection (GetPageSelection());
 
-        // Restore the selection and prevent a recursive call to
-        // UpdateCurrentPage().
-        SetPageSelection(pSelection, false);
-    }
+    mrController.GetCurrentSlideManager()->SwitchCurrentSlide(pCurrentPageDescriptor);
+
+    // Restore the selection and prevent a recursive call to
+    // UpdateCurrentPage().
+    SetPageSelection(pSelection, false);
 }
 
 //===== PageSelector::UpdateLock ==============================================
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
index 22b7019a7b9d..d079aea862f3 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
@@ -683,21 +683,21 @@ void SelectionFunction::SwitchToNormalMode()
 
 void SelectionFunction::SwitchToDragAndDropMode (const Point& rMousePosition)
 {
-    if (mpModeHandler->GetMode() != DragAndDropMode)
-    {
+    if (mpModeHandler->GetMode() == DragAndDropMode)
+        return;
+
 #ifndef MACOSX
-        std::shared_ptr<DragAndDropModeHandler> handler(
-            new DragAndDropModeHandler(mrSlideSorter, *this));
-        SwitchMode(handler);
-        // Delayed initialization, only after mpModeHanler is set, otherwise DND initialization
-        // could already trigger DND events, which would recursively trigger this code again,
-        // and without mpModeHandler set it would again try to set a new handler.
-        handler->Initialize(rMousePosition, mpWindow);
+    std::shared_ptr<DragAndDropModeHandler> handler(
+        new DragAndDropModeHandler(mrSlideSorter, *this));
+    SwitchMode(handler);
+    // Delayed initialization, only after mpModeHanler is set, otherwise DND initialization
+    // could already trigger DND events, which would recursively trigger this code again,
+    // and without mpModeHandler set it would again try to set a new handler.
+    handler->Initialize(rMousePosition, mpWindow);
 #else
-        SwitchMode(std::shared_ptr<ModeHandler>(
-            new DragAndDropModeHandler(mrSlideSorter, *this, rMousePosition, mpWindow)));
+    SwitchMode(std::shared_ptr<ModeHandler>(
+        new DragAndDropModeHandler(mrSlideSorter, *this, rMousePosition, mpWindow)));
 #endif
-    }
 }
 
 void SelectionFunction::SwitchToMultiSelectionMode (
@@ -973,19 +973,19 @@ void SelectionFunction::ModeHandler::SwitchView (const model::SharedPageDescript
     // Switch to the draw view.  This is done only when the current
     // view is the main view.
     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
-    if (pViewShell!=nullptr && pViewShell->IsMainViewShell())
+    if (pViewShell==nullptr || !pViewShell->IsMainViewShell())
+        return;
+
+    if (rpDescriptor.get()!=nullptr && rpDescriptor->GetPage()!=nullptr)
     {
-        if (rpDescriptor.get()!=nullptr && rpDescriptor->GetPage()!=nullptr)
-        {
-            mrSlideSorter.GetModel().GetDocument()->SetSelected(rpDescriptor->GetPage(), true);
-            pViewShell->GetFrameView()->SetSelectedPage(
-                (rpDescriptor->GetPage()->GetPageNum()-1)/2);
-        }
-        if (mrSlideSorter.GetViewShellBase() != nullptr)
-        framework::FrameworkHelper::Instance(*mrSlideSorter.GetViewShellBase())->RequestView(
-            framework::FrameworkHelper::msImpressViewURL,
-            framework::FrameworkHelper::msCenterPaneURL);
+        mrSlideSorter.GetModel().GetDocument()->SetSelected(rpDescriptor->GetPage(), true);
+        pViewShell->GetFrameView()->SetSelectedPage(
+            (rpDescriptor->GetPage()->GetPageNum()-1)/2);
     }
+    if (mrSlideSorter.GetViewShellBase() != nullptr)
+    framework::FrameworkHelper::Instance(*mrSlideSorter.GetViewShellBase())->RequestView(
+        framework::FrameworkHelper::msImpressViewURL,
+        framework::FrameworkHelper::msCenterPaneURL);
 }
 
 void SelectionFunction::ModeHandler::StartDrag (
@@ -1201,26 +1201,26 @@ void NormalModeHandler::RangeSelect (const model::SharedPageDescriptor& rpDescri
     model::SharedPageDescriptor pAnchor (rSelector.GetSelectionAnchor());
     DeselectAllPages();
 
-    if (pAnchor.get() != nullptr)
+    if (pAnchor.get() == nullptr)
+        return;
+
+    // Select all pages between the anchor and the given one, including
+    // the two.
+    const sal_uInt16 nAnchorIndex ((pAnchor->GetPage()->GetPageNum()-1) / 2);
+    const sal_uInt16 nOtherIndex ((rpDescriptor->GetPage()->GetPageNum()-1) / 2);
+
+    // Iterate over all pages in the range.  Start with the anchor
+    // page.  This way the PageSelector will recognize it again as
+    // anchor (the first selected page after a DeselectAllPages()
+    // becomes the anchor.)
+    const sal_uInt16 nStep ((nAnchorIndex < nOtherIndex) ? +1 : -1);
+    sal_uInt16 nIndex (nAnchorIndex);
+    while (true)
     {
-        // Select all pages between the anchor and the given one, including
-        // the two.
-        const sal_uInt16 nAnchorIndex ((pAnchor->GetPage()->GetPageNum()-1) / 2);
-        const sal_uInt16 nOtherIndex ((rpDescriptor->GetPage()->GetPageNum()-1) / 2);
-
-        // Iterate over all pages in the range.  Start with the anchor
-        // page.  This way the PageSelector will recognize it again as
-        // anchor (the first selected page after a DeselectAllPages()
-        // becomes the anchor.)
-        const sal_uInt16 nStep ((nAnchorIndex < nOtherIndex) ? +1 : -1);
-        sal_uInt16 nIndex (nAnchorIndex);
-        while (true)
-        {
-            rSelector.SelectPage(nIndex);
-            if (nIndex == nOtherIndex)
-                break;
-            nIndex = nIndex + nStep;
-        }
+        rSelector.SelectPage(nIndex);
+        if (nIndex == nOtherIndex)
+            break;
+        nIndex = nIndex + nStep;
     }
 }
 
@@ -1441,19 +1441,19 @@ void MultiSelectionModeHandler::UpdateSelection()
             maSecondCorner,
             false,
             false));
-    if (nIndexUnderMouse>=0 && nIndexUnderMouse<nPageCount)
-    {
-        if (mnAnchorIndex < 0)
-            mnAnchorIndex = nIndexUnderMouse;
-        mnSecondIndex = nIndexUnderMouse;
+    if (!(nIndexUnderMouse>=0 && nIndexUnderMouse<nPageCount))
+        return;
 
-        Range aRange (mnAnchorIndex, mnSecondIndex);
-        aRange.Justify();
+    if (mnAnchorIndex < 0)
+        mnAnchorIndex = nIndexUnderMouse;
+    mnSecondIndex = nIndexUnderMouse;
 
-        for (sal_Int32 nIndex=0; nIndex<nPageCount; ++nIndex)
-        {
-            UpdateSelectionState(rModel.GetPageDescriptor(nIndex), aRange.IsInside(nIndex));
-        }
+    Range aRange (mnAnchorIndex, mnSecondIndex);
+    aRange.Justify();
+
+    for (sal_Int32 nIndex=0; nIndex<nPageCount; ++nIndex)
+    {
+        UpdateSelectionState(rModel.GetPageDescriptor(nIndex), aRange.IsInside(nIndex));
     }
 }
 
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
index 36b728622654..64e6e457aca7 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionManager.cxx
@@ -216,35 +216,35 @@ void SelectionManager::DeleteSelectedMasterPages (const ::std::vector<SdPage*>&
 void SelectionManager::SelectionHasChanged ()
 {
     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
-    if (pViewShell != nullptr)
-    {
-        pViewShell->Invalidate (SID_EXPAND_PAGE);
-        pViewShell->Invalidate (SID_SUMMARY_PAGE);
-        pViewShell->Invalidate(SID_SHOW_SLIDE);
-        pViewShell->Invalidate(SID_HIDE_SLIDE);
-        pViewShell->Invalidate(SID_DELETE_PAGE);
-        pViewShell->Invalidate(SID_DELETE_MASTER_PAGE);
-        pViewShell->Invalidate(SID_ASSIGN_LAYOUT);
-
-        // StatusBar
-        pViewShell->Invalidate (SID_STATUS_PAGE);
-        pViewShell->Invalidate (SID_STATUS_LAYOUT);
-
-        OSL_ASSERT(mrController.GetCurrentSlideManager());
-        SharedPageDescriptor pDescriptor(mrController.GetCurrentSlideManager()->GetCurrentSlide());
-        if (pDescriptor.get() != nullptr)
-            pViewShell->UpdatePreview(pDescriptor->GetPage());
-
-        // Tell the selection change listeners that the selection has changed.
-        for (auto& rLink : maSelectionChangeListeners)
-        {
-            rLink.Call(nullptr);
-        }
+    if (pViewShell == nullptr)
+        return;
 
-        // Reset the insertion position: until set again it is calculated from
-        // the current selection.
-        mnInsertionPosition = -1;
+    pViewShell->Invalidate (SID_EXPAND_PAGE);
+    pViewShell->Invalidate (SID_SUMMARY_PAGE);
+    pViewShell->Invalidate(SID_SHOW_SLIDE);
+    pViewShell->Invalidate(SID_HIDE_SLIDE);
+    pViewShell->Invalidate(SID_DELETE_PAGE);
+    pViewShell->Invalidate(SID_DELETE_MASTER_PAGE);
+    pViewShell->Invalidate(SID_ASSIGN_LAYOUT);
+
+    // StatusBar
+    pViewShell->Invalidate (SID_STATUS_PAGE);
+    pViewShell->Invalidate (SID_STATUS_LAYOUT);
+
+    OSL_ASSERT(mrController.GetCurrentSlideManager());
+    SharedPageDescriptor pDescriptor(mrController.GetCurrentSlideManager()->GetCurrentSlide());
+    if (pDescriptor.get() != nullptr)
+        pViewShell->UpdatePreview(pDescriptor->GetPage());
+
+    // Tell the selection change listeners that the selection has changed.
+    for (auto& rLink : maSelectionChangeListeners)
+    {
+        rLink.Call(nullptr);
     }
+
+    // Reset the insertion position: until set again it is calculated from
+    // the current selection.
+    mnInsertionPosition = -1;
 }
 
 void SelectionManager::AddSelectionChangeListener (const Link<LinkParamNone*,void>& rListener)
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index 0875ba1c981d..3e247825fcf0 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -746,55 +746,55 @@ void SlotManager::GetClipboardState ( SfxItemSet& rSet)
     }
 
     // Cut, copy, and delete page are disabled when there is no selection.
-    if (rSet.GetItemState(SID_CUT) == SfxItemState::DEFAULT
+    if (!(rSet.GetItemState(SID_CUT) == SfxItemState::DEFAULT
         || rSet.GetItemState(SID_COPY)  == SfxItemState::DEFAULT
         || rSet.GetItemState(SID_DELETE) == SfxItemState::DEFAULT
         || rSet.GetItemState(SID_DELETE_PAGE) == SfxItemState::DEFAULT
-        || rSet.GetItemState(SID_DELETE_MASTER_PAGE) == SfxItemState::DEFAULT)
-    {
-        model::PageEnumeration aSelectedPages (
-            model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
-                mrSlideSorter.GetModel()));
-
-        // For copy to work we have to have at least one selected page.
-        if ( ! aSelectedPages.HasMoreElements())
-            rSet.DisableItem(SID_COPY);
-
-        bool bDisable = false;
-        // The operations that lead to the deletion of a page are valid if
-        // a) there is at least one selected page
-        // b) deleting the selected pages leaves at least one page in the
-        // document
-        // c) selected master pages must not be used by slides.
+        || rSet.GetItemState(SID_DELETE_MASTER_PAGE) == SfxItemState::DEFAULT))
+        return;
 
-        // Test a).
-        if ( ! aSelectedPages.HasMoreElements())
-            bDisable = true;
-        // Test b): Count the number of selected pages.  It has to be less
-        // than the number of all pages.
-        else if (mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount()
-            >= mrSlideSorter.GetController().GetPageSelector().GetPageCount())
-            bDisable = true;
-        // Test c): Iterate over the selected pages and look for a master
-        // page that is used by at least one page.
-        else while (aSelectedPages.HasMoreElements())
+    model::PageEnumeration aSelectedPages (
+        model::PageEnumerationProvider::CreateSelectedPagesEnumeration(
+            mrSlideSorter.GetModel()));
+
+    // For copy to work we have to have at least one selected page.
+    if ( ! aSelectedPages.HasMoreElements())
+        rSet.DisableItem(SID_COPY);
+
+    bool bDisable = false;
+    // The operations that lead to the deletion of a page are valid if
+    // a) there is at least one selected page
+    // b) deleting the selected pages leaves at least one page in the
+    // document
+    // c) selected master pages must not be used by slides.
+
+    // Test a).
+    if ( ! aSelectedPages.HasMoreElements())
+        bDisable = true;
+    // Test b): Count the number of selected pages.  It has to be less
+    // than the number of all pages.
+    else if (mrSlideSorter.GetController().GetPageSelector().GetSelectedPageCount()
+        >= mrSlideSorter.GetController().GetPageSelector().GetPageCount())
+        bDisable = true;
+    // Test c): Iterate over the selected pages and look for a master
+    // page that is used by at least one page.
+    else while (aSelectedPages.HasMoreElements())
+    {
+        SdPage* pPage = aSelectedPages.GetNextElement()->GetPage();
+        int nUseCount (mrSlideSorter.GetModel().GetDocument()
+            ->GetMasterPageUserCount(pPage));
+        if (nUseCount > 0)
         {
-            SdPage* pPage = aSelectedPages.GetNextElement()->GetPage();
-            int nUseCount (mrSlideSorter.GetModel().GetDocument()
-                ->GetMasterPageUserCount(pPage));
-            if (nUseCount > 0)
-            {
-                bDisable = true;
-                break;
-            }
+            bDisable = true;
+            break;
         }
+    }
 
-        if (bDisable)
-        {
-            rSet.DisableItem(SID_CUT);
-            rSet.DisableItem(SID_DELETE_PAGE);
-            rSet.DisableItem(SID_DELETE_MASTER_PAGE);
-        }
+    if (bDisable)
+    {
+        rSet.DisableItem(SID_CUT);
+        rSet.DisableItem(SID_DELETE_PAGE);
+        rSet.DisableItem(SID_DELETE_MASTER_PAGE);
     }
 }
 
@@ -860,57 +860,57 @@ void SlotManager::RenameSlide(const SfxRequest& rRequest)
                 mrSlideSorter.GetModel()));
     if (aSelectedPages.HasMoreElements())
         pSelectedPage = aSelectedPages.GetNextElement()->GetPage();
-    if (pSelectedPage != nullptr)
-    {
-        // tdf#107183 Set different dialog titles when renaming
-        // master slides or normal ones
-        OUString aTitle;
-        if( rRequest.GetSlot() == SID_RENAME_MASTER_PAGE )
-            aTitle = SdResId( STR_TITLE_RENAMEMASTER );
-        else
-            aTitle = SdResId( STR_TITLE_RENAMESLIDE );
+    if (pSelectedPage == nullptr)
+        return;
 
-        OUString aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
-        OUString aPageName = pSelectedPage->GetName();
+    // tdf#107183 Set different dialog titles when renaming
+    // master slides or normal ones
+    OUString aTitle;
+    if( rRequest.GetSlot() == SID_RENAME_MASTER_PAGE )
+        aTitle = SdResId( STR_TITLE_RENAMEMASTER );
+    else
+        aTitle = SdResId( STR_TITLE_RENAMESLIDE );
 
-        if(rRequest.GetArgs())
-        {
-           OUString aName;
-           aName = rRequest.GetArgs()->GetItem<const SfxStringItem>(SID_RENAMEPAGE)->GetValue();
+    OUString aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
+    OUString aPageName = pSelectedPage->GetName();
 
-           bool bResult =  RenameSlideFromDrawViewShell(pSelectedPage->GetPageNum()/2, aName );
-           DBG_ASSERT( bResult, "Couldn't rename slide" );
-        }
-        else
+    if(rRequest.GetArgs())
+    {
+       OUString aName;
+       aName = rRequest.GetArgs()->GetItem<const SfxStringItem>(SID_RENAMEPAGE)->GetValue();
+
+       bool bResult =  RenameSlideFromDrawViewShell(pSelectedPage->GetPageNum()/2, aName );
+       DBG_ASSERT( bResult, "Couldn't rename slide" );
+    }
+    else
+    {
+        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+        vcl::Window* pWin = mrSlideSorter.GetContentWindow();
+        ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(
+                pWin ? pWin->GetFrameWeld() : nullptr,
+                aPageName, aDescr));
+        aNameDlg->SetText( aTitle );
+        aNameDlg->SetCheckNameHdl( LINK( this, SlotManager, RenameSlideHdl ), true );
+        aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
+
+        if( aNameDlg->Execute() == RET_OK )
         {
-            SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-            vcl::Window* pWin = mrSlideSorter.GetContentWindow();
-            ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(
-                    pWin ? pWin->GetFrameWeld() : nullptr,
-                    aPageName, aDescr));
-            aNameDlg->SetText( aTitle );
-            aNameDlg->SetCheckNameHdl( LINK( this, SlotManager, RenameSlideHdl ), true );
-            aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
-
-            if( aNameDlg->Execute() == RET_OK )
+            OUString aNewName;
+            aNameDlg->GetName( aNewName );
+            if (aNewName != aPageName)
             {
-                OUString aNewName;
-                aNameDlg->GetName( aNewName );
-                if (aNewName != aPageName)
-                {
-                    bool bResult =
-                            RenameSlideFromDrawViewShell(
-                              pSelectedPage->GetPageNum()/2, aNewName );
-                    DBG_ASSERT( bResult, "Couldn't rename slide" );
-                }
+                bool bResult =
+                        RenameSlideFromDrawViewShell(
+                          pSelectedPage->GetPageNum()/2, aNewName );
+                DBG_ASSERT( bResult, "Couldn't rename slide" );
             }
-            aNameDlg.disposeAndClear();
         }
-        // Tell the slide sorter about the name change (necessary for
-        // accessibility.)
-        mrSlideSorter.GetController().PageNameHasChanged(
-                (pSelectedPage->GetPageNum()-1)/2, aPageName);
+        aNameDlg.disposeAndClear();
     }
+    // Tell the slide sorter about the name change (necessary for
+    // accessibility.)
+    mrSlideSorter.GetController().PageNameHasChanged(
+            (pSelectedPage->GetPageNum()-1)/2, aPageName);
 }
 
 IMPL_LINK(SlotManager, RenameSlideHdl, AbstractSvxNameDialog&, rDialog, bool)
diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
index 967606b4484f..78d61da20396 100644
--- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
@@ -78,19 +78,19 @@ void VisibleAreaManager::RequestVisible (
     const model::SharedPageDescriptor& rpDescriptor,
     const bool bForce)
 {
-    if (rpDescriptor)
+    if (!rpDescriptor)
+        return;
+
+    if (mnDisableCount == 0)
     {
-        if (mnDisableCount == 0)
-        {
-            maVisibleRequests.push_back(
-                mrSlideSorter.GetView().GetLayouter().GetPageObjectBox(
-                    rpDescriptor->GetPageIndex(),
-                    true));
-        }
-        if (bForce && ! mbIsCurrentSlideTrackingActive)
-            ActivateCurrentSlideTracking();
-        MakeVisible();
+        maVisibleRequests.push_back(
+            mrSlideSorter.GetView().GetLayouter().GetPageObjectBox(
+                rpDescriptor->GetPageIndex(),
+                true));
     }
+    if (bForce && ! mbIsCurrentSlideTrackingActive)
+        ActivateCurrentSlideTracking();
+    MakeVisible();
 }
 
 void VisibleAreaManager::RequestCurrentSlideVisible()
diff --git a/sd/source/ui/slidesorter/shell/SlideSorter.cxx b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
index 5e6520b45d2b..5009238fb57e 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorter.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorter.cxx
@@ -165,24 +165,24 @@ void SlideSorter::Init()
 
     // Initialize the window.
     sd::Window *pContentWindow = GetContentWindow().get();
-    if (pContentWindow)
-    {
-        vcl::Window* pParentWindow = pContentWindow->GetParent();
-        if (pParentWindow != nullptr)
-            pParentWindow->SetBackground(Wallpaper());
-        pContentWindow->SetBackground(Wallpaper());
-        pContentWindow->SetViewOrigin (Point(0,0));
-        // We do our own scrolling while dragging a page selection.
-        pContentWindow->SetUseDropScroll (false);
-        // Change the winbits so that the active window accepts the focus.
-        pContentWindow->SetStyle ((pContentWindow->GetStyle() & ~WB_DIALOGCONTROL) | WB_TABSTOP);
-        pContentWindow->Hide();
-
-        // Set view pointer of base class.
-        SetupControls();
-
-        mbIsValid = true;
-    }
+    if (!pContentWindow)
+        return;
+
+    vcl::Window* pParentWindow = pContentWindow->GetParent();
+    if (pParentWindow != nullptr)
+        pParentWindow->SetBackground(Wallpaper());
+    pContentWindow->SetBackground(Wallpaper());
+    pContentWindow->SetViewOrigin (Point(0,0));
+    // We do our own scrolling while dragging a page selection.
+    pContentWindow->SetUseDropScroll (false);
+    // Change the winbits so that the active window accepts the focus.
+    pContentWindow->SetStyle ((pContentWindow->GetStyle() & ~WB_DIALOGCONTROL) | WB_TABSTOP);
+    pContentWindow->Hide();
+
+    // Set view pointer of base class.
+    SetupControls();
+
+    mbIsValid = true;
 }
 
 SlideSorter::~SlideSorter()
diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index ad6d84131933..5f6fc84d9253 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -537,31 +537,31 @@ void SlideSorterViewShell::ReadFrameViewData (FrameView* pFrameView)
 void SlideSorterViewShell::WriteFrameViewData()
 {
     assert(mpSlideSorter.get()!=nullptr);
-    if (mpFrameView != nullptr)
-    {
-        view::SlideSorterView& rView (mpSlideSorter->GetView());
-        mpFrameView->SetSlidesPerRow(static_cast<sal_uInt16>(rView.GetLayouter().GetColumnCount()));
+    if (mpFrameView == nullptr)
+        return;
 
-        // DrawMode for 'main' window
-        if( mpFrameView->GetDrawMode() != GetActiveWindow()->GetDrawMode() )
-            mpFrameView->SetDrawMode( GetActiveWindow()->GetDrawMode() );
+    view::SlideSorterView& rView (mpSlideSorter->GetView());
+    mpFrameView->SetSlidesPerRow(static_cast<sal_uInt16>(rView.GetLayouter().GetColumnCount()));
 
-        SdPage* pActualPage = GetActualPage();
-        if (pActualPage != nullptr)
-        {
-            if (IsMainViewShell())
-                mpFrameView->SetSelectedPage((pActualPage->GetPageNum()- 1) / 2);
-            // else
-            // The slide sorter is not expected to switch the current page
-            // other than by double clicks.  That is handled separately.
-        }
-        else
-        {
-            // We have no current page to set but at least we can make sure
-            // that the index of the frame view has a legal value.
-            if (mpFrameView->GetSelectedPage() >= mpSlideSorter->GetModel().GetPageCount())
-                mpFrameView->SetSelectedPage(static_cast<sal_uInt16>(mpSlideSorter->GetModel().GetPageCount())-1);
-        }
+    // DrawMode for 'main' window
+    if( mpFrameView->GetDrawMode() != GetActiveWindow()->GetDrawMode() )
+        mpFrameView->SetDrawMode( GetActiveWindow()->GetDrawMode() );
+
+    SdPage* pActualPage = GetActualPage();
+    if (pActualPage != nullptr)
+    {
+        if (IsMainViewShell())
+            mpFrameView->SetSelectedPage((pActualPage->GetPageNum()- 1) / 2);
+        // else
+        // The slide sorter is not expected to switch the current page
+        // other than by double clicks.  That is handled separately.
+    }
+    else
+    {
+        // We have no current page to set but at least we can make sure
+        // that the index of the frame view has a legal value.
+        if (mpFrameView->GetSelectedPage() >= mpSlideSorter->GetModel().GetPageCount())
+            mpFrameView->SetSelectedPage(static_cast<sal_uInt16>(mpSlideSorter->GetModel().GetPageCount())-1);
     }
 }
 
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 69997e1357dc..2616e93eee60 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -439,79 +439,79 @@ void SlideSorterView::InvalidatePageObjectVisibilities()
 void SlideSorterView::DeterminePageObjectVisibilities()
 {
     sd::Window *pWindow (mrSlideSorter.GetContentWindow().get());
-    if (pWindow)
+    if (!pWindow)
+        return;
+
+    // Set this flag to true here so that an invalidate during the
+    // visibility calculation can correctly invalidate it again.
+    mbPageObjectVisibilitiesValid = true;
+
+    ::tools::Rectangle aViewArea (pWindow->PixelToLogic(::tools::Rectangle(Point(0,0),pWindow->GetSizePixel())));
+    const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(aViewArea));
+    const Range aUnion(
+        ::std::min(maVisiblePageRange.Min(), aRange.Min()),
+        ::std::max(maVisiblePageRange.Max(), aRange.Max()));
+
+    // For page objects that just dropped off the visible area we
+    // decrease the priority of pending requests for preview bitmaps.
+    if (maVisiblePageRange != aRange)
+        mbPreciousFlagUpdatePending |= true;
+
+    model::SharedPageDescriptor pDescriptor;
+    for (long nIndex=aUnion.Min(); nIndex<=aUnion.Max(); nIndex++)
     {
-        // Set this flag to true here so that an invalidate during the
-        // visibility calculation can correctly invalidate it again.
-        mbPageObjectVisibilitiesValid = true;
-
-        ::tools::Rectangle aViewArea (pWindow->PixelToLogic(::tools::Rectangle(Point(0,0),pWindow->GetSizePixel())));
-        const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(aViewArea));
-        const Range aUnion(
-            ::std::min(maVisiblePageRange.Min(), aRange.Min()),
-            ::std::max(maVisiblePageRange.Max(), aRange.Max()));
-
-        // For page objects that just dropped off the visible area we
-        // decrease the priority of pending requests for preview bitmaps.
-        if (maVisiblePageRange != aRange)
-            mbPreciousFlagUpdatePending |= true;
-
-        model::SharedPageDescriptor pDescriptor;
-        for (long nIndex=aUnion.Min(); nIndex<=aUnion.Max(); nIndex++)
-        {
-            pDescriptor = mrModel.GetPageDescriptor(nIndex);
-            if (pDescriptor.get() != nullptr)
-                SetState(
-                    pDescriptor,
-                    PageDescriptor::ST_Visible,
-                    aRange.IsInside(nIndex));
-        }
+        pDescriptor = mrModel.GetPageDescriptor(nIndex);
+        if (pDescriptor.get() != nullptr)
+            SetState(
+                pDescriptor,
+                PageDescriptor::ST_Visible,
+                aRange.IsInside(nIndex));
+    }
 
-        // Broadcast a change of the set of visible page objects.
-        if (maVisiblePageRange != aRange)
-        {
-            maVisiblePageRange = aRange;
+    // Broadcast a change of the set of visible page objects.
+    if (maVisiblePageRange != aRange)
+    {
+        maVisiblePageRange = aRange;
 
-            // Tell the listeners that the visibility of some objects has
-            // changed.
-            ::std::vector<Link<LinkParamNone*,void>>& aChangeListeners (maVisibilityChangeListeners);
-            for (const auto& rLink : aChangeListeners)
-            {
-                rLink.Call(nullptr);
-            }
+        // Tell the listeners that the visibility of some objects has
+        // changed.
+        ::std::vector<Link<LinkParamNone*,void>>& aChangeListeners (maVisibilityChangeListeners);
+        for (const auto& rLink : aChangeListeners)
+        {
+            rLink.Call(nullptr);
         }
-
-        // Restore the mouse over state.
-        UpdatePageUnderMouse();
     }
+
+    // Restore the mouse over state.
+    UpdatePageUnderMouse();
 }
 
 void SlideSorterView::UpdatePreciousFlags()
 {
-    if (mbPreciousFlagUpdatePending)
-    {
-        mbPreciousFlagUpdatePending = false;
+    if (!mbPreciousFlagUpdatePending)
+        return;
+
+    mbPreciousFlagUpdatePending = false;
 
-        model::SharedPageDescriptor pDescriptor;
-        std::shared_ptr<cache::PageCache> pCache = GetPreviewCache();
-        sal_Int32 nPageCount (mrModel.GetPageCount());
+    model::SharedPageDescriptor pDescriptor;
+    std::shared_ptr<cache::PageCache> pCache = GetPreviewCache();
+    sal_Int32 nPageCount (mrModel.GetPageCount());
 
-        for (int nIndex=0; nIndex<=nPageCount; ++nIndex)
+    for (int nIndex=0; nIndex<=nPageCount; ++nIndex)
+    {
+        pDescriptor = mrModel.GetPageDescriptor(nIndex);
+        if (pDescriptor.get() != nullptr)
         {
-            pDescriptor = mrModel.GetPageDescriptor(nIndex);
-            if (pDescriptor.get() != nullptr)
-            {
-                pCache->SetPreciousFlag(
-                    pDescriptor->GetPage(),
-                    maVisiblePageRange.IsInside(nIndex));
-            }
-            else
-            {
-                // At least one cache entry can not be updated.  Remember to
-                // repeat the whole updating later and leave the loop now.
-                mbPreciousFlagUpdatePending = true;
-                break;
-            }
+            pCache->SetPreciousFlag(
+                pDescriptor->GetPage(),
+                maVisiblePageRange.IsInside(nIndex));
+        }
+        else
+        {
+            // At least one cache entry can not be updated.  Remember to
+            // repeat the whole updating later and leave the loop now.
+            mbPreciousFlagUpdatePending = true;
+            break;
         }
     }
 }
@@ -770,20 +770,20 @@ void SlideSorterView::UpdatePageUnderMouse (
 void SlideSorterView::SetPageUnderMouse (
     const model::SharedPageDescriptor& rpDescriptor)
 {
-    if (mpPageUnderMouse != rpDescriptor)
-    {
-        if (mpPageUnderMouse)
-            SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false);
+    if (mpPageUnderMouse == rpDescriptor)
+        return;
 
-        mpPageUnderMouse = rpDescriptor;
+    if (mpPageUnderMouse)
+        SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false);
 
-        if (mpPageUnderMouse)
-            SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true);
+    mpPageUnderMouse = rpDescriptor;
 
-        // Change the quick help text to display the name of the page under
-        // the mouse.
-        mpToolTip->SetPage(rpDescriptor);
-    }
+    if (mpPageUnderMouse)
+        SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true);
+
+    // Change the quick help text to display the name of the page under
+    // the mouse.
+    mpToolTip->SetPage(rpDescriptor);
 }
 
 bool SlideSorterView::SetState (
diff --git a/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
index 3bb9477fbe1d..63ebfe3ddf9a 100644
--- a/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
+++ b/sd/source/ui/slidesorter/view/SlsInsertAnimator.cxx
@@ -322,27 +322,27 @@ void PageObjectRun::UpdateOffsets(
     const sal_Int32 nLocalInsertIndex(bIsVertical
         ? rInsertPosition.GetRow()
         : rInsertPosition.GetColumn());
-    if (nLocalInsertIndex != mnLocalInsertIndex)
-    {
-        mnLocalInsertIndex = nLocalInsertIndex;
+    if (nLocalInsertIndex == mnLocalInsertIndex)
+        return;
 
-        model::SlideSorterModel& rModel (mrAnimatorAccess.GetModel());
-        const sal_Int32 nRunLength (mnEndIndex - mnStartIndex + 1);
-        for (sal_Int32 nIndex=0; nIndex<nRunLength; ++nIndex)
-        {
-            model::SharedPageDescriptor pDescriptor(rModel.GetPageDescriptor(nIndex+mnStartIndex));
-            if (pDescriptor)
-                maStartOffset[nIndex] = pDescriptor->GetVisualState().GetLocationOffset();
-            maEndOffset[nIndex] = nIndex < mnLocalInsertIndex
-                ? rInsertPosition.GetLeadingOffset()
-                : rInsertPosition.GetTrailingOffset();
-            if (bIsVertical)
-                maEndOffset[nIndex].setX( 0 );
-            else
-                maEndOffset[nIndex].setY( 0 );
-        }
-        RestartAnimation();
+    mnLocalInsertIndex = nLocalInsertIndex;
+
+    model::SlideSorterModel& rModel (mrAnimatorAccess.GetModel());
+    const sal_Int32 nRunLength (mnEndIndex - mnStartIndex + 1);
+    for (sal_Int32 nIndex=0; nIndex<nRunLength; ++nIndex)
+    {
+        model::SharedPageDescriptor pDescriptor(rModel.GetPageDescriptor(nIndex+mnStartIndex));
+        if (pDescriptor)
+            maStartOffset[nIndex] = pDescriptor->GetVisualState().GetLocationOffset();
+        maEndOffset[nIndex] = nIndex < mnLocalInsertIndex
+            ? rInsertPosition.GetLeadingOffset()
+            : rInsertPosition.GetTrailingOffset();
+        if (bIsVertical)
+            maEndOffset[nIndex].setX( 0 );
+        else
+            maEndOffset[nIndex].setY( 0 );
     }
+    RestartAnimation();
 }
 
 void PageObjectRun::ResetOffsets (const controller::Animator::AnimationMode eMode)
diff --git a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
index c0b1bfa16c8e..60a4182afe3b 100644
--- a/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
+++ b/sd/source/ui/slidesorter/view/SlsInsertionIndicatorOverlay.cxx
@@ -244,38 +244,38 @@ void InsertionIndicatorOverlay::PaintPageCount (
     // Paint the number of slides.
     std::shared_ptr<view::Theme> pTheme (mrSlideSorter.GetTheme());
     std::shared_ptr<vcl::Font> pFont(Theme::GetFont(Theme::Font_PageCount, rDevice));
-    if (pFont)
-    {
-        OUString sNumber (OUString::number(nSelectionCount));
-
-        // Determine the size of the (painted) text and create a bounding
-        // box that centers the text on the first preview.
-        rDevice.SetFont(*pFont);
-        ::tools::Rectangle aTextBox;
-        rDevice.GetTextBoundRect(aTextBox, sNumber);
-        Point aTextOffset (aTextBox.TopLeft());
-        Size aTextSize (aTextBox.GetSize());
-        // Place text inside the first page preview.
-        Point aTextLocation(rFirstPageOffset);
-        // Center the text.
-        aTextLocation += Point(
-            (rPreviewSize.Width()-aTextBox.GetWidth())/2,
-            (rPreviewSize.Height()-aTextBox.GetHeight())/2);
-        aTextBox = ::tools::Rectangle(aTextLocation, aTextSize);
-
-        // Paint background, border and text.
-        static const sal_Int32 nBorder = 5;
-        rDevice.SetFillColor(pTheme->GetColor(Theme::Color_Selection));
-        rDevice.SetLineColor(pTheme->GetColor(Theme::Color_Selection));
-        rDevice.DrawRect(GrowRectangle(aTextBox, nBorder));
-
-        rDevice.SetFillColor();
-        rDevice.SetLineColor(pTheme->GetColor(Theme::Color_PageCountFontColor));
-        rDevice.DrawRect(GrowRectangle(aTextBox, nBorder-1));
-
-        rDevice.SetTextColor(pTheme->GetColor(Theme::Color_PageCountFontColor));
-        rDevice.DrawText(aTextBox.TopLeft()-aTextOffset, sNumber);
-    }
+    if (!pFont)
+        return;
+
+    OUString sNumber (OUString::number(nSelectionCount));
+
+    // Determine the size of the (painted) text and create a bounding
+    // box that centers the text on the first preview.
+    rDevice.SetFont(*pFont);
+    ::tools::Rectangle aTextBox;
+    rDevice.GetTextBoundRect(aTextBox, sNumber);
+    Point aTextOffset (aTextBox.TopLeft());
+    Size aTextSize (aTextBox.GetSize());
+    // Place text inside the first page preview.
+    Point aTextLocation(rFirstPageOffset);
+    // Center the text.
+    aTextLocation += Point(
+        (rPreviewSize.Width()-aTextBox.GetWidth())/2,
+        (rPreviewSize.Height()-aTextBox.GetHeight())/2);
+    aTextBox = ::tools::Rectangle(aTextLocation, aTextSize);
+
+    // Paint background, border and text.
+    static const sal_Int32 nBorder = 5;
+    rDevice.SetFillColor(pTheme->GetColor(Theme::Color_Selection));
+    rDevice.SetLineColor(pTheme->GetColor(Theme::Color_Selection));
+    rDevice.DrawRect(GrowRectangle(aTextBox, nBorder));
+
+    rDevice.SetFillColor();
+    rDevice.SetLineColor(pTheme->GetColor(Theme::Color_PageCountFontColor));
+    rDevice.DrawRect(GrowRectangle(aTextBox, nBorder-1));
+
+    rDevice.SetTextColor(pTheme->GetColor(Theme::Color_PageCountFontColor));
+    rDevice.DrawText(aTextBox.TopLeft()-aTextOffset, sNumber);
 }
 
 void InsertionIndicatorOverlay::SetLocation (const Point& rLocation)
@@ -318,35 +318,35 @@ void InsertionIndicatorOverlay::SetLayerInvalidator (const SharedILayerInvalidat
 
 void InsertionIndicatorOverlay::Show()
 {
-    if ( ! mbIsVisible)
-    {
-        mbIsVisible = true;
+    if (  mbIsVisible)
+        return;
 
-        std::shared_ptr<LayeredDevice> pLayeredDevice (
-            mrSlideSorter.GetView().GetLayeredDevice());
-        if (pLayeredDevice)
-        {
-            pLayeredDevice->RegisterPainter(shared_from_this(), gnLayerIndex);
-            if (mpLayerInvalidator)
-                mpLayerInvalidator->Invalidate(GetBoundingBox());
-        }
+    mbIsVisible = true;
+
+    std::shared_ptr<LayeredDevice> pLayeredDevice (
+        mrSlideSorter.GetView().GetLayeredDevice());
+    if (pLayeredDevice)
+    {
+        pLayeredDevice->RegisterPainter(shared_from_this(), gnLayerIndex);
+        if (mpLayerInvalidator)
+            mpLayerInvalidator->Invalidate(GetBoundingBox());
     }
 }
 
 void InsertionIndicatorOverlay::Hide()
 {
-    if (mbIsVisible)
-    {
-        mbIsVisible = false;
+    if (!mbIsVisible)
+        return;
 
-        std::shared_ptr<LayeredDevice> pLayeredDevice (
-            mrSlideSorter.GetView().GetLayeredDevice());
-        if (pLayeredDevice)
-        {
-            if (mpLayerInvalidator)
-                mpLayerInvalidator->Invalidate(GetBoundingBox());
-            pLayeredDevice->RemovePainter(shared_from_this(), gnLayerIndex);
-        }
+    mbIsVisible = false;
+
+    std::shared_ptr<LayeredDevice> pLayeredDevice (
+        mrSlideSorter.GetView().GetLayeredDevice());
+    if (pLayeredDevice)
+    {
+        if (mpLayerInvalidator)
+            mpLayerInvalidator->Invalidate(GetBoundingBox());
+        pLayeredDevice->RemovePainter(shared_from_this(), gnLayerIndex);
     }
 }
 
diff --git a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
index 9332934258ed..395181bbce4c 100644
--- a/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
+++ b/sd/source/ui/slidesorter/view/SlsPageObjectPainter.cxx
@@ -68,22 +68,22 @@ void PageObjectPainter::PaintPageObject (
     OutputDevice& rDevice,
     const model::SharedPageDescriptor& rpDescriptor)
 {
-    if (UpdatePageObjectLayouter())
-    {
-        PageObjectLayouter *pPageObjectLayouter = mrLayouter.GetPageObjectLayouter().get();
-        // Turn off antialiasing to avoid the bitmaps from being
-        // shifted by fractions of a pixel and thus show blurry edges.
-        const AntialiasingFlags nSavedAntialiasingMode (rDevice.GetAntialiasing());
-        rDevice.SetAntialiasing(nSavedAntialiasingMode & ~AntialiasingFlags::EnableB2dDraw);
-
-        PaintBackground(pPageObjectLayouter, rDevice, rpDescriptor);
-        PaintPreview(pPageObjectLayouter, rDevice, rpDescriptor);
-        PaintPageNumber(pPageObjectLayouter, rDevice, rpDescriptor);
-        PaintTransitionEffect(pPageObjectLayouter, rDevice, rpDescriptor);
-        if (rpDescriptor->GetPage()->hasAnimationNode())
-            PaintCustomAnimationEffect(pPageObjectLayouter, rDevice, rpDescriptor);
-        rDevice.SetAntialiasing(nSavedAntialiasingMode);
-    }
+    if (!UpdatePageObjectLayouter())
+        return;
+
+    PageObjectLayouter *pPageObjectLayouter = mrLayouter.GetPageObjectLayouter().get();
+    // Turn off antialiasing to avoid the bitmaps from being
+    // shifted by fractions of a pixel and thus show blurry edges.
+    const AntialiasingFlags nSavedAntialiasingMode (rDevice.GetAntialiasing());
+    rDevice.SetAntialiasing(nSavedAntialiasingMode & ~AntialiasingFlags::EnableB2dDraw);
+
+    PaintBackground(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintPreview(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintPageNumber(pPageObjectLayouter, rDevice, rpDescriptor);
+    PaintTransitionEffect(pPageObjectLayouter, rDevice, rpDescriptor);
+    if (rpDescriptor->GetPage()->hasAnimationNode())
+        PaintCustomAnimationEffect(pPageObjectLayouter, rDevice, rpDescriptor);
+    rDevice.SetAntialiasing(nSavedAntialiasingMode);
 }
 
 bool PageObjectPainter::UpdatePageObjectLayouter()
@@ -137,19 +137,19 @@ void PageObjectPainter::PaintPreview (
         PageObjectLayouter::Part::Preview,
         PageObjectLayouter::ModelCoordinateSystem));
 
-    if (mpCache != nullptr)
-    {
-        const SdrPage* pPage = rpDescriptor->GetPage();
-        mpCache->SetPreciousFlag(pPage, true);
+    if (mpCache == nullptr)
+        return;
 
-        const BitmapEx aPreview (GetPreviewBitmap(rpDescriptor, &rDevice));
-        if ( ! aPreview.IsEmpty())
-        {
-            if (aPreview.GetSizePixel() != aBox.GetSize())
-                rDevice.DrawBitmapEx(aBox.TopLeft(), aBox.GetSize(), aPreview);
-            else
-                rDevice.DrawBitmapEx(aBox.TopLeft(), aPreview);
-        }
+    const SdrPage* pPage = rpDescriptor->GetPage();
+    mpCache->SetPreciousFlag(pPage, true);
+
+    const BitmapEx aPreview (GetPreviewBitmap(rpDescriptor, &rDevice));
+    if ( ! aPreview.IsEmpty())
+    {
+        if (aPreview.GetSizePixel() != aBox.GetSize())
+            rDevice.DrawBitmapEx(aBox.TopLeft(), aBox.GetSize(), aPreview);
+        else
+            rDevice.DrawBitmapEx(aBox.TopLeft(), aPreview);
     }
 }
 
diff --git a/sd/source/ui/slidesorter/view/SlsToolTip.cxx b/sd/source/ui/slidesorter/view/SlsToolTip.cxx
index df492bcb23a9..025c2624587a 100644
--- a/sd/source/ui/slidesorter/view/SlsToolTip.cxx
+++ b/sd/source/ui/slidesorter/view/SlsToolTip.cxx
@@ -54,45 +54,45 @@ ToolTip::~ToolTip()
 
 void ToolTip::SetPage (const model::SharedPageDescriptor& rpDescriptor)
 {
-    if (mpDescriptor != rpDescriptor)
-    {
-        maShowTimer.Stop();
-        bool bWasVisible = Hide();
+    if (mpDescriptor == rpDescriptor)
+        return;
 
-        if (bWasVisible)
-        {
-            maHiddenTimer.Start();
-        }
+    maShowTimer.Stop();
+    bool bWasVisible = Hide();
+
+    if (bWasVisible)
+    {
+        maHiddenTimer.Start();
+    }
 
-        mpDescriptor = rpDescriptor;
+    mpDescriptor = rpDescriptor;
 
-        if (mpDescriptor)
+    if (mpDescriptor)
+    {
+        SdPage* pPage = mpDescriptor->GetPage();
+        OUString sHelpText;
+        if (pPage != nullptr)
+            sHelpText = pPage->GetName();
+        else
         {
-            SdPage* pPage = mpDescriptor->GetPage();
-            OUString sHelpText;
-            if (pPage != nullptr)
-                sHelpText = pPage->GetName();
-            else
-            {
-                OSL_ASSERT(mpDescriptor->GetPage() != nullptr);
-            }
-            if (sHelpText.isEmpty())
-            {
-                sHelpText = SdResId(STR_PAGE);
-                sHelpText += OUString::number(mpDescriptor->GetPageIndex()+1);
-            }
-
-            msCurrentHelpText = sHelpText;
-            // show new tooltip immediately, if last one was recently hidden
-            if(maHiddenTimer.IsActive())
-                DoShow();
-            else
-                maShowTimer.Start();
+            OSL_ASSERT(mpDescriptor->GetPage() != nullptr);
         }
-        else
+        if (sHelpText.isEmpty())
         {
-            msCurrentHelpText.clear();
+            sHelpText = SdResId(STR_PAGE);
+            sHelpText += OUString::number(mpDescriptor->GetPageIndex()+1);
         }
+
+        msCurrentHelpText = sHelpText;
+        // show new tooltip immediately, if last one was recently hidden
+        if(maHiddenTimer.IsActive())
+            DoShow();
+        else
+            maShowTimer.Start();
+    }
+    else
+    {
+        msCurrentHelpText.clear();
     }
 }
 
@@ -106,36 +106,36 @@ void ToolTip::DoShow()
     }
 
     sd::Window *pWindow (mrSlideSorter.GetContentWindow().get());
-    if (!msCurrentHelpText.isEmpty() && pWindow)
-    {
-        ::tools::Rectangle aBox (
-            mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
-                mpDescriptor,
-                PageObjectLayouter::Part::Preview,
-                PageObjectLayouter::WindowCoordinateSystem));
-
-        // Do not show the help text when the (lower edge of the ) preview
-        // is not visible.  The tool tip itself may still be outside the
-        // window.
-        if (aBox.Bottom() >= pWindow->GetSizePixel().Height())
-            return;
-
-        vcl::Window* pParent (pWindow);
-        while (pParent!=nullptr && pParent->GetParent()!=nullptr)
-            pParent = pParent->GetParent();
-        const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft());
-
-        // We do not know how high the tool tip will be but want its top
-        // edge not its bottom to be at a specific position (a little below
-        // the preview).  Therefore we use a little trick and place the tool
-        // tip at the top of a rectangle that is placed below the preview.
-        aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3);
-        mnHelpWindowHandle = Help::ShowPopover(
-            pWindow,
-            aBox,
-            msCurrentHelpText,
-            QuickHelpFlags::Center | QuickHelpFlags::Top);
-    }
+    if (msCurrentHelpText.isEmpty() || !pWindow)
+        return;
+
+    ::tools::Rectangle aBox (
+        mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
+            mpDescriptor,
+            PageObjectLayouter::Part::Preview,
+            PageObjectLayouter::WindowCoordinateSystem));
+
+    // Do not show the help text when the (lower edge of the ) preview
+    // is not visible.  The tool tip itself may still be outside the
+    // window.
+    if (aBox.Bottom() >= pWindow->GetSizePixel().Height())
+        return;
+
+    vcl::Window* pParent (pWindow);
+    while (pParent!=nullptr && pParent->GetParent()!=nullptr)
+        pParent = pParent->GetParent();
+    const Point aOffset (pWindow->GetWindowExtentsRelative(pParent).TopLeft());
+
+    // We do not know how high the tool tip will be but want its top
+    // edge not its bottom to be at a specific position (a little below
+    // the preview).  Therefore we use a little trick and place the tool
+    // tip at the top of a rectangle that is placed below the preview.
+    aBox.Move(aOffset.X(), aOffset.Y() + aBox.GetHeight() + 3);
+    mnHelpWindowHandle = Help::ShowPopover(
+        pWindow,
+        aBox,
+        msCurrentHelpText,
+        QuickHelpFlags::Center | QuickHelpFlags::Top);
 }
 
 bool ToolTip::Hide()


More information about the Libreoffice-commits mailing list