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