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