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