LibreOffice Module vcl (master)  1
print.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 <sal/types.h>
21 #include <sal/log.hxx>
22 
23 #include <tools/helpers.hxx>
24 #include <tools/debug.hxx>
25 
26 #include <vcl/QueueInfo.hxx>
27 #include <vcl/event.hxx>
28 #include <vcl/virdev.hxx>
29 #include <vcl/print.hxx>
30 
32 
33 #include <salinst.hxx>
34 #include <salvd.hxx>
35 #include <salgdi.hxx>
36 #include <salptype.hxx>
37 #include <salprn.hxx>
38 #include <svdata.hxx>
39 #include <print.hrc>
40 #include <jobset.h>
41 #include <outdev.h>
43 #include <print.h>
44 
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/configuration/theDefaultProvider.hpp>
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/uno/Sequence.h>
50 
52 
53 namespace
54 {
55  Paper ImplGetPaperFormat( tools::Long nWidth100thMM, tools::Long nHeight100thMM )
56  {
57  PaperInfo aInfo(nWidth100thMM, nHeight100thMM);
58  aInfo.doSloppyFit();
59  return aInfo.getPaper();
60  }
61 
62  const PaperInfo& ImplGetEmptyPaper()
63  {
64  static PaperInfo aInfo(PAPER_USER);
65  return aInfo;
66  }
67 }
68 
70 {
71  const ImplJobSetup& rConstData = rJobSetup.ImplGetConstData();
72 
73  if ( !rConstData.GetPaperWidth() || !rConstData.GetPaperHeight() )
74  {
75  if ( rConstData.GetPaperFormat() != PAPER_USER )
76  {
77  PaperInfo aInfo(rConstData.GetPaperFormat());
78 
79  ImplJobSetup& rData = rJobSetup.ImplGetData();
80  rData.SetPaperWidth( aInfo.getWidth() );
81  rData.SetPaperHeight( aInfo.getHeight() );
82  }
83  }
84  else if ( rConstData.GetPaperFormat() == PAPER_USER )
85  {
86  Paper ePaper = ImplGetPaperFormat( rConstData.GetPaperWidth(), rConstData.GetPaperHeight() );
87  if ( ePaper != PAPER_USER )
88  rJobSetup.ImplGetData().SetPaperFormat(ePaper);
89  }
90 }
91 
92 // PrinterOptions
93 PrinterOptions::PrinterOptions() :
94  mbReduceTransparency( false ),
95  meReducedTransparencyMode( PrinterTransparencyMode::Auto ),
96  mbReduceGradients( false ),
97  meReducedGradientsMode( PrinterGradientMode::Stripes ),
98  mnReducedGradientStepCount( 64 ),
99  mbReduceBitmaps( false ),
100  meReducedBitmapMode( PrinterBitmapMode::Normal ),
101  mnReducedBitmapResolution( 200 ),
102  mbReducedBitmapsIncludeTransparency( true ),
103  mbConvertToGreyscales( false ),
104  mbPDFAsStandardPrintJobFormat( false )
105 {
106 }
107 
108 void PrinterOptions::ReadFromConfig( bool i_bFile )
109 {
110  bool bSuccess = false;
111  // save old state in case something goes wrong
112  PrinterOptions aOldValues( *this );
113 
114  // get the configuration service
115  css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider;
116  css::uno::Reference< css::container::XNameAccess > xConfigAccess;
117  try
118  {
119  // get service provider
120  css::uno::Reference< css::uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
121  // create configuration hierarchical access name
122  try
123  {
124  xConfigProvider = css::configuration::theDefaultProvider::get( xContext );
125 
126  css::beans::PropertyValue aVal;
127  aVal.Name = "nodepath";
128  if( i_bFile )
129  aVal.Value <<= OUString( "/org.openoffice.Office.Common/Print/Option/File" );
130  else
131  aVal.Value <<= OUString( "/org.openoffice.Office.Common/Print/Option/Printer" );
132  xConfigAccess.set(
133  xConfigProvider->createInstanceWithArguments(
134  "com.sun.star.configuration.ConfigurationAccess", { css::uno::Any(aVal) } ),
135  css::uno::UNO_QUERY );
136  if( xConfigAccess.is() )
137  {
138  css::uno::Reference< css::beans::XPropertySet > xSet( xConfigAccess, css::uno::UNO_QUERY );
139  if( xSet.is() )
140  {
141  sal_Int32 nValue = 0;
142  bool bValue = false;
143  if( xSet->getPropertyValue("ReduceTransparency") >>= bValue )
144  SetReduceTransparency( bValue );
145  if( xSet->getPropertyValue("ReducedTransparencyMode") >>= nValue )
146  SetReducedTransparencyMode( static_cast<PrinterTransparencyMode>(nValue) );
147  if( xSet->getPropertyValue("ReduceGradients") >>= bValue )
148  SetReduceGradients( bValue );
149  if( xSet->getPropertyValue("ReducedGradientMode") >>= nValue )
150  SetReducedGradientMode( static_cast<PrinterGradientMode>(nValue) );
151  if( xSet->getPropertyValue("ReducedGradientStepCount") >>= nValue )
152  SetReducedGradientStepCount( static_cast<sal_uInt16>(nValue) );
153  if( xSet->getPropertyValue("ReduceBitmaps") >>= bValue )
154  SetReduceBitmaps( bValue );
155  if( xSet->getPropertyValue("ReducedBitmapMode") >>= nValue )
156  SetReducedBitmapMode( static_cast<PrinterBitmapMode>(nValue) );
157  if( xSet->getPropertyValue("ReducedBitmapResolution") >>= nValue )
158  SetReducedBitmapResolution( static_cast<sal_uInt16>(nValue) );
159  if( xSet->getPropertyValue("ReducedBitmapIncludesTransparency") >>= bValue )
160  SetReducedBitmapIncludesTransparency( bValue );
161  if( xSet->getPropertyValue("ConvertToGreyscales") >>= bValue )
162  SetConvertToGreyscales( bValue );
163  if( xSet->getPropertyValue("PDFAsStandardPrintJobFormat") >>= bValue )
164  SetPDFAsStandardPrintJobFormat( bValue );
165 
166  bSuccess = true;
167  }
168  }
169  }
170  catch( const css::uno::Exception& )
171  {
172  }
173  }
174  catch( const css::lang::WrappedTargetException& )
175  {
176  }
177 
178  if( ! bSuccess )
179  *this = aOldValues;
180 }
181 
182 void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
183  const Point& rDestPt, const Size& rDestSize,
184  const Point& rSrcPtPixel, const Size& rSrcSizePixel )
185 {
186  Point aDestPt( LogicToPixel( rDestPt ) );
187  Size aDestSz( LogicToPixel( rDestSize ) );
188  tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
189 
190  aSrcRect.Justify();
191 
192  if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() )
193  return;
194 
195  Bitmap aPaint( rBmp ), aMask( rMask );
197 
200 
201  // mirrored horizontally
202  if( aDestSz.Width() < 0 )
203  {
204  aDestSz.setWidth( -aDestSz.Width() );
205  aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
206  nMirrFlags |= BmpMirrorFlags::Horizontal;
207  }
208 
209  // mirrored vertically
210  if( aDestSz.Height() < 0 )
211  {
212  aDestSz.setHeight( -aDestSz.Height() );
213  aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
214  nMirrFlags |= BmpMirrorFlags::Vertical;
215  }
216 
217  // source cropped?
218  if( aSrcRect != tools::Rectangle( Point(), aPaint.GetSizePixel() ) )
219  {
220  aPaint.Crop( aSrcRect );
221  aMask.Crop( aSrcRect );
222  }
223 
224  // destination mirrored
225  if( nMirrFlags != BmpMirrorFlags::NONE )
226  {
227  aPaint.Mirror( nMirrFlags );
228  aMask.Mirror( nMirrFlags );
229  }
230 
231  // we always want to have a mask
232  if( aMask.IsEmpty() )
233  {
234  aMask = Bitmap(aSrcRect.GetSize(), vcl::PixelFormat::N1_BPP);
235  aMask.Erase( COL_BLACK );
236  }
237 
238  // do painting
239  const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
240  tools::Long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
241  std::unique_ptr<tools::Long[]> pMapX(new tools::Long[ nSrcWidth + 1 ]);
242  std::unique_ptr<tools::Long[]> pMapY(new tools::Long[ nSrcHeight + 1 ]);
243  const bool bOldMap = mbMap;
244 
245  mbMap = false;
246 
247  // create forward mapping tables
248  for( nX = 0; nX <= nSrcWidth; nX++ )
249  pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
250 
251  for( nY = 0; nY <= nSrcHeight; nY++ )
252  pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight );
253 
254  // walk through all rectangles of mask
255  const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
256  RectangleVector aRectangles;
257  aWorkRgn.GetRegionRectangles(aRectangles);
258 
259  for (auto const& rectangle : aRectangles)
260  {
261  const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
262  const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
263  pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
264  Bitmap aBandBmp(aPaint);
265 
266  aBandBmp.Crop(rectangle);
267  DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
268  }
269 
270  mbMap = bOldMap;
271 
272 }
273 
275  const basegfx::B2DHomMatrix& /*aFullTransform*/,
276  const BitmapEx& /*rBitmapEx*/,
277  double /*fAlpha*/)
278 {
279  // printers can't draw bitmaps directly
280  return false;
281 }
282 
284  const basegfx::B2DHomMatrix& /*aFullTransform*/,
285  basegfx::B2DRange& /*aVisibleRange*/,
286  double& /*fMaximumArea*/)
287 {
288  // deliberately do nothing - you can't reduce the
289  // target range for a printer at all
290  return true;
291 }
292 
293 void Printer::DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize,
294  const Point& rSrcPtPixel, const Size& rSrcSizePixel,
295  BitmapEx& rBmpEx )
296 {
297  if( rBmpEx.IsAlpha() )
298  {
299  // #107169# For true alpha bitmaps, no longer masking the
300  // bitmap, but perform a full alpha blend against a white
301  // background here.
302  Bitmap aBmp( rBmpEx.GetBitmap() );
303  aBmp.Blend( rBmpEx.GetAlpha(), COL_WHITE );
304  DrawBitmap( rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel, aBmp );
305  }
306  else
307  {
308  Bitmap aBmp( rBmpEx.GetBitmap() );
309  ImplPrintTransparent( aBmp, Bitmap(), rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel );
310  }
311 }
312 
314  sal_uInt16 nTransparencePercent )
315 {
316  // #110958# Disable alpha VDev, we perform the necessary
317  VirtualDevice* pOldAlphaVDev = mpAlphaVDev;
318 
319  // operation explicitly further below.
320  if( mpAlphaVDev )
321  mpAlphaVDev = nullptr;
322 
323  GDIMetaFile* pOldMetaFile = mpMetaFile;
324  mpMetaFile = nullptr;
325 
326  mpMetaFile = pOldMetaFile;
327 
328  // #110958# Restore disabled alpha VDev
329  mpAlphaVDev = pOldAlphaVDev;
330 
331  tools::Rectangle aPolyRect( LogicToPixel( rPolyPoly ).GetBoundRect() );
332  const Size aDPISize( LogicToPixel(Size(1, 1), MapMode(MapUnit::MapInch)) );
333  const tools::Long nBaseExtent = std::max<tools::Long>( FRound( aDPISize.Width() / 300. ), 1 );
334  tools::Long nMove;
335  const sal_uInt16 nTrans = ( nTransparencePercent < 13 ) ? 0 :
336  ( nTransparencePercent < 38 ) ? 25 :
337  ( nTransparencePercent < 63 ) ? 50 :
338  ( nTransparencePercent < 88 ) ? 75 : 100;
339 
340  switch( nTrans )
341  {
342  case 25: nMove = nBaseExtent * 3; break;
343  case 50: nMove = nBaseExtent * 4; break;
344  case 75: nMove = nBaseExtent * 6; break;
345 
346  // #i112959# very transparent (88 < nTransparencePercent <= 99)
347  case 100: nMove = nBaseExtent * 8; break;
348 
349  // #i112959# not transparent (nTransparencePercent < 13)
350  default: nMove = 0; break;
351  }
352 
354  IntersectClipRegion(vcl::Region(rPolyPoly));
356  const bool bOldMap = mbMap;
357  EnableMapMode( false );
358 
359  if(nMove)
360  {
361  tools::Rectangle aRect( aPolyRect.TopLeft(), Size( aPolyRect.GetWidth(), nBaseExtent ) );
362  while( aRect.Top() <= aPolyRect.Bottom() )
363  {
364  DrawRect( aRect );
365  aRect.Move( 0, nMove );
366  }
367 
368  aRect = tools::Rectangle( aPolyRect.TopLeft(), Size( nBaseExtent, aPolyRect.GetHeight() ) );
369  while( aRect.Left() <= aPolyRect.Right() )
370  {
371  DrawRect( aRect );
372  aRect.Move( nMove, 0 );
373  }
374  }
375  else
376  {
377  // #i112959# if not transparent, draw full rectangle in clip region
378  DrawRect( aPolyRect );
379  }
380 
381  EnableMapMode( bOldMap );
382  Pop();
383 
384  mpMetaFile = pOldMetaFile;
385 
386  // #110958# Restore disabled alpha VDev
387  mpAlphaVDev = pOldAlphaVDev;
388 }
389 
390 void Printer::DrawOutDev( const Point& /*rDestPt*/, const Size& /*rDestSize*/,
391  const Point& /*rSrcPt*/, const Size& /*rSrcSize*/ )
392 {
393  SAL_WARN( "vcl.gdi", "Don't use OutputDevice::DrawOutDev(...) with printer devices!" );
394 }
395 
396 void Printer::DrawOutDev( const Point& /*rDestPt*/, const Size& /*rDestSize*/,
397  const Point& /*rSrcPt*/, const Size& /*rSrcSize*/,
398  const OutputDevice& /*rOutDev*/ )
399 {
400  SAL_WARN( "vcl.gdi", "Don't use OutputDevice::DrawOutDev(...) with printer devices!" );
401 }
402 
403 void Printer::CopyArea( const Point& /*rDestPt*/,
404  const Point& /*rSrcPt*/, const Size& /*rSrcSize*/,
405  bool /*bWindowInvalidate*/ )
406 {
407  SAL_WARN( "vcl.gdi", "Don't use OutputDevice::CopyArea(...) with printer devices!" );
408 }
409 
411 {
412  Point aPageOffset = Point( 0, 0 ) - this->GetPageOffsetPixel();
413  Size aSize = this->GetPaperSizePixel();
414  return tools::Rectangle( aPageOffset, aSize );
415 }
416 
417 void Printer::SetPrinterOptions( const PrinterOptions& i_rOptions )
418 {
419  *mpPrinterOptions = i_rOptions;
420 }
421 
423 {
424  // due to a "hotfix" for AOO bug i55719, this needs to return false
425  return false;
426 }
427 
429 {
432 }
433 
435 {
436 }
437 
439 {
440 }
441 
442 void ImplPrnQueueList::Add( std::unique_ptr<SalPrinterQueueInfo> pData )
443 {
444  std::unordered_map< OUString, sal_Int32 >::iterator it =
445  m_aNameToIndex.find( pData->maPrinterName );
446  if( it == m_aNameToIndex.end() )
447  {
448  m_aNameToIndex[ pData->maPrinterName ] = m_aQueueInfos.size();
449  m_aPrinterList.push_back( pData->maPrinterName );
450  m_aQueueInfos.push_back( ImplPrnQueueData() );
451  m_aQueueInfos.back().mpQueueInfo = nullptr;
452  m_aQueueInfos.back().mpSalQueueInfo = std::move(pData);
453  }
454  else // this should not happen, but ...
455  {
456  ImplPrnQueueData& rData = m_aQueueInfos[ it->second ];
457  rData.mpQueueInfo.reset();
458  rData.mpSalQueueInfo = std::move(pData);
459  }
460 }
461 
462 ImplPrnQueueData* ImplPrnQueueList::Get( const OUString& rPrinter )
463 {
464  ImplPrnQueueData* pData = nullptr;
465  std::unordered_map<OUString,sal_Int32>::iterator it =
466  m_aNameToIndex.find( rPrinter );
467  if( it != m_aNameToIndex.end() )
468  pData = &m_aQueueInfos[it->second];
469  return pData;
470 }
471 
472 static void ImplInitPrnQueueList()
473 {
474  ImplSVData* pSVData = ImplGetSVData();
475 
476  pSVData->maGDIData.mpPrinterQueueList.reset(new ImplPrnQueueList);
477 
478  static const char* pEnv = getenv( "SAL_DISABLE_PRINTERLIST" );
479  if( !pEnv || !*pEnv )
480  pSVData->mpDefInst->GetPrinterQueueInfo( pSVData->maGDIData.mpPrinterQueueList.get() );
481 }
482 
484 {
485  ImplSVData* pSVData = ImplGetSVData();
486  pSVData->maGDIData.mpPrinterQueueList.reset();
487 }
488 
489 const std::vector<OUString>& Printer::GetPrinterQueues()
490 {
491  ImplSVData* pSVData = ImplGetSVData();
492  if ( !pSVData->maGDIData.mpPrinterQueueList )
494  return pSVData->maGDIData.mpPrinterQueueList->m_aPrinterList;
495 }
496 
497 const QueueInfo* Printer::GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate )
498 {
499  ImplSVData* pSVData = ImplGetSVData();
500 
501  if ( !pSVData->maGDIData.mpPrinterQueueList )
503 
504  if ( !pSVData->maGDIData.mpPrinterQueueList )
505  return nullptr;
506 
507  ImplPrnQueueData* pInfo = pSVData->maGDIData.mpPrinterQueueList->Get( rPrinterName );
508  if( pInfo )
509  {
510  if( !pInfo->mpQueueInfo || bStatusUpdate )
511  pSVData->mpDefInst->GetPrinterQueueState( pInfo->mpSalQueueInfo.get() );
512 
513  if ( !pInfo->mpQueueInfo )
514  pInfo->mpQueueInfo.reset(new QueueInfo);
515 
516  pInfo->mpQueueInfo->maPrinterName = pInfo->mpSalQueueInfo->maPrinterName;
517  pInfo->mpQueueInfo->maDriver = pInfo->mpSalQueueInfo->maDriver;
518  pInfo->mpQueueInfo->maLocation = pInfo->mpSalQueueInfo->maLocation;
519  pInfo->mpQueueInfo->maComment = pInfo->mpSalQueueInfo->maComment;
520  pInfo->mpQueueInfo->mnStatus = pInfo->mpSalQueueInfo->mnStatus;
521  pInfo->mpQueueInfo->mnJobs = pInfo->mpSalQueueInfo->mnJobs;
522  return pInfo->mpQueueInfo.get();
523  }
524  return nullptr;
525 }
526 
528 {
529  static const char* pEnv = getenv( "SAL_DISABLE_DEFAULTPRINTER" );
530  if( !pEnv || !*pEnv )
531  {
532  ImplSVData* pSVData = ImplGetSVData();
533 
534  return pSVData->mpDefInst->GetDefaultPrinter();
535  }
536  return OUString();
537 }
538 
540 {
541  mbDevOutput = false;
542  mbDefPrinter = false;
544  mnPageQueueSize = 0;
545  mnCopyCount = 1;
546  mbCollateCopy = false;
547  mbPrinting = false;
548  mbJobActive = false;
549  mbPrintFile = false;
550  mbInPrintPage = false;
551  mbNewJobSetup = false;
552  mbSinglePrintJobs = false;
553  mpInfoPrinter = nullptr;
554  mpPrinter = nullptr;
555  mpDisplayDev = nullptr;
556  mpPrinterOptions.reset(new PrinterOptions);
557 
558  // Add printer to the list
559  ImplSVData* pSVData = ImplGetSVData();
560  mpNext = pSVData->maGDIData.mpFirstPrinter;
561  mpPrev = nullptr;
562  if ( mpNext )
563  mpNext->mpPrev = this;
564  pSVData->maGDIData.mpFirstPrinter = this;
565 }
566 
568 {
570 
571  if ( mpGraphics )
572  return true;
573 
574  mbInitLineColor = true;
575  mbInitFillColor = true;
576  mbInitFont = true;
577  mbInitTextColor = true;
578  mbInitClipRegion = true;
579 
580  ImplSVData* pSVData = ImplGetSVData();
581 
582  if ( mpJobGraphics )
584  else if ( mpDisplayDev )
585  {
586  const VirtualDevice* pVirDev = mpDisplayDev;
587  mpGraphics = pVirDev->mpVirDev->AcquireGraphics();
588  // if needed retry after releasing least recently used virtual device graphics
589  while ( !mpGraphics )
590  {
591  if ( !pSVData->maGDIData.mpLastVirGraphics )
592  break;
594  mpGraphics = pVirDev->mpVirDev->AcquireGraphics();
595  }
596  // update global LRU list of virtual device graphics
597  if ( mpGraphics )
598  {
600  pSVData->maGDIData.mpFirstVirGraphics = const_cast<Printer*>(this);
601  if ( mpNextGraphics )
602  mpNextGraphics->mpPrevGraphics = const_cast<Printer*>(this);
603  if ( !pSVData->maGDIData.mpLastVirGraphics )
604  pSVData->maGDIData.mpLastVirGraphics = const_cast<Printer*>(this);
605  }
606  }
607  else
608  {
610  // if needed retry after releasing least recently used printer graphics
611  while ( !mpGraphics )
612  {
613  if ( !pSVData->maGDIData.mpLastPrnGraphics )
614  break;
617  }
618  // update global LRU list of printer graphics
619  if ( mpGraphics )
620  {
622  pSVData->maGDIData.mpFirstPrnGraphics = const_cast<Printer*>(this);
623  if ( mpNextGraphics )
624  mpNextGraphics->mpPrevGraphics = const_cast<Printer*>(this);
625  if ( !pSVData->maGDIData.mpLastPrnGraphics )
626  pSVData->maGDIData.mpLastPrnGraphics = const_cast<Printer*>(this);
627  }
628  }
629 
630  if ( mpGraphics )
631  {
634  }
635 
636  return mpGraphics != nullptr;
637 }
638 
640 {
641 #ifdef UNX
642  // HACK to fix an urgent P1 printing issue fast
643  // WinSalPrinter does not respect GetGraphics/ReleaseGraphics conventions
644  // so Printer::mpGraphics often points to a dead WinSalGraphics
645  // TODO: fix WinSalPrinter's GetGraphics/ReleaseGraphics handling
647 #endif
648  mbNewFont = true;
649  mbInitFont = true;
650 
651  mpFontInstance.clear();
652  mpDeviceFontList.reset();
653  mpDeviceFontSizeList.reset();
654 }
655 
656 void Printer::ReleaseGraphics( bool bRelease )
657 {
659 
660  if ( !mpGraphics )
661  return;
662 
663  // release the fonts of the physically released graphics device
664  if( bRelease )
666 
667  ImplSVData* pSVData = ImplGetSVData();
668 
669  Printer* pPrinter = this;
670 
671  if ( !pPrinter->mpJobGraphics )
672  {
673  if ( pPrinter->mpDisplayDev )
674  {
675  VirtualDevice* pVirDev = pPrinter->mpDisplayDev;
676  if ( bRelease )
677  pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
678  // remove from global LRU list of virtual device graphics
679  if ( mpPrevGraphics )
681  else
683  if ( mpNextGraphics )
685  else
687  }
688  else
689  {
690  if ( bRelease )
692  // remove from global LRU list of printer graphics
693  if ( mpPrevGraphics )
695  else
696  pSVData->maGDIData.mpFirstPrnGraphics = static_cast<Printer*>(mpNextGraphics.get());
697  if ( mpNextGraphics )
699  else
700  pSVData->maGDIData.mpLastPrnGraphics = static_cast<Printer*>(mpPrevGraphics.get());
701  }
702  }
703 
704  mpGraphics = nullptr;
705  mpPrevGraphics = nullptr;
706  mpNextGraphics = nullptr;
707 }
708 
710 {
711  ImplSVData* pSVData = ImplGetSVData();
712  // #i74084# update info for this specific SalPrinterQueueInfo
713  pSVData->mpDefInst->GetPrinterQueueState( pInfo );
714 
715  // Test whether the driver actually matches the JobSetup
717  if ( rData.GetDriverData() )
718  {
719  if ( rData.GetPrinterName() != pInfo->maPrinterName ||
720  rData.GetDriver() != pInfo->maDriver )
721  {
722  std::free( const_cast<sal_uInt8*>(rData.GetDriverData()) );
723  rData.SetDriverData(nullptr);
724  rData.SetDriverDataLen(0);
725  }
726  }
727 
728  // Remember printer name
729  maPrinterName = pInfo->maPrinterName;
730  maDriver = pInfo->maDriver;
731 
732  // Add printer name to JobSetup
733  rData.SetPrinterName( maPrinterName );
734  rData.SetDriver( maDriver );
735 
736  mpInfoPrinter = pSVData->mpDefInst->CreateInfoPrinter( pInfo, &rData );
737  mpPrinter = nullptr;
738  mpJobGraphics = nullptr;
740 
741  if ( !mpInfoPrinter )
742  {
743  ImplInitDisplay();
744  return;
745  }
746 
747  // we need a graphics
748  if ( !AcquireGraphics() )
749  {
750  ImplInitDisplay();
751  return;
752  }
753 
754  // Init data
756  mxFontCollection = std::make_shared<PhysicalFontCollection>();
757  mxFontCache = std::make_shared<ImplFontCache>();
759 }
760 
762 {
763  ImplSVData* pSVData = ImplGetSVData();
764 
765  mpInfoPrinter = nullptr;
766  mpPrinter = nullptr;
767  mpJobGraphics = nullptr;
768 
772  mnDPIX = mpDisplayDev->mnDPIX;
773  mnDPIY = mpDisplayDev->mnDPIY;
774 }
775 
776 void Printer::DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor,
777  const Point& rDestPt, const Size& rDestSize,
778  const Point& rSrcPtPixel, const Size& rSrcSizePixel )
779 {
780  Point aDestPt( LogicToPixel( rDestPt ) );
781  Size aDestSz( LogicToPixel( rDestSize ) );
782  tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
783 
784  aSrcRect.Justify();
785 
786  if( !(!rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height()) )
787  return;
788 
789  Bitmap aMask( rMask );
791 
794 
795  // mirrored horizontally
796  if( aDestSz.Width() < 0 )
797  {
798  aDestSz.setWidth( -aDestSz.Width() );
799  aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
800  nMirrFlags |= BmpMirrorFlags::Horizontal;
801  }
802 
803  // mirrored vertically
804  if( aDestSz.Height() < 0 )
805  {
806  aDestSz.setHeight( -aDestSz.Height() );
807  aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
808  nMirrFlags |= BmpMirrorFlags::Vertical;
809  }
810 
811  // source cropped?
812  if( aSrcRect != tools::Rectangle( Point(), aMask.GetSizePixel() ) )
813  aMask.Crop( aSrcRect );
814 
815  // destination mirrored
816  if( nMirrFlags != BmpMirrorFlags::NONE)
817  aMask.Mirror( nMirrFlags );
818 
819  // do painting
820  const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
821  tools::Long nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight;
822  std::unique_ptr<tools::Long[]> pMapX( new tools::Long[ nSrcWidth + 1 ] );
823  std::unique_ptr<tools::Long[]> pMapY( new tools::Long[ nSrcHeight + 1 ] );
824  GDIMetaFile* pOldMetaFile = mpMetaFile;
825  const bool bOldMap = mbMap;
826 
827  mpMetaFile = nullptr;
828  mbMap = false;
830  SetLineColor( rMaskColor );
831  SetFillColor( rMaskColor );
832  InitLineColor();
833  InitFillColor();
834 
835  // create forward mapping tables
836  for( nX = 0; nX <= nSrcWidth; nX++ )
837  pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
838 
839  for( nY = 0; nY <= nSrcHeight; nY++ )
840  pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight );
841 
842  // walk through all rectangles of mask
843  const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel())));
844  RectangleVector aRectangles;
845  aWorkRgn.GetRegionRectangles(aRectangles);
846 
847  for (auto const& rectangle : aRectangles)
848  {
849  const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]);
850  const Size aMapSz(
851  pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1
852  pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y
853 
854  DrawRect(tools::Rectangle(aMapPt, aMapSz));
855  }
856 
857  Pop();
858  mbMap = bOldMap;
859  mpMetaFile = pOldMetaFile;
860 }
861 
862 SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName,
863  const OUString* pDriver )
864 {
865  ImplSVData* pSVData = ImplGetSVData();
866  if ( !pSVData->maGDIData.mpPrinterQueueList )
868 
869  ImplPrnQueueList* pPrnList = pSVData->maGDIData.mpPrinterQueueList.get();
870  if ( pPrnList && !pPrnList->m_aQueueInfos.empty() )
871  {
872  // first search for the printer name directly
873  ImplPrnQueueData* pInfo = pPrnList->Get( rPrinterName );
874  if( pInfo )
875  return pInfo->mpSalQueueInfo.get();
876 
877  // then search case insensitive
878  for(const ImplPrnQueueData & rQueueInfo : pPrnList->m_aQueueInfos)
879  {
880  if( rQueueInfo.mpSalQueueInfo->maPrinterName.equalsIgnoreAsciiCase( rPrinterName ) )
881  return rQueueInfo.mpSalQueueInfo.get();
882  }
883 
884  // then search for driver name
885  if ( pDriver )
886  {
887  for(const ImplPrnQueueData & rQueueInfo : pPrnList->m_aQueueInfos)
888  {
889  if( rQueueInfo.mpSalQueueInfo->maDriver == *pDriver )
890  return rQueueInfo.mpSalQueueInfo.get();
891  }
892  }
893 
894  // then the default printer
895  pInfo = pPrnList->Get( GetDefaultPrinterName() );
896  if( pInfo )
897  return pInfo->mpSalQueueInfo.get();
898 
899  // last chance: the first available printer
900  return pPrnList->m_aQueueInfos[0].mpSalQueueInfo.get();
901  }
902 
903  return nullptr;
904 }
905 
907 {
908  // we need a graphics
909  if ( !AcquireGraphics() )
910  return;
911 
915  maPageOffset,
916  maPaperSize );
917 }
918 
920 {
922 }
923 
925 {
926  // use display-equivalent step size calculation
927  tools::Long nInc = (nMinRect < 800) ? 10 : 20;
928 
929  return nInc;
930 }
931 
934 {
935  ImplInitData();
937  if ( pInfo )
938  {
939  ImplInit( pInfo );
940  if ( !IsDisplayPrinter() )
941  mbDefPrinter = true;
942  }
943  else
944  ImplInitDisplay();
945 }
946 
947 Printer::Printer( const JobSetup& rJobSetup )
949  , maJobSetup(rJobSetup)
950 {
951  ImplInitData();
952  const ImplJobSetup& rConstData = rJobSetup.ImplGetConstData();
953  OUString aDriver = rConstData.GetDriver();
954  SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( rConstData.GetPrinterName(),
955  &aDriver );
956  if ( pInfo )
957  {
958  ImplInit( pInfo );
959  SetJobSetup( rJobSetup );
960  }
961  else
962  {
963  ImplInitDisplay();
964  maJobSetup = JobSetup();
965  }
966 }
967 
968 Printer::Printer( const QueueInfo& rQueueInfo )
970 {
971  ImplInitData();
972  SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( rQueueInfo.GetPrinterName(),
973  &rQueueInfo.GetDriver() );
974  if ( pInfo )
975  ImplInit( pInfo );
976  else
977  ImplInitDisplay();
978 }
979 
980 Printer::Printer( const OUString& rPrinterName )
982 {
983  ImplInitData();
984  SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( rPrinterName, nullptr );
985  if ( pInfo )
986  ImplInit( pInfo );
987  else
988  ImplInitDisplay();
989 }
990 
992 {
993  disposeOnce();
994 }
995 
997 {
998  SAL_WARN_IF( IsPrinting(), "vcl.gdi", "Printer::~Printer() - Job is printing" );
999  SAL_WARN_IF( IsJobActive(), "vcl.gdi", "Printer::~Printer() - Job is active" );
1000 
1001  mpPrinterOptions.reset();
1002 
1003  ReleaseGraphics();
1004  if ( mpInfoPrinter )
1006  if ( mpDisplayDev )
1008  else
1009  {
1010  // OutputDevice Dtor is trying the same thing; that why we need to set
1011  // the FontEntry to NULL here
1012  // TODO: consolidate duplicate cleanup by Printer and OutputDevice
1013  mpFontInstance.clear();
1014  mpDeviceFontList.reset();
1015  mpDeviceFontSizeList.reset();
1016  mxFontCache.reset();
1017  // font list deleted by OutputDevice dtor
1018  }
1019 
1020  // Add printer from the list
1021  ImplSVData* pSVData = ImplGetSVData();
1022  if ( mpPrev )
1023  mpPrev->mpNext = mpNext;
1024  else
1025  pSVData->maGDIData.mpFirstPrinter = mpNext;
1026  if ( mpNext )
1027  mpNext->mpPrev = mpPrev;
1028 
1029  mpPrev.clear();
1030  mpNext.clear();
1032 }
1033 
1035 {
1036  Size aBrdSize(LogicToPixel(Size(20, 20), MapMode(MapUnit::Map100thMM)));
1037 
1038  if (!aBrdSize.Width())
1039  aBrdSize.setWidth(1);
1040 
1041  if (!aBrdSize.Height())
1042  aBrdSize.setHeight(1);
1043 
1044  return aBrdSize;
1045 }
1046 
1047 sal_uInt32 Printer::GetCapabilities( PrinterCapType nType ) const
1048 {
1049  if ( IsDisplayPrinter() )
1050  return 0;
1051 
1052  if( mpInfoPrinter )
1054  else
1055  return 0;
1056 }
1057 
1058 bool Printer::HasSupport( PrinterSupport eFeature ) const
1059 {
1060  switch ( eFeature )
1061  {
1072  }
1073 
1074  return true;
1075 }
1076 
1077 bool Printer::SetJobSetup( const JobSetup& rSetup )
1078 {
1079  if ( IsDisplayPrinter() || mbInPrintPage )
1080  return false;
1081 
1082  JobSetup aJobSetup = rSetup;
1083 
1084  ReleaseGraphics();
1085  if ( mpInfoPrinter->SetPrinterData( &aJobSetup.ImplGetData() ) )
1086  {
1087  ImplUpdateJobSetupPaper( aJobSetup );
1088  mbNewJobSetup = true;
1089  maJobSetup = aJobSetup;
1092  return true;
1093  }
1094 
1095  return false;
1096 }
1097 
1099 {
1100  if ( IsDisplayPrinter() )
1101  return false;
1102 
1103  if ( IsJobActive() || IsPrinting() )
1104  return false;
1105 
1106  JobSetup aJobSetup = maJobSetup;
1107  ImplJobSetup& rData = aJobSetup.ImplGetData();
1108  rData.SetPrinterSetupMode( eMode );
1109  // TODO: orig page size
1110 
1111  if (!pWindow)
1112  {
1113  vcl::Window* pDefWin = ImplGetDefaultWindow();
1114  pWindow = pDefWin ? pDefWin->GetFrameWeld() : nullptr;
1115  }
1116  if( !pWindow )
1117  return false;
1118 
1119  ReleaseGraphics();
1120  ImplSVData* pSVData = ImplGetSVData();
1121  pSVData->maAppData.mnModalMode++;
1122  nImplSysDialog++;
1123  bool bSetup = mpInfoPrinter->Setup(pWindow, &rData);
1124  pSVData->maAppData.mnModalMode--;
1125  nImplSysDialog--;
1126  if ( bSetup )
1127  {
1128  ImplUpdateJobSetupPaper( aJobSetup );
1129  mbNewJobSetup = true;
1130  maJobSetup = aJobSetup;
1133  return true;
1134  }
1135  return false;
1136 }
1137 
1138 bool Printer::SetPrinterProps( const Printer* pPrinter )
1139 {
1140  if ( IsJobActive() || IsPrinting() )
1141  return false;
1142 
1143  ImplSVData* pSVData = ImplGetSVData();
1144 
1145  mbDefPrinter = pPrinter->mbDefPrinter;
1146  maPrintFile = pPrinter->maPrintFile;
1147  mbPrintFile = pPrinter->mbPrintFile;
1148  mnCopyCount = pPrinter->mnCopyCount;
1149  mbCollateCopy = pPrinter->mbCollateCopy;
1150  mnPageQueueSize = pPrinter->mnPageQueueSize;
1151  *mpPrinterOptions = *pPrinter->mpPrinterOptions;
1152 
1153  if ( pPrinter->IsDisplayPrinter() )
1154  {
1155  // Destroy old printer
1156  if ( !IsDisplayPrinter() )
1157  {
1158  ReleaseGraphics();
1160  mpFontInstance.clear();
1161  mpDeviceFontList.reset();
1162  mpDeviceFontSizeList.reset();
1163  // clean up font list
1164  mxFontCache.reset();
1165  mxFontCollection.reset();
1166 
1167  mbInitFont = true;
1168  mbNewFont = true;
1169  mpInfoPrinter = nullptr;
1170  }
1171 
1172  // Construct new printer
1173  ImplInitDisplay();
1174  return true;
1175  }
1176 
1177  // Destroy old printer?
1178  if ( GetName() != pPrinter->GetName() )
1179  {
1180  ReleaseGraphics();
1181  if ( mpDisplayDev )
1182  {
1184  }
1185  else
1186  {
1188 
1189  mpFontInstance.clear();
1190  mpDeviceFontList.reset();
1191  mpDeviceFontSizeList.reset();
1192  mxFontCache.reset();
1193  mxFontCollection.reset();
1194  mbInitFont = true;
1195  mbNewFont = true;
1196  mpInfoPrinter = nullptr;
1197  }
1198 
1199  // Construct new printer
1200  OUString aDriver = pPrinter->GetDriverName();
1201  SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( pPrinter->GetName(), &aDriver );
1202  if ( pInfo )
1203  {
1204  ImplInit( pInfo );
1205  SetJobSetup( pPrinter->GetJobSetup() );
1206  }
1207  else
1208  ImplInitDisplay();
1209  }
1210  else
1211  SetJobSetup( pPrinter->GetJobSetup() );
1212 
1213  return false;
1214 }
1215 
1217 {
1218  if ( mbInPrintPage )
1219  return false;
1220 
1221  if ( maJobSetup.ImplGetConstData().GetOrientation() != eOrientation )
1222  {
1223  JobSetup aJobSetup = maJobSetup;
1224  ImplJobSetup& rData = aJobSetup.ImplGetData();
1225 
1226  rData.SetOrientation(eOrientation);
1227 
1228  if ( IsDisplayPrinter() )
1229  {
1230  mbNewJobSetup = true;
1231  maJobSetup = aJobSetup;
1232  return true;
1233  }
1234 
1235  ReleaseGraphics();
1237  {
1238  ImplUpdateJobSetupPaper( aJobSetup );
1239  mbNewJobSetup = true;
1240  maJobSetup = aJobSetup;
1243  return true;
1244  }
1245  else
1246  return false;
1247  }
1248 
1249  return true;
1250 }
1251 
1253 {
1255 }
1256 
1257 bool Printer::SetPaperBin( sal_uInt16 nPaperBin )
1258 {
1259  if ( mbInPrintPage )
1260  return false;
1261 
1262  if ( maJobSetup.ImplGetConstData().GetPaperBin() != nPaperBin &&
1263  nPaperBin < GetPaperBinCount() )
1264  {
1265  JobSetup aJobSetup = maJobSetup;
1266  ImplJobSetup& rData = aJobSetup.ImplGetData();
1267  rData.SetPaperBin(nPaperBin);
1268 
1269  if ( IsDisplayPrinter() )
1270  {
1271  mbNewJobSetup = true;
1272  maJobSetup = aJobSetup;
1273  return true;
1274  }
1275 
1276  ReleaseGraphics();
1277  if ( mpInfoPrinter->SetData( JobSetFlags::PAPERBIN, &rData ) )
1278  {
1279  ImplUpdateJobSetupPaper( aJobSetup );
1280  mbNewJobSetup = true;
1281  maJobSetup = aJobSetup;
1284  return true;
1285  }
1286  else
1287  return false;
1288  }
1289 
1290  return true;
1291 }
1292 
1293 sal_uInt16 Printer::GetPaperBin() const
1294 {
1296 }
1297 
1299 {
1301 }
1302 
1303 // dear loplugins, DO NOT REMOVE this code
1304 // it will be used in follow-up commits
1305 void Printer::SetPrinterSettingsPreferred( bool bPaperSizeFromSetup)
1306 {
1307  if ( maJobSetup.ImplGetConstData().GetPapersizeFromSetup() != bPaperSizeFromSetup )
1308  {
1309  JobSetup aJobSetup = maJobSetup;
1310  ImplJobSetup& rData = aJobSetup.ImplGetData();
1311  rData.SetPapersizeFromSetup(bPaperSizeFromSetup);
1312 
1313  mbNewJobSetup = true;
1314  maJobSetup = aJobSetup;
1315  }
1316 }
1317 
1318 // Map user paper format to an available printer paper format
1320 {
1321  ImplJobSetup& rData = aJobSetup.ImplGetData();
1322 
1323  // The angle that a landscape page will be turned counterclockwise wrt to portrait.
1324  int nLandscapeAngle = mpInfoPrinter ? mpInfoPrinter->GetLandscapeAngle( &maJobSetup.ImplGetConstData() ) : 900;
1325  int nPaperCount = GetPaperInfoCount();
1326  PaperInfo aInfo(rData.GetPaperWidth(), rData.GetPaperHeight());
1327 
1328  // Compare all paper formats and get the appropriate one
1329  for ( int i = 0; i < nPaperCount; i++ )
1330  {
1331  const PaperInfo& rPaperInfo = GetPaperInfo( i );
1332 
1333  if ( aInfo.sloppyEqual(rPaperInfo) )
1334  {
1335  rData.SetPaperFormat(
1336  ImplGetPaperFormat( rPaperInfo.getWidth(),
1337  rPaperInfo.getHeight() ));
1339  return;
1340  }
1341  }
1342 
1343  // If the printer supports landscape orientation, check paper sizes again
1344  // with landscape orientation. This is necessary as a printer driver provides
1345  // all paper sizes with portrait orientation only!!
1346  if ( !(rData.GetPaperFormat() == PAPER_USER &&
1347  nLandscapeAngle != 0 &&
1349  return;
1350 
1351  const tools::Long nRotatedWidth = rData.GetPaperHeight();
1352  const tools::Long nRotatedHeight = rData.GetPaperWidth();
1353  PaperInfo aRotatedInfo(nRotatedWidth, nRotatedHeight);
1354 
1355  for ( int i = 0; i < nPaperCount; i++ )
1356  {
1357  const PaperInfo& rPaperInfo = GetPaperInfo( i );
1358 
1359  if ( aRotatedInfo.sloppyEqual( rPaperInfo ) )
1360  {
1361  rData.SetPaperFormat(
1362  ImplGetPaperFormat( rPaperInfo.getWidth(),
1363  rPaperInfo.getHeight() ));
1365  return;
1366  }
1367  }
1368 }
1369 
1370 void Printer::SetPaper( Paper ePaper )
1371 {
1372  if ( mbInPrintPage )
1373  return;
1374 
1375  if ( maJobSetup.ImplGetConstData().GetPaperFormat() == ePaper )
1376  return;
1377 
1378  JobSetup aJobSetup = maJobSetup;
1379  ImplJobSetup& rData = aJobSetup.ImplGetData();
1380 
1381  rData.SetPaperFormat( ePaper );
1382  if ( ePaper != PAPER_USER )
1383  {
1384  PaperInfo aInfo(ePaper);
1385  rData.SetPaperWidth( aInfo.getWidth() );
1386  rData.SetPaperHeight( aInfo.getHeight() );
1387  }
1388 
1389  if ( IsDisplayPrinter() )
1390  {
1391  mbNewJobSetup = true;
1392  maJobSetup = aJobSetup;
1393  return;
1394  }
1395 
1396  ReleaseGraphics();
1397  if ( ePaper == PAPER_USER )
1398  ImplFindPaperFormatForUserSize( aJobSetup );
1400  {
1401  ImplUpdateJobSetupPaper( aJobSetup );
1402  mbNewJobSetup = true;
1403  maJobSetup = aJobSetup;
1406  }
1407 }
1408 
1409 bool Printer::SetPaperSizeUser( const Size& rSize )
1410 {
1411  if ( mbInPrintPage )
1412  return false;
1413 
1414  const Size aPixSize = LogicToPixel( rSize );
1415  const Size aPageSize = PixelToLogic(aPixSize, MapMode(MapUnit::Map100thMM));
1416  bool bNeedToChange(maJobSetup.ImplGetConstData().GetPaperWidth() != aPageSize.Width() ||
1417  maJobSetup.ImplGetConstData().GetPaperHeight() != aPageSize.Height());
1418 
1419  if(!bNeedToChange)
1420  {
1421  // #i122984# only need to change when Paper is different from PAPER_USER and
1422  // the mapped Paper which will created below in the call to ImplFindPaperFormatForUserSize
1423  // and will replace maJobSetup.ImplGetConstData()->GetPaperFormat(). This leads to
1424  // unnecessary JobSetups, e.g. when printing a multi-page fax, but also with
1425  // normal print
1426  const Paper aPaper = ImplGetPaperFormat(aPageSize.Width(), aPageSize.Height());
1427 
1428  bNeedToChange = maJobSetup.ImplGetConstData().GetPaperFormat() != PAPER_USER &&
1430  }
1431 
1432  if(bNeedToChange)
1433  {
1434  JobSetup aJobSetup = maJobSetup;
1435  ImplJobSetup& rData = aJobSetup.ImplGetData();
1436  rData.SetPaperFormat( PAPER_USER );
1437  rData.SetPaperWidth( aPageSize.Width() );
1438  rData.SetPaperHeight( aPageSize.Height() );
1439 
1440  if ( IsDisplayPrinter() )
1441  {
1442  mbNewJobSetup = true;
1443  maJobSetup = aJobSetup;
1444  return true;
1445  }
1446 
1447  ReleaseGraphics();
1448  ImplFindPaperFormatForUserSize( aJobSetup );
1449 
1450  // Changing the paper size can also change the orientation!
1452  {
1453  ImplUpdateJobSetupPaper( aJobSetup );
1454  mbNewJobSetup = true;
1455  maJobSetup = aJobSetup;
1458  return true;
1459  }
1460  else
1461  return false;
1462  }
1463 
1464  return true;
1465 }
1466 
1468 {
1469  if( ! mpInfoPrinter )
1470  return 0;
1471  if( ! mpInfoPrinter->m_bPapersInit )
1473  return mpInfoPrinter->m_aPaperFormats.size();
1474 }
1475 
1476 OUString Printer::GetPaperName( Paper ePaper )
1477 {
1478  ImplSVData* pSVData = ImplGetSVData();
1479  if( pSVData->maPaperNames.empty() )
1480  {
1481  static const int PaperIndex[] =
1482  {
1496  };
1497  assert(SAL_N_ELEMENTS(PaperIndex) == SAL_N_ELEMENTS(RID_STR_PAPERNAMES) && "localized paper name count wrong");
1498  for (size_t i = 0; i < SAL_N_ELEMENTS(PaperIndex); ++i)
1499  pSVData->maPaperNames[PaperIndex[i]] = VclResId(RID_STR_PAPERNAMES[i]);
1500  }
1501 
1502  std::unordered_map<int,OUString>::const_iterator it = pSVData->maPaperNames.find( static_cast<int>(ePaper) );
1503  return (it != pSVData->maPaperNames.end()) ? it->second : OUString();
1504 }
1505 
1506 const PaperInfo& Printer::GetPaperInfo( int nPaper ) const
1507 {
1508  if( ! mpInfoPrinter )
1509  return ImplGetEmptyPaper();
1510  if( ! mpInfoPrinter->m_bPapersInit )
1512  if( mpInfoPrinter->m_aPaperFormats.empty() || nPaper < 0 || nPaper >= int(mpInfoPrinter->m_aPaperFormats.size()) )
1513  return ImplGetEmptyPaper();
1514  return mpInfoPrinter->m_aPaperFormats[nPaper];
1515 }
1516 
1518 {
1519  PaperInfo aInfo = GetPaperInfo( nPaper );
1520  return PixelToLogic( Size( aInfo.getWidth(), aInfo.getHeight() ) );
1521 }
1522 
1524 {
1525  if ( mbInPrintPage )
1526  return;
1527 
1528  if ( maJobSetup.ImplGetConstData().GetDuplexMode() == eDuplex )
1529  return;
1530 
1531  JobSetup aJobSetup = maJobSetup;
1532  ImplJobSetup& rData = aJobSetup.ImplGetData();
1533 
1534  rData.SetDuplexMode( eDuplex );
1535 
1536  if ( IsDisplayPrinter() )
1537  {
1538  mbNewJobSetup = true;
1539  maJobSetup = aJobSetup;
1540  return;
1541  }
1542 
1543  ReleaseGraphics();
1544  if ( mpInfoPrinter->SetData( JobSetFlags::DUPLEXMODE, &rData ) )
1545  {
1546  ImplUpdateJobSetupPaper( aJobSetup );
1547  mbNewJobSetup = true;
1548  maJobSetup = aJobSetup;
1551  }
1552 }
1553 
1555 {
1557 }
1558 
1560 {
1562 }
1563 
1564 sal_uInt16 Printer::GetPaperBinCount() const
1565 {
1566  if ( IsDisplayPrinter() )
1567  return 0;
1568 
1570 }
1571 
1572 OUString Printer::GetPaperBinName( sal_uInt16 nPaperBin ) const
1573 {
1574  if ( IsDisplayPrinter() )
1575  return OUString();
1576 
1577  if ( nPaperBin < GetPaperBinCount() )
1578  return mpInfoPrinter->GetPaperBinName( &maJobSetup.ImplGetConstData(), nPaperBin );
1579  else
1580  return OUString();
1581 }
1582 
1583 void Printer::SetCopyCount( sal_uInt16 nCopy, bool bCollate )
1584 {
1585  mnCopyCount = nCopy;
1586  mbCollateCopy = bCollate;
1587 }
1588 
1590 {
1591  ErrCode nVCLError;
1592  switch ( nError )
1593  {
1594  case SalPrinterError::NONE:
1595  nVCLError = ERRCODE_NONE;
1596  break;
1598  nVCLError = PRINTER_ABORT;
1599  break;
1600  default:
1601  nVCLError = PRINTER_GENERALERROR;
1602  break;
1603  }
1604 
1605  return nVCLError;
1606 }
1607 
1609 {
1610  if ( !IsJobActive() )
1611  return;
1612 
1613  SAL_WARN_IF( mbInPrintPage, "vcl.gdi", "Printer::EndJob() - StartPage() without EndPage() called" );
1614 
1615  mbJobActive = false;
1616 
1617  if ( mpPrinter )
1618  {
1619  ReleaseGraphics();
1620 
1621  mbPrinting = false;
1622 
1623  mbDevOutput = false;
1624  mpPrinter->EndJob();
1625  mpPrinter.reset();
1626  }
1627 }
1628 
1630 {
1631  if ( !IsJobActive() )
1632  return;
1633 
1634  if ( !mpPrinter )
1635  return;
1636 
1637  SalGraphics* pGraphics = mpPrinter->StartPage( &maJobSetup.ImplGetData(),
1638  mbNewJobSetup );
1639  if ( pGraphics )
1640  {
1641  ReleaseGraphics();
1642  mpJobGraphics = pGraphics;
1643  }
1644  mbDevOutput = true;
1645 
1646  // PrintJob not aborted ???
1647  if ( IsJobActive() )
1648  mbInPrintPage = true;
1649 }
1650 
1652 {
1653  if ( !IsJobActive() )
1654  return;
1655 
1656  mbInPrintPage = false;
1657 
1658  if ( mpPrinter )
1659  {
1660  mpPrinter->EndPage();
1661  ReleaseGraphics();
1662  mbDevOutput = false;
1663 
1664  mpJobGraphics = nullptr;
1665  mbNewJobSetup = false;
1666  }
1667 }
1668 
1670 {
1671  ImplSVData* pSVData = ImplGetSVData();
1672  ImplPrnQueueList* pPrnList = pSVData->maGDIData.mpPrinterQueueList.get();
1673 
1674  if ( !pPrnList )
1675  return;
1676 
1677  std::unique_ptr<ImplPrnQueueList> pNewList(new ImplPrnQueueList);
1678  pSVData->mpDefInst->GetPrinterQueueInfo( pNewList.get() );
1679 
1680  bool bChanged = pPrnList->m_aQueueInfos.size() != pNewList->m_aQueueInfos.size();
1681  for( decltype(pPrnList->m_aQueueInfos)::size_type i = 0; ! bChanged && i < pPrnList->m_aQueueInfos.size(); i++ )
1682  {
1683  ImplPrnQueueData& rInfo = pPrnList->m_aQueueInfos[i];
1684  ImplPrnQueueData& rNewInfo = pNewList->m_aQueueInfos[i];
1685  if( ! rInfo.mpSalQueueInfo || ! rNewInfo.mpSalQueueInfo || // sanity check
1686  rInfo.mpSalQueueInfo->maPrinterName != rNewInfo.mpSalQueueInfo->maPrinterName )
1687  {
1688  bChanged = true;
1689  }
1690  }
1691  if( !bChanged )
1692  return;
1693 
1695  pSVData->maGDIData.mpPrinterQueueList = std::move(pNewList);
1696 
1697  Application* pApp = GetpApp();
1698  if( pApp )
1699  {
1703  }
1704 }
1705 
1707 {
1708  return true;
1709 }
1710 
1711 void Printer::ClipAndDrawGradientMetafile ( const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly )
1712 {
1713  const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
1714 
1716  IntersectClipRegion(vcl::Region(rPolyPoly));
1717  DrawGradient( aBoundRect, rGradient );
1718  Pop();
1719 }
1720 
1721 void Printer::SetFontOrientation( LogicalFontInstance* const pFontEntry ) const
1722 {
1723  pFontEntry->mnOrientation = pFontEntry->mxFontMetric->GetOrientation();
1724 }
1725 
1727 {
1728  return aRegion;
1729 }
1730 
1731 Bitmap Printer::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
1732 {
1733  SAL_WARN("vcl.gdi", "GetBitmap(): This should never be called on by a Printer instance");
1734 
1735  return OutputDevice::GetBitmap( rSrcPt, rSize );
1736 }
1737 
1738 css::awt::DeviceInfo Printer::GetDeviceInfo() const
1739 {
1740  Size aDevSz = GetPaperSizePixel();
1741  css::awt::DeviceInfo aInfo = GetCommonDeviceInfo(aDevSz);
1742  Size aOutSz = GetOutputSizePixel();
1743  Point aOffset = GetPageOffset();
1744  aInfo.LeftInset = aOffset.X();
1745  aInfo.TopInset = aOffset.Y();
1746  aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X();
1747  aInfo.BottomInset = aDevSz.Height() - aOutSz.Height() - aOffset.Y();
1748  aInfo.Capabilities = 0;
1749 
1750  return aInfo;
1751 }
1752 
1753 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PAPER_A7
bool DrawTransformBitmapExDirect(const basegfx::B2DHomMatrix &aFullTransform, const BitmapEx &rBitmapEx, double fAlpha=1.0) override
Transform and draw a bitmap directly.
Definition: print.cxx:274
PAPER_FANFOLD_US
bool mbJobActive
Definition: print.hxx:166
PAPER_ENV_C2
void SetPrinterSetupMode(PrinterSetupMode eMode)
Definition: jobset.cxx:160
virtual void ClipAndDrawGradientMetafile(const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly) override
Definition: print.cxx:1711
VclPtr< OutputDevice > mpNextGraphics
Next output device in list.
Definition: outdev.hxx:177
virtual SalGraphics * AcquireGraphics()=0
virtual void ImplReleaseFonts() override
Definition: print.cxx:639
PAPER_SLIDE_DIA
sal_uInt16 GetPaperBinCount() const
Definition: print.cxx:1564
PAPER_KAI32
PAPER_A10
const OUString & GetName() const
Definition: print.hxx:266
PAPER_EXECUTIVE
PAPER_B6_ISO
SalGraphics * mpJobGraphics
Definition: print.hxx:150
virtual int GetLandscapeAngle(const ImplJobSetup *pSetupData)=0
PAPER_FANFOLD_DE
PAPER_ENV_C3
bool IsDisplayPrinter() const
Definition: print.hxx:269
PAPER_A6
JobSetup maJobSetup
Definition: print.hxx:158
void setWidth(tools::Long nWidth)
bool SetPaperBin(sal_uInt16 nPaperBin)
Definition: print.cxx:1257
static void NotifyAllWindows(DataChangedEvent &rDCEvt)
Notify all windows that the application has changed data.
Definition: svapp.cxx:760
sal_uInt16 GetPaperBin() const
Definition: print.cxx:1293
DuplexMode GetDuplexMode() const
Definition: print.cxx:1554
PAPER_ENV_MONARCH
Size maPaperSize
Definition: print.hxx:160
PrinterCapType
Definition: prntypes.hxx:71
std::unique_ptr< ContentProperties > pData
VCL_DLLPRIVATE void ImplInit(SalPrinterQueueInfo *pInfo)
Definition: print.cxx:709
SAL_DLLPRIVATE void ImplPrintTransparent(const Bitmap &rBmp, const Bitmap &rMask, const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel)
Definition: print.cxx:182
std::vector< PaperInfo > m_aPaperFormats
Definition: salprn.hxx:54
virtual bool AcquireGraphics() const override
Acquire a graphics device that the output device uses to draw on.
Definition: print.cxx:567
PAPER_ENV_C5
PAPER_B5_ISO
std::unique_ptr< SalPrinterQueueInfo > mpSalQueueInfo
Definition: print.h:39
PAPER_B4_JIS
PAPER_ONSCREENSHOW_4_3
ImplSVAppData maAppData
Definition: svdata.hxx:391
PAPER_ENV_PERSONAL
VCL_DLLPRIVATE void ImplInitDisplay()
Definition: print.cxx:761
long Long
void disposeAndClear()
Definition: vclptr.hxx:200
static VCL_DLLPRIVATE SalPrinterQueueInfo * ImplGetQueueInfo(const OUString &rPrinterName, const OUString *pDriver)
Definition: print.cxx:862
VclPtr< OutputDevice > mpLastVirGraphics
Definition: svdata.hxx:215
void SetPrinterSettingsPreferred(bool bPaperSizeFromSetup)
Definition: print.cxx:1305
PAPER_POSTCARD_JP
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
PAPER_B5_JIS
const JobSetup & GetJobSetup() const
Definition: print.hxx:276
virtual ~Printer() override
Definition: print.cxx:991
PAPER_ENV_11
static OUString GetDefaultPrinterName()
Definition: print.cxx:527
PAPER_16K_197x273
VCL_DLLPRIVATE void ImplUpdateFontList()
Definition: print.cxx:919
PAPER_ARCHA
const ContentProperties & rData
PAPER_B0_ISO
std::shared_ptr< PhysicalFontCollection > mxFontCollection
Definition: outdev.hxx:181
void SetCopyCount(sal_uInt16 nCopy, bool bCollate)
Definition: print.cxx:1583
sal_Int32 mnDPIY
Definition: outdev.hxx:209
static void updatePrinters()
Checks the printer list and updates it necessary.
Definition: print.cxx:1669
std::unique_ptr< ImplDeviceFontSizeList > mpDeviceFontSizeList
Definition: outdev.hxx:183
void IntersectClipRegion(const tools::Rectangle &rRect)
PAPER_10x14
sal_Int32 mnDPIX
Definition: outdev.hxx:208
PAPER_A_PLUS
void EnableMapMode(bool bEnable=true)
Definition: map.cxx:543
Size GetSizePixel() const
bool mbMap
Definition: outdev.hxx:236
ImplFontMetricDataRef mxFontMetric
std::unique_ptr< SalPrinter > mpPrinter
Definition: print.hxx:149
PAPER_ONSCREENSHOW_16_9
PrinterSetupMode
Definition: prntypes.hxx:85
void doSloppyFit(bool bAlsoTryRotated=false)
const OUString & GetDriver() const
Definition: jobset.h:67
Orientation GetOrientation() const
Definition: print.cxx:1252
PAPER_A9
VCL_DLLPRIVATE void ImplInitData()
Definition: print.cxx:539
ImplSVGDIData maGDIData
Definition: svdata.hxx:392
SAL_DLLPRIVATE const ImplJobSetup & ImplGetConstData() const
Definition: jobset.cxx:210
Point GetPageOffset() const
Definition: print.hxx:322
std::vector< tools::Rectangle > RectangleVector
Definition: region.hxx:37
virtual void dispose() override
Definition: print.cxx:996
virtual OUString GetDefaultPrinter()=0
void SetDriverDataLen(sal_uInt32 nDriverDataLen)
Definition: jobset.cxx:145
DuplexMode GetDuplexMode() const
Definition: jobset.h:73
PAPER_ENV_14
constexpr tools::Long Width() const
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
SAL_DLLPRIVATE void InitLineColor()
bool mbCollateCopy
Definition: print.hxx:167
std::unique_ptr< ImplPrnQueueList > mpPrinterQueueList
Definition: svdata.hxx:221
void SetDuplexMode(DuplexMode)
Definition: print.cxx:1523
weld::Window * GetFrameWeld() const
Definition: window2.cxx:847
VclPtr< Printer > mpNext
Definition: print.hxx:152
virtual tools::Long GetGradientStepCount(tools::Long nMinRect) override
Definition: print.cxx:924
DuplexMode
Definition: prntypes.hxx:28
sal_uInt16 mnPageQueueSize
Definition: print.hxx:162
tools::Long getHeight() const
void DrawDeviceBitmap(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel, BitmapEx &rBitmapEx) override
Definition: print.cxx:293
bool IsAlpha() const
Definition: BitmapEx.cxx:193
static void ImplCallEventListenersApplicationDataChanged(void *pData)
Send event to all VCL application event listeners.
Definition: svapp.cxx:779
bool Mirror(BmpMirrorFlags nMirrorFlags)
Mirror the bitmap.
PAPER_ENV_9
void SetPaperHeight(tools::Long nHeight)
Definition: jobset.cxx:140
PAPER_ARCHE
tools::Long Left() const
virtual bool Setup(weld::Window *pFrame, ImplJobSetup *pSetupData)=0
PAPER_QUARTO
PAPER_16K_195x270
VCL_DLLPRIVATE void ImplFindPaperFormatForUserSize(JobSetup &)
Definition: print.cxx:1319
PAPER_ENV_C6
PAPER_KAI16
PAPER_LEGAL
PAPER_ENV_C7
virtual bool UsePolyPolygonForComplexGradient() override
Definition: print.cxx:1706
AntialiasingFlags mnAntialiasing
Definition: outdev.hxx:233
tools::Long Bottom() const
css::awt::DeviceInfo GetDeviceInfo() const override
Definition: print.cxx:1738
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const
constexpr tools::Long GetWidth() const
PAPER_ENV_ITALY
VCL_DLLPRIVATE void ImplEndPage()
Definition: print.cxx:1651
const Size & GetPaperSizePixel() const
Definition: print.hxx:318
void SetDuplexMode(DuplexMode eDuplexMode)
Definition: jobset.cxx:120
#define PRINTER_GENERALERROR
Definition: errcode.hxx:266
PAPER_B2_ISO
void SetDriverData(sal_uInt8 *pDriverData)
Definition: jobset.cxx:150
Application * GetpApp()
Definition: svapp.cxx:151
bool Blend(const AlphaMask &rAlpha, const Color &rBackgroundColor)
Alpha-blend the given bitmap against a specified uniform background color.
SAL_DLLPRIVATE ImplJobSetup & ImplGetData()
Definition: jobset.cxx:215
bool IsJobActive() const
Definition: print.hxx:332
PAPER_KAI32BIG
PAPER_TABLOID
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
Point maPageOffset
Definition: print.hxx:159
#define SAL_N_ELEMENTS(arr)
OUString GetPaperBinName(sal_uInt16 nPaperBin) const
Definition: print.cxx:1572
SalGraphics * mpGraphics
Graphics context to draw on.
Definition: outdev.hxx:175
VclPtr< VirtualDevice > mpDisplayDev
Definition: print.hxx:153
bool SetPaperSizeUser(const Size &rSize)
Definition: print.cxx:1409
bool HasSupport(PrinterSupport eFeature) const
Definition: print.cxx:1058
PAPER_B_PLUS
bool sloppyEqual(const PaperInfo &rOther) const
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
PAPER_A8
VclPtr< Printer > mpFirstPrinter
Definition: svdata.hxx:220
virtual bool HasMirroredGraphics() const override
Definition: print.cxx:422
void SetLineColor()
SAL_DLLPRIVATE void InitFillColor()
void clear()
Definition: vclptr.hxx:190
VclPtr< Printer > mpLastPrnGraphics
Definition: svdata.hxx:217
void SetPaperWidth(tools::Long nWidth)
Definition: jobset.cxx:135
PAPER_FANFOLD_LEGAL_DE
vcl::PixelFormat getPixelFormat() const
PAPER_ENV_DL
PAPER_A4_PLUS
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY)=0
bool GetPapersizeFromSetup() const
Definition: jobset.h:94
std::unordered_map< OUString, sal_Int32 > m_aNameToIndex
Definition: print.h:54
sal_uInt16 mnModalMode
Definition: svdata.hxx:149
int i
bool TransformAndReduceBitmapExToTargetRange(const basegfx::B2DHomMatrix &aFullTransform, basegfx::B2DRange &aVisibleRange, double &fMaximumArea) override
Transform and reduce the area that needs to be drawn of the bitmap and return the new visible range a...
Definition: print.cxx:283
PAPER_ENV_10
void SetOrientation(Orientation eOrientation)
Definition: jobset.cxx:115
virtual void ReleaseGraphics(SalGraphics *pGraphics)=0
virtual void dispose() override
Definition: outdev.cxx:145
tools::Long FRound(double fVal)
PAPER_C
virtual void SetFontOrientation(LogicalFontInstance *const pFontInstance) const override
Definition: print.cxx:1721
const OUString & GetPrinterName() const
Definition: jobset.h:64
std::unique_ptr< ImplDeviceFontList > mpDeviceFontList
Definition: outdev.hxx:182
PAPER_ENV_INVITE
const OUString & GetDriverName() const
Definition: print.hxx:267
PAPER_ARCHC
VCL_DLLPRIVATE void ImplStartPage()
Definition: print.cxx:1629
bool mbInitLineColor
Definition: outdev.hxx:244
const sal_uInt8 * GetDriverData() const
Definition: jobset.h:91
tools::Long mnOutHeight
Definition: outdev.hxx:207
void SetFillColor()
bool mbNewFont
Definition: outdev.hxx:250
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:162
std::vector< OUString > m_aPrinterList
Definition: print.h:56
PAPER_A1
bool mbPrinting
Definition: print.hxx:165
PAPER_D
VclPtr< Printer > mpFirstPrnGraphics
Definition: svdata.hxx:216
ImplPrnQueueData * Get(const OUString &rPrinter)
Definition: print.cxx:462
std::unique_ptr< SalVirtualDevice > mpVirDev
Definition: virdev.hxx:48
virtual tools::Rectangle GetBackgroundComponentBounds() const override
Definition: print.cxx:410
vcl::Region CreateRegion(const Color &rColor, const tools::Rectangle &rRect) const
Create region of similar colors in a given rectangle.
BmpMirrorFlags
Definition: bitmap.hxx:41
const PaperInfo & GetPaperInfo(int nPaper) const
Definition: print.cxx:1506
void SetPapersizeFromSetup(bool bPapersizeFromSetup)
Definition: jobset.cxx:155
virtual OUString GetPaperBinName(const ImplJobSetup *pSetupData, sal_uInt16 nPaperBin)=0
bool mbNewJobSetup
Definition: print.hxx:170
RasterOp meRasterOp
Definition: outdev.hxx:228
OUString maDriver
Definition: salprn.hxx:40
Printer()
Definition: print.cxx:932
Paper
Size GetOutputSizePixel() const
Definition: outdev.hxx:303
Orientation GetOrientation() const
Definition: jobset.h:70
OUString maDriver
Definition: print.hxx:156
bool mbInitTextColor
Definition: outdev.hxx:247
Base class used mainly for the LibreOffice Desktop class.
Definition: svapp.hxx:233
vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override
Perform actual rect clip against outdev dimensions, to generate empty clips whenever one of the value...
Definition: print.cxx:1726
virtual void GetPageInfo(const ImplJobSetup *pSetupData, tools::Long &rOutWidth, tools::Long &rOutHeight, Point &rPageOffset, Size &rPaperSize)=0
PAPER_ARCHD
PAPER_WIDESCREEN
tools::Long Top() const
virtual bool SetPrinterData(ImplJobSetup *pSetupData)=0
void DrawBitmap(const Point &rDestPt, const Bitmap &rBitmap)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool mbDefPrinter
Definition: print.hxx:164
Paper getPaper() const
virtual void DrawOutDev(const Point &rDestPt, const Size &rDestSize, const Point &rSrcPt, const Size &rSrcSize) override
Definition: print.cxx:390
PrintQueueFlags mnStatus
Definition: salprn.hxx:43
void ReleaseFonts()
Definition: salgdi.hxx:141
PAPER_12x11
constexpr sal_uInt32 QUEUE_JOBS_DONTKNOW
Definition: prntypes.hxx:68
virtual void ReleaseGraphics(bool bRelease=true) override
Release the graphics device, and remove it from the graphics device list.
Definition: print.cxx:656
PAPER_ENV_C4
constexpr Point TopLeft() const
static const std::vector< OUString > & GetPrinterQueues()
Definition: print.cxx:489
PAPER_B7_ISO
void SetPaper(Paper ePaper)
Definition: print.cxx:1370
PAPER_9x11
virtual SalInfoPrinter * CreateInfoPrinter(SalPrinterQueueInfo *pQueueInfo, ImplJobSetup *pSetupData)=0
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Definition: BitmapEx.cxx:203
virtual Bitmap GetBitmap(const Point &rSrcPt, const Size &rSize) const override
Definition: print.cxx:1731
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
Definition: map.cxx:1066
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:835
std::vector< ImplPrnQueueData > m_aQueueInfos
Definition: print.h:55
PAPER_SCREEN_16_10
PAPER_SCREEN_4_3
PAPER_B10_ISO
virtual void SetXORMode(bool bSet, bool bInvertOnly)=0
VclPtr< OutputDevice > mpPrevGraphics
Previous output device in list.
Definition: outdev.hxx:176
PAPER_ENV_C8
void setAntiAlias(bool bNew)
Definition: salgdi.hxx:83
bool IsPrinting() const
Definition: print.hxx:330
VclPtr< VirtualDevice > mpAlphaVDev
Definition: outdev.hxx:192
sal_uInt16 GetPaperBin() const
Definition: jobset.h:76
constexpr Size GetSize() const
const Point & GetPageOffsetPixel() const
Definition: print.hxx:321
PAPER_LEDGER
def rectangle(l)
PAPER_ARCHB
PAPER_USER
bool mbSinglePrintJobs
Definition: print.hxx:171
AlphaMask GetAlpha() const
Definition: BitmapEx.cxx:215
bool Setup(weld::Window *pWindow, PrinterSetupMode eMode=PrinterSetupMode::DocumentGlobal)
Definition: print.cxx:1098
virtual void ReleaseGraphics(bool bRelease=true)=0
Release the graphics device, and remove it from the graphics device list.
VCL_DLLPRIVATE void ImplUpdatePageData()
Definition: print.cxx:906
PAPER_B9_ISO
#define PRINTER_ABORT
Definition: errcode.hxx:265
const OUString & GetPrinterName() const
Definition: QueueInfo.cxx:28
css::awt::DeviceInfo GetCommonDeviceInfo(Size const &aDevSize) const
Definition: outdev.cxx:718
void SetPaperBin(sal_uInt16 nPaperBin)
Definition: jobset.cxx:125
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
Definition: errcode.hxx:196
constexpr tools::Long Height() const
VCL_DLLPRIVATE void EndJob()
Definition: print.cxx:1608
bool Convert(BmpConversion eConversion)
Convert bitmap format.
VclPtr< Printer > mpPrev
Definition: print.hxx:151
tools::Long GetPaperWidth() const
Definition: jobset.h:82
bool SetOrientation(Orientation eOrient)
Definition: print.cxx:1216
bool mbPrintFile
Definition: print.hxx:168
bool mbInitClipRegion
Definition: outdev.hxx:248
ErrCode mnError
Definition: print.hxx:161
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
PAPER_DOUBLEPOSTCARD_JP
virtual void GetPrinterQueueInfo(ImplPrnQueueList *pList)=0
SAL_DLLPRIVATE void ImplUpdateFontData()
PAPER_ENV_12
OUString VclResId(std::string_view aId)
Definition: svdata.cxx:259
OUString maPrinterName
Definition: print.hxx:155
void GetRegionRectangles(RectangleVector &rTarget) const
Definition: region.cxx:1659
int GetPaperInfoCount() const
Definition: print.cxx:1467
Degree10 GetOrientation() const
VclPtr< OutputDevice > mpFirstVirGraphics
Definition: svdata.hxx:214
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
std::shared_ptr< ImplFontCache > mxScreenFontCache
Definition: svdata.hxx:223
sal_uInt16 mnCopyCount
Definition: print.hxx:163
std::unique_ptr< QueueInfo > mpQueueInfo
Definition: print.h:38
PAPER_B8_ISO
static VCL_DLLPRIVATE ErrCode ImplSalPrinterErrorCodeToVCL(SalPrinterError nError)
Definition: print.cxx:1589
bool IsEmpty() const
Definition: bitmap.hxx:535
Orientation
Definition: prntypes.hxx:31
void SetPrinterName(const OUString &rPrinterName)
Definition: jobset.cxx:105
Reference< XComponentContext > getProcessComponentContext()
PAPER_SCREEN_16_9
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
static const QueueInfo * GetQueueInfo(const OUString &rPrinterName, bool bStatusUpdate)
Definition: print.cxx:497
bool mbInitFont
Definition: outdev.hxx:246
PAPER_B4_ISO
PAPER_A3
bool GetPrinterSettingsPreferred() const
Definition: print.cxx:1298
rtl::Reference< LogicalFontInstance > mpFontInstance
Definition: outdev.hxx:179
PAPER_15x11
virtual void CopyArea(const Point &rDestPt, const Point &rSrcPt, const Size &rSrcSize, bool bWindowInvalidate=false) override
Definition: print.cxx:403
bool mbInitFillColor
Definition: outdev.hxx:245
virtual void InitPaperFormats(const ImplJobSetup *pSetupData)=0
tools::Long mnOutWidth
Definition: outdev.hxx:206
SalInfoPrinter * mpInfoPrinter
Definition: print.hxx:148
Paper GetPaperFormat() const
Definition: jobset.h:79
PAPER_LETTER
PAPER_A0
void SetDriver(const OUString &rDriver)
Definition: jobset.cxx:110
PrinterSupport
bool Erase(const Color &rFillColor)
Fill the entire bitmap with the given color.
Definition: bitmappaint.cxx:34
virtual sal_uInt16 GetPaperBinCount(const ImplJobSetup *pSetupData)=0
void setHeight(tools::Long nHeight)
virtual void EmulateDrawTransparent(const tools::PolyPolygon &rPolyPoly, sal_uInt16 nTransparencePercent) override
Definition: print.cxx:313
Paper GetPaper() const
Definition: print.cxx:1559
virtual bool SetData(JobSetFlags nFlags, ImplJobSetup *pSetupData)=0
tools::Long GetPaperHeight() const
Definition: jobset.h:85
bool mbDevOutput
Definition: outdev.hxx:240
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
std::shared_ptr< ImplFontCache > mxFontCache
Definition: outdev.hxx:180
tools::Rectangle GetBoundRect() const
PAPER_ENV_C65
#define SAL_WARN(area, stream)
bool m_bPapersInit
Definition: salprn.hxx:55
PAPER_LETTER_PLUS
virtual Size GetButtonBorderSize() override
Definition: print.cxx:1034
void SetPaperFormat(Paper ePaperFormat)
Definition: jobset.cxx:130
#define DBG_TESTSOLARMUTEX()
PAPER_ONSCREENSHOW_16_10
bool mbInPrintPage
Definition: print.hxx:169
PAPER_B6_JIS
bool SetJobSetup(const JobSetup &rSetup)
Definition: print.cxx:1077
virtual void DrawDeviceMask(const Bitmap &rMask, const Color &rMaskColor, const Point &rDestPt, const Size &rDestSize, const Point &rSrcPtPixel, const Size &rSrcSizePixel) override
Definition: print.cxx:776
static OUString GetPaperName(Paper ePaper)
Definition: print.cxx:1476
const OUString & GetDriver() const
Definition: QueueInfo.cxx:29
PAPER_A5
PAPER_E
tools::Long getWidth() const
PAPER_A4
vcl::Window * ImplGetDefaultWindow()
Returns either the application window, or the default GL context window.
Definition: svdata.cxx:210
sal_uInt32 GetCapabilities(PrinterCapType nType) const
Definition: print.cxx:1047
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:59
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
PAPER_B3_ISO
PAPER_STATEMENT
PAPER_10x11
virtual sal_uInt32 GetCapabilities(const ImplJobSetup *pSetupData, PrinterCapType nType)=0
std::shared_ptr< PhysicalFontCollection > mxScreenFontList
Definition: svdata.hxx:222
VCL_DLLPRIVATE void SetPrinterOptions(const PrinterOptions &rOptions)
SetPrinterOptions is used internally only now.
Definition: print.cxx:417
bool SetPrinterProps(const Printer *pPrinter)
Definition: print.cxx:1138
PAPER_B1_ISO
tools::Long Right() const
OUString maPrintFile
Definition: print.hxx:157
SalInstance * mpDefInst
Definition: svdata.hxx:383
std::unique_ptr< PrinterOptions > mpPrinterOptions
Definition: print.hxx:154
const Color & GetFillColor() const
Definition: outdev.hxx:509
std::unordered_map< int, OUString > maPaperNames
Definition: svdata.hxx:409
SalPrinterError
Definition: salptype.hxx:41
PAPER_A2
GDIMetaFile * mpMetaFile
Definition: outdev.hxx:178
OUString maPrinterName
Definition: salprn.hxx:39
sal_Int16 nValue
virtual void GetDevFontList(PhysicalFontCollection *)=0
sal_uInt32 mnJobs
Definition: salprn.hxx:44
constexpr tools::Long GetHeight() const
Size GetPaperSize() const
Definition: print.hxx:319
virtual void DestroyInfoPrinter(SalInfoPrinter *pPrinter)=0
virtual void GetPrinterQueueState(SalPrinterQueueInfo *pInfo)=0
void Add(std::unique_ptr< SalPrinterQueueInfo > pData)
Definition: print.cxx:442