Blame SOURCES/0001-allow-slide-design-to-affect-multiple-standard-pages.patch

f325b2
From f7ed8b99b628625851fb28ec1a3dead710c8871c Mon Sep 17 00:00:00 2001
f325b2
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f325b2
Date: Tue, 23 Jun 2015 16:54:52 +0100
f325b2
Subject: [PATCH] allow slide design to affect multiple standard pages
f325b2
f325b2
modify this minimally and select all standard pages
f325b2
selected in the slidesorted, unselect them afterwards
f325b2
and loop over the selected ones.
f325b2
f325b2
This looks like it could do with a rework to disentangle
f325b2
the master/standard pages stuff, but leave it as is in
f325b2
this commit
f325b2
f325b2
Change-Id: Ifd01fe21c91e5e6b07b2d8bba0d85facadc25998
f325b2
---
f325b2
 sd/source/ui/func/fuprlout.cxx | 94 +++++++++++++++++++++++++++++-------------
f325b2
 1 file changed, 66 insertions(+), 28 deletions(-)
f325b2
f325b2
diff --git a/sd/source/ui/func/fuprlout.cxx b/sd/source/ui/func/fuprlout.cxx
f325b2
index 6ce661f..f087ad9 100644
f325b2
--- a/sd/source/ui/func/fuprlout.cxx
f325b2
+++ b/sd/source/ui/func/fuprlout.cxx
f325b2
@@ -42,6 +42,7 @@
f325b2
 #include "strmname.h"
f325b2
 #include "app.hrc"
f325b2
 #include "DrawDocShell.hxx"
f325b2
+#include "SlideSorterViewShell.hxx"
f325b2
 #include "unprlout.hxx"
f325b2
 #include "unchss.hxx"
f325b2
 #include "unmovss.hxx"
f325b2
@@ -89,24 +90,6 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
 
f325b2
     bool bError = false;
f325b2
 
f325b2
-    // determine the active page
f325b2
-    sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND;
f325b2
-    for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++)
f325b2
-    {
f325b2
-        if (mpDoc->GetSdPage(nPage, PK_STANDARD)->IsSelected())
f325b2
-        {
f325b2
-            nSelectedPage = nPage;
f325b2
-            break;
f325b2
-        }
f325b2
-    }
f325b2
-
f325b2
-    DBG_ASSERT(nSelectedPage != SDRPAGE_NOTFOUND, "no selected page");
f325b2
-    SdPage* pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD);
f325b2
-    OUString aOldLayoutName(pSelectedPage->GetLayoutName());
f325b2
-    sal_Int32 nPos = aOldLayoutName.indexOf(SD_LT_SEPARATOR);
f325b2
-    if (nPos != -1)
f325b2
-        aOldLayoutName = aOldLayoutName.copy(0, nPos);
f325b2
-
f325b2
     /* if we are on a master page, the changes apply for all pages and notes-
f325b2
        pages who are using the relevant layout */
f325b2
     bool bOnMaster = false;
f325b2
@@ -117,6 +100,51 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
         if (eEditMode == EM_MASTERPAGE)
f325b2
             bOnMaster = true;
f325b2
     }
