summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-11-02 20:16:31 +0200
committerAndras Timar <andras.timar@collabora.com>2022-03-15 13:00:20 +0100
commit3e7ccf89394835ef94fe9a7e46e0d695c1b79125 (patch)
tree4f13b43940f9f6ad88fb581add2db6a6e76e66b3
parentupgrade expat to 2.4.5 (diff)
downloadcore-3e7ccf89394835ef94fe9a7e46e0d695c1b79125.tar.gz
core-3e7ccf89394835ef94fe9a7e46e0d695c1b79125.zip
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>
-rw-r--r--vcl/inc/printdlg.hxx1
-rw-r--r--vcl/source/window/printdlg.cxx13
2 files changed, 8 insertions, 6 deletions
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index db1e6a73bcfc..703b4f247fe9 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,
- 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 8866abe43733..0afe5d487a8f 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -214,7 +214,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,
@@ -243,12 +242,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 );
@@ -953,7 +958,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
if ( !hasPreview() )
{
mxPreview->setPreview( aMtf, aCurPageSize,
- Printer::GetPaperName( mePaper ),
maNoPreviewStr,
aPrt->GetDPIX(), aPrt->GetDPIY(),
aPrt->GetPrinterOptions().IsConvertToGreyscales()
@@ -988,7 +992,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()