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