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