1 |
From 830b0e364cb1fec07664e1d5ec8a4c9593009959 Mon Sep 17 00:00:00 2001 |
2 |
From: David Tardon <dtardon@redhat.com> |
3 |
Date: Wed, 20 Jan 2016 18:40:06 +0100 |
4 |
Subject: [PATCH] rhbz#1168757 propagate selected slides to print dialog |
5 |
|
6 |
Change-Id: Icef119baffb8985ea0cb94d7e59f0daae88023ac |
7 |
(cherry picked from commit f90f8329fe5e95f25ba449e307fd40d56d68d3bb) |
8 |
--- |
9 |
sd/source/ui/view/DocumentRenderer.cxx | 41 ++++++++++++++++++++++++++++++---- |
10 |
1 file changed, 37 insertions(+), 4 deletions(-) |
11 |
|
12 |
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx |
13 |
index fd2b69c..d3b0a65 100644 |
14 |
--- a/sd/source/ui/view/DocumentRenderer.cxx |
15 |
+++ b/sd/source/ui/view/DocumentRenderer.cxx |
16 |
@@ -33,10 +33,12 @@ |
17 |
#include "FrameView.hxx" |
18 |
#include "Outliner.hxx" |
19 |
#include "OutlineViewShell.hxx" |
20 |
+#include "SlideSorterViewShell.hxx" |
21 |
|
22 |
#include <basegfx/polygon/b2dpolygon.hxx> |
23 |
#include <basegfx/polygon/b2dpolypolygon.hxx> |
24 |
#include <basegfx/matrix/b2dhommatrix.hxx> |
25 |
+#include <rtl/ustrbuf.hxx> |
26 |
#include <sfx2/printer.hxx> |
27 |
#include <editeng/editstat.hxx> |
28 |
#include <editeng/outlobj.hxx> |
29 |
@@ -333,8 +335,9 @@ namespace { |
30 |
class DialogCreator : Resource |
31 |
{ |
32 |
public: |
33 |
- DialogCreator (bool bImpress, sal_Int32 nCurPage) |
34 |
+ DialogCreator (ViewShellBase &rBase, bool bImpress, sal_Int32 nCurPage) |
35 |
: Resource(SdResId(_STR_IMPRESS_PRINT_UI_OPTIONS)) |
36 |
+ , mrBase(rBase) |
37 |
, mbImpress(bImpress) |
38 |
, mnCurPage(nCurPage) |
39 |
{ |
40 |
@@ -359,6 +362,7 @@ namespace { |
41 |
} |
42 |
|
43 |
private: |
44 |
+ ViewShellBase &mrBase; |
45 |
std::vector<beans::PropertyValue> maProperties; |
46 |
std::vector<sal_Int32> maSlidesPerPage; |
47 |
bool mbImpress; |
48 |
@@ -584,19 +588,48 @@ namespace { |
49 |
aWidgetIds[0] = "printallpages"; |
50 |
aWidgetIds[1] = "printpages"; |
51 |
aWidgetIds[2] = "printselection"; |
52 |
+ |
53 |
+ // check if there is a selection of slides |
54 |
+ OUString aPageRange(OUString::number(mnCurPage + 1)); |
55 |
+ int nPrintRange(0); |
56 |
+ using sd::slidesorter::SlideSorterViewShell; |
57 |
+ SlideSorterViewShell* const pSSViewSh(SlideSorterViewShell::GetSlideSorter(mrBase)); |
58 |
+ if (pSSViewSh) |
59 |
+ { |
60 |
+ const std::shared_ptr<SlideSorterViewShell::PageSelection> pPageSelection(pSSViewSh->GetPageSelection()); |
61 |
+ if (bool(pPageSelection) && pPageSelection->size() > 1) |
62 |
+ { |
63 |
+ OUStringBuffer aBuf; |
64 |
+ // TODO: this could be improved by writing ranges instead of consecutive page |
65 |
+ // numbers if appropriate. Do we have a helper function for that somewhere? |
66 |
+ bool bFirst(true); |
67 |
+ for (auto pPage: *pPageSelection) |
68 |
+ { |
69 |
+ if (!bFirst) |
70 |
+ { |
71 |
+ aBuf.append(','); |
72 |
+ bFirst = false; |
73 |
+ } |
74 |
+ aBuf.append(OUString::number(pPage->GetPageNum() / 2 + 1)); |
75 |
+ } |
76 |
+ aPageRange = aBuf.getStr(); |
77 |
+ nPrintRange = 1; |
78 |
+ } |
79 |
+ } |
80 |
+ |
81 |
AddDialogControl( vcl::PrinterOptionsHelper::setChoiceRadiosControlOpt(aWidgetIds, "", |
82 |
aHelpIds, |
83 |
aPrintRangeName, |
84 |
CreateChoice(mbImpress |
85 |
? _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE |
86 |
: _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE), |
87 |
- 0 ) |
88 |
+ nPrintRange ) |
89 |
); |
90 |
// create a an Edit dependent on "Pages" selected |
91 |
vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, true ); |
92 |
AddDialogControl(vcl::PrinterOptionsHelper::setEditControlOpt("pagerange", "", |
93 |
".HelpID:vcl:PrintDialog:PageRange:Edit", "PageRange", |
94 |
- OUString::number(mnCurPage + 1), aPageRangeOpt)); |
95 |
+ aPageRange, aPageRangeOpt)); |
96 |
|
97 |
FreeResource(); |
98 |
} |
99 |
@@ -1140,7 +1173,7 @@ public: |
100 |
, mpPrintView() |
101 |
, mbHasOrientationWarningBeenShown(false) |
102 |
{ |
103 |
- DialogCreator aCreator( mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() ); |
104 |
+ DialogCreator aCreator( mrBase, mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS, GetCurrentPageIndex() ); |
105 |
m_aUIProperties = aCreator.GetDialogControls(); |
106 |
maSlidesPerPage = aCreator.GetSlidesPerPage(); |
107 |
|
108 |
-- |
109 |
2.5.0 |
110 |
|