sc/qa/unit/tiledrendering/tiledrendering.cxx |   26 +++++++-------------------
 sc/source/ui/inc/tabview.hxx                 |    2 ++
 sc/source/ui/view/tabview3.cxx               |   14 +++++++++++++-
 sc/source/ui/view/tabview5.cxx               |   22 ++++++++++++++++------
 4 files changed, 38 insertions(+), 26 deletions(-)

New commits:
commit 9f3ee2b27ceeab175fb865a55cfeabd66fbb128d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Jan 14 16:29:56 2024 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Mon Feb 12 21:36:55 2024 +0100

    don't invalidate when switching tabs
    
    Change-Id: If013bb2a2d4de32da21ef6a86cc2237c6e75c0e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162049
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 7ec0d730180d..7dc38facfa8e 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -141,7 +141,7 @@ public:
     void testVbaRangeCopyPaste();
     void testInvalidationLoop();
     void testPageDownInvalidation();
-    void testSheetChangeInvalidation();
+    void testSheetChangeNoInvalidation();
     void testInsertDeletePageInvalidation();
     void testGetRowColumnHeadersInvalidation();
     void testJumpHorizontallyInvalidation();
@@ -213,7 +213,7 @@ public:
     CPPUNIT_TEST(testVbaRangeCopyPaste);
     CPPUNIT_TEST(testInvalidationLoop);
     CPPUNIT_TEST(testPageDownInvalidation);
-    CPPUNIT_TEST(testSheetChangeInvalidation);
+    CPPUNIT_TEST(testSheetChangeNoInvalidation);
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST(testGetRowColumnHeadersInvalidation);
     CPPUNIT_TEST(testJumpHorizontallyInvalidation);
@@ -2011,13 +2011,12 @@ void ScTiledRenderingTest::testPageDownInvalidation()
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(15, 15, 1230, 225), 
aView1.m_aInvalidations[0]);
 }
 
-void ScTiledRenderingTest::testSheetChangeInvalidation()
+void ScTiledRenderingTest::testSheetChangeNoInvalidation()
 {
     const bool oldPartInInvalidation = 
comphelper::LibreOfficeKit::isPartInInvalidation();
     comphelper::LibreOfficeKit::setPartInInvalidation(true);
 
     ScModelObj* pModelObj = createDoc("two_sheets.ods");
-    ScDocument* pDoc = pModelObj->GetDocument();
     ScViewData* pViewData = ScDocShell::GetViewData();
     CPPUNIT_ASSERT(pViewData);
 
@@ -2033,19 +2032,8 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | 
KEY_MOD1);
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | 
KEY_MOD1);
     Scheduler::ProcessEventsToIdle();
-    CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
-    CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
-    const ScSheetLimits& rLimits = pDoc->GetSheetLimits();
-    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1280 * 
rLimits.GetMaxColCount(),
-                                          256 * rLimits.GetMaxRowCount()),
-                         aView1.m_aInvalidations[0]);
-    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), 
aView1.m_aInvalidations[1]);
-    CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsParts.size());
-    CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), 
aView1.m_aInvalidationsParts[0]);
-    CPPUNIT_ASSERT_EQUAL(pModelObj->getPart(), 
aView1.m_aInvalidationsParts[1]);
-    CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidationsMode.size());
-    CPPUNIT_ASSERT_EQUAL(pModelObj->getEditMode(), 
aView1.m_aInvalidationsMode[0]);
-    CPPUNIT_ASSERT_EQUAL(pModelObj->getEditMode(), 
aView1.m_aInvalidationsMode[1]);
+    // switching sheets should trigger no invalidations
+    CPPUNIT_ASSERT(!aView1.m_bInvalidateTiles);
     comphelper::LibreOfficeKit::setPartInInvalidation(oldPartInInvalidation);
 }
 
@@ -2072,7 +2060,7 @@ void 
ScTiledRenderingTest::testInsertDeletePageInvalidation()
     dispatchCommand(mxComponent, ".uno:Insert", aArgs);
     Scheduler::ProcessEventsToIdle();
     CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
-    CPPUNIT_ASSERT_EQUAL(size_t(6), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(size_t(2), aView1.m_aInvalidations.size());
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), 
aView1.m_aInvalidations[0]);
     CPPUNIT_ASSERT_EQUAL(2, pModelObj->getParts());
 
