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