diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-01-28 17:28:54 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-01-29 11:14:05 +0100 |
commit | a01b54995d3d7c73ab28bdb412d4d5bcdf9c887f (patch) | |
tree | 61e32ae2e3e896cf2ea7ad533fb8beeb5ed55891 /sw/qa | |
parent | e7cf5e1187c378b680fecefd0d3176de09c55bba (diff) |
sw: don't repaint all text frames on text node delete for bullet numberings
The intention of the InvalidateNumRule() call is probably to make sure
that generated number portions in e.g. Arabic numbering are up to date.
But this is not necessary for bullets and causes not needed
invalidations.
(cherry picked from commit 6de46444027d03b617d02b66434f626c5723501f)
Conflicts:
sw/qa/extras/tiledrendering/tiledrendering.cxx
Change-Id: Iad555727e5e2b069bbffae0e7650fb8c75a56770
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110124
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index d5d638e9b4ca..47c54f84e96d 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -50,6 +50,7 @@ #include <flddat.hxx> #include <basesh.hxx> #include <vcl/ITiledRenderable.hxx> +#include <rootfrm.hxx> static char const DATA_DIRECTORY[] = "/sw/qa/extras/tiledrendering/data/"; @@ -134,6 +135,7 @@ public: void testSpellOnlineRenderParameter(); void testTablePaintInvalidate(); void testExtTextInputReadOnly(); + void testBulletDeleteInvalidation(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -205,13 +207,17 @@ public: CPPUNIT_TEST(testSpellOnlineRenderParameter); CPPUNIT_TEST(testTablePaintInvalidate); CPPUNIT_TEST(testExtTextInputReadOnly); + CPPUNIT_TEST(testBulletDeleteInvalidation); CPPUNIT_TEST_SUITE_END(); private: SwXTextDocument* createDoc(const char* pName = nullptr); static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); + // First invalidation. tools::Rectangle m_aInvalidation; + /// Union of all invalidations. + tools::Rectangle m_aInvalidations; Size m_aDocumentSize; OString m_aTextSelection; bool m_bFound; @@ -285,17 +291,20 @@ void SwTiledRenderingTest::callbackImpl(int nType, const char* pPayload) { case LOK_CALLBACK_INVALIDATE_TILES: { + tools::Rectangle aInvalidation; + uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); + if (OString("EMPTY") == pPayload) + return; + CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); + aInvalidation.setX(aSeq[0].toInt32()); + aInvalidation.setY(aSeq[1].toInt32()); + aInvalidation.setWidth(aSeq[2].toInt32()); + aInvalidation.setHeight(aSeq[3].toInt32()); if (m_aInvalidation.IsEmpty()) { - uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(pPayload)); - if (OString("EMPTY") == pPayload) - return; - CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5); - m_aInvalidation.setX(aSeq[0].toInt32()); - m_aInvalidation.setY(aSeq[1].toInt32()); - m_aInvalidation.setWidth(aSeq[2].toInt32()); - m_aInvalidation.setHeight(aSeq[3].toInt32()); + m_aInvalidation = aInvalidation; } + m_aInvalidations.Union(aInvalidation); ++m_nInvalidations; } break; @@ -2826,6 +2835,38 @@ void SwTiledRenderingTest::testExtTextInputReadOnly() CPPUNIT_ASSERT(getParagraph(1)->getString().isEmpty()); } +void SwTiledRenderingTest::testBulletDeleteInvalidation() +{ + // Given a document with 3 paragraphs: first 2 is bulleted, the last is not. + SwXTextDocument* pXTextDocument = createDoc(); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->SplitNode(); + pWrtShell->Up(/*bSelect=*/false); + pWrtShell->StartAllAction(); + pWrtShell->BulletOn(); + pWrtShell->EndAllAction(); + pWrtShell->Insert2("a"); + pWrtShell->SplitNode(); + pWrtShell->Insert2("b"); + pWrtShell->Down(/*bSelect=*/false); + 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. + pWrtShell->DelLeft(); + + // 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(); |