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