svx/source/svdraw/svdpagv.cxx |  108 ++++++++++++++++++++++++++----------------
 1 file changed, 68 insertions(+), 40 deletions(-)

New commits:
commit 87e2c1686a0566cffcd5185f52152efee4e44175
Author:     Tamás Zolnai <[email protected]>
AuthorDate: Thu Nov 6 11:58:14 2025 +0100
Commit:     Tamás Zolnai <[email protected]>
CommitDate: Fri Nov 7 13:58:16 2025 +0100

    tdf#169291: Fix rendering of solid grid in Writer.
    
    When solid lines are used for rendering the grid,
    different input agruments are expected by DrawGrid() method.
    The start position of the lines is needed, which is determined
    by the edge of the drawing area.
    
    Also move the DrawGrid() call out of the loop. It's enough to call
    the rendering code once for the vertical and once for the horizontal
    lines.
    
    Change-Id: I1f1eddd2c3c9abd91fbd3e48eaee9bd10385ef6e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193541
    Reviewed-by: Tamás Zolnai <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index ffdfef307c7c..88fbdb8d8220 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -501,64 +501,92 @@ void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, 
const tools::Rectangle& r
             const tools::Rectangle aDrawingArea(x1, y1, x2, y2);
             if( bHoriLines )
             {
-                DrawGridFlags nGridFlags = ( bHoriSolid ? 
DrawGridFlags::HorzLines : DrawGridFlags::Dots );
-                sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
-                sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000)/ 
nSteps) - (nx2 * 1000) ) : 0;
-                sal_uInt32 nStepOffset = 0;
-                sal_uInt16 nPointOffset = 0;
-
-                for(sal_uInt16 a=0;a<nSteps;a++)
+                if( bHoriSolid )
                 {
                     // Make sure the origin of the subgrid is within the 
drawing area
-                    const Point aSubGridPosition(xFinOrg + (a * nx2) + 
nPointOffset, yBigOrg);
-                    if (!aDrawingArea.Contains(aSubGridPosition))
+                    const Point aSubGridPosition(x1, yBigOrg);
+                    if (aDrawingArea.Contains(aSubGridPosition))
                     {
-                        continue;
+                        // draw
+                        rOut.DrawGrid(
+                            tools::Rectangle( aSubGridPosition, Point(x2, y2) 
),
+                            Size( nx1, ny1 ), DrawGridFlags::HorzLines );
                     }
+                }
+                else
+                {
+                    sal_uInt16 nSteps = sal_uInt16(nx1 / nx2);
+                    sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000)/ 
nSteps) - (nx2 * 1000) ) : 0;
+                    sal_uInt32 nStepOffset = 0;
+                    sal_uInt16 nPointOffset = 0;
 
-                    // draw
-                    rOut.DrawGrid(
-                        tools::Rectangle( aSubGridPosition, Point(x2, y2) ),
-                        Size( nx1, ny1 ), nGridFlags );
-
-                    // do a step
-                    nStepOffset += nRestPerStepMul1000;
-                    while(nStepOffset >= 1000)
+                    for(sal_uInt16 a=0;a<nSteps;a++)
                     {
-                        nStepOffset -= 1000;
-                        nPointOffset++;
+                        // 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( aSubGridPosition, Point(x2, y2) 
),
+                            Size( nx1, ny1 ), DrawGridFlags::Dots );
+
+                        // do a step
+                        nStepOffset += nRestPerStepMul1000;
+                        while(nStepOffset >= 1000)
+                        {
+                            nStepOffset -= 1000;
+                            nPointOffset++;
+                        }
                     }
                 }
             }
 
             if( bVertLines )
             {
-                DrawGridFlags nGridFlags = ( bVertSolid ? 
DrawGridFlags::VertLines : DrawGridFlags::Dots );
-                sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
-                sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ 
nSteps) - (ny2 * 1000L) ) : 0;
-                sal_uInt32 nStepOffset = 0;
-                sal_uInt16 nPointOffset = 0;
-
-                for(sal_uInt16 a=0;a<nSteps;a++)
+                if( bVertSolid )
                 {
                     // Make sure the origin of the subgrid is within the 
drawing area
-                    const Point aSubGridPosition(xBigOrg, yFinOrg + (a * ny2) 
+ nPointOffset);
-                    if (!aDrawingArea.Contains(aSubGridPosition))
+                    const Point aSubGridPosition(xBigOrg, y1);
+                    if (aDrawingArea.Contains(aSubGridPosition))
                     {
-                        continue;
+                        // draw
+                        rOut.DrawGrid(
+                            tools::Rectangle( aSubGridPosition, Point(x2, y2) 
),
+                            Size( nx1, ny1 ), DrawGridFlags::VertLines );
                     }
+                }
+                else
+                {
+                    sal_uInt16 nSteps = sal_uInt16(ny1 / ny2);
+                    sal_uInt32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 
1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
+                    sal_uInt32 nStepOffset = 0;
+                    sal_uInt16 nPointOffset = 0;
 
-                    // draw
-                    rOut.DrawGrid(
-                        tools::Rectangle( aSubGridPosition, Point(x2, y2) ),
-                        Size( nx1, ny1 ), nGridFlags );
-
-                    // do a step
-                    nStepOffset += nRestPerStepMul1000;
-                    while(nStepOffset >= 1000)
+                    for(sal_uInt16 a=0;a<nSteps;a++)
                     {
-                        nStepOffset -= 1000;
-                        nPointOffset++;
+                        // 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( aSubGridPosition, Point(x2, y2) 
),
+                            Size( nx1, ny1 ), DrawGridFlags::Dots );
+
+                        // do a step
+                        nStepOffset += nRestPerStepMul1000;
+                        while(nStepOffset >= 1000)
+                        {
+                            nStepOffset -= 1000;
+                            nPointOffset++;
+                        }
                     }
                 }
             }

Reply via email to