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-04 19:45:58 +0200
commit81bcee9866661ee0558474467d83c0fa929e932c (patch)
treed3b50492bddcd94a3429ece172b5a13795eae989 /sw
parentcec215e0e3adaf26c89c4ffbaa53f87481772f0c (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
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 a5083731c5a3..9d603643e652 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:
@@ -3554,6 +3556,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, "//SwParaPortion/SwLineLayout/SwLinePortion[1]", "portion", "foo");
+ assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwLinePortion[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, "//SwParaPortion/SwLineLayout/SwLinePortion[3]", "portion", "bar");
+ assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/SwLinePortion[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 428f67026f29..107d6f9afc95 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -58,6 +58,7 @@
#include <txtfld.hxx>
#include <flowfrm.hxx>
+#include <txtfrm.hxx>
using namespace com::sun::star;
@@ -287,6 +288,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();
+ }
}
}
}