diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-09-21 22:22:38 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-09-22 19:40:02 +0200 |
commit | 6005aeca4416eb0d583fd12ab837afa91d9d18ec (patch) | |
tree | 47c5a3e238a0ab20a583b2748dac6b4c9f7bd7bf /vcl/unx | |
parent | 3805a4090dbbffa54bb1a9d7fe63e723fc6d029b (diff) |
tdf#151107 swap job orientation if paper matching swapped width/height
if we eventually are forced to pick a final paper size which has the
orthogonal orientation than that requested, then swap the orientation of
the jobdata too
and re-init the orientation to defaults in Printer::SetPaperSizeUser
when we set a new user paper size rather than keeping the orig
Change-Id: Ie9e783575734c7f9eec3984efd1357cae5375130
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140358
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/print/genprnpsp.cxx | 14 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 29 |
2 files changed, 33 insertions, 10 deletions
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index 5c17874c4dfb..30c4f884a041 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -569,6 +569,10 @@ bool PspSalInfoPrinter::SetData( const PPDKey* pKey; const PPDValue* pValue; + // merge orientation if necessary + if( nSetDataFlags & JobSetFlags::ORIENTATION ) + aData.m_eOrientation = pJobSetup->GetOrientation() == Orientation::Landscape ? orientation::Landscape : orientation::Portrait; + // merge papersize if necessary if( nSetDataFlags & JobSetFlags::PAPERSIZE ) { @@ -577,7 +581,8 @@ bool PspSalInfoPrinter::SetData( if( pJobSetup->GetPaperFormat() == PAPER_USER ) aPaper = aData.m_pParser->matchPaper( TenMuToPt( pJobSetup->GetPaperWidth() ), - TenMuToPt( pJobSetup->GetPaperHeight() ) ); + TenMuToPt( pJobSetup->GetPaperHeight() ), + &aData.m_eOrientation ); else aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), RTL_TEXTENCODING_ISO_8859_1); @@ -591,7 +596,8 @@ bool PspSalInfoPrinter::SetData( PaperInfo aInfo( pJobSetup->GetPaperFormat() ); aPaper = aData.m_pParser->matchPaper( TenMuToPt( aInfo.getWidth() ), - TenMuToPt( aInfo.getHeight() ) ); + TenMuToPt( aInfo.getHeight() ), + &aData.m_eOrientation ); pValue = pKey->getValueCaseInsensitive( aPaper ); } @@ -619,10 +625,6 @@ bool PspSalInfoPrinter::SetData( // (e.g. SGENPRT has no InputSlot) } - // merge orientation if necessary - if( nSetDataFlags & JobSetFlags::ORIENTATION ) - aData.m_eOrientation = pJobSetup->GetOrientation() == Orientation::Landscape ? orientation::Landscape : orientation::Portrait; - // merge duplex if necessary if( nSetDataFlags & JobSetFlags::DUPLEXMODE ) { diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 6e980776e73e..dfe553caa6ed 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -1466,7 +1466,7 @@ bool PPDParser::getPaperDimension( return true; } -OUString PPDParser::matchPaper(int nWidth, int nHeight, bool bDontSwap) const +OUString PPDParser::matchPaperImpl(int nWidth, int nHeight, bool bSwaped, psp::orientation* pOrientation) const { if( ! m_pPaperDimensions ) return OUString(); @@ -1497,13 +1497,34 @@ OUString PPDParser::matchPaper(int nWidth, int nHeight, bool bDontSwap) const } } - if( nPDim == -1 && ! bDontSwap ) + if (nPDim == -1 && !bSwaped) { // swap portrait/landscape and try again - return matchPaper( nHeight, nWidth, true ); + return matchPaperImpl(nHeight, nWidth, true, pOrientation); } - return nPDim != -1 ? m_pPaperDimensions->getValue( nPDim )->m_aOption : OUString(); + if (nPDim == -1) + return OUString(); + + if (bSwaped && pOrientation) + { + switch (*pOrientation) + { + case psp::orientation::Portrait: + *pOrientation = psp::orientation::Landscape; + break; + case psp::orientation::Landscape: + *pOrientation = psp::orientation::Portrait; + break; + } + } + + return m_pPaperDimensions->getValue( nPDim )->m_aOption; +} + +OUString PPDParser::matchPaper(int nWidth, int nHeight, psp::orientation* pOrientation) const +{ + return matchPaperImpl(nHeight, nWidth, true, pOrientation); } OUString PPDParser::getDefaultInputSlot() const |