vcl/source/gdi/print3.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+)
New commits: commit c02bef3a272f6d93669c4e0b51606dcdf56fe425 Author: Justin Luth <[email protected]> AuthorDate: Thu Oct 23 16:15:47 2025 -0400 Commit: Justin Luth <[email protected]> CommitDate: Fri Oct 24 03:24:15 2025 +0200 tdf#166185 vcl PrinterController: oversized? align top, not center If the printout is too large to fit on the paper, then instead of centering it, start at the top, since it is usually better to lose bottom content than top content. [I was originally going to do the same thing for Width, but RightToLeft languages would disagree about being better to lose right content than left...] Change-Id: I34c7420740655e76889c813dffb2d9866d7d1997 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192927 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index ff1721f84536..0dba55e6f11a 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1198,6 +1198,16 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte o_rMtf.WindStart(); tools::Long nDX = (aPaperSize.Width() - aPageSize.aSize.Width()) / 2; tools::Long nDY = (aPaperSize.Height() - aPageSize.aSize.Height()) / 2; + + // if the printout is larger than the paper: instead of centering, start at the top + const bool bHeigher = aPageSize.aSize.Height() > aPaperSize.Height(); + if (aPageSize.bFullPaper && bHeigher) + { + Point aOffset(mpImplData->mxPrinter->GetPageOffset()); + if (aPageSize.aSize.Height() - aPaperSize.Height() > aOffset.Y() * 2) + nDY = -aOffset.Y(); + } + o_rMtf.Move( nDX, nDY, mpImplData->mxPrinter->GetDPIX(), mpImplData->mxPrinter->GetDPIY() ); o_rMtf.WindStart(); o_rMtf.SetPrefSize( aPaperSize );
