diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-01-29 09:44:04 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-01-29 20:20:32 +0100 |
commit | 46db5807b88547a7219db78f38932114ec483167 (patch) | |
tree | 057c56b808edcc6e5a1c7d387629864496b2cc64 | |
parent | b7f26d40a8223ea02845b415a724f2a5d3e94022 (diff) |
sw: don't repaint all text frames on turning off a bullet for bullet numberings
This is similar to the text node deletion case, but here no text is
deleted, just a text node with bullet numbering is turned into one
without a numbering.
Again, it is not necessary to repaint all text frames of the numbering,
since the bullet char is the same for all nodes (unlike e.g. Arabic
numbering).
(cherry picked from commit ccabb67d77e2bcece42434f51cf6d84d393d567c)
Change-Id: Ieb071031ca5ce0421c4120c4c89089af6c811848
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110160
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 4 |
2 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 47c54f84e96d..732ebc7bcf09 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -136,6 +136,7 @@ public: void testTablePaintInvalidate(); void testExtTextInputReadOnly(); void testBulletDeleteInvalidation(); + void testBulletNoNumInvalidation(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -208,6 +209,7 @@ public: CPPUNIT_TEST(testTablePaintInvalidate); CPPUNIT_TEST(testExtTextInputReadOnly); CPPUNIT_TEST(testBulletDeleteInvalidation); + CPPUNIT_TEST(testBulletNoNumInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -2867,6 +2869,38 @@ void SwTiledRenderingTest::testBulletDeleteInvalidation() CPPUNIT_ASSERT(!aFirstTextRect.IsOver(m_aInvalidations)); } +void SwTiledRenderingTest::testBulletNoNumInvalidation() +{ + // Given a document with 3 paragraphs: all are bulleted. + SwXTextDocument* pXTextDocument = createDoc(); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->StartAllAction(); + pWrtShell->BulletOn(); + pWrtShell->EndAllAction(); + pWrtShell->Insert2("a"); + pWrtShell->SplitNode(); + pWrtShell->Insert2("b"); + pWrtShell->SplitNode(); + pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(), + pWrtShell->GetLayout()->getFrameArea()); + Scheduler::ProcessEventsToIdle(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + m_aInvalidations = tools::Rectangle(); + + // When pressing backspace in the last paragraph to turn bullets off. + pWrtShell->StartAllAction(); + pWrtShell->NumOrNoNum(/*bDelete=*/false); + pWrtShell->EndAllAction(); + + // Then the first paragraph should not be invalidated. + SwRootFrame* pRoot = pWrtShell->GetLayout(); + SwFrame* pPage = pRoot->GetLower(); + SwFrame* pBody = pPage->GetLower(); + SwFrame* pFirstText = pBody->GetLower(); + tools::Rectangle aFirstTextRect = pFirstText->getFrameArea().SVRect(); + CPPUNIT_ASSERT(!aFirstTextRect.IsOver(m_aInvalidations)); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index bbb9630db144..b511c00f98e7 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4911,8 +4911,10 @@ namespace { }); } - if ( mbUpdateListCount && mrTextNode.IsInList() ) + if (mbUpdateListCount && mrTextNode.IsInList() && NeedsRenumbering(mrTextNode)) { + // Repaint all text frames that belong to this numbering to avoid outdated generated + // numbers. mrTextNode.DoNum( [](SwNodeNum & rNum) { rNum.InvalidateAndNotifyTree(); }); } |