diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-01 10:09:19 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-01 11:50:39 +0100 |
commit | e267fe1a3dffc39bf5076dd6413ed3b0e698378c (patch) | |
tree | 93e8b4cfd8aa45ec15db47987c3a9bd30124519d | |
parent | 83f0ec0ac179feb188fc0c9184d5c57c1870fde4 (diff) |
sw: don't repaint all text frames on selecting and deleting several bullets
This is similar to disabling bullets for a paragraph, but in this case
the text nodes are deleted as well.
It seems to me that both invalidations are only useful in the numberging
(e.g. Arabic) case, and not in the bullet case.
Change-Id: Ie03e2847e5e50d9464399f4ea0840910e43a663a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110240
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 38 | ||||
-rw-r--r-- | sw/source/core/docnode/nodes.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/inc/txtfrm.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 18 |
4 files changed, 60 insertions, 15 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index c82c4fe10dde..7157b7487539 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -151,6 +151,7 @@ public: void testExtTextInputReadOnly(); void testBulletDeleteInvalidation(); void testBulletNoNumInvalidation(); + void testBulletMultiDeleteInvalidation(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -227,6 +228,7 @@ public: CPPUNIT_TEST(testExtTextInputReadOnly); CPPUNIT_TEST(testBulletDeleteInvalidation); CPPUNIT_TEST(testBulletNoNumInvalidation); + CPPUNIT_TEST(testBulletMultiDeleteInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -3004,6 +3006,42 @@ void SwTiledRenderingTest::testBulletNoNumInvalidation() CPPUNIT_ASSERT(!aFirstTextRect.IsOver(m_aInvalidations)); } +void SwTiledRenderingTest::testBulletMultiDeleteInvalidation() +{ + // Given a document with 5 paragraphs: all are bulleted. + SwXTextDocument* pXTextDocument = createDoc(); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->StartAllAction(); + pWrtShell->BulletOn(); + pWrtShell->EndAllAction(); + // There is alredy an initial text node, so type 5 times, but split 4 times. + for (int i = 0; i < 4; ++i) + { + pWrtShell->Insert2("a"); + pWrtShell->SplitNode(); + } + pWrtShell->Insert2("a"); + // Go to the end of the 4th para. + pWrtShell->Up(/*bSelect=*/false); + pWrtShell->GetLayout()->PaintSwFrame(*pWrtShell->GetOut(), + pWrtShell->GetLayout()->getFrameArea()); + Scheduler::ProcessEventsToIdle(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + m_aInvalidations = tools::Rectangle(); + + // When selecting and deleting several bullets: select till the end of the 2nd para and delete. + pWrtShell->Up(/*bSelect=*/true, /*nCount=*/2); + pWrtShell->DelRight(); + + // 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/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 7a1d2bd07491..827604a9cfc4 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -43,6 +43,7 @@ #include <fmtftn.hxx> #include <docsh.hxx> +#include <txtfrm.hxx> typedef std::vector<SwStartNode*> SwStartNodePointers; @@ -227,8 +228,13 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz, } } else + { // if movement into the UndoNodes-array, update numbering - pTextNd->InvalidateNumRule(); + if (sw::HasNumberingWhichNeedsLayoutUpdate(*pTextNd)) + { + pTextNd->InvalidateNumRule(); + } + } pTextNd->RemoveFromList(); } @@ -1197,7 +1203,10 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes) m_pOutlineNodes->erase( pTextNd ); bUpdateOutline = true; } - pTextNd->InvalidateNumRule(); + if (sw::HasNumberingWhichNeedsLayoutUpdate(*pTextNd)) + { + pTextNd->InvalidateNumRule(); + } } else if( pCurrentNode->IsContentNode() ) static_cast<SwContentNode*>(pCurrentNode)->InvalidateNumRule(); diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index 389adb8c92ad..ff6086e1ac1f 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -144,6 +144,12 @@ bool IsMarkHintHidden(SwRootFrame const& rLayout, void RecreateStartTextFrames(SwTextNode & rNode); +/** + * Decides if rTextNode has a numbering which has layout-level values (e.g. Arabic, but not + * none or bullets). + */ +bool HasNumberingWhichNeedsLayoutUpdate(const SwTextNode& rTextNode); + } // namespace sw /// Represents the visualization of a paragraph. Typical upper is an diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index ee3f85c2a04e..8bb3aee07cc4 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -907,15 +907,7 @@ void CheckResetRedlineMergeFlag(SwTextNode & rNode, Recreate const eRecreateMerg } } -} // namespace - -namespace -{ -/** - * Decides if rTextNode has a numbering which has layout-level values (e.g. Arabic, but not - * none or bullets). - */ -bool NeedsRenumbering(const SwTextNode& rTextNode) +bool HasNumberingWhichNeedsLayoutUpdate(const SwTextNode& rTextNode) { const SwNodeNum* pNodeNum = rTextNode.GetNum(); if (!pNodeNum) @@ -946,7 +938,7 @@ bool NeedsRenumbering(const SwTextNode& rTextNode) return true; } } -} +} // namespace SwContentNode *SwTextNode::JoinNext() { @@ -1030,14 +1022,14 @@ SwContentNode *SwTextNode::JoinNext() rDoc.CorrAbs( aIdx, SwPosition( *this ), nOldLen, true ); } SwNode::Merge const eOldMergeFlag(pTextNode->GetRedlineMergeFlag()); - bool bOldNeedsRenumbering = NeedsRenumbering(*pTextNode); + bool bOldHasNumberingWhichNeedsLayoutUpdate = HasNumberingWhichNeedsLayoutUpdate(*pTextNode); rNds.Delete(aIdx); SetWrong( pList, false ); SetGrammarCheck( pList3, false ); SetSmartTags( pList2, false ); - if (bOldNeedsRenumbering || NeedsRenumbering(*this)) + if (bOldHasNumberingWhichNeedsLayoutUpdate || HasNumberingWhichNeedsLayoutUpdate(*this)) { // Repaint all text frames that belong to this numbering to avoid outdated generated // numbers. @@ -4870,7 +4862,7 @@ namespace { }); } - if (mbUpdateListCount && mrTextNode.IsInList() && NeedsRenumbering(mrTextNode)) + if (mbUpdateListCount && mrTextNode.IsInList() && HasNumberingWhichNeedsLayoutUpdate(mrTextNode)) { // Repaint all text frames that belong to this numbering to avoid outdated generated // numbers. |