sc/qa/unit/tiledrendering/tiledrendering.cxx | 43 +++++++++++++++++++++++++++ sc/source/ui/view/tabview.cxx | 38 +++++++++++------------ 2 files changed, 62 insertions(+), 19 deletions(-)
New commits: commit bcb0dbe1ce6b871d1b7864fc59d74cafbd07b35a Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Thu Sep 26 11:28:53 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Thu Sep 26 19:45:21 2019 +0200 sc lok: Optimize invalidation triggered by getRowColumnHeaders() method Don't call a full invalidation, rather use invalidation only on the new area. Make sure that the invalidation is called first. Reviewed-on: https://gerrit.libreoffice.org/79494 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit e740aaf876edd58c1f5c5e17af2495cad36cfc27) Change-Id: I89d1c6342ed8e95fe738a876a76ca6feda031962 Reviewed-on: https://gerrit.libreoffice.org/79620 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 31457b92a15b..8c238fd6659d 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -1810,9 +1810,8 @@ void ScTiledRenderingTest::testGetRowColumnHeadersInvalidation() pModelObj->getRowColumnHeaders(tools::Rectangle(0, 15, 19650, 5400)); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); - 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(tools::Rectangle(26775, 0, 49725, 13005), aView1.m_aInvalidations[1]); + CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 49725, 13005), aView1.m_aInvalidations[0]); // Extend area top-to-bottom aView1.m_bInvalidateTiles = false; @@ -1820,9 +1819,8 @@ void ScTiledRenderingTest::testGetRowColumnHeadersInvalidation() pModelObj->getRowColumnHeaders(tools::Rectangle(0, 5400, 19650, 9800)); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); - 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(tools::Rectangle(0, 13005, 49725, 19380), aView1.m_aInvalidations[1]); + CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 13005, 49725, 19380), aView1.m_aInvalidations[0]); // Extend area left-to-right aView1.m_bInvalidateTiles = false; @@ -1830,9 +1828,8 @@ void ScTiledRenderingTest::testGetRowColumnHeadersInvalidation() pModelObj->getRowColumnHeaders(tools::Rectangle(5400, 5400, 25050, 9800)); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); - 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(tools::Rectangle(49725, 0, 75225, 19380), aView1.m_aInvalidations[1]); + CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size()); + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(49725, 0, 75225, 19380), aView1.m_aInvalidations[0]); } } diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 0e1ac5ec747b..f0bf950ff996 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -2558,14 +2558,6 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) SAL_INFO("sc.lok.header", "Row Header: a new height: " << aNewSize.Height()); if (pDocSh) { - // Provide size in the payload, so clients don't have to - // call lok::Document::getDocumentSize(). - std::stringstream ss; - ss << aNewSize.Width() << ", " << aNewSize.Height(); - OString sSize = ss.str().c_str(); - ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel); - // New area extended to the bottom of the sheet after last row // excluding overlapping area with aNewColArea tools::Rectangle aNewRowArea(0, aOldSize.getHeight(), aOldSize.getWidth(), aNewSize.getHeight()); @@ -2576,6 +2568,14 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) UpdateSelectionOverlay(); SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewRowArea.toString()); } + + // Provide size in the payload, so clients don't have to + // call lok::Document::getDocumentSize(). + std::stringstream ss; + ss << aNewSize.Width() << ", " << aNewSize.Height(); + OString sSize = ss.str().c_str(); + ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false); } } @@ -2700,17 +2700,6 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) if (pDocSh) { - if (aOldSize != aNewSize) - { - // Provide size in the payload, so clients don't have to - // call lok::Document::getDocumentSize(). - std::stringstream ss; - ss << aNewSize.Width() << ", " << aNewSize.Height(); - OString sSize = ss.str().c_str(); - ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); - SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel); - } - // New area extended to the right of the sheet after last column // including overlapping area with aNewRowArea tools::Rectangle aNewColArea(aOldSize.getWidth(), 0, aNewSize.getWidth(), aNewSize.getHeight()); @@ -2721,6 +2710,17 @@ OUString ScTabView::getRowColumnHeaders(const tools::Rectangle& rRectangle) UpdateSelectionOverlay(); SfxLokHelper::notifyInvalidation(aViewData.GetViewShell(), aNewColArea.toString()); } + + if (aOldSize != aNewSize) + { + // Provide size in the payload, so clients don't have to + // call lok::Document::getDocumentSize(). + std::stringstream ss; + ss << aNewSize.Width() << ", " << aNewSize.Height(); + OString sSize = ss.str().c_str(); + ScModelObj* pModel = ScModelObj::getImplementation(aViewData.GetViewShell()->GetCurrentDocument()); + SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false); + } } } commit 9a41f5a494c94670d669b7c4551688eca178ce7a Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Sat Sep 21 15:46:38 2019 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Thu Sep 26 19:45:00 2019 +0200 sc lok: Test invalidation triggered by getRowColumnHeaders() method Reviewed-on: https://gerrit.libreoffice.org/79493 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit 9c975823b82e6b64c3dff0b4347162e8d426b852) Change-Id: Ie9961688333b3ddd10562d62606dfe01b173534d Reviewed-on: https://gerrit.libreoffice.org/79619 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 9335b51b305e..31457b92a15b 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -105,6 +105,7 @@ public: void testPageDownInvalidation(); void testSheetChangeInvalidation(); void testInsertDeletePageInvalidation(); + void testGetRowColumnHeadersInvalidation(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -141,6 +142,7 @@ public: CPPUNIT_TEST(testPageDownInvalidation); CPPUNIT_TEST(testSheetChangeInvalidation); CPPUNIT_TEST(testInsertDeletePageInvalidation); + CPPUNIT_TEST(testGetRowColumnHeadersInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -1789,6 +1791,50 @@ void ScTiledRenderingTest::testInsertDeletePageInvalidation() CPPUNIT_ASSERT_EQUAL(1, pModelObj->getParts()); } +void ScTiledRenderingTest::testGetRowColumnHeadersInvalidation() +{ + comphelper::LibreOfficeKit::setActive(); + + ScModelObj* pModelObj = createDoc("empty.ods"); + ScViewData* pViewData = ScDocShell::GetViewData(); + CPPUNIT_ASSERT(pViewData); + + int nView1 = SfxLokHelper::getView(); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData)); + + SfxLokHelper::setView(nView1); + aView1.m_bInvalidateTiles = false; + aView1.m_aInvalidations.clear(); + pModelObj->getRowColumnHeaders(tools::Rectangle(0, 15, 19650, 5400)); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); + 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(tools::Rectangle(26775, 0, 49725, 13005), aView1.m_aInvalidations[1]); + + // Extend area top-to-bottom + aView1.m_bInvalidateTiles = false; + aView1.m_aInvalidations.clear(); + pModelObj->getRowColumnHeaders(tools::Rectangle(0, 5400, 19650, 9800)); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); + 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(tools::Rectangle(0, 13005, 49725, 19380), aView1.m_aInvalidations[1]); + + // Extend area left-to-right + aView1.m_bInvalidateTiles = false; + aView1.m_aInvalidations.clear(); + pModelObj->getRowColumnHeaders(tools::Rectangle(5400, 5400, 25050, 9800)); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT(aView1.m_bInvalidateTiles); + 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(tools::Rectangle(49725, 0, 75225, 19380), aView1.m_aInvalidations[1]); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits