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