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/idle.hxx>
26 #include <vcl/print.hxx>
27 #include <vcl/customweld.hxx>
28 #include <vcl/weld.hxx>
29 #include <map>
30 
31 namespace vcl {
32  class PrintDialog;
33 }
34 
35 namespace vcl
36 {
38  {
39  friend class MoreOptionsDialog;
40  public:
41 
43  {
48  sal_Int32 mnDPIX;
49  sal_Int32 mnDPIY;
53 
54  OUString maHorzText;
55  OUString maVertText;
56 
57  void preparePreviewBitmap();
58 
59  public:
61  virtual ~PrintPreviewWindow() override;
62 
63  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
64  virtual bool Command( const CommandEvent& ) override;
65  virtual void Resize() override;
66 
67  void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
68  std::u16string_view i_rPaperName,
69  const OUString& i_rNoPageString,
70  sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
71  bool i_bGreyscale
72  );
73  };
74 
76  {
78  int mnRows;
79  int mnColumns;
80  public:
82 
83  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
84 
85  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
86 
87  void setValues( NupOrderType i_nOrderMode, int i_nColumns, int i_nRows )
88  {
89  mnOrderMode = i_nOrderMode;
90  mnRows = i_nRows;
91  mnColumns = i_nColumns;
92  Invalidate();
93  }
94  };
95 
96  PrintDialog(weld::Window*, const std::shared_ptr<PrinterController>&);
97  virtual ~PrintDialog() override;
98 
99  bool isPrintToFile() const;
100  bool isCollate() const;
101  bool isSingleJobs() const;
102  bool hasPreview() const;
103 
104  void setPaperSizes();
105  void previewForward();
106  void previewBackward();
107  void previewFirst();
108  void previewLast();
109 
110  private:
111 
112  std::unique_ptr<weld::Builder> mxCustomOptionsUIBuilder;
113 
114  std::shared_ptr<PrinterController> maPController;
115 
116  std::unique_ptr<weld::Notebook> mxTabCtrl;
117  std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
118  std::unique_ptr<weld::Frame> mxPageLayoutFrame;
119  std::unique_ptr<weld::ComboBox> mxPrinters;
120  std::unique_ptr<weld::Label> mxStatusTxt;
121  std::unique_ptr<weld::Button> mxSetupButton;
122 
123  std::unique_ptr<weld::SpinButton> mxCopyCountField;
124  std::unique_ptr<weld::CheckButton> mxCollateBox;
125  std::unique_ptr<weld::Image> mxCollateImage;
126  std::unique_ptr<weld::Entry> mxPageRangeEdit;
127  std::unique_ptr<weld::RadioButton> mxPageRangesRadioButton;
128  std::unique_ptr<weld::ComboBox> mxPaperSidesBox;
129  std::unique_ptr<weld::CheckButton> mxSingleJobsBox;
130  std::unique_ptr<weld::CheckButton> mxReverseOrderBox;
131 
132  std::unique_ptr<weld::Button> mxOKButton;
133  std::unique_ptr<weld::Button> mxCancelButton;
134  std::unique_ptr<weld::Button> mxHelpButton;
135  std::unique_ptr<weld::Button> mxMoreOptionsBtn;
136 
137  std::unique_ptr<weld::Button> mxBackwardBtn;
138  std::unique_ptr<weld::Button> mxForwardBtn;
139  std::unique_ptr<weld::Button> mxFirstBtn;
140  std::unique_ptr<weld::Button> mxLastBtn;
141 
142  std::unique_ptr<weld::CheckButton> mxPreviewBox;
143  std::unique_ptr<weld::Label> mxNumPagesText;
144  std::unique_ptr<PrintPreviewWindow> mxPreview;
145  std::unique_ptr<weld::CustomWeld> mxPreviewWindow;
146  std::unique_ptr<weld::Entry> mxPageEdit;
147 
148  std::unique_ptr<weld::RadioButton> mxPagesBtn;
149  std::unique_ptr<weld::RadioButton> mxBrochureBtn;
150  std::unique_ptr<weld::Label> mxPagesBoxTitleTxt;
151  std::unique_ptr<weld::ComboBox> mxNupPagesBox;
152 
153  // controls for "Custom" page mode
154  std::unique_ptr<weld::Label> mxNupNumPagesTxt;
155  std::unique_ptr<weld::SpinButton> mxNupColEdt;
156  std::unique_ptr<weld::Label> mxNupTimesTxt;
157  std::unique_ptr<weld::SpinButton> mxNupRowsEdt;
158  std::unique_ptr<weld::Label> mxPageMarginTxt1;
159  std::unique_ptr<weld::MetricSpinButton> mxPageMarginEdt;
160  std::unique_ptr<weld::Label> mxPageMarginTxt2;
161  std::unique_ptr<weld::Label> mxSheetMarginTxt1;
162  std::unique_ptr<weld::MetricSpinButton> mxSheetMarginEdt;
163  std::unique_ptr<weld::Label> mxSheetMarginTxt2;
164  std::unique_ptr<weld::ComboBox> mxPaperSizeBox;
165  std::unique_ptr<weld::ComboBox> mxOrientationBox;
166 
167  // page order ("left to right, then down")
168  std::unique_ptr<weld::Label> mxNupOrderTxt;
169  std::unique_ptr<weld::ComboBox> mxNupOrderBox;
170  std::unique_ptr<ShowNupOrderWindow> mxNupOrder;
171  std::unique_ptr<weld::CustomWeld> mxNupOrderWin;
173  std::unique_ptr<weld::CheckButton> mxBorderCB;
174  std::unique_ptr<weld::Expander> mxRangeExpander;
175  std::unique_ptr<weld::Expander> mxLayoutExpander;
176  std::unique_ptr<weld::Widget> mxCustom;
177 
179  OUString maPrintText;
180  OUString maDefPrtText;
181 
182  OUString maPageStr;
183  OUString maNoPageStr;
184  OUString maNoPreviewStr;
185  sal_Int32 mnCurPage;
186  sal_Int32 mnCachedPages;
187 
189 
190  std::vector<std::unique_ptr<weld::Widget>>
192 
193  std::map<weld::Widget*, OUString>
195  std::map<OUString, std::vector<weld::Widget*>>
197  std::map<weld::Widget*, sal_Int32>
199 
204 
206 
208 
210  DECL_LINK(updatePreviewIdle, Timer*, void);
212  DECL_LINK(updatePreviewNoCacheIdle, Timer*, void);
213 
214  DECL_LINK( ClickHdl, weld::Button&, void );
215  DECL_LINK( SelectHdl, weld::ComboBox&, void );
216  DECL_LINK( ActivateHdl, weld::Entry&, bool );
217  DECL_LINK( FocusOutHdl, weld::Widget&, void );
218  DECL_LINK( SpinModifyHdl, weld::SpinButton&, void );
219  DECL_LINK( MetricSpinModifyHdl, weld::MetricSpinButton&, void );
220  DECL_LINK( ToggleHdl, weld::ToggleButton&, void );
221 
222  DECL_LINK( UIOption_CheckHdl, weld::ToggleButton&, void );
223  DECL_LINK( UIOption_RadioHdl, weld::ToggleButton&, void );
224  DECL_LINK( UIOption_SelectHdl, weld::ComboBox&, void );
225  DECL_LINK( UIOption_SpinModifyHdl, weld::SpinButton&, void );
226  DECL_LINK( UIOption_EntryModifyHdl, weld::Entry&, void );
227 
228  css::beans::PropertyValue* getValueForWindow(weld::Widget*) const;
229 
230  void preparePreview( bool i_bMayUseCache );
231  void setupPaperSidesBox();
232  void storeToSettings();
233  void readFromSettings();
234  void setPaperOrientation( Orientation eOrientation );
235  void updateOrientationBox( bool bAutomatic = true );
236  bool hasOrientationChanged() const;
237  void checkPaperSize( Size& rPaperSize );
238  void setPreviewText();
239  void updatePrinterText();
242  void makeEnabled( weld::Widget* );
243  void updateWindowFromProperty( const OUString& );
245  void showAdvancedControls( bool );
246  void updateNup( bool i_bMayUseCache = true );
247  void updateNupFromPages( bool i_bMayUseCache = true );
248  void enableNupControls( bool bEnable );
249  void setupOptionalUI();
250  Size const & getJobPageSize();
251 
252  };
253 
255  {
256  OUString maStr;
258  sal_Int32 mnCur;
259  sal_Int32 mnMax;
260 
261  std::unique_ptr<weld::Label> mxText;
262  std::unique_ptr<weld::ProgressBar> mxProgress;
263  std::unique_ptr<weld::Button> mxButton;
264 
265  DECL_LINK( ClickHdl, weld::Button&, void );
266 
267  public:
268  PrintProgressDialog(weld::Window* i_pParent, int i_nMax);
269  virtual ~PrintProgressDialog() override;
270  bool isCanceled() const { return mbCanceled; }
271  void setProgress( int i_nCurrent );
272  void tick();
273  };
274 }
275 
276 #endif // VCL_INC_NEWPRINTDLG_HXX
277 
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PrintPreviewWindow(PrintDialog *pDialog)
Definition: printdlg.cxx:69
bool mbShowLayoutFrame
Definition: printdlg.hxx:205
void setPaperOrientation(Orientation eOrientation)
Definition: printdlg.cxx:995
std::unique_ptr< weld::Widget > mxCustom
Definition: printdlg.hxx:176
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
Definition: printdlg.hxx:173
OUString maPrintToFileText
Definition: printdlg.hxx:178
std::unique_ptr< weld::Button > mxBackwardBtn
Definition: printdlg.hxx:137
std::unique_ptr< weld::ComboBox > mxNupPagesBox
Definition: printdlg.hxx:151
OUString maNoPageStr
Definition: printdlg.hxx:183
void previewBackward()
Definition: printdlg.cxx:2157
std::shared_ptr< PrinterController > maPController
Definition: printdlg.hxx:114
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
Definition: printdlg.hxx:159
std::unique_ptr< weld::RadioButton > mxBrochureBtn
Definition: printdlg.hxx:149
virtual ~PrintPreviewWindow() override
Definition: printdlg.cxx:82
void checkOptionalControlDependencies()
Definition: printdlg.cxx:1035
std::unique_ptr< weld::Button > mxHelpButton
Definition: printdlg.hxx:134
std::unique_ptr< weld::Button > mxFirstBtn
Definition: printdlg.hxx:139
void showAdvancedControls(bool)
Definition: printdlg.cxx:1270
void updateNupFromPages(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1150
void checkPaperSize(Size &rPaperSize)
Definition: printdlg.cxx:983
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
Definition: printdlg.hxx:129
std::unique_ptr< weld::ComboBox > mxNupOrderBox
Definition: printdlg.hxx:169
std::unique_ptr< weld::Label > mxPageMarginTxt2
Definition: printdlg.hxx:160
std::unique_ptr< weld::Button > mxForwardBtn
Definition: printdlg.hxx:138
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
Definition: printdlg.hxx:170
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
Definition: printdlg.hxx:127
std::unique_ptr< weld::Expander > mxRangeExpander
Definition: printdlg.hxx:174
virtual ~PrintDialog() override
Definition: printdlg.cxx:695
std::unique_ptr< weld::Expander > mxLayoutExpander
Definition: printdlg.hxx:175
Idle maUpdatePreviewNoCacheIdle
Definition: printdlg.hxx:211
std::unique_ptr< weld::RadioButton > mxPagesBtn
Definition: printdlg.hxx:148
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
Definition: printdlg.hxx:196
DECL_LINK(updatePreviewIdle, Timer *, void)
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
Definition: printdlg.hxx:130
OUString maPrintText
Definition: printdlg.hxx:179
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:133
void makeEnabled(weld::Widget *)
Definition: printdlg.cxx:1686
virtual void Resize() override
Definition: printdlg.cxx:86
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
Definition: printdlg.hxx:128
void previewForward()
Definition: printdlg.cxx:2147
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:402
void setProgress(int i_nCurrent)
Definition: printdlg.cxx:2227
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Definition: printdlg.hxx:191
void updateOrientationBox(bool bAutomatic=true)
Definition: printdlg.cxx:960
std::unique_ptr< weld::Button > mxSetupButton
Definition: printdlg.hxx:121
Size const & getJobPageSize()
Definition: printdlg.cxx:467
bool hasPreview() const
Definition: printdlg.cxx:1764
std::unique_ptr< weld::ComboBox > mxOrientationBox
Definition: printdlg.hxx:165
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
Definition: printdlg.cxx:1057
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
Definition: printdlg.cxx:2189
Size maNupPortraitSize
Definition: printdlg.hxx:200
std::unique_ptr< weld::Entry > mxPageRangeEdit
Definition: printdlg.hxx:126
std::unique_ptr< weld::ComboBox > mxPrinters
Definition: printdlg.hxx:119
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
Definition: printdlg.hxx:157
void updatePrinterText()
Definition: printdlg.cxx:861
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
Definition: printdlg.hxx:145
void storeToSettings()
Definition: printdlg.cxx:721
std::unique_ptr< weld::ProgressBar > mxProgress
Definition: printdlg.hxx:262
virtual bool Command(const CommandEvent &) override
Definition: printdlg.cxx:198
OUString maDefPrtText
Definition: printdlg.hxx:180
void setPreviewText()
Definition: printdlg.cxx:879
std::unique_ptr< weld::Label > mxSheetMarginTxt2
Definition: printdlg.hxx:163
std::unique_ptr< weld::SpinButton > mxCopyCountField
Definition: printdlg.hxx:123
void setupOptionalUI()
Definition: printdlg.cxx:1301
std::unique_ptr< weld::Button > mxLastBtn
Definition: printdlg.hxx:140
void checkControlDependencies()
Definition: printdlg.cxx:1013
bool hasOrientationChanged() const
Definition: printdlg.cxx:973
void setPaperSizes()
Definition: printdlg.cxx:816
std::unique_ptr< weld::Notebook > mxTabCtrl
Definition: printdlg.hxx:116
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
bool isCanceled() const
Definition: printdlg.hxx:270
friend class MoreOptionsDialog
Definition: printdlg.hxx:39
bool mbCollateAlwaysOff
Definition: printdlg.hxx:188
void setPreview(const GDIMetaFile &, const Size &i_rPaperSize, std::u16string_view i_rPaperName, const OUString &i_rNoPageString, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, bool i_bGreyscale)
Definition: printdlg.cxx:212
std::unique_ptr< weld::Label > mxNumPagesText
Definition: printdlg.hxx:143
bool isPrintToFile() const
Definition: printdlg.cxx:1749
std::unique_ptr< weld::CheckButton > mxCollateBox
Definition: printdlg.hxx:124
Paper
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
Definition: printdlg.hxx:112
Idle maUpdatePreviewIdle
Definition: printdlg.hxx:209
std::unique_ptr< weld::CheckButton > mxPreviewBox
Definition: printdlg.hxx:142
std::unique_ptr< weld::Label > mxNupNumPagesTxt
Definition: printdlg.hxx:154
sal_Int32 mnCurPage
Definition: printdlg.hxx:185
std::unique_ptr< weld::Label > mxPageMarginTxt1
Definition: printdlg.hxx:158
void setValues(NupOrderType i_nOrderMode, int i_nColumns, int i_nRows)
Definition: printdlg.hxx:87
std::unique_ptr< weld::Frame > mxPageLayoutFrame
Definition: printdlg.hxx:118
std::map< weld::Widget *, OUString > maControlToPropertyMap
Definition: printdlg.hxx:194
std::unique_ptr< weld::Entry > mxPageEdit
Definition: printdlg.hxx:146
sal_Int32 mnCachedPages
Definition: printdlg.hxx:186
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
Definition: printdlg.hxx:117
std::unique_ptr< weld::Label > mxStatusTxt
Definition: printdlg.hxx:120
Size maNupLandscapeSize
Definition: printdlg.hxx:201
void readFromSettings()
Definition: printdlg.cxx:760
A widget used to choose from a list of items.
Definition: weld.hxx:662
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
Definition: printdlg.hxx:150
bool isCollate() const
Definition: printdlg.cxx:1754
void updateWindowFromProperty(const OUString &)
Definition: printdlg.cxx:1697
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
Definition: printdlg.cxx:1769
void enableNupControls(bool bEnable)
Definition: printdlg.cxx:1251
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: printdlg.cxx:123
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
Definition: printdlg.hxx:171
void updateNup(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1094
std::unique_ptr< PrintPreviewWindow > mxPreview
Definition: printdlg.hxx:144
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
Definition: printdlg.hxx:162
std::unique_ptr< weld::Label > mxNupOrderTxt
Definition: printdlg.hxx:168
std::unique_ptr< weld::Label > mxSheetMarginTxt1
Definition: printdlg.hxx:161
std::unique_ptr< weld::Image > mxCollateImage
Definition: printdlg.hxx:125
Orientation
Definition: prntypes.hxx:31
std::unique_ptr< weld::Button > mxMoreOptionsBtn
Definition: printdlg.hxx:135
std::unique_ptr< weld::Label > mxNupTimesTxt
Definition: printdlg.hxx:156
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:132
OUString maPageStr
Definition: printdlg.hxx:182
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
Definition: printdlg.hxx:198
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
Definition: printdlg.hxx:164
std::unique_ptr< weld::Button > mxButton
Definition: printdlg.hxx:263
DECL_LINK(ClickHdl, weld::Button &, void)
bool isSingleJobs() const
Definition: printdlg.cxx:1759
void setupPaperSidesBox()
Definition: printdlg.cxx:705
Definition: timer.hxx:26
OUString maNoPreviewStr
Definition: printdlg.hxx:184
NupOrderType
Definition: print.hxx:380
std::unique_ptr< weld::SpinButton > mxNupColEdt
Definition: printdlg.hxx:155
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
Definition: printdlg.hxx:203
PrintDialog(weld::Window *, const std::shared_ptr< PrinterController > &)
Definition: printdlg.cxx:482
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: printdlg.cxx:410
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
void preparePreview(bool i_bMayUseCache)
Definition: printdlg.cxx:895
virtual ~PrintProgressDialog() override
Definition: printdlg.cxx:2218
std::unique_ptr< weld::Label > mxText
Definition: printdlg.hxx:261