diff options
author | Xisco Fauli <anistenis@gmail.com> | 2016-05-02 19:07:23 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2016-06-24 23:01:04 +0000 |
commit | 0325b22a2a2b537a71f53b7c5d3e6c13fef68911 (patch) | |
tree | 185ce849074b367c8005abb704fc4c7f271fca00 /vcl/headless/svpprn.cxx | |
parent | 46773b0b59bb9061c5f5660e65e4ebc0d455fe02 (diff) |
tdf#62525 vcl: use cow_wrapper for jobset
Besides:
* Convert ImplJobSetup to be a class.
* Use ImplJobSetup's setters and getters everywhere
* add some const-correctness at places
Change-Id: I32101048e9be4f3950a4540b0666ed548bbcb211
Reviewed-on: https://gerrit.libreoffice.org/24594
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'vcl/headless/svpprn.cxx')
-rw-r--r-- | vcl/headless/svpprn.cxx | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx index a966452848da..c5c8ea550d2b 100644 --- a/vcl/headless/svpprn.cxx +++ b/vcl/headless/svpprn.cxx @@ -60,17 +60,17 @@ inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*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->mnPaperWidth = 0; - pJobSetup->mnPaperHeight = 0; - if( pJobSetup->mePaperFormat == PAPER_USER ) + pJobSetup->SetPaperFormat( PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )) ); + pJobSetup->SetPaperWidth( 0 ); + pJobSetup->SetPaperHeight( 0 ); + if( pJobSetup->GetPaperFormat() == PAPER_USER ) { // transform to 100dth mm width = PtTo10Mu( width ); @@ -78,13 +78,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 ); } } @@ -92,27 +92,28 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) const PPDKey* pKey = nullptr; const PPDValue* pValue = nullptr; - pJobSetup->mnPaperBin = 0xffff; + pJobSetup->SetPaperBin( 0xffff ); 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() || pValue == pKey->getDefaultValue() ) - pJobSetup->mnPaperBin = 0xffff; + sal_uInt16 nPaperBin; + for( nPaperBin = 0; + pValue != pKey->getValue( nPaperBin ) && + nPaperBin < pKey->countValues(); + nPaperBin++ ); + pJobSetup->SetPaperBin(nPaperBin); + if( nPaperBin >= pKey->countValues() || pValue == pKey->getDefaultValue() ) + pJobSetup->SetPaperBin( 0xffff ); } // 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 ) @@ -123,40 +124,40 @@ 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 ); } } // SalInstance SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, - ImplJobSetup* pJobSetup ) + ImplJobSetup* pJobSetup ) { // create and initialize SalInfoPrinter SvpSalInfoPrinter* pPrinter = new SvpSalInfoPrinter(); @@ -168,12 +169,13 @@ SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueIn 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 ); } |