svx/source/svdraw/svdpagv.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
New commits: commit e49b92a479dc88f02c4adeb9db732d9b5c11b9bc Author: Tamás Zolnai <[email protected]> AuthorDate: Tue Nov 4 09:17:09 2025 +0100 Commit: Tamás Zolnai <[email protected]> CommitDate: Wed Nov 5 10:00:23 2025 +0100 tdf#169226: Avoid rendering grid points outside of the drawing area In Writer. The drawing area might be very small. The code always drew the first segment of the grid without considering that this segment might not be fully visible. Change-Id: I76d51393ae1f0219c25e890bd57ec00a7c51ed91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193385 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <[email protected]> diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx index 41419bc113f1..ffdfef307c7c 100644 --- a/svx/source/svdraw/svdpagv.cxx +++ b/svx/source/svdraw/svdpagv.cxx @@ -498,6 +498,7 @@ void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& r if( x1 <= x2 && y1 <= y2 ) { + const tools::Rectangle aDrawingArea(x1, y1, x2, y2); if( bHoriLines ) { DrawGridFlags nGridFlags = ( bHoriSolid ? DrawGridFlags::HorzLines : DrawGridFlags::Dots ); @@ -508,9 +509,16 @@ void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& r for(sal_uInt16 a=0;a<nSteps;a++) { + // Make sure the origin of the subgrid is within the drawing area + const Point aSubGridPosition(xFinOrg + (a * nx2) + nPointOffset, yBigOrg); + if (!aDrawingArea.Contains(aSubGridPosition)) + { + continue; + } + // draw rOut.DrawGrid( - tools::Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ), + tools::Rectangle( aSubGridPosition, Point(x2, y2) ), Size( nx1, ny1 ), nGridFlags ); // do a step @@ -533,9 +541,16 @@ void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const tools::Rectangle& r for(sal_uInt16 a=0;a<nSteps;a++) { + // Make sure the origin of the subgrid is within the drawing area + const Point aSubGridPosition(xBigOrg, yFinOrg + (a * ny2) + nPointOffset); + if (!aDrawingArea.Contains(aSubGridPosition)) + { + continue; + } + // draw rOut.DrawGrid( - tools::Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ), + tools::Rectangle( aSubGridPosition, Point(x2, y2) ), Size( nx1, ny1 ), nGridFlags ); // do a step
