Debian Codegraph @

vcl/inc/printdlg.hxx

raw symbols SCIP
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 #pragma once
21
22 #include <vcl/bitmap.hxx>
23 #include <vcl/gdimtf.hxx>
24 #include <vcl/idle.hxx>
25 #include <vcl/print.hxx>
26 #include <vcl/customweld.hxx>
27 #include <vcl/weld.hxx>
28 #include <map>
29
30 namespace vcl
31 {
32 class PrintDialog final : public weld::GenericDialogController
33 {
34 friend class MoreOptionsDialog;
35 public:
36
37 class PrintPreviewWindow final : public weld::CustomWidgetController
38 {
39 PrintDialog* mpDialog;
40 GDIMetaFile maMtf;
41 Size maOrigSize;
42 Size maPreviewSize;
43 sal_Int32 mnDPIX;
44 sal_Int32 mnDPIY;
45 Bitmap maPreviewBitmap;
46 OUString maReplacementString;
47 bool mbGreyscale;
48
49 OUString maHorzText;
50 OUString maVertText;
51
52 void preparePreviewBitmap();
53
54 public:
55 PrintPreviewWindow(PrintDialog* pDialog);
56 virtual ~PrintPreviewWindow() override;
57
58 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
59 virtual bool Command( const CommandEvent& ) override;
60 virtual void Resize() override;
61
62 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
63 std::u16string_view i_rPaperName,
64 const OUString& i_rNoPageString,
65 sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
66 bool i_bGreyscale
67 );
68 };
69
70 class ShowNupOrderWindow final : public weld::CustomWidgetController
71 {
72 NupOrderType mnOrderMode;
73 int mnRows;
74 int mnColumns;
75 public:
76 ShowNupOrderWindow();
77
78 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
79
80 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
81
82 void setValues( NupOrderType i_nOrderMode, int i_nColumns, int i_nRows )
83 {
84 mnOrderMode = i_nOrderMode;
85 mnRows = i_nRows;
86 mnColumns = i_nColumns;
87 Invalidate();
88 }
89 };
90
91 PrintDialog(weld::Window*, std::shared_ptr<PrinterController> );
92 virtual ~PrintDialog() override;
93
94 bool isPrintToFile() const;
95 bool isCollate() const;
96 bool isSingleJobs() const;
97 bool hasPreview() const;
98
99 void setPaperSizes();
100 void previewForward();
101 void previewBackward();
102 void previewFirst();
103 void previewLast();
104
105 private:
106
107 std::unique_ptr<weld::Builder> mxCustomOptionsUIBuilder;
108
109 std::shared_ptr<PrinterController> maPController;
110
111 std::unique_ptr<weld::Notebook> mxTabCtrl;
112 std::unique_ptr<weld::ScrolledWindow> mxScrolledWindow;
113 std::unique_ptr<weld::Frame> mxPageLayoutFrame;
114 std::unique_ptr<weld::ComboBox> mxPrinters;
115 std::unique_ptr<weld::Label> mxStatusTxt;
116 std::unique_ptr<weld::Button> mxSetupButton;
117
118 std::unique_ptr<weld::SpinButton> mxCopyCountField;
119 std::unique_ptr<weld::CheckButton> mxCollateBox;
120 std::unique_ptr<weld::Image> mxCollateImage;
121 std::unique_ptr<weld::Entry> mxPageRangeEdit;
122 std::unique_ptr<weld::RadioButton> mxPageRangesRadioButton;
123 std::unique_ptr<weld::ComboBox> mxPaperSidesBox;
124 std::unique_ptr<weld::CheckButton> mxSingleJobsBox;
125 std::unique_ptr<weld::CheckButton> mxReverseOrderBox;
126
127 std::unique_ptr<weld::Button> mxOKButton;
128 std::unique_ptr<weld::Button> mxCancelButton;
129
130 std::unique_ptr<weld::Button> mxBackwardBtn;
131 std::unique_ptr<weld::Button> mxForwardBtn;
132 std::unique_ptr<weld::Button> mxFirstBtn;
133 std::unique_ptr<weld::Button> mxLastBtn;
134
135 std::unique_ptr<weld::CheckButton> mxPreviewBox;
136 std::unique_ptr<weld::Label> mxNumPagesText;
137 std::unique_ptr<PrintPreviewWindow> mxPreview;
138 std::unique_ptr<weld::CustomWeld> mxPreviewWindow;
139 std::unique_ptr<weld::Entry> mxPageEdit;
140
141 std::unique_ptr<weld::RadioButton> mxPagesBtn;
142 std::unique_ptr<weld::RadioButton> mxBrochureBtn;
143 std::unique_ptr<weld::Label> mxPagesBoxTitleTxt;
144 std::unique_ptr<weld::ComboBox> mxNupPagesBox;
145
146 // controls for "Custom" page mode
147 std::unique_ptr<weld::Label> mxNupNumPagesTxt;
148 std::unique_ptr<weld::SpinButton> mxNupColEdt;
149 std::unique_ptr<weld::Label> mxNupTimesTxt;
150 std::unique_ptr<weld::SpinButton> mxNupRowsEdt;
151 std::unique_ptr<weld::Label> mxPageMarginTxt1;
152 std::unique_ptr<weld::MetricSpinButton> mxPageMarginEdt;
153 std::unique_ptr<weld::Label> mxPageMarginTxt2;
154 std::unique_ptr<weld::Label> mxSheetMarginTxt1;
155 std::unique_ptr<weld::MetricSpinButton> mxSheetMarginEdt;
156 std::unique_ptr<weld::Label> mxSheetMarginTxt2;
157 std::unique_ptr<weld::ComboBox> mxPaperSizeBox;
158 std::unique_ptr<weld::ComboBox> mxOrientationBox;
159
160 // page order ("left to right, then down")
161 std::unique_ptr<weld::Label> mxNupOrderTxt;
162 std::unique_ptr<weld::ComboBox> mxNupOrderBox;
163 std::unique_ptr<ShowNupOrderWindow> mxNupOrder;
164 std::unique_ptr<weld::CustomWeld> mxNupOrderWin;
165 /// border around each page
166 std::unique_ptr<weld::CheckButton> mxBorderCB;
167 std::unique_ptr<weld::Expander> mxRangeExpander;
168 std::unique_ptr<weld::Expander> mxLayoutExpander;
169 std::unique_ptr<weld::Widget> mxCustom;
170
171 OUString maPrintToFileText;
172 OUString maPrintText;
173 OUString maDefPrtText;
174
175 OUString maPageStr;
176 OUString maNoPageStr;
177 OUString maNoPreviewStr;
178 sal_Int32 mnCurPage;
179 sal_Int32 mnCachedPages;
180
181 std::vector<std::unique_ptr<weld::Widget>>
182 maExtraControls;
183
184 std::map<weld::Widget*, OUString>
185 maControlToPropertyMap;
186 std::map<OUString, std::vector<weld::Widget*>>
187 maPropertyToWindowMap;
188 std::map<weld::Widget*, sal_Int32>
189 maControlToNumValMap;
190
191 Size maNupPortraitSize;
192 Size maNupLandscapeSize;
193 /// internal, used for automatic Nup-Portrait/landscape
194 Size maFirstPageSize;
195
196 bool mbShowLayoutFrame;
197
198 Paper mePaper;
199
200 Idle maUpdatePreviewIdle;
201 DECL_LINK(updatePreviewIdle, Timer*, void);
202 Idle maUpdatePreviewNoCacheIdle;
203 DECL_LINK(updatePreviewNoCacheIdle, Timer*, void);
204
205 DECL_LINK( ClickHdl, weld::Button&, void );
206 DECL_LINK(SelectPrinterHdl, weld::ComboBox&, void);
207 DECL_LINK(SelectPaperSidesHdl, weld::ComboBox&, void);
208 DECL_LINK(SelectOrientationHdl, weld::ComboBox&, void);
209 DECL_LINK(SelectNupOrderHdl, weld::ComboBox&, void);
210 DECL_LINK(SelectNupPagesHdl, weld::ComboBox&, void);
211 DECL_LINK(SelectPaperSizeHdl, weld::ComboBox&, void);
212 DECL_LINK( ActivateHdl, weld::Entry&, bool );
213 DECL_LINK( FocusOutHdl, weld::Widget&, void );
214 DECL_LINK( SpinModifyHdl, weld::SpinButton&, void );
215 DECL_LINK( MetricSpinModifyHdl, weld::MetricSpinButton&, void );
216 DECL_LINK( ToggleHdl, weld::Toggleable&, void );
217
218 DECL_LINK( UIOption_CheckHdl, weld::Toggleable&, void );
219 DECL_LINK( UIOption_RadioHdl, weld::Toggleable&, void );
220 DECL_LINK( UIOption_SelectHdl, weld::ComboBox&, void );
221 DECL_LINK( UIOption_SpinModifyHdl, weld::SpinButton&, void );
222 DECL_LINK( UIOption_EntryModifyHdl, weld::Entry&, void );
223
224 css::beans::PropertyValue* getValueForWindow(weld::Widget*) const;
225
226 void ImplDestroy();
227 void preparePreview( bool i_bMayUseCache );
228 void setupPaperSidesBox();
229 void storeToSettings();
230 void readFromSettings();
231 void setPaperOrientation( Orientation eOrientation, bool fromUser );
232 void updateOrientationBox( bool bAutomatic = true );
233 void updatePageSize( int nOrientation );
234 void updatePageRange( const sal_Int32 nPages );
235 bool hasOrientationChanged() const;
236 void setPreviewText();
237 void updatePrinterText();
238 void checkControlDependencies();
239 void checkOptionalControlDependencies();
240 void makeEnabled( weld::Widget* );
241 void updateWindowFromProperty( const OUString& );
242 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& );
243 void showAdvancedControls( bool );
244 void updateNup( bool i_bMayUseCache = true );
245 void updateNupFromPages( bool i_bMayUseCache = true );
246 void enableNupControls( bool bEnable );
247 void setupOptionalUI();
248 Size const & getJobPageSize();
249
250 };
251
252 class PrintProgressDialog final : public weld::GenericDialogController
253 {
254 OUString maStr;
255 bool mbCanceled;
256 sal_Int32 mnCur;
257 sal_Int32 mnMax;
258
259 std::unique_ptr<weld::Label> mxText;
260 std::unique_ptr<weld::ProgressBar> mxProgress;
261 std::unique_ptr<weld::Button> mxButton;
262
263 DECL_LINK( ClickHdl, weld::Button&, void );
264
265 public:
266 PrintProgressDialog(weld::Window* i_pParent, int i_nMax);
267 virtual ~PrintProgressDialog() override;
268 bool isCanceled() const { return mbCanceled; }
269 void setProgress( int i_nCurrent );
270 void tick();
271 };
272 }
273
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */