Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / osx / salprn.cxx
blob7d48ffa99d161895ccd136a0c95ba7ffad17293e
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/print.hxx>
23 #include <sal/macros.h>
25 #include "osx/salinst.h"
26 #include "osx/salprn.h"
27 #include "osx/printview.h"
28 #include "quartz/salgdi.h"
29 #include "osx/saldata.hxx"
30 #include "quartz/utils.h"
32 #include "jobset.h"
33 #include "salptype.hxx"
35 #include "com/sun/star/beans/PropertyValue.hpp"
36 #include "com/sun/star/awt/Size.hpp"
37 #include "com/sun/star/uno/Sequence.hxx"
39 #include <algorithm>
40 #include <cstdlib>
42 using namespace vcl;
43 using namespace com::sun::star;
44 using namespace com::sun::star::beans;
46 AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) :
47 mpGraphics( nullptr ),
48 mbGraphics( false ),
49 mbJob( false ),
50 mpPrinter( nil ),
51 mpPrintInfo( nil ),
52 mePageOrientation( Orientation::Portrait ),
53 mnStartPageOffsetX( 0 ),
54 mnStartPageOffsetY( 0 ),
55 mnCurPageRangeStart( 0 ),
56 mnCurPageRangeCount( 0 )
58 NSString* pStr = CreateNSString( i_rQueue.maPrinterName );
59 mpPrinter = [NSPrinter printerWithName: pStr];
60 [pStr release];
62 NSPrintInfo* pShared = [NSPrintInfo sharedPrintInfo];
63 if( pShared )
65 mpPrintInfo = [pShared copy];
66 [mpPrintInfo setPrinter: mpPrinter];
67 #if MACOSX_SDK_VERSION >= 1090
68 mePageOrientation = ([mpPrintInfo orientation] == NSPaperOrientationPortrait) ? Orientation::Landscape : Orientation::Portrait;
69 [mpPrintInfo setOrientation: NSPaperOrientationPortrait];
70 #else
71 mePageOrientation = ([mpPrintInfo orientation] == NSLandscapeOrientation) ? Orientation::Landscape : Orientation::Portrait;
72 [mpPrintInfo setOrientation: NSPortraitOrientation];
73 #endif
76 mpGraphics = new AquaSalGraphics();
78 const int nWidth = 100, nHeight = 100;
79 mpContextMemory.reset(static_cast<sal_uInt8*>(rtl_allocateMemory(nWidth * 4 * nHeight)),
80 &rtl_freeMemory);
82 if (mpContextMemory)
84 mrContext = CGBitmapContextCreate(mpContextMemory.get(),
85 nWidth, nHeight, 8, nWidth * 4,
86 GetSalData()->mxRGBSpace, kCGImageAlphaNoneSkipFirst);
87 if( mrContext )
88 SetupPrinterGraphics( mrContext );
92 AquaSalInfoPrinter::~AquaSalInfoPrinter()
94 delete mpGraphics;
95 if( mpPrintInfo )
96 [mpPrintInfo release];
97 if( mrContext )
98 CFRelease( mrContext );
101 void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const
103 if( mpGraphics )
105 if( mpPrintInfo )
107 // FIXME: get printer resolution
108 long nDPIX = 720, nDPIY = 720;
109 NSSize aPaperSize = [mpPrintInfo paperSize];
111 NSRect aImageRect = [mpPrintInfo imageablePageBounds];
112 if( mePageOrientation == Orientation::Portrait )
114 // move mirrored CTM back into paper
115 double dX = 0, dY = aPaperSize.height;
116 // move CTM to reflect imageable area
117 dX += aImageRect.origin.x;
118 dY -= aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
119 CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY );
120 // scale to be top/down and reflect our "virtual" DPI
121 CGContextScaleCTM( i_rContext, 72.0/double(nDPIX), -(72.0/double(nDPIY)) );
123 else
125 // move CTM to reflect imageable area
126 double dX = aImageRect.origin.x, dY = aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
127 CGContextTranslateCTM( i_rContext, -dX, -dY );
128 // turn by 90 degree
129 CGContextRotateCTM( i_rContext, M_PI/2 );
130 // move turned CTM back into paper
131 dX = aPaperSize.height;
132 dY = -aPaperSize.width;
133 CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX );
134 // scale to be top/down and reflect our "virtual" DPI
135 CGContextScaleCTM( i_rContext, -(72.0/double(nDPIY)), (72.0/double(nDPIX)) );
137 mpGraphics->SetPrinterGraphics( i_rContext, nDPIX, nDPIY );
139 else
140 OSL_FAIL( "no print info in SetupPrinterGraphics" );
144 SalGraphics* AquaSalInfoPrinter::AcquireGraphics()
146 SalGraphics* pGraphics = mbGraphics ? nullptr : mpGraphics;
147 mbGraphics = true;
148 return pGraphics;
151 void AquaSalInfoPrinter::ReleaseGraphics( SalGraphics* )
153 mbGraphics = false;
156 bool AquaSalInfoPrinter::Setup( SalFrame*, ImplJobSetup* )
158 return false;
161 bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
163 // FIXME: implement driver data
164 if( io_pSetupData && io_pSetupData->GetDriverData() )
165 return SetData( JobSetFlags::ALL, io_pSetupData );
167 bool bSuccess = true;
169 // set system type
170 io_pSetupData->SetSystem( JOBSETUP_SYSTEM_MAC );
172 // get paper format
173 if( mpPrintInfo )
175 NSSize aPaperSize = [mpPrintInfo paperSize];
176 double width = aPaperSize.width, height = aPaperSize.height;
177 // set paper
178 PaperInfo aInfo( PtTo10Mu( width ), PtTo10Mu( height ) );
179 aInfo.doSloppyFit();
180 io_pSetupData->SetPaperFormat( aInfo.getPaper() );
181 if( io_pSetupData->GetPaperFormat() == PAPER_USER )
183 io_pSetupData->SetPaperWidth( PtTo10Mu( width ) );
184 io_pSetupData->SetPaperHeight( PtTo10Mu( height ) );
186 else
188 io_pSetupData->SetPaperWidth( 0 );
189 io_pSetupData->SetPaperHeight( 0 );
192 // set orientation
193 io_pSetupData->SetOrientation( mePageOrientation );
195 io_pSetupData->SetPaperBin( 0 );
196 io_pSetupData->SetDriverData( static_cast<sal_uInt8*>(rtl_allocateMemory( 4 )) );
197 io_pSetupData->SetDriverDataLen( 4 );
199 else
200 bSuccess = false;
202 return bSuccess;
205 void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation )
208 Orientation ePaperOrientation = Orientation::Portrait;
209 const PaperInfo* pPaper = matchPaper( i_nWidth, i_nHeight, ePaperOrientation );
211 if( pPaper )
213 NSString* pPaperName = [CreateNSString( OStringToOUString(PaperInfo::toPSName(pPaper->getPaper()), RTL_TEXTENCODING_ASCII_US) ) autorelease];
214 [mpPrintInfo setPaperName: pPaperName];
216 else if( i_nWidth > 0 && i_nHeight > 0 )
218 NSSize aPaperSize = { static_cast<CGFloat>(TenMuToPt(i_nWidth)), static_cast<CGFloat>(TenMuToPt(i_nHeight)) };
219 [mpPrintInfo setPaperSize: aPaperSize];
221 // this seems counterintuitive
222 mePageOrientation = i_eSetOrientation;
225 bool AquaSalInfoPrinter::SetData( JobSetFlags i_nFlags, ImplJobSetup* io_pSetupData )
227 if( ! io_pSetupData || io_pSetupData->GetSystem() != JOBSETUP_SYSTEM_MAC )
228 return false;
230 if( mpPrintInfo )
232 if( i_nFlags & JobSetFlags::ORIENTATION )
233 mePageOrientation = io_pSetupData->GetOrientation();
235 if( i_nFlags & JobSetFlags::PAPERSIZE )
237 // set paper format
238 long width = 21000, height = 29700;
239 if( io_pSetupData->GetPaperFormat() == PAPER_USER )
241 // #i101108# sanity check
242 if( io_pSetupData->GetPaperWidth() && io_pSetupData->GetPaperHeight() )
244 width = io_pSetupData->GetPaperWidth();
245 height = io_pSetupData->GetPaperHeight();
248 else
250 PaperInfo aInfo( io_pSetupData->GetPaperFormat() );
251 width = aInfo.getWidth();
252 height = aInfo.getHeight();
255 setPaperSize( width, height, mePageOrientation );
259 return mpPrintInfo != nil;
262 sal_uInt16 AquaSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* )
264 return 0;
267 OUString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup*, sal_uInt16 )
269 return OUString();
272 sal_uInt32 AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, PrinterCapType i_nType )
274 switch( i_nType )
276 case PrinterCapType::SupportDialog:
277 return 0;
278 case PrinterCapType::Copies:
279 return 0xffff;
280 case PrinterCapType::CollateCopies:
281 return 0xffff;
282 case PrinterCapType::SetOrientation:
283 return 1;
284 case PrinterCapType::SetPaperSize:
285 return 1;
286 case PrinterCapType::SetPaper:
287 return 1;
288 case PrinterCapType::ExternalDialog:
289 return officecfg::Office::Common::Misc::UseSystemPrintDialog::get()
290 ? 1 : 0;
291 case PrinterCapType::PDF:
292 return 1;
293 case PrinterCapType::UsePullModel:
294 return 1;
295 default: break;
297 return 0;
300 void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
301 long& o_rOutWidth, long& o_rOutHeight,
302 long& o_rPageOffX, long& o_rPageOffY,
303 long& o_rPageWidth, long& o_rPageHeight )
305 if( mpPrintInfo )
307 sal_Int32 nDPIX = 72, nDPIY = 72;
308 mpGraphics->GetResolution( nDPIX, nDPIY );
309 const double fXScaling = static_cast<double>(nDPIX)/72.0,
310 fYScaling = static_cast<double>(nDPIY)/72.0;
312 NSSize aPaperSize = [mpPrintInfo paperSize];
313 o_rPageWidth = static_cast<long>( double(aPaperSize.width) * fXScaling );
314 o_rPageHeight = static_cast<long>( double(aPaperSize.height) * fYScaling );
316 NSRect aImageRect = [mpPrintInfo imageablePageBounds];
317 o_rPageOffX = static_cast<long>( aImageRect.origin.x * fXScaling );
318 o_rPageOffY = static_cast<long>( (aPaperSize.height - aImageRect.size.height - aImageRect.origin.y) * fYScaling );
319 o_rOutWidth = static_cast<long>( aImageRect.size.width * fXScaling );
320 o_rOutHeight = static_cast<long>( aImageRect.size.height * fYScaling );
322 if( mePageOrientation == Orientation::Landscape )
324 std::swap( o_rOutWidth, o_rOutHeight );
325 std::swap( o_rPageWidth, o_rPageHeight );
326 std::swap( o_rPageOffX, o_rPageOffY );
331 static Size getPageSize( vcl::PrinterController& i_rController, sal_Int32 i_nPage )
333 Size aPageSize;
334 uno::Sequence< PropertyValue > aPageParms( i_rController.getPageParameters( i_nPage ) );
335 for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty )
337 if ( aPageParms[ nProperty ].Name == "PageSize" )
339 awt::Size aSize;
340 aPageParms[ nProperty].Value >>= aSize;
341 aPageSize.Width() = aSize.Width;
342 aPageSize.Height() = aSize.Height;
343 break;
346 return aPageSize;
349 bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName,
350 const OUString& i_rJobName,
351 const OUString& /*i_rAppName*/,
352 ImplJobSetup* i_pSetupData,
353 vcl::PrinterController& i_rController
356 if( mbJob )
357 return false;
359 bool bSuccess = false;
360 bool bWasAborted = false;
361 AquaSalInstance* pInst = GetSalData()->mpFirstInstance;
362 PrintAccessoryViewState aAccViewState;
363 sal_Int32 nAllPages = 0;
365 // reset IsLastPage
366 i_rController.setLastPage( false );
368 // update job data
369 if( i_pSetupData )
370 SetData( JobSetFlags::ALL, i_pSetupData );
372 // do we want a progress panel ?
373 bool bShowProgressPanel = true;
374 beans::PropertyValue* pMonitor = i_rController.getValue( OUString( "MonitorVisible" ) );
375 if( pMonitor )
376 pMonitor->Value >>= bShowProgressPanel;
377 if( ! i_rController.isShowDialogs() )
378 bShowProgressPanel = false;
380 // possibly create one job for collated output
381 bool bSinglePrintJobs = false;
382 beans::PropertyValue* pSingleValue = i_rController.getValue( OUString( "PrintCollateAsSingleJobs" ) );
383 if( pSingleValue )
385 pSingleValue->Value >>= bSinglePrintJobs;
388 // FIXME: jobStarted() should be done after the print dialog has ended (if there is one)
389 // how do I know when that might be ?
390 i_rController.jobStarted();
392 int nCopies = i_rController.getPrinter()->GetCopyCount();
393 int nJobs = 1;
394 if( bSinglePrintJobs )
396 nJobs = nCopies;
397 nCopies = 1;
400 for( int nCurJob = 0; nCurJob < nJobs; nCurJob++ )
402 aAccViewState.bNeedRestart = true;
405 if( aAccViewState.bNeedRestart )
407 mnCurPageRangeStart = 0;
408 mnCurPageRangeCount = 0;
409 nAllPages = i_rController.getFilteredPageCount();
412 aAccViewState.bNeedRestart = false;
414 Size aCurSize( 21000, 29700 );
415 if( nAllPages > 0 )
417 mnCurPageRangeCount = 1;
418 aCurSize = getPageSize( i_rController, mnCurPageRangeStart );
419 Size aNextSize( aCurSize );
421 // print pages up to a different size
422 while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages )
424 aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount );
425 if( aCurSize == aNextSize // same page size
427 (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation
430 mnCurPageRangeCount++;
432 else
433 break;
436 else
437 mnCurPageRangeCount = 0;
439 // now for the current run
440 mnStartPageOffsetX = mnStartPageOffsetY = 0;
441 // setup the paper size and orientation
442 // do this on our associated Printer object, since that is
443 // out interface to the applications which occasionally rely on the paper
444 // information (e.g. brochure printing scales to the found paper size)
445 // also SetPaperSizeUser has the advantage that we can share a
446 // platform independent paper matching algorithm
447 VclPtr<Printer> pPrinter( i_rController.getPrinter() );
448 pPrinter->SetMapMode( MapMode( MapUnit::Map100thMM ) );
449 pPrinter->SetPaperSizeUser( aCurSize, true );
451 // create view
452 NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this];
454 NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
456 // set filename
457 if( i_pFileName )
459 [mpPrintInfo setJobDisposition: NSPrintSaveJob];
460 NSString* pPath = CreateNSString( *i_pFileName );
461 [pPrintDict setObject:[NSURL fileURLWithPath:pPath] forKey:NSPrintJobSavingURL];
462 [pPath release];
465 [pPrintDict setObject: [[NSNumber numberWithInt: nCopies] autorelease] forKey: NSPrintCopies];
466 if( nCopies > 1 )
467 [pPrintDict setObject: [[NSNumber numberWithBool: pPrinter->IsCollateCopy()] autorelease] forKey: NSPrintMustCollate];
468 [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
469 [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
470 // #i103253# weird: for some reason, autoreleasing the value below like the others above
471 // leads do a double free malloc error. Why this value should behave differently from all the others
472 // is a mystery.
473 [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage];
475 // create print operation
476 NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
478 if( pPrintOperation )
480 NSObject* pReleaseAfterUse = nil;
481 bool bShowPanel = !i_rController.isDirectPrint()
482 && (officecfg::Office::Common::Misc::UseSystemPrintDialog::
483 get())
484 && i_rController.isShowDialogs();
485 [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
486 [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO];
488 // set job title (since MacOSX 10.5)
489 if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] )
490 [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]];
492 if( bShowPanel && mnCurPageRangeStart == 0 && nCurJob == 0) // only the first range of pages (in the first job) gets the accessory view
493 pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState];
495 bSuccess = true;
496 mbJob = true;
497 pInst->startedPrintJob();
498 BOOL wasSuccessful = [pPrintOperation runOperation];
499 pInst->endedPrintJob();
500 bSuccess = wasSuccessful;
501 bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame;
502 mbJob = false;
503 if( pReleaseAfterUse )
504 [pReleaseAfterUse release];
507 mnCurPageRangeStart += mnCurPageRangeCount;
508 mnCurPageRangeCount = 1;
509 } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages );
512 // inform application that it can release its data
513 // this is awkward, but the XRenderable interface has no method for this,
514 // so we need to call XRenderadble::render one last time with IsLastPage = true
515 i_rController.setLastPage( true );
516 GDIMetaFile aPageFile;
517 if( mrContext )
518 SetupPrinterGraphics( mrContext );
519 i_rController.getFilteredPageFile( 0, aPageFile );
521 i_rController.setJobState( bWasAborted
522 ? view::PrintableState_JOB_ABORTED
523 : view::PrintableState_JOB_SPOOLED );
525 mnCurPageRangeStart = mnCurPageRangeCount = 0;
527 return bSuccess;
530 bool AquaSalInfoPrinter::EndJob()
532 mnStartPageOffsetX = mnStartPageOffsetY = 0;
533 mbJob = false;
534 return true;
537 bool AquaSalInfoPrinter::AbortJob()
539 mbJob = false;
541 // FIXME: implementation
542 return false;
545 SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
547 if( i_bNewJobData && i_pSetupData )
548 SetPrinterData( i_pSetupData );
550 CGContextRef rContext = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
552 SetupPrinterGraphics( rContext );
554 return mpGraphics;
557 bool AquaSalInfoPrinter::EndPage()
559 mpGraphics->InvalidateContext();
560 return true;
563 sal_uLong AquaSalInfoPrinter::GetErrorCode()
565 return 0;
568 AquaSalPrinter::AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter ) :
569 mpInfoPrinter( i_pInfoPrinter )
573 AquaSalPrinter::~AquaSalPrinter()
577 bool AquaSalPrinter::StartJob( const OUString* i_pFileName,
578 const OUString& i_rJobName,
579 const OUString& i_rAppName,
580 ImplJobSetup* i_pSetupData,
581 vcl::PrinterController& i_rController )
583 return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController );
586 bool AquaSalPrinter::StartJob( const OUString* /*i_pFileName*/,
587 const OUString& /*i_rJobName*/,
588 const OUString& /*i_rAppName*/,
589 sal_uInt32 /*i_nCopies*/,
590 bool /*i_bCollate*/,
591 bool /*i_bDirect*/,
592 ImplJobSetup* )
594 OSL_FAIL( "should never be called" );
595 return false;
598 bool AquaSalPrinter::EndJob()
600 return mpInfoPrinter->EndJob();
603 SalGraphics* AquaSalPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
605 return mpInfoPrinter->StartPage( i_pSetupData, i_bNewJobData );
608 void AquaSalPrinter::EndPage()
610 mpInfoPrinter->EndPage();
613 sal_uLong AquaSalPrinter::GetErrorCode()
615 return AquaSalInfoPrinter::GetErrorCode();
618 void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
620 m_aPaperFormats.clear();
621 m_bPapersInit = true;
623 if( mpPrinter )
625 SAL_WNODEPRECATED_DECLARATIONS_PUSH
626 //TODO: 10.9 statusForTable:, stringListForKey:inTable:
627 if( [mpPrinter statusForTable: @"PPD"] == NSPrinterTableOK )
629 NSArray* pPaperNames = [mpPrinter stringListForKey: @"PageSize" inTable: @"PPD"];
630 if( pPaperNames )
632 unsigned int nPapers = [pPaperNames count];
633 for( unsigned int i = 0; i < nPapers; i++ )
635 NSString* pPaper = [pPaperNames objectAtIndex: i];
636 // first try to match the name
637 OString aPaperName( [pPaper UTF8String] );
638 Paper ePaper = PaperInfo::fromPSName( aPaperName );
639 if( ePaper != PAPER_USER )
641 m_aPaperFormats.push_back( PaperInfo( ePaper ) );
643 else
645 NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper];
646 if( aPaperSize.width > 0 && aPaperSize.height > 0 )
648 PaperInfo aInfo( PtTo10Mu( aPaperSize.width ),
649 PtTo10Mu( aPaperSize.height ) );
650 if( aInfo.getPaper() == PAPER_USER )
651 aInfo.doSloppyFit();
652 m_aPaperFormats.push_back( aInfo );
658 SAL_WNODEPRECATED_DECLARATIONS_POP
662 const PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const
664 if( ! m_bPapersInit )
665 const_cast<AquaSalInfoPrinter*>(this)->InitPaperFormats( nullptr );
667 const PaperInfo* pMatch = nullptr;
668 o_rOrientation = Orientation::Portrait;
669 for( int n = 0; n < 2 ; n++ )
671 for( size_t i = 0; i < m_aPaperFormats.size(); i++ )
673 if( std::abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 50 &&
674 std::abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 50 )
676 pMatch = &m_aPaperFormats[i];
677 return pMatch;
680 o_rOrientation = Orientation::Landscape;
681 std::swap( i_nWidth, i_nHeight );
683 return pMatch;
686 int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* )
688 return 900;
691 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */