LibreOffice Module vcl (master) 1
printdlg.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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#include <o3tl/safeint.hxx>
21#include <sal/log.hxx>
22#include <osl/diagnose.h>
23#include <rtl/ustrbuf.hxx>
25#include <officecfg/Office/Common.hxx>
26
27#include <utility>
28#include <vcl/QueueInfo.hxx>
29#include <vcl/commandevent.hxx>
30#include <vcl/decoview.hxx>
31#include <vcl/help.hxx>
32#include <vcl/naturalsort.hxx>
33#include <vcl/print.hxx>
35#include <vcl/settings.hxx>
36#include <vcl/svapp.hxx>
37#include <vcl/virdev.hxx>
38#include <vcl/wall.hxx>
39#include <vcl/weldutils.hxx>
40#include <vcl/windowstate.hxx>
41
42#include <bitmaps.hlst>
43#include <configsettings.hxx>
44#include <printdlg.hxx>
45#include <strings.hrc>
46#include <svdata.hxx>
47
48#include <com/sun/star/beans/PropertyValue.hpp>
49
50using namespace vcl;
51using namespace com::sun::star;
52using namespace com::sun::star::uno;
53using namespace com::sun::star::lang;
54using namespace com::sun::star::container;
55using namespace com::sun::star::beans;
56
57enum
58{
62};
63
64namespace {
65 bool lcl_ListBoxCompare( const OUString& rStr1, const OUString& rStr2 )
66 {
67 return vcl::NaturalSortCompare( rStr1, rStr2 ) < 0;
68 }
69}
70
71PrintDialog::PrintPreviewWindow::PrintPreviewWindow(PrintDialog* pDialog)
72 : mpDialog(pDialog)
73 , maOrigSize( 10, 10 )
74 , mnDPIX(Application::GetDefaultDevice()->GetDPIX())
75 , mnDPIY(Application::GetDefaultDevice()->GetDPIY())
76 , mbGreyscale( false )
77{
78}
79
81{
82}
83
85{
86 Size aNewSize(GetOutputSizePixel());
87 tools::Long nTextHeight = GetDrawingArea()->get_text_height();
88 // leave small space for decoration
89 aNewSize.AdjustWidth( -(nTextHeight + 2) );
90 aNewSize.AdjustHeight( -(nTextHeight + 2) );
91 Size aScaledSize;
92 double fScale = 1.0;
93
94 // #i106435# catch corner case of Size(0,0)
95 Size aOrigSize( maOrigSize );
96 if( aOrigSize.Width() < 1 )
97 aOrigSize.setWidth( aNewSize.Width() );
98 if( aOrigSize.Height() < 1 )
99 aOrigSize.setHeight( aNewSize.Height() );
100 if( aOrigSize.Width() > aOrigSize.Height() )
101 {
102 aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * aOrigSize.Height() / aOrigSize.Width() );
103 if( aScaledSize.Height() > aNewSize.Height() )
104 fScale = double(aNewSize.Height())/double(aScaledSize.Height());
105 }
106 else
107 {
108 aScaledSize = Size( aNewSize.Height() * aOrigSize.Width() / aOrigSize.Height(), aNewSize.Height() );
109 if( aScaledSize.Width() > aNewSize.Width() )
110 fScale = double(aNewSize.Width())/double(aScaledSize.Width());
111 }
112 aScaledSize.setWidth( tools::Long(aScaledSize.Width()*fScale) );
113 aScaledSize.setHeight( tools::Long(aScaledSize.Height()*fScale) );
114
115 maPreviewSize = aScaledSize;
116
117 // check and evtl. recreate preview bitmap
118 preparePreviewBitmap();
119}
120
122{
123 rRenderContext.Push();
124 weld::SetPointFont(rRenderContext, rRenderContext.GetSettings().GetStyleSettings().GetLabelFont());
125
126 rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
127 rRenderContext.Erase();
128
129 auto nTextHeight = rRenderContext.GetTextHeight();
130 Size aSize(GetOutputSizePixel());
131 Point aOffset((aSize.Width() - maPreviewSize.Width() + nTextHeight) / 2,
132 (aSize.Height() - maPreviewSize.Height() + nTextHeight) / 2);
133
134 // horizontal line
135 {
136 auto nWidth = rRenderContext.GetTextWidth(maHorzText);
137
138 auto nStart = aOffset.X() + (maPreviewSize.Width() - nWidth) / 2;
139 rRenderContext.DrawText(Point(nStart, aOffset.Y() - nTextHeight), maHorzText, 0, maHorzText.getLength());
140
141 DecorationView aDecoView(&rRenderContext);
142 auto nTop = aOffset.Y() - (nTextHeight / 2);
143 aDecoView.DrawSeparator(Point(aOffset.X(), nTop), Point(nStart - 2, nTop), false);
144 aDecoView.DrawSeparator(Point(nStart + nWidth + 2, nTop), Point(aOffset.X() + maPreviewSize.Width(), nTop), false);
145 }
146
147 // vertical line
148 {
149 rRenderContext.Push(PushFlags::FONT);
150 vcl::Font aFont(rRenderContext.GetFont());
151 aFont.SetOrientation(900_deg10);
152 rRenderContext.SetFont(aFont);
153
154 auto nLeft = aOffset.X() - nTextHeight;
155
156 auto nWidth = rRenderContext.GetTextWidth(maVertText);
157 auto nStart = aOffset.Y() + (maPreviewSize.Height() + nWidth) / 2;
158
159 rRenderContext.DrawText(Point(nLeft, nStart), maVertText, 0, maVertText.getLength());
160
161 DecorationView aDecoView(&rRenderContext);
162 nLeft = aOffset.X() - (nTextHeight / 2);
163 aDecoView.DrawSeparator(Point(nLeft, aOffset.Y()), Point(nLeft, nStart - nWidth - 2), true);
164 aDecoView.DrawSeparator(Point(nLeft, nStart + 2), Point(nLeft, aOffset.Y() + maPreviewSize.Height()), true);
165
166 rRenderContext.Pop();
167 }
168
169 if (!maReplacementString.isEmpty())
170 {
171 // replacement is active
172 tools::Rectangle aTextRect(aOffset + Point(2, 2), Size(maPreviewSize.Width() - 4, maPreviewSize.Height() - 4));
173 rRenderContext.DrawText(aTextRect, maReplacementString,
176 }
177 else
178 {
179 BitmapEx aPreviewBitmap(maPreviewBitmap);
180
181 // This explicit force-to-scale allows us to get the
182 // mentioned best quality here. Unfortunately this is
183 // currently not sure when using just ::DrawBitmap with
184 // a defined size or ::DrawOutDev
185 aPreviewBitmap.Scale(maPreviewSize, BmpScaleFlag::BestQuality);
186 rRenderContext.DrawBitmapEx(aOffset, aPreviewBitmap);
187 }
188
189 tools::Rectangle aFrameRect(aOffset + Point(-1, -1), Size(maPreviewSize.Width() + 2, maPreviewSize.Height() + 2));
190 DecorationView aDecorationView(&rRenderContext);
191 aDecorationView.DrawFrame(aFrameRect, DrawFrameStyle::Group);
192
193 rRenderContext.Pop();
194}
195
197{
198 if( rEvt.GetCommand() == CommandEventId::Wheel )
199 {
200 const CommandWheelData* pWheelData = rEvt.GetWheelData();
201 if(pWheelData->GetDelta() > 0)
202 mpDialog->previewForward();
203 else if (pWheelData->GetDelta() < 0)
204 mpDialog->previewBackward();
205 return true;
206 }
207 return CustomWidgetController::Command(rEvt);
208}
209
211 const Size& i_rOrigSize,
212 std::u16string_view i_rPaperName,
213 const OUString& i_rReplacement,
214 sal_Int32 i_nDPIX,
215 sal_Int32 i_nDPIY,
216 bool i_bGreyscale
217 )
218{
219 maMtf = i_rNewPreview;
220 mnDPIX = i_nDPIX;
221 mnDPIY = i_nDPIY;
222 maOrigSize = i_rOrigSize;
223 maReplacementString = i_rReplacement;
224 mbGreyscale = i_bGreyscale;
225
226 // use correct measurements
229 int nDigits = 0;
230 if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
231 {
232 eUnit = o3tl::Length::in100;
233 nDigits = 2;
234 }
235 Size aLogicPaperSize(o3tl::convert(i_rOrigSize, o3tl::Length::mm100, eUnit));
236 OUString aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
237 OUStringBuffer aBuf( aNumText + " " );
238 aBuf.appendAscii( eUnit == o3tl::Length::mm ? "mm" : "in" );
239 if( !i_rPaperName.empty() )
240 {
241 aBuf.append( OUString::Concat(" (") + i_rPaperName + ")" );
242 }
243 maHorzText = aBuf.makeStringAndClear();
244
245 aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
246 aBuf.append( aNumText + " " );
247 aBuf.appendAscii( eUnit == o3tl::Length::mm ? "mm" : "in" );
248 maVertText = aBuf.makeStringAndClear();
249
250 // We have a new Metafile and evtl. a new page, so we need to reset
251 // the PreviewBitmap to force new creation
252 maPreviewBitmap = Bitmap();
253
254 // sets/calculates e.g. maPreviewSize
255 // also triggers preparePreviewBitmap()
256 Resize();
257
258 Invalidate();
259}
260
262{
263 if(maPreviewSize.IsEmpty())
264 {
265 // not yet fully initialized, no need to prepare anything
266 return;
267 }
268
269 // define an allowed number of pixels, also see
270 // defaults for primitive renderers and similar. This
271 // might be centralized and made dependent of 32/64bit
272 const sal_uInt32 nMaxSquarePixels(500000);
273
274 // check how big (squarePixels) the preview is currently (with
275 // max value of MaxSquarePixels)
276 const sal_uInt32 nCurrentSquarePixels(
277 std::min(
278 nMaxSquarePixels,
279 static_cast<sal_uInt32>(maPreviewBitmap.GetSizePixel().getWidth())
280 * static_cast<sal_uInt32>(maPreviewBitmap.GetSizePixel().getHeight())));
281
282 // check how big (squarePixels) the preview needs to be (with
283 // max value of MaxSquarePixels)
284 const sal_uInt32 nRequiredSquarePixels(
285 std::min(
286 nMaxSquarePixels,
287 static_cast<sal_uInt32>(maPreviewSize.getWidth())
288 * static_cast<sal_uInt32>(maPreviewSize.getHeight())));
289
290 // check if preview is big enough. Use a scaling value in
291 // the comparison to not get bigger at the last possible moment
292 // what may look awkward and pixelated (again). This means
293 // to use a percentage value - if we have at least
294 // that value of required pixels, we are good.
295 static const double fPreventAwkwardFactor(1.35); // 35%
296 if(nCurrentSquarePixels >= static_cast<sal_uInt32>(nRequiredSquarePixels * fPreventAwkwardFactor))
297 {
298 // at this place we also could add a mechanism to let the preview
299 // bitmap 'shrink' again if it is currently 'too big' -> bigger
300 // than required. I think this is not necessary for now.
301
302 // already sufficient, done.
303 return;
304 }
305
306 // check if we have enough square pixels e.g for 8x8 pixels
307 if(nRequiredSquarePixels < 64)
308 {
309 // too small preview - let it empty
310 return;
311 }
312
313 // Calculate nPlannedSquarePixels which is the required size
314 // expanded by a percentage (with max value of MaxSquarePixels)
315 static const double fExtraSpaceFactor(1.65); // 65%
316 const sal_uInt32 nPlannedSquarePixels(
317 std::min(
318 nMaxSquarePixels,
319 static_cast<sal_uInt32>(maPreviewSize.getWidth() * fExtraSpaceFactor)
320 * static_cast<sal_uInt32>(maPreviewSize.getHeight() * fExtraSpaceFactor)));
321
322 // calculate back new width and height - it might have been
323 // truncated by MaxSquarePixels.
324 // We know that w*h == nPlannedSquarePixels and w/h == ratio
325 const double fRatio(static_cast<double>(maPreviewSize.getWidth()) / static_cast<double>(maPreviewSize.getHeight()));
326 const double fNewWidth(sqrt(static_cast<double>(nPlannedSquarePixels) * fRatio));
327 const double fNewHeight(sqrt(static_cast<double>(nPlannedSquarePixels) / fRatio));
328 const Size aScaledSize(basegfx::fround(fNewWidth), basegfx::fround(fNewHeight));
329
330 // check if this eventual maximum is already reached
331 // due to having hit the MaxSquarePixels. Due to using
332 // an integer AspectRatio, we cannot make a numeric exact
333 // comparison - we need to compare if we are close
334 const double fScaledSizeSquare(static_cast<double>(aScaledSize.getWidth() * aScaledSize.getHeight()));
335 const double fPreviewSizeSquare(static_cast<double>(maPreviewBitmap.GetSizePixel().getWidth() * maPreviewBitmap.GetSizePixel().getHeight()));
336
337 // test as equal up to 0.1% (0.001)
338 if(fPreviewSizeSquare != 0.0 && fabs((fScaledSizeSquare / fPreviewSizeSquare) - 1.0) < 0.001)
339 {
340 // maximum is reached, avoid bigger scaling
341 return;
342 }
343
344 // create temporary VDev with requested Size and DPI.
345 // CAUTION: DPI *is* important here - it DIFFERS from 75x75, usually 600x600 is used
347 pPrerenderVDev->SetOutputSizePixel(aScaledSize, false);
348 pPrerenderVDev->SetReferenceDevice( mnDPIX, mnDPIY );
349
350 // calculate needed Scale for Metafile (using Size and DPI from VDev)
351 Size aLogicSize( pPrerenderVDev->PixelToLogic( pPrerenderVDev->GetOutputSizePixel(), MapMode( MapUnit::Map100thMM ) ) );
352 Size aOrigSize( maOrigSize );
353 if( aOrigSize.Width() < 1 )
354 aOrigSize.setWidth( aLogicSize.Width() );
355 if( aOrigSize.Height() < 1 )
356 aOrigSize.setHeight( aLogicSize.Height() );
357 double fScale = double(aLogicSize.Width())/double(aOrigSize.Width());
358
359 // tdf#141761
360 // The display quality of the Preview is pretty ugly when
361 // FormControls are used. I made a deep-dive why this happens,
362 // and in principle the reason is the Mteafile::Scale used
363 // below. Since Metafile actions are integer, that floating point
364 // scale leads to rounding errors that make the lines painting
365 // the FormControls disappear in the surrounding ClipRegions.
366 // That Scale cannot be avoided since the Metafile contains it's
367 // own SetMapMode commands which *will* be executed on ::Play,
368 // so the ::Scale is the only possibility fr Metafile currently:
369 // Giving a Size as parameter in ::Play will *not* work due to
370 // the relativeMapMode that gets created will fail on
371 // ::SetMapMode actions in the Metafile - and FormControls DO
372 // use ::SetMapMode(MapPixel).
373 // This can only be solved better in the future using Primitives
374 // which would allow any scale by embedding to a Transformation,
375 // but that would be a bigger rework.
376 // Until then, use this little 'trick' to improve quality.
377 // It uses the fact to empirically having tested that the quality
378 // gets really bad for FormControls starting by a scale factor
379 // smaller than 0.2 - that makes the ClipRegion overlap start.
380 // So - for now - try not to go below that.
381 static const double fMinimumScale(0.2);
382 double fFactor(0.0);
383 if(fScale < fMinimumScale)
384 {
385 fFactor = fMinimumScale / fScale;
386 fScale = fMinimumScale;
387
388 double fWidth(aScaledSize.getWidth() * fFactor);
389 double fHeight(aScaledSize.getHeight() * fFactor);
390 const double fNewNeededPixels(fWidth * fHeight);
391
392 // to not risk using too big bitmaps and running into
393 // memory problems, still limit to a useful factor is
394 // necessary, also empirically estimated to
395 // avoid the quality from collapsing (using a direct
396 // in-between , ceil'd result)
397 static const double fMaximumQualitySquare(1396221.0);
398
399 if(fNewNeededPixels > fMaximumQualitySquare)
400 {
401 const double fCorrection(fMaximumQualitySquare/fNewNeededPixels);
402 fWidth *= fCorrection;
403 fHeight *= fCorrection;
404 fScale *= fCorrection;
405 }
406
407 const Size aScaledSize2(basegfx::fround(fWidth), basegfx::fround(fHeight));
408 pPrerenderVDev->SetOutputSizePixel(aScaledSize2, false);
409 aLogicSize = pPrerenderVDev->PixelToLogic( aScaledSize2, MapMode( MapUnit::Map100thMM ) );
410 }
411
412 pPrerenderVDev->EnableOutput();
413 pPrerenderVDev->SetBackground( Wallpaper(COL_WHITE) );
414 pPrerenderVDev->Erase();
415 pPrerenderVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
416 if( mbGreyscale )
417 pPrerenderVDev->SetDrawMode( pPrerenderVDev->GetDrawMode() |
420
421 // Copy, Scale and Paint Metafile
422 GDIMetaFile aMtf( maMtf );
423 aMtf.WindStart();
424 aMtf.Scale( fScale, fScale );
425 aMtf.WindStart();
426 aMtf.Play(*pPrerenderVDev, Point(0, 0), aLogicSize);
427
428 pPrerenderVDev->SetMapMode(MapMode(MapUnit::MapPixel));
429 maPreviewBitmap = pPrerenderVDev->GetBitmapEx(Point(0, 0), pPrerenderVDev->GetOutputSizePixel());
430
431 if(0.0 != fFactor)
432 {
433 // Correct to needed size, BmpScaleFlag::Interpolate is acceptable,
434 // but BmpScaleFlag::BestQuality is just better. In case of time
435 // constraints, change to Interpolate would be possible
436 maPreviewBitmap.Scale(aScaledSize, BmpScaleFlag::BestQuality);
437 }
438}
439
441 : mnOrderMode( NupOrderType::LRTB )
442 , mnRows( 1 )
443 , mnColumns( 1 )
444{
445}
446
448{
449 Size aSize(70, 70);
450 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
451 CustomWidgetController::SetDrawingArea(pDrawingArea);
452 SetOutputSizePixel(aSize);
453}
454
456{
457 rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel));
458 rRenderContext.SetTextColor(rRenderContext.GetSettings().GetStyleSettings().GetFieldTextColor());
459 rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetFieldColor()));
460 rRenderContext.Erase();
461
462 int nPages = mnRows * mnColumns;
463 Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetFieldFont());
464 aFont.SetFontSize(Size(0, 24));
465 rRenderContext.SetFont(aFont);
466 Size aSampleTextSize(rRenderContext.GetTextWidth(OUString::number(nPages + 1)), rRenderContext.GetTextHeight());
467 Size aOutSize(GetOutputSizePixel());
468 Size aSubSize(aOutSize.Width() / mnColumns, aOutSize.Height() / mnRows);
469 // calculate font size: shrink the sample text so it fits
470 double fX = double(aSubSize.Width()) / double(aSampleTextSize.Width());
471 double fY = double(aSubSize.Height()) / double(aSampleTextSize.Height());
472 double fScale = (fX < fY) ? fX : fY;
473 tools::Long nFontHeight = tools::Long(24.0 * fScale) - 3;
474 if (nFontHeight < 5)
475 nFontHeight = 5;
476 aFont.SetFontSize(Size( 0, nFontHeight));
477 rRenderContext.SetFont(aFont);
478 tools::Long nTextHeight = rRenderContext.GetTextHeight();
479 for (int i = 0; i < nPages; i++)
480 {
481 OUString aPageText(OUString::number(i + 1));
482 int nX = 0, nY = 0;
483 switch (mnOrderMode)
484 {
486 nX = (i % mnColumns);
487 nY = (i / mnColumns);
488 break;
490 nX = (i / mnRows);
491 nY = (i % mnRows);
492 break;
494 nX = mnColumns - 1 - (i % mnColumns);
495 nY = (i / mnColumns);
496 break;
498 nX = mnColumns - 1 - (i / mnRows);
499 nY = (i % mnRows);
500 break;
501 }
502 Size aTextSize(rRenderContext.GetTextWidth(aPageText), nTextHeight);
503 int nDeltaX = (aSubSize.Width() - aTextSize.Width()) / 2;
504 int nDeltaY = (aSubSize.Height() - aTextSize.Height()) / 2;
505 rRenderContext.DrawText(Point(nX * aSubSize.Width() + nDeltaX,
506 nY * aSubSize.Height() + nDeltaY), aPageText);
507 }
508 DecorationView aDecorationView(&rRenderContext);
509 aDecorationView.DrawFrame(tools::Rectangle(Point(0, 0), aOutSize), DrawFrameStyle::Group);
510}
511
513{
515 {
517 GDIMetaFile aMtf;
518 if( maPController->getPageCountProtected() > 0 )
519 {
520 PrinterController::PageSize aPageSize = maPController->getPageFile( 0, aMtf, true );
521 maFirstPageSize = aPageSize.aSize;
522 }
523 }
524 return maFirstPageSize;
525}
526
527PrintDialog::PrintDialog(weld::Window* i_pWindow, std::shared_ptr<PrinterController> i_xController)
528 : GenericDialogController(i_pWindow, "vcl/ui/printdialog.ui", "PrintDialog")
529 , maPController(std::move( i_xController ))
530 , mxTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
531 , mxScrolledWindow(m_xBuilder->weld_scrolled_window("scrolledwindow"))
532 , mxPageLayoutFrame(m_xBuilder->weld_frame("layoutframe"))
533 , mxPrinters(m_xBuilder->weld_combo_box("printersbox"))
534 , mxStatusTxt(m_xBuilder->weld_label("status"))
535 , mxSetupButton(m_xBuilder->weld_button("setup"))
536 , mxCopyCountField(m_xBuilder->weld_spin_button("copycount"))
537 , mxCollateBox(m_xBuilder->weld_check_button("collate"))
538 , mxCollateImage(m_xBuilder->weld_image("collateimage"))
539 , mxPageRangeEdit(m_xBuilder->weld_entry("pagerange"))
540 , mxPageRangesRadioButton(m_xBuilder->weld_radio_button("rbRangePages"))
541 , mxPaperSidesBox(m_xBuilder->weld_combo_box("sidesbox"))
542 , mxSingleJobsBox(m_xBuilder->weld_check_button("singlejobs"))
543 , mxReverseOrderBox(m_xBuilder->weld_check_button("reverseorder"))
544 , mxOKButton(m_xBuilder->weld_button("ok"))
545 , mxCancelButton(m_xBuilder->weld_button("cancel"))
546 , mxHelpButton(m_xBuilder->weld_button("help"))
547 , mxBackwardBtn(m_xBuilder->weld_button("backward"))
548 , mxForwardBtn(m_xBuilder->weld_button("forward"))
549 , mxFirstBtn(m_xBuilder->weld_button("btnFirst"))
550 , mxLastBtn(m_xBuilder->weld_button("btnLast"))
551 , mxPreviewBox(m_xBuilder->weld_check_button("previewbox"))
552 , mxNumPagesText(m_xBuilder->weld_label("totalnumpages"))
553 , mxPreview(new PrintPreviewWindow(this))
554 , mxPreviewWindow(new weld::CustomWeld(*m_xBuilder, "preview", *mxPreview))
555 , mxPageEdit(m_xBuilder->weld_entry("pageedit"))
556 , mxPagesBtn(m_xBuilder->weld_radio_button("pagespersheetbtn"))
557 , mxBrochureBtn(m_xBuilder->weld_radio_button("brochure"))
558 , mxPagesBoxTitleTxt(m_xBuilder->weld_label("pagespersheettxt"))
559 , mxNupPagesBox(m_xBuilder->weld_combo_box("pagespersheetbox"))
560 , mxNupNumPagesTxt(m_xBuilder->weld_label("pagestxt"))
561 , mxNupColEdt(m_xBuilder->weld_spin_button("pagecols"))
562 , mxNupTimesTxt(m_xBuilder->weld_label("by"))
563 , mxNupRowsEdt(m_xBuilder->weld_spin_button("pagerows"))
564 , mxPageMarginTxt1(m_xBuilder->weld_label("pagemargintxt1"))
565 , mxPageMarginEdt(m_xBuilder->weld_metric_spin_button("pagemarginsb", FieldUnit::MM))
566 , mxPageMarginTxt2(m_xBuilder->weld_label("pagemargintxt2"))
567 , mxSheetMarginTxt1(m_xBuilder->weld_label("sheetmargintxt1"))
568 , mxSheetMarginEdt(m_xBuilder->weld_metric_spin_button("sheetmarginsb", FieldUnit::MM))
569 , mxSheetMarginTxt2(m_xBuilder->weld_label("sheetmargintxt2"))
570 , mxPaperSizeBox(m_xBuilder->weld_combo_box("papersizebox"))
571 , mxOrientationBox(m_xBuilder->weld_combo_box("pageorientationbox"))
572 , mxNupOrderTxt(m_xBuilder->weld_label("labelorder"))
573 , mxNupOrderBox(m_xBuilder->weld_combo_box("orderbox"))
575 , mxNupOrderWin(new weld::CustomWeld(*m_xBuilder, "orderpreview", *mxNupOrder))
576 , mxBorderCB(m_xBuilder->weld_check_button("bordercb"))
577 , mxRangeExpander(m_xBuilder->weld_expander("exRangeExpander"))
578 , mxLayoutExpander(m_xBuilder->weld_expander("exLayoutExpander"))
579 , mxCustom(m_xBuilder->weld_widget("customcontents"))
580 , maPrintToFileText( VclResId( SV_PRINT_TOFILE_TXT ) )
581 , maDefPrtText( VclResId( SV_PRINT_DEFPRT_TXT ) )
582 , maNoPageStr( VclResId( SV_PRINT_NOPAGES ) )
583 , maNoPreviewStr( VclResId( SV_PRINT_NOPREVIEW ) )
584 , mnCurPage( 0 )
585 , mnCachedPages( 0 )
586 , mbCollateAlwaysOff(false)
587 , mbShowLayoutFrame( true )
588 , maUpdatePreviewIdle("Print Dialog Update Preview Idle")
589 , maUpdatePreviewNoCacheIdle("Print Dialog Update Preview (no cache) Idle")
590{
591 // save printbutton text, gets exchanged occasionally with print to file
592 maPrintText = mxOKButton->get_label();
593
594 maPageStr = mxNumPagesText->get_label();
595
597
598 mxPrinters->append_text(maPrintToFileText);
599 // fill printer listbox
600 std::vector< OUString > rQueues( Printer::GetPrinterQueues() );
601 std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
602 for( const auto& rQueue : rQueues )
603 {
604 mxPrinters->append_text(rQueue);
605 }
606 // select current printer
607 if (mxPrinters->find_text(maPController->getPrinter()->GetName()) != -1)
608 mxPrinters->set_active_text(maPController->getPrinter()->GetName());
609 else
610 {
611 // fall back to last printer
613 OUString aValue( pItem->getValue( "PrintDialog",
614 "LastPrinter" ) );
615 if (mxPrinters->find_text(aValue) != -1)
616 {
617 mxPrinters->set_active_text(aValue);
618 maPController->setPrinter( VclPtrInstance<Printer>( aValue ) );
619 }
620 else
621 {
622 // fall back to default printer
623 mxPrinters->set_active_text(Printer::GetDefaultPrinterName());
625 }
626 }
627
628 // not printing to file
629 maPController->resetPrinterOptions( false );
630
631 // update the text fields for the printer
633
634 // setup dependencies
636
637 // setup paper sides box
639
640 // set initial focus to "Number of copies"
641 mxCopyCountField->grab_focus();
642 mxCopyCountField->select_region(0, -1);
643
644 // setup sizes for N-Up
645 Size aNupSize( maPController->getPrinter()->PixelToLogic(
646 maPController->getPrinter()->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) ) );
647 if( maPController->getPrinter()->GetOrientation() == Orientation::Landscape )
648 {
649 maNupLandscapeSize = aNupSize;
650 // coverity[swapped_arguments : FALSE] - this is in the correct order
651 maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() );
652 }
653 else
654 {
655 maNupPortraitSize = aNupSize;
656 // coverity[swapped_arguments : FALSE] - this is in the correct order
657 maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() );
658 }
659
661 maUpdatePreviewIdle.SetInvokeHandler(LINK( this, PrintDialog, updatePreviewIdle));
663 maUpdatePreviewNoCacheIdle.SetInvokeHandler(LINK(this, PrintDialog, updatePreviewNoCacheIdle));
664
665 initFromMultiPageSetup( maPController->getMultipage() );
666
667 // setup optional UI options set by application
669
670 // hide layout frame if unwanted
672
673 // restore settings from last run
675
676 // setup click hdl
677 mxOKButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
678 mxCancelButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
679 mxHelpButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
680 mxSetupButton->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
681 mxBackwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
682 mxForwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
683 mxFirstBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
684 mxLastBtn->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
685
686 // setup toggle hdl
687 mxReverseOrderBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
688 mxCollateBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
689 mxSingleJobsBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
690 mxBrochureBtn->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
691 mxPreviewBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
692 mxBorderCB->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
693
694 // setup select hdl
695 mxPrinters->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
696 mxPaperSidesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
697 mxNupPagesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
698 mxOrientationBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
699 mxNupOrderBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
700 mxPaperSizeBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
701
702 // setup modify hdl
703 mxPageEdit->connect_activate( LINK( this, PrintDialog, ActivateHdl ) );
704 mxPageEdit->connect_focus_out( LINK( this, PrintDialog, FocusOutHdl ) );
705 mxCopyCountField->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
706 mxNupColEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
707 mxNupRowsEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
708 mxPageMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );
709 mxSheetMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );
710
712
713 // tdf#129180 Delay setting the default value in the Paper Size list
714 // set paper sizes listbox
716
717 mxRangeExpander->set_expanded(
718 officecfg::Office::Common::Print::Dialog::RangeSectionExpanded::get());
719 mxLayoutExpander->set_expanded(
720 officecfg::Office::Common::Print::Dialog::LayoutSectionExpanded::get());
721
722 // lock the dialog height, regardless of later expander state
723 mxScrolledWindow->set_size_request(
724 mxScrolledWindow->get_preferred_size().Width() + mxScrolledWindow->get_scroll_thickness(),
725 450);
726
727 m_xDialog->set_centered_on_parent(true);
728}
729
731{
732 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
733 officecfg::Office::Common::Print::Dialog::RangeSectionExpanded::set(mxRangeExpander->get_expanded(), batch);
734 officecfg::Office::Common::Print::Dialog::LayoutSectionExpanded::set(mxLayoutExpander->get_expanded(), batch);
735 batch->commit();
736}
737
739{
740 DuplexMode eDuplex = maPController->getPrinter()->GetDuplexMode();
741
742 if ( eDuplex == DuplexMode::Unknown || isPrintToFile() )
743 {
744 mxPaperSidesBox->set_active( 0 );
745 mxPaperSidesBox->set_sensitive( false );
746 }
747 else
748 {
749 mxPaperSidesBox->set_active( static_cast<sal_Int32>(eDuplex) - 1 );
750 mxPaperSidesBox->set_sensitive( true );
751 }
752}
753
755{
757
758 pItem->setValue( "PrintDialog",
759 "LastPrinter",
761 : mxPrinters->get_active_text() );
762
763 pItem->setValue( "PrintDialog",
764 "LastPage",
765 mxTabCtrl->get_tab_label_text(mxTabCtrl->get_current_page_ident()));
766
767 pItem->setValue( "PrintDialog",
768 "WindowState",
769 m_xDialog->get_window_state(vcl::WindowDataMask::All) );
770
771 pItem->setValue( "PrintDialog",
772 "CopyCount",
773 mxCopyCountField->get_text() );
774
775 pItem->setValue( "PrintDialog",
776 "Collate",
777 mxCollateBox->get_active() ? OUString("true") :
778 OUString("false") );
779
780 pItem->setValue( "PrintDialog",
781 "CollateSingleJobs",
782 mxSingleJobsBox->get_active() ? OUString("true") :
783 OUString("false") );
784
785 pItem->setValue( "PrintDialog",
786 "HasPreview",
787 hasPreview() ? OUString("true") :
788 OUString("false") );
789
790 pItem->Commit();
791}
792
794{
796
797 // read last selected tab page; if it exists, activate it
798 OUString aValue = pItem->getValue( "PrintDialog",
799 "LastPage" );
800 sal_uInt16 nCount = mxTabCtrl->get_n_pages();
801 for (sal_uInt16 i = 0; i < nCount; ++i)
802 {
803 OUString sPageId = mxTabCtrl->get_page_ident(i);
804 if (aValue == mxTabCtrl->get_tab_label_text(sPageId))
805 {
806 mxTabCtrl->set_current_page(sPageId);
807 break;
808 }
809 }
810
811 // persistent window state
812 aValue = pItem->getValue( "PrintDialog",
813 "WindowState" );
814 if (!aValue.isEmpty())
815 m_xDialog->set_window_state(aValue);
816
817 // collate
818 aValue = pItem->getValue( "PrintDialog",
819 "CollateBox" );
820 if( aValue.equalsIgnoreAsciiCase("alwaysoff") )
821 {
822 mbCollateAlwaysOff = true;
823 mxCollateBox->set_active( false );
824 mxCollateBox->set_sensitive( false );
825 }
826 else
827 {
828 mbCollateAlwaysOff = false;
829 aValue = pItem->getValue( "PrintDialog",
830 "Collate" );
831 mxCollateBox->set_active( aValue.equalsIgnoreAsciiCase("true") );
832 }
833
834 // collate single jobs
835 aValue = pItem->getValue( "PrintDialog",
836 "CollateSingleJobs" );
837 mxSingleJobsBox->set_active(aValue.equalsIgnoreAsciiCase("true"));
838
839 // preview box
840 aValue = pItem->getValue( "PrintDialog",
841 "HasPreview" );
842 if ( aValue.equalsIgnoreAsciiCase("false") )
843 mxPreviewBox->set_active( false );
844 else
845 mxPreviewBox->set_active( true );
846
847}
848
850{
851 mxPaperSizeBox->clear();
852
853 VclPtr<Printer> aPrt( maPController->getPrinter() );
854 mePaper = aPrt->GetPaper();
855
856 if ( isPrintToFile() )
857 {
858 mxPaperSizeBox->set_sensitive( false );
859 }
860 else
861 {
862 Size aSizeOfPaper = aPrt->GetSizeOfPaper();
863 PaperInfo aPaperInfo(aSizeOfPaper.getWidth(), aSizeOfPaper.getHeight());
866 int nDigits = 0;
867 if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
868 {
869 eUnit = o3tl::Length::in100;
870 nDigits = 2;
871 }
872 for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++)
873 {
874 PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
875 aInfo.doSloppyFit(true);
876 Paper ePaper = aInfo.getPaper();
877
878 Size aSize = aPrt->GetPaperSize( nPaper );
879 Size aLogicPaperSize( o3tl::convert(aSize, o3tl::Length::mm100, eUnit) );
880
881 OUString aWidth( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
882 OUString aHeight( rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ) );
883 OUString aUnit = eUnit == o3tl::Length::mm ? OUString("mm") : OUString("in");
884 OUString aPaperName;
885
886 // Paper sizes that we don't know of but the system printer driver lists are not "User
887 // Defined". Displaying them as such is just confusing.
888 if (ePaper != PAPER_USER)
889 aPaperName = Printer::GetPaperName( ePaper ) + " ";
890
891 aPaperName += aWidth + aUnit + " x " + aHeight + aUnit;
892
893 mxPaperSizeBox->append_text(aPaperName);
894
895 if ( (ePaper != PAPER_USER && ePaper == mePaper) ||
896 (ePaper == PAPER_USER && aInfo.sloppyEqual(aPaperInfo) ) )
897 mxPaperSizeBox->set_active( nPaper );
898 }
899
900 mxPaperSizeBox->set_sensitive( true );
901 }
902}
903
905{
906 const OUString aDefPrt( Printer::GetDefaultPrinterName() );
907 const QueueInfo* pInfo = Printer::GetQueueInfo( mxPrinters->get_active_text(), true );
908 if( pInfo )
909 {
910 // FIXME: status text
911 OUString aStatus;
912 if( aDefPrt == pInfo->GetPrinterName() )
913 aStatus = maDefPrtText;
914 mxStatusTxt->set_label( aStatus );
915 }
916 else
917 {
918 mxStatusTxt->set_label( OUString() );
919 }
920}
921
923{
924 OUString aNewText( maPageStr.replaceFirst( "%n", OUString::number( mnCachedPages ) ) );
925 mxNumPagesText->set_label( aNewText );
926}
927
928IMPL_LINK_NOARG(PrintDialog, updatePreviewIdle, Timer*, void)
929{
930 preparePreview(true);
931}
932
933IMPL_LINK_NOARG(PrintDialog, updatePreviewNoCacheIdle, Timer*, void)
934{
935 preparePreview(false);
936}
937
938void PrintDialog::preparePreview( bool i_bMayUseCache )
939{
940 VclPtr<Printer> aPrt( maPController->getPrinter() );
941 Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
942 // tdf#123076 Get paper size for the preview top label
943 mePaper = aPrt->GetPaper();
944 GDIMetaFile aMtf;
945
946 // page range may have changed depending on options
947 sal_Int32 nPages = maPController->getFilteredPageCount();
948 mnCachedPages = nPages;
949
951
952 if ( !hasPreview() )
953 {
954 mxPreview->setPreview( aMtf, aCurPageSize,
957 aPrt->GetDPIX(), aPrt->GetDPIY(),
958 aPrt->GetPrinterOptions().IsConvertToGreyscales()
959 );
960
961 mxForwardBtn->set_sensitive( false );
962 mxBackwardBtn->set_sensitive( false );
963 mxFirstBtn->set_sensitive( false );
964 mxLastBtn->set_sensitive( false );
965
966 mxPageEdit->set_sensitive( false );
967
968 return;
969 }
970
971 if( mnCurPage >= nPages )
972 mnCurPage = nPages-1;
973 if( mnCurPage < 0 )
974 mnCurPage = 0;
975 mxPageEdit->set_text(OUString::number(mnCurPage + 1));
976
977 if( nPages > 0 )
978 {
980 maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache );
981 aCurPageSize = aPrt->PixelToLogic(aPrt->GetPaperSizePixel(), MapMode(MapUnit::Map100thMM));
982 if( ! aPageSize.bFullPaper )
983 {
984 const MapMode aMapMode( MapUnit::Map100thMM );
985 Point aOff( aPrt->PixelToLogic( aPrt->GetPageOffsetPixel(), aMapMode ) );
986 aMtf.Move( aOff.X(), aOff.Y() );
987 }
988 // tdf#150561: page size may have changed so sync mePaper with it
989 mePaper = aPrt->GetPaper();
990 }
991
992 mxPreview->setPreview( aMtf, aCurPageSize,
994 nPages > 0 ? OUString() : maNoPageStr,
995 aPrt->GetDPIX(), aPrt->GetDPIY(),
996 aPrt->GetPrinterOptions().IsConvertToGreyscales()
997 );
998
999 mxForwardBtn->set_sensitive( mnCurPage < nPages-1 );
1000 mxBackwardBtn->set_sensitive( mnCurPage != 0 );
1001 mxFirstBtn->set_sensitive( mnCurPage != 0 );
1002 mxLastBtn->set_sensitive( mnCurPage < nPages-1 );
1003 mxPageEdit->set_sensitive( nPages > 1 );
1004}
1005
1006void PrintDialog::updateOrientationBox( const bool bAutomatic )
1007{
1008 if ( !bAutomatic )
1009 {
1010 Orientation eOrientation = maPController->getPrinter()->GetOrientation();
1011 mxOrientationBox->set_active( static_cast<sal_Int32>(eOrientation) + 1 );
1012 }
1013 else if ( hasOrientationChanged() )
1014 {
1016 }
1017}
1018
1020{
1021 const int nOrientation = mxOrientationBox->get_active();
1022 const Orientation eOrientation = maPController->getPrinter()->GetOrientation();
1023
1024 return (nOrientation == ORIENTATION_LANDSCAPE && eOrientation == Orientation::Portrait)
1025 || (nOrientation == ORIENTATION_PORTRAIT && eOrientation == Orientation::Landscape);
1026}
1027
1028// Always use this function to set paper orientation to make sure everything behaves well
1029void PrintDialog::setPaperOrientation( Orientation eOrientation, bool fromUser )
1030{
1031 VclPtr<Printer> aPrt( maPController->getPrinter() );
1032 aPrt->SetOrientation( eOrientation );
1033 maPController->setOrientationFromUser( eOrientation, fromUser );
1034}
1035
1037{
1038 if (mxCopyCountField->get_value() > 1)
1039 {
1040 mxCollateBox->set_sensitive( !mbCollateAlwaysOff );
1041 mxSingleJobsBox->set_sensitive( mxCollateBox->get_active() );
1042 }
1043 else
1044 {
1045 mxCollateBox->set_sensitive( false );
1046 mxSingleJobsBox->set_sensitive( false );
1047 }
1048
1049 OUString aImg(mxCollateBox->get_active() ? OUString(SV_PRINT_COLLATE_BMP) : OUString(SV_PRINT_NOCOLLATE_BMP));
1050
1051 mxCollateImage->set_from_icon_name(aImg);
1052
1053 // enable setup button only for printers that can be setup
1054 bool bHaveSetup = maPController->getPrinter()->HasSupport( PrinterSupport::SetupDialog );
1055 mxSetupButton->set_sensitive(bHaveSetup);
1056}
1057
1059{
1060 for( const auto& rEntry : maControlToPropertyMap )
1061 {
1062 bool bShouldbeEnabled = maPController->isUIOptionEnabled( rEntry.second );
1063
1064 if (bShouldbeEnabled && dynamic_cast<weld::RadioButton*>(rEntry.first))
1065 {
1066 auto r_it = maControlToNumValMap.find( rEntry.first );
1067 if( r_it != maControlToNumValMap.end() )
1068 {
1069 bShouldbeEnabled = maPController->isUIChoiceEnabled( rEntry.second, r_it->second );
1070 }
1071 }
1072
1073 bool bIsEnabled = rEntry.first->get_sensitive();
1074 // Enable does not do a change check first, so can be less cheap than expected
1075 if (bShouldbeEnabled != bIsEnabled)
1076 rEntry.first->set_sensitive( bShouldbeEnabled );
1077 }
1078}
1079
1081{
1082 mxNupOrderWin->show();
1083 mxPagesBtn->set_active(true);
1084 mxBrochureBtn->hide();
1085
1086 // setup field units for metric fields
1088 FieldUnit eUnit = FieldUnit::MM;
1089 sal_uInt16 nDigits = 0;
1090 if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
1091 {
1092 eUnit = FieldUnit::INCH;
1093 nDigits = 2;
1094 }
1095 // set units
1096 mxPageMarginEdt->set_unit( eUnit );
1097 mxSheetMarginEdt->set_unit( eUnit );
1098
1099 // set precision
1100 mxPageMarginEdt->set_digits( nDigits );
1101 mxSheetMarginEdt->set_digits( nDigits );
1102
1103 mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( i_rMPS.nLeftMargin ), FieldUnit::MM_100TH );
1104 mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( i_rMPS.nHorizontalSpacing ), FieldUnit::MM_100TH );
1105 mxBorderCB->set_active( i_rMPS.bDrawBorder );
1106 mxNupRowsEdt->set_value( i_rMPS.nRows );
1107 mxNupColEdt->set_value( i_rMPS.nColumns );
1108 mxNupOrderBox->set_active( static_cast<sal_Int32>(i_rMPS.nOrder) );
1109 if( i_rMPS.nRows != 1 || i_rMPS.nColumns != 1 )
1110 {
1111 mxNupPagesBox->set_active( mxNupPagesBox->get_count()-1 );
1112 showAdvancedControls( true );
1113 mxNupOrder->setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows );
1114 }
1115}
1116
1117void PrintDialog::updateNup( bool i_bMayUseCache )
1118{
1119 int nRows = mxNupRowsEdt->get_value();
1120 int nCols = mxNupColEdt->get_value();
1121 tools::Long nPageMargin = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
1122 tools::Long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));
1123
1125 aMPS.nRows = nRows;
1126 aMPS.nColumns = nCols;
1127 aMPS.nLeftMargin =
1128 aMPS.nTopMargin =
1129 aMPS.nRightMargin =
1130 aMPS.nBottomMargin = nSheetMargin;
1131
1132 aMPS.nHorizontalSpacing =
1133 aMPS.nVerticalSpacing = nPageMargin;
1134
1135 aMPS.bDrawBorder = mxBorderCB->get_active();
1136
1137 aMPS.nOrder = static_cast<NupOrderType>(mxNupOrderBox->get_active());
1138
1139 int nOrientationMode = mxOrientationBox->get_active();
1140 if( nOrientationMode == ORIENTATION_LANDSCAPE )
1142 else if( nOrientationMode == ORIENTATION_PORTRAIT )
1144 else // automatic mode
1145 {
1146 // get size of first real page to see if it is portrait or landscape
1147 // we assume same page sizes for all the pages for this
1148 Size aPageSize = getJobPageSize();
1149
1150 Size aMultiSize( aPageSize.Width() * nCols, aPageSize.Height() * nRows );
1151 if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape
1152 {
1155 }
1156 else
1157 {
1160 }
1161 }
1162
1163 maPController->setMultipage( aMPS );
1164
1165 mxNupOrder->setValues( aMPS.nOrder, nCols, nRows );
1166
1167 if (i_bMayUseCache)
1169 else
1171}
1172
1173void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
1174{
1175 int nPages = mxNupPagesBox->get_active_id().toInt32();
1176 int nRows = mxNupRowsEdt->get_value();
1177 int nCols = mxNupColEdt->get_value();
1178 tools::Long nPageMargin = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
1179 tools::Long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));
1180 bool bCustom = false;
1181
1182 if( nPages == 1 )
1183 {
1184 nRows = nCols = 1;
1185 nSheetMargin = 0;
1186 nPageMargin = 0;
1187 }
1188 else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 )
1189 {
1190 Size aJobPageSize( getJobPageSize() );
1191 bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height();
1192 if( nPages == 2 )
1193 {
1194 if( bPortrait )
1195 {
1196 nRows = 1;
1197 nCols = 2;
1198 }
1199 else
1200 {
1201 nRows = 2;
1202 nCols = 1;
1203 }
1204 }
1205 else if( nPages == 4 )
1206 nRows = nCols = 2;
1207 else if( nPages == 6 )
1208 {
1209 if( bPortrait )
1210 {
1211 nRows = 2;
1212 nCols = 3;
1213 }
1214 else
1215 {
1216 nRows = 3;
1217 nCols = 2;
1218 }
1219 }
1220 else if( nPages == 9 )
1221 nRows = nCols = 3;
1222 else if( nPages == 16 )
1223 nRows = nCols = 4;
1224 nPageMargin = 0;
1225 nSheetMargin = 0;
1226 }
1227 else
1228 bCustom = true;
1229
1230 if( nPages > 1 )
1231 {
1232 // set upper limits for margins based on job page size and rows/columns
1233 Size aSize( getJobPageSize() );
1234
1235 // maximum sheet distance: 1/2 sheet
1236 tools::Long nHorzMax = aSize.Width()/2;
1237 tools::Long nVertMax = aSize.Height()/2;
1238 if( nSheetMargin > nHorzMax )
1239 nSheetMargin = nHorzMax;
1240 if( nSheetMargin > nVertMax )
1241 nSheetMargin = nVertMax;
1242
1243 mxSheetMarginEdt->set_max(
1244 mxSheetMarginEdt->normalize(
1245 std::min(nHorzMax, nVertMax) ), FieldUnit::MM_100TH );
1246
1247 // maximum page distance
1248 nHorzMax = (aSize.Width() - 2*nSheetMargin);
1249 if( nCols > 1 )
1250 nHorzMax /= (nCols-1);
1251 nVertMax = (aSize.Height() - 2*nSheetMargin);
1252 if( nRows > 1 )
1253 nHorzMax /= (nRows-1);
1254
1255 if( nPageMargin > nHorzMax )
1256 nPageMargin = nHorzMax;
1257 if( nPageMargin > nVertMax )
1258 nPageMargin = nVertMax;
1259
1260 mxPageMarginEdt->set_max(
1261 mxSheetMarginEdt->normalize(
1262 std::min(nHorzMax, nVertMax ) ), FieldUnit::MM_100TH );
1263 }
1264
1265 mxNupRowsEdt->set_value( nRows );
1266 mxNupColEdt->set_value( nCols );
1267 mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( nPageMargin ), FieldUnit::MM_100TH );
1268 mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( nSheetMargin ), FieldUnit::MM_100TH );
1269
1270 showAdvancedControls( bCustom );
1271 updateNup( i_bMayUseCache );
1272}
1273
1275{
1276 mxNupPagesBox->set_sensitive( bEnable );
1277 mxNupNumPagesTxt->set_sensitive( bEnable );
1278 mxNupColEdt->set_sensitive( bEnable );
1279 mxNupTimesTxt->set_sensitive( bEnable );
1280 mxNupRowsEdt->set_sensitive( bEnable );
1281 mxPageMarginTxt1->set_sensitive( bEnable );
1282 mxPageMarginEdt->set_sensitive( bEnable );
1283 mxPageMarginTxt2->set_sensitive( bEnable );
1284 mxSheetMarginTxt1->set_sensitive( bEnable );
1285 mxSheetMarginEdt->set_sensitive( bEnable );
1286 mxSheetMarginTxt2->set_sensitive( bEnable );
1287 mxNupOrderTxt->set_sensitive( bEnable );
1288 mxNupOrderBox->set_sensitive( bEnable );
1289 mxNupOrderWin->set_sensitive( bEnable );
1290 mxBorderCB->set_sensitive( bEnable );
1291}
1292
1294{
1295 mxNupNumPagesTxt->set_visible( i_bShow );
1296 mxNupColEdt->set_visible( i_bShow );
1297 mxNupTimesTxt->set_visible( i_bShow );
1298 mxNupRowsEdt->set_visible( i_bShow );
1299 mxPageMarginTxt1->set_visible( i_bShow );
1300 mxPageMarginEdt->set_visible( i_bShow );
1301 mxPageMarginTxt2->set_visible( i_bShow );
1302 mxSheetMarginTxt1->set_visible( i_bShow );
1303 mxSheetMarginEdt->set_visible( i_bShow );
1304 mxSheetMarginTxt2->set_visible( i_bShow );
1305}
1306
1307namespace
1308{
1309 void setHelpId( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
1310 {
1311 if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() )
1312 i_pWindow->set_help_id( i_rHelpIds.getConstArray()[i_nIndex] );
1313 }
1314
1315 void setHelpText( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpTexts, sal_Int32 i_nIndex )
1316 {
1317 // without a help text set and the correct smartID,
1318 // help texts will be retrieved from the online help system
1319 if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() )
1320 i_pWindow->set_tooltip_text(i_rHelpTexts.getConstArray()[i_nIndex]);
1321 }
1322}
1323
1325{
1326 const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() );
1327 for( const auto& rOption : rOptions )
1328 {
1329 if (rOption.Name == "OptionsUIFile")
1330 {
1331 OUString sOptionsUIFile;
1332 rOption.Value >>= sOptionsUIFile;
1334 std::unique_ptr<weld::Container> xWindow = mxCustomOptionsUIBuilder->weld_container("box");
1335 xWindow->show();
1336 continue;
1337 }
1338
1340 rOption.Value >>= aOptProp;
1341
1342 // extract ui element
1343 OUString aCtrlType;
1344 OUString aID;
1345 OUString aText;
1346 OUString aPropertyName;
1347 Sequence< OUString > aChoices;
1348 Sequence< sal_Bool > aChoicesDisabled;
1349 Sequence< OUString > aHelpTexts;
1351 Sequence< OUString > aHelpIds;
1352 sal_Int64 nMinValue = 0, nMaxValue = 0;
1353 OUString aGroupingHint;
1354
1355 for( const beans::PropertyValue& rEntry : std::as_const(aOptProp) )
1356 {
1357 if ( rEntry.Name == "ID" )
1358 {
1359 rEntry.Value >>= aIDs;
1360 aID = aIDs[0];
1361 }
1362 if ( rEntry.Name == "Text" )
1363 {
1364 rEntry.Value >>= aText;
1365 }
1366 else if ( rEntry.Name == "ControlType" )
1367 {
1368 rEntry.Value >>= aCtrlType;
1369 }
1370 else if ( rEntry.Name == "Choices" )
1371 {
1372 rEntry.Value >>= aChoices;
1373 }
1374 else if ( rEntry.Name == "ChoicesDisabled" )
1375 {
1376 rEntry.Value >>= aChoicesDisabled;
1377 }
1378 else if ( rEntry.Name == "Property" )
1379 {
1380 PropertyValue aVal;
1381 rEntry.Value >>= aVal;
1382 aPropertyName = aVal.Name;
1383 }
1384 else if ( rEntry.Name == "Enabled" )
1385 {
1386 }
1387 else if ( rEntry.Name == "GroupingHint" )
1388 {
1389 rEntry.Value >>= aGroupingHint;
1390 }
1391 else if ( rEntry.Name == "DependsOnName" )
1392 {
1393 }
1394 else if ( rEntry.Name == "DependsOnEntry" )
1395 {
1396 }
1397 else if ( rEntry.Name == "AttachToDependency" )
1398 {
1399 }
1400 else if ( rEntry.Name == "MinValue" )
1401 {
1402 rEntry.Value >>= nMinValue;
1403 }
1404 else if ( rEntry.Name == "MaxValue" )
1405 {
1406 rEntry.Value >>= nMaxValue;
1407 }
1408 else if ( rEntry.Name == "HelpText" )
1409 {
1410 if( ! (rEntry.Value >>= aHelpTexts) )
1411 {
1412 OUString aHelpText;
1413 if( rEntry.Value >>= aHelpText )
1414 {
1415 aHelpTexts.realloc( 1 );
1416 *aHelpTexts.getArray() = aHelpText;
1417 }
1418 }
1419 }
1420 else if ( rEntry.Name == "HelpId" )
1421 {
1422 if( ! (rEntry.Value >>= aHelpIds ) )
1423 {
1424 OUString aHelpId;
1425 if( rEntry.Value >>= aHelpId )
1426 {
1427 aHelpIds.realloc( 1 );
1428 *aHelpIds.getArray() = aHelpId;
1429 }
1430 }
1431 }
1432 else if ( rEntry.Name == "HintNoLayoutPage" )
1433 {
1434 bool bHasLayoutFrame = false;
1435 rEntry.Value >>= bHasLayoutFrame;
1436 mbShowLayoutFrame = !bHasLayoutFrame;
1437 }
1438 }
1439
1440 if (aCtrlType == "Group")
1441 {
1442 aID = "custom";
1443
1444 weld::Container* pPage = mxTabCtrl->get_page(aID);
1445 if (!pPage)
1446 continue;
1447
1448 mxTabCtrl->set_tab_label_text(aID, aText);
1449
1450 // set help id
1451 if (aHelpIds.hasElements())
1452 pPage->set_help_id(aHelpIds[0]);
1453
1454 // set help text
1455 if (aHelpTexts.hasElements())
1456 pPage->set_tooltip_text(aHelpTexts[0]);
1457
1458 pPage->show();
1459 }
1460 else if (aCtrlType == "Subgroup" && !aID.isEmpty())
1461 {
1462 std::unique_ptr<weld::Widget> xWidget;
1463 // since 'New Print Dialog Design' fromwhich in calc is not a frame anymore
1464 if (aID == "fromwhich")
1465 {
1466 std::unique_ptr<weld::Label> xLabel = m_xBuilder->weld_label(aID);
1467 xLabel->set_label(aText);
1468 xWidget = std::move(xLabel);
1469 }
1470 else
1471 {
1472 std::unique_ptr<weld::Frame> xFrame = m_xBuilder->weld_frame(aID);
1474 xFrame = mxCustomOptionsUIBuilder->weld_frame(aID);
1475 if (xFrame)
1476 {
1477 xFrame->set_label(aText);
1478 xWidget = std::move(xFrame);
1479 }
1480 }
1481
1482 if (!xWidget)
1483 continue;
1484
1485 // set help id
1486 setHelpId(xWidget.get(), aHelpIds, 0);
1487 // set help text
1488 setHelpText(xWidget.get(), aHelpTexts, 0);
1489
1490 xWidget->show();
1491 }
1492 // EVIL
1493 else if( aCtrlType == "Bool" && aGroupingHint == "LayoutPage" && aPropertyName == "PrintProspect" )
1494 {
1495 mxBrochureBtn->set_label(aText);
1496 mxBrochureBtn->show();
1497
1498 bool bVal = false;
1499 PropertyValue* pVal = maPController->getValue( aPropertyName );
1500 if( pVal )
1501 pVal->Value >>= bVal;
1502 mxBrochureBtn->set_active( bVal );
1503 mxBrochureBtn->set_sensitive( maPController->isUIOptionEnabled( aPropertyName ) && pVal != nullptr );
1504
1505 maPropertyToWindowMap[aPropertyName].emplace_back(mxBrochureBtn.get());
1506 maControlToPropertyMap[mxBrochureBtn.get()] = aPropertyName;
1507
1508 // set help id
1509 setHelpId( mxBrochureBtn.get(), aHelpIds, 0 );
1510 // set help text
1511 setHelpText( mxBrochureBtn.get(), aHelpTexts, 0 );
1512 }
1513 else if (aCtrlType == "Bool")
1514 {
1515 // add a check box
1516 std::unique_ptr<weld::CheckButton> xNewBox = m_xBuilder->weld_check_button(aID);
1517 if (!xNewBox && mxCustomOptionsUIBuilder)
1518 xNewBox = mxCustomOptionsUIBuilder->weld_check_button(aID);
1519 if (!xNewBox)
1520 continue;
1521
1522 xNewBox->set_label( aText );
1523 xNewBox->show();
1524
1525 bool bVal = false;
1526 PropertyValue* pVal = maPController->getValue( aPropertyName );
1527 if( pVal )
1528 pVal->Value >>= bVal;
1529 xNewBox->set_active( bVal );
1530 xNewBox->connect_toggled( LINK( this, PrintDialog, UIOption_CheckHdl ) );
1531
1532 maExtraControls.emplace_back(std::move(xNewBox));
1533
1534 weld::Widget* pWidget = maExtraControls.back().get();
1535
1536 maPropertyToWindowMap[aPropertyName].emplace_back(pWidget);
1537 maControlToPropertyMap[pWidget] = aPropertyName;
1538
1539 // set help id
1540 setHelpId(pWidget, aHelpIds, 0);
1541 // set help text
1542 setHelpText(pWidget, aHelpTexts, 0);
1543 }
1544 else if (aCtrlType == "Radio")
1545 {
1546 sal_Int32 nCurHelpText = 0;
1547
1548 // iterate options
1549 sal_Int32 nSelectVal = 0;
1550 PropertyValue* pVal = maPController->getValue( aPropertyName );
1551 if( pVal && pVal->Value.hasValue() )
1552 pVal->Value >>= nSelectVal;
1553 for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
1554 {
1555 aID = aIDs[m];
1556 std::unique_ptr<weld::RadioButton> xBtn = m_xBuilder->weld_radio_button(aID);
1557 if (!xBtn && mxCustomOptionsUIBuilder)
1558 xBtn = mxCustomOptionsUIBuilder->weld_radio_button(aID);
1559 if (!xBtn)
1560 continue;
1561
1562 xBtn->set_label( aChoices[m] );
1563 xBtn->set_active( m == nSelectVal );
1564 xBtn->connect_toggled( LINK( this, PrintDialog, UIOption_RadioHdl ) );
1565 if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] )
1566 xBtn->set_sensitive( false );
1567 xBtn->show();
1568
1569 maExtraControls.emplace_back(std::move(xBtn));
1570
1571 weld::Widget* pWidget = maExtraControls.back().get();
1572
1573 maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1574 maControlToPropertyMap[pWidget] = aPropertyName;
1575 maControlToNumValMap[pWidget] = m;
1576
1577 // set help id
1578 setHelpId( pWidget, aHelpIds, nCurHelpText );
1579 // set help text
1580 setHelpText( pWidget, aHelpTexts, nCurHelpText );
1581 nCurHelpText++;
1582 }
1583 }
1584 else if ( aCtrlType == "List" )
1585 {
1586 std::unique_ptr<weld::ComboBox> xList = m_xBuilder->weld_combo_box(aID);
1587 if (!xList && mxCustomOptionsUIBuilder)
1588 xList = mxCustomOptionsUIBuilder->weld_combo_box(aID);
1589 if (!xList)
1590 continue;
1591
1592 // iterate options
1593 for( const auto& rChoice : std::as_const(aChoices) )
1594 xList->append_text(rChoice);
1595
1596 sal_Int32 nSelectVal = 0;
1597 PropertyValue* pVal = maPController->getValue( aPropertyName );
1598 if( pVal && pVal->Value.hasValue() )
1599 pVal->Value >>= nSelectVal;
1600 xList->set_active(nSelectVal);
1601 xList->connect_changed( LINK( this, PrintDialog, UIOption_SelectHdl ) );
1602 xList->show();
1603
1604 maExtraControls.emplace_back(std::move(xList));
1605
1606 weld::Widget* pWidget = maExtraControls.back().get();
1607
1608 maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1609 maControlToPropertyMap[pWidget] = aPropertyName;
1610
1611 // set help id
1612 setHelpId( pWidget, aHelpIds, 0 );
1613 // set help text
1614 setHelpText( pWidget, aHelpTexts, 0 );
1615 }
1616 else if ( aCtrlType == "Range" )
1617 {
1618 std::unique_ptr<weld::SpinButton> xField = m_xBuilder->weld_spin_button(aID);
1619 if (!xField && mxCustomOptionsUIBuilder)
1620 xField = mxCustomOptionsUIBuilder->weld_spin_button(aID);
1621 if (!xField)
1622 continue;
1623
1624 // set min/max and current value
1625 if(nMinValue != nMaxValue)
1626 xField->set_range(nMinValue, nMaxValue);
1627
1628 sal_Int64 nCurVal = 0;
1629 PropertyValue* pVal = maPController->getValue( aPropertyName );
1630 if( pVal && pVal->Value.hasValue() )
1631 pVal->Value >>= nCurVal;
1632 xField->set_value( nCurVal );
1633 xField->connect_value_changed( LINK( this, PrintDialog, UIOption_SpinModifyHdl ) );
1634 xField->show();
1635
1636 maExtraControls.emplace_back(std::move(xField));
1637
1638 weld::Widget* pWidget = maExtraControls.back().get();
1639
1640 maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1641 maControlToPropertyMap[pWidget] = aPropertyName;
1642
1643 // set help id
1644 setHelpId( pWidget, aHelpIds, 0 );
1645 // set help text
1646 setHelpText( pWidget, aHelpTexts, 0 );
1647 }
1648 else if (aCtrlType == "Edit")
1649 {
1650 std::unique_ptr<weld::Entry> xField = m_xBuilder->weld_entry(aID);
1651 if (!xField && mxCustomOptionsUIBuilder)
1652 xField = mxCustomOptionsUIBuilder->weld_entry(aID);
1653 if (!xField)
1654 continue;
1655
1656 OUString aCurVal;
1657 PropertyValue* pVal = maPController->getValue( aPropertyName );
1658 if( pVal && pVal->Value.hasValue() )
1659 pVal->Value >>= aCurVal;
1660 xField->set_text( aCurVal );
1661 xField->connect_changed( LINK( this, PrintDialog, UIOption_EntryModifyHdl ) );
1662 xField->show();
1663
1664 maExtraControls.emplace_back(std::move(xField));
1665
1666 weld::Widget* pWidget = maExtraControls.back().get();
1667
1668 maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1669 maControlToPropertyMap[pWidget] = aPropertyName;
1670
1671 // set help id
1672 setHelpId( pWidget, aHelpIds, 0 );
1673 // set help text
1674 setHelpText( pWidget, aHelpTexts, 0 );
1675 }
1676 else
1677 {
1678 SAL_WARN( "vcl", "Unsupported UI option: \"" << aCtrlType << '"');
1679 }
1680 }
1681
1682 // #i106506# if no brochure button, then the singular Pages radio button
1683 // makes no sense, so replace it by a FixedText label
1684 if (!mxBrochureBtn->get_visible() && mxPagesBtn->get_visible())
1685 {
1686 mxPagesBoxTitleTxt->set_label(mxPagesBtn->get_label());
1687 mxPagesBoxTitleTxt->show();
1688 mxPagesBtn->hide();
1689
1690 mxNupPagesBox->set_accessible_relation_labeled_by(mxPagesBoxTitleTxt.get());
1691 }
1692
1693 // update enable states
1695
1696 // print range not shown (currently math only) -> hide spacer line and reverse order
1697 if (!mxPageRangeEdit->get_visible())
1698 {
1699 mxReverseOrderBox->hide();
1700 }
1701
1703 mxTabCtrl->remove_page(mxTabCtrl->get_page_ident(1));
1704}
1705
1707{
1708 auto it = maControlToPropertyMap.find( i_pWindow );
1709 if( it != maControlToPropertyMap.end() )
1710 {
1711 OUString aDependency( maPController->makeEnabled( it->second ) );
1712 if( !aDependency.isEmpty() )
1713 updateWindowFromProperty( aDependency );
1714 }
1715}
1716
1717void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
1718{
1719 beans::PropertyValue* pValue = maPController->getValue( i_rProperty );
1720 auto it = maPropertyToWindowMap.find( i_rProperty );
1721 if( !(pValue && it != maPropertyToWindowMap.end()) )
1722 return;
1723
1724 const auto& rWindows( it->second );
1725 if( rWindows.empty() )
1726 return;
1727
1728 bool bVal = false;
1729 sal_Int32 nVal = -1;
1730 if( pValue->Value >>= bVal )
1731 {
1732 // we should have a CheckBox for this one
1733 weld::CheckButton* pBox = dynamic_cast<weld::CheckButton*>(rWindows.front());
1734 if( pBox )
1735 {
1736 pBox->set_active( bVal );
1737 }
1738 else if ( i_rProperty == "PrintProspect" )
1739 {
1740 // EVIL special case
1741 if( bVal )
1742 mxBrochureBtn->set_active(true);
1743 else
1744 mxPagesBtn->set_active(true);
1745 }
1746 else
1747 {
1748 SAL_WARN( "vcl", "missing a checkbox" );
1749 }
1750 }
1751 else if( pValue->Value >>= nVal )
1752 {
1753 // this could be a ListBox or a RadioButtonGroup
1754 weld::ComboBox* pList = dynamic_cast<weld::ComboBox*>(rWindows.front());
1755 if( pList )
1756 {
1757 pList->set_active( static_cast< sal_uInt16 >(nVal) );
1758 }
1759 else if( nVal >= 0 && o3tl::make_unsigned(nVal) < rWindows.size() )
1760 {
1761 weld::RadioButton* pBtn = dynamic_cast<weld::RadioButton*>(rWindows[nVal]);
1762 SAL_WARN_IF( !pBtn, "vcl", "unexpected control for property" );
1763 if( pBtn )
1764 pBtn->set_active(true);
1765 }
1766 }
1767}
1768
1770{
1771 return ( mxPrinters->get_active() == 0 );
1772}
1773
1775{
1776 return mxCopyCountField->get_value() > 1 && mxCollateBox->get_active();
1777}
1778
1780{
1781 return mxSingleJobsBox->get_active();
1782}
1783
1785{
1786 return mxPreviewBox->get_active();
1787}
1788
1789PropertyValue* PrintDialog::getValueForWindow( weld::Widget* i_pWindow ) const
1790{
1791 PropertyValue* pVal = nullptr;
1792 auto it = maControlToPropertyMap.find( i_pWindow );
1793 if( it != maControlToPropertyMap.end() )
1794 {
1795 pVal = maPController->getValue( it->second );
1796 SAL_WARN_IF( !pVal, "vcl", "property value not found" );
1797 }
1798 else
1799 {
1800 OSL_FAIL( "changed control not in property map" );
1801 }
1802 return pVal;
1803}
1804
1805IMPL_LINK(PrintDialog, ToggleHdl, weld::Toggleable&, rButton, void)
1806{
1807 if (&rButton == mxPreviewBox.get())
1808 {
1809 maUpdatePreviewIdle.Start();
1810 }
1811 else if( &rButton == mxBorderCB.get() )
1812 {
1813 updateNup();
1814 }
1815 else if (&rButton == mxSingleJobsBox.get())
1816 {
1817 maPController->setValue( "SinglePrintJobs",
1818 Any( isSingleJobs() ) );
1819 checkControlDependencies();
1820 }
1821 else if( &rButton == mxCollateBox.get() )
1822 {
1823 maPController->setValue( "Collate",
1824 Any( isCollate() ) );
1825 checkControlDependencies();
1826 }
1827 else if( &rButton == mxReverseOrderBox.get() )
1828 {
1829 bool bChecked = mxReverseOrderBox->get_active();
1830 maPController->setReversePrint( bChecked );
1831 maPController->setValue( "PrintReverse",
1832 Any( bChecked ) );
1833 maUpdatePreviewIdle.Start();
1834 }
1835 else if (&rButton == mxBrochureBtn.get())
1836 {
1837 PropertyValue* pVal = getValueForWindow(mxBrochureBtn.get());
1838 if( pVal )
1839 {
1840 bool bVal = mxBrochureBtn->get_active();
1841 pVal->Value <<= bVal;
1842
1843 checkOptionalControlDependencies();
1844
1845 // update preview and page settings
1846 maUpdatePreviewNoCacheIdle.Start();
1847 }
1848 if (mxBrochureBtn->get_active())
1849 {
1850 mxOrientationBox->set_sensitive( false );
1851 mxOrientationBox->set_active( ORIENTATION_LANDSCAPE );
1852 mxNupPagesBox->set_active( 0 );
1853 updateNupFromPages();
1854 showAdvancedControls( false );
1855 enableNupControls( false );
1856 }
1857 else
1858 {
1859 mxOrientationBox->set_sensitive( true );
1860 mxOrientationBox->set_active( ORIENTATION_AUTOMATIC );
1861 enableNupControls( true );
1862 updateNupFromPages();
1863 }
1864
1865 }
1866}
1867
1868IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
1869{
1870 if (&rButton == mxOKButton.get() || &rButton == mxCancelButton.get())
1871 {
1872 storeToSettings();
1873 m_xDialog->response(&rButton == mxOKButton.get() ? RET_OK : RET_CANCEL);
1874 }
1875 else if( &rButton == mxHelpButton.get() )
1876 {
1877 // start help system
1878 Help* pHelp = Application::GetHelp();
1879 if( pHelp )
1880 {
1881 pHelp->Start("vcl/ui/printdialog/PrintDialog", mxOKButton.get());
1882 }
1883 }
1884 else if( &rButton == mxForwardBtn.get() )
1885 {
1886 previewForward();
1887 }
1888 else if( &rButton == mxBackwardBtn.get() )
1889 {
1890 previewBackward();
1891 }
1892 else if( &rButton == mxFirstBtn.get() )
1893 {
1894 previewFirst();
1895 }
1896 else if( &rButton == mxLastBtn.get() )
1897 {
1898 previewLast();
1899 }
1900 else
1901 {
1902 if( &rButton == mxSetupButton.get() )
1903 {
1904 maPController->setupPrinter(m_xDialog.get());
1905
1906 if ( !isPrintToFile() )
1907 {
1908 VclPtr<Printer> aPrt( maPController->getPrinter() );
1909 mePaper = aPrt->GetPaper();
1910
1911 for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++ )
1912 {
1913 PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
1914 aInfo.doSloppyFit(true);
1915 Paper ePaper = aInfo.getPaper();
1916
1917 if ( mePaper == ePaper )
1918 {
1919 mxPaperSizeBox->set_active( nPaper );
1920 break;
1921 }
1922 }
1923 }
1924
1925 updateOrientationBox( false );
1926 setupPaperSidesBox();
1927
1928 // tdf#63905 don't use cache: page size may change
1929 maUpdatePreviewNoCacheIdle.Start();
1930 }
1931 checkControlDependencies();
1932 }
1933
1934}
1935
1936IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
1937{
1938 if (&rBox == mxPrinters.get())
1939 {
1940 if ( !isPrintToFile() )
1941 {
1942 OUString aNewPrinter(rBox.get_active_text());
1943 // set new printer
1944 maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
1945 maPController->resetPrinterOptions( false );
1946
1947 updateOrientationBox();
1948
1949 // update text fields
1950 mxOKButton->set_label(maPrintText);
1951 updatePrinterText();
1952 setPaperSizes();
1953 maUpdatePreviewIdle.Start();
1954 }
1955 else // print to file
1956 {
1957 // use the default printer or FIXME: the last used one?
1958 maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
1959 mxOKButton->set_label(maPrintToFileText);
1960 maPController->resetPrinterOptions( true );
1961
1962 setPaperSizes();
1963 updateOrientationBox();
1964 maUpdatePreviewIdle.Start();
1965 }
1966
1967 setupPaperSidesBox();
1968 }
1969 else if ( &rBox == mxPaperSidesBox.get() )
1970 {
1971 DuplexMode eDuplex = static_cast<DuplexMode>(mxPaperSidesBox->get_active() + 1);
1972 maPController->getPrinter()->SetDuplexMode( eDuplex );
1973 }
1974 else if( &rBox == mxOrientationBox.get() )
1975 {
1976 int nOrientation = mxOrientationBox->get_active();
1977 if ( nOrientation != ORIENTATION_AUTOMATIC )
1978 setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ), true );
1979
1980 updateNup( false );
1981 }
1982 else if ( &rBox == mxNupOrderBox.get() )
1983 {
1984 updateNup();
1985 }
1986 else if( &rBox == mxNupPagesBox.get() )
1987 {
1988 if( !mxPagesBtn->get_active() )
1989 mxPagesBtn->set_active(true);
1990 updateNupFromPages( false );
1991 }
1992 else if ( &rBox == mxPaperSizeBox.get() )
1993 {
1994 VclPtr<Printer> aPrt( maPController->getPrinter() );
1995 PaperInfo aInfo = aPrt->GetPaperInfo( rBox.get_active() );
1996 aInfo.doSloppyFit(true);
1997 mePaper = aInfo.getPaper();
1998
1999 if ( mePaper == PAPER_USER )
2000 aPrt->SetPaperSizeUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
2001 else
2002 aPrt->SetPaper( mePaper );
2003
2004 maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
2005
2006 maUpdatePreviewIdle.Start();
2007 }
2008}
2009
2011{
2012 checkControlDependencies();
2013 updateNupFromPages();
2014}
2015
2017{
2018 ActivateHdl(*mxPageEdit);
2019}
2020
2022{
2023 sal_Int32 nPage = mxPageEdit->get_text().toInt32();
2024 if (nPage < 1)
2025 {
2026 nPage = 1;
2027 mxPageEdit->set_text("1");
2028 }
2029 else if (nPage > mnCachedPages)
2030 {
2031 nPage = mnCachedPages;
2032 mxPageEdit->set_text(OUString::number(mnCachedPages));
2033 }
2034 int nNewCurPage = nPage - 1;
2035 if (nNewCurPage != mnCurPage)
2036 {
2037 mnCurPage = nNewCurPage;
2038 maUpdatePreviewIdle.Start();
2039 }
2040 return true;
2041}
2042
2043IMPL_LINK( PrintDialog, SpinModifyHdl, weld::SpinButton&, rEdit, void )
2044{
2045 checkControlDependencies();
2046 if (&rEdit == mxNupRowsEdt.get() || &rEdit == mxNupColEdt.get())
2047 {
2048 updateNupFromPages();
2049 }
2050 else if( &rEdit == mxCopyCountField.get() )
2051 {
2052 maPController->setValue( "CopyCount",
2053 Any( sal_Int32(mxCopyCountField->get_value()) ) );
2054 maPController->setValue( "Collate",
2055 Any( isCollate() ) );
2056 }
2057}
2058
2059IMPL_LINK( PrintDialog, UIOption_CheckHdl, weld::Toggleable&, i_rBox, void )
2060{
2061 PropertyValue* pVal = getValueForWindow( &i_rBox );
2062 if( pVal )
2063 {
2064 makeEnabled( &i_rBox );
2065
2066 bool bVal = i_rBox.get_active();
2067 pVal->Value <<= bVal;
2068
2069 checkOptionalControlDependencies();
2070
2071 // update preview and page settings
2072 maUpdatePreviewNoCacheIdle.Start();
2073 }
2074}
2075
2076IMPL_LINK( PrintDialog, UIOption_RadioHdl, weld::Toggleable&, i_rBtn, void )
2077{
2078 // this handler gets called for all radiobuttons that get unchecked, too
2079 // however we only want one notification for the new value (that is for
2080 // the button that gets checked)
2081 if( !i_rBtn.get_active() )
2082 return;
2083
2084 PropertyValue* pVal = getValueForWindow( &i_rBtn );
2085 auto it = maControlToNumValMap.find( &i_rBtn );
2086 if( !(pVal && it != maControlToNumValMap.end()) )
2087 return;
2088
2089 makeEnabled( &i_rBtn );
2090
2091 sal_Int32 nVal = it->second;
2092 pVal->Value <<= nVal;
2093
2094 updateOrientationBox();
2095
2096 checkOptionalControlDependencies();
2097
2098 // tdf#41205 give focus to the page range edit if the corresponding radio button was selected
2099 if (pVal->Name == "PrintContent" && mxPageRangesRadioButton->get_active())
2100 mxPageRangeEdit->grab_focus();
2101
2102 // update preview and page settings
2103 maUpdatePreviewNoCacheIdle.Start();
2104}
2105
2106IMPL_LINK( PrintDialog, UIOption_SelectHdl, weld::ComboBox&, i_rBox, void )
2107{
2108 PropertyValue* pVal = getValueForWindow( &i_rBox );
2109 if( !pVal )
2110 return;
2111
2112 makeEnabled( &i_rBox );
2113
2114 sal_Int32 nVal( i_rBox.get_active() );
2115 pVal->Value <<= nVal;
2116
2117 //If we are in impress we start in print slides mode and get a
2118 //maFirstPageSize for slides which are usually landscape mode, if we
2119 //change to notes which are usually in portrait mode, and then visit
2120 //n-up print, we will assume notes are in landscape unless we throw
2121 //away maFirstPageSize when we change page content type
2122 if (pVal->Name == "PageContentType")
2123 maFirstPageSize = Size();
2124
2125 checkOptionalControlDependencies();
2126
2127 // update preview and page settings
2128 maUpdatePreviewNoCacheIdle.Start();
2129}
2130
2131IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void )
2132{
2133 PropertyValue* pVal = getValueForWindow( &i_rBox );
2134 if( pVal )
2135 {
2136 makeEnabled( &i_rBox );
2137
2138 sal_Int64 nVal = i_rBox.get_value();
2139 pVal->Value <<= nVal;
2140
2141 checkOptionalControlDependencies();
2142
2143 // update preview and page settings
2144 maUpdatePreviewNoCacheIdle.Start();
2145 }
2146}
2147
2148IMPL_LINK( PrintDialog, UIOption_EntryModifyHdl, weld::Entry&, i_rBox, void )
2149{
2150 PropertyValue* pVal = getValueForWindow( &i_rBox );
2151 if( pVal )
2152 {
2153 makeEnabled( &i_rBox );
2154
2155 OUString aVal( i_rBox.get_text() );
2156 pVal->Value <<= aVal;
2157
2158 checkOptionalControlDependencies();
2159
2160 // update preview and page settings
2161 maUpdatePreviewNoCacheIdle.Start();
2162 }
2163}
2164
2166{
2167 sal_Int32 nValue = mxPageEdit->get_text().toInt32() + 1;
2168 if (nValue <= mnCachedPages)
2169 {
2170 mxPageEdit->set_text(OUString::number(nValue));
2171 ActivateHdl(*mxPageEdit);
2172 }
2173}
2174
2176{
2177 sal_Int32 nValue = mxPageEdit->get_text().toInt32() - 1;
2178 if (nValue >= 1)
2179 {
2180 mxPageEdit->set_text(OUString::number(nValue));
2181 ActivateHdl(*mxPageEdit);
2182 }
2183}
2184
2186{
2187 mxPageEdit->set_text("1");
2188 ActivateHdl(*mxPageEdit);
2189}
2190
2192{
2193 mxPageEdit->set_text(OUString::number(mnCachedPages));
2194 ActivateHdl(*mxPageEdit);
2195}
2196
2197
2198static OUString getNewLabel(const OUString& aLabel, int i_nCurr, int i_nMax)
2199{
2200 OUString aNewText( aLabel.replaceFirst( "%p", OUString::number( i_nCurr ) ) );
2201 aNewText = aNewText.replaceFirst( "%n", OUString::number( i_nMax ) );
2202
2203 return aNewText;
2204}
2205
2206// PrintProgressDialog
2208 : GenericDialogController(i_pParent, "vcl/ui/printprogressdialog.ui", "PrintProgressDialog")
2209 , mbCanceled(false)
2210 , mnCur(0)
2211 , mnMax(i_nMax)
2212 , mxText(m_xBuilder->weld_label("label"))
2213 , mxProgress(m_xBuilder->weld_progress_bar("progressbar"))
2214 , mxButton(m_xBuilder->weld_button("cancel"))
2215{
2216 if( mnMax < 1 )
2217 mnMax = 1;
2218
2219 maStr = mxText->get_label();
2220
2221 //just multiply largest value by 10 and take the width of that string as
2222 //the max size we will want
2223 mxText->set_label(getNewLabel(maStr, mnMax * 10, mnMax * 10));
2224 mxText->set_size_request(mxText->get_preferred_size().Width(), -1);
2225
2226 //Pick a useful max width
2227 mxProgress->set_size_request(mxProgress->get_approximate_digit_width() * 25, -1);
2228
2229 mxButton->connect_clicked( LINK( this, PrintProgressDialog, ClickHdl ) );
2230
2231 // after this patch f7157f04fab298423e2c4f6a7e5f8e361164b15f, we have seen the calc Max string (sometimes) look above
2232 // now init to the right start values
2233 mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
2234}
2235
2237{
2238}
2239
2241{
2242 mbCanceled = true;
2243}
2244
2246{
2247 mnCur = i_nCurrent;
2248
2249 if( mnMax < 1 )
2250 mnMax = 1;
2251
2252 mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
2253
2254 // here view the dialog, with the right label
2255 mxProgress->set_percentage(mnCur*100/mnMax);
2256}
2257
2259{
2260 if( mnCur < mnMax )
2261 setProgress( ++mnCur );
2262}
2263
2264/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
OUString aPageText
const StyleSettings & GetStyleSettings() const
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:237
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1043
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:638
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
Definition: builder.cxx:186
static Help * GetHelp()
Gets the application's help.
Definition: svapp.cxx:1352
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: BitmapEx.cxx:305
CommandEventId GetCommand() const
const CommandWheelData * GetWheelData() const
tools::Long GetDelta() const
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
Definition: decoview.cxx:811
void DrawSeparator(const Point &rStart, const Point &rStop, bool bVertical=true)
Definition: decoview.cxx:965
void Move(tools::Long nX, tools::Long nY)
Definition: gdimtf.cxx:653
void WindStart()
Definition: gdimtf.cxx:572
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:748
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:325
Definition: help.hxx:61
virtual bool Start(const OUString &rHelpId, weld::Widget *pWidget=nullptr)
Definition: help.cxx:58
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
Definition: idle.cxx:34
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
MeasurementSystem getMeasurementSystemEnum() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
Get the output device's DPI x-axis value.
Definition: outdev.hxx:385
const vcl::Font & GetFont() const
Definition: outdev.hxx:529
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
Definition: bitmapex.cxx:33
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:56
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
Get the output device's DPI y-axis value.
Definition: outdev.hxx:391
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1110
void SetMapMode()
Definition: map.cxx:597
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:886
void SetTextColor(const Color &rColor)
Definition: text.cxx:716
void Erase()
Definition: wallpaper.cxx:96
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:897
void SetBackground()
Definition: background.cxx:27
void Pop()
Definition: stack.cxx:91
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:797
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
bool sloppyEqual(const PaperInfo &rOther) const
tools::Long getWidth() const
Paper getPaper() const
void doSloppyFit(bool bAlsoTryRotated=false)
tools::Long getHeight() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
static OUString GetDefaultPrinterName()
Definition: print.cxx:426
bool SetOrientation(Orientation eOrient)
Definition: print.cxx:1110
const Point & GetPageOffsetPixel() const
Definition: print.hxx:252
void SetPaper(Paper ePaper)
Definition: print.cxx:1264
Size GetPaperSize() const
Definition: print.hxx:250
static void updatePrinters()
Checks the printer list and updates it necessary.
Definition: print.cxx:1570
int GetPaperInfoCount() const
Definition: print.cxx:1362
static const std::vector< OUString > & GetPrinterQueues()
Definition: print.cxx:387
static OUString GetPaperName(Paper ePaper)
Definition: print.cxx:1371
bool SetPaperSizeUser(const Size &rSize)
Definition: print.cxx:1303
static const QueueInfo * GetQueueInfo(const OUString &rPrinterName, bool bStatusUpdate)
Definition: print.cxx:396
Size GetSizeOfPaper() const
Definition: print.cxx:1460
const PaperInfo & GetPaperInfo(int nPaper) const
Definition: print.cxx:1402
const Size & GetPaperSizePixel() const
Definition: print.hxx:249
const vcl::printer::Options & GetPrinterOptions() const
Definition: print.hxx:221
Paper GetPaper() const
Definition: print.cxx:1455
const OUString & GetPrinterName() const
Definition: QueueInfo.cxx:28
bool IsEmpty() const
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
constexpr tools::Long getWidth() const
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const Color & GetFieldTextColor() const
const vcl::Font & GetFieldFont() const
const vcl::Font & GetLabelFont() const
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:606
Definition: timer.hxx:27
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:277
static std::shared_ptr< ConfigurationChanges > create()
void SetFontSize(const Size &)
Definition: font/font.cxx:149
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:197
virtual ~PrintPreviewWindow() override
Definition: printdlg.cxx:80
virtual void Resize() override
Definition: printdlg.cxx:84
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: printdlg.cxx:121
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:210
virtual bool Command(const CommandEvent &) override
Definition: printdlg.cxx:196
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: printdlg.cxx:455
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:447
std::unique_ptr< weld::Image > mxCollateImage
Definition: printdlg.hxx:125
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
Definition: printdlg.hxx:129
void updateOrientationBox(bool bAutomatic=true)
Definition: printdlg.cxx:1006
std::unique_ptr< weld::Label > mxNupNumPagesTxt
Definition: printdlg.hxx:153
std::unique_ptr< weld::Frame > mxPageLayoutFrame
Definition: printdlg.hxx:118
void setupPaperSidesBox()
Definition: printdlg.cxx:738
std::unique_ptr< weld::Label > mxNupOrderTxt
Definition: printdlg.hxx:167
bool hasPreview() const
Definition: printdlg.cxx:1784
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
Definition: printdlg.hxx:158
bool mbCollateAlwaysOff
Definition: printdlg.hxx:187
OUString maDefPrtText
Definition: printdlg.hxx:179
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Definition: printdlg.hxx:190
Idle maUpdatePreviewNoCacheIdle
Definition: printdlg.hxx:210
void updateWindowFromProperty(const OUString &)
Definition: printdlg.cxx:1717
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
Definition: printdlg.hxx:127
std::unique_ptr< weld::Entry > mxPageEdit
Definition: printdlg.hxx:145
bool isSingleJobs() const
Definition: printdlg.cxx:1779
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
Definition: printdlg.hxx:170
void enableNupControls(bool bEnable)
Definition: printdlg.cxx:1274
PrintDialog(weld::Window *, std::shared_ptr< PrinterController >)
Definition: printdlg.cxx:527
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
Definition: printdlg.hxx:161
void showAdvancedControls(bool)
Definition: printdlg.cxx:1293
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
Definition: printdlg.hxx:202
std::unique_ptr< weld::ComboBox > mxPrinters
Definition: printdlg.hxx:119
std::unique_ptr< weld::Notebook > mxTabCtrl
Definition: printdlg.hxx:116
bool hasOrientationChanged() const
Definition: printdlg.cxx:1019
std::unique_ptr< weld::ComboBox > mxNupPagesBox
Definition: printdlg.hxx:150
std::shared_ptr< PrinterController > maPController
Definition: printdlg.hxx:114
void updateNup(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1117
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
Definition: printdlg.hxx:172
std::unique_ptr< weld::Label > mxPageMarginTxt1
Definition: printdlg.hxx:157
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
Definition: printdlg.hxx:149
std::unique_ptr< weld::SpinButton > mxNupColEdt
Definition: printdlg.hxx:154
std::unique_ptr< weld::Button > mxBackwardBtn
Definition: printdlg.hxx:136
sal_Int32 mnCurPage
Definition: printdlg.hxx:184
virtual ~PrintDialog() override
Definition: printdlg.cxx:730
std::map< weld::Widget *, OUString > maControlToPropertyMap
Definition: printdlg.hxx:193
void makeEnabled(weld::Widget *)
Definition: printdlg.cxx:1706
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
Definition: printdlg.hxx:195
std::unique_ptr< weld::ComboBox > mxNupOrderBox
Definition: printdlg.hxx:168
std::unique_ptr< weld::ComboBox > mxOrientationBox
Definition: printdlg.hxx:164
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
Definition: printdlg.hxx:156
std::unique_ptr< weld::Button > mxHelpButton
Definition: printdlg.hxx:134
std::unique_ptr< weld::CheckButton > mxCollateBox
Definition: printdlg.hxx:124
Idle maUpdatePreviewIdle
Definition: printdlg.hxx:208
void previewBackward()
Definition: printdlg.cxx:2175
std::unique_ptr< weld::Button > mxSetupButton
Definition: printdlg.hxx:121
std::unique_ptr< weld::Button > mxFirstBtn
Definition: printdlg.hxx:138
OUString maPrintText
Definition: printdlg.hxx:178
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
Definition: printdlg.hxx:130
std::unique_ptr< weld::Label > mxSheetMarginTxt1
Definition: printdlg.hxx:160
std::unique_ptr< weld::Button > mxLastBtn
Definition: printdlg.hxx:139
std::unique_ptr< weld::SpinButton > mxCopyCountField
Definition: printdlg.hxx:123
std::unique_ptr< weld::Label > mxSheetMarginTxt2
Definition: printdlg.hxx:162
void setPreviewText()
Definition: printdlg.cxx:922
void setPaperOrientation(Orientation eOrientation, bool fromUser)
Definition: printdlg.cxx:1029
OUString maNoPageStr
Definition: printdlg.hxx:182
void previewForward()
Definition: printdlg.cxx:2165
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
Definition: printdlg.hxx:128
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
Definition: printdlg.hxx:112
void setupOptionalUI()
Definition: printdlg.cxx:1324
sal_Int32 mnCachedPages
Definition: printdlg.hxx:185
std::unique_ptr< weld::RadioButton > mxPagesBtn
Definition: printdlg.hxx:147
bool isPrintToFile() const
Definition: printdlg.cxx:1769
std::unique_ptr< weld::Label > mxNupTimesTxt
Definition: printdlg.hxx:155
std::unique_ptr< weld::RadioButton > mxBrochureBtn
Definition: printdlg.hxx:148
std::unique_ptr< weld::Label > mxStatusTxt
Definition: printdlg.hxx:120
OUString maPrintToFileText
Definition: printdlg.hxx:177
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
Definition: printdlg.hxx:197
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
Definition: printdlg.hxx:169
bool isCollate() const
Definition: printdlg.cxx:1774
std::unique_ptr< weld::ScrolledWindow > mxScrolledWindow
Definition: printdlg.hxx:117
std::unique_ptr< weld::Expander > mxRangeExpander
Definition: printdlg.hxx:173
void checkControlDependencies()
Definition: printdlg.cxx:1036
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
Definition: printdlg.hxx:163
void preparePreview(bool i_bMayUseCache)
Definition: printdlg.cxx:938
OUString maPageStr
Definition: printdlg.hxx:181
Size maNupLandscapeSize
Definition: printdlg.hxx:200
void storeToSettings()
Definition: printdlg.cxx:754
std::unique_ptr< PrintPreviewWindow > mxPreview
Definition: printdlg.hxx:143
Size maNupPortraitSize
Definition: printdlg.hxx:199
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
Definition: printdlg.cxx:1080
std::unique_ptr< weld::Expander > mxLayoutExpander
Definition: printdlg.hxx:174
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
Definition: printdlg.cxx:1789
std::unique_ptr< weld::Label > mxPageMarginTxt2
Definition: printdlg.hxx:159
std::unique_ptr< weld::Entry > mxPageRangeEdit
Definition: printdlg.hxx:126
std::unique_ptr< weld::Widget > mxCustom
Definition: printdlg.hxx:175
void updateNupFromPages(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1173
void readFromSettings()
Definition: printdlg.cxx:793
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
Definition: printdlg.hxx:144
void checkOptionalControlDependencies()
Definition: printdlg.cxx:1058
std::unique_ptr< weld::Button > mxForwardBtn
Definition: printdlg.hxx:137
void updatePrinterText()
Definition: printdlg.cxx:904
void setPaperSizes()
Definition: printdlg.cxx:849
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:133
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:132
Size const & getJobPageSize()
Definition: printdlg.cxx:512
OUString maNoPreviewStr
Definition: printdlg.hxx:183
std::unique_ptr< weld::Label > mxNumPagesText
Definition: printdlg.hxx:142
std::unique_ptr< weld::CheckButton > mxPreviewBox
Definition: printdlg.hxx:141
bool mbShowLayoutFrame
Definition: printdlg.hxx:204
void setProgress(int i_nCurrent)
Definition: printdlg.cxx:2245
std::unique_ptr< weld::Button > mxButton
Definition: printdlg.hxx:261
std::unique_ptr< weld::Label > mxText
Definition: printdlg.hxx:259
std::unique_ptr< weld::ProgressBar > mxProgress
Definition: printdlg.hxx:260
virtual ~PrintProgressDialog() override
Definition: printdlg.cxx:2236
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
Definition: printdlg.cxx:2207
OUString getValue(const OUString &rGroup, const OUString &rKey) const
static SettingsConfigItem * get()
void setValue(const OUString &rGroup, const OUString &rKey, const OUString &rValue)
A widget used to choose from a list of items.
Definition: weld.hxx:713
virtual void set_active(int pos)=0
std::shared_ptr< weld::Dialog > m_xDialog
Definition: weld.hxx:2674
GenericDialogController(weld::Widget *pParent, const OUString &rUIFile, const OUString &rDialogId, bool bMobile=false)
Definition: weldutils.cxx:51
std::unique_ptr< weld::Builder > m_xBuilder
Definition: weld.hxx:2673
virtual void set_active(bool active)=0
virtual void show()=0
virtual void set_help_id(const OUString &rName)=0
virtual void set_tooltip_text(const OUString &rTip)=0
virtual void set_size_request(int nWidth, int nHeight)=0
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
int nCount
FieldUnit
sal_Int16 nValue
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
aBuf
B2IRange fround(const B2DRange &rRange)
int i
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
m
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
long Long
sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
NupOrderType
Definition: print.hxx:312
IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel *, CurHyperLabel, void)
Definition: roadmap.cxx:634
IMPL_LINK_NOARG(QuickSelectionEngine_Data, SearchStringTimeout, Timer *, void)
void SetPointFont(OutputDevice &rDevice, const vcl::Font &rFont)
Definition: weldutils.cxx:620
Reference< text::XText > mxText
Paper
PAPER_USER
static OUString getNewLabel(const OUString &aLabel, int i_nCurr, int i_nMax)
Definition: printdlg.cxx:2198
@ ORIENTATION_AUTOMATIC
Definition: printdlg.cxx:59
@ ORIENTATION_PORTRAIT
Definition: printdlg.cxx:60
@ ORIENTATION_LANDSCAPE
Definition: printdlg.cxx:61
DuplexMode
Definition: prntypes.hxx:28
Orientation
Definition: prntypes.hxx:31
bool bFullPaper
Full paper, not only imageable area is printed.
Definition: print.hxx:353
Reference< XFrame > xFrame
OUString VclResId(TranslateId aId)
Definition: svdata.cxx:261
@ POST_PAINT
Everything running directly after painting.
bool bIsEnabled
OUString aLabel
@ RET_OK
Definition: vclenum.hxx:206
@ RET_CANCEL
Definition: vclenum.hxx:205