vcl/inc/printdlg.hxx | 1 - vcl/source/window/printdlg.cxx | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
New commits: commit 65081542d2dabdf17820d62abdc5a22d3734e52d Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Tue Nov 2 20:16:31 2021 +0200 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Nov 3 12:07:14 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/+/124612 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <t...@collabora.com> diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 21aab3667d4e..d2ce1670a845 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -65,7 +65,6 @@ namespace vcl virtual void Resize() override; void setPreview( const GDIMetaFile&, const Size& i_rPaperSize, - std::u16string_view 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 9909b087e02d..bf4fdf1519eb 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -207,7 +207,6 @@ bool PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt ) void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview, const Size& i_rOrigSize, - std::u16string_view i_rPaperName, const OUString& i_rReplacement, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY, @@ -235,12 +234,18 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi OUStringBuffer aBuf; aBuf.append( aNumText + " " ); aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" ); - if( !i_rPaperName.empty() ) + + // Look up the paper name from the dimensions + PaperInfo aPaperInfoFromSize(i_rOrigSize.getWidth(), i_rOrigSize.getHeight()); + aPaperInfoFromSize.doSloppyFit( true ); + + 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 ); @@ -944,7 +949,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache ) if ( !hasPreview() ) { mxPreview->setPreview( aMtf, aCurPageSize, - Printer::GetPaperName( mePaper ), maNoPreviewStr, aPrt->GetDPIX(), aPrt->GetDPIY(), aPrt->GetPrinterOptions().IsConvertToGreyscales() @@ -979,7 +983,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()