summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-04-04 16:01:57 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-04-05 10:47:52 +0200
commit167c2156b4ceda708be367ccb916c1c3a5e40597 (patch)
treeb71fa0715db6baba8d2b0d562fdb9c70b6056b79 /sw
parentb7b517109c65757c87aa70b3f49dda18dfd8c1f8 (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. (cherry picked from commit 81bcee9866661ee0558474467d83c0fa929e932c) Change-Id: Ida759be418bc3706810d9774e060d06143893bb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132557 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-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 24e5876203e7..e59c8cccacf4 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -166,6 +166,7 @@ public:
void testBulletMultiDeleteInvalidation();
void testCondCollCopy();
void testMoveShapeHandle();
+ void testRedlinePortions();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -252,6 +253,7 @@ public:
CPPUNIT_TEST(testBulletMultiDeleteInvalidation);
CPPUNIT_TEST(testCondCollCopy);
CPPUNIT_TEST(testMoveShapeHandle);
+ CPPUNIT_TEST(testRedlinePortions);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3561,6 +3563,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 c6d469678fa3..35568a615581 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -57,6 +57,7 @@
#include <txtfld.hxx>
#include <flowfrm.hxx>
+#include <txtfrm.hxx>
using namespace com::sun::star;
@@ -286,6 +287,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();
+ }
}
}
}