LibreOffice Module vcl (master)  1
printdlg.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <printdlg.hxx>
21 #include <svdata.hxx>
22 #include <strings.hrc>
23 #include <bitmaps.hlst>
24 
25 #include <vcl/QueueInfo.hxx>
26 #include <vcl/commandevent.hxx>
27 #include <vcl/naturalsort.hxx>
28 #include <vcl/print.hxx>
29 #include <vcl/wall.hxx>
30 #include <vcl/decoview.hxx>
31 #include <configsettings.hxx>
32 #include <vcl/help.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/settings.hxx>
35 #include <vcl/virdev.hxx>
36 
38 
39 #include <sal/log.hxx>
40 #include <osl/diagnose.h>
41 #include <rtl/ustrbuf.hxx>
42 
43 #include <com/sun/star/beans/PropertyValue.hpp>
44 
45 using namespace vcl;
46 using namespace com::sun::star;
47 using namespace com::sun::star::uno;
48 using namespace com::sun::star::lang;
49 using namespace com::sun::star::container;
50 using namespace com::sun::star::beans;
51 
52 enum
53 {
57 };
58 
59 namespace {
60  bool lcl_ListBoxCompare( const OUString& rStr1, const OUString& rStr2 )
61  {
62  return vcl::NaturalSortCompare( rStr1, rStr2 ) < 0;
63  }
64 }
65 
67  : GenericDialogController(i_pParent->getDialog(), "vcl/ui/moreoptionsdialog.ui", "MoreOptionsDialog")
68  , mpParent( i_pParent )
69  , mxOKButton(m_xBuilder->weld_button("ok"))
70  , mxCancelButton(m_xBuilder->weld_button("cancel"))
71  , mxSingleJobsBox(m_xBuilder->weld_check_button("singlejobs"))
72 {
73  mxSingleJobsBox->set_active( mpParent->isSingleJobs() );
74 
75  mxOKButton->connect_clicked( LINK( this, MoreOptionsDialog, ClickHdl ) );
76  mxCancelButton->connect_clicked( LINK( this, MoreOptionsDialog, ClickHdl ) );
77 }
78 
80 {
81 }
82 
83 IMPL_LINK (MoreOptionsDialog, ClickHdl, weld::Button&, rButton, void)
84 {
85  if (&rButton == mxOKButton.get())
86  {
87  mpParent->mbSingleJobs = mxSingleJobsBox->get_active();
88  m_xDialog->response(RET_OK);
89  }
90  else if (&rButton == mxCancelButton.get())
91  {
92  m_xDialog->response(RET_CANCEL);
93  }
94 }
95 
97  : mpDialog(pDialog)
98  , maMtf()
99  , maOrigSize( 10, 10 )
100  , maPreviewSize()
101  , mnDPIX(Application::GetDefaultDevice()->GetDPIX())
102  , mnDPIY(Application::GetDefaultDevice()->GetDPIY())
103  , maPreviewBitmap()
104  , maReplacementString()
105  , mbGreyscale( false )
106 {
107 }
108 
110 {
111 }
112 
114 {
115  Size aNewSize(GetOutputSizePixel());
116  tools::Long nTextHeight = GetDrawingArea()->get_text_height();
117  // leave small space for decoration
118  aNewSize.AdjustWidth( -(nTextHeight + 2) );
119  aNewSize.AdjustHeight( -(nTextHeight + 2) );
120  Size aScaledSize;
121  double fScale = 1.0;
122 
123  // #i106435# catch corner case of Size(0,0)
124  Size aOrigSize( maOrigSize );
125  if( aOrigSize.Width() < 1 )
126  aOrigSize.setWidth( aNewSize.Width() );
127  if( aOrigSize.Height() < 1 )
128  aOrigSize.setHeight( aNewSize.Height() );
129  if( aOrigSize.Width() > aOrigSize.Height() )
130  {
131  aScaledSize = Size( aNewSize.Width(), aNewSize.Width() * aOrigSize.Height() / aOrigSize.Width() );
132  if( aScaledSize.Height() > aNewSize.Height() )
133  fScale = double(aNewSize.Height())/double(aScaledSize.Height());
134  }
135  else
136  {
137  aScaledSize = Size( aNewSize.Height() * aOrigSize.Width() / aOrigSize.Height(), aNewSize.Height() );
138  if( aScaledSize.Width() > aNewSize.Width() )
139  fScale = double(aNewSize.Width())/double(aScaledSize.Width());
140  }
141  aScaledSize.setWidth( tools::Long(aScaledSize.Width()*fScale) );
142  aScaledSize.setHeight( tools::Long(aScaledSize.Height()*fScale) );
143 
144  maPreviewSize = aScaledSize;
145 
146  // check and evtl. recreate preview bitmap
147  preparePreviewBitmap();
148 }
149 
151 {
152  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 45,
153  pDrawingArea->get_text_height() * 30);
154  CustomWidgetController::SetDrawingArea(pDrawingArea);
155 }
156 
158 {
159  rRenderContext.Push();
160  if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice()))
161  {
162  Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetLabelFont());
163  pDefaultDevice->SetPointFont(rRenderContext, aFont);
164  }
165 
166  rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
167  rRenderContext.Erase();
168 
169  auto nTextHeight = rRenderContext.GetTextHeight();
170  Size aSize(GetOutputSizePixel());
171  Point aOffset((aSize.Width() - maPreviewSize.Width() + nTextHeight) / 2,
172  (aSize.Height() - maPreviewSize.Height() + nTextHeight) / 2);
173 
174  // horizontal line
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  auto 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(Degree10(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.IsEmpty())
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::Enable);
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  tools::Long nFontHeight = tools::Long(24.0 * fScale) - 3;
467  if (nFontHeight < 5)
468  nFontHeight = 5;
469  aFont.SetFontSize(Size( 0, nFontHeight));
470  rRenderContext.SetFont(aFont);
471  tools::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.IsEmpty() )
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"))
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  , maUpdatePreviewIdle("Print Dialog Update Preview Idle")
582  , maUpdatePreviewNoCacheIdle("Print Dialog Update Preview (no cache) Idle")
583 {
584  // save printbutton text, gets exchanged occasionally with print to file
585  maPrintText = mxOKButton->get_label();
586 
587  maPageStr = mxNumPagesText->get_label();
588 
590 
591  mxPrinters->append_text(maPrintToFileText);
592  // fill printer listbox
593  std::vector< OUString > rQueues( Printer::GetPrinterQueues() );
594  std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
595  for( const auto& rQueue : rQueues )
596  {
597  mxPrinters->append_text(rQueue);
598  }
599  // select current printer
600  if (mxPrinters->find_text(maPController->getPrinter()->GetName()) != -1)
601  mxPrinters->set_active_text(maPController->getPrinter()->GetName());
602  else
603  {
604  // fall back to last printer
606  OUString aValue( pItem->getValue( "PrintDialog",
607  "LastPrinter" ) );
608  if (mxPrinters->find_text(aValue) != -1)
609  {
610  mxPrinters->set_active_text(aValue);
611  maPController->setPrinter( VclPtrInstance<Printer>( aValue ) );
612  }
613  else
614  {
615  // fall back to default printer
616  mxPrinters->set_active_text(Printer::GetDefaultPrinterName());
618  }
619  }
620 
621  // not printing to file
622  maPController->resetPrinterOptions( false );
623 
624  // update the text fields for the printer
626 
627  // set paper sizes listbox
628  setPaperSizes();
629 
630  // setup dependencies
632 
633  // setup paper sides box
635 
636  // set initial focus to "Number of copies"
637  mxCopyCountField->grab_focus();
638  mxCopyCountField->select_region(0, -1);
639 
640  // setup sizes for N-Up
641  Size aNupSize( maPController->getPrinter()->PixelToLogic(
642  maPController->getPrinter()->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) ) );
643  if( maPController->getPrinter()->GetOrientation() == Orientation::Landscape )
644  {
645  maNupLandscapeSize = aNupSize;
646  // coverity[swapped_arguments : FALSE] - this is in the correct order
647  maNupPortraitSize = Size( aNupSize.Height(), aNupSize.Width() );
648  }
649  else
650  {
651  maNupPortraitSize = aNupSize;
652  // coverity[swapped_arguments : FALSE] - this is in the correct order
653  maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() );
654  }
655 
657  maUpdatePreviewIdle.SetInvokeHandler(LINK( this, PrintDialog, updatePreviewIdle));
659  maUpdatePreviewNoCacheIdle.SetInvokeHandler(LINK(this, PrintDialog, updatePreviewNoCacheIdle));
660 
661  initFromMultiPageSetup( maPController->getMultipage() );
662 
663  // setup optional UI options set by application
664  setupOptionalUI();
665 
666  // hide layout frame if unwanted
667  mxPageLayoutFrame->set_visible(mbShowLayoutFrame);
668 
669  // restore settings from last run
671 
672  // setup click hdl
673  mxOKButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
674  mxCancelButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
675  mxHelpButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
676  mxSetupButton->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
677  mxMoreOptionsBtn->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
678  mxBackwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
679  mxForwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
680  mxFirstBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
681  mxLastBtn->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
682  mxPreviewBox->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
683  mxBorderCB->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
684 
685  // setup toggle hdl
686  mxReverseOrderBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
687  mxCollateBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
688  mxPagesBtn->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
689 
690  // setup select hdl
691  mxPrinters->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
692  mxPaperSidesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
693  mxNupPagesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
694  mxOrientationBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
695  mxNupOrderBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
696  mxPaperSizeBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
697 
698  // setup modify hdl
699  mxPageEdit->connect_activate( LINK( this, PrintDialog, ActivateHdl ) );
700  mxPageEdit->connect_focus_out( LINK( this, PrintDialog, FocusOutHdl ) );
701  mxCopyCountField->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
702  mxNupColEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
703  mxNupRowsEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
704  mxPageMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );
705  mxSheetMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );
706 
707  mxRangeExpander->connect_expanded(LINK( this, PrintDialog, ExpandHdl));
708  mxLayoutExpander->connect_expanded(LINK( this, PrintDialog, ExpandHdl));
709 
711 }
712 
714 {
715  m_xDialog->resize_to_request();
716 }
717 
719 {
720 }
721 
723 {
724  DuplexMode eDuplex = maPController->getPrinter()->GetDuplexMode();
725 
726  if ( eDuplex == DuplexMode::Unknown || isPrintToFile() )
727  {
728  mxPaperSidesBox->set_active( 0 );
729  mxPaperSidesBox->set_sensitive( false );
730  }
731  else
732  {
733  mxPaperSidesBox->set_active( static_cast<sal_Int32>(eDuplex) - 1 );
734  mxPaperSidesBox->set_sensitive( true );
735  }
736 }
737 
739 {
741 
742  pItem->setValue( "PrintDialog",
743  "LastPrinter",
745  : mxPrinters->get_active_text() );
746 
747  pItem->setValue( "PrintDialog",
748  "LastPage",
749  mxTabCtrl->get_tab_label_text(mxTabCtrl->get_current_page_ident()));
750 
751  pItem->setValue( "PrintDialog",
752  "WindowState",
753  OStringToOUString(m_xDialog->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_UTF8) );
754 
755  pItem->setValue( "PrintDialog",
756  "CopyCount",
757  mxCopyCountField->get_text() );
758 
759  pItem->setValue( "PrintDialog",
760  "Collate",
761  mxCollateBox->get_active() ? OUString("true") :
762  OUString("false") );
763 
764  pItem->setValue( "PrintDialog",
765  "CollateSingleJobs",
766  mbSingleJobs ? OUString("true") :
767  OUString("false") );
768 
769  pItem->setValue( "PrintDialog",
770  "HasPreview",
771  hasPreview() ? OUString("true") :
772  OUString("false") );
773 
774  pItem->Commit();
775 }
776 
778 {
780 
781  // read last selected tab page; if it exists, activate it
782  OUString aValue = pItem->getValue( "PrintDialog",
783  "LastPage" );
784  sal_uInt16 nCount = mxTabCtrl->get_n_pages();
785  for (sal_uInt16 i = 0; i < nCount; ++i)
786  {
787  OString sPageId = mxTabCtrl->get_page_ident(i);
788  if (aValue == mxTabCtrl->get_tab_label_text(sPageId))
789  {
790  mxTabCtrl->set_current_page(sPageId);
791  break;
792  }
793  }
794 
795  // persistent window state
796  aValue = pItem->getValue( "PrintDialog",
797  "WindowState" );
798  if (!aValue.isEmpty())
799  m_xDialog->set_window_state(OUStringToOString(aValue, RTL_TEXTENCODING_UTF8));
800 
801  // collate
802  aValue = pItem->getValue( "PrintDialog",
803  "CollateBox" );
804  if( aValue.equalsIgnoreAsciiCase("alwaysoff") )
805  {
806  mbCollateAlwaysOff = true;
807  mxCollateBox->set_active( false );
808  mxCollateBox->set_sensitive( false );
809  }
810  else
811  {
812  mbCollateAlwaysOff = false;
813  aValue = pItem->getValue( "PrintDialog",
814  "Collate" );
815  mxCollateBox->set_active( aValue.equalsIgnoreAsciiCase("true") );
816  }
817 
818  // collate single jobs
819  aValue = pItem->getValue( "PrintDialog",
820  "CollateSingleJobs" );
821  if ( aValue.equalsIgnoreAsciiCase("true") )
822  mbSingleJobs = true;
823  else
824  mbSingleJobs = false;
825 
826  // preview box
827  aValue = pItem->getValue( "PrintDialog",
828  "HasPreview" );
829  if ( aValue.equalsIgnoreAsciiCase("false") )
830  mxPreviewBox->set_active( false );
831  else
832  mxPreviewBox->set_active( true );
833 
834 }
835 
837 {
838  mxPaperSizeBox->clear();
839 
840  VclPtr<Printer> aPrt( maPController->getPrinter() );
841  mePaper = aPrt->GetPaper();
842 
843  if ( isPrintToFile() )
844  {
845  mxPaperSizeBox->set_sensitive( false );
846  }
847  else
848  {
849  for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++)
850  {
851  PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
852  aInfo.doSloppyFit();
853  Paper ePaper = aInfo.getPaper();
854 
856  MapUnit eUnit = MapUnit::MapMM;
857  int nDigits = 0;
858  if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
859  {
860  eUnit = MapUnit::Map100thInch;
861  nDigits = 2;
862  }
863  Size aSize = aPrt->GetPaperSize( nPaper );
864  Size aLogicPaperSize( OutputDevice::LogicToLogic( aSize, MapMode( MapUnit::Map100thMM ), MapMode( eUnit ) ) );
865 
866  OUString aWidth( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
867  OUString aHeight( rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ) );
868  OUString aUnit = eUnit == MapUnit::MapMM ? OUString("mm") : OUString("in");
869  OUString aPaperName = Printer::GetPaperName( ePaper ) + " " + aWidth + aUnit + " x " + aHeight + aUnit;
870 
871  mxPaperSizeBox->append_text(aPaperName);
872 
873  if ( ePaper == mePaper )
874  mxPaperSizeBox->set_active( nPaper );
875  }
876 
877  mxPaperSizeBox->set_sensitive( true );
878  }
879 }
880 
882 {
883  const OUString aDefPrt( Printer::GetDefaultPrinterName() );
884  const QueueInfo* pInfo = Printer::GetQueueInfo( mxPrinters->get_active_text(), true );
885  if( pInfo )
886  {
887  // FIXME: status text
888  OUString aStatus;
889  if( aDefPrt == pInfo->GetPrinterName() )
890  aStatus = maDefPrtText;
891  mxStatusTxt->set_label( aStatus );
892  }
893  else
894  {
895  mxStatusTxt->set_label( OUString() );
896  }
897 }
898 
900 {
901  OUString aNewText( maPageStr.replaceFirst( "%n", OUString::number( mnCachedPages ) ) );
902  mxNumPagesText->set_label( aNewText );
903 }
904 
905 IMPL_LINK_NOARG(PrintDialog, updatePreviewIdle, Timer*, void)
906 {
907  preparePreview(true);
908 }
909 
910 IMPL_LINK_NOARG(PrintDialog, updatePreviewNoCacheIdle, Timer*, void)
911 {
912  preparePreview(false);
913 }
914 
915 void PrintDialog::preparePreview( bool i_bMayUseCache )
916 {
917  VclPtr<Printer> aPrt( maPController->getPrinter() );
918  Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
919  // tdf#123076 Get paper size for the preview top label
920  mePaper = aPrt->GetPaper();
921  GDIMetaFile aMtf;
922 
923  // page range may have changed depending on options
924  sal_Int32 nPages = maPController->getFilteredPageCount();
925  mnCachedPages = nPages;
926 
927  setPreviewText();
928 
929  if ( !hasPreview() )
930  {
931  mxPreview->setPreview( aMtf, aCurPageSize,
934  aPrt->GetDPIX(), aPrt->GetDPIY(),
935  aPrt->GetPrinterOptions().IsConvertToGreyscales()
936  );
937 
938  mxForwardBtn->set_sensitive( false );
939  mxBackwardBtn->set_sensitive( false );
940  mxFirstBtn->set_sensitive( false );
941  mxLastBtn->set_sensitive( false );
942 
943  mxPageEdit->set_sensitive( false );
944 
945  return;
946  }
947 
948  if( mnCurPage >= nPages )
949  mnCurPage = nPages-1;
950  if( mnCurPage < 0 )
951  mnCurPage = 0;
952 
953 
954  const MapMode aMapMode( MapUnit::Map100thMM );
955  if( nPages > 0 )
956  {
957  PrinterController::PageSize aPageSize =
958  maPController->getFilteredPageFile( mnCurPage, aMtf, i_bMayUseCache );
959  if( ! aPageSize.bFullPaper )
960  {
961  Point aOff( aPrt->PixelToLogic( aPrt->GetPageOffsetPixel(), aMapMode ) );
962  aMtf.Move( aOff.X(), aOff.Y() );
963  }
964  }
965 
966  mxPreview->setPreview( aMtf, aCurPageSize,
968  nPages > 0 ? OUString() : maNoPageStr,
969  aPrt->GetDPIX(), aPrt->GetDPIY(),
970  aPrt->GetPrinterOptions().IsConvertToGreyscales()
971  );
972 
973  mxForwardBtn->set_sensitive( mnCurPage < nPages-1 );
974  mxBackwardBtn->set_sensitive( mnCurPage != 0 );
975  mxFirstBtn->set_sensitive( mnCurPage != 0 );
976  mxLastBtn->set_sensitive( mnCurPage < nPages-1 );
977  mxPageEdit->set_sensitive( nPages > 1 );
978 }
979 
980 void PrintDialog::updateOrientationBox( const bool bAutomatic )
981 {
982  if ( !bAutomatic )
983  {
984  Orientation eOrientation = maPController->getPrinter()->GetOrientation();
985  mxOrientationBox->set_active( static_cast<sal_Int32>(eOrientation) + 1 );
986  }
987  else if ( hasOrientationChanged() )
988  {
990  }
991 }
992 
994 {
995  const int nOrientation = mxOrientationBox->get_active();
996  const Orientation eOrientation = maPController->getPrinter()->GetOrientation();
997 
998  return (nOrientation == ORIENTATION_LANDSCAPE && eOrientation == Orientation::Portrait)
999  || (nOrientation == ORIENTATION_PORTRAIT && eOrientation == Orientation::Landscape);
1000 }
1001 
1002 // make sure paper size matches paper orientation
1004 {
1005  Orientation eOrientation = maPController->getPrinter()->GetOrientation();
1006  if ( (eOrientation == Orientation::Portrait && rPaperSize.Width() > rPaperSize.Height()) ||
1007  (eOrientation == Orientation::Landscape && rPaperSize.Width() < rPaperSize.Height()) )
1008  {
1009  // coverity[swapped-arguments : FALSE] - this is in the correct order
1010  rPaperSize = Size( rPaperSize.Height(), rPaperSize.Width() );
1011  }
1012 }
1013 
1014 // Always use this function to set paper orientation to make sure everything behaves well
1016 {
1017  VclPtr<Printer> aPrt( maPController->getPrinter() );
1018  aPrt->SetOrientation( eOrientation );
1019 
1020  // check if it's necessary to swap width and height of paper
1021  if ( maPController->isPaperSizeFromUser() )
1022  {
1023  Size& aPaperSize = maPController->getPaperSizeFromUser();
1024  checkPaperSize( aPaperSize );
1025  }
1026  else if ( maPController->getPapersizeFromSetup() )
1027  {
1028  Size& aPaperSize = maPController->getPaperSizeSetup();
1029  checkPaperSize( aPaperSize );
1030  }
1031 }
1032 
1034 {
1035  if (mxCopyCountField->get_value() > 1)
1036  mxCollateBox->set_sensitive( !mbCollateAlwaysOff );
1037  else
1038  mxCollateBox->set_sensitive( false );
1039 
1040  OUString aImg(mxCollateBox->get_active() ? OUString(SV_PRINT_COLLATE_BMP) : OUString(SV_PRINT_NOCOLLATE_BMP));
1041 
1042  mxCollateImage->set_from_icon_name(aImg);
1043 
1044  // enable setup button only for printers that can be setup
1045  bool bHaveSetup = maPController->getPrinter()->HasSupport( PrinterSupport::SetupDialog );
1046  mxSetupButton->set_sensitive(bHaveSetup);
1047 }
1048 
1050 {
1051  for( const auto& rEntry : maControlToPropertyMap )
1052  {
1053  bool bShouldbeEnabled = maPController->isUIOptionEnabled( rEntry.second );
1054 
1055  if (bShouldbeEnabled && dynamic_cast<weld::RadioButton*>(rEntry.first))
1056  {
1057  auto r_it = maControlToNumValMap.find( rEntry.first );
1058  if( r_it != maControlToNumValMap.end() )
1059  {
1060  bShouldbeEnabled = maPController->isUIChoiceEnabled( rEntry.second, r_it->second );
1061  }
1062  }
1063 
1064  bool bIsEnabled = rEntry.first->get_sensitive();
1065  // Enable does not do a change check first, so can be less cheap than expected
1066  if (bShouldbeEnabled != bIsEnabled)
1067  rEntry.first->set_sensitive( bShouldbeEnabled );
1068  }
1069 }
1070 
1072 {
1073  mxNupOrderWin->show();
1074  mxPagesBtn->set_active(true);
1075  mxBrochureBtn->hide();
1076 
1077  // setup field units for metric fields
1079  FieldUnit eUnit = FieldUnit::MM;
1080  sal_uInt16 nDigits = 0;
1081  if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
1082  {
1083  eUnit = FieldUnit::INCH;
1084  nDigits = 2;
1085  }
1086  // set units
1087  mxPageMarginEdt->set_unit( eUnit );
1088  mxSheetMarginEdt->set_unit( eUnit );
1089 
1090  // set precision
1091  mxPageMarginEdt->set_digits( nDigits );
1092  mxSheetMarginEdt->set_digits( nDigits );
1093 
1094  mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( i_rMPS.nLeftMargin ), FieldUnit::MM_100TH );
1095  mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( i_rMPS.nHorizontalSpacing ), FieldUnit::MM_100TH );
1096  mxBorderCB->set_active( i_rMPS.bDrawBorder );
1097  mxNupRowsEdt->set_value( i_rMPS.nRows );
1098  mxNupColEdt->set_value( i_rMPS.nColumns );
1099  mxNupOrderBox->set_active( static_cast<sal_Int32>(i_rMPS.nOrder) );
1100  if( i_rMPS.nRows != 1 || i_rMPS.nColumns != 1 )
1101  {
1102  mxNupPagesBox->set_active( mxNupPagesBox->get_count()-1 );
1103  showAdvancedControls( true );
1104  mxNupOrder->setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows );
1105  }
1106 }
1107 
1108 void PrintDialog::updateNup( bool i_bMayUseCache )
1109 {
1110  int nRows = mxNupRowsEdt->get_value();
1111  int nCols = mxNupColEdt->get_value();
1112  tools::Long nPageMargin = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
1113  tools::Long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));
1114 
1116  aMPS.nRows = nRows;
1117  aMPS.nColumns = nCols;
1118  aMPS.nLeftMargin =
1119  aMPS.nTopMargin =
1120  aMPS.nRightMargin =
1121  aMPS.nBottomMargin = nSheetMargin;
1122 
1123  aMPS.nHorizontalSpacing =
1124  aMPS.nVerticalSpacing = nPageMargin;
1125 
1126  aMPS.bDrawBorder = mxBorderCB->get_active();
1127 
1128  aMPS.nOrder = static_cast<NupOrderType>(mxNupOrderBox->get_active());
1129 
1130  int nOrientationMode = mxOrientationBox->get_active();
1131  if( nOrientationMode == ORIENTATION_LANDSCAPE )
1133  else if( nOrientationMode == ORIENTATION_PORTRAIT )
1135  else // automatic mode
1136  {
1137  // get size of first real page to see if it is portrait or landscape
1138  // we assume same page sizes for all the pages for this
1139  Size aPageSize = getJobPageSize();
1140 
1141  Size aMultiSize( aPageSize.Width() * nCols, aPageSize.Height() * nRows );
1142  if( aMultiSize.Width() > aMultiSize.Height() ) // fits better on landscape
1143  {
1146  }
1147  else
1148  {
1151  }
1152  }
1153 
1154  maPController->setMultipage( aMPS );
1155 
1156  mxNupOrder->setValues( aMPS.nOrder, nCols, nRows );
1157 
1158  if (i_bMayUseCache)
1160  else
1162 }
1163 
1164 void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
1165 {
1166  int nPages = mxNupPagesBox->get_active_id().toInt32();
1167  int nRows = mxNupRowsEdt->get_value();
1168  int nCols = mxNupColEdt->get_value();
1169  tools::Long nPageMargin = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
1170  tools::Long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));
1171  bool bCustom = false;
1172 
1173  if( nPages == 1 )
1174  {
1175  nRows = nCols = 1;
1176  nSheetMargin = 0;
1177  nPageMargin = 0;
1178  }
1179  else if( nPages == 2 || nPages == 4 || nPages == 6 || nPages == 9 || nPages == 16 )
1180  {
1181  Size aJobPageSize( getJobPageSize() );
1182  bool bPortrait = aJobPageSize.Width() < aJobPageSize.Height();
1183  if( nPages == 2 )
1184  {
1185  if( bPortrait )
1186  {
1187  nRows = 1;
1188  nCols = 2;
1189  }
1190  else
1191  {
1192  nRows = 2;
1193  nCols = 1;
1194  }
1195  }
1196  else if( nPages == 4 )
1197  nRows = nCols = 2;
1198  else if( nPages == 6 )
1199  {
1200  if( bPortrait )
1201  {
1202  nRows = 2;
1203  nCols = 3;
1204  }
1205  else
1206  {
1207  nRows = 3;
1208  nCols = 2;
1209  }
1210  }
1211  else if( nPages == 9 )
1212  nRows = nCols = 3;
1213  else if( nPages == 16 )
1214  nRows = nCols = 4;
1215  nPageMargin = 0;
1216  nSheetMargin = 0;
1217  }
1218  else
1219  bCustom = true;
1220 
1221  if( nPages > 1 )
1222  {
1223  // set upper limits for margins based on job page size and rows/columns
1224  Size aSize( getJobPageSize() );
1225 
1226  // maximum sheet distance: 1/2 sheet
1227  tools::Long nHorzMax = aSize.Width()/2;
1228  tools::Long nVertMax = aSize.Height()/2;
1229  if( nSheetMargin > nHorzMax )
1230  nSheetMargin = nHorzMax;
1231  if( nSheetMargin > nVertMax )
1232  nSheetMargin = nVertMax;
1233 
1234  mxSheetMarginEdt->set_max(
1235  mxSheetMarginEdt->normalize(
1236  std::min(nHorzMax, nVertMax) ), FieldUnit::MM_100TH );
1237 
1238  // maximum page distance
1239  nHorzMax = (aSize.Width() - 2*nSheetMargin);
1240  if( nCols > 1 )
1241  nHorzMax /= (nCols-1);
1242  nVertMax = (aSize.Height() - 2*nSheetMargin);
1243  if( nRows > 1 )
1244  nHorzMax /= (nRows-1);
1245 
1246  if( nPageMargin > nHorzMax )
1247  nPageMargin = nHorzMax;
1248  if( nPageMargin > nVertMax )
1249  nPageMargin = nVertMax;
1250 
1251  mxPageMarginEdt->set_max(
1252  mxSheetMarginEdt->normalize(
1253  std::min(nHorzMax, nVertMax ) ), FieldUnit::MM_100TH );
1254  }
1255 
1256  mxNupRowsEdt->set_value( nRows );
1257  mxNupColEdt->set_value( nCols );
1258  mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( nPageMargin ), FieldUnit::MM_100TH );
1259  mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( nSheetMargin ), FieldUnit::MM_100TH );
1260 
1261  showAdvancedControls( bCustom );
1262  updateNup( i_bMayUseCache );
1263 }
1264 
1266 {
1267  mxNupPagesBox->set_sensitive( bEnable );
1268  mxNupNumPagesTxt->set_sensitive( bEnable );
1269  mxNupColEdt->set_sensitive( bEnable );
1270  mxNupTimesTxt->set_sensitive( bEnable );
1271  mxNupRowsEdt->set_sensitive( bEnable );
1272  mxPageMarginTxt1->set_sensitive( bEnable );
1273  mxPageMarginEdt->set_sensitive( bEnable );
1274  mxPageMarginTxt2->set_sensitive( bEnable );
1275  mxSheetMarginTxt1->set_sensitive( bEnable );
1276  mxSheetMarginEdt->set_sensitive( bEnable );
1277  mxSheetMarginTxt2->set_sensitive( bEnable );
1278  mxNupOrderTxt->set_sensitive( bEnable );
1279  mxNupOrderBox->set_sensitive( bEnable );
1280  mxNupOrderWin->set_sensitive( bEnable );
1281  mxBorderCB->set_sensitive( bEnable );
1282 }
1283 
1285 {
1286  mxNupNumPagesTxt->set_visible( i_bShow );
1287  mxNupColEdt->set_visible( i_bShow );
1288  mxNupTimesTxt->set_visible( i_bShow );
1289  mxNupRowsEdt->set_visible( i_bShow );
1290  mxPageMarginTxt1->set_visible( i_bShow );
1291  mxPageMarginEdt->set_visible( i_bShow );
1292  mxPageMarginTxt2->set_visible( i_bShow );
1293  mxSheetMarginTxt1->set_visible( i_bShow );
1294  mxSheetMarginEdt->set_visible( i_bShow );
1295  mxSheetMarginTxt2->set_visible( i_bShow );
1296 }
1297 
1298 namespace
1299 {
1300  void setHelpId( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
1301  {
1302  if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() )
1303  i_pWindow->set_help_id( OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) );
1304  }
1305 
1306  void setHelpText( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpTexts, sal_Int32 i_nIndex )
1307  {
1308  // without a help text set and the correct smartID,
1309  // help texts will be retrieved from the online help system
1310  if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() )
1311  i_pWindow->set_tooltip_text(i_rHelpTexts.getConstArray()[i_nIndex]);
1312  }
1313 }
1314 
1316 {
1317  const Sequence< PropertyValue >& rOptions( maPController->getUIOptions() );
1318  for( const auto& rOption : rOptions )
1319  {
1320  if (rOption.Name == "OptionsUIFile")
1321  {
1322  OUString sOptionsUIFile;
1323  rOption.Value >>= sOptionsUIFile;
1324  mxCustomOptionsUIBuilder.reset(Application::CreateBuilder(mxCustom.get(), sOptionsUIFile));
1325  std::unique_ptr<weld::Container> xWindow = mxCustomOptionsUIBuilder->weld_container("box");
1326  xWindow->show();
1327  continue;
1328  }
1329 
1331  rOption.Value >>= aOptProp;
1332 
1333  // extract ui element
1334  OUString aCtrlType;
1335  OString aID;
1336  OUString aText;
1337  OUString aPropertyName;
1338  Sequence< OUString > aChoices;
1339  Sequence< sal_Bool > aChoicesDisabled;
1340  Sequence< OUString > aHelpTexts;
1341  Sequence< OUString > aIDs;
1342  Sequence< OUString > aHelpIds;
1343  sal_Int64 nMinValue = 0, nMaxValue = 0;
1344  OUString aGroupingHint;
1345 
1346  for( const beans::PropertyValue& rEntry : std::as_const(aOptProp) )
1347  {
1348  if ( rEntry.Name == "ID" )
1349  {
1350  rEntry.Value >>= aIDs;
1351  aID = OUStringToOString(aIDs[0], RTL_TEXTENCODING_UTF8);
1352  }
1353  if ( rEntry.Name == "Text" )
1354  {
1355  rEntry.Value >>= aText;
1356  }
1357  else if ( rEntry.Name == "ControlType" )
1358  {
1359  rEntry.Value >>= aCtrlType;
1360  }
1361  else if ( rEntry.Name == "Choices" )
1362  {
1363  rEntry.Value >>= aChoices;
1364  }
1365  else if ( rEntry.Name == "ChoicesDisabled" )
1366  {
1367  rEntry.Value >>= aChoicesDisabled;
1368  }
1369  else if ( rEntry.Name == "Property" )
1370  {
1371  PropertyValue aVal;
1372  rEntry.Value >>= aVal;
1373  aPropertyName = aVal.Name;
1374  }
1375  else if ( rEntry.Name == "Enabled" )
1376  {
1377  }
1378  else if ( rEntry.Name == "GroupingHint" )
1379  {
1380  rEntry.Value >>= aGroupingHint;
1381  }
1382  else if ( rEntry.Name == "DependsOnName" )
1383  {
1384  }
1385  else if ( rEntry.Name == "DependsOnEntry" )
1386  {
1387  }
1388  else if ( rEntry.Name == "AttachToDependency" )
1389  {
1390  }
1391  else if ( rEntry.Name == "MinValue" )
1392  {
1393  rEntry.Value >>= nMinValue;
1394  }
1395  else if ( rEntry.Name == "MaxValue" )
1396  {
1397  rEntry.Value >>= nMaxValue;
1398  }
1399  else if ( rEntry.Name == "HelpText" )
1400  {
1401  if( ! (rEntry.Value >>= aHelpTexts) )
1402  {
1403  OUString aHelpText;
1404  if( rEntry.Value >>= aHelpText )
1405  {
1406  aHelpTexts.realloc( 1 );
1407  *aHelpTexts.getArray() = aHelpText;
1408  }
1409  }
1410  }
1411  else if ( rEntry.Name == "HelpId" )
1412  {
1413  if( ! (rEntry.Value >>= aHelpIds ) )
1414  {
1415  OUString aHelpId;
1416  if( rEntry.Value >>= aHelpId )
1417  {
1418  aHelpIds.realloc( 1 );
1419  *aHelpIds.getArray() = aHelpId;
1420  }
1421  }
1422  }
1423  else if ( rEntry.Name == "HintNoLayoutPage" )
1424  {
1425  bool bHasLayoutFrame = false;
1426  rEntry.Value >>= bHasLayoutFrame;
1427  mbShowLayoutFrame = !bHasLayoutFrame;
1428  }
1429  }
1430 
1431  if (aCtrlType == "Group")
1432  {
1433  aID = "custom";
1434 
1435  weld::Container* pPage = mxTabCtrl->get_page(aID);
1436  if (!pPage)
1437  continue;
1438 
1439  mxTabCtrl->set_tab_label_text(aID, aText);
1440 
1441  // set help id
1442  if (aHelpIds.hasElements())
1443  pPage->set_help_id(OUStringToOString(aHelpIds.getConstArray()[0], RTL_TEXTENCODING_UTF8));
1444 
1445  // set help text
1446  if (aHelpTexts.hasElements())
1447  pPage->set_tooltip_text(aHelpTexts.getConstArray()[0]);
1448 
1449  pPage->show();
1450  }
1451  else if (aCtrlType == "Subgroup" && !aID.isEmpty())
1452  {
1453  std::unique_ptr<weld::Widget> xWidget;
1454  // since 'New Print Dialog Design' fromwhich in calc is not a frame anymore
1455  if (aID == "fromwhich")
1456  {
1457  std::unique_ptr<weld::Label> xLabel = m_xBuilder->weld_label(aID);
1458  xLabel->set_label(aText);
1459  xWidget = std::move(xLabel);
1460  }
1461  else
1462  {
1463  std::unique_ptr<weld::Frame> xFrame = m_xBuilder->weld_frame(aID);
1464  if (!xFrame && mxCustomOptionsUIBuilder)
1465  xFrame = mxCustomOptionsUIBuilder->weld_frame(aID);
1466  if (xFrame)
1467  {
1468  xFrame->set_label(aText);
1469  xWidget = std::move(xFrame);
1470  }
1471  }
1472 
1473  if (!xWidget)
1474  continue;
1475 
1476  // set help id
1477  setHelpId(xWidget.get(), aHelpIds, 0);
1478  // set help text
1479  setHelpText(xWidget.get(), aHelpTexts, 0);
1480 
1481  xWidget->show();
1482  }
1483  // EVIL
1484  else if( aCtrlType == "Bool" && aGroupingHint == "LayoutPage" && aPropertyName == "PrintProspect" )
1485  {
1486  mxBrochureBtn->set_label(aText);
1487  mxBrochureBtn->show();
1488 
1489  bool bVal = false;
1490  PropertyValue* pVal = maPController->getValue( aPropertyName );
1491  if( pVal )
1492  pVal->Value >>= bVal;
1493  mxBrochureBtn->set_active( bVal );
1494  mxBrochureBtn->set_sensitive( maPController->isUIOptionEnabled( aPropertyName ) && pVal != nullptr );
1495  mxBrochureBtn->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
1496 
1497  maPropertyToWindowMap[aPropertyName].emplace_back(mxBrochureBtn.get());
1498  maControlToPropertyMap[mxBrochureBtn.get()] = aPropertyName;
1499 
1500  // set help id
1501  setHelpId( mxBrochureBtn.get(), aHelpIds, 0 );
1502  // set help text
1503  setHelpText( mxBrochureBtn.get(), aHelpTexts, 0 );
1504  }
1505  else if (aCtrlType == "Bool")
1506  {
1507  // add a check box
1508  std::unique_ptr<weld::CheckButton> xNewBox = m_xBuilder->weld_check_button(aID);
1509  if (!xNewBox && mxCustomOptionsUIBuilder)
1510  xNewBox = mxCustomOptionsUIBuilder->weld_check_button(aID);
1511  if (!xNewBox)
1512  continue;
1513 
1514  xNewBox->set_label( aText );
1515  xNewBox->show();
1516 
1517  bool bVal = false;
1518  PropertyValue* pVal = maPController->getValue( aPropertyName );
1519  if( pVal )
1520  pVal->Value >>= bVal;
1521  xNewBox->set_active( bVal );
1522  xNewBox->connect_toggled( LINK( this, PrintDialog, UIOption_CheckHdl ) );
1523 
1524  maExtraControls.emplace_back(std::move(xNewBox));
1525 
1526  weld::Widget* pWidget = maExtraControls.back().get();
1527 
1528  maPropertyToWindowMap[aPropertyName].emplace_back(pWidget);
1529  maControlToPropertyMap[pWidget] = aPropertyName;
1530 
1531  // set help id
1532  setHelpId(pWidget, aHelpIds, 0);
1533  // set help text
1534  setHelpText(pWidget, aHelpTexts, 0);
1535  }
1536  else if (aCtrlType == "Radio")
1537  {
1538  sal_Int32 nCurHelpText = 0;
1539 
1540  // iterate options
1541  sal_Int32 nSelectVal = 0;
1542  PropertyValue* pVal = maPController->getValue( aPropertyName );
1543  if( pVal && pVal->Value.hasValue() )
1544  pVal->Value >>= nSelectVal;
1545  for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
1546  {
1547  aID = OUStringToOString(aIDs[m], RTL_TEXTENCODING_UTF8);
1548  std::unique_ptr<weld::RadioButton> xBtn = m_xBuilder->weld_radio_button(aID);
1549  if (!xBtn && mxCustomOptionsUIBuilder)
1550  xBtn = mxCustomOptionsUIBuilder->weld_radio_button(aID);
1551  if (!xBtn)
1552  continue;
1553 
1554  xBtn->set_label( aChoices[m] );
1555  xBtn->set_active( m == nSelectVal );
1556  xBtn->connect_toggled( LINK( this, PrintDialog, UIOption_RadioHdl ) );
1557  if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] )
1558  xBtn->set_sensitive( false );
1559  xBtn->show();
1560 
1561  maExtraControls.emplace_back(std::move(xBtn));
1562 
1563  weld::Widget* pWidget = maExtraControls.back().get();
1564 
1565  maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1566  maControlToPropertyMap[pWidget] = aPropertyName;
1567  maControlToNumValMap[pWidget] = m;
1568 
1569  // set help id
1570  setHelpId( pWidget, aHelpIds, nCurHelpText );
1571  // set help text
1572  setHelpText( pWidget, aHelpTexts, nCurHelpText );
1573  nCurHelpText++;
1574  }
1575  }
1576  else if ( aCtrlType == "List" )
1577  {
1578  std::unique_ptr<weld::ComboBox> xList = m_xBuilder->weld_combo_box(aID);
1579  if (!xList && mxCustomOptionsUIBuilder)
1580  xList = mxCustomOptionsUIBuilder->weld_combo_box(aID);
1581  if (!xList)
1582  continue;
1583 
1584  // iterate options
1585  for( const auto& rChoice : std::as_const(aChoices) )
1586  xList->append_text(rChoice);
1587 
1588  sal_Int32 nSelectVal = 0;
1589  PropertyValue* pVal = maPController->getValue( aPropertyName );
1590  if( pVal && pVal->Value.hasValue() )
1591  pVal->Value >>= nSelectVal;
1592  xList->set_active(nSelectVal);
1593  xList->connect_changed( LINK( this, PrintDialog, UIOption_SelectHdl ) );
1594  xList->show();
1595 
1596  maExtraControls.emplace_back(std::move(xList));
1597 
1598  weld::Widget* pWidget = maExtraControls.back().get();
1599 
1600  maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1601  maControlToPropertyMap[pWidget] = aPropertyName;
1602 
1603  // set help id
1604  setHelpId( pWidget, aHelpIds, 0 );
1605  // set help text
1606  setHelpText( pWidget, aHelpTexts, 0 );
1607  }
1608  else if ( aCtrlType == "Range" )
1609  {
1610  std::unique_ptr<weld::SpinButton> xField = m_xBuilder->weld_spin_button(aID);
1611  if (!xField && mxCustomOptionsUIBuilder)
1612  xField = mxCustomOptionsUIBuilder->weld_spin_button(aID);
1613  if (!xField)
1614  continue;
1615 
1616  // set min/max and current value
1617  if(nMinValue != nMaxValue)
1618  xField->set_range(nMinValue, nMaxValue);
1619 
1620  sal_Int64 nCurVal = 0;
1621  PropertyValue* pVal = maPController->getValue( aPropertyName );
1622  if( pVal && pVal->Value.hasValue() )
1623  pVal->Value >>= nCurVal;
1624  xField->set_value( nCurVal );
1625  xField->connect_value_changed( LINK( this, PrintDialog, UIOption_SpinModifyHdl ) );
1626  xField->show();
1627 
1628  maExtraControls.emplace_back(std::move(xField));
1629 
1630  weld::Widget* pWidget = maExtraControls.back().get();
1631 
1632  maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1633  maControlToPropertyMap[pWidget] = aPropertyName;
1634 
1635  // set help id
1636  setHelpId( pWidget, aHelpIds, 0 );
1637  // set help text
1638  setHelpText( pWidget, aHelpTexts, 0 );
1639  }
1640  else if (aCtrlType == "Edit")
1641  {
1642  std::unique_ptr<weld::Entry> xField = m_xBuilder->weld_entry(aID);
1643  if (!xField && mxCustomOptionsUIBuilder)
1644  xField = mxCustomOptionsUIBuilder->weld_entry(aID);
1645  if (!xField)
1646  continue;
1647 
1648  OUString aCurVal;
1649  PropertyValue* pVal = maPController->getValue( aPropertyName );
1650  if( pVal && pVal->Value.hasValue() )
1651  pVal->Value >>= aCurVal;
1652  xField->set_text( aCurVal );
1653  xField->connect_changed( LINK( this, PrintDialog, UIOption_EntryModifyHdl ) );
1654  xField->show();
1655 
1656  maExtraControls.emplace_back(std::move(xField));
1657 
1658  weld::Widget* pWidget = maExtraControls.back().get();
1659 
1660  maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
1661  maControlToPropertyMap[pWidget] = aPropertyName;
1662 
1663  // set help id
1664  setHelpId( pWidget, aHelpIds, 0 );
1665  // set help text
1666  setHelpText( pWidget, aHelpTexts, 0 );
1667  }
1668  else
1669  {
1670  SAL_WARN( "vcl", "Unsupported UI option: \"" << aCtrlType << '"');
1671  }
1672  }
1673 
1674  // #i106506# if no brochure button, then the singular Pages radio button
1675  // makes no sense, so replace it by a FixedText label
1676  if (!mxBrochureBtn->get_visible() && mxPagesBtn->get_visible())
1677  {
1678  mxPagesBoxTitleTxt->set_label(mxPagesBtn->get_label());
1679  mxPagesBoxTitleTxt->show();
1680  mxPagesBtn->hide();
1681 
1682  mxPagesBoxTitleTxt->set_accessible_relation_label_for(mxNupPagesBox.get());
1683  mxNupPagesBox->set_accessible_relation_labeled_by(mxPagesBoxTitleTxt.get());
1684  mxPagesBtn->set_accessible_relation_label_for(nullptr);
1685  }
1686 
1687  // update enable states
1689 
1690  // print range not shown (currently math only) -> hide spacer line and reverse order
1691  if (!mxPageRangeEdit->get_visible())
1692  {
1693  mxReverseOrderBox->hide();
1694  }
1695 
1697  mxTabCtrl->remove_page(mxTabCtrl->get_page_ident(1));
1698 }
1699 
1701 {
1702  auto it = maControlToPropertyMap.find( i_pWindow );
1703  if( it != maControlToPropertyMap.end() )
1704  {
1705  OUString aDependency( maPController->makeEnabled( it->second ) );
1706  if( !aDependency.isEmpty() )
1707  updateWindowFromProperty( aDependency );
1708  }
1709 }
1710 
1711 void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
1712 {
1713  beans::PropertyValue* pValue = maPController->getValue( i_rProperty );
1714  auto it = maPropertyToWindowMap.find( i_rProperty );
1715  if( !(pValue && it != maPropertyToWindowMap.end()) )
1716  return;
1717 
1718  const auto& rWindows( it->second );
1719  if( rWindows.empty() )
1720  return;
1721 
1722  bool bVal = false;
1723  sal_Int32 nVal = -1;
1724  if( pValue->Value >>= bVal )
1725  {
1726  // we should have a CheckBox for this one
1727  weld::CheckButton* pBox = dynamic_cast<weld::CheckButton*>(rWindows.front());
1728  if( pBox )
1729  {
1730  pBox->set_active( bVal );
1731  }
1732  else if ( i_rProperty == "PrintProspect" )
1733  {
1734  // EVIL special case
1735  if( bVal )
1736  mxBrochureBtn->set_active(true);
1737  else
1738  mxPagesBtn->set_active(true);
1739  }
1740  else
1741  {
1742  SAL_WARN( "vcl", "missing a checkbox" );
1743  }
1744  }
1745  else if( pValue->Value >>= nVal )
1746  {
1747  // this could be a ListBox or a RadioButtonGroup
1748  weld::ComboBox* pList = dynamic_cast<weld::ComboBox*>(rWindows.front());
1749  if( pList )
1750  {
1751  pList->set_active( static_cast< sal_uInt16 >(nVal) );
1752  }
1753  else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) )
1754  {
1755  weld::RadioButton* pBtn = dynamic_cast<weld::RadioButton*>(rWindows[nVal]);
1756  SAL_WARN_IF( !pBtn, "vcl", "unexpected control for property" );
1757  if( pBtn )
1758  pBtn->set_active(true);
1759  }
1760  }
1761 }
1762 
1764 {
1765  return ( mxPrinters->get_active() == 0 );
1766 }
1767 
1769 {
1770  return mxCopyCountField->get_value() > 1 && mxCollateBox->get_active();
1771 }
1772 
1774 {
1775  return mxPreviewBox->get_active();
1776 }
1777 
1778 PropertyValue* PrintDialog::getValueForWindow( weld::Widget* i_pWindow ) const
1779 {
1780  PropertyValue* pVal = nullptr;
1781  auto it = maControlToPropertyMap.find( i_pWindow );
1782  if( it != maControlToPropertyMap.end() )
1783  {
1784  pVal = maPController->getValue( it->second );
1785  SAL_WARN_IF( !pVal, "vcl", "property value not found" );
1786  }
1787  else
1788  {
1789  OSL_FAIL( "changed control not in property map" );
1790  }
1791  return pVal;
1792 }
1793 
1794 IMPL_LINK(PrintDialog, ToggleHdl, weld::ToggleButton&, rButton, void)
1795 {
1796  ClickHdl(rButton);
1797 }
1798 
1799 IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
1800 {
1801  if (&rButton == mxOKButton.get() || &rButton == mxCancelButton.get())
1802  {
1803  storeToSettings();
1804  m_xDialog->response(&rButton == mxOKButton.get() ? RET_OK : RET_CANCEL);
1805  }
1806  else if( &rButton == mxHelpButton.get() )
1807  {
1808  // start help system
1809  Help* pHelp = Application::GetHelp();
1810  if( pHelp )
1811  {
1812  pHelp->Start("vcl/ui/printdialog/PrintDialog", mxOKButton.get());
1813  }
1814  }
1815  else if ( &rButton == mxPreviewBox.get() )
1816  {
1817  maUpdatePreviewIdle.Start();
1818  }
1819  else if( &rButton == mxForwardBtn.get() )
1820  {
1821  previewForward();
1822  }
1823  else if( &rButton == mxBackwardBtn.get() )
1824  {
1825  previewBackward();
1826  }
1827  else if( &rButton == mxFirstBtn.get() )
1828  {
1829  previewFirst();
1830  }
1831  else if( &rButton == mxLastBtn.get() )
1832  {
1833  previewLast();
1834  }
1835  else if( &rButton == mxBrochureBtn.get() )
1836  {
1837  PropertyValue* pVal = getValueForWindow( &rButton );
1838  if( pVal )
1839  {
1840  bool bVal = mxBrochureBtn->get_active();
1841  pVal->Value <<= bVal;
1842 
1843  checkOptionalControlDependencies();
1844 
1845  // update preview and page settings
1846  maUpdatePreviewNoCacheIdle.Start();
1847  }
1848  if( mxBrochureBtn->get_active() )
1849  {
1850  mxOrientationBox->set_sensitive( false );
1851  mxOrientationBox->set_active( ORIENTATION_LANDSCAPE );
1852  mxNupPagesBox->set_active( 0 );
1853  updateNupFromPages();
1854  showAdvancedControls( false );
1855  enableNupControls( false );
1856  }
1857  }
1858  else if( &rButton == mxPagesBtn.get() )
1859  {
1860  mxOrientationBox->set_sensitive( true );
1861  mxOrientationBox->set_active( ORIENTATION_AUTOMATIC );
1862  enableNupControls( true );
1863  updateNupFromPages();
1864  }
1865  else if( &rButton == mxCollateBox.get() )
1866  {
1867  maPController->setValue( "Collate",
1868  makeAny( isCollate() ) );
1869  checkControlDependencies();
1870  }
1871  else if( &rButton == mxReverseOrderBox.get() )
1872  {
1873  bool bChecked = mxReverseOrderBox->get_active();
1874  maPController->setReversePrint( bChecked );
1875  maPController->setValue( "PrintReverse",
1876  makeAny( bChecked ) );
1877  maUpdatePreviewIdle.Start();
1878  }
1879  else if( &rButton == mxBorderCB.get() )
1880  {
1881  updateNup();
1882  }
1883  else if ( &rButton == mxMoreOptionsBtn.get() )
1884  {
1885  mxMoreOptionsDlg.reset(new MoreOptionsDialog(this));
1886  mxMoreOptionsDlg->run();
1887  }
1888  else
1889  {
1890  if( &rButton == mxSetupButton.get() )
1891  {
1892  maPController->setupPrinter(m_xDialog.get());
1893 
1894  if ( !isPrintToFile() )
1895  {
1896  VclPtr<Printer> aPrt( maPController->getPrinter() );
1897  mePaper = aPrt->GetPaper();
1898 
1899  for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++ )
1900  {
1901  PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
1902  aInfo.doSloppyFit();
1903  Paper ePaper = aInfo.getPaper();
1904 
1905  if ( mePaper == ePaper )
1906  {
1907  mxPaperSizeBox->set_active( nPaper );
1908  break;
1909  }
1910  }
1911  }
1912 
1913  updateOrientationBox( false );
1914  setupPaperSidesBox();
1915 
1916  // tdf#63905 don't use cache: page size may change
1917  maUpdatePreviewNoCacheIdle.Start();
1918  }
1919  checkControlDependencies();
1920  }
1921 
1922 }
1923 
1924 IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
1925 {
1926  if (&rBox == mxPrinters.get())
1927  {
1928  if ( !isPrintToFile() )
1929  {
1930  OUString aNewPrinter(rBox.get_active_text());
1931  // set new printer
1932  maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
1933  maPController->resetPrinterOptions( false );
1934 
1935  updateOrientationBox();
1936 
1937  // update text fields
1938  mxOKButton->set_label(maPrintText);
1939  updatePrinterText();
1940  setPaperSizes();
1941  maUpdatePreviewIdle.Start();
1942  }
1943  else // print to file
1944  {
1945  // use the default printer or FIXME: the last used one?
1946  maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
1947  mxOKButton->set_label(maPrintToFileText);
1948  maPController->resetPrinterOptions( true );
1949 
1950  setPaperSizes();
1951  updateOrientationBox();
1952  maUpdatePreviewIdle.Start();
1953  }
1954 
1955  setupPaperSidesBox();
1956  }
1957  else if ( &rBox == mxPaperSidesBox.get() )
1958  {
1959  DuplexMode eDuplex = static_cast<DuplexMode>(mxPaperSidesBox->get_active() + 1);
1960  maPController->getPrinter()->SetDuplexMode( eDuplex );
1961  }
1962  else if( &rBox == mxOrientationBox.get() )
1963  {
1964  int nOrientation = mxOrientationBox->get_active();
1965  if ( nOrientation != ORIENTATION_AUTOMATIC )
1966  setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ) );
1967 
1968  updateNup( false );
1969  }
1970  else if ( &rBox == mxNupOrderBox.get() )
1971  {
1972  updateNup();
1973  }
1974  else if( &rBox == mxNupPagesBox.get() )
1975  {
1976  if( !mxPagesBtn->get_active() )
1977  mxPagesBtn->set_active(true);
1978  updateNupFromPages( false );
1979  }
1980  else if ( &rBox == mxPaperSizeBox.get() )
1981  {
1982  VclPtr<Printer> aPrt( maPController->getPrinter() );
1983  PaperInfo aInfo = aPrt->GetPaperInfo( rBox.get_active() );
1984  aInfo.doSloppyFit();
1985  mePaper = aInfo.getPaper();
1986 
1987  if ( mePaper == PAPER_USER )
1988  aPrt->SetPaperSizeUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
1989  else
1990  aPrt->SetPaper( mePaper );
1991 
1992  Size aPaperSize( aInfo.getWidth(), aInfo.getHeight() );
1993  checkPaperSize( aPaperSize );
1994  maPController->setPaperSizeFromUser( aPaperSize );
1995 
1996  maUpdatePreviewIdle.Start();
1997  }
1998 }
1999 
2001 {
2002  checkControlDependencies();
2003  updateNupFromPages();
2004 }
2005 
2007 {
2008  ActivateHdl(*mxPageEdit);
2009 }
2010 
2012 {
2013  sal_Int32 nPage = mxPageEdit->get_text().toInt32();
2014  if (nPage < 1)
2015  {
2016  nPage = 1;
2017  mxPageEdit->set_text("1");
2018  }
2019  else if (nPage > mnCachedPages)
2020  {
2021  nPage = mnCachedPages;
2022  mxPageEdit->set_text(OUString::number(mnCachedPages));
2023  }
2024  int nNewCurPage = nPage - 1;
2025  if (nNewCurPage != mnCurPage)
2026  {
2027  mnCurPage = nNewCurPage;
2028  maUpdatePreviewIdle.Start();
2029  }
2030  return true;
2031 }
2032 
2033 IMPL_LINK( PrintDialog, SpinModifyHdl, weld::SpinButton&, rEdit, void )
2034 {
2035  checkControlDependencies();
2036  if (&rEdit == mxNupRowsEdt.get() || &rEdit == mxNupColEdt.get())
2037  {
2038  updateNupFromPages();
2039  }
2040  else if( &rEdit == mxCopyCountField.get() )
2041  {
2042  maPController->setValue( "CopyCount",
2043  makeAny( sal_Int32(mxCopyCountField->get_value()) ) );
2044  maPController->setValue( "Collate",
2045  makeAny( isCollate() ) );
2046  }
2047 }
2048 
2049 IMPL_LINK( PrintDialog, UIOption_CheckHdl, weld::ToggleButton&, i_rBox, void )
2050 {
2051  PropertyValue* pVal = getValueForWindow( &i_rBox );
2052  if( pVal )
2053  {
2054  makeEnabled( &i_rBox );
2055 
2056  bool bVal = i_rBox.get_active();
2057  pVal->Value <<= bVal;
2058 
2059  checkOptionalControlDependencies();
2060 
2061  // update preview and page settings
2062  maUpdatePreviewNoCacheIdle.Start();
2063  }
2064 }
2065 
2066 IMPL_LINK( PrintDialog, UIOption_RadioHdl, weld::ToggleButton&, i_rBtn, void )
2067 {
2068  // this handler gets called for all radiobuttons that get unchecked, too
2069  // however we only want one notification for the new value (that is for
2070  // the button that gets checked)
2071  if( !i_rBtn.get_active() )
2072  return;
2073 
2074  PropertyValue* pVal = getValueForWindow( &i_rBtn );
2075  auto it = maControlToNumValMap.find( &i_rBtn );
2076  if( !(pVal && it != maControlToNumValMap.end()) )
2077  return;
2078 
2079  makeEnabled( &i_rBtn );
2080 
2081  sal_Int32 nVal = it->second;
2082  pVal->Value <<= nVal;
2083 
2084  updateOrientationBox();
2085 
2086  checkOptionalControlDependencies();
2087 
2088  // tdf#41205 give focus to the page range edit if the corresponding radio button was selected
2089  if (pVal->Name == "PrintContent" && mxPageRangesRadioButton->get_active())
2090  mxPageRangeEdit->grab_focus();
2091 
2092  // update preview and page settings
2093  maUpdatePreviewNoCacheIdle.Start();
2094 }
2095 
2096 IMPL_LINK( PrintDialog, UIOption_SelectHdl, weld::ComboBox&, i_rBox, void )
2097 {
2098  PropertyValue* pVal = getValueForWindow( &i_rBox );
2099  if( !pVal )
2100  return;
2101 
2102  makeEnabled( &i_rBox );
2103 
2104  sal_Int32 nVal( i_rBox.get_active() );
2105  pVal->Value <<= nVal;
2106 
2107  //If we are in impress we start in print slides mode and get a
2108  //maFirstPageSize for slides which are usually landscape mode, if we
2109  //change to notes which are usually in portrait mode, and then visit
2110  //n-up print, we will assume notes are in landscape unless we throw
2111  //away maFirstPageSize when we change page content type
2112  if (pVal->Name == "PageContentType")
2113  maFirstPageSize = Size();
2114 
2115  checkOptionalControlDependencies();
2116 
2117  // update preview and page settings
2118  maUpdatePreviewNoCacheIdle.Start();
2119 }
2120 
2121 IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void )
2122 {
2123  PropertyValue* pVal = getValueForWindow( &i_rBox );
2124  if( pVal )
2125  {
2126  makeEnabled( &i_rBox );
2127 
2128  sal_Int64 nVal = i_rBox.get_value();
2129  pVal->Value <<= nVal;
2130 
2131  checkOptionalControlDependencies();
2132 
2133  // update preview and page settings
2134  maUpdatePreviewNoCacheIdle.Start();
2135  }
2136 }
2137 
2138 IMPL_LINK( PrintDialog, UIOption_EntryModifyHdl, weld::Entry&, i_rBox, void )
2139 {
2140  PropertyValue* pVal = getValueForWindow( &i_rBox );
2141  if( pVal )
2142  {
2143  makeEnabled( &i_rBox );
2144 
2145  OUString aVal( i_rBox.get_text() );
2146  pVal->Value <<= aVal;
2147 
2148  checkOptionalControlDependencies();
2149 
2150  // update preview and page settings
2151  maUpdatePreviewNoCacheIdle.Start();
2152  }
2153 }
2154 
2156 {
2157  sal_Int32 nValue = mxPageEdit->get_text().toInt32() + 1;
2158  if (nValue <= mnCachedPages)
2159  {
2160  mxPageEdit->set_text(OUString::number(nValue));
2161  ActivateHdl(*mxPageEdit);
2162  }
2163 }
2164 
2166 {
2167  sal_Int32 nValue = mxPageEdit->get_text().toInt32() - 1;
2168  if (nValue >= 1)
2169  {
2170  mxPageEdit->set_text(OUString::number(nValue));
2171  ActivateHdl(*mxPageEdit);
2172  }
2173 }
2174 
2176 {
2177  mxPageEdit->set_text("1");
2178  ActivateHdl(*mxPageEdit);
2179 }
2180 
2182 {
2183  mxPageEdit->set_text(OUString::number(mnCachedPages));
2184  ActivateHdl(*mxPageEdit);
2185 }
2186 
2187 
2188 static OUString getNewLabel(const OUString& aLabel, int i_nCurr, int i_nMax)
2189 {
2190  OUString aNewText( aLabel.replaceFirst( "%p", OUString::number( i_nCurr ) ) );
2191  aNewText = aNewText.replaceFirst( "%n", OUString::number( i_nMax ) );
2192 
2193  return aNewText;
2194 }
2195 
2196 // PrintProgressDialog
2198  : GenericDialogController(i_pParent, "vcl/ui/printprogressdialog.ui", "PrintProgressDialog")
2199  , mbCanceled(false)
2200  , mnCur(0)
2201  , mnMax(i_nMax)
2202  , mxText(m_xBuilder->weld_label("label"))
2203  , mxProgress(m_xBuilder->weld_progress_bar("progressbar"))
2204  , mxButton(m_xBuilder->weld_button("cancel"))
2205 {
2206  if( mnMax < 1 )
2207  mnMax = 1;
2208 
2209  maStr = mxText->get_label();
2210 
2211  //just multiply largest value by 10 and take the width of that string as
2212  //the max size we will want
2213  mxText->set_label(getNewLabel(maStr, mnMax * 10, mnMax * 10));
2214  mxText->set_size_request(mxText->get_preferred_size().Width(), -1);
2215 
2216  //Pick a useful max width
2217  mxProgress->set_size_request(mxProgress->get_approximate_digit_width() * 25, -1);
2218 
2219  mxButton->connect_clicked( LINK( this, PrintProgressDialog, ClickHdl ) );
2220 
2221  // after this patch f7157f04fab298423e2c4f6a7e5f8e361164b15f, we have seen the calc Max string (sometimes) look above
2222  // now init to the right start values
2223  mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
2224 }
2225 
2227 {
2228 }
2229 
2231 {
2232  mbCanceled = true;
2233 }
2234 
2235 void PrintProgressDialog::setProgress( int i_nCurrent )
2236 {
2237  mnCur = i_nCurrent;
2238 
2239  if( mnMax < 1 )
2240  mnMax = 1;
2241 
2242  mxText->set_label(getNewLabel(maStr, mnCur, mnMax));
2243 
2244  // here view the dialog, with the right label
2245  mxProgress->set_percentage(mnCur*100/mnMax);
2246 }
2247 
2249 {
2250  if( mnCur < mnMax )
2251  setProgress( ++mnCur );
2252 }
2253 
2254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< weld::Dialog > m_xDialog
Definition: weld.hxx:2331
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:795
PrintPreviewWindow(PrintDialog *pDialog)
Definition: printdlg.cxx:96
bool mbShowLayoutFrame
Definition: printdlg.hxx:221
void setPaperOrientation(Orientation eOrientation)
Definition: printdlg.cxx:1015
std::unique_ptr< weld::Widget > mxCustom
Definition: printdlg.hxx:192
std::unique_ptr< weld::CheckButton > mxBorderCB
border around each page
Definition: printdlg.hxx:189
OUString maPrintToFileText
Definition: printdlg.hxx:194
FieldUnit
std::unique_ptr< weld::Button > mxBackwardBtn
Definition: printdlg.hxx:153
std::unique_ptr< weld::ComboBox > mxNupPagesBox
Definition: printdlg.hxx:167
sal_Int32 NaturalSortCompare(const OUString &rA, const OUString &rB)
void SetFontSize(const Size &)
Definition: font/font.cxx:117
OUString maNoPageStr
Definition: printdlg.hxx:199
Size aSize
In 100th mm.
Definition: print.hxx:409
void previewBackward()
Definition: printdlg.cxx:2165
MoreOptionsDialog(PrintDialog *i_pParent)
Definition: printdlg.cxx:66
std::shared_ptr< PrinterController > maPController
Definition: printdlg.hxx:130
std::unique_ptr< weld::MetricSpinButton > mxPageMarginEdt
Definition: printdlg.hxx:175
std::unique_ptr< weld::RadioButton > mxBrochureBtn
Definition: printdlg.hxx:165
std::unique_ptr< weld::Builder > m_xBuilder
Definition: weld.hxx:2330
void setWidth(tools::Long nWidth)
DrawModeFlags
Definition: outdev.hxx:198
virtual ~PrintPreviewWindow() override
Definition: printdlg.cxx:109
void checkOptionalControlDependencies()
Definition: printdlg.cxx:1049
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Definition: map.cxx:1675
std::unique_ptr< weld::Button > mxHelpButton
Definition: printdlg.hxx:150
std::unique_ptr< weld::Button > mxFirstBtn
Definition: printdlg.hxx:155
void showAdvancedControls(bool)
Definition: printdlg.cxx:1284
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:1352
void doSloppyFit()
void updateNupFromPages(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1164
tools::Long getWidth() const
bool Scale(const Size &rNewSize, BmpScaleFlag nScaleFlag=BmpScaleFlag::Default)
Scale the bitmap.
Definition: bitmapex.cxx:366
void checkPaperSize(Size &rPaperSize)
Definition: printdlg.cxx:1003
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:41
std::unique_ptr< weld::ComboBox > mxNupOrderBox
Definition: printdlg.hxx:185
std::unique_ptr< weld::Label > mxPageMarginTxt2
Definition: printdlg.hxx:176
std::unique_ptr< weld::Button > mxForwardBtn
Definition: printdlg.hxx:154
long Long
void setPreview(const GDIMetaFile &, const Size &i_rPaperSize, const OUString &i_rPaperName, const OUString &i_rNoPageString, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, bool i_bGreyscale)
Definition: printdlg.cxx:250
Reference< XFrame > xFrame
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:706
std::unique_ptr< ShowNupOrderWindow > mxNupOrder
Definition: printdlg.hxx:186
std::unique_ptr< weld::RadioButton > mxPageRangesRadioButton
Definition: printdlg.hxx:144
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
Definition: decoview.cxx:837
PrintDialog * mpParent
Definition: printdlg.hxx:39
std::unique_ptr< weld::Expander > mxRangeExpander
Definition: printdlg.hxx:190
aBuf
static OUString GetDefaultPrinterName()
Definition: print.cxx:437
virtual ~PrintDialog() override
Definition: printdlg.cxx:718
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
Definition: builder.cxx:163
static void updatePrinters()
Checks the printer list and updates it necessary.
Definition: print.cxx:1577
std::unique_ptr< weld::Expander > mxLayoutExpander
Definition: printdlg.hxx:191
Idle maUpdatePreviewNoCacheIdle
Definition: printdlg.hxx:228
std::unique_ptr< weld::RadioButton > mxPagesBtn
Definition: printdlg.hxx:164
const CommandWheelData * GetWheelData() const
std::map< OUString, std::vector< weld::Widget * > > maPropertyToWindowMap
Definition: printdlg.hxx:212
std::unique_ptr< weld::CheckButton > mxReverseOrderBox
Definition: printdlg.hxx:146
void SetMapMode()
Definition: map.cxx:654
const vcl::Font & GetFieldFont() const
const Color & GetFieldTextColor() const
OUString maPrintText
Definition: printdlg.hxx:195
std::unique_ptr< weld::Button > mxCancelButton
Definition: printdlg.hxx:149
void makeEnabled(weld::Widget *)
Definition: printdlg.cxx:1700
virtual void Resize() override
Definition: printdlg.cxx:113
Everything running directly after painting.
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
Definition: svapp.cxx:1051
std::unique_ptr< weld::ComboBox > mxPaperSidesBox
Definition: printdlg.hxx:145
Paper
void previewForward()
Definition: printdlg.cxx:2155
DuplexMode
Definition: prntypes.hxx:28
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:440
void setProgress(int i_nCurrent)
Definition: printdlg.cxx:2235
void SetBackground()
std::vector< std::unique_ptr< weld::Widget > > maExtraControls
Definition: printdlg.hxx:207
virtual void show()=0
void updateOrientationBox(bool bAutomatic=true)
Definition: printdlg.cxx:980
const vcl::Font & GetLabelFont() const
const vcl::Font & GetFont() const
Definition: outdev.hxx:649
std::unique_ptr< weld::Button > mxSetupButton
Definition: printdlg.hxx:138
int nCount
Size const & getJobPageSize()
Definition: printdlg.cxx:505
virtual void Start() override
Activates the timer task.
Definition: idle.cxx:34
bool hasPreview() const
Definition: printdlg.cxx:1773
std::unique_ptr< weld::ComboBox > mxOrientationBox
Definition: printdlg.hxx:181
virtual void set_help_id(const OString &rName)=0
void Play(GDIMetaFile &rMtf)
Definition: gdimtf.cxx:325
virtual void set_tooltip_text(const OUString &rTip)=0
void initFromMultiPageSetup(const vcl::PrinterController::MultiPageSetup &)
Definition: printdlg.cxx:1071
PrintProgressDialog(weld::Window *i_pParent, int i_nMax)
Definition: printdlg.cxx:2197
B2IRange fround(const B2DRange &rRange)
Size maNupPortraitSize
Definition: printdlg.hxx:216
virtual void set_active(bool active)=0
std::unique_ptr< weld::Entry > mxPageRangeEdit
Definition: printdlg.hxx:143
bool SetPaperSizeUser(const Size &rSize)
Definition: print.cxx:1318
std::unique_ptr< weld::CheckButton > mxSingleJobsBox
Definition: printdlg.hxx:42
tools::Long getHeight() const
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:40
std::unique_ptr< weld::ComboBox > mxPrinters
Definition: printdlg.hxx:136
std::unique_ptr< weld::SpinButton > mxNupRowsEdt
Definition: printdlg.hxx:173
void updatePrinterText()
Definition: printdlg.cxx:881
std::unique_ptr< weld::CustomWeld > mxPreviewWindow
Definition: printdlg.hxx:161
void storeToSettings()
Definition: printdlg.cxx:738
std::unique_ptr< weld::ProgressBar > mxProgress
Definition: printdlg.hxx:281
bool IsEmpty() const
int i
void setValue(const OUString &rGroup, const OUString &rKey, const OUString &rValue)
virtual bool Command(const CommandEvent &) override
Definition: printdlg.cxx:236
OUString maDefPrtText
Definition: printdlg.hxx:196
void setPreviewText()
Definition: printdlg.cxx:899
std::unique_ptr< weld::Label > mxSheetMarginTxt2
Definition: printdlg.hxx:179
std::unique_ptr< weld::SpinButton > mxCopyCountField
Definition: printdlg.hxx:140
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:192
void setupOptionalUI()
Definition: printdlg.cxx:1315
std::unique_ptr< weld::Button > mxLastBtn
Definition: printdlg.hxx:156
void checkControlDependencies()
Definition: printdlg.cxx:1033
bool hasOrientationChanged() const
Definition: printdlg.cxx:993
void setPaperSizes()
Definition: printdlg.cxx:836
std::unique_ptr< weld::Notebook > mxTabCtrl
Definition: printdlg.hxx:134
virtual bool Start(const OUString &rHelpId, const vcl::Window *pWindow)
Definition: help.cxx:53
tools::Long Width() const
AntialiasingFlags
Definition: outdev.hxx:229
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:302
virtual ~MoreOptionsDialog() override
Definition: printdlg.cxx:79
CommandEventId GetCommand() const
float u
void SetTextColor(const Color &rColor)
Definition: text.cxx:666
bool mbCollateAlwaysOff
Definition: printdlg.hxx:204
Reference< text::XText > mxText
std::unique_ptr< weld::Label > mxNumPagesText
Definition: printdlg.hxx:159
bool isPrintToFile() const
Definition: printdlg.cxx:1763
const LocaleDataWrapper & GetLocaleDataWrapper(LanguageType nLang)
OUString getValue(const OUString &rGroup, const OUString &rKey) const
std::unique_ptr< weld::CheckButton > mxCollateBox
Definition: printdlg.hxx:141
void Move(tools::Long nX, tools::Long nY)
Definition: gdimtf.cxx:634
virtual void set_active(int pos)=0
const AllSettings & GetSettings() const
Definition: outdev.hxx:418
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:230
std::unique_ptr< weld::Builder > mxCustomOptionsUIBuilder
Definition: printdlg.hxx:128
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: printdlg.cxx:150
void WindStart()
Definition: gdimtf.cxx:553
Idle maUpdatePreviewIdle
Definition: printdlg.hxx:226
std::unique_ptr< weld::CheckButton > mxPreviewBox
Definition: printdlg.hxx:158
Paper getPaper() const
std::unique_ptr< weld::Label > mxNupNumPagesTxt
Definition: printdlg.hxx:170
sal_Int32 mnCurPage
Definition: printdlg.hxx:201
std::unique_ptr< weld::Label > mxPageMarginTxt1
Definition: printdlg.hxx:174
std::unique_ptr< weld::Frame > mxPageLayoutFrame
Definition: printdlg.hxx:135
void DrawSeparator(const Point &rStart, const Point &rStop, bool bVertical=true)
Definition: decoview.cxx:1010
std::map< weld::Widget *, OUString > maControlToPropertyMap
Definition: printdlg.hxx:210
std::unique_ptr< weld::Entry > mxPageEdit
Definition: printdlg.hxx:162
sal_Int32 mnCachedPages
Definition: printdlg.hxx:202
static const std::vector< OUString > & GetPrinterQueues()
Definition: print.cxx:399
bool isSingleJobs() const
Definition: printdlg.hxx:117
RegionData_Impl * mpParent
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
std::unique_ptr< weld::Label > mxStatusTxt
Definition: printdlg.hxx:137
A construction helper for a temporary VclPtr.
Definition: vclptr.hxx:275
OUString aPageText
Size maNupLandscapeSize
Definition: printdlg.hxx:217
void Erase()
Definition: wallpaper.cxx:103
void readFromSettings()
Definition: printdlg.cxx:777
A widget used to choose from a list of items.
Definition: weld.hxx:596
std::unique_ptr< weld::Label > mxPagesBoxTitleTxt
Definition: printdlg.hxx:166
weld::Entry & rEdit
bool isCollate() const
Definition: printdlg.cxx:1768
const OUString & GetPrinterName() const
Definition: QueueInfo.cxx:28
void updateWindowFromProperty(const OUString &)
Definition: printdlg.cxx:1711
#define SAL_WARN_IF(condition, area, stream)
css::beans::PropertyValue * getValueForWindow(weld::Widget *) const
Definition: printdlg.cxx:1778
void enableNupControls(bool bEnable)
Definition: printdlg.cxx:1265
bool bIsEnabled
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: printdlg.cxx:157
void SetFont(const vcl::Font &rNewFont)
std::unique_ptr< weld::CustomWeld > mxNupOrderWin
Definition: printdlg.hxx:187
bool SetOrientation(Orientation eOrient)
Definition: print.cxx:1125
void updateNup(bool i_bMayUseCache=true)
Definition: printdlg.cxx:1108
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:903
static OUString getNewLabel(const OUString &aLabel, int i_nCurr, int i_nMax)
Definition: printdlg.cxx:2188
std::unique_ptr< PrintPreviewWindow > mxPreview
Definition: printdlg.hxx:160
virtual int get_text_height() const =0
std::unique_ptr< weld::MetricSpinButton > mxSheetMarginEdt
Definition: printdlg.hxx:178
tools::Long AdjustWidth(tools::Long n)
std::unique_ptr< weld::Label > mxNupOrderTxt
Definition: printdlg.hxx:184
std::unique_ptr< weld::Label > mxSheetMarginTxt1
Definition: printdlg.hxx:177
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:892
Reference< XExecutableDialog > m_xDialog
void Scale(double fScaleX, double fScaleY)
Definition: gdimtf.cxx:711
tools::Long Height() const
std::unique_ptr< weld::Image > mxCollateImage
Definition: printdlg.hxx:142
Orientation
Definition: prntypes.hxx:31
std::unique_ptr< weld::Button > mxMoreOptionsBtn
Definition: printdlg.hxx:151
std::unique_ptr< weld::Label > mxNupTimesTxt
Definition: printdlg.hxx:172
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
static const QueueInfo * GetQueueInfo(const OUString &rPrinterName, bool bStatusUpdate)
Definition: print.cxx:407
std::unique_ptr< weld::Button > mxOKButton
Definition: printdlg.hxx:148
tools::Long AdjustHeight(tools::Long n)
OUString maPageStr
Definition: printdlg.hxx:198
std::map< weld::Widget *, sal_Int32 > maControlToNumValMap
Definition: printdlg.hxx:214
std::unique_ptr< weld::ComboBox > mxPaperSizeBox
Definition: printdlg.hxx:180
IMPL_LINK(ORoadmap, ImplClickHdl, HyperLabel *, CurHyperLabel, void)
Definition: roadmap.cxx:631
std::unique_ptr< weld::Button > mxButton
Definition: printdlg.hxx:282
void setHeight(tools::Long nHeight)
Paper GetPaper() const
Definition: print.cxx:1467
tools::Long GetDelta() const
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
MapUnit
void setupPaperSidesBox()
Definition: printdlg.cxx:722
#define SAL_WARN(area, stream)
OUString VclResId(const char *pId)
Definition: svdata.cxx:267
Definition: timer.hxx:26
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:608
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
OUString maNoPreviewStr
Definition: printdlg.hxx:200
static OUString GetPaperName(Paper ePaper)
Definition: print.cxx:1385
tuple m
NupOrderType
Definition: print.hxx:370
std::unique_ptr< weld::SpinButton > mxNupColEdt
Definition: printdlg.hxx:171
bool bFullPaper
Full paper, not only imageable area is printed.
Definition: print.hxx:412
static SettingsConfigItem * get()
Size maFirstPageSize
internal, used for automatic Nup-Portrait/landscape
Definition: printdlg.hxx:219
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
PAPER_USER
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
void preparePreview(bool i_bMayUseCache)
Definition: printdlg.cxx:915
virtual ~PrintProgressDialog() override
Definition: printdlg.cxx:2226
sal_Int16 nValue
GenericDialogController(weld::Widget *pParent, const OUString &rUIFile, const OString &rDialogId, bool bMobile=false)
Definition: weldutils.cxx:47
MeasurementSystem getMeasurementSystemEnum() const
std::unique_ptr< weld::Label > mxText
Definition: printdlg.hxx:280
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)