vcl/inc/printdlg.hxx | 1 - vcl/source/window/printdlg.cxx | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
New commits: commit 8d49b548ba2aabb799f879fc6daa7b1e09b09139 Author: Tor Lillqvist <[email protected]> AuthorDate: Tue Nov 2 20:16:31 2021 +0200 Commit: Andras Timar <[email protected]> CommitDate: Wed Nov 10 12:18:05 2021 +0100 tdf#145354: Ensure displayed paper name matches displayed paper dimensions I could not reproduce it now but at least in some slightly older version of LibreOffice, it could happen that at the top of the print preview image was displayed "143 mm (A4)" which is silly, as neither side of an A4 paper is 143 mm. Look up the matching paper size from the dimensions displayed. Use the "sloppy" match function to allow for sub-millimeter rounding errors. Change-Id: I6320798061246101c6fc78baf841b71b32b25833 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124635 Tested-by: Andras Timar <[email protected]> Reviewed-by: Andras Timar <[email protected]> diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 64e127e43261..db041f1705fd 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -81,7 +81,6 @@ namespace vcl virtual void Resize() override; void setPreview( const GDIMetaFile&, const Size& i_rPaperSize, - const OUString& i_rPaperName, const OUString& i_rNoPageString, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, bool i_bGreyscale diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 120d6a5b6e1c..250df3916b78 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -248,7 +248,6 @@ bool PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize, - const OUString& i_rPaperName, const OUString& i_rReplacement, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, @@ -277,12 +276,18 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi aBuf.append( aNumText ) .append( u' ' ); aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" ); - if( !i_rPaperName.isEmpty() ) + + // Look up the paper name from the dimensions + PaperInfo aPaperInfoFromSize(i_rOrigSize.getWidth(), i_rOrigSize.getHeight()); + aPaperInfoFromSize.doSloppyFit(); + + if (aPaperInfoFromSize.getPaper() != PAPER_USER) { aBuf.append( " (" ); - aBuf.append( i_rPaperName ); + aBuf.append( Printer::GetPaperName(aPaperInfoFromSize.getPaper()) ); aBuf.append( ')' ); } + maHorzText = aBuf.makeStringAndClear(); aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ); @@ -935,7 +940,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache ) if ( !hasPreview() ) { mxPreview->setPreview( aMtf, aCurPageSize, - Printer::GetPaperName( mePaper ), maNoPreviewStr, aPrt->GetDPIX(), aPrt->GetDPIY(), aPrt->GetPrinterOptions().IsConvertToGreyscales() @@ -970,7 +974,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache ) } mxPreview->setPreview( aMtf, aCurPageSize, - Printer::GetPaperName( mePaper ), nPages > 0 ? OUString() : maNoPageStr, aPrt->GetDPIX(), aPrt->GetDPIY(), aPrt->GetPrinterOptions().IsConvertToGreyscales()
