[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sd/source

Caolán McNamara caolanm at redhat.com
Mon May 14 13:44:51 UTC 2018


 sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx |    5 +-
 sd/source/ui/slidesorter/model/SlideSorterModel.cxx     |   29 +++++++++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)

New commits:
commit f2cc4285c51addcb3814222616778c18dd311fe0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 11 11:16:54 2018 +0100

    Resolves: tdf#117475 page properties change triggers page reorder event
    
    and page reorder remove and re-inserts the slide in the slide sorter, so the
    selected page property is removed when the page doesn't really get removed. So
    then there's no selection to apply the later master page property to.
    
    Change-Id: I4a32958542da1bf2f5041dde0294a772645e30ad
    Reviewed-on: https://gerrit.libreoffice.org/54127
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
index 0837c565e5a5..e5d859f743be 100644
--- a/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
+++ b/sd/source/ui/slidesorter/inc/model/SlideSorterModel.hxx
@@ -216,8 +216,9 @@ private:
     void AdaptSize();
 
     SdPage* GetPage (const sal_Int32 nCoreIndex) const;
-    void InsertSlide (SdPage* pPage);
-    void DeleteSlide (const SdPage* pPage);
+    void InsertSlide (SdPage* pPage, bool bMarkSelected);
+    // return if this page was marked as selected before being removed
+    bool DeleteSlide (const SdPage* pPage);
     void UpdateIndices (const sal_Int32 nFirstIndex);
 };
 
diff --git a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
index 0267860dfecc..44d29094fc2a 100644
--- a/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
+++ b/sd/source/ui/slidesorter/model/SlideSorterModel.cxx
@@ -534,15 +534,17 @@ bool SlideSorterModel::NotifyPageEvent (const SdrPage* pSdrPage)
     //NotifyPageEvent is called for add, remove, *and* change position so for
     //the change position case we must ensure we don't end up with the slide
     //duplicated in our list
-    DeleteSlide(pPage);
+    bool bSelected = DeleteSlide(pPage);
     if (pPage->IsInserted())
-        InsertSlide(pPage);
+    {
+        InsertSlide(pPage, bSelected);
+    }
     CheckModel(*this);
 
     return true;
 }
 
-void SlideSorterModel::InsertSlide (SdPage* pPage)
+void SlideSorterModel::InsertSlide(SdPage* pPage, bool bMarkSelected)
 {
     // Find the index at which to insert the given page.
     sal_uInt16 nCoreIndex (pPage->GetPageNum());
@@ -559,19 +561,24 @@ void SlideSorterModel::InsertSlide (SdPage* pPage)
         if (GetPage(nIndex+1) != GetPageDescriptor(nIndex)->GetPage())
             return;
 
+    auto iter = maPageDescriptors.begin() + nIndex;
+
     // Insert the given page at index nIndex
-    maPageDescriptors.insert(
-        maPageDescriptors.begin()+nIndex,
+    iter = maPageDescriptors.insert(
+        iter,
         std::make_shared<PageDescriptor>(
                 Reference<drawing::XDrawPage>(mxSlides->getByIndex(nIndex),UNO_QUERY),
                 pPage,
                 nIndex));
 
+    if (bMarkSelected)
+        (*iter)->SetState(PageDescriptor::ST_Selected, true);
+
     // Update page indices.
     UpdateIndices(nIndex+1);
 }
 
-void SlideSorterModel::DeleteSlide (const SdPage* pPage)
+bool SlideSorterModel::DeleteSlide (const SdPage* pPage)
 {
     sal_Int32 nIndex(0);
 
@@ -594,15 +601,21 @@ void SlideSorterModel::DeleteSlide (const SdPage* pPage)
         }
     }
 
+    bool bMarkedSelected(false);
+
     if(nIndex >= 0 && nIndex < static_cast<sal_Int32>(maPageDescriptors.size()))
     {
         if (maPageDescriptors[nIndex])
             if (maPageDescriptors[nIndex]->GetPage() != pPage)
-                return;
+                return false;
 
-        maPageDescriptors.erase(maPageDescriptors.begin()+nIndex);
+        auto iter = maPageDescriptors.begin() + nIndex;
+        bMarkedSelected = (*iter)->HasState(PageDescriptor::ST_Selected);
+        maPageDescriptors.erase(iter);
         UpdateIndices(nIndex);
     }
+
+    return bMarkedSelected;
 }
 
 void SlideSorterModel::UpdateIndices (const sal_Int32 nFirstIndex)


More information about the Libreoffice-commits mailing list