1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef VCL_INC_NEWPRINTDLG_HXX
21 #define VCL_INC_NEWPRINTDLG_HXX
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>
37 class PrintDialog final
: public weld::GenericDialogController
39 friend class MoreOptionsDialog
;
42 class PrintPreviewWindow final
: public weld::CustomWidgetController
44 PrintDialog
* mpDialog
;
50 BitmapEx maPreviewBitmap
;
51 OUString maReplacementString
;
57 void preparePreviewBitmap();
60 PrintPreviewWindow(PrintDialog
* pDialog
);
61 virtual ~PrintPreviewWindow() override
;
63 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
64 virtual bool Command( const CommandEvent
& ) override
;
65 virtual void Resize() override
;
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
,
75 class ShowNupOrderWindow final
: public weld::CustomWidgetController
77 NupOrderType mnOrderMode
;
83 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
85 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& ) override
;
87 void setValues( NupOrderType i_nOrderMode
, int i_nColumns
, int i_nRows
)
89 mnOrderMode
= i_nOrderMode
;
91 mnColumns
= i_nColumns
;
96 PrintDialog(weld::Window
*, std::shared_ptr
<PrinterController
> );
97 virtual ~PrintDialog() override
;
99 bool isPrintToFile() const;
100 bool isCollate() const;
101 bool isSingleJobs() const;
102 bool hasPreview() const;
104 void setPaperSizes();
105 void previewForward();
106 void previewBackward();
112 std::unique_ptr
<weld::Builder
> mxCustomOptionsUIBuilder
;
114 std::shared_ptr
<PrinterController
> maPController
;
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
;
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
;
132 std::unique_ptr
<weld::Button
> mxOKButton
;
133 std::unique_ptr
<weld::Button
> mxCancelButton
;
135 std::unique_ptr
<weld::Button
> mxBackwardBtn
;
136 std::unique_ptr
<weld::Button
> mxForwardBtn
;
137 std::unique_ptr
<weld::Button
> mxFirstBtn
;
138 std::unique_ptr
<weld::Button
> mxLastBtn
;
140 std::unique_ptr
<weld::CheckButton
> mxPreviewBox
;
141 std::unique_ptr
<weld::Label
> mxNumPagesText
;
142 std::unique_ptr
<PrintPreviewWindow
> mxPreview
;
143 std::unique_ptr
<weld::CustomWeld
> mxPreviewWindow
;
144 std::unique_ptr
<weld::Entry
> mxPageEdit
;
146 std::unique_ptr
<weld::RadioButton
> mxPagesBtn
;
147 std::unique_ptr
<weld::RadioButton
> mxBrochureBtn
;
148 std::unique_ptr
<weld::Label
> mxPagesBoxTitleTxt
;
149 std::unique_ptr
<weld::ComboBox
> mxNupPagesBox
;
151 // controls for "Custom" page mode
152 std::unique_ptr
<weld::Label
> mxNupNumPagesTxt
;
153 std::unique_ptr
<weld::SpinButton
> mxNupColEdt
;
154 std::unique_ptr
<weld::Label
> mxNupTimesTxt
;
155 std::unique_ptr
<weld::SpinButton
> mxNupRowsEdt
;
156 std::unique_ptr
<weld::Label
> mxPageMarginTxt1
;
157 std::unique_ptr
<weld::MetricSpinButton
> mxPageMarginEdt
;
158 std::unique_ptr
<weld::Label
> mxPageMarginTxt2
;
159 std::unique_ptr
<weld::Label
> mxSheetMarginTxt1
;
160 std::unique_ptr
<weld::MetricSpinButton
> mxSheetMarginEdt
;
161 std::unique_ptr
<weld::Label
> mxSheetMarginTxt2
;
162 std::unique_ptr
<weld::ComboBox
> mxPaperSizeBox
;
163 std::unique_ptr
<weld::ComboBox
> mxOrientationBox
;
165 // page order ("left to right, then down")
166 std::unique_ptr
<weld::Label
> mxNupOrderTxt
;
167 std::unique_ptr
<weld::ComboBox
> mxNupOrderBox
;
168 std::unique_ptr
<ShowNupOrderWindow
> mxNupOrder
;
169 std::unique_ptr
<weld::CustomWeld
> mxNupOrderWin
;
170 /// border around each page
171 std::unique_ptr
<weld::CheckButton
> mxBorderCB
;
172 std::unique_ptr
<weld::Expander
> mxRangeExpander
;
173 std::unique_ptr
<weld::Expander
> mxLayoutExpander
;
174 std::unique_ptr
<weld::Widget
> mxCustom
;
176 OUString maPrintToFileText
;
177 OUString maPrintText
;
178 OUString maDefPrtText
;
181 OUString maNoPageStr
;
182 OUString maNoPreviewStr
;
184 sal_Int32 mnCachedPages
;
186 bool mbCollateAlwaysOff
;
188 std::vector
<std::unique_ptr
<weld::Widget
>>
191 std::map
<weld::Widget
*, OUString
>
192 maControlToPropertyMap
;
193 std::map
<OUString
, std::vector
<weld::Widget
*>>
194 maPropertyToWindowMap
;
195 std::map
<weld::Widget
*, sal_Int32
>
196 maControlToNumValMap
;
198 Size maNupPortraitSize
;
199 Size maNupLandscapeSize
;
200 /// internal, used for automatic Nup-Portrait/landscape
201 Size maFirstPageSize
;
203 bool mbShowLayoutFrame
;
207 Idle maUpdatePreviewIdle
;
208 DECL_LINK(updatePreviewIdle
, Timer
*, void);
209 Idle maUpdatePreviewNoCacheIdle
;
210 DECL_LINK(updatePreviewNoCacheIdle
, Timer
*, void);
212 DECL_LINK( ClickHdl
, weld::Button
&, void );
213 DECL_LINK( SelectHdl
, weld::ComboBox
&, void );
214 DECL_LINK( ActivateHdl
, weld::Entry
&, bool );
215 DECL_LINK( FocusOutHdl
, weld::Widget
&, void );
216 DECL_LINK( SpinModifyHdl
, weld::SpinButton
&, void );
217 DECL_LINK( MetricSpinModifyHdl
, weld::MetricSpinButton
&, void );
218 DECL_LINK( ToggleHdl
, weld::Toggleable
&, void );
220 DECL_LINK( UIOption_CheckHdl
, weld::Toggleable
&, void );
221 DECL_LINK( UIOption_RadioHdl
, weld::Toggleable
&, void );
222 DECL_LINK( UIOption_SelectHdl
, weld::ComboBox
&, void );
223 DECL_LINK( UIOption_SpinModifyHdl
, weld::SpinButton
&, void );
224 DECL_LINK( UIOption_EntryModifyHdl
, weld::Entry
&, void );
226 css::beans::PropertyValue
* getValueForWindow(weld::Widget
*) const;
228 void preparePreview( bool i_bMayUseCache
);
229 void setupPaperSidesBox();
230 void storeToSettings();
231 void readFromSettings();
232 void setPaperOrientation( Orientation eOrientation
, bool fromUser
);
233 void updateOrientationBox( bool bAutomatic
= true );
234 void updatePageSize( int nOrientation
);
235 void updatePageRange( const sal_Int32 nPages
);
236 bool hasOrientationChanged() const;
237 void setPreviewText();
238 void updatePrinterText();
239 void checkControlDependencies();
240 void checkOptionalControlDependencies();
241 void makeEnabled( weld::Widget
* );
242 void updateWindowFromProperty( const OUString
& );
243 void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup
& );
244 void showAdvancedControls( bool );
245 void updateNup( bool i_bMayUseCache
= true );
246 void updateNupFromPages( bool i_bMayUseCache
= true );
247 void enableNupControls( bool bEnable
);
248 void setupOptionalUI();
249 Size
const & getJobPageSize();
253 class PrintProgressDialog final
: public weld::GenericDialogController
260 std::unique_ptr
<weld::Label
> mxText
;
261 std::unique_ptr
<weld::ProgressBar
> mxProgress
;
262 std::unique_ptr
<weld::Button
> mxButton
;
264 DECL_LINK( ClickHdl
, weld::Button
&, void );
267 PrintProgressDialog(weld::Window
* i_pParent
, int i_nMax
);
268 virtual ~PrintProgressDialog() override
;
269 bool isCanceled() const { return mbCanceled
; }
270 void setProgress( int i_nCurrent
);
275 #endif // VCL_INC_NEWPRINTDLG_HXX
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */