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 SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
64  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
65  virtual bool Command( const CommandEvent& ) override;
66  virtual void Resize() override;
67 
68  void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
69  const OUString& i_rPaperName,
70  const OUString& i_rNoPageString,
71  sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
72  bool i_bGreyscale
73  );
74  };
75 
77  {
79  int mnRows;
80  int mnColumns;
81  public:
83 
84  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
85 
86  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
87 
88  void setValues( NupOrderType i_nOrderMode, int i_nColumns, int i_nRows )
89  {
90  mnOrderMode = i_nOrderMode;
91  mnRows = i_nRows;
92  mnColumns = i_nColumns;
93  Invalidate();
94  }
95  };
96 
97  PrintDialog(weld::Window*, const std::shared_ptr<PrinterController>&);
98  virtual ~PrintDialog() override;
99 
100  bool isPrintToFile() const;
101  bool isCollate() const;
102  bool isSingleJobs() const;
103  bool hasPreview() const;
104 
105  void setPaperSizes();
106  void previewForward();
107  void previewBackward();
108  void previewFirst();
109  void previewLast();
110 
111  private:
112 
113  std::unique_ptr<weld::Builder> mxCustomOptionsUIBuilder;
114 
115  std::shared_ptr<PrinterController> maPController;
116 
117  std::unique_ptr<weld::Notebook> mxTabCtrl;
118  std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
119  std::unique_ptr<weld::Frame> mxPageLayoutFrame;
120  std::unique_ptr<weld::ComboBox> mxPrinters;
121  std::unique_ptr<weld::Label> mxStatusTxt;
122  std::unique_ptr<weld::Button> mxSetupButton;
123 
124  std::unique_ptr<weld::SpinButton> mxCopyCountField;
125  std::unique_ptr<weld::CheckButton> mxCollateBox;
126  std::unique_ptr<weld::Image> mxCollateImage;
127  std::unique_ptr<weld::Entry> mxPageRangeEdit;
128  std::unique_ptr<weld::RadioButton> mxPageRangesRadioButton;
129  std::unique_ptr<weld::ComboBox> mxPaperSidesBox;
130  std::unique_ptr<weld::CheckButton> mxSingleJobsBox;
131  std::unique_ptr<weld::CheckButton> mxReverseOrderBox;
132 
133  std::unique_ptr<weld::Button> mxOKButton;
134  std::unique_ptr<weld::Button> mxCancelButton;
135  std::unique_ptr<weld::Button> mxHelpButton;
136  std::unique_ptr<weld::Button> mxMoreOptionsBtn;
137 
138  std::unique_ptr<weld::Button> mxBackwardBtn;
139  std::unique_ptr<weld::Button> mxForwardBtn;
140  std::unique_ptr<weld::Button> mxFirstBtn;
141  std::unique_ptr<weld::Button> mxLastBtn;
142 
143  std::unique_ptr<weld::CheckButton> mxPreviewBox;
144  std::unique_ptr<weld::Label> mxNumPagesText;
145  std::unique_ptr<PrintPreviewWindow> mxPreview;
146  std::unique_ptr<weld::CustomWeld> mxPreviewWindow;
147  std::unique_ptr<weld::Entry> mxPageEdit;
148 
149  std::unique_ptr<weld::RadioButton> mxPagesBtn;
150  std::unique_ptr<weld::RadioButton> mxBrochureBtn;
151  std::unique_ptr<weld::Label> mxPagesBoxTitleTxt;
152  std::unique_ptr<weld::ComboBox> mxNupPagesBox;
153 
154  // controls for "Custom" page mode
155  std::unique_ptr<weld::Label> mxNupNumPagesTxt;
156  std::unique_ptr<weld::SpinButton> mxNupColEdt;
157  std::unique_ptr<weld::Label> mxNupTimesTxt;
158  std::unique_ptr<weld::SpinButton> mxNupRowsEdt;
159  std::unique_ptr<weld::Label> mxPageMarginTxt1;
160  std::unique_ptr<weld::MetricSpinButton> mxPageMarginEdt;
161  std::unique_ptr<weld::Label> mxPageMarginTxt2;
162  std::unique_ptr<weld::Label> mxSheetMarginTxt1;
163  std::unique_ptr<weld::MetricSpinButton> mxSheetMarginEdt;
164  std::unique_ptr<weld::Label> mxSheetMarginTxt2;
165  std::unique_ptr<weld::ComboBox> mxPaperSizeBox;
166  std::unique_ptr<weld::ComboBox> mxOrientationBox;
167 
168  // page order ("left to right, then down")
169  std::unique_ptr<weld::Label> mxNupOrderTxt;
170  std::unique_ptr<weld::ComboBox> mxNupOrderBox;
171  std::unique_ptr<ShowNupOrderWindow> mxNupOrder;
172  std::unique_ptr<weld::CustomWeld> mxNupOrderWin;
174  std::unique_ptr<weld::CheckButton> mxBorderCB;
175  std::unique_ptr<weld::Expander> mxRangeExpander;
176  std::unique_ptr<weld::Expander> mxLayoutExpander;
177  std::unique_ptr<weld::Widget> mxCustom;
178 
180  OUString maPrintText;
181  OUString maDefPrtText;
182 
183  OUString maPageStr;
184  OUString maNoPageStr;
185  OUString maNoPreviewStr;
186  sal_Int32 mnCurPage;
187  sal_Int32 mnCachedPages;
188 
190 
191  std::vector<std::unique_ptr<weld::Widget>>
193 
194  std::map<weld::Widget*, OUString>
196  std::map<OUString, std::vector<weld::Widget*>>
198  std::map<weld::Widget*, sal_Int32>
200 
205 
207 
209 
211  DECL_LINK(updatePreviewIdle, Timer*, void);
213  DECL_LINK(updatePreviewNoCacheIdle, Timer*, void);
214 
215  DECL_LINK( ClickHdl, weld::Button&, void );
216  DECL_LINK( SelectHdl, weld::ComboBox&, void );
217  DECL_LINK( ActivateHdl, weld::Entry&, bool );
218  DECL_LINK( FocusOutHdl, weld::Widget&, void );
219  DECL_LINK( SpinModifyHdl, weld::SpinButton&, void );
220  DECL_LINK( MetricSpinModifyHdl, weld::MetricSpinButton&, void );
221  DECL_LINK( ToggleHdl, weld::ToggleButton&, void );
222 
223  DECL_LINK( UIOption_CheckHdl, weld::ToggleButton&, void );
224  DECL_LINK( UIOption_RadioHdl, weld::ToggleButton&, void );
225  DECL_LINK( UIOption_SelectHdl, weld::ComboBox&, void );
226  DECL_LINK( UIOption_SpinModifyHdl, weld::SpinButton&, void );
227  DECL_LINK( UIOption_EntryModifyHdl, weld::Entry&, void );
228 
229  DECL_LINK( ExpandHdl, weld::Expander&, void );
230 
231  css::beans::PropertyValue* getValueForWindow(weld::Widget*) const;
232 
233  void preparePreview( bool i_bMayUseCache );
234  void setupPaperSidesBox();
235  void storeToSettings();
236  void readFromSettings();
237  void setPaperOrientation( Orientation eOrientation );
238  void updateOrientationBox( bool bAutomatic = true );
239  bool hasOrientationChanged() const;
240  void checkPaperSize( Size& rPaperSize );
241  void setPreviewText();
242  void updatePrinterText();
245  void makeEnabled( weld::Widget* );
246  void updateWindowFromProperty( const OUString& );
248  void showAdvancedControls( bool );
249  void updateNup( bool i_bMayUseCache = true );
250  void updateNupFromPages( bool i_bMayUseCache = true );
251  void enableNupControls( bool bEnable );
252  void setupOptionalUI();
253  Size const & getJobPageSize();
254 
255  };
256 
258  {
259  OUString maStr;
261  sal_Int32 mnCur;
262  sal_Int32 mnMax;
263 
264  std::unique_ptr<weld::Label> mxText;
265  std::unique_ptr<weld::ProgressBar> mxProgress;
266  std::unique_ptr<weld::Button> mxButton;
267 
268  DECL_LINK( ClickHdl, weld::Button&, void );
269 
270  public:
271  PrintProgressDialog(weld::Window* i_pParent, int i_nMax);
272  virtual ~PrintProgressDialog() override;
273  bool isCanceled() const { return mbCanceled; }
274  void setProgress( int i_nCurrent );
275  void tick();
276  };
277 }
278 
279 #endif // VCL_INC_NEWPRINTDLG_HXX
280 
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PrintPreviewWindow(PrintDialog *pDialog)
Definition: printdlg.cxx:66
bool mbShowLayoutFrame
Definition: printdlg.hxx:206
void setPaperOrientation(Orientation eOrientation)
Definition: printdlg.cxx:988
std::unique_ptr< weld::Widget > mxCustom
Definition: printdlg.hxx:177
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
Definition: printdlg.hxx:174
OUString maPrintToFileText
Definition: printdlg.hxx:179
std::unique_ptr< weld::Button > mxBackwardBtn
Definition: printdlg.hxx:138
std::unique_ptr< weld::ComboBox > mxNupPagesBox
Definition: printdlg.hxx:152
OUString maNoPageStr
Definition: printdlg.hxx:184
void previewBackward()
Definition: printdlg.cxx:2150
std::shared_ptr< PrinterController > maPController
Definition: printdlg.hxx:115
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
Definition: printdlg.hxx:160
std::unique_ptr< weld::RadioButton > mxBrochureBtn
Definition: printdlg.hxx:150
virtual ~PrintPreviewWindow() override
Definition: printdlg.cxx:79
void checkOptionalControlDependencies()
Definition: printdlg.cxx:1028
std::unique_ptr< weld::Button > mxHelpButton
Definition: printdlg.hxx:135
std::unique_ptr< weld::Button > mxFirstBtn
Definition: printdlg.hxx:140
void showAdvancedControls(bool)
Definition: printdlg.cxx:1263
void updateNupFromPages(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1143
void checkPaperSize(Size &rPaperSize)
Definition: printdlg.cxx:976
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
Definition: printdlg.hxx:130
std::unique_ptr< weld::ComboBox > mxNupOrderBox
Definition: printdlg.hxx:170
std::unique_ptr< weld::Label > mxPageMarginTxt2
Definition: printdlg.hxx:161
std::unique_ptr< weld::Button > mxForwardBtn
Definition: printdlg.hxx:139
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:220
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
Definition: printdlg.hxx:171
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
Definition: printdlg.hxx:128
std::unique_ptr< weld::Expander > mxRangeExpander
Definition: printdlg.hxx:175
virtual ~PrintDialog() override
Definition: printdlg.cxx:694
std::unique_ptr< weld::Expander > mxLayoutExpander
Definition: printdlg.hxx:176
Idle maUpdatePreviewNoCacheIdle
Definition: printdlg.hxx:212
std::unique_ptr< weld::RadioButton > mxPagesBtn
Definition: printdlg.hxx:149
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
Definition: printdlg.hxx:197
DECL_LINK(updatePreviewIdle, Timer *, void)
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
Definition: printdlg.hxx:131
OUString maPrintText
Definition: printdlg.hxx:180
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:134
void makeEnabled(weld::Widget *)
Definition: printdlg.cxx:1679
virtual void Resize() override
Definition: printdlg.cxx:83
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
Definition: printdlg.hxx:129
void previewForward()
Definition: printdlg.cxx:2140
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:410
void setProgress(int i_nCurrent)
Definition: printdlg.cxx:2220
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Definition: printdlg.hxx:192
void updateOrientationBox(bool bAutomatic=true)
Definition: printdlg.cxx:953
std::unique_ptr< weld::Button > mxSetupButton
Definition: printdlg.hxx:122
Size const & getJobPageSize()
Definition: printdlg.cxx:475
bool hasPreview() const
Definition: printdlg.cxx:1757
std::unique_ptr< weld::ComboBox > mxOrientationBox
Definition: printdlg.hxx:166
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
Definition: printdlg.cxx:1050
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
Definition: printdlg.cxx:2182
Size maNupPortraitSize
Definition: printdlg.hxx:201
std::unique_ptr< weld::Entry > mxPageRangeEdit
Definition: printdlg.hxx:127
std::unique_ptr< weld::ComboBox > mxPrinters
Definition: printdlg.hxx:120
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
Definition: printdlg.hxx:158
void updatePrinterText()
Definition: printdlg.cxx:854
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
Definition: printdlg.hxx:146
void storeToSettings()
Definition: printdlg.cxx:714
std::unique_ptr< weld::ProgressBar > mxProgress
Definition: printdlg.hxx:265
virtual bool Command(const CommandEvent &) override
Definition: printdlg.cxx:206
OUString maDefPrtText
Definition: printdlg.hxx:181
void setPreviewText()
Definition: printdlg.cxx:872
std::unique_ptr< weld::Label > mxSheetMarginTxt2
Definition: printdlg.hxx:164
std::unique_ptr< weld::SpinButton > mxCopyCountField
Definition: printdlg.hxx:124
void setupOptionalUI()
Definition: printdlg.cxx:1294
std::unique_ptr< weld::Button > mxLastBtn
Definition: printdlg.hxx:141
void checkControlDependencies()
Definition: printdlg.cxx:1006
bool hasOrientationChanged() const
Definition: printdlg.cxx:966
void setPaperSizes()
Definition: printdlg.cxx:809
std::unique_ptr< weld::Notebook > mxTabCtrl
Definition: printdlg.hxx:117
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:273
friend class MoreOptionsDialog
Definition: printdlg.hxx:39
bool mbCollateAlwaysOff
Definition: printdlg.hxx:189
std::unique_ptr< weld::Label > mxNumPagesText
Definition: printdlg.hxx:144
bool isPrintToFile() const
Definition: printdlg.cxx:1742
std::unique_ptr< weld::CheckButton > mxCollateBox
Definition: printdlg.hxx:125
Paper
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
Definition: printdlg.hxx:113
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:120
Idle maUpdatePreviewIdle
Definition: printdlg.hxx:210
std::unique_ptr< weld::CheckButton > mxPreviewBox
Definition: printdlg.hxx:143
std::unique_ptr< weld::Label > mxNupNumPagesTxt
Definition: printdlg.hxx:155
sal_Int32 mnCurPage
Definition: printdlg.hxx:186
std::unique_ptr< weld::Label > mxPageMarginTxt1
Definition: printdlg.hxx:159
void setValues(NupOrderType i_nOrderMode, int i_nColumns, int i_nRows)
Definition: printdlg.hxx:88
std::unique_ptr< weld::Frame > mxPageLayoutFrame
Definition: printdlg.hxx:119
std::map< weld::Widget *, OUString > maControlToPropertyMap
Definition: printdlg.hxx:195
std::unique_ptr< weld::Entry > mxPageEdit
Definition: printdlg.hxx:147
sal_Int32 mnCachedPages
Definition: printdlg.hxx:187
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
Definition: printdlg.hxx:118
std::unique_ptr< weld::Label > mxStatusTxt
Definition: printdlg.hxx:121
Size maNupLandscapeSize
Definition: printdlg.hxx:202
void readFromSettings()
Definition: printdlg.cxx:753
A widget used to choose from a list of items.
Definition: weld.hxx:638
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
Definition: printdlg.hxx:151
bool isCollate() const
Definition: printdlg.cxx:1747
void updateWindowFromProperty(const OUString &)
Definition: printdlg.cxx:1690
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
Definition: printdlg.cxx:1762
void enableNupControls(bool bEnable)
Definition: printdlg.cxx:1244
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: printdlg.cxx:127
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
Definition: printdlg.hxx:172
void updateNup(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1087
std::unique_ptr< PrintPreviewWindow > mxPreview
Definition: printdlg.hxx:145
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
Definition: printdlg.hxx:163
std::unique_ptr< weld::Label > mxNupOrderTxt
Definition: printdlg.hxx:169
std::unique_ptr< weld::Label > mxSheetMarginTxt1
Definition: printdlg.hxx:162
std::unique_ptr< weld::Image > mxCollateImage
Definition: printdlg.hxx:126
Orientation
Definition: prntypes.hxx:31
std::unique_ptr< weld::Button > mxMoreOptionsBtn
Definition: printdlg.hxx:136
std::unique_ptr< weld::Label > mxNupTimesTxt
Definition: printdlg.hxx:157
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:133
OUString maPageStr
Definition: printdlg.hxx:183
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
Definition: printdlg.hxx:199
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
Definition: printdlg.hxx:165
std::unique_ptr< weld::Button > mxButton
Definition: printdlg.hxx:266
DECL_LINK(ClickHdl, weld::Button &, void)
bool isSingleJobs() const
Definition: printdlg.cxx:1752
void setupPaperSidesBox()
Definition: printdlg.cxx:698
Definition: timer.hxx:26
OUString maNoPreviewStr
Definition: printdlg.hxx:185
NupOrderType
Definition: print.hxx:380
std::unique_ptr< weld::SpinButton > mxNupColEdt
Definition: printdlg.hxx:156
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
Definition: printdlg.hxx:204
PrintDialog(weld::Window *, const std::shared_ptr< PrinterController > &)
Definition: printdlg.cxx:490
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: printdlg.cxx:418
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
void preparePreview(bool i_bMayUseCache)
Definition: printdlg.cxx:888
virtual ~PrintProgressDialog() override
Definition: printdlg.cxx:2211
std::unique_ptr< weld::Label > mxText
Definition: printdlg.hxx:264