tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / vcl / osx / salprn.cxx
blob3fe37a9ab55e836b7b8cc660b291fa90111fd53b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <officecfg/Office/Common.hxx>
22 #include <vcl/gdimtf.hxx>
23 #include <vcl/print.hxx>
24 #include <sal/macros.h>
25 #include <osl/diagnose.h>
26 #include <tools/long.hxx>
28 #include <osx/salinst.h>
29 #include <osx/salprn.h>
30 #include <osx/printview.h>
31 #include <quartz/salgdi.h>
32 #include <osx/saldata.hxx>
33 #include <quartz/utils.h>
35 #include <jobset.h>
36 #include <salptype.hxx>
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/awt/Size.hpp>
40 #include <com/sun/star/uno/Sequence.hxx>
42 #include <algorithm>
43 #include <cstdlib>
45 using namespace vcl;
46 using namespace com::sun::star;
47 using namespace com::sun::star::beans;
49 AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) :
50 mpGraphics( nullptr ),
51 mbGraphics( false ),
52 mbJob( false ),
53 mpPrinter( nil ),
54 mpPrintInfo( nil ),
55 mePageOrientation( Orientation::Portrait ),
56 mnStartPageOffsetX( 0 ),
57 mnStartPageOffsetY( 0 ),
58 mnCurPageRangeStart( 0 ),
59 mnCurPageRangeCount( 0 )
61 NSString* pStr = CreateNSString( i_rQueue.maPrinterName );
62 mpPrinter = [NSPrinter printerWithName: pStr];
63 [pStr release];
65 NSPrintInfo* pShared = [NSPrintInfo sharedPrintInfo];
66 if( pShared )
68 mpPrintInfo = [pShared copy];
69 [mpPrintInfo setPrinter: mpPrinter];
70 mePageOrientation = ([mpPrintInfo orientation] == NSPaperOrientationLandscape) ? Orientation::Landscape : Orientation::Portrait;
71 [mpPrintInfo setOrientation: NSPaperOrientationPortrait];
74 mpGraphics = new AquaSalGraphics(true);
76 const int nWidth = 100, nHeight = 100;
77 mpContextMemory.reset(new (std::nothrow) sal_uInt8[nWidth * 4 * nHeight]);
79 if (mpContextMemory)
81 mrContext = CGBitmapContextCreate(mpContextMemory.get(),
82 nWidth, nHeight, 8, nWidth * 4,
83 GetSalData()->mxRGBSpace, kCGImageAlphaNoneSkipFirst);
84 if( mrContext )
85 SetupPrinterGraphics( mrContext );
89 AquaSalInfoPrinter::~AquaSalInfoPrinter()
91 delete mpGraphics;
92 if( mpPrintInfo )
93 [mpPrintInfo release];
94 if( mrContext )
95 CFRelease( mrContext );
98 void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const
100 if( mpGraphics )
102 if( mpPrintInfo )
104 // FIXME: get printer resolution
105 sal_Int32 nDPIX = 720, nDPIY = 720;
106 NSSize aPaperSize = [mpPrintInfo paperSize];
108 NSRect aImageRect = [mpPrintInfo imageablePageBounds];
109 if( mePageOrientation == Orientation::Portrait )
111 // move mirrored CTM back into paper
112 double dX = 0, dY = aPaperSize.height;
113 // move CTM to reflect imageable area
114 dX += aImageRect.origin.x;
115 dY -= aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
116 CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY );
117 // scale to be top/down and reflect our "virtual" DPI
118 CGContextScaleCTM( i_rContext, 72.0/double(nDPIX), -(72.0/double(nDPIY)) );
120 else
122 // move CTM to reflect imageable area
123 double dX = aImageRect.origin.x, dY = aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
124 CGContextTranslateCTM( i_rContext, -dX, -dY );
125 // turn by 90 degree
126 CGContextRotateCTM( i_rContext, M_PI/2 );
127 // move turned CTM back into paper
128 dX = aPaperSize.height;
129 dY = -aPaperSize.width;
130 CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX );
131 // scale to be top/down and reflect our "virtual" DPI
132 CGContextScaleCTM( i_rContext, -(72.0/double(nDPIY)), (72.0/double(nDPIX)) );
134 mpGraphics->SetPrinterGraphics( i_rContext, nDPIX, nDPIY );
136 else
137 OSL_FAIL( "no print info in SetupPrinterGraphics" );
141 SalGraphics* AquaSalInfoPrinter::AcquireGraphics()
143 SalGraphics* pGraphics = mbGraphics ? nullptr : mpGraphics;
144 mbGraphics = true;
145 return pGraphics;
148 void AquaSalInfoPrinter::ReleaseGraphics( SalGraphics* )
150 mbGraphics = false;
153 bool AquaSalInfoPrinter::Setup( weld::Window*, ImplJobSetup* )
155 return false;
158 bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
160 // FIXME: implement driver data
161 if( io_pSetupData && io_pSetupData->GetDriverData() )
162 return SetData( JobSetFlags::ALL, io_pSetupData );
164 bool bSuccess = true;
166 // set system type
167 io_pSetupData->SetSystem( JOBSETUP_SYSTEM_MAC );
169 // get paper format
170 if( mpPrintInfo )
172 NSSize aPaperSize = [mpPrintInfo paperSize];
173 double width = aPaperSize.width, height = aPaperSize.height;
174 // set paper
175 PaperInfo aInfo( PtTo10Mu( width ), PtTo10Mu( height ) );
176 aInfo.doSloppyFit();
177 io_pSetupData->SetPaperFormat( aInfo.getPaper() );
178 if( io_pSetupData->GetPaperFormat() == PAPER_USER )
180 io_pSetupData->SetPaperWidth( PtTo10Mu( width ) );
181 io_pSetupData->SetPaperHeight( PtTo10Mu( height ) );
183 else
185 io_pSetupData->SetPaperWidth( 0 );
186 io_pSetupData->SetPaperHeight( 0 );
189 // set orientation
190 io_pSetupData->SetOrientation( mePageOrientation );
192 io_pSetupData->SetPaperBin( 0 );
193 io_pSetupData->SetDriverData( std::make_unique<sal_uInt8[]>(4), 4 );
195 else
196 bSuccess = false;
198 return bSuccess;
201 void AquaSalInfoPrinter::setPaperSize( tools::Long i_nWidth, tools::Long i_nHeight, Orientation i_eSetOrientation )
204 Orientation ePaperOrientation = Orientation::Portrait;
205 const PaperInfo* pPaper = matchPaper( i_nWidth, i_nHeight, ePaperOrientation );
207 if( pPaper )
209 NSString* pPaperName = [CreateNSString( OStringToOUString(PaperInfo::toPSName(pPaper->getPaper()), RTL_TEXTENCODING_ASCII_US) ) autorelease];
210 [mpPrintInfo setPaperName: pPaperName];
212 else if( i_nWidth > 0 && i_nHeight > 0 )
214 NSSize aPaperSize = { static_cast<CGFloat>(TenMuToPt(i_nWidth)), static_cast<CGFloat>(TenMuToPt(i_nHeight)) };
215 [mpPrintInfo setPaperSize: aPaperSize];
217 // this seems counterintuitive
218 mePageOrientation = i_eSetOrientation;
221 bool AquaSalInfoPrinter::SetData( JobSetFlags i_nFlags, ImplJobSetup* io_pSetupData )
223 if( ! io_pSetupData || io_pSetupData->GetSystem() != JOBSETUP_SYSTEM_MAC )
224 return false;
226 if( mpPrintInfo )
228 if( i_nFlags & JobSetFlags::ORIENTATION )
229 mePageOrientation = io_pSetupData->GetOrientation();
231 if( i_nFlags & JobSetFlags::PAPERSIZE )
233 // set paper format
234 tools::Long width = 21000, height = 29700;
235 if( io_pSetupData->GetPaperFormat() == PAPER_USER )
237 // #i101108# sanity check
238 if( io_pSetupData->GetPaperWidth() && io_pSetupData->GetPaperHeight() )
240 width = io_pSetupData->GetPaperWidth();
241 height = io_pSetupData->GetPaperHeight();
244 else
246 PaperInfo aInfo( io_pSetupData->GetPaperFormat() );
247 width = aInfo.getWidth();
248 height = aInfo.getHeight();
251 setPaperSize( width, height, mePageOrientation );
255 return mpPrintInfo != nil;
258 sal_uInt16 AquaSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* )
260 return 0;
263 OUString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup*, sal_uInt16 )
265 return OUString();
268 sal_uInt16 AquaSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sal_uInt16 )
270 return 0xffff;
273 sal_uInt16 AquaSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup*, sal_uInt16)
275 return 0;
278 sal_uInt32 AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, PrinterCapType i_nType )
280 switch( i_nType )
282 case PrinterCapType::SupportDialog:
283 return 0;
284 case PrinterCapType::Copies:
285 return 0xffff;
286 case PrinterCapType::CollateCopies:
287 return 0xffff;
288 case PrinterCapType::SetOrientation:
289 return 1;
290 case PrinterCapType::SetPaperSize:
291 return 1;
292 case PrinterCapType::SetPaper:
293 return 1;
294 case PrinterCapType::ExternalDialog:
295 return officecfg::Office::Common::Misc::UseSystemPrintDialog::get()
296 ? 1 : 0;
297 case PrinterCapType::PDF:
298 return 1;
299 case PrinterCapType::UsePullModel:
300 return 1;
301 default: break;
303 return 0;
306 void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
307 tools::Long& o_rOutWidth, tools::Long& o_rOutHeight,
308 Point& rPageOffset,
309 Size& rPaperSize )
311 if( mpPrintInfo )
313 sal_Int32 nDPIX = 72, nDPIY = 72;
314 mpGraphics->GetResolution( nDPIX, nDPIY );
315 const double fXScaling = static_cast<double>(nDPIX)/72.0,
316 fYScaling = static_cast<double>(nDPIY)/72.0;
318 NSSize aPaperSize = [mpPrintInfo paperSize];
319 rPaperSize.setWidth( static_cast<tools::Long>( double(aPaperSize.width) * fXScaling ) );
320 rPaperSize.setHeight( static_cast<tools::Long>( double(aPaperSize.height) * fYScaling ) );
322 NSRect aImageRect = [mpPrintInfo imageablePageBounds];
323 rPageOffset.setX( static_cast<tools::Long>( aImageRect.origin.x * fXScaling ) );
324 rPageOffset.setY( static_cast<tools::Long>( (aPaperSize.height - aImageRect.size.height - aImageRect.origin.y) * fYScaling ) );
325 o_rOutWidth = static_cast<tools::Long>( aImageRect.size.width * fXScaling );
326 o_rOutHeight = static_cast<tools::Long>( aImageRect.size.height * fYScaling );
328 if( mePageOrientation == Orientation::Landscape )
330 std::swap( o_rOutWidth, o_rOutHeight );
331 // swap width and height
332 tools::Long n = rPaperSize.Width();
333 rPaperSize.setWidth(rPaperSize.Height());
334 rPaperSize.setHeight(n);
335 // swap offset x and y
336 n = rPageOffset.X();
337 rPageOffset.setX(rPageOffset.Y());
338 rPageOffset.setY(n);
343 static Size getPageSize( vcl::PrinterController const & i_rController, sal_Int32 i_nPage )
345 Size aPageSize;
346 uno::Sequence< PropertyValue > const aPageParms( i_rController.getPageParameters( i_nPage ) );
347 for( const PropertyValue & pv : aPageParms )
349 if ( pv.Name == "PageSize" )
351 awt::Size aSize;
352 pv.Value >>= aSize;
353 aPageSize.setWidth( aSize.Width );
354 aPageSize.setHeight( aSize.Height );
355 break;
358 return aPageSize;
361 bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName,
362 const OUString& i_rJobName,
363 ImplJobSetup* i_pSetupData,
364 vcl::PrinterController& i_rController
367 if( mbJob )
368 return false;
370 bool bSuccess = false;
371 bool bWasAborted = false;
372 AquaSalInstance* pInst = GetSalData()->mpInstance;
373 PrintAccessoryViewState aAccViewState;
374 sal_Int32 nAllPages = 0;
376 // reset IsLastPage
377 i_rController.setLastPage( false );
379 // update job data
380 if( i_pSetupData )
381 SetData( JobSetFlags::ALL, i_pSetupData );
383 // do we want a progress panel ?
384 bool bShowProgressPanel = true;
385 beans::PropertyValue* pMonitor = i_rController.getValue( OUString( "MonitorVisible" ) );
386 if( pMonitor )
387 pMonitor->Value >>= bShowProgressPanel;
388 if( ! i_rController.isShowDialogs() )
389 bShowProgressPanel = false;
391 // possibly create one job for collated output
392 bool bSinglePrintJobs = i_rController.getPrinter()->IsSinglePrintJobs();
394 // FIXME: jobStarted() should be done after the print dialog has ended (if there is one)
395 // how do I know when that might be ?
396 i_rController.jobStarted();
398 int nCopies = i_rController.getPrinter()->GetCopyCount();
399 int nJobs = 1;
400 if( bSinglePrintJobs )
402 nJobs = nCopies;
403 nCopies = 1;
406 for( int nCurJob = 0; nCurJob < nJobs; nCurJob++ )
408 aAccViewState.bNeedRestart = true;
411 if( aAccViewState.bNeedRestart )
413 mnCurPageRangeStart = 0;
414 mnCurPageRangeCount = 0;
415 nAllPages = i_rController.getFilteredPageCount();
418 aAccViewState.bNeedRestart = false;
420 Size aCurSize( 21000, 29700 );
421 if( nAllPages > 0 )
423 mnCurPageRangeCount = 1;
424 aCurSize = getPageSize( i_rController, mnCurPageRangeStart );
425 Size aNextSize( aCurSize );
427 // print pages up to a different size
428 while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages )
430 aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount );
431 if( aCurSize == aNextSize // same page size
433 (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation
436 mnCurPageRangeCount++;
438 else
439 break;
442 else
443 mnCurPageRangeCount = 0;
445 // now for the current run
446 mnStartPageOffsetX = mnStartPageOffsetY = 0;
447 // setup the paper size and orientation
448 // do this on our associated Printer object, since that is
449 // out interface to the applications which occasionally rely on the paper
450 // information (e.g. brochure printing scales to the found paper size)
451 // also SetPaperSizeUser has the advantage that we can share a
452 // platform independent paper matching algorithm
453 VclPtr<Printer> pPrinter( i_rController.getPrinter() );
454 pPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
455 pPrinter->SetPaperSizeUser( aCurSize );
457 // create view
458 NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this];
460 NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
462 // set filename
463 if( i_pFileName )
465 [mpPrintInfo setJobDisposition: NSPrintSaveJob];
466 NSString* pPath = CreateNSString( *i_pFileName );
467 [pPrintDict setObject:[NSURL fileURLWithPath:pPath] forKey:NSPrintJobSavingURL];
468 [pPath release];
471 [pPrintDict setObject: [[NSNumber numberWithInt: nCopies] autorelease] forKey: NSPrintCopies];
472 if( nCopies > 1 )
473 [pPrintDict setObject: [[NSNumber numberWithBool: pPrinter->IsCollateCopy()] autorelease] forKey: NSPrintMustCollate];
474 [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
475 [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
476 // #i103253# weird: for some reason, autoreleasing the value below like the others above
477 // leads do a double free malloc error. Why this value should behave differently from all the others
478 // is a mystery.
479 [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage];
481 // create print operation
482 NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
484 if( pPrintOperation )
486 NSObject* pReleaseAfterUse = nil;
487 bool bShowPanel = !i_rController.isDirectPrint()
488 && (officecfg::Office::Common::Misc::UseSystemPrintDialog::
489 get())
490 && i_rController.isShowDialogs();
491 [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
492 [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO];
494 // set job title (since MacOSX 10.5)
495 if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] )
496 [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]];
498 if( bShowPanel && mnCurPageRangeStart == 0 && nCurJob == 0) // only the first range of pages (in the first job) gets the accessory view
499 pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState];
501 bSuccess = true;
502 mbJob = true;
503 pInst->startedPrintJob();
504 bool wasSuccessful = [pPrintOperation runOperation];
505 pInst->endedPrintJob();
506 bSuccess = wasSuccessful;
507 bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame;
508 mbJob = false;
509 if( pReleaseAfterUse )
510 [pReleaseAfterUse release];
513 mnCurPageRangeStart += mnCurPageRangeCount;
514 mnCurPageRangeCount = 1;
515 } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages );
518 // inform application that it can release its data
519 // this is awkward, but the XRenderable interface has no method for this,
520 // so we need to call XRenderable::render one last time with IsLastPage = true
521 i_rController.setLastPage( true );
522 GDIMetaFile aPageFile;
523 if( mrContext )
524 SetupPrinterGraphics( mrContext );
525 i_rController.getFilteredPageFile( 0, aPageFile );
527 i_rController.setJobState( bWasAborted
528 ? view::PrintableState_JOB_ABORTED
529 : view::PrintableState_JOB_SPOOLED );
531 mnCurPageRangeStart = mnCurPageRangeCount = 0;
533 return bSuccess;
536 bool AquaSalInfoPrinter::EndJob()
538 mnStartPageOffsetX = mnStartPageOffsetY = 0;
539 mbJob = false;
540 return true;
543 bool AquaSalInfoPrinter::AbortJob()
545 mbJob = false;
547 // FIXME: implementation
548 return false;
551 SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
553 if( i_bNewJobData && i_pSetupData )
554 SetPrinterData( i_pSetupData );
556 CGContextRef rContext = [[NSGraphicsContext currentContext] CGContext];
558 SetupPrinterGraphics( rContext );
560 return mpGraphics;
563 bool AquaSalInfoPrinter::EndPage()
565 mpGraphics->InvalidateContext();
566 return true;
569 AquaSalPrinter::AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter ) :
570 mpInfoPrinter( i_pInfoPrinter )
574 AquaSalPrinter::~AquaSalPrinter()
578 bool AquaSalPrinter::StartJob( const OUString* i_pFileName,
579 const OUString& i_rJobName,
580 const OUString&,
581 ImplJobSetup* i_pSetupData,
582 vcl::PrinterController& i_rController )
584 return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_pSetupData, i_rController );
587 bool AquaSalPrinter::StartJob( const OUString* /*i_pFileName*/,
588 const OUString& /*i_rJobName*/,
589 const OUString& /*i_rAppName*/,
590 sal_uInt32 /*i_nCopies*/,
591 bool /*i_bCollate*/,
592 bool /*i_bDirect*/,
593 ImplJobSetup* )
595 OSL_FAIL( "should never be called" );
596 return false;
599 bool AquaSalPrinter::EndJob()
601 return mpInfoPrinter->EndJob();
604 SalGraphics* AquaSalPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
606 return mpInfoPrinter->StartPage( i_pSetupData, i_bNewJobData );
609 void AquaSalPrinter::EndPage()
611 mpInfoPrinter->EndPage();
614 void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
616 m_aPaperFormats.clear();
617 m_bPapersInit = true;
619 if( mpPrinter )
621 SAL_WNODEPRECATED_DECLARATIONS_PUSH
622 //TODO: 10.9 statusForTable:, stringListForKey:inTable:
623 if( [mpPrinter statusForTable: @"PPD"] == NSPrinterTableOK )
625 NSArray* pPaperNames = [mpPrinter stringListForKey: @"PageSize" inTable: @"PPD"];
626 if( pPaperNames )
628 unsigned int nPapers = [pPaperNames count];
629 for( unsigned int i = 0; i < nPapers; i++ )
631 NSString* pPaper = [pPaperNames objectAtIndex: i];
632 // first try to match the name
633 OString aPaperName( [pPaper UTF8String] );
634 Paper ePaper = PaperInfo::fromPSName( aPaperName );
635 if( ePaper != PAPER_USER )
637 m_aPaperFormats.push_back( PaperInfo( ePaper ) );
639 else
641 NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper];
642 if( aPaperSize.width > 0 && aPaperSize.height > 0 )
644 PaperInfo aInfo( PtTo10Mu( aPaperSize.width ),
645 PtTo10Mu( aPaperSize.height ) );
646 if( aInfo.getPaper() == PAPER_USER )
647 aInfo.doSloppyFit();
648 m_aPaperFormats.push_back( aInfo );
654 SAL_WNODEPRECATED_DECLARATIONS_POP
658 const PaperInfo* AquaSalInfoPrinter::matchPaper( tools::Long i_nWidth, tools::Long i_nHeight, Orientation& o_rOrientation ) const
660 if( ! m_bPapersInit )
661 const_cast<AquaSalInfoPrinter*>(this)->InitPaperFormats( nullptr );
663 const PaperInfo* pMatch = nullptr;
664 o_rOrientation = Orientation::Portrait;
665 for( int n = 0; n < 2 ; n++ )
667 for( size_t i = 0; i < m_aPaperFormats.size(); i++ )
669 if( std::abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 50 &&
670 std::abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 50 )
672 pMatch = &m_aPaperFormats[i];
673 return pMatch;
676 o_rOrientation = Orientation::Landscape;
677 std::swap( i_nWidth, i_nHeight );
679 return pMatch;
682 int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* )
684 return 900;
687 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */