[Libreoffice-commits] core.git: Branch 'feature/sc_lok_invalidation' - 6 commits - sc/qa sc/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 21 16:37:43 UTC 2019


 sc/qa/unit/tiledrendering/data/insert_delete_sheet.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx           |  140 +++++++++++++++++
 sc/source/ui/view/tabview.cxx                          |   38 ++--
 sc/source/ui/view/tabview3.cxx                         |   16 -
 4 files changed, 167 insertions(+), 27 deletions(-)

New commits:
commit e393add74cfec40178a78bbb7d50bfb64b8a6e64
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 21 16:44:32 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 21 16:44:32 2019 +0200

    sc lok: Optimize invalidation triggered by ScTabView::SetCursor() method
    
    Don't call a full invalidation, rather use invalidation only on the new
    area. Make sure that the invalidation is called first.
    
    Change-Id: Ibdcc71a81f852acbd40a710204540ebd8df77907

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a2f3e800f72e..59700cfccc9c 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1809,9 +1809,8 @@ void ScTiledRenderingTest::testJumpHorizontallyInvalidation()
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD2);
     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, 39525, 13005), aView1.m_aInvalidations[1]);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 39525, 13005), aView1.m_aInvalidations[0]);
 }
 
 void ScTiledRenderingTest::testJumpToLastRowInvalidation()
@@ -1833,9 +1832,8 @@ void ScTiledRenderingTest::testJumpToLastRowInvalidation()
     pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN | KEY_MOD1);
     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, 26775, 127500255), aView1.m_aInvalidations[1]);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 13005, 26775, 127500255), aView1.m_aInvalidations[0]);
 }
 
 }
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index c5228c7ab0a7..91d4a93ef3f6 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -399,14 +399,6 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
 
                 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 = comphelper::getUnoTunnelImplementation<ScModelObj>(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());
@@ -425,6 +417,14 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
                     {
                         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 = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+                    SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false);
                 }
             }
         }
commit 08168b342ccefea3e3dc2551a68be392a87a8af4
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 21 16:39:46 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 21 16:39:46 2019 +0200

    sc lok: Test invalidation triggered by jumping to the last row in the sheet
    
    Change-Id: I27e9a1cea465fab2c129754b2ebba978919c2bca

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index acd017773b54..a2f3e800f72e 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -104,6 +104,7 @@ public:
     void testInsertDeletePageInvalidation();
     void testGetRowColumnHeadersInvalidation();
     void testJumpHorizontallyInvalidation();
+    void testJumpToLastRowInvalidation();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -143,6 +144,7 @@ public:
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST(testGetRowColumnHeadersInvalidation);
     CPPUNIT_TEST(testJumpHorizontallyInvalidation);
+    CPPUNIT_TEST(testJumpToLastRowInvalidation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1812,6 +1814,30 @@ void ScTiledRenderingTest::testJumpHorizontallyInvalidation()
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(26775, 0, 39525, 13005), aView1.m_aInvalidations[1]);
 }
 
+void ScTiledRenderingTest::testJumpToLastRowInvalidation()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    ScModelObj* pModelObj = createDoc("empty.ods");
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    CPPUNIT_ASSERT(pViewData);
+
+    int nView1 = SfxLokHelper::getView();
+    ViewCallback aView1;
+    CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+    SfxLokHelper::setView(nView1);
+    aView1.m_bInvalidateTiles = false;
+    aView1.m_aInvalidations.clear();
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN | KEY_MOD1);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN | KEY_MOD1);
+    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, 26775, 127500255), aView1.m_aInvalidations[1]);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
commit b14a4958defd8e7759c968a886e1feb99d40eb6c
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 21 16:13:14 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 21 16:39:30 2019 +0200

    sc lok: Test invalidation triggered by jumping horizontally in the sheet
    
    Change-Id: Ia3d3b3f3020151939b8fb1cf48635303dc49892e

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 35e61c791db6..acd017773b54 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -103,6 +103,7 @@ public:
     void testSheetChangeInvalidation();
     void testInsertDeletePageInvalidation();
     void testGetRowColumnHeadersInvalidation();
+    void testJumpHorizontallyInvalidation();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -141,6 +142,7 @@ public:
     CPPUNIT_TEST(testSheetChangeInvalidation);
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST(testGetRowColumnHeadersInvalidation);
+    CPPUNIT_TEST(testJumpHorizontallyInvalidation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1783,6 +1785,33 @@ void ScTiledRenderingTest::testGetRowColumnHeadersInvalidation()
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(49725, 0, 75225, 19380), aView1.m_aInvalidations[0]);
 }
 
