diff options
Diffstat (limited to 'vcl/unx/generic/print/genprnpsp.cxx')
-rw-r--r-- | vcl/unx/generic/print/genprnpsp.cxx | 150 |
1 files changed, 77 insertions, 73 deletions
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 63495e9adec6..e9b9d87e6884 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -155,18 +155,20 @@ inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778) static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) { - pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT); + pJobSetup->SetOrientation( (Orientation)(rData.m_eOrientation == orientation::Landscape ? + ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT)); // copy page size OUString aPaper; int width, height; rData.m_aContext.getPageSize( aPaper, width, height ); - pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )); + pJobSetup->SetPaperFormat( PaperInfo::fromPSName( + OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 ))); - pJobSetup->mnPaperWidth = 0; - pJobSetup->mnPaperHeight = 0; - if( pJobSetup->mePaperFormat == PAPER_USER ) + pJobSetup->SetPaperWidth( 0 ); + pJobSetup->SetPaperHeight( 0 ); + if( pJobSetup->GetPaperFormat() == PAPER_USER ) { // transform to 100dth mm width = PtTo10Mu( width ); @@ -174,13 +176,13 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) if( rData.m_eOrientation == psp::orientation::Portrait ) { - pJobSetup->mnPaperWidth = width; - pJobSetup->mnPaperHeight= height; + pJobSetup->SetPaperWidth( width ); + pJobSetup->SetPaperHeight( height ); } else { - pJobSetup->mnPaperWidth = height; - pJobSetup->mnPaperHeight= width; + pJobSetup->SetPaperWidth( height ); + pJobSetup->SetPaperHeight( width ); } } @@ -188,27 +190,28 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) const PPDKey* pKey = nullptr; const PPDValue* pValue = nullptr; - pJobSetup->mnPaperBin = 0; + pJobSetup->SetPaperBin( 0 ); if( rData.m_pParser ) pKey = rData.m_pParser->getKey( OUString("InputSlot") ); if( pKey ) pValue = rData.m_aContext.getValue( pKey ); if( pKey && pValue ) { - for( pJobSetup->mnPaperBin = 0; - pValue != pKey->getValue( pJobSetup->mnPaperBin ) && - pJobSetup->mnPaperBin < pKey->countValues(); - pJobSetup->mnPaperBin++ ) - ; - if( pJobSetup->mnPaperBin >= pKey->countValues() ) - pJobSetup->mnPaperBin = 0; + sal_uInt16 nPaperBin; + for( nPaperBin = 0; + pValue != pKey->getValue( nPaperBin ) && + nPaperBin < pKey->countValues(); + nPaperBin++); + pJobSetup->SetPaperBin(nPaperBin); + if( pJobSetup->GetPaperBin() >= pKey->countValues() ) + pJobSetup->SetPaperBin( 0 ); } // copy duplex pKey = nullptr; pValue = nullptr; - pJobSetup->meDuplexMode = DUPLEX_UNKNOWN; + pJobSetup->SetDuplexMode( DUPLEX_UNKNOWN ); if( rData.m_pParser ) pKey = rData.m_pParser->getKey( OUString("Duplex") ); if( pKey ) @@ -219,33 +222,33 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) pValue->m_aOption.startsWithIgnoreAsciiCase( "Simplex" ) ) { - pJobSetup->meDuplexMode = DUPLEX_OFF; + pJobSetup->SetDuplexMode( DUPLEX_OFF); } else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexNoTumble" ) ) { - pJobSetup->meDuplexMode = DUPLEX_LONGEDGE; + pJobSetup->SetDuplexMode( DUPLEX_LONGEDGE ); } else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexTumble" ) ) { - pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE; + pJobSetup->SetDuplexMode( DUPLEX_SHORTEDGE ); } } // copy the whole context - if( pJobSetup->mpDriverData ) - rtl_freeMemory( pJobSetup->mpDriverData ); + if( pJobSetup->GetDriverData() ) + rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) ); sal_uInt32 nBytes; void* pBuffer = nullptr; if( rData.getStreamBuffer( pBuffer, nBytes ) ) { - pJobSetup->mnDriverDataLen = nBytes; - pJobSetup->mpDriverData = static_cast<sal_uInt8*>(pBuffer); + pJobSetup->SetDriverDataLen( nBytes ); + pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) ); } else { - pJobSetup->mnDriverDataLen = 0; - pJobSetup->mpDriverData = nullptr; + pJobSetup->SetDriverDataLen( 0 ); + pJobSetup->SetDriverData( nullptr ); } } @@ -382,18 +385,19 @@ void SalGenericInstance::configurePspInfoPrinter(PspSalInfoPrinter *pPrinter, pPrinter->m_aJobData = aInfo; pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData ); - if( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo ); + if( pJobSetup->GetDriverData() ) + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), + pJobSetup->GetDriverDataLen(), aInfo ); - pJobSetup->mnSystem = JOBSETUP_SYSTEM_UNIX; - pJobSetup->maPrinterName = pQueueInfo->maPrinterName; - pJobSetup->maDriver = aInfo.m_aDriverName; + pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX ); + pJobSetup->SetPrinterName( pQueueInfo->maPrinterName ); + pJobSetup->SetDriver( aInfo.m_aDriverName ); copyJobDataToJobSetup( pJobSetup, aInfo ); } } SalInfoPrinter* SalGenericInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pJobSetup ) + ImplJobSetup* pJobSetup ) { mbPrinterInit = true; // create and initialize SalInfoPrinter @@ -553,42 +557,42 @@ bool PspSalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pJobSetup ) PrinterInfoManager& rManager = PrinterInfoManager::get(); - PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->maPrinterName ) ); - if ( pJobSetup->mpDriverData ) + PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->GetPrinterName() ) ); + if ( pJobSetup->GetDriverData() ) { SetData( JobSetFlags::ALL, pJobSetup ); - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aInfo ); } - aInfo.m_bPapersizeFromSetup = pJobSetup->mbPapersizeFromSetup; + aInfo.m_bPapersizeFromSetup = pJobSetup->GetPapersizeFromSetup(); if (SetupPrinterDriver(aInfo)) { aInfo.resolveDefaultBackend(); - rtl_freeMemory( pJobSetup->mpDriverData ); - pJobSetup->mpDriverData = nullptr; + rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) ); + pJobSetup->SetDriverData( nullptr ); sal_uInt32 nBytes; void* pBuffer = nullptr; aInfo.getStreamBuffer( pBuffer, nBytes ); - pJobSetup->mnDriverDataLen = nBytes; - pJobSetup->mpDriverData = static_cast<sal_uInt8*>(pBuffer); + pJobSetup->SetDriverDataLen( nBytes ); + pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) ); // copy everything to job setup copyJobDataToJobSetup( pJobSetup, aInfo ); - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData ); return true; } return false; } // This function gets the driver data and puts it into pJobSetup -// If pJobSetup->mpDriverData is NOT NULL, then the independent +// If pJobSetup->GetDriverData() is NOT NULL, then the independent // data should be merged into the driver data -// If pJobSetup->mpDriverData IS NULL, then the driver defaults +// If pJobSetup->GetDriverData() IS NULL, then the driver defaults // should be merged into the independent data bool PspSalInfoPrinter::SetPrinterData( ImplJobSetup* pJobSetup ) { - if( pJobSetup->mpDriverData ) + if( pJobSetup->GetDriverData() ) return SetData( JobSetFlags::ALL, pJobSetup ); copyJobDataToJobSetup( pJobSetup, m_aJobData ); @@ -605,7 +609,7 @@ bool PspSalInfoPrinter::SetData( ImplJobSetup* pJobSetup ) { JobData aData; - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); if( aData.m_pParser ) { @@ -617,21 +621,21 @@ bool PspSalInfoPrinter::SetData( { OUString aPaper; - if( pJobSetup->mePaperFormat == PAPER_USER ) + if( pJobSetup->GetPaperFormat() == PAPER_USER ) aPaper = aData.m_pParser->matchPaper( - TenMuToPt( pJobSetup->mnPaperWidth ), - TenMuToPt( pJobSetup->mnPaperHeight ) ); + TenMuToPt( pJobSetup->GetPaperWidth() ), + TenMuToPt( pJobSetup->GetPaperHeight() ) ); else - aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1); + aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), RTL_TEXTENCODING_ISO_8859_1); pKey = aData.m_pParser->getKey( OUString("PageSize") ); pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : nullptr; // some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5) // try to find the correct paper anyway using the size - if( pKey && ! pValue && pJobSetup->mePaperFormat != PAPER_USER ) + if( pKey && ! pValue && pJobSetup->GetPaperFormat() != PAPER_USER ) { - PaperInfo aInfo( pJobSetup->mePaperFormat ); + PaperInfo aInfo( pJobSetup->GetPaperFormat() ); aPaper = aData.m_pParser->matchPaper( TenMuToPt( aInfo.getWidth() ), TenMuToPt( aInfo.getHeight() ) ); @@ -648,11 +652,11 @@ bool PspSalInfoPrinter::SetData( pKey = aData.m_pParser->getKey( OUString("InputSlot") ); if( pKey ) { - int nPaperBin = pJobSetup->mnPaperBin; + int nPaperBin = pJobSetup->GetPaperBin(); if( nPaperBin >= pKey->countValues() ) pValue = pKey->getDefaultValue(); else - pValue = pKey->getValue( pJobSetup->mnPaperBin ); + pValue = pKey->getValue( pJobSetup->GetPaperBin() ); // may fail due to constraints; // real paper bin is copied back to jobsetup in that case @@ -664,7 +668,7 @@ bool PspSalInfoPrinter::SetData( // merge orientation if necessary if( nSetDataFlags & JobSetFlags::ORIENTATION ) - aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait; + aData.m_eOrientation = pJobSetup->GetOrientation() == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait; // merge duplex if necessary if( nSetDataFlags & JobSetFlags::DUPLEXMODE ) @@ -673,7 +677,7 @@ bool PspSalInfoPrinter::SetData( if( pKey ) { pValue = nullptr; - switch( pJobSetup->meDuplexMode ) + switch( pJobSetup->GetDuplexMode() ) { case DUPLEX_OFF: pValue = pKey->getValue( OUString("None") ); @@ -715,7 +719,7 @@ void PspSalInfoPrinter::GetPageInfo( return; JobData aData; - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); // get the selected page size if( aData.m_pParser ) @@ -752,7 +756,7 @@ sal_uLong PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup ) return 0; JobData aData; - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( OUString("InputSlot") ): nullptr; return pKey ? pKey->countValues() : 0; @@ -761,7 +765,7 @@ sal_uLong PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup ) OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_uLong nPaperBin ) { JobData aData; - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); OUString aRet; if( aData.m_pParser ) @@ -808,9 +812,9 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr { // see if the PPD contains the fax4CUPS "Dial" option and that it's not set // to "manually" - JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->maPrinterName); - if( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->GetPrinterName()); + if( pJobSetup->GetDriverData() ) + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey(OUString("Dial")) : nullptr; const PPDValue* pValue = pKey ? aData.m_aContext.getValue(pKey) : nullptr; if (pValue && !pValue->m_aOption.equalsIgnoreAsciiCase("Manually")) @@ -819,24 +823,24 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr } case PrinterCapType::PDF: - if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "pdf" ) ) + if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->GetPrinterName(), "pdf" ) ) return 1; else { // see if the PPD contains a value to set PDF device - JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName ); - if( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->GetPrinterName() ); + if( pJobSetup->GetDriverData() ) + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); return aData.m_nPDFDevice > 0 ? 1 : 0; } case PrinterCapType::ExternalDialog: - return PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "external_dialog" ) ? 1 : 0; + return PrinterInfoManager::get().checkFeatureToken( pJobSetup->GetPrinterName(), "external_dialog" ) ? 1 : 0; case PrinterCapType::UsePullModel: { // see if the PPD contains a value to set PDF device - JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName ); - if( pJobSetup->mpDriverData ) - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData ); + JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->GetPrinterName() ); + if( pJobSetup->GetDriverData() ) + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData ); return aData.m_nPDFDevice > 0 ? 1 : 0; } default: break; @@ -890,7 +894,7 @@ bool PspSalPrinter::StartJob( m_nCopies = nCopies; m_bCollate = bCollate; - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData ); if( m_nCopies > 1 ) { // in case user did not do anything (m_nCopies=1) @@ -954,7 +958,7 @@ SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, bool ) { OSL_TRACE("PspSalPrinter::StartPage"); - JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); + JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData ); m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx, m_pInfoPrinter); @@ -1033,7 +1037,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo // update job data if( i_pSetupData ) - JobData::constructFromStreamBuffer( i_pSetupData->mpDriverData, i_pSetupData->mnDriverDataLen, m_aJobData ); + JobData::constructFromStreamBuffer( i_pSetupData->GetDriverData(), i_pSetupData->GetDriverDataLen(), m_aJobData ); OSL_ASSERT( m_aJobData.m_nPDFDevice > 0 ); m_aJobData.m_nPDFDevice = 1; |