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