+void ScTiledRenderingTest::testJumpHorizontallyInvalidation()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    ScModelObj* pModelObj = createDoc("empty.ods");
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    CPPUNIT_ASSERT(pViewData);
+
+    int nView1 = SfxLokHelper::getView();
+    ViewCallback aView1;
+    CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+    SfxLokHelper::setView(nView1);
+    aView1.m_bInvalidateTiles = false;
+    aView1.m_aInvalidations.clear();
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | KEY_MOD2);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD2);
+    Scheduler::ProcessEventsToIdle();
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::PAGEDOWN | KEY_MOD2);
+    pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::PAGEDOWN | KEY_MOD2);
+    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, 39525, 13005), aView1.m_aInvalidations[1]);
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
commit 275ac5a643b0212d69b6fbf9b9ad493db06b68c3
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 21 15:48:44 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 21 15:50:59 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.
    
    Change-Id: I89d1c6342ed8e95fe738a876a76ca6feda031962

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index a22cca344966..35e61c791db6 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1761,9 +1761,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;
@@ -1771,9 +1770,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;
@@ -1781,9 +1779,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 5116fd17e6fc..8e83b17ed267 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2555,14 +2555,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 = comphelper::getUnoTunnelImplementation<ScModelObj>(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());
@@ -2573,6 +2565,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 = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+            SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false);
         }
     }
 
@@ -2697,17 +2697,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 = comphelper::getUnoTunnelImplementation<ScModelObj>(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());
@@ -2718,6 +2707,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 = comphelper::getUnoTunnelImplementation<ScModelObj>(aViewData.GetViewShell()->GetCurrentDocument());
+                SfxLokHelper::notifyDocumentSizeChanged(aViewData.GetViewShell(), sSize, pModel, false);
+            }
         }
     }
 
commit e536802c1ee8f9feacf3deb376b72620097d0fc8
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Sep 21 15:46:38 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Sep 21 15:46:38 2019 +0200

    sc lok: Test invalidation triggered by getRowColumnHeaders() method
    
    Change-Id: Ie9961688333b3ddd10562d62606dfe01b173534d

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 5c6d74541c81..a22cca344966 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -102,6 +102,7 @@ public:
     void testPageDownInvalidation();
     void testSheetChangeInvalidation();
     void testInsertDeletePageInvalidation();
+    void testGetRowColumnHeadersInvalidation();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -139,6 +140,7 @@ public:
     CPPUNIT_TEST(testPageDownInvalidation);
     CPPUNIT_TEST(testSheetChangeInvalidation);
     CPPUNIT_TEST(testInsertDeletePageInvalidation);
+    CPPUNIT_TEST(testGetRowColumnHeadersInvalidation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1741,6 +1743,49 @@ 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;
+    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);
commit ab74ca0373b20591db94a746d2f04fc9942850a9
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Sep 17 17:58:26 2019 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Sep 17 17:58:26 2019 +0200

    sc lok: Test invalidation after adding\removing sheet
    
    Change-Id: Id69f19a1170c04faae800b5ae7678ffe243263d6

diff --git a/sc/qa/unit/tiledrendering/data/insert_delete_sheet.ods b/sc/qa/unit/tiledrendering/data/insert_delete_sheet.ods
new file mode 100644
index 000000000000..b0ee4e005e48
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/insert_delete_sheet.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 000050262011..5c6d74541c81 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -101,6 +101,7 @@ public:
     void testInvalidationLoop();
     void testPageDownInvalidation();
     void testSheetChangeInvalidation();
+    void testInsertDeletePageInvalidation();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnSelections);
@@ -137,6 +138,7 @@ public:
     CPPUNIT_TEST(testInvalidationLoop);
     CPPUNIT_TEST(testPageDownInvalidation);
     CPPUNIT_TEST(testSheetChangeInvalidation);
+    CPPUNIT_TEST(testInsertDeletePageInvalidation);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1696,6 +1698,49 @@ void ScTiledRenderingTest::testSheetChangeInvalidation()
     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1310720, 268435456), aView1.m_aInvalidations[0]);
 }
 
+void ScTiledRenderingTest::testInsertDeletePageInvalidation()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    ScModelObj* pModelObj = createDoc("insert_delete_sheet.ods");
+    // the document has 1 sheet
+    CPPUNIT_ASSERT_EQUAL(1, pModelObj->getParts());
+    ScViewData* pViewData = ScDocShell::GetViewData();
+    CPPUNIT_ASSERT(pViewData);
+
+    int nView1 = SfxLokHelper::getView();
+    ViewCallback aView1;
+    CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+    SfxLokHelper::setView(nView1);
+    aView1.m_bInvalidateTiles = false;
+    aView1.m_aInvalidations.clear();
+
+    uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
+            { "Name", uno::Any(OUString("")) },
+            { "Index", uno::Any(sal_Int32(1)) }
+        }));
+    comphelper::dispatchCommand(".uno:Insert", aArgs);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
+    CPPUNIT_ASSERT_EQUAL(size_t(8), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), aView1.m_aInvalidations[0]);
+    CPPUNIT_ASSERT_EQUAL(2, pModelObj->getParts());
+
+    // Delete sheet
+    aView1.m_bInvalidateTiles = false;
+    aView1.m_aInvalidations.clear();
+    uno::Sequence<beans::PropertyValue> aArgs2( comphelper::InitPropertySequence({
+            { "Index", uno::Any(sal_Int32(1)) }
+        }));
+    comphelper::dispatchCommand(".uno:Remove", aArgs2);
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT(aView1.m_bInvalidateTiles);
+    CPPUNIT_ASSERT_EQUAL(size_t(5), aView1.m_aInvalidations.size());
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(0, 0, 1000000000, 1000000000), aView1.m_aInvalidations[0]);
+    CPPUNIT_ASSERT_EQUAL(1, pModelObj->getParts());
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);


More information about the Libreoffice-commits mailing list