sc/qa/unit/tiledrendering/tiledrendering.cxx | 22 +++++----------------- sc/source/ui/inc/tabview.hxx | 1 + sc/source/ui/view/tabview3.cxx | 14 +++++++++++++- sc/source/ui/view/tabview5.cxx | 22 ++++++++++++++++------ 4 files changed, 35 insertions(+), 24 deletions(-)
New commits: commit 2004d0f616540d134845178cfe9f9e074131b3af Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Jan 14 16:29:56 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Feb 13 11:19:11 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> (cherry picked from commit 9f3ee2b27ceeab175fb865a55cfeabd66fbb128d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163294 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 85f9c235f450..c7d43a141a84 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1824,13 +1824,12 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testPageDownInvalidation) CPPUNIT_ASSERT_EQUAL(tools::Rectangle(15, 15, 1230, 225), aView1.m_aInvalidations[0]); } -CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSheetChangeInvalidation) +CPPUNIT_TEST_FIXTURE(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); @@ -1846,19 +1845,8 @@ CPPUNIT_TEST_FIXTURE(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); } @@ -1884,7 +1872,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testInsertDeletePageInvalidation) })); dispatchCommand(mxComponent, ".uno:Insert", aArgs); 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()); @@ -1896,7 +1884,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testInsertDeletePageInvalidation) })); dispatchCommand(mxComponent, ".uno:Remove", aArgs2); 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 93f1b60e5759..de8324898814 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -268,6 +268,7 @@ private: DECL_STATIC_LINK(ScTabView, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); void UpdateHighlightOverlay(); + void ImplTabChanged(bool bSameTabButMoved); protected: void UpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr, diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx index fb91cc886ef3..a2a6667b8f27 100644 --- a/sc/source/ui/view/tabview3.cxx +++ b/sc/source/ui/view/tabview3.cxx @@ -64,6 +64,7 @@ #include <markdata.hxx> #include <formula/FormulaCompiler.hxx> #include <comphelper/lok.hxx> +#include <comphelper/scopeguard.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <output.hxx> @@ -2069,7 +2070,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 c9b65bb58c8e..2ba41b775bd6 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 @@ -324,6 +334,11 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) break; } } +} + +void ScTabView::TabChanged( bool bSameTabButMoved ) +{ + ImplTabChanged(bSameTabButMoved); if (!comphelper::LibreOfficeKit::isActive()) return; @@ -339,11 +354,6 @@ void ScTabView::TabChanged( bool bSameTabButMoved ) ss << aDocSize.Width() << ", " << aDocSize.Height(); OString sRect(ss.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); }