@@ -2085,7 +2073,7 @@ void 
ScTiledRenderingTest::testInsertDeletePageInvalidation()
     dispatchCommand(mxComponent, ".uno:Remove", aArgs2);
     Scheduler::ProcessEventsToIdle();
     CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
-    CPPUNIT_ASSERT_EQUAL(size_t(5), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), 
aView1.m_aInvalidations[0]);
     CPPUNIT_ASSERT_EQUAL(1, pModelObj->getParts());
 }
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index e6c68651804a..02aa2211589a 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -264,6 +264,8 @@ private:
 
     DECL_STATIC_LINK(ScTabView, InstallLOKNotifierHdl, void*, 
vcl::ILibreOfficeKitNotifier*);
 
+    void            ImplTabChanged(bool bSameTabButMoved);
+
 protected:
     void            UpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr,
                                         const SCROW* pPosY = nullptr );
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f30de4e3d121..7ffa5c0d0138 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -63,6 +63,7 @@
 #include <markdata.hxx>
 #include <formula/FormulaCompiler.hxx>
 #include <comphelper/lok.hxx>
+#include <comphelper/scopeguard.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <output.hxx>
 
@@ -2033,7 +2034,18 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool 
bExtendSelection, bool bSa
     SyncGridWindowMapModeFromDrawMapMode();
     SetNewVisArea();
 
-    PaintGrid();
+    // disable invalidations for kit during tab switching
+    {
+        ScTabViewShell* pViewShell = aViewData.GetViewShell();
+        SfxLokCallbackInterface* pCallback = 
pViewShell->getLibreOfficeKitViewCallback();
+        pViewShell->setLibreOfficeKitViewCallback(nullptr);
+        comphelper::ScopeGuard aOutputGuard(
+            [pViewShell, pCallback] {
+                pViewShell->setLibreOfficeKitViewCallback(pCallback);
+            });
+        PaintGrid();
+    }
+
     PaintTop();
     PaintLeft();
     PaintExtras();
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index dd3e057ada21..7111d354d6b5 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -52,6 +52,7 @@
 #include <vcl/settings.hxx>
 
 #include <comphelper/lok.hxx>
+#include <comphelper/scopeguard.hxx>
 #include <officecfg/Office/Calc.hxx>
 
 using namespace com::sun::star;
@@ -277,8 +278,17 @@ void ScTabView::DoAddWin( ScGridWindow* pWin )
     pWin->SetAutoSpellContext(mpSpellCheckCxt);
 }
 
-void ScTabView::TabChanged( bool bSameTabButMoved )
+void ScTabView::ImplTabChanged(bool bSameTabButMoved)
 {
+    // For kit ignore invalidations during tab change
+    ScTabViewShell* pViewShell = aViewData.GetViewShell();
+    SfxLokCallbackInterface* pCallback = 
pViewShell->getLibreOfficeKitViewCallback();
+    pViewShell->setLibreOfficeKitViewCallback(nullptr);
+    comphelper::ScopeGuard aOutputGuard(
+        [pViewShell, pCallback] {
+            pViewShell->setLibreOfficeKitViewCallback(pCallback);
+        });
+
     if (pDrawView)
     {
         DrawDeselectAll();      // end also text edit mode
@@ -327,6 +337,11 @@ void ScTabView::TabChanged( bool bSameTabButMoved )
             break;
         }
     }
+}
+
+void ScTabView::TabChanged( bool bSameTabButMoved )
+{
+    ImplTabChanged(bSameTabButMoved);
 
     if (!comphelper::LibreOfficeKit::isActive())
         return;
@@ -342,11 +357,6 @@ void ScTabView::TabChanged( bool bSameTabButMoved )
     ss << aDocSize.Width() << ", " << aDocSize.Height();
     OString sRect = ss.str().c_str();
     ScTabViewShell* pViewShell = aViewData.GetViewShell();
-
-    // Invalidate first
-    tools::Rectangle aRectangle(0, 0, 1000000000, 1000000000);
-    pViewShell->libreOfficeKitViewInvalidateTilesCallback(&aRectangle, 
aViewData.GetTabNo(), 0);
-
     ScModelObj* pModel = 
comphelper::getFromUnoTunnel<ScModelObj>(pViewShell->GetCurrentDocument());
     SfxLokHelper::notifyDocumentSizeChanged(pViewShell, sRect, pModel, false);
 }

Reply via email to