sw/qa/extras/tiledrendering/tiledrendering.cxx | 38 +++++++++++++++++++++++++ sw/source/core/docnode/nodes.cxx | 13 +++++++- sw/source/core/inc/txtfrm.hxx | 6 +++ sw/source/core/txtnode/ndtxt.cxx | 18 +++-------- 4 files changed, 60 insertions(+), 15 deletions(-)
New commits: commit ca9a84f82d2b2790a0ffc49d1e0157ff93852817 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Feb 1 10:09:19 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Feb 1 13:56:28 2021 +0100 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. (cherry picked from commit e267fe1a3dffc39bf5076dd6413ed3b0e698378c) Change-Id: Ie03e2847e5e50d9464399f4ea0840910e43a663a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110247 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 732ebc7bcf09..4b9e133c3a52 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -137,6 +137,7 @@ public: void testExtTextInputReadOnly(); void testBulletDeleteInvalidation(); void testBulletNoNumInvalidation(); + void testBulletMultiDeleteInvalidation(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -210,6 +211,7 @@ public: CPPUNIT_TEST(testExtTextInputReadOnly); CPPUNIT_TEST(testBulletDeleteInvalidation); CPPUNIT_TEST(testBulletNoNumInvalidation); + CPPUNIT_TEST(testBulletMultiDeleteInvalidation); CPPUNIT_TEST_SUITE_END(); private: @@ -2901,6 +2903,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 2a2bef4f4488..26efe5401038 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; @@ -229,8 +230,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(); } @@ -1193,7 +1199,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 6bf44794cbaf..06676950700a 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 b511c00f98e7..5b662a990036 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -947,15 +947,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) @@ -986,7 +978,7 @@ bool NeedsRenumbering(const SwTextNode& rTextNode) return true; } } -} +} // namespace SwContentNode *SwTextNode::JoinNext() { @@ -1070,14 +1062,14 @@ SwContentNode *SwTextNode::JoinNext() pDoc->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. @@ -4911,7 +4903,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. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits