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