sw/qa/extras/tiledrendering/tiledrendering.cxx |   39 +++++++++++++++++++++++++
 sw/source/core/doc/docredln.cxx                |    9 +++++
 2 files changed, 48 insertions(+)

New commits:
commit 1e75ae757ac1cb10bb70a00a272099a457639416
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Mon Apr 4 16:01:57 2022 +0200
Commit:     Gökay ŞATIR <gokaysa...@collabora.com>
CommitDate: Tue Apr 5 16:46:38 2022 +0200

    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 <vmik...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 81bcee9866661ee0558474467d83c0fa929e932c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132392
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>
    Reviewed-by: Gökay ŞATIR <gokaysa...@collabora.com>

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();
+                }
             }
         }
     }

Reply via email to