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