sc/qa/unit/tiledrendering/data/page-view.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering2.cxx |   27 ++++++++++++++++++++++++++
 sc/source/ui/view/gridwin4.cxx                |   15 +++++++++++++-
 3 files changed, 41 insertions(+), 1 deletion(-)

New commits:
commit 6d2dc20708bd3dafe96cf136898299307e6b68e2
Author:     Jaume Pujantell <[email protected]>
AuthorDate: Wed Jan 21 20:08:04 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Jan 28 09:06:48 2026 +0100

    cool#14171 lok: sc: offset properly some drawings in LOK
    
    In tiled rendering mode, the lines around page break view where being
    rendered in improper places. This is due to the fact that the lines
    where drawn in absolute coordinates while the rendering device has it's
    own origin.
    
    This can be accounted for by moving the origin before DrawPagePreview.
    Like it's already done before DrawButtons.
    
    Change-Id: I47dc6022306bb49b2bb4c0010fccfb1c6147b2f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197771
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit dfb0ed2123890cf036cee81383248a53378aaa4c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198218
    Tested-by: Miklos Vajna <[email protected]>

diff --git a/sc/qa/unit/tiledrendering/data/page-view.xlsx 
b/sc/qa/unit/tiledrendering/data/page-view.xlsx
new file mode 100644
index 000000000000..3cf6fec42399
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/page-view.xlsx 
differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering2.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering2.cxx
index e5d3cecaab45..d25c44eebadc 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering2.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering2.cxx
@@ -14,6 +14,7 @@
 #include <comphelper/propertyvalue.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <vcl/BitmapReadAccess.hxx>
 #include <vcl/scheduler.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
@@ -252,6 +253,32 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testTdf167042)
     CPPUNIT_ASSERT_EQUAL(u"test1"_ustr, pNote->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testBreakPageView)
+{
+    // Give a file in page break view mode
+    ScModelObj* pModelObj = createDoc("page-view.xlsx");
+
+    // Paint a tile not at the top or left
+    size_t nCanvasSize = 1024;
+    size_t nTileSize = 256;
+    std::vector<unsigned char> aPixmap(nCanvasSize * nCanvasSize * 4, 0);
+    ScopedVclPtrInstance<VirtualDevice> xDevice(DeviceFormat::WITHOUT_ALPHA);
+    xDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
+    xDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasSize, 
nCanvasSize),
+                                                       Fraction(1.0), Point(), 
aPixmap.data());
+    pModelObj->paintTile(*xDevice, nCanvasSize, nCanvasSize, 3840, 3840, 3840, 
3840);
+    xDevice->EnableMapMode(false);
+    Bitmap aBitmap = xDevice->GetBitmap(Point(0, 0), Size(nTileSize, 
nTileSize));
+
+    // Top left pixel should be white, not blue
+    BitmapScopedReadAccess pAccess(aBitmap);
+    Color aColor(pAccess->GetPixel(0, 0));
+    // Without the fix in place, this test fails with
+    // - Expected: rgba[ffffffff]
+    // - Actual  : rgba[000080ff]
+    CPPUNIT_ASSERT_EQUAL(Color(255, 255, 255), aColor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index c85000116b9e..2b2aed7c0120 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -953,7 +953,18 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, 
const ScTableInfo& rTableI
     if (!bGridFirst && (bGrid || bPage) && !bNoBackgroundAndGrid)
         aOutputData.DrawGrid(*pContentDev, bGrid, bPage);
 
-    pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
+    if (bIsTiledRendering)
+    {
+        // Tiled offset nScrX, nScrY
+        MapMode aMap(MapUnit::MapPixel);
+        Point aOrigin(
+            o3tl::convert(aOriginalMode.GetOrigin(), o3tl::Length::twip, 
o3tl::Length::px));
+        aOrigin.Move(nScrX, nScrY);
+        aMap.SetOrigin(aOrigin);
+        pContentDev->SetMapMode(aMap);
+    }
+    else
+        pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
 
     //tdf#128258 - draw a dotted line before hidden columns/rows
     DrawHiddenIndicator(nX1,nY1,nX2,nY2, *pContentDev);
@@ -967,6 +978,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const 
ScTableInfo& rTableI
             pContentDev->SetClipRegion();
         }
     }
+    if (bIsTiledRendering)
+        pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
 
     aOutputData.DrawShadow();
     aOutputData.DrawFrame(*pContentDev);

Reply via email to