Blame SOURCES/0001-rhbz-1168757-propagate-selected-slides-to-print-dial.patch

f325b2
From 6184f8debb94571c11ab085ccbc5f431459fe1d5 Mon Sep 17 00:00:00 2001
f325b2
From: David Tardon <dtardon@redhat.com>
f325b2
Date: Wed, 20 Jan 2016 18:40:06 +0100
f325b2
Subject: [PATCH] rhbz#1168757 propagate selected slides to print dialog
f325b2
f325b2
(cherry picked from commit f90f8329fe5e95f25ba449e307fd40d56d68d3bb)
f325b2
f325b2
Change-Id: Icef119baffb8985ea0cb94d7e59f0daae88023ac
f325b2
---
f325b2
 sd/source/ui/view/DocumentRenderer.cxx | 41 ++++++++++++++++++++++++++++++----
f325b2
 1 file changed, 37 insertions(+), 4 deletions(-)
f325b2
f325b2
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
f325b2
index 734c61a..8924468 100644
f325b2
--- a/sd/source/ui/view/DocumentRenderer.cxx
f325b2
+++ b/sd/source/ui/view/DocumentRenderer.cxx
f325b2
@@ -33,10 +33,12 @@
f325b2
 #include "FrameView.hxx"
f325b2
 #include "Outliner.hxx"
f325b2
 #include "OutlineViewShell.hxx"
f325b2
+#include "SlideSorterViewShell.hxx"
f325b2
 
f325b2
 #include <basegfx/polygon/b2dpolygon.hxx>
f325b2
 #include <basegfx/polygon/b2dpolypolygon.hxx>
f325b2
 #include <basegfx/matrix/b2dhommatrix.hxx>
f325b2
+#include <rtl/ustrbuf.hxx>
f325b2
 #include <sfx2/printer.hxx>
f325b2
 #include <editeng/editstat.hxx>
f325b2
 #include <editeng/outlobj.hxx>
f325b2
@@ -333,8 +335,9 @@ namespace {
f325b2
     class DialogCreator : Resource
f325b2
     {
f325b2
     public:
f325b2
-        DialogCreator (bool bImpress, sal_Int32 nCurPage)
f325b2
+        DialogCreator (ViewShellBase &rBase, bool bImpress, sal_Int32 nCurPage)
f325b2
             : Resource(SdResId(_STR_IMPRESS_PRINT_UI_OPTIONS))
f325b2
+            , mrBase(rBase)
f325b2
             , mbImpress(bImpress)
f325b2
             , mnCurPage(nCurPage)
f325b2
         {
f325b2
@@ -359,6 +362,7 @@ namespace {
f325b2
         }
f325b2
 
f325b2
     private:
f325b2
+        ViewShellBase &mrBase;
f325b2
         ::std::vector<beans::PropertyValue> maProperties;
f325b2
         ::std::vector<sal_Int32> maSlidesPerPage;
f325b2
         bool mbImpress;
f325b2
@@ -584,19 +588,48 @@ namespace {
f325b2
             aWidgetIds[0] = "printallpages";
f325b2
             aWidgetIds[1] = "printpages";
f325b2
             aWidgetIds[2] = "printselection";
f325b2
+
f325b2
+            // check if there is a selection of slides
f325b2
+            OUString aPageRange(OUString::number(mnCurPage + 1));
f325b2
+            int nPrintRange(0);
f325b2
+            using sd::slidesorter::SlideSorterViewShell;
f325b2
+            SlideSorterViewShell* const pSSViewSh(SlideSorterViewShell::GetSlideSorter(mrBase));
f325b2
+            if (pSSViewSh)
f325b2
+            {
f325b2
+                const boost::shared_ptr<SlideSorterViewShell::PageSelection> pPageSelection(pSSViewSh->GetPageSelection());
f325b2
+                if (bool(pPageSelection) && pPageSelection->size() > 1)
f325b2
+                {
f325b2
+                    OUStringBuffer aBuf;
f325b2
+                    // TODO: this could be improved by writing ranges instead of consecutive page
f325b2
+                    // numbers if appropriate. Do we have a helper function for that somewhere?
f325b2
+                    bool bFirst(true);
f325b2
+                    for (auto pPage: *pPageSelection)
f325b2
+                    {
f325b2
+                        if (!bFirst)
f325b2
+                        {
f325b2
+                            aBuf.append(',');
f325b2
+                            bFirst = false;
f325b2
+                        }
f325b2
+                        aBuf.append(OUString::number(pPage->GetPageNum() / 2 + 1));
f325b2
+                    }
f325b2
+                    aPageRange = aBuf.getStr();
f325b2
+                    nPrintRange = 1;
f325b2
+                }
f325b2
+            }
f325b2
+
f325b2
             AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(aWidgetIds, "",
f325b2
                                 aHelpIds,
f325b2
                                 aPrintRangeName,
f325b2
                                 CreateChoice(mbImpress
f325b2
                                              ? _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE
f325b2
                                              : _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE),
f325b2
-                                0 )
f325b2
+                                nPrintRange )
f325b2
                             );
f325b2
             // create a an Edit dependent on "Pages" selected
f325b2
             vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, true );
f325b2
             AddDialogControl(vcl::PrinterOptionsHelper::setEditControlOpt("pagerange", "",
f325b2
                                 ".HelpID:vcl:PrintDialog:PageRange:Edit", "PageRange",
f325b2
-                                OUString::number(mnCurPage + 1), aPageRangeOpt));
f325b2
+                                aPageRange, aPageRangeOpt));
f325b2
 
f325b2
             FreeResource();
f325b2
         }
f325b2
@@ -1140,7 +1173,7 @@ public:
f325b2
         , mpPrintView()
f325b2
         , mbHasOrientationWarningBeenShown(false)
f325b2
     {
f325b2
-        DialogCreator aCreator( mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() );
f325b2
+        DialogCreator aCreator( mrBase, mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() );
f325b2
         m_aUIProperties = aCreator.GetDialogControls();
f325b2
         maSlidesPerPage = aCreator.GetSlidesPerPage();
f325b2
 
f325b2
-- 
f325b2
2.5.0
f325b2