LibreOffice Module vcl (master)  1
printdlg.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef VCL_INC_NEWPRINTDLG_HXX
21 #define VCL_INC_NEWPRINTDLG_HXX
22 
23 #include <vcl/bitmapex.hxx>
24 #include <vcl/gdimtf.hxx>
25 #include <vcl/print.hxx>
26 #include <vcl/customweld.hxx>
27 #include <vcl/weld.hxx>
28 #include <map>
29 
30 namespace vcl {
31  class PrintDialog;
32 }
33 
34 namespace vcl
35 {
37  {
39  std::unique_ptr<weld::Button> mxOKButton;
40  std::unique_ptr<weld::Button> mxCancelButton;
41  std::unique_ptr<weld::CheckButton> mxSingleJobsBox;
42 
43  DECL_LINK( ClickHdl, weld::Button&, void );
44 
45  public:
46 
47  MoreOptionsDialog(PrintDialog* i_pParent);
48  virtual ~MoreOptionsDialog() override;
49  };
50 
52  {
53  friend class MoreOptionsDialog;
54  public:
55 
57  {
62  sal_Int32 mnDPIX;
63  sal_Int32 mnDPIY;
67 
68  OUString maHorzText;
69  OUString maVertText;
70 
71  void preparePreviewBitmap();
72 
73  public:
75  virtual ~PrintPreviewWindow() override;
76 
77  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
78  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
79  virtual bool Command( const CommandEvent& ) override;
80  virtual void Resize() override;
81 
82  void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
83  const OUString& i_rPaperName,
84  const OUString& i_rNoPageString,
85  sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
86  bool i_bGreyscale
87  );
88  };
89 
91  {
93  int mnRows;
94  int mnColumns;
95  public:
97 
98  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
99 
100  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
101 
102  void setValues( NupOrderType i_nOrderMode, int i_nColumns, int i_nRows )
103  {
104  mnOrderMode = i_nOrderMode;
105  mnRows = i_nRows;
106  mnColumns = i_nColumns;
107  Invalidate();
108  }
109  };
110 
111  PrintDialog(weld::Window*, const std::shared_ptr<PrinterController>&);
112  virtual ~PrintDialog() override;
113 
114  bool isPrintToFile() const;
115  bool isCollate() const;
116  bool isSingleJobs() const { return mbSingleJobs; };
117  bool hasPreview() const;
118 
119  void setPaperSizes();
120  void previewForward();
121  void previewBackward();
122  void previewFirst();
123  void previewLast();
124 
125  private:
126 
127  std::unique_ptr<weld::Builder> mxCustomOptionsUIBuilder;
128 
129  std::shared_ptr<PrinterController> maPController;
130 
131  std::unique_ptr<MoreOptionsDialog> mxMoreOptionsDlg;
132 
133  std::unique_ptr<weld::Notebook> mxTabCtrl;
134  std::unique_ptr<weld::Frame> mxPageLayoutFrame;
135  std::unique_ptr<weld::ComboBox> mxPrinters;
136  std::unique_ptr<weld::Label> mxStatusTxt;
137  std::unique_ptr<weld::Button> mxSetupButton;
138 
139  std::unique_ptr<weld::SpinButton> mxCopyCountField;
140  std::unique_ptr<weld::CheckButton> mxCollateBox;
141  std::unique_ptr<weld::Image> mxCollateImage;
142  std::unique_ptr<weld::Entry> mxPageRangeEdit;
143  std::unique_ptr<weld::RadioButton> mxPageRangesRadioButton;
144  std::unique_ptr<weld::ComboBox> mxPaperSidesBox;
145  std::unique_ptr<weld::CheckButton> mxReverseOrderBox;
146 
147  std::unique_ptr<weld::Button> mxOKButton;
148  std::unique_ptr<weld::Button> mxCancelButton;
149  std::unique_ptr<weld::Button> mxHelpButton;
150  std::unique_ptr<weld::Button> mxMoreOptionsBtn;
151 
152  std::unique_ptr<weld::Button> mxBackwardBtn;
153  std::unique_ptr<weld::Button> mxForwardBtn;
154  std::unique_ptr<weld::Button> mxFirstBtn;
155  std::unique_ptr<weld::Button> mxLastBtn;
156 
157  std::unique_ptr<weld::CheckButton> mxPreviewBox;
158  std::unique_ptr<weld::Label> mxNumPagesText;
159  std::unique_ptr<PrintPreviewWindow> mxPreview;
160  std::unique_ptr<weld::CustomWeld> mxPreviewWindow;
161  std::unique_ptr<weld::Entry> mxPageEdit;
162 
163  std::unique_ptr<weld::RadioButton> mxPagesBtn;
164  std::unique_ptr<weld::RadioButton> mxBrochureBtn;
165  std::unique_ptr<weld::Label> mxPagesBoxTitleTxt;
166  std::unique_ptr<weld::ComboBox> mxNupPagesBox;
167 
168  // controls for "Custom" page mode
169  std::unique_ptr<weld::Label> mxNupNumPagesTxt;
170  std::unique_ptr<weld::SpinButton> mxNupColEdt;
171  std::unique_ptr<weld::Label> mxNupTimesTxt;
172  std::unique_ptr<weld::SpinButton> mxNupRowsEdt;
173  std::unique_ptr<weld::Label> mxPageMarginTxt1;
174  std::unique_ptr<weld::MetricSpinButton> mxPageMarginEdt;
175  std::unique_ptr<weld::Label> mxPageMarginTxt2;
176  std::unique_ptr<weld::Label> mxSheetMarginTxt1;
177  std::unique_ptr<weld::MetricSpinButton> mxSheetMarginEdt;
178  std::unique_ptr<weld::Label> mxSheetMarginTxt2;
179  std::unique_ptr<weld::ComboBox> mxPaperSizeBox;
180  std::unique_ptr<weld::ComboBox> mxOrientationBox;
181 
182  // page order ("left to right, then down")
183  std::unique_ptr<weld::Label> mxNupOrderTxt;
184  std::unique_ptr<weld::ComboBox> mxNupOrderBox;
185  std::unique_ptr<ShowNupOrderWindow> mxNupOrder;
186  std::unique_ptr<weld::CustomWeld> mxNupOrderWin;
188  std::unique_ptr<weld::CheckButton> mxBorderCB;
189  std::unique_ptr<weld::Widget> mxCustom;
190 
191  OUString const maPrintToFileText;
192  OUString maPrintText;
193  OUString const maDefPrtText;
194 
195  OUString maPageStr;
196  OUString const maNoPageStr;
197  OUString const maNoPreviewStr;
198  sal_Int32 mnCurPage;
199  sal_Int32 mnCachedPages;
200 
202 
203  std::vector<std::unique_ptr<weld::Widget>>
205 
206  std::map<weld::Widget*, OUString>
208  std::map<OUString, std::vector<weld::Widget*>>
210  std::map<weld::Widget*, sal_Int32>
212 
217 
220 
222 
223  DECL_LINK( ClickHdl, weld::Button&, void );
224  DECL_LINK( SelectHdl, weld::ComboBox&, void );
225  DECL_LINK( ActivateHdl, weld::Entry&, bool );
226  DECL_LINK( FocusOutHdl, weld::Widget&, void );
227  DECL_LINK( SpinModifyHdl, weld::SpinButton&, void );
228  DECL_LINK( MetricSpinModifyHdl, weld::MetricSpinButton&, void );
229  DECL_LINK( ToggleHdl, weld::ToggleButton&, void );
230 
231  DECL_LINK( UIOption_CheckHdl, weld::ToggleButton&, void );
232  DECL_LINK( UIOption_RadioHdl, weld::ToggleButton&, void );
233  DECL_LINK( UIOption_SelectHdl, weld::ComboBox&, void );
234  DECL_LINK( UIOption_SpinModifyHdl, weld::SpinButton&, void );
235  DECL_LINK( UIOption_EntryModifyHdl, weld::Entry&, void );
236 
237  css::beans::PropertyValue* getValueForWindow(weld::Widget*) const;
238 
239  void preparePreview( bool i_bMayUseCache );
240  void setupPaperSidesBox();
241  void storeToSettings();
242  void readFromSettings();
243  void setPaperOrientation( Orientation eOrientation );
244  void updateOrientationBox( bool bAutomatic = true );
245  bool hasOrientationChanged() const;
246  void checkPaperSize( Size& rPaperSize );
247  void setPreviewText();
248  void updatePrinterText();
251  void makeEnabled( weld::Widget* );
252  void updateWindowFromProperty( const OUString& );
254  void showAdvancedControls( bool );
255  void updateNup( bool i_bMayUseCache = true );
256  void updateNupFromPages( bool i_bMayUseCache = true );
257  void enableNupControls( bool bEnable );
258  void setupOptionalUI();
259  Size const & getJobPageSize();
260 
261  };
262 
264  {
265  OUString maStr;
267  sal_Int32 mnCur;
268  sal_Int32 mnMax;
269 
270  std::unique_ptr<weld::Label> mxText;
271  std::unique_ptr<weld::ProgressBar> mxProgress;
272  std::unique_ptr<weld::Button> mxButton;
273 
274  DECL_LINK( ClickHdl, weld::Button&, void );
275 
276  public:
277  PrintProgressDialog(weld::Window* i_pParent, int i_nMax);
278  virtual ~PrintProgressDialog() override;
279  bool isCanceled() const { return mbCanceled; }
280  void setProgress( int i_nCurrent );
281  void tick();
282  };
283 }
284 
285 #endif // VCL_INC_NEWPRINTDLG_HXX
286 
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PrintPreviewWindow(PrintDialog *pDialog)
Definition: printdlg.cxx:94
bool mbShowLayoutFrame
Definition: printdlg.hxx:218
void setPaperOrientation(Orientation eOrientation)
Definition: printdlg.cxx:987
std::unique_ptr< weld::Widget > mxCustom
Definition: printdlg.hxx:189
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
Definition: printdlg.hxx:188
std::unique_ptr< weld::Button > mxBackwardBtn
Definition: printdlg.hxx:152
std::unique_ptr< weld::ComboBox > mxNupPagesBox
Definition: printdlg.hxx:166
Orientation
Definition: Exif.hxx:25
void previewBackward()
Definition: printdlg.cxx:2138
MoreOptionsDialog(PrintDialog *i_pParent)
Definition: printdlg.cxx:64
std::shared_ptr< PrinterController > maPController
Definition: printdlg.hxx:129
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
Definition: printdlg.hxx:174
std::unique_ptr< weld::RadioButton > mxBrochureBtn
Definition: printdlg.hxx:164
virtual ~PrintPreviewWindow() override
Definition: printdlg.cxx:107
void checkOptionalControlDependencies()
Definition: printdlg.cxx:1021
std::unique_ptr< weld::Button > mxHelpButton
Definition: printdlg.hxx:149
std::unique_ptr< weld::Button > mxFirstBtn
Definition: printdlg.hxx:154
void showAdvancedControls(bool)
Definition: printdlg.cxx:1253
void updateNupFromPages(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1133
void checkPaperSize(Size &rPaperSize)
Definition: printdlg.cxx:975
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:40
std::unique_ptr< weld::ComboBox > mxNupOrderBox
Definition: printdlg.hxx:184
std::unique_ptr< weld::Label > mxPageMarginTxt2
Definition: printdlg.hxx:175
std::unique_ptr< weld::Button > mxForwardBtn
Definition: printdlg.hxx:153
void setPreview(const GDIMetaFile &, const Size &i_rPaperSize, const OUString &i_rPaperName, const OUString &i_rNoPageString, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, bool i_bGreyscale)
Definition: printdlg.cxx:250
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
Definition: printdlg.hxx:185
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
Definition: printdlg.hxx:143
PrintDialog * mpParent
Definition: printdlg.hxx:38
virtual ~PrintDialog() override
Definition: printdlg.cxx:702
std::unique_ptr< weld::RadioButton > mxPagesBtn
Definition: printdlg.hxx:163
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
Definition: printdlg.hxx:209
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
Definition: printdlg.hxx:145
OUString maPrintText
Definition: printdlg.hxx:192
OUString const maPrintToFileText
Definition: printdlg.hxx:191
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:148
void makeEnabled(weld::Widget *)
Definition: printdlg.cxx:1669
virtual void Resize() override
Definition: printdlg.cxx:111
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
Definition: printdlg.hxx:144
Paper
void previewForward()
Definition: printdlg.cxx:2128
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:440
void setProgress(int i_nCurrent)
Definition: printdlg.cxx:2197
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Definition: printdlg.hxx:204
void updateOrientationBox(bool bAutomatic=true)
Definition: printdlg.cxx:952
std::unique_ptr< weld::Button > mxSetupButton
Definition: printdlg.hxx:137
Size const & getJobPageSize()
Definition: printdlg.cxx:505
bool hasPreview() const
Definition: printdlg.cxx:1742
std::unique_ptr< weld::ComboBox > mxOrientationBox
Definition: printdlg.hxx:180
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
Definition: printdlg.cxx:1043
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
Definition: printdlg.cxx:2161
Size maNupPortraitSize
Definition: printdlg.hxx:213
std::unique_ptr< MoreOptionsDialog > mxMoreOptionsDlg
Definition: printdlg.hxx:131
std::unique_ptr< weld::Entry > mxPageRangeEdit
Definition: printdlg.hxx:142
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
Definition: printdlg.hxx:41
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:39
std::unique_ptr< weld::ComboBox > mxPrinters
Definition: printdlg.hxx:135
OUString const maNoPreviewStr
Definition: printdlg.hxx:197
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
Definition: printdlg.hxx:172
void updatePrinterText()
Definition: printdlg.cxx:865
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
Definition: printdlg.hxx:160
void storeToSettings()
Definition: printdlg.cxx:722
std::unique_ptr< weld::ProgressBar > mxProgress
Definition: printdlg.hxx:271
virtual bool Command(const CommandEvent &) override
Definition: printdlg.cxx:236
void setPreviewText()
Definition: printdlg.cxx:883
std::unique_ptr< weld::Label > mxSheetMarginTxt2
Definition: printdlg.hxx:178
DECL_LINK(ClickHdl, weld::Button &, void)
std::unique_ptr< weld::SpinButton > mxCopyCountField
Definition: printdlg.hxx:139
void setupOptionalUI()
Definition: printdlg.cxx:1284
std::unique_ptr< weld::Button > mxLastBtn
Definition: printdlg.hxx:155
OUString const maNoPageStr
Definition: printdlg.hxx:196
void checkControlDependencies()
Definition: printdlg.cxx:1005
bool hasOrientationChanged() const
Definition: printdlg.cxx:965
void setPaperSizes()
Definition: printdlg.cxx:820
std::unique_ptr< weld::Notebook > mxTabCtrl
Definition: printdlg.hxx:133
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
virtual ~MoreOptionsDialog() override
Definition: printdlg.cxx:77
bool isCanceled() const
Definition: printdlg.hxx:279
bool mbCollateAlwaysOff
Definition: printdlg.hxx:201
OUString const maDefPrtText
Definition: printdlg.hxx:193
std::unique_ptr< weld::Label > mxNumPagesText
Definition: printdlg.hxx:158
bool isPrintToFile() const
Definition: printdlg.cxx:1732
std::unique_ptr< weld::CheckButton > mxCollateBox
Definition: printdlg.hxx:140
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
Definition: printdlg.hxx:127
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:148
std::unique_ptr< weld::CheckButton > mxPreviewBox
Definition: printdlg.hxx:157
std::unique_ptr< weld::Label > mxNupNumPagesTxt
Definition: printdlg.hxx:169
sal_Int32 mnCurPage
Definition: printdlg.hxx:198
std::unique_ptr< weld::Label > mxPageMarginTxt1
Definition: printdlg.hxx:173
void setValues(NupOrderType i_nOrderMode, int i_nColumns, int i_nRows)
Definition: printdlg.hxx:102
std::unique_ptr< weld::Frame > mxPageLayoutFrame
Definition: printdlg.hxx:134
std::map< weld::Widget *, OUString > maControlToPropertyMap
Definition: printdlg.hxx:207
std::unique_ptr< weld::Entry > mxPageEdit
Definition: printdlg.hxx:161
sal_Int32 mnCachedPages
Definition: printdlg.hxx:199
bool isSingleJobs() const
Definition: printdlg.hxx:116
std::unique_ptr< weld::Label > mxStatusTxt
Definition: printdlg.hxx:136
Size maNupLandscapeSize
Definition: printdlg.hxx:214
void readFromSettings()
Definition: printdlg.cxx:761
A widget used to choose from a list of items.
Definition: weld.hxx:566
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
Definition: printdlg.hxx:165
bool isCollate() const
Definition: printdlg.cxx:1737
void updateWindowFromProperty(const OUString &)
Definition: printdlg.cxx:1680
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
Definition: printdlg.cxx:1747
void enableNupControls(bool bEnable)
Definition: printdlg.cxx:1234
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: printdlg.cxx:155
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
Definition: printdlg.hxx:186
void updateNup(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1080
std::unique_ptr< PrintPreviewWindow > mxPreview
Definition: printdlg.hxx:159
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
Definition: printdlg.hxx:177
std::unique_ptr< weld::Label > mxNupOrderTxt
Definition: printdlg.hxx:183
std::unique_ptr< weld::Label > mxSheetMarginTxt1
Definition: printdlg.hxx:176
std::unique_ptr< weld::Image > mxCollateImage
Definition: printdlg.hxx:141
std::unique_ptr< weld::Button > mxMoreOptionsBtn
Definition: printdlg.hxx:150
std::unique_ptr< weld::Label > mxNupTimesTxt
Definition: printdlg.hxx:171
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:147
OUString maPageStr
Definition: printdlg.hxx:195
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
Definition: printdlg.hxx:211
DECL_LINK(ClickHdl, weld::Button &, void)
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
Definition: printdlg.hxx:179
std::unique_ptr< weld::Button > mxButton
Definition: printdlg.hxx:272
DECL_LINK(ClickHdl, weld::Button &, void)
void setupPaperSidesBox()
Definition: printdlg.cxx:706
NupOrderType
Definition: print.hxx:387
std::unique_ptr< weld::SpinButton > mxNupColEdt
Definition: printdlg.hxx:170
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
Definition: printdlg.hxx:216
PrintDialog(weld::Window *, const std::shared_ptr< PrinterController > &)
Definition: printdlg.cxx:520
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: printdlg.cxx:448
void preparePreview(bool i_bMayUseCache)
Definition: printdlg.cxx:889
virtual ~PrintProgressDialog() override
Definition: printdlg.cxx:2188
std::unique_ptr< weld::Label > mxText
Definition: printdlg.hxx:270