Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / osx / salprn.cxx
blob4995ae00f5f05f884f4cda6cd51ac0aa097a5c7c
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 <boost/bind.hpp>
22 #include "officecfg/Office/Common.hxx"
24 #include "vcl/print.hxx"
25 #include <sal/macros.h>
27 #include "osx/salinst.h"
28 #include "osx/salprn.h"
29 #include "osx/printview.h"
30 #include "quartz/salgdi.h"
31 #include "osx/saldata.hxx"
32 #include "quartz/utils.h"
34 #include "jobset.h"
35 #include "salptype.hxx"
37 #include "com/sun/star/beans/PropertyValue.hpp"
38 #include "com/sun/star/awt/Size.hpp"
39 #include "com/sun/star/uno/Sequence.hxx"
41 #include <algorithm>
42 #include <cstdlib>
44 using namespace vcl;
45 using namespace com::sun::star;
46 using namespace com::sun::star::beans;
48 AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) :
49 mpGraphics( 0 ),
50 mbGraphics( false ),
51 mbJob( false ),
52 mpPrinter( nil ),
53 mpPrintInfo( nil ),
54 mePageOrientation( ORIENTATION_PORTRAIT ),
55 mnStartPageOffsetX( 0 ),
56 mnStartPageOffsetY( 0 ),
57 mnCurPageRangeStart( 0 ),
58 mnCurPageRangeCount( 0 )
60 NSString* pStr = CreateNSString( i_rQueue.maPrinterName );
61 mpPrinter = [NSPrinter printerWithName: pStr];
62 [pStr release];
64 NSPrintInfo* pShared = [NSPrintInfo sharedPrintInfo];
65 if( pShared )
67 mpPrintInfo = [pShared copy];
68 [mpPrintInfo setPrinter: mpPrinter];
69 #if MACOSX_SDK_VERSION >= 1090
70 mePageOrientation = ([mpPrintInfo orientation] == NSPaperOrientationPortrait) ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
71 [mpPrintInfo setOrientation: NSPaperOrientationPortrait];
72 #else
73 mePageOrientation = ([mpPrintInfo orientation] == NSLandscapeOrientation) ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
74 [mpPrintInfo setOrientation: NSPortraitOrientation];
75 #endif
78 mpGraphics = new AquaSalGraphics();
80 const int nWidth = 100, nHeight = 100;
81 maContextMemory.reset( static_cast<sal_uInt8*>( rtl_allocateMemory( nWidth * 4 * nHeight ) ),
82 boost::bind( rtl_freeMemory, _1 ) );
84 if( maContextMemory )
86 mrContext = CGBitmapContextCreate( maContextMemory.get(), nWidth, nHeight, 8, nWidth * 4, 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 ? NULL : 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->mpDriverData )
165 return SetData( ~0, io_pSetupData );
167 bool bSuccess = true;
169 // set system type
170 io_pSetupData->mnSystem = 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->mePaperFormat = aInfo.getPaper();
181 if( io_pSetupData->mePaperFormat == PAPER_USER )
183 io_pSetupData->mnPaperWidth = PtTo10Mu( width );
184 io_pSetupData->mnPaperHeight = PtTo10Mu( height );
186 else
188 io_pSetupData->mnPaperWidth = 0;
189 io_pSetupData->mnPaperHeight = 0;
192 // set orientation
193 io_pSetupData->meOrientation = mePageOrientation;
195 io_pSetupData->mnPaperBin = 0;
196 io_pSetupData->mpDriverData = static_cast<sal_uInt8*>(rtl_allocateMemory( 4 ));
197 io_pSetupData->mnDriverDataLen = 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( sal_uLong i_nFlags, ImplJobSetup* io_pSetupData )
227 if( ! io_pSetupData || io_pSetupData->mnSystem != JOBSETUP_SYSTEM_MAC )
228 return false;
230 if( mpPrintInfo )
232 if( (i_nFlags & SAL_JOBSET_ORIENTATION) != 0 )
233 mePageOrientation = io_pSetupData->meOrientation;
235 if( (i_nFlags & SAL_JOBSET_PAPERSIZE) != 0)
237 // set paper format
238 long width = 21000, height = 29700;
239 if( io_pSetupData->mePaperFormat == PAPER_USER )
241 // #i101108# sanity check
242 if( io_pSetupData->mnPaperWidth && io_pSetupData->mnPaperHeight )
244 width = io_pSetupData->mnPaperWidth;
245 height = io_pSetupData->mnPaperHeight;
248 else
250 PaperInfo aInfo( io_pSetupData->mePaperFormat );
251 width = aInfo.getWidth();
252 height = aInfo.getHeight();
255 setPaperSize( width, height, mePageOrientation );
259 return mpPrintInfo != nil;
262 sal_uLong AquaSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* )
264 return 0;
267 OUString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup*, sal_uLong )
269 return OUString();
272 sal_uLong AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, sal_uInt16 i_nType )
274 switch( i_nType )
276 case PRINTER_CAPABILITIES_SUPPORTDIALOG:
277 return 0;
278 case PRINTER_CAPABILITIES_COPIES:
279 return 0xffff;
280 case PRINTER_CAPABILITIES_COLLATECOPIES:
281 return 0xffff;
282 case PRINTER_CAPABILITIES_SETORIENTATION:
283 return 1;
284 case PRINTER_CAPABILITIES_SETDUPLEX:
285 return 0;
286 case PRINTER_CAPABILITIES_SETPAPERBIN:
287 return 0;
288 case PRINTER_CAPABILITIES_SETPAPERSIZE:
289 return 1;
290 case PRINTER_CAPABILITIES_SETPAPER:
291 return 1;
292 case PRINTER_CAPABILITIES_EXTERNALDIALOG:
293 return officecfg::Office::Common::Misc::UseSystemPrintDialog::get()
294 ? 1 : 0;
295 case PRINTER_CAPABILITIES_PDF:
296 return 1;
297 case PRINTER_CAPABILITIES_USEPULLMODEL:
298 return 1;
299 default: break;
301 return 0;
304 void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
305 long& o_rOutWidth, long& o_rOutHeight,
306 long& o_rPageOffX, long& o_rPageOffY,
307 long& o_rPageWidth, long& o_rPageHeight )
309 if( mpPrintInfo )
311 sal_Int32 nDPIX = 72, nDPIY = 72;
312 mpGraphics->GetResolution( nDPIX, nDPIY );
313 const double fXScaling = static_cast<double>(nDPIX)/72.0,
314 fYScaling = static_cast<double>(nDPIY)/72.0;
316 NSSize aPaperSize = [mpPrintInfo paperSize];
317 o_rPageWidth = static_cast<long>( double(aPaperSize.width) * fXScaling );
318 o_rPageHeight = static_cast<long>( double(aPaperSize.height) * fYScaling );
320 NSRect aImageRect = [mpPrintInfo imageablePageBounds];
321 o_rPageOffX = static_cast<long>( aImageRect.origin.x * fXScaling );
322 o_rPageOffY = static_cast<long>( (aPaperSize.height - aImageRect.size.height - aImageRect.origin.y) * fYScaling );
323 o_rOutWidth = static_cast<long>( aImageRect.size.width * fXScaling );
324 o_rOutHeight = static_cast<long>( aImageRect.size.height * fYScaling );
326 if( mePageOrientation == ORIENTATION_LANDSCAPE )
328 std::swap( o_rOutWidth, o_rOutHeight );
329 std::swap( o_rPageWidth, o_rPageHeight );
330 std::swap( o_rPageOffX, o_rPageOffY );
335 static Size getPageSize( vcl::PrinterController& i_rController, sal_Int32 i_nPage )
337 Size aPageSize;
338 uno::Sequence< PropertyValue > aPageParms( i_rController.getPageParameters( i_nPage ) );
339 for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty )
341 if ( aPageParms[ nProperty ].Name == "PageSize" )
343 awt::Size aSize;
344 aPageParms[ nProperty].Value >>= aSize;
345 aPageSize.Width() = aSize.Width;
346 aPageSize.Height() = aSize.Height;
347 break;
350 return aPageSize;
353 bool AquaSalInfoPrinter::StartJob( const OUString* i_pFileName,
354 const OUString& i_rJobName,
355 const OUString& /*i_rAppName*/,
356 ImplJobSetup* i_pSetupData,
357 vcl::PrinterController& i_rController
360 if( mbJob )
361 return false;
363 bool bSuccess = false;
364 bool bWasAborted = false;
365 AquaSalInstance* pInst = GetSalData()->mpFirstInstance;
366 PrintAccessoryViewState aAccViewState;
367 sal_Int32 nAllPages = 0;
369 // reset IsLastPage
370 i_rController.setLastPage( false );
372 // update job data
373 if( i_pSetupData )
374 SetData( ~0, i_pSetupData );
376 // do we want a progress panel ?
377 bool bShowProgressPanel = true;
378 beans::PropertyValue* pMonitor = i_rController.getValue( OUString( "MonitorVisible" ) );
379 if( pMonitor )
380 pMonitor->Value >>= bShowProgressPanel;
381 if( ! i_rController.isShowDialogs() )
382 bShowProgressPanel = false;
384 // possibly create one job for collated output
385 bool bSinglePrintJobs = false;
386 beans::PropertyValue* pSingleValue = i_rController.getValue( OUString( "PrintCollateAsSingleJobs" ) );
387 if( pSingleValue )
389 pSingleValue->Value >>= bSinglePrintJobs;
392 // FIXME: jobStarted() should be done after the print dialog has ended (if there is one)
393 // how do I know when that might be ?
394 i_rController.jobStarted();
396 int nCopies = i_rController.getPrinter()->GetCopyCount();
397 int nJobs = 1;
398 if( bSinglePrintJobs )
400 nJobs = nCopies;
401 nCopies = 1;
404 for( int nCurJob = 0; nCurJob < nJobs; nCurJob++ )
406 aAccViewState.bNeedRestart = true;
409 if( aAccViewState.bNeedRestart )
411 mnCurPageRangeStart = 0;
412 mnCurPageRangeCount = 0;
413 nAllPages = i_rController.getFilteredPageCount();
416 aAccViewState.bNeedRestart = false;
418 Size aCurSize( 21000, 29700 );
419 if( nAllPages > 0 )
421 mnCurPageRangeCount = 1;
422 aCurSize = getPageSize( i_rController, mnCurPageRangeStart );
423 Size aNextSize( aCurSize );
425 // print pages up to a different size
426 while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages )
428 aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount );
429 if( aCurSize == aNextSize // same page size
431 (aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation
434 mnCurPageRangeCount++;
436 else
437 break;
440 else
441 mnCurPageRangeCount = 0;
443 // now for the current run
444 mnStartPageOffsetX = mnStartPageOffsetY = 0;
445 // setup the paper size and orientation
446 // do this on our associated Printer object, since that is
447 // out interface to the applications which occasionally rely on the paper
448 // information (e.g. brochure printing scales to the found paper size)
449 // also SetPaperSizeUser has the advantage that we can share a
450 // platform independent paper matching algorithm
451 VclPtr<Printer> pPrinter( i_rController.getPrinter() );
452 pPrinter->SetMapMode( MapMode( MAP_100TH_MM ) );
453 pPrinter->SetPaperSizeUser( aCurSize, true );
455 // create view
456 NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this];
458 NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
460 // set filename
461 if( i_pFileName )
463 [mpPrintInfo setJobDisposition: NSPrintSaveJob];
464 NSString* pPath = CreateNSString( *i_pFileName );
465 [pPrintDict setObject:[NSURL fileURLWithPath:pPath] forKey:NSPrintJobSavingURL];
466 [pPath release];
469 [pPrintDict setObject: [[NSNumber numberWithInt: nCopies] autorelease] forKey: NSPrintCopies];
470 if( nCopies > 1 )
471 [pPrintDict setObject: [[NSNumber numberWithBool: pPrinter->IsCollateCopy()] autorelease] forKey: NSPrintMustCollate];
472 [pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
473 [pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
474 // #i103253# weird: for some reason, autoreleasing the value below like the others above
475 // leads do a double free malloc error. Why this value should behave differently from all the others
476 // is a mystery.
477 [pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage];
479 // create print operation
480 NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
482 if( pPrintOperation )
484 NSObject* pReleaseAfterUse = nil;
485 bool bShowPanel = !i_rController.isDirectPrint()
486 && (officecfg::Office::Common::Misc::UseSystemPrintDialog::
487 get())
488 && i_rController.isShowDialogs();
489 [pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
490 [pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO];
492 // set job title (since MacOSX 10.5)
493 if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] )
494 [pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]];
496 if( bShowPanel && mnCurPageRangeStart == 0 && nCurJob == 0) // only the first range of pages (in the first job) gets the accesory view
497 pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState];
499 bSuccess = true;
500 mbJob = true;
501 pInst->startedPrintJob();
502 [pPrintOperation runOperation];
503 pInst->endedPrintJob();
504 bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame;
505 mbJob = false;
506 if( pReleaseAfterUse )
507 [pReleaseAfterUse release];
510 mnCurPageRangeStart += mnCurPageRangeCount;
511 mnCurPageRangeCount = 1;
512 } while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages );
515 // inform application that it can release its data
516 // this is awkward, but the XRenderable interface has no method for this,
517 // so we need to call XRenderadble::render one last time with IsLastPage = true
518 i_rController.setLastPage( true );
519 GDIMetaFile aPageFile;
520 if( mrContext )
521 SetupPrinterGraphics( mrContext );
522 i_rController.getFilteredPageFile( 0, aPageFile );
524 i_rController.setJobState( bWasAborted
525 ? view::PrintableState_JOB_ABORTED
526 : view::PrintableState_JOB_SPOOLED );
528 mnCurPageRangeStart = mnCurPageRangeCount = 0;
530 return bSuccess;
533 bool AquaSalInfoPrinter::EndJob()
535 mnStartPageOffsetX = mnStartPageOffsetY = 0;
536 mbJob = false;
537 return true;
540 bool AquaSalInfoPrinter::AbortJob()
542 mbJob = false;
544 // FIXME: implementation
545 return false;
548 SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
550 if( i_bNewJobData && i_pSetupData )
551 SetPrinterData( i_pSetupData );
553 CGContextRef rContext = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
555 SetupPrinterGraphics( rContext );
557 return mpGraphics;
560 bool AquaSalInfoPrinter::EndPage()
562 mpGraphics->InvalidateContext();
563 return true;
566 sal_uLong AquaSalInfoPrinter::GetErrorCode()
568 return 0;
571 AquaSalPrinter::AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter ) :
572 mpInfoPrinter( i_pInfoPrinter )
576 AquaSalPrinter::~AquaSalPrinter()
580 bool AquaSalPrinter::StartJob( const OUString* i_pFileName,
581 const OUString& i_rJobName,
582 const OUString& i_rAppName,
583 ImplJobSetup* i_pSetupData,
584 vcl::PrinterController& i_rController )
586 return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController );
589 bool AquaSalPrinter::StartJob( const OUString* /*i_pFileName*/,
590 const OUString& /*i_rJobName*/,
591 const OUString& /*i_rAppName*/,
592 sal_uLong /*i_nCopies*/,
593 bool /*i_bCollate*/,
594 bool /*i_bDirect*/,
595 ImplJobSetup* )
597 OSL_FAIL( "should never be called" );
598 return false;
601 bool AquaSalPrinter::EndJob()
603 return mpInfoPrinter->EndJob();
606 bool AquaSalPrinter::AbortJob()
608 return mpInfoPrinter->AbortJob();
611 SalGraphics* AquaSalPrinter::StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData )
613 return mpInfoPrinter->StartPage( i_pSetupData, i_bNewJobData );
616 bool AquaSalPrinter::EndPage()
618 return mpInfoPrinter->EndPage();
621 sal_uLong AquaSalPrinter::GetErrorCode()
623 return AquaSalInfoPrinter::GetErrorCode();
626 void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* )
628 m_aPaperFormats.clear();
629 m_bPapersInit = true;
631 if( mpPrinter )
633 SAL_WNODEPRECATED_DECLARATIONS_PUSH
634 //TODO: 10.9 statusForTable:, stringListForKey:inTable:
635 if( [mpPrinter statusForTable: @"PPD"] == NSPrinterTableOK )
637 NSArray* pPaperNames = [mpPrinter stringListForKey: @"PageSize" inTable: @"PPD"];
638 if( pPaperNames )
640 unsigned int nPapers = [pPaperNames count];
641 for( unsigned int i = 0; i < nPapers; i++ )
643 NSString* pPaper = [pPaperNames objectAtIndex: i];
644 // first try to match the name
645 OString aPaperName( [pPaper UTF8String] );
646 Paper ePaper = PaperInfo::fromPSName( aPaperName );
647 if( ePaper != PAPER_USER )
649 m_aPaperFormats.push_back( PaperInfo( ePaper ) );
651 else
653 NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper];
654 if( aPaperSize.width > 0 && aPaperSize.height > 0 )
656 PaperInfo aInfo( PtTo10Mu( aPaperSize.width ),
657 PtTo10Mu( aPaperSize.height ) );
658 if( aInfo.getPaper() == PAPER_USER )
659 aInfo.doSloppyFit();
660 m_aPaperFormats.push_back( aInfo );
666 SAL_WNODEPRECATED_DECLARATIONS_POP
670 const PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const
672 if( ! m_bPapersInit )
673 const_cast<AquaSalInfoPrinter*>(this)->InitPaperFormats( NULL );
675 const PaperInfo* pMatch = NULL;
676 o_rOrientation = ORIENTATION_PORTRAIT;
677 for( int n = 0; n < 2 ; n++ )
679 for( size_t i = 0; i < m_aPaperFormats.size(); i++ )
681 if( std::abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 50 &&
682 std::abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 50 )
684 pMatch = &m_aPaperFormats[i];
685 return pMatch;
688 o_rOrientation = ORIENTATION_LANDSCAPE;
689 std::swap( i_nWidth, i_nHeight );
691 return pMatch;
694 int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* )
696 return 900;
699 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */