2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* $RCSfile: salprn.cxx,v $
|
2008-10-01 18:22:22 +00:00
|
|
|
* $Revision: 1.16.56.2 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 06:17:31 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:45:29 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_vcl.hxx"
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
#include "salinst.h"
|
|
|
|
#include "salprn.h"
|
2008-01-14 15:18:23 +00:00
|
|
|
#include "aquaprintview.h"
|
2007-10-09 14:16:20 +00:00
|
|
|
#include "salgdi.h"
|
|
|
|
#include "saldata.hxx"
|
|
|
|
#include "vcl/jobset.h"
|
|
|
|
#include "vcl/salptype.hxx"
|
2008-03-05 15:59:50 +00:00
|
|
|
#include "vcl/print.hxx"
|
|
|
|
#include "vcl/unohelp.hxx"
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2008-03-05 15:59:50 +00:00
|
|
|
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
|
|
|
|
#include "com/sun/star/container/XNameAccess.hpp"
|
|
|
|
#include "com/sun/star/beans/PropertyValue.hpp"
|
2009-03-26 16:42:26 +00:00
|
|
|
#include "com/sun/star/awt/Size.hpp"
|
2008-07-01 22:07:36 +00:00
|
|
|
|
2008-12-01 13:29:22 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2008-03-05 15:59:50 +00:00
|
|
|
using namespace rtl;
|
|
|
|
using namespace vcl;
|
2009-03-26 16:42:26 +00:00
|
|
|
using namespace com::sun::star;
|
2008-03-05 15:59:50 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace com::sun::star::container;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// =======================================================================
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
AquaSalInfoPrinter::AquaSalInfoPrinter( const SalPrinterQueueInfo& i_rQueue ) :
|
|
|
|
mpGraphics( 0 ),
|
|
|
|
mbGraphics( false ),
|
2007-10-09 14:16:20 +00:00
|
|
|
mbJob( false ),
|
|
|
|
mpPrinter( nil ),
|
|
|
|
mpPrintInfo( nil ),
|
2008-03-05 15:59:50 +00:00
|
|
|
mePageOrientation( ORIENTATION_PORTRAIT ),
|
|
|
|
mnStartPageOffsetX( 0 ),
|
2009-05-15 15:16:28 +00:00
|
|
|
mnStartPageOffsetY( 0 ),
|
|
|
|
mnCurPageRangeStart( 0 ),
|
|
|
|
mnCurPageRangeCount( 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
NSString* pStr = CreateNSString( i_rQueue.maPrinterName );
|
|
|
|
mpPrinter = [NSPrinter printerWithName: pStr];
|
|
|
|
[pStr release];
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
NSPrintInfo* pShared = [NSPrintInfo sharedPrintInfo];
|
|
|
|
if( pShared )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
mpPrintInfo = [pShared copy];
|
|
|
|
[mpPrintInfo setPrinter: mpPrinter];
|
|
|
|
mePageOrientation = ([mpPrintInfo orientation] == NSLandscapeOrientation) ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
|
|
|
|
[mpPrintInfo setOrientation: NSPortraitOrientation];
|
|
|
|
}
|
|
|
|
|
|
|
|
mpGraphics = new AquaSalGraphics();
|
|
|
|
|
|
|
|
const int nWidth = 100, nHeight = 100;
|
|
|
|
maContextMemory.reset( reinterpret_cast<sal_uInt8*>( rtl_allocateMemory( nWidth * 4 * nHeight ) ),
|
|
|
|
boost::bind( rtl_freeMemory, _1 ) );
|
2009-05-15 15:16:28 +00:00
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
if( maContextMemory )
|
|
|
|
{
|
|
|
|
mrContext = CGBitmapContextCreate( maContextMemory.get(), nWidth, nHeight, 8, nWidth * 4, GetSalData()->mxRGBSpace, kCGImageAlphaNoneSkipFirst );
|
|
|
|
if( mrContext )
|
|
|
|
SetupPrinterGraphics( mrContext );
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
AquaSalInfoPrinter::~AquaSalInfoPrinter()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
delete mpGraphics;
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mpPrintInfo )
|
|
|
|
[mpPrintInfo release];
|
|
|
|
#if 0
|
|
|
|
// FIXME: verify that NSPrintInfo releases the printer
|
|
|
|
// else we have a leak here
|
|
|
|
if( mpPrinter )
|
|
|
|
[mpPrinter release];
|
|
|
|
#endif
|
|
|
|
if( mrContext )
|
|
|
|
CFRelease( mrContext );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
void AquaSalInfoPrinter::SetupPrinterGraphics( CGContextRef i_rContext ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
if( mpGraphics )
|
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mpPrintInfo )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
// FIXME: get printer resolution
|
|
|
|
long nDPIX = 720, nDPIY = 720;
|
|
|
|
NSSize aPaperSize = [mpPrintInfo paperSize];
|
|
|
|
|
2009-07-25 01:56:38 +00:00
|
|
|
NSRect aImageRect = [mpPrintInfo imageablePageBounds];
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mePageOrientation == ORIENTATION_PORTRAIT )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2009-07-16 09:56:45 +00:00
|
|
|
// move mirrored CTM back into paper
|
2007-10-09 14:16:20 +00:00
|
|
|
double dX = 0, dY = aPaperSize.height;
|
2009-07-16 09:56:45 +00:00
|
|
|
// move CTM to reflect imageable area
|
2008-12-01 13:29:22 +00:00
|
|
|
dX += aImageRect.origin.x;
|
|
|
|
dY -= aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
|
2008-03-05 15:59:50 +00:00
|
|
|
CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetX, dY - mnStartPageOffsetY );
|
2009-07-16 09:56:45 +00:00
|
|
|
// scale to be top/down and reflect our "virtual" DPI
|
2009-08-20 15:09:25 +00:00
|
|
|
CGContextScaleCTM( i_rContext, 72.0/double(nDPIX), -(72.0/double(nDPIY)) );
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
2007-10-09 14:16:20 +00:00
|
|
|
else
|
|
|
|
{
|
2009-07-16 09:56:45 +00:00
|
|
|
// move CTM to reflect imageable area
|
|
|
|
double dX = aImageRect.origin.x, dY = aPaperSize.height - aImageRect.size.height - aImageRect.origin.y;
|
|
|
|
CGContextTranslateCTM( i_rContext, -dX, -dY );
|
|
|
|
// turn by 90 degree
|
2007-10-09 14:16:20 +00:00
|
|
|
CGContextRotateCTM( i_rContext, M_PI/2 );
|
2009-07-16 09:56:45 +00:00
|
|
|
// move turned CTM back into paper
|
|
|
|
dX = aPaperSize.height;
|
|
|
|
dY = -aPaperSize.width;
|
2008-03-05 15:59:50 +00:00
|
|
|
CGContextTranslateCTM( i_rContext, dX + mnStartPageOffsetY, dY - mnStartPageOffsetX );
|
2009-07-16 09:56:45 +00:00
|
|
|
// scale to be top/down and reflect our "virtual" DPI
|
2009-08-20 15:09:25 +00:00
|
|
|
CGContextScaleCTM( i_rContext, -(72.0/double(nDPIY)), (72.0/double(nDPIX)) );
|
2007-10-09 14:16:20 +00:00
|
|
|
}
|
|
|
|
mpGraphics->SetPrinterGraphics( i_rContext, nDPIX, nDPIY, 1.0 );
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
else
|
2007-10-09 14:16:20 +00:00
|
|
|
DBG_ERROR( "no print info in SetupPrinterGraphics" );
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
SalGraphics* AquaSalInfoPrinter::GetGraphics()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
SalGraphics* pGraphics = mbGraphics ? NULL : mpGraphics;
|
|
|
|
mbGraphics = true;
|
|
|
|
return pGraphics;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
void AquaSalInfoPrinter::ReleaseGraphics( SalGraphics* )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
mbGraphics = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalInfoPrinter::Setup( SalFrame* i_pFrame, ImplJobSetup* i_pSetupData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
static struct PaperSizeEntry
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
double fWidth;
|
|
|
|
double fHeight;
|
|
|
|
Paper nPaper;
|
|
|
|
} aPaperSizes[] =
|
|
|
|
{
|
|
|
|
{ 842, 1191, PAPER_A3 },
|
|
|
|
{ 595, 842, PAPER_A4 },
|
|
|
|
{ 420, 595, PAPER_A5 },
|
|
|
|
{ 612, 792, PAPER_LETTER },
|
|
|
|
{ 612, 1008, PAPER_LEGAL },
|
2009-06-12 09:36:34 +00:00
|
|
|
{ 728, 1032, PAPER_B4_JIS },
|
|
|
|
{ 516, 729, PAPER_B5_JIS },
|
2007-07-05 09:20:17 +00:00
|
|
|
{ 792, 1224, PAPER_TABLOID }
|
|
|
|
};
|
|
|
|
|
2008-07-01 22:07:36 +00:00
|
|
|
static bool getPaperSize( double& o_fWidth, double& o_fHeight, const Paper i_ePaper )
|
2007-10-09 14:16:20 +00:00
|
|
|
{
|
|
|
|
for(unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
|
|
|
|
{
|
|
|
|
if( aPaperSizes[i].nPaper == i_ePaper )
|
|
|
|
{
|
|
|
|
o_fWidth = aPaperSizes[i].fWidth;
|
|
|
|
o_fHeight = aPaperSizes[i].fHeight;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
static Paper recognizePaper( double i_fWidth, double i_fHeight )
|
|
|
|
{
|
|
|
|
Paper aPaper = PAPER_USER;
|
|
|
|
sal_uInt64 nPaperDesc = 1000000*sal_uInt64(i_fWidth) + sal_uInt64(i_fHeight);
|
|
|
|
switch( nPaperDesc )
|
|
|
|
{
|
|
|
|
case 842001191: aPaper = PAPER_A3; break;
|
|
|
|
case 595000842: aPaper = PAPER_A4; break;
|
|
|
|
case 420000595: aPaper = PAPER_A5; break;
|
|
|
|
case 612000792: aPaper = PAPER_LETTER; break;
|
2009-06-12 09:36:34 +00:00
|
|
|
case 728001032: aPaper = PAPER_B4_JIS; break;
|
|
|
|
case 516000729: aPaper = PAPER_B5_JIS; break;
|
2007-07-05 09:20:17 +00:00
|
|
|
case 612001008: aPaper = PAPER_LEGAL; break;
|
|
|
|
case 792001224: aPaper = PAPER_TABLOID; break;
|
|
|
|
default:
|
|
|
|
aPaper = PAPER_USER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aPaper == PAPER_USER )
|
|
|
|
{
|
|
|
|
// search with fuzz factor
|
|
|
|
for( unsigned int i = 0; i < sizeof(aPaperSizes)/sizeof(aPaperSizes[0]); i++ )
|
|
|
|
{
|
|
|
|
double w = (i_fWidth > aPaperSizes[i].fWidth) ? i_fWidth - aPaperSizes[i].fWidth : aPaperSizes[i].fWidth - i_fWidth;
|
|
|
|
double h = (i_fHeight > aPaperSizes[i].fHeight) ? i_fHeight - aPaperSizes[i].fHeight : aPaperSizes[i].fHeight - i_fHeight;
|
|
|
|
if( w < 3 && h < 3 )
|
|
|
|
{
|
|
|
|
aPaper = aPaperSizes[i].nPaper;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aPaper;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
|
|
|
|
{
|
|
|
|
// FIXME: implement driver data
|
|
|
|
if( io_pSetupData && io_pSetupData->mpDriverData )
|
|
|
|
return SetData( ~0, io_pSetupData );
|
|
|
|
|
|
|
|
|
|
|
|
BOOL bSuccess = TRUE;
|
|
|
|
|
|
|
|
// set system type
|
|
|
|
io_pSetupData->mnSystem = JOBSETUP_SYSTEM_MAC;
|
|
|
|
|
|
|
|
// get paper format
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mpPrintInfo )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
NSSize aPaperSize = [mpPrintInfo paperSize];
|
|
|
|
double width = aPaperSize.width, height = aPaperSize.height;
|
|
|
|
// set paper
|
|
|
|
io_pSetupData->mePaperFormat = recognizePaper( width, height );
|
|
|
|
if( io_pSetupData->mePaperFormat == PAPER_USER )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
io_pSetupData->mnPaperWidth = PtTo10Mu( width );
|
|
|
|
io_pSetupData->mnPaperHeight = PtTo10Mu( height );
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
io_pSetupData->mnPaperWidth = 0;
|
|
|
|
io_pSetupData->mnPaperHeight = 0;
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
2007-10-09 14:16:20 +00:00
|
|
|
|
|
|
|
// set orientation
|
|
|
|
io_pSetupData->meOrientation = mePageOrientation;
|
2007-07-05 09:20:17 +00:00
|
|
|
|
|
|
|
io_pSetupData->mnPaperBin = 0;
|
|
|
|
io_pSetupData->mpDriverData = reinterpret_cast<BYTE*>(rtl_allocateMemory( 4 ));
|
|
|
|
io_pSetupData->mnDriverDataLen = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
return bSuccess;
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2009-05-15 15:16:28 +00:00
|
|
|
void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation )
|
|
|
|
{
|
|
|
|
|
|
|
|
Orientation ePaperOrientation = ORIENTATION_PORTRAIT;
|
2009-08-12 16:37:34 +00:00
|
|
|
const PaperInfo* pPaper = matchPaper( i_nWidth, i_nHeight, ePaperOrientation );
|
2009-05-15 15:16:28 +00:00
|
|
|
|
|
|
|
if( pPaper )
|
|
|
|
{
|
2009-07-25 01:56:38 +00:00
|
|
|
NSString* pPaperName = [CreateNSString( rtl::OStringToOUString(PaperInfo::toPSName(pPaper->getPaper()), RTL_TEXTENCODING_ASCII_US) ) autorelease];
|
2009-05-15 15:16:28 +00:00
|
|
|
[mpPrintInfo setPaperName: pPaperName];
|
|
|
|
}
|
|
|
|
else if( i_nWidth > 0 && i_nHeight > 0 )
|
|
|
|
{
|
|
|
|
NSSize aPaperSize = { TenMuToPt(i_nWidth), TenMuToPt(i_nHeight) };
|
|
|
|
[mpPrintInfo setPaperSize: aPaperSize];
|
|
|
|
}
|
|
|
|
// this seems counterintuitive
|
|
|
|
mePageOrientation = i_eSetOrientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalInfoPrinter::SetData( ULONG i_nFlags, ImplJobSetup* io_pSetupData )
|
|
|
|
{
|
|
|
|
if( ! io_pSetupData || io_pSetupData->mnSystem != JOBSETUP_SYSTEM_MAC )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mpPrintInfo )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2009-05-15 15:16:28 +00:00
|
|
|
if( (i_nFlags & SAL_JOBSET_ORIENTATION) != 0 )
|
|
|
|
mePageOrientation = io_pSetupData->meOrientation;
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
if( (i_nFlags & SAL_JOBSET_PAPERSIZE) != 0)
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
// set paper format
|
2009-05-15 15:16:28 +00:00
|
|
|
long width = 0, height = 0;
|
2007-10-09 14:16:20 +00:00
|
|
|
if( io_pSetupData->mePaperFormat == PAPER_USER )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2009-05-15 15:16:28 +00:00
|
|
|
width = io_pSetupData->mnPaperWidth;
|
|
|
|
height = io_pSetupData->mnPaperHeight;
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
2007-10-09 14:16:20 +00:00
|
|
|
else
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2009-05-15 15:16:28 +00:00
|
|
|
double w = 595, h = 842;
|
|
|
|
getPaperSize( w, h, io_pSetupData->mePaperFormat );
|
|
|
|
width = static_cast<long>(PtTo10Mu( w ));
|
|
|
|
height = static_cast<long>(PtTo10Mu( h ));
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
|
2009-05-15 15:16:28 +00:00
|
|
|
setPaperSize( width, height, mePageOrientation );
|
|
|
|
}
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
return mpPrintInfo != nil;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
ULONG AquaSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* i_pSetupData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
XubString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup* i_pSetupData, ULONG i_nPaperBin )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-01 21:12:34 +00:00
|
|
|
return XubString();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-03-05 15:59:50 +00:00
|
|
|
static bool getUseNativeDialog()
|
|
|
|
{
|
|
|
|
bool bNative = true;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// get service provider
|
|
|
|
Reference< XMultiServiceFactory > xSMgr( unohelper::GetMultiServiceFactory() );
|
|
|
|
// create configuration hierachical access name
|
|
|
|
if( xSMgr.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XMultiServiceFactory > xConfigProvider(
|
|
|
|
Reference< XMultiServiceFactory >(
|
|
|
|
xSMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"com.sun.star.configuration.ConfigurationProvider" ))),
|
|
|
|
UNO_QUERY )
|
|
|
|
);
|
|
|
|
if( xConfigProvider.is() )
|
|
|
|
{
|
|
|
|
Sequence< Any > aArgs(1);
|
|
|
|
PropertyValue aVal;
|
|
|
|
aVal.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
|
|
|
|
aVal.Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Misc" ) );
|
|
|
|
aArgs.getArray()[0] <<= aVal;
|
|
|
|
Reference< XNameAccess > xConfigAccess(
|
|
|
|
Reference< XNameAccess >(
|
|
|
|
xConfigProvider->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
|
|
|
|
"com.sun.star.configuration.ConfigurationAccess" )),
|
|
|
|
aArgs ),
|
|
|
|
UNO_QUERY )
|
|
|
|
);
|
|
|
|
if( xConfigAccess.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Bool bValue = sal_False;
|
|
|
|
Any aAny = xConfigAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseSystemPrintDialog" ) ) );
|
|
|
|
if( aAny >>= bValue )
|
|
|
|
bNative = bValue;
|
|
|
|
}
|
|
|
|
catch( NoSuchElementException& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
catch( WrappedTargetException& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( WrappedTargetException& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return bNative;
|
|
|
|
}
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
ULONG AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup* i_pSetupData, USHORT i_nType )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
switch( i_nType )
|
|
|
|
{
|
|
|
|
case PRINTER_CAPABILITIES_SUPPORTDIALOG:
|
|
|
|
return 0;
|
|
|
|
case PRINTER_CAPABILITIES_COPIES:
|
|
|
|
return 0xffff;
|
|
|
|
case PRINTER_CAPABILITIES_COLLATECOPIES:
|
|
|
|
return 0;
|
|
|
|
case PRINTER_CAPABILITIES_SETORIENTATION:
|
|
|
|
return 1;
|
2009-05-28 16:46:25 +00:00
|
|
|
case PRINTER_CAPABILITIES_SETDUPLEX:
|
|
|
|
return 0;
|
2007-07-05 09:20:17 +00:00
|
|
|
case PRINTER_CAPABILITIES_SETPAPERBIN:
|
|
|
|
return 0;
|
|
|
|
case PRINTER_CAPABILITIES_SETPAPERSIZE:
|
|
|
|
return 1;
|
|
|
|
case PRINTER_CAPABILITIES_SETPAPER:
|
|
|
|
return 1;
|
2008-03-05 15:59:50 +00:00
|
|
|
case PRINTER_CAPABILITIES_EXTERNALDIALOG:
|
|
|
|
return getUseNativeDialog() ? 1 : 0;
|
2009-06-24 15:59:36 +00:00
|
|
|
case PRINTER_CAPABILITIES_PDF:
|
|
|
|
return 1;
|
2007-07-05 09:20:17 +00:00
|
|
|
default: break;
|
|
|
|
};
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
void AquaSalInfoPrinter::GetPageInfo( const ImplJobSetup*,
|
|
|
|
long& o_rOutWidth, long& o_rOutHeight,
|
|
|
|
long& o_rPageOffX, long& o_rPageOffY,
|
|
|
|
long& o_rPageWidth, long& o_rPageHeight )
|
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mpPrintInfo )
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
long nDPIX = 72, nDPIY = 72;
|
|
|
|
mpGraphics->GetResolution( nDPIX, nDPIY );
|
|
|
|
const double fXScaling = static_cast<double>(nDPIX)/72.0,
|
|
|
|
fYScaling = static_cast<double>(nDPIY)/72.0;
|
|
|
|
|
|
|
|
NSSize aPaperSize = [mpPrintInfo paperSize];
|
2008-01-14 15:18:23 +00:00
|
|
|
o_rPageWidth = static_cast<long>( double(aPaperSize.width) * fXScaling );
|
|
|
|
o_rPageHeight = static_cast<long>( double(aPaperSize.height) * fYScaling );
|
2008-12-01 13:29:22 +00:00
|
|
|
|
|
|
|
NSRect aImageRect = [mpPrintInfo imageablePageBounds];
|
|
|
|
o_rPageOffX = static_cast<long>( aImageRect.origin.x * fXScaling );
|
|
|
|
o_rPageOffY = static_cast<long>( (aPaperSize.height - aImageRect.size.height - aImageRect.origin.y) * fYScaling );
|
|
|
|
o_rOutWidth = static_cast<long>( aImageRect.size.width * fXScaling );
|
|
|
|
o_rOutHeight = static_cast<long>( aImageRect.size.height * fYScaling );
|
|
|
|
|
|
|
|
if( mePageOrientation == ORIENTATION_LANDSCAPE )
|
|
|
|
{
|
|
|
|
std::swap( o_rOutWidth, o_rOutHeight );
|
|
|
|
std::swap( o_rPageWidth, o_rPageHeight );
|
|
|
|
std::swap( o_rPageOffX, o_rPageOffY );
|
|
|
|
}
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
static Size getPageSize( vcl::PrinterController& i_rController, sal_Int32 i_nPage )
|
2009-03-26 16:42:26 +00:00
|
|
|
{
|
|
|
|
Size aPageSize;
|
2009-07-06 10:54:21 +00:00
|
|
|
Sequence< PropertyValue > aPageParms( i_rController.getPageParameters( i_nPage ) );
|
2009-03-26 16:42:26 +00:00
|
|
|
for( sal_Int32 nProperty = 0, nPropertyCount = aPageParms.getLength(); nProperty < nPropertyCount; ++nProperty )
|
|
|
|
{
|
|
|
|
if( aPageParms[ nProperty ].Name.equalsAscii( "PageSize" ) )
|
|
|
|
{
|
|
|
|
awt::Size aSize;
|
|
|
|
aPageParms[ nProperty].Value >>= aSize;
|
|
|
|
aPageSize.Width() = aSize.Width;
|
|
|
|
aPageSize.Height() = aSize.Height;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aPageSize;
|
|
|
|
}
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
BOOL AquaSalInfoPrinter::StartJob( const String* i_pFileName,
|
2009-06-26 14:03:31 +00:00
|
|
|
const String& i_rJobName,
|
2008-10-01 18:22:22 +00:00
|
|
|
const String& i_rAppName,
|
|
|
|
ImplJobSetup* i_pSetupData,
|
2009-08-05 15:46:46 +00:00
|
|
|
vcl::PrinterController& i_rController
|
|
|
|
)
|
2007-07-05 09:20:17 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
if( mbJob )
|
2007-07-05 09:20:17 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
BOOL bSuccess = FALSE;
|
2009-06-26 10:50:42 +00:00
|
|
|
bool bWasAborted = false;
|
2008-07-01 22:07:36 +00:00
|
|
|
AquaSalInstance* pInst = GetSalData()->mpFirstInstance;
|
2009-06-02 13:23:25 +00:00
|
|
|
PrintAccessoryViewState aAccViewState;
|
2009-05-14 13:32:29 +00:00
|
|
|
sal_Int32 nAllPages = 0;
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2009-06-02 13:23:25 +00:00
|
|
|
aAccViewState.bNeedRestart = true;
|
|
|
|
|
2009-04-24 13:15:04 +00:00
|
|
|
// reset IsLastPage
|
2009-07-06 10:54:21 +00:00
|
|
|
i_rController.setLastPage( sal_False );
|
2009-04-24 13:15:04 +00:00
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
// update job data
|
|
|
|
if( i_pSetupData )
|
|
|
|
SetData( ~0, i_pSetupData );
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2009-06-26 12:32:01 +00:00
|
|
|
// do we want a progress panel ?
|
|
|
|
sal_Bool bShowProgressPanel = sal_True;
|
2009-07-06 10:54:21 +00:00
|
|
|
beans::PropertyValue* pMonitor = i_rController.getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MonitorVisible" ) ) );
|
2009-06-26 12:32:01 +00:00
|
|
|
if( pMonitor )
|
|
|
|
pMonitor->Value >>= bShowProgressPanel;
|
2009-08-05 15:02:39 +00:00
|
|
|
if( ! i_rController.isShowDialogs() )
|
2009-08-05 14:46:00 +00:00
|
|
|
bShowProgressPanel = sal_False;
|
2009-06-26 12:32:01 +00:00
|
|
|
|
2009-06-26 10:50:42 +00:00
|
|
|
// FIXME: jobStarted() should be done after the print dialog has ended (if there is one)
|
|
|
|
// how do I know when that might be ?
|
2009-07-06 10:54:21 +00:00
|
|
|
i_rController.jobStarted();
|
2009-03-26 16:42:26 +00:00
|
|
|
do
|
|
|
|
{
|
2009-06-02 13:23:25 +00:00
|
|
|
if( aAccViewState.bNeedRestart )
|
2009-03-26 16:42:26 +00:00
|
|
|
{
|
2009-05-14 13:32:29 +00:00
|
|
|
mnCurPageRangeStart = 0;
|
|
|
|
mnCurPageRangeCount = 0;
|
2009-07-06 10:54:21 +00:00
|
|
|
nAllPages = i_rController.getFilteredPageCount();
|
2009-03-26 16:42:26 +00:00
|
|
|
}
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2009-06-02 13:23:25 +00:00
|
|
|
aAccViewState.bNeedRestart = false;
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2009-05-14 13:32:29 +00:00
|
|
|
Size aCurSize( 21000, 29700 );
|
|
|
|
if( nAllPages > 0 )
|
2009-03-26 16:42:26 +00:00
|
|
|
{
|
2009-05-14 13:32:29 +00:00
|
|
|
mnCurPageRangeCount = 1;
|
2009-07-06 10:54:21 +00:00
|
|
|
aCurSize = getPageSize( i_rController, mnCurPageRangeStart );
|
2009-05-14 13:32:29 +00:00
|
|
|
Size aNextSize( aCurSize );
|
|
|
|
|
|
|
|
// print pages up to a different size
|
|
|
|
while( mnCurPageRangeCount + mnCurPageRangeStart < nAllPages )
|
2009-03-26 16:42:26 +00:00
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
aNextSize = getPageSize( i_rController, mnCurPageRangeStart + mnCurPageRangeCount );
|
2009-05-14 13:32:29 +00:00
|
|
|
if( aCurSize == aNextSize // same page size
|
|
|
|
||
|
|
|
|
(aCurSize.Width() == aNextSize.Height() && aCurSize.Height() == aNextSize.Width()) // same size, but different orientation
|
|
|
|
)
|
|
|
|
{
|
|
|
|
mnCurPageRangeCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2009-03-26 16:42:26 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-14 13:32:29 +00:00
|
|
|
else
|
|
|
|
mnCurPageRangeCount = 0;
|
2008-07-01 22:07:36 +00:00
|
|
|
|
2009-03-26 16:42:26 +00:00
|
|
|
// now for the current run
|
|
|
|
mnStartPageOffsetX = mnStartPageOffsetY = 0;
|
|
|
|
// setup the paper size and orientation
|
2009-05-15 15:16:28 +00:00
|
|
|
setPaperSize( aCurSize.Width(), aCurSize.Height(), ORIENTATION_PORTRAIT );
|
2008-07-01 22:07:36 +00:00
|
|
|
|
2009-03-26 16:42:26 +00:00
|
|
|
// create view
|
2009-07-06 10:54:21 +00:00
|
|
|
NSView* pPrintView = [[AquaPrintView alloc] initWithController: &i_rController withInfoPrinter: this];
|
2008-07-01 22:07:36 +00:00
|
|
|
|
2009-03-26 16:42:26 +00:00
|
|
|
NSMutableDictionary* pPrintDict = [mpPrintInfo dictionary];
|
|
|
|
|
|
|
|
// set filename
|
|
|
|
if( i_pFileName )
|
|
|
|
{
|
|
|
|
[mpPrintInfo setJobDisposition: NSPrintSaveJob];
|
|
|
|
NSString* pPath = CreateNSString( *i_pFileName );
|
|
|
|
[pPrintDict setObject: pPath forKey: NSPrintSavePath];
|
|
|
|
[pPath release];
|
|
|
|
}
|
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
[pPrintDict setObject: [[NSNumber numberWithInt: (int)i_rController.getPrinter()->GetCopyCount()] autorelease] forKey: NSPrintCopies];
|
2009-03-26 16:42:26 +00:00
|
|
|
[pPrintDict setObject: [[NSNumber numberWithBool: YES] autorelease] forKey: NSPrintDetailedErrorReporting];
|
|
|
|
[pPrintDict setObject: [[NSNumber numberWithInt: 1] autorelease] forKey: NSPrintFirstPage];
|
2009-08-05 14:46:00 +00:00
|
|
|
// #i103253# weird: for some reason, autoreleasing the value below like the others above
|
|
|
|
// leads do a double free malloc error. Why this value should behave differently from all the others
|
|
|
|
// is a mystery.
|
|
|
|
[pPrintDict setObject: [NSNumber numberWithInt: mnCurPageRangeCount] forKey: NSPrintLastPage];
|
2009-03-26 16:42:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
// create print operation
|
|
|
|
NSPrintOperation* pPrintOperation = [NSPrintOperation printOperationWithView: pPrintView printInfo: mpPrintInfo];
|
|
|
|
|
|
|
|
if( pPrintOperation )
|
|
|
|
{
|
|
|
|
NSObject* pReleaseAfterUse = nil;
|
2009-08-05 15:46:46 +00:00
|
|
|
bool bShowPanel = (! i_rController.isDirectPrint() && getUseNativeDialog() && i_rController.isShowDialogs() );
|
2009-03-26 16:42:26 +00:00
|
|
|
[pPrintOperation setShowsPrintPanel: bShowPanel ? YES : NO ];
|
2009-06-26 12:32:01 +00:00
|
|
|
[pPrintOperation setShowsProgressPanel: bShowProgressPanel ? YES : NO];
|
2009-06-26 14:03:31 +00:00
|
|
|
|
|
|
|
// set job title (since MacOSX 10.5)
|
|
|
|
if( [pPrintOperation respondsToSelector: @selector(setJobTitle:)] )
|
|
|
|
[pPrintOperation performSelector: @selector(setJobTitle:) withObject: [CreateNSString( i_rJobName ) autorelease]];
|
|
|
|
|
2009-05-14 13:32:29 +00:00
|
|
|
if( bShowPanel && mnCurPageRangeStart == 0 ) // only the first range of pages gets the accesory view
|
2009-07-06 10:54:21 +00:00
|
|
|
pReleaseAfterUse = [AquaPrintAccessoryView setupPrinterPanel: pPrintOperation withController: &i_rController withState: &aAccViewState];
|
2009-03-26 16:42:26 +00:00
|
|
|
|
|
|
|
bSuccess = TRUE;
|
|
|
|
mbJob = true;
|
|
|
|
pInst->startedPrintJob();
|
|
|
|
[pPrintOperation runOperation];
|
|
|
|
pInst->endedPrintJob();
|
2009-06-26 10:50:42 +00:00
|
|
|
bWasAborted = [[[pPrintOperation printInfo] jobDisposition] compare: NSPrintCancelJob] == NSOrderedSame;
|
2009-03-26 16:42:26 +00:00
|
|
|
mbJob = false;
|
|
|
|
if( pReleaseAfterUse )
|
|
|
|
[pReleaseAfterUse release];
|
|
|
|
}
|
|
|
|
|
|
|
|
mnCurPageRangeStart += mnCurPageRangeCount;
|
|
|
|
mnCurPageRangeCount = 1;
|
2009-06-02 13:23:25 +00:00
|
|
|
} while( aAccViewState.bNeedRestart || mnCurPageRangeStart + mnCurPageRangeCount < nAllPages );
|
2007-07-05 09:20:17 +00:00
|
|
|
|
2009-04-24 13:15:04 +00:00
|
|
|
// inform applictation that it can release its data
|
|
|
|
// this is awkward, but the XRenderable interface has no method for this,
|
|
|
|
// so we need to call XRenderadble::render one last time with IsLastPage = TRUE
|
2009-05-14 13:32:29 +00:00
|
|
|
if( nAllPages > 0 )
|
|
|
|
{
|
2009-07-06 10:54:21 +00:00
|
|
|
i_rController.setLastPage( sal_True );
|
2009-05-14 13:32:29 +00:00
|
|
|
GDIMetaFile aPageFile;
|
2009-05-14 15:38:18 +00:00
|
|
|
if( mrContext )
|
|
|
|
SetupPrinterGraphics( mrContext );
|
2009-07-06 10:54:21 +00:00
|
|
|
i_rController.getFilteredPageFile( 0, aPageFile );
|
2009-05-14 13:32:29 +00:00
|
|
|
}
|
2009-04-24 13:15:04 +00:00
|
|
|
|
2009-07-06 10:54:21 +00:00
|
|
|
i_rController.setJobState( bWasAborted
|
2009-06-26 10:50:42 +00:00
|
|
|
? view::PrintableState_JOB_ABORTED
|
|
|
|
: view::PrintableState_JOB_SPOOLED );
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
mnCurPageRangeStart = mnCurPageRangeCount = 0;
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL AquaSalInfoPrinter::EndJob()
|
|
|
|
{
|
2008-03-05 15:59:50 +00:00
|
|
|
mnStartPageOffsetX = mnStartPageOffsetY = 0;
|
2007-07-05 09:20:17 +00:00
|
|
|
mbJob = false;
|
2007-10-09 14:16:20 +00:00
|
|
|
return TRUE;
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL AquaSalInfoPrinter::AbortJob()
|
|
|
|
{
|
|
|
|
mbJob = false;
|
|
|
|
|
|
|
|
// FIXME: implementation
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
SalGraphics* AquaSalInfoPrinter::StartPage( ImplJobSetup* i_pSetupData, BOOL i_bNewJobData )
|
|
|
|
{
|
|
|
|
if( i_bNewJobData && i_pSetupData )
|
|
|
|
SetPrinterData( i_pSetupData );
|
|
|
|
|
2007-10-09 14:16:20 +00:00
|
|
|
CGContextRef rContext = reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
|
2007-07-05 09:20:17 +00:00
|
|
|
|
|
|
|
SetupPrinterGraphics( rContext );
|
|
|
|
|
|
|
|
return mpGraphics;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL AquaSalInfoPrinter::EndPage()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-08-20 15:09:25 +00:00
|
|
|
mpGraphics->UnsetState();
|
2007-10-09 14:16:20 +00:00
|
|
|
return TRUE;
|
2007-07-05 09:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ULONG AquaSalInfoPrinter::GetErrorCode() const
|
|
|
|
{
|
|
|
|
return 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
AquaSalPrinter::AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter ) :
|
|
|
|
mpInfoPrinter( i_pInfoPrinter )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
AquaSalPrinter::~AquaSalPrinter()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2008-10-01 18:22:22 +00:00
|
|
|
BOOL AquaSalPrinter::StartJob( const String* i_pFileName,
|
2009-06-26 14:03:31 +00:00
|
|
|
const String& i_rJobName,
|
2008-10-01 18:22:22 +00:00
|
|
|
const String& i_rAppName,
|
|
|
|
ImplJobSetup* i_pSetupData,
|
2009-07-06 10:54:21 +00:00
|
|
|
vcl::PrinterController& i_rController )
|
2007-10-09 14:16:20 +00:00
|
|
|
{
|
2009-08-05 15:46:46 +00:00
|
|
|
return mpInfoPrinter->StartJob( i_pFileName, i_rJobName, i_rAppName, i_pSetupData, i_rController );
|
2007-10-09 14:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalPrinter::StartJob( const XubString* i_pFileName,
|
2009-06-26 14:03:31 +00:00
|
|
|
const XubString& i_rJobName,
|
|
|
|
const XubString& i_rAppName,
|
2009-08-05 15:46:46 +00:00
|
|
|
ULONG i_nCopies,
|
|
|
|
bool i_bCollate,
|
|
|
|
bool i_bDirect,
|
2009-06-26 14:03:31 +00:00
|
|
|
ImplJobSetup* i_pSetupData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-10-09 14:16:20 +00:00
|
|
|
DBG_ERROR( "should never be called" );
|
|
|
|
return FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalPrinter::EndJob()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
return mpInfoPrinter->EndJob();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalPrinter::AbortJob()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
return mpInfoPrinter->AbortJob();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
SalGraphics* AquaSalPrinter::StartPage( ImplJobSetup* i_pSetupData, BOOL i_bNewJobData )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
return mpInfoPrinter->StartPage( i_pSetupData, i_bNewJobData );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
BOOL AquaSalPrinter::EndPage()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2007-07-05 09:20:17 +00:00
|
|
|
return mpInfoPrinter->EndPage();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
ULONG AquaSalPrinter::GetErrorCode()
|
|
|
|
{
|
|
|
|
return mpInfoPrinter->GetErrorCode();
|
|
|
|
}
|
|
|
|
|
2009-05-14 16:18:28 +00:00
|
|
|
void AquaSalInfoPrinter::InitPaperFormats( const ImplJobSetup* i_pSetupData )
|
|
|
|
{
|
|
|
|
m_aPaperFormats.clear();
|
|
|
|
m_bPapersInit = true;
|
|
|
|
|
|
|
|
if( mpPrinter )
|
|
|
|
{
|
|
|
|
if( [mpPrinter statusForTable: @"PPD"] == NSPrinterTableOK )
|
|
|
|
{
|
|
|
|
NSArray* pPaperNames = [mpPrinter stringListForKey: @"PageSize" inTable: @"PPD"];
|
|
|
|
if( pPaperNames )
|
|
|
|
{
|
|
|
|
unsigned int nPapers = [pPaperNames count];
|
|
|
|
for( unsigned int i = 0; i < nPapers; i++ )
|
|
|
|
{
|
|
|
|
NSString* pPaper = [pPaperNames objectAtIndex: i];
|
|
|
|
NSSize aPaperSize = [mpPrinter pageSizeForPaper: pPaper];
|
|
|
|
if( aPaperSize.width > 0 && aPaperSize.height > 0 )
|
|
|
|
{
|
2009-08-12 16:37:34 +00:00
|
|
|
PaperInfo aInfo( PtTo10Mu( aPaperSize.width ),
|
|
|
|
PtTo10Mu( aPaperSize.height ) );
|
2009-05-14 16:18:28 +00:00
|
|
|
m_aPaperFormats.push_back( aInfo );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-25 01:56:38 +00:00
|
|
|
const PaperInfo* AquaSalInfoPrinter::matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const
|
2009-05-15 15:16:28 +00:00
|
|
|
{
|
|
|
|
if( ! m_bPapersInit )
|
|
|
|
const_cast<AquaSalInfoPrinter*>(this)->InitPaperFormats( NULL );
|
|
|
|
|
2009-07-25 01:56:38 +00:00
|
|
|
const PaperInfo* pMatch = NULL;
|
2009-05-15 15:16:28 +00:00
|
|
|
o_rOrientation = ORIENTATION_PORTRAIT;
|
|
|
|
for( int n = 0; n < 2 ; n++ )
|
|
|
|
{
|
|
|
|
for( size_t i = 0; i < m_aPaperFormats.size(); i++ )
|
|
|
|
{
|
2009-08-12 16:37:34 +00:00
|
|
|
if( abs( m_aPaperFormats[i].getWidth() - i_nWidth ) < 50 &&
|
|
|
|
abs( m_aPaperFormats[i].getHeight() - i_nHeight ) < 50 )
|
2009-05-15 15:16:28 +00:00
|
|
|
{
|
|
|
|
pMatch = &m_aPaperFormats[i];
|
|
|
|
return pMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
o_rOrientation = ORIENTATION_LANDSCAPE;
|
|
|
|
std::swap( i_nWidth, i_nHeight );
|
|
|
|
}
|
|
|
|
return pMatch;
|
|
|
|
}
|
|
|
|
|
2009-05-14 16:18:28 +00:00
|
|
|
int AquaSalInfoPrinter::GetLandscapeAngle( const ImplJobSetup* i_pSetupData )
|
|
|
|
{
|
|
|
|
return 900;
|
|
|
|
}
|
|
|
|
|
2007-07-05 09:20:17 +00:00
|
|
|
|