don't invalidate when switching tabs

Change-Id: If013bb2a2d4de32da21ef6a86cc2237c6e75c0e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162049
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
Caolán McNamara 2024-01-14 16:29:56 +00:00 committed by Michael Meeks
parent c6ce873777
commit 9f3ee2b27c
4 changed files with 38 additions and 26 deletions

View file

@ -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());
}

View file

@ -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 );

View file

@ -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();

View file

@ -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);
}