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