sc/source/ui/view/output.cxx   |    8 ++++++--
 sc/source/ui/view/printfun.cxx |    4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit cef2ea134acf20ce3a1bcf681424b1ed2864f7db
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Sat Mar 15 17:48:11 2025 +0100
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Sun Mar 16 15:00:27 2025 +0100

    tdf#135891 - Adjust the x position to ensure the correct starting point
    
    Change-Id: I739f27796ed2bf995a8c11e8e6fe958776a05bfd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182965
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 60648f726e85..13e5e5af9572 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -1135,6 +1135,10 @@ void ScOutputData::DrawBackground(vcl::RenderContext& 
rRenderContext)
                 if ( bLayoutRTL )
                     nPosX += nMirrorW - nOneX;
 
+                // tdf#135891 - adjust the x position to ensure the correct 
starting point
+                if (!bWorksInPixels)
+                    nPosX -= nLayoutSign + 1;
+
                 aRect = tools::Rectangle(nPosX, nPosY - 1, nPosX, nPosY - 1 + 
nRowHeight);
                 if (bWorksInPixels)
                     aRect = rRenderContext.PixelToLogic(aRect); // internal 
data in pixels, but we'll be drawing in logic units
@@ -1219,8 +1223,8 @@ void ScOutputData::DrawBackground(vcl::RenderContext& 
rRenderContext)
 
                     nPosX = nNewPosX;
                     // tdf#135891 - adjust the x position to ensure the 
correct starting point
-                    if (!bWorksInPixels && ((nX == 0 && !bLayoutRTL) || (nX == 
nX1 && bLayoutRTL)))
-                        nPosX += nSignedOneX;
+                    if (!bWorksInPixels && nX == nX1)
+                        nPosX += nSignedOneX + 1;
                 }
 
                 tools::Long nPosXLogic = nPosX;
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 07f5225b87f5..1b66b85906eb 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -541,7 +541,9 @@ void ScPrintFunc::DrawToDev(ScDocument& rDoc, OutputDevice* 
pDev, double /* nPri
 
     //  If no lines, still leave space for grid lines
     //  (would be elseways cut away)
-    nScrX += 1;
+    // tdf#135891 - adjust the x position to ensure the correct starting point
+    const Size aOnePixel = pDev->PixelToLogic(Size(1, 1));
+    nScrX += aOnePixel.Width();
     nScrY += 1;
 
     ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, &rDoc, nTab,

Reply via email to