f325b2
+
f325b2
+    std::vector<SdPage*> aUnselect;
f325b2
+    if (!bOnMaster)
f325b2
+    {
f325b2
+        //We later rely on IsSelected, so transfer the selection here
f325b2
+        //into the document
f325b2
+        slidesorter::SlideSorterViewShell* pSlideSorterViewShell
f325b2
+            = slidesorter::SlideSorterViewShell::GetSlideSorter(mpViewShell->GetViewShellBase());
f325b2
+        if (pSlideSorterViewShell)
f325b2
+        {
f325b2
+            boost::shared_ptr<slidesorter::SlideSorterViewShell::PageSelection> xSelection(
f325b2
+                pSlideSorterViewShell->GetPageSelection());
f325b2
+            if (xSelection)
f325b2
+            {
f325b2
+                for (auto it = xSelection->begin(); it != xSelection->end(); ++it)
f325b2
+                {
f325b2
+                    SdPage *pPage = *it;
f325b2
+                    if (pPage->IsSelected() || pPage->GetPageKind() != PK_STANDARD)
f325b2
+                        continue;
f325b2
+                    mpDoc->SetSelected(pPage, true);
f325b2
+                    aUnselect.push_back(pPage);
f325b2
+                }
f325b2
+            }
f325b2
+        }
f325b2
+    }
f325b2
+
f325b2
+    std::vector<SdPage*> aSelectedPages;
f325b2
+    std::vector<sal_uInt16> aSelectedPageNums;
f325b2
+    // determine the active pages
f325b2
+    for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++)
f325b2
+    {
f325b2
+        SdPage* pPage = mpDoc->GetSdPage(nPage, PK_STANDARD);
f325b2
+        if (pPage->IsSelected())
f325b2
+        {
f325b2
+            aSelectedPages.push_back(pPage);
f325b2
+            aSelectedPageNums.push_back(nPage);
f325b2
+        }
f325b2
+    }
f325b2
+
f325b2
+    assert(!aSelectedPages.empty() && "no selected page");
f325b2
+    OUString aOldLayoutName(aSelectedPages.back()->GetLayoutName());
f325b2
+    sal_Int32 nPos = aOldLayoutName.indexOf(SD_LT_SEPARATOR);
f325b2
+    if (nPos != -1)
f325b2
+        aOldLayoutName = aOldLayoutName.copy(0, nPos);
f325b2
+
f325b2
     bool bMasterPage = bOnMaster;
f325b2
     bool bCheckMasters = false;
f325b2
 
f325b2
@@ -196,14 +224,15 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
             OUString aLayoutName;
f325b2
             if( pTempDoc )
f325b2
                 aLayoutName = aFile.getToken(1, DOCUMENT_TOKEN);
f325b2
-
f325b2
-            mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
f325b2
+            for (auto nSelectedPage : aSelectedPageNums)
f325b2
+                mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters);
f325b2
             mpDoc->CloseBookmarkDoc();
f325b2
         }
f325b2
         else
f325b2
         {
f325b2
             // use master page with the layout name aFile from current Doc
f325b2
-            mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
f325b2
+            for (auto nSelectedPage : aSelectedPageNums)
f325b2
+                mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters);
f325b2
         }
f325b2
 
f325b2
         // remove blocking
f325b2
@@ -211,7 +240,7 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
             static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(false);
f325b2
 
f325b2
         // if the master page was visible, show it again
f325b2
-        if (!bError && nSelectedPage != SDRPAGE_NOTFOUND)
f325b2
+        if (!bError)
f325b2
         {
f325b2
             if (bOnMaster)
f325b2
             {
f325b2
@@ -219,13 +248,16 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
                 {
f325b2
                     ::sd::View* pView =
f325b2
                           static_cast<DrawViewShell*>(mpViewShell)->GetView();
f325b2
-                    sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
f325b2
+                    for (auto pSelectedPage : aSelectedPages)
f325b2
+                    {
f325b2
+                        sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum();
f325b2
 
f325b2
-                    if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES)
f325b2
-                        nPgNum++;
f325b2
+                        if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES)
f325b2
+                            nPgNum++;
f325b2
 
f325b2
-                    pView->HideSdrPage();
f325b2
-                    pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
f325b2
+                        pView->HideSdrPage();
f325b2
+                        pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum));
f325b2
+                    }
f325b2
                 }
f325b2
 
f325b2
                 // force update of TabBar
f325b2
@@ -233,10 +265,16 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
f325b2
             }
f325b2
             else
f325b2
             {
f325b2
-                pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
f325b2
+                for (auto pSelectedPage : aSelectedPages)
f325b2
+                    pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout());
f325b2
             }
f325b2
         }
f325b2
 
f325b2
+        //Undo transfer to document selection
f325b2
+        for (auto pPage : aUnselect)
f325b2
+            mpDoc->SetSelected(pPage, false);
f325b2
+
f325b2
+
f325b2
         // fake a mode change to repaint the page tab bar
f325b2
         if( mpViewShell && mpViewShell->ISA( DrawViewShell ) )
f325b2
         {
f325b2
-- 
f325b2
2.4.0
f325b2