diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-11-02 20:16:31 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-03-15 12:47:19 +0100 |
commit | 28b19ef4c95d7c742a7f002283558ea1f72c9021 (patch) | |
tree | 7f787cccdee89b2e9605d25ef8e9b4a03b31e272 /vcl | |
parent | 62de78f08bf07b24889c357eb8a31fc5472baff3 (diff) |
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 <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/printdlg.hxx | 1 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 16 |
2 files changed, 10 insertions, 7 deletions
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index e4d42f4bb7c7..a403d07f5206 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 251ce6002535..7d918d931ba1 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -211,7 +211,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, @@ -237,14 +236,21 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi Size aLogicPaperSize(OutputDevice::LogicToLogic(i_rOrigSize, MapMode(MapUnit::Map100thMM), MapMode(eUnit))); OUString aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) ); OUStringBuffer aBuf; - aBuf.append( aNumText + " " ); + aBuf.append( aNumText ) + .append( u' ' ); 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(); + + 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 ); @@ -948,7 +954,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache ) if ( !hasPreview() ) { mxPreview->setPreview( aMtf, aCurPageSize, - Printer::GetPaperName( mePaper ), maNoPreviewStr, aPrt->GetDPIX(), aPrt->GetDPIY(), aPrt->GetPrinterOptions().IsConvertToGreyscales() @@ -984,7 +989,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() |