summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-04-04 16:01:57 +0200
committerGökay ŞATIR <gokaysatir@collabora.com>2022-04-05 16:46:38 +0200
commit1e75ae757ac1cb10bb70a00a272099a457639416 (patch)
treea10d3450e06e2444eca1c2d2b1a37856b74796e0
parent716522af100e572069c6600115a480d2036a2051 (diff)
sw lok: fix missing cache invalidation in SwRedlineTable::Insert()
The trouble is that the FillRects() call in SwRedlineTable::LOKRedlineNotification() builds a text portion list, but that's not yet correct, and later we don't build a text portion list as we already have one. Fix this similar to the frame size problem by invalidating the cache after we got our rectangles. Change-Id: Ida759be418bc3706810d9774e060d06143893bb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132521 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins (cherry picked from commit 81bcee9866661ee0558474467d83c0fa929e932c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132392 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Mert Tumer <mert.tumer@collabora.com> Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com>
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx39
-rw-r--r--sw/source/core/doc/docredln.cxx9
2 files changed, 48 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 7b02eb66a69e..8ac5fcc83e02 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -164,6 +164,7 @@ public:
void testBulletMultiDeleteInvalidation();
void testCondCollCopy();
void testMoveShapeHandle();
+ void testRedlinePortions();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -249,6 +250,7 @@ public:
CPPUNIT_TEST(testBulletMultiDeleteInvalidation);
CPPUNIT_TEST(testCondCollCopy);
CPPUNIT_TEST(testMoveShapeHandle);
+ CPPUNIT_TEST(testRedlinePortions);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3531,6 +3533,43 @@ void SwTiledRenderingTest::testCondCollCopy()
xTransferable->getTransferData(aFlavor);
}
+void SwTiledRenderingTest::testRedlinePortions()
+{
+ // Given a document with 3 portions: before insert redline (foo), the insert redline (ins) and after insert
+ // redline (bar):
+ SwXTextDocument* pXTextDocument = createDoc();
+ SwDocShell* pDocShell = pXTextDocument->GetDocShell();
+ SwView* pView = pDocShell->GetView();
+ pView->SetRedlineAuthor("first");
+ pDocShell->SetView(pView);
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->Insert("foo");
+ pDocShell->SetChangeRecording(true);
+ pWrtShell->Insert("ins");
+ pDocShell->SetChangeRecording(false);
+ pWrtShell->Insert("bar after");
+
+ // When deleting "fooinsbar":
+ pView->SetRedlineAuthor("second");
+ pDocShell->SetView(pView);
+ pWrtShell->SttEndDoc(/*bStt*/true);
+ pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, /*nCount=*/9, /*bBasicCall=*/false);
+ pDocShell->SetChangeRecording(true);
+ pWrtShell->Delete();
+
+ // Then make sure that the portion list is updated, so "bar" can be marked as deleted without
+ // marking " after" as well:
+ xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+ assertXPath(pXmlDoc, "//Text[1]", "Portion", "foo");
+ assertXPath(pXmlDoc, "//Text[2]", "Portion", "ins");
+ // Without the accompanying fix in place, this test would have failed width:
+ // - Expected: bar
+ // - Actual : bar after
+ // i.e. the portion list was outdated, even " after" was marked as deleted.
+ assertXPath(pXmlDoc, "//Text[3]", "Portion", "bar");
+ assertXPath(pXmlDoc, "//Text[4]", "Portion", " after");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 354aa058d9ed..51c9fd64f945 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -56,6 +56,7 @@
#include <txtfld.hxx>
#include <flowfrm.hxx>
+#include <txtfrm.hxx>
using namespace com::sun::star;
@@ -310,6 +311,14 @@ void lcl_LOKInvalidateFrames(const sw::BroadcastingModify& rMod, const SwRootFra
if (pPoint)
{
pTmpFrame->InvalidateSize();
+
+ // Also empty the text portion cache, so it gets rebuilt, taking the new redlines
+ // into account.
+ if (pTmpFrame->IsTextFrame())
+ {
+ auto pTextFrame = static_cast<SwTextFrame*>(pTmpFrame);
+ pTextFrame->ClearPara();
+ }
}
}
}