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