sc/qa/unit/tiledrendering/data/split.ods     |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   43 +++++++++++++++++++++++++++
 sc/source/ui/view/gridwin.cxx                |   17 ++++++++++
 3 files changed, 60 insertions(+)

New commits:
commit 3314d4f9a6461f569d12ad0fef51eef26c5510c2
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Dec 19 21:03:11 2023 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Dec 28 21:30:01 2023 +0100

    kit: update formulas in frozen area
    
    when the main pane has scrolled sufficiently that those areas are off
    screen from the main pane perspective.
    
    In kit mode while there can be (up to) 4 panes, each pane is considered
    to be at cell 0, 0 and of the same size as the window.
    
    Unlike desktop mode the information as to what ranges are shown when
    there are frozen rows/cols is instead available via LOKSheetFreezeIndex
    
    commit daaf101ffe683eb691418ec2df4adc260d7e6a15
    Date:   Mon May 7 12:49:22 2018 +0200
    
        lok: sc: formulas were not updated correctly
    
        this patch fixes several issues:
    
    commit 0ef7bc8a1d2f00715d6849f1bbceb26e32382d41
    Date:   Fri Mar 29 09:01:05 2019 -0400
    
        sc lok: avoid save incorrect data, whether the pane has ...
    
        horizontal / vertical splits
    
    commit 7b4802070ac6fb930255536bf3ed2c52428b4181
    Date:   Wed Jul 15 15:55:45 2020 +0530
    
        lok-freezepanes: Generalize FreezePanes* uno-commands...
    
    commit 818b7e508bcabae48cb1c96c987a9f83d83ff6e0
    Date:   Wed Apr 21 18:28:13 2021 +0200
    
        lok: calc: formula breaking to multiple lines partly shown in edit mode
    
    Change-Id: I1e55f7bbc0df5c6fd09a10e261d25c1ce00a243a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160995
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161270
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/qa/unit/tiledrendering/data/split.ods 
b/sc/qa/unit/tiledrendering/data/split.ods
new file mode 100644
index 000000000000..efe2c225a410
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/split.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index d72cb6457fb4..8446f07fc3b9 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3141,6 +3141,49 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testOpenURL)
     CPPUNIT_ASSERT(!aView2.m_aHyperlinkClicked.isEmpty());
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testInvalidateForSplitPanes)
+{
+    comphelper::LibreOfficeKit::setCompatFlag(
+        comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
+
+    ScModelObj* pModelObj = createDoc("split.ods");
+    CPPUNIT_ASSERT(pModelObj);
+    ScTabViewShell* pView = 
dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+    CPPUNIT_ASSERT(pView);
+
+    // view
+    ViewCallback aView;
+
+    // move way over to the right where BP:20 exists, enough so that rows A 
and B
+    // would scroll off the page and not be visible, if they were not frozen
+    pModelObj->setClientVisibleArea(tools::Rectangle(73050, 0, 94019, 7034));
+    Scheduler::ProcessEventsToIdle();
+
+    ScAddress aBP20(67, 19, 0); // BP:20
+
+    pView->SetCursor(aBP20.Col(), aBP20.Row());
+    Scheduler::ProcessEventsToIdle();
+
+    aView.m_bInvalidateTiles = false;
+    aView.m_aInvalidations.clear();
+
+    lcl_typeCharsInCell("X", aBP20.Col(), aBP20.Row(), pView, pModelObj); // 
Type 'X' in A1
+
+    CPPUNIT_ASSERT(aView.m_bInvalidateTiles);
+
+    // missing before fix
+    tools::Rectangle aTopLeftPane(0, 500, 3817, 742);
+    bool bFoundTopLeftPane =
+        std::find(aView.m_aInvalidations.begin(), 
aView.m_aInvalidations.end(), aTopLeftPane) != aView.m_aInvalidations.end();
+    CPPUNIT_ASSERT_MESSAGE("The cell visible in the top left pane should be 
redrawn", bFoundTopLeftPane);
+
+    // missing before fix
+    tools::Rectangle aBottomLeftPane(0, 500, 3817, 3242);
+    bool bFoundBottomLeftPane =
+        std::find(aView.m_aInvalidations.begin(), 
aView.m_aInvalidations.end(), aBottomLeftPane) != aView.m_aInvalidations.end();
+    CPPUNIT_ASSERT_MESSAGE("The cell visible in the bottom left pane should be 
redrawn", bFoundBottomLeftPane);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index aa90b2183415..446badbb1244 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5101,6 +5101,23 @@ void ScGridWindow::UpdateFormulas(SCCOL nX1, SCROW nY1, 
SCCOL nX2, SCROW nY2)
             nY2 = pViewShell->GetLOKEndHeaderRow();
 
         if (nX1 < 0 || nY1 < 0) return;
+
+        // Consider frozen ranges not in main pane range as candidates
+        // for update
+        SCCOLROW nFreezeCol = mrViewData.GetLOKSheetFreezeIndex(true);
+        SCCOLROW nFreezeRow = mrViewData.GetLOKSheetFreezeIndex(false);
+        if ((nFreezeCol || nFreezeRow) && (nX1 || nY1))
+        {
+            // top left
+            if (nFreezeCol && nFreezeRow)
+                UpdateFormulaRange(0, 0, nFreezeCol, nFreezeRow);
+            // bottom left
+            if (nFreezeCol && nX1)
+                UpdateFormulaRange(0, nY1, nFreezeCol, nY2);
+            // top right
+            if (nFreezeRow && nY1)
+                UpdateFormulaRange(nX1, 0, nX2, nFreezeRow);
+        }
     }
     else
     {

Reply